Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/webservice/service_user_settings.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00025 require_once('../../config.php');
00026 require_once($CFG->libdir . '/adminlib.php');
00027 require_once($CFG->dirroot . '/webservice/lib.php');
00028 require_once($CFG->dirroot . '/' . $CFG->admin . '/webservice/forms.php');
00029 
00030 $serviceid = required_param('serviceid', PARAM_INT);
00031 $userid = required_param('userid', PARAM_INT);
00032 
00033 admin_externalpage_setup('externalserviceusersettings');
00034 
00035 //define nav bar
00036 $PAGE->set_url('/' . $CFG->admin . '/webservice/service_user_settings.php',
00037         array('id' => $serviceid, 'userid'  => $userid));
00038 $node = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING);
00039 if ($node) {
00040     $node->make_active();
00041 }
00042 $PAGE->navbar->add(get_string('serviceusers', 'webservice'),
00043         new moodle_url('/' . $CFG->admin . '/webservice/service_users.php', array('id' => $serviceid)));
00044 $PAGE->navbar->add(get_string('serviceusersettings', 'webservice'));
00045 
00046 $formaction = new moodle_url('', array('id' => $serviceid, 'userid' => $userid));
00047 $returnurl = new moodle_url('/' . $CFG->admin . '/webservice/service_users.php', array('id' => $serviceid));
00048 
00049 $webservicemanager = new webservice();
00050 $serviceuser = $webservicemanager->get_ws_authorised_user($serviceid, $userid);
00051 $usersettingsform = new external_service_authorised_user_settings_form($formaction, $serviceuser);
00052 $settingsformdata = $usersettingsform->get_data();
00053 
00054 if ($usersettingsform->is_cancelled()) {
00055     redirect($returnurl);
00056 
00057 } else if (!empty($settingsformdata) and confirm_sesskey()) {
00059     $settingsformdata = (object)$settingsformdata;
00060 
00061     $serviceuserinfo = new stdClass();
00062     $serviceuserinfo->id = $serviceuser->serviceuserid;
00063     $serviceuserinfo->iprestriction = $settingsformdata->iprestriction;
00064     $serviceuserinfo->validuntil = $settingsformdata->validuntil;
00065 
00066     $webservicemanager->update_ws_authorised_user($serviceuserinfo);
00067 
00068     //TODO: assign capability
00069 
00070     //display successful notification
00071     $notification = $OUTPUT->notification(get_string('usersettingssaved', 'webservice'), 'success');
00072 }
00073 
00074 echo $OUTPUT->header();
00075 echo $OUTPUT->heading(get_string('serviceusersettings', 'webservice'), 3, 'main');
00076 if (!empty($notification)) {
00077     echo $notification;
00078 }
00079 $usersettingsform->display();
00080 
00081 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations