mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
Merge branch 'MDL-35998' of git://github.com/mouneyrac/moodle
Conflicts: version.php
This commit is contained in:
commit
5252ec82a2
@ -245,6 +245,15 @@ if ($hassiteconfig) {
|
||||
|
||||
/// Web services
|
||||
$ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
|
||||
// Mobile
|
||||
$temp = new admin_settingpage('mobile', new lang_string('mobile','admin'), 'moodle/site:config', false);
|
||||
$enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
|
||||
$enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
|
||||
$temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
|
||||
new lang_string('enablemobilewebservice', 'admin'),
|
||||
new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
|
||||
$temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'admin'), new lang_string('configmobilecssurl','admin'), '', PARAM_URL));
|
||||
$ADMIN->add('webservicesettings', $temp);
|
||||
/// overview page
|
||||
$temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
|
||||
$temp->add(new admin_setting_webservicesoverview());
|
||||
@ -253,9 +262,9 @@ if ($hassiteconfig) {
|
||||
$ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
|
||||
/// manage service
|
||||
$temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
|
||||
$enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
|
||||
$enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
|
||||
$temp->add(new admin_setting_enablemobileservice('enablemobilewebservice', new lang_string('enablemobilewebservice', 'admin'), new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
|
||||
$temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
|
||||
new lang_string('enablemobilewebservice', 'admin'),
|
||||
new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
|
||||
$temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
|
||||
$temp->add(new admin_setting_manageexternalservices());
|
||||
$ADMIN->add('webservicesettings', $temp);
|
||||
|
@ -258,6 +258,7 @@ $string['configminpasswordlength'] = 'Passwords must be at least these many char
|
||||
$string['configminpasswordlower'] = 'Passwords must have at least these many lower case letters.';
|
||||
$string['configminpasswordnonalphanum'] = 'Passwords must have at least these many non-alphanumeric characters.';
|
||||
$string['configminpasswordupper'] = 'Passwords must have at least these many upper case letters.';
|
||||
$string['configmobilecssurl'] = 'A CSS file to customise your mobile app interface.';
|
||||
$string['configmodchooserdefault'] = 'Should the activity chooser be presented to users by default?';
|
||||
$string['configmycoursesperpage'] = 'Maximum number of courses to display in any list of a user\'s own courses';
|
||||
$string['configmymoodleredirect'] = 'This setting forces redirects to /my on login for non-admins and replaces the top level site navigation with /my';
|
||||
@ -690,6 +691,8 @@ $string['mnetrestore_extusers_admin'] = '<strong>Note:</strong> This backup file
|
||||
$string['mnetrestore_extusers_mismatch'] = '<strong>Note:</strong> This backup file apparently originates from a different Moodle installation and contains remote Moodle Network user accounts that may fail to restore. This operation is unsupported. If you are certain that it was created on this Moodle installation, or you can ensure that all the needed Moodle Network Hosts are configured, you may want to still try the restore.';
|
||||
$string['mnetrestore_extusers_noadmin'] = '<strong>Note:</strong> This backup file seems to come from a different Moodle installation and contains remote Moodle Network user accounts. You are not allowed to execute this type of restore. Contact the administrator of the site or, alternatively, restore this course without any user information (modules, files...)';
|
||||
$string['mnetrestore_extusers_switchuserauth'] = 'Remote Moodle Network user {$a->username} (coming from {$a->mnethosturl}) switched to local {$a->auth} authenticated user.';
|
||||
$string['mobile'] = 'Mobile';
|
||||
$string['mobilecssurl'] = 'CSS';
|
||||
$string['modchooserdefault'] = 'Activity chooser default';
|
||||
$string['modeditdefaults'] = 'Default values for activity settings';
|
||||
$string['modsettings'] = 'Manage activities';
|
||||
|
@ -6753,16 +6753,21 @@ class admin_setting_managerepository extends admin_setting {
|
||||
*/
|
||||
class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
|
||||
|
||||
private $xmlrpcuse; //boolean: true => capability 'webservice/xmlrpc:use' is set for authenticated user role
|
||||
/** @var boolean True means that the capability 'webservice/xmlrpc:use' is set for authenticated user role */
|
||||
private $xmlrpcuse;
|
||||
/** @var boolean True means that the capability 'webservice/rest:use' is set for authenticated user role */
|
||||
private $restuse;
|
||||
|
||||
/**
|
||||
* Return true if Authenticated user role has the capability 'webservice/xmlrpc:use', otherwise false
|
||||
* Return true if Authenticated user role has the capability 'webservice/xmlrpc:use' and 'webservice/rest:use', otherwise false.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_xmlrpc_cap_allowed() {
|
||||
private function is_protocol_cap_allowed() {
|
||||
global $DB, $CFG;
|
||||
|
||||
//if the $this->xmlrpcuse variable is not set, it needs to be set
|
||||
// We keep xmlrpc enabled for backward compatibility.
|
||||
// If the $this->xmlrpcuse variable is not set, it needs to be set.
|
||||
if (empty($this->xmlrpcuse) and $this->xmlrpcuse!==false) {
|
||||
$params = array();
|
||||
$params['permission'] = CAP_ALLOW;
|
||||
@ -6771,20 +6776,29 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
|
||||
$this->xmlrpcuse = $DB->record_exists('role_capabilities', $params);
|
||||
}
|
||||
|
||||
return $this->xmlrpcuse;
|
||||
// If the $this->restuse variable is not set, it needs to be set.
|
||||
if (empty($this->restuse) and $this->restuse!==false) {
|
||||
$params = array();
|
||||
$params['permission'] = CAP_ALLOW;
|
||||
$params['roleid'] = $CFG->defaultuserroleid;
|
||||
$params['capability'] = 'webservice/rest:use';
|
||||
$this->restuse = $DB->record_exists('role_capabilities', $params);
|
||||
}
|
||||
|
||||
return ($this->xmlrpcuse && $this->restuse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'webservice/xmlrpc:use' to the Authenticated user role (allow or not)
|
||||
* Set the 'webservice/xmlrpc:use'/'webservice/rest:use' to the Authenticated user role (allow or not)
|
||||
* @param type $status true to allow, false to not set
|
||||
*/
|
||||
private function set_xmlrpc_cap($status) {
|
||||
private function set_protocol_cap($status) {
|
||||
global $CFG;
|
||||
if ($status and !$this->is_xmlrpc_cap_allowed()) {
|
||||
if ($status and !$this->is_protocol_cap_allowed()) {
|
||||
//need to allow the cap
|
||||
$permission = CAP_ALLOW;
|
||||
$assign = true;
|
||||
} else if (!$status and $this->is_xmlrpc_cap_allowed()){
|
||||
} else if (!$status and $this->is_protocol_cap_allowed()){
|
||||
//need to disallow the cap
|
||||
$permission = CAP_INHERIT;
|
||||
$assign = true;
|
||||
@ -6792,6 +6806,7 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
|
||||
if (!empty($assign)) {
|
||||
$systemcontext = get_system_context();
|
||||
assign_capability('webservice/xmlrpc:use', $permission, $CFG->defaultuserroleid, $systemcontext->id, true);
|
||||
assign_capability('webservice/rest:use', $permission, $CFG->defaultuserroleid, $systemcontext->id, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6838,7 +6853,7 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
|
||||
require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
$webservicemanager = new webservice();
|
||||
$mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
|
||||
if ($mobileservice->enabled and $this->is_xmlrpc_cap_allowed()) {
|
||||
if ($mobileservice->enabled and $this->is_protocol_cap_allowed()) {
|
||||
return $this->config_read($this->name); //same as returning 1
|
||||
} else {
|
||||
return 0;
|
||||
@ -6864,6 +6879,7 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
|
||||
require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
$webservicemanager = new webservice();
|
||||
|
||||
$updateprotocol = false;
|
||||
if ((string)$data === $this->yes) {
|
||||
//code run when enable mobile web service
|
||||
//enable web service systeme if necessary
|
||||
@ -6879,11 +6895,20 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
|
||||
|
||||
if (!in_array('xmlrpc', $activeprotocols)) {
|
||||
$activeprotocols[] = 'xmlrpc';
|
||||
$updateprotocol = true;
|
||||
}
|
||||
|
||||
if (!in_array('rest', $activeprotocols)) {
|
||||
$activeprotocols[] = 'rest';
|
||||
$updateprotocol = true;
|
||||
}
|
||||
|
||||
if ($updateprotocol) {
|
||||
set_config('webserviceprotocols', implode(',', $activeprotocols));
|
||||
}
|
||||
|
||||
//allow xml-rpc:use capability for authenticated user
|
||||
$this->set_xmlrpc_cap(true);
|
||||
$this->set_protocol_cap(true);
|
||||
|
||||
} else {
|
||||
//disable web service system if no other services are enabled
|
||||
@ -6898,11 +6923,21 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
|
||||
$protocolkey = array_search('xmlrpc', $activeprotocols);
|
||||
if ($protocolkey !== false) {
|
||||
unset($activeprotocols[$protocolkey]);
|
||||
$updateprotocol = true;
|
||||
}
|
||||
|
||||
$protocolkey = array_search('rest', $activeprotocols);
|
||||
if ($protocolkey !== false) {
|
||||
unset($activeprotocols[$protocolkey]);
|
||||
$updateprotocol = true;
|
||||
}
|
||||
|
||||
if ($updateprotocol) {
|
||||
set_config('webserviceprotocols', implode(',', $activeprotocols));
|
||||
}
|
||||
|
||||
//disallow xml-rpc:use capability for authenticated user
|
||||
$this->set_xmlrpc_cap(false);
|
||||
$this->set_protocol_cap(false);
|
||||
}
|
||||
|
||||
//disable the mobile service
|
||||
|
@ -30,7 +30,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2012110201.01; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2012110201.02; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
@ -87,6 +87,7 @@ class core_webservice_external extends external_api {
|
||||
'firstname' => $USER->firstname,
|
||||
'lastname' => $USER->lastname,
|
||||
'fullname' => fullname($USER),
|
||||
'lang' => current_language(),
|
||||
'userid' => $USER->id,
|
||||
'userpictureurl' => $profileimageurl->out(false)
|
||||
);
|
||||
@ -155,6 +156,9 @@ class core_webservice_external extends external_api {
|
||||
|
||||
$siteinfo['functions'] = $availablefunctions;
|
||||
|
||||
// Mobile CSS theme and alternative login url
|
||||
$siteinfo['mobilecssurl'] = get_config('admin', 'mobilecssurl');
|
||||
|
||||
return $siteinfo;
|
||||
}
|
||||
|
||||
@ -172,6 +176,7 @@ class core_webservice_external extends external_api {
|
||||
'firstname' => new external_value(PARAM_TEXT, 'first name'),
|
||||
'lastname' => new external_value(PARAM_TEXT, 'last name'),
|
||||
'fullname' => new external_value(PARAM_TEXT, 'user full name'),
|
||||
'lang' => new external_value(PARAM_LANG, 'user language'),
|
||||
'userid' => new external_value(PARAM_INT, 'user id'),
|
||||
'siteurl' => new external_value(PARAM_RAW, 'site url'),
|
||||
'userpictureurl' => new external_value(PARAM_URL, 'the user profile picture.
|
||||
@ -191,7 +196,8 @@ class core_webservice_external extends external_api {
|
||||
'downloadfiles' => new external_value(PARAM_INT, '1 if users are allowed to download files, 0 if not',
|
||||
VALUE_OPTIONAL),
|
||||
'release' => new external_value(PARAM_TEXT, 'Moodle release number', VALUE_OPTIONAL),
|
||||
'version' => new external_value(PARAM_TEXT, 'Moodle version number', VALUE_OPTIONAL)
|
||||
'version' => new external_value(PARAM_TEXT, 'Moodle version number', VALUE_OPTIONAL),
|
||||
'mobilecssurl' => new external_value(PARAM_URL, 'Mobile custom CSS theme', VALUE_OPTIONAL)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -80,10 +80,12 @@ class core_webservice_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals('johnd', $siteinfo['username']);
|
||||
$this->assertEquals('John', $siteinfo['firstname']);
|
||||
$this->assertEquals('Doe', $siteinfo['lastname']);
|
||||
$this->assertEquals(current_language(), $siteinfo['lang']);
|
||||
$this->assertEquals($USER->id, $siteinfo['userid']);
|
||||
$this->assertEquals(true, $siteinfo['downloadfiles']);
|
||||
$this->assertEquals($CFG->release, $siteinfo['release']);
|
||||
$this->assertEquals($CFG->version, $siteinfo['version']);
|
||||
$this->assertEquals(get_config('admin', 'mobilecssurl'), $siteinfo['mobilecssurl']);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user