Skip to content
Browse files

MDL-32941 fix criteriaerror exception code + wrong phpdoc scope

  • Loading branch information...
1 parent d6ebe01 commit 8c507544d485a28a2579bf309f304aac7329796a @mouneyrac mouneyrac committed May 17, 2012
Showing with 11 additions and 12 deletions.
  1. +10 −12 course/externallib.php
  2. +1 −0 lang/en/webservice.php
View
22 course/externallib.php
@@ -311,8 +311,6 @@ public static function get_categories($criteria = array(), $addsubcategories = t
$context = context_system::instance();
$value = null;
- // $criteriaerrormsg is a code error, do not fix typo, do not edit it.
- $criteriaerrormsg = 'Missing permissions to search on a criteria.';
switch ($key) {
case 'id':
$value = clean_param($crit['value'], PARAM_INT);
@@ -324,8 +322,8 @@ public static function get_categories($criteria = array(), $addsubcategories = t
} else {
// We must throw an exception.
// Otherwise the dev client would think no idnumber exists.
- throw new moodle_exception($criteriaerrormsg,
- '', '', null,
+ throw new moodle_exception('criteriaerror',
+ 'webservice', '', null,
'You don\'t have the permissions to search on the "idnumber" field.');
}
break;
@@ -344,8 +342,8 @@ public static function get_categories($criteria = array(), $addsubcategories = t
context_system::instance())) {
$value = clean_param($crit['value'], PARAM_INT);
} else {
- throw new moodle_exception($criteriaerrormsg,
- '', '', null,
+ throw new moodle_exception('criteriaerror',
+ 'webservice', '', null,
'You don\'t have the permissions to search on the "visible" field.');
}
break;
@@ -354,15 +352,15 @@ public static function get_categories($criteria = array(), $addsubcategories = t
if (has_capability('moodle/category:manage', $context)) {
$value = clean_param($crit['value'], PARAM_THEME);
} else {
- throw new moodle_exception($criteriaerrormsg,
- '', '', null,
+ throw new moodle_exception('criteriaerror',
+ 'webservice', '', null,
'You don\'t have the permissions to search on the "theme" field.');
}
break;
default:
- throw new moodle_exception($criteriaerrormsg,
- '', '', null,
+ throw new moodle_exception('criteriaerror',
+ 'webservice', '', null,
'You can not search on this criteria: ' . $key);
}
@@ -497,7 +495,7 @@ public static function get_categories($criteria = array(), $addsubcategories = t
* @return int result of strcmp
* @since Moodle 2.3
*/
- public static function compare_categories_by_path($category1, $category2) {
+ private static function compare_categories_by_path($category1, $category2) {
return strcmp($category1->path, $category2->path);
}
@@ -510,7 +508,7 @@ public static function compare_categories_by_path($category1, $category2) {
* @return int result of strcmp
* @since Moodle 2.3
*/
- public static function compare_categories_by_sortorder($category1, $category2) {
+ private static function compare_categories_by_sortorder($category1, $category2) {
return strcmp($category1['sortorder'], $category2['sortorder']);
}
View
1 lang/en/webservice.php
@@ -54,6 +54,7 @@
$string['createtokenforuserdescription'] = 'Create a token for the web services user.';
$string['createuser'] = 'Create a specific user';
$string['createuserdescription'] = 'A web services user is required to represent the system controlling Moodle.';
+$string['criteriaerror'] = 'Missing permissions to search on a criteria.';
$string['default'] = 'Default to "{$a}"';
$string['deleteaservice'] = 'Delete service';
$string['deleteservice'] = 'Delete the service: {$a->name} (id: {$a->id})';

0 comments on commit 8c50754

Please sign in to comment.
Something went wrong with that request. Please try again.