Skip to content

Commit

Permalink
MDL-33060 remove some get_string from exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mouneyrac committed May 18, 2012
1 parent 71d7bc3 commit 96d3b93
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 63 deletions.
12 changes: 4 additions & 8 deletions course/externallib.php
Expand Up @@ -302,8 +302,7 @@ public static function get_courses($options) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $course->id;
throw new moodle_exception(
get_string('errorcoursecontextnotvalid', 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid', 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:view', $context);

Expand Down Expand Up @@ -520,23 +519,20 @@ public static function create_courses($courses) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->catid = $course['categoryid'];
throw new moodle_exception(
get_string('errorcatcontextnotvalid', 'webservice', $exceptionparam));
throw new moodle_exception('errorcatcontextnotvalid', 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:create', $context);

// Make sure lang is valid
if (key_exists('lang', $course) and empty($availablelangs[$course['lang']])) {
throw new moodle_exception(
get_string('errorinvalidparam', 'webservice', 'lang'));
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'lang');
}

// Make sure theme is valid
if (key_exists('forcetheme', $course)) {
if (!empty($CFG->allowcoursethemes)) {
if (empty($availablethemes[$course['forcetheme']])) {
throw new moodle_exception(
get_string('errorinvalidparam', 'webservice', 'forcetheme'));
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'forcetheme');
} else {
$course['theme'] = $course['forcetheme'];
}
Expand Down
4 changes: 2 additions & 2 deletions enrol/externallib.php
Expand Up @@ -207,7 +207,7 @@ public static function get_enrolled_users($courseid, $options) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $params['courseid'];
throw new moodle_exception(get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}

if ($courseid == SITEID) {
Expand Down Expand Up @@ -543,7 +543,7 @@ public static function get_enrolled_users($courseid, $withcapability = null, $gr
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $params['courseid'];
throw new moodle_exception(get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}

if ($courseid == SITEID) {
Expand Down
21 changes: 7 additions & 14 deletions group/externallib.php
Expand Up @@ -95,8 +95,7 @@ public static function create_groups($groups) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $group->courseid;
throw new moodle_exception(
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:managegroups', $context);

Expand Down Expand Up @@ -168,8 +167,7 @@ public static function get_groups($groupids) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $group->courseid;
throw new moodle_exception(
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:managegroups', $context);

Expand Down Expand Up @@ -231,8 +229,7 @@ public static function get_course_groups($courseid) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $params['courseid'];
throw new moodle_exception(
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:managegroups', $context);

Expand Down Expand Up @@ -310,8 +307,7 @@ public static function delete_groups($groupids) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $group->courseid;
throw new moodle_exception(
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:managegroups', $context);

Expand Down Expand Up @@ -369,8 +365,7 @@ public static function get_group_members($groupids) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $group->courseid;
throw new moodle_exception(
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:managegroups', $context);

Expand Down Expand Up @@ -450,8 +445,7 @@ public static function add_group_members($members) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $group->courseid;
throw new moodle_exception(
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:managegroups', $context);

Expand Down Expand Up @@ -529,8 +523,7 @@ public static function delete_group_members($members) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $group->courseid;
throw new moodle_exception(
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
require_capability('moodle/course:managegroups', $context);

Expand Down
6 changes: 0 additions & 6 deletions lang/en/webservice.php
Expand Up @@ -25,7 +25,6 @@

$string['accessexception'] = 'Access control exception';
$string['actwebserviceshhdr'] = 'Active web service protocols';
$string['accesstofunctionnotallowed'] = 'Access to the function {$a}() is not allowed. Please check if a service containing the function is enabled. In the service settings: if the service is restricted check that the user is listed. Still in the service settings check for IP restriction or if the service requires a capability.';
$string['addaservice'] = 'Add service';
$string['addcapabilitytousers'] = 'Check users capability';
$string['addcapabilitytousersdescription'] = 'Users should have two capabilities - webservice:createtoken and a capability matching the protocols used, for example webservice/rest:use, webservice/soap:use. To achieve this, create a web services role with the appropriate capabilities allowed and assign it to the web services user as a system role.';
Expand Down Expand Up @@ -75,7 +74,6 @@
$string['enableprotocolsdescription'] = 'At least one protocol should be enabled. For security reasons, only protocols that are to be used should be enabled.';
$string['enablews'] = 'Enable web services';
$string['enablewsdescription'] = 'Web services must be enabled in Advanced features.';
$string['enabledirectdownload'] = 'Web service file downloading must be enabled in external service settings';
$string['entertoken'] = 'Enter a security key/token:';
$string['error'] = 'Error: {$a}';
$string['errorcatcontextnotvalid'] = 'You cannot execute functions in the category context (category id:{$a->catid}). The context error message was: {$a->message}';
Expand Down Expand Up @@ -106,7 +104,6 @@
$string['invalidiptoken'] = 'Invalid token - your IP is not supported';
$string['invalidtimedtoken'] = 'Invalid token - token expired';
$string['invalidtoken'] = 'Invalid token - token not found';
$string['invalidtokensession'] = 'Invalid session based token - session not found or expired';
$string['iprestriction'] = 'IP restriction';
$string['iprestriction_help'] = 'The user will need to call web service from the listed IPs.';
$string['key'] = 'Key';
Expand Down Expand Up @@ -136,7 +133,6 @@
$string['potusersmatching'] = 'Not authorised users matching';
$string['print'] = 'Print all';
$string['protocol'] = 'Protocol';
$string['protocolnotallowed'] = 'You are not allowed to use the {$a} protocol (missing capability: webservice/{$a}:use)';
$string['removefunction'] = 'Remove';
$string['removefunctionconfirm'] = 'Do you really want to remove function "{$a->function}" from service "{$a->service}"?';
$string['requireauthentication'] = 'This method requires authentication with xxx permission.';
Expand Down Expand Up @@ -205,8 +201,6 @@
$string['wsaccessusernologin'] = 'Refused web service access for nologin authentication username: {$a}';
$string['wsaccessusersuspended'] = 'Refused web service access for suspended username: {$a}';
$string['wsaccessuserunconfirmed'] = 'Refused web service access for unconfirmed username: {$a}';
$string['wsauthmissing'] = 'The web service authentication plugin is missing.';
$string['wsauthnotenabled'] = 'The web service authentication plugin is disabled.';
$string['wsclientdoc'] = 'Moodle web service client documentation';
$string['wsdocapi'] = 'API Documentation';
$string['wsdocumentation'] = 'Web service documentation';
Expand Down

0 comments on commit 96d3b93

Please sign in to comment.