MDL-32941 fix criteriaerror exception code + wrong phpdoc scope

This commit is contained in:
Jerome Mouneyrac 2012-05-17 13:36:40 +08:00
parent d6ebe011b6
commit 8c507544d4
2 changed files with 11 additions and 12 deletions

View file

@ -311,8 +311,6 @@ class core_course_external extends external_api {
$context = context_system::instance(); $context = context_system::instance();
$value = null; $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) { switch ($key) {
case 'id': case 'id':
$value = clean_param($crit['value'], PARAM_INT); $value = clean_param($crit['value'], PARAM_INT);
@ -324,8 +322,8 @@ class core_course_external extends external_api {
} else { } else {
// We must throw an exception. // We must throw an exception.
// Otherwise the dev client would think no idnumber exists. // Otherwise the dev client would think no idnumber exists.
throw new moodle_exception($criteriaerrormsg, throw new moodle_exception('criteriaerror',
'', '', null, 'webservice', '', null,
'You don\'t have the permissions to search on the "idnumber" field.'); 'You don\'t have the permissions to search on the "idnumber" field.');
} }
break; break;
@ -344,8 +342,8 @@ class core_course_external extends external_api {
context_system::instance())) { context_system::instance())) {
$value = clean_param($crit['value'], PARAM_INT); $value = clean_param($crit['value'], PARAM_INT);
} else { } else {
throw new moodle_exception($criteriaerrormsg, throw new moodle_exception('criteriaerror',
'', '', null, 'webservice', '', null,
'You don\'t have the permissions to search on the "visible" field.'); 'You don\'t have the permissions to search on the "visible" field.');
} }
break; break;
@ -354,15 +352,15 @@ class core_course_external extends external_api {
if (has_capability('moodle/category:manage', $context)) { if (has_capability('moodle/category:manage', $context)) {
$value = clean_param($crit['value'], PARAM_THEME); $value = clean_param($crit['value'], PARAM_THEME);
} else { } else {
throw new moodle_exception($criteriaerrormsg, throw new moodle_exception('criteriaerror',
'', '', null, 'webservice', '', null,
'You don\'t have the permissions to search on the "theme" field.'); 'You don\'t have the permissions to search on the "theme" field.');
} }
break; break;
default: default:
throw new moodle_exception($criteriaerrormsg, throw new moodle_exception('criteriaerror',
'', '', null, 'webservice', '', null,
'You can not search on this criteria: ' . $key); 'You can not search on this criteria: ' . $key);
} }
@ -497,7 +495,7 @@ class core_course_external extends external_api {
* @return int result of strcmp * @return int result of strcmp
* @since Moodle 2.3 * @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); return strcmp($category1->path, $category2->path);
} }
@ -510,7 +508,7 @@ class core_course_external extends external_api {
* @return int result of strcmp * @return int result of strcmp
* @since Moodle 2.3 * @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']); return strcmp($category1['sortorder'], $category2['sortorder']);
} }

View file

@ -54,6 +54,7 @@ $string['createtokenforuserauto'] = 'Create a token for a user automatically';
$string['createtokenforuserdescription'] = 'Create a token for the web services user.'; $string['createtokenforuserdescription'] = 'Create a token for the web services user.';
$string['createuser'] = 'Create a specific user'; $string['createuser'] = 'Create a specific user';
$string['createuserdescription'] = 'A web services user is required to represent the system controlling Moodle.'; $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['default'] = 'Default to "{$a}"';
$string['deleteaservice'] = 'Delete service'; $string['deleteaservice'] = 'Delete service';
$string['deleteservice'] = 'Delete the service: {$a->name} (id: {$a->id})'; $string['deleteservice'] = 'Delete the service: {$a->name} (id: {$a->id})';