From: jerome Date: Mon, 9 Mar 2009 05:20:16 +0000 (+0000) Subject: web service MDL-12886 update web service exception messages X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6d1c1a6bd93f226a314db082ff04d5b2fbf38f00;p=moodle.git web service MDL-12886 update web service exception messages --- diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 08f05ac950..78622e4a5e 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -3,6 +3,7 @@ $string['adminprimarynoedit'] = 'The primary admin cannot be edited by others'; +$string['authnotexisting'] = 'The autorization plugin doesn\'t exist'; $string['authorizeerror'] = 'Authorize error'; $string['blockdoesnotexist'] = 'This block does not exist'; $string['blockcannotinistantiate'] = 'Problem in instantiating block object'; @@ -16,6 +17,7 @@ $string['cannotaddcoursemodule'] = 'Could not add a new course module'; $string['cannotaddcoursemoduletosection'] = 'Could not add the new course module to that section'; $string['cannotaddcmtosection'] = 'Could not add the new course module to that section'; $string['cannotaddrss'] = 'You do not have permission to add rss feeds'; +$string['cannotaddmembergroupiddoesntexist'] = 'Cannot add member group: the group id doesn\'t exist'; $string['cannotaddmodule'] = '$a module could not be added to the module list!'; $string['cannotaddnewmodule'] = 'Could not add a new module of $a'; $string['cannotaddnewinstance'] = 'Could not add a new instance of $a'; @@ -162,6 +164,7 @@ $string['componentisuptodate'] = 'Component is up-to-date'; $string['confirmsesskeybad'] = 'Sorry, but your session key could not be confirmed to carry out this action. This security feature prevents against accidental or malicious execution of important functions in your name. Please make sure you really wanted to execute this function.'; $string['couldnotassignrole'] = 'A serious but unspecified error occurred while trying to assign a role to you'; $string['countriesphpempty'] = 'Error: The file countries.php in language pack $a is empty or missing.'; +$string['coursedoesntexistcannotcreategroup'] = 'Cannot create group: the course doesn\'t exist'; $string['coursegroupunknown'] = 'Course corresponding to group $a not specified'; $string['coursemisconf'] = 'Course is misconfigured'; $string['courserequestdisabled'] = 'Sorry, but requesting courses has been disabled by the administrator'; @@ -224,6 +227,7 @@ $string['headersent'] = 'Headers already sent'; $string['generalexceptionmessage'] = 'Exception - $a'; $string['gradepubdisable'] = 'Grade publishing disabled'; $string['groupalready'] = 'User already belongs to group $a'; +$string['groupiddoesntexistcannotdelete'] = 'Cannot delete group: group id doesn\'t exist'; $string['groupexistforcourse'] = 'Group \"$a\" already exists for this course'; $string['groupnotaddederror'] = 'Group \"$a\" not added'; $string['groupunknown'] = 'Group $a not associated to specified course'; @@ -443,12 +447,14 @@ $string['upgraderequires19'] = 'Error: New Moodle version was installed on serve $string['urlnotdefinerss'] = 'URL not defined for RSS feed'; $string['userautherror'] = 'Unknown auth plugin'; $string['userauthunsupported'] = 'Auth plugin not supported here'; +$string['useriddoesntexist'] = 'User id doesn\'t exist'; $string['useremailduplicate'] = 'Duplicate address'; $string['usermustbemnet'] = 'Users in the MNET access control list must be remote MNET users'; $string['usernotaddedadmin'] = 'Cannot delete admin accounts'; $string['usernotaddederror'] = 'User not added - error'; $string['usernotaddedregistered'] = 'User not added - already registered'; $string['usernotavailable'] = 'The details of this user are not available to you'; +$string['usernotcreated'] = 'The user could not be created'; $string['usernotdeletederror'] = 'User not deleted - error'; $string['usernotdeletedmissing'] = 'User not deleted - could not find the username'; $string['usernotdeletedoff'] = 'User not deleted - deleting not allowed'; @@ -470,6 +476,19 @@ $string['wrongdestpath'] = 'Wrong destination path'; $string['wrongroleid'] = 'Incorrect role ID!'; $string['wrongsourcebase'] = 'Wrong source URL base'; $string['wrongzipfilename'] = 'Wrong ZIP file name'; +$string['wscouldnotaddgroupmembernopermission'] = 'WS - Could not add group member - No permission'; +$string['wscouldnotcreategroupnopermission'] = 'WS - Could not create group - No permission'; +$string['wscouldnotcreateeuserindb'] = 'WS - Could not create a user'; +$string['wscouldnotcreateeusernopermission'] = 'WS - Could not create a user - No permission'; +$string['wscouldnotdeletegroupnopermission'] = 'WS - Could not delete group - No permission'; +$string['wscouldnotdeletenoexistinguser'] = 'WS - Could not delete a user - User doesn\'t exist'; +$string['wscouldnotdeleteusernopermission'] = 'WS - Could not delete a user - No permission'; +$string['wscouldnotgetgroupnopermission'] = 'WS - Could not get group - No permission'; +$string['wscouldnotremovegroupmembernopermission'] = 'WS - Could not remove group member - No permission'; +$string['wscouldnotupdatenoexistinguser'] = 'WS - Could not update a user - User doesn\'t exist'; +$string['wscouldnotupdateuserindb'] = 'WS - Could not update a user'; +$string['wscouldnotupdateusernopermission'] = 'WS - Could not update a user - No permission'; +$string['wscouldnotvieweusernopermission'] = 'WS - Could not view a user - No permission'; $string['wwwrootmismatch'] = 'Incorrect access detected, this server may be accessed only through \"$a\" address, sorry.
Please notify server administrator.'; $string['wwwrootslash'] = 'Detected incorrect \$CFG->wwwroot in config.php, it must not contain trailing slash.
Please notify server administrator.'; $string['xmldberror'] = 'XMLDB error!'; diff --git a/user/external.php b/user/external.php index 8f3b5c943f..bb4b0985a7 100644 --- a/user/external.php +++ b/user/external.php @@ -60,7 +60,7 @@ final class user_external { return get_users(true, $params['search'], false, null, 'firstname ASC','', '', '', 1000, 'id, auth, confirmed, username, idnumber, firstname, lastname, email, emailstop, lang, theme, timezone, mailformat, city, description, country'); } else { - throw new moodle_exception('wscouldnotvieweuser'); + throw new moodle_exception('wscouldnotvieweusernopermission'); } } @@ -104,7 +104,7 @@ final class user_external { return $userids; } else { - throw new moodle_exception('wscouldnotcreateeuser'); + throw new moodle_exception('wscouldnotcreateeusernopermission'); } } @@ -137,7 +137,7 @@ final class user_external { return $deletionsuccessfull; } else { - throw new moodle_exception('wscouldnotdeleteuser'); + throw new moodle_exception('wscouldnotdeleteusernopermission'); } } @@ -195,7 +195,7 @@ final class user_external { return $updatesuccessfull; } else { - throw new moodle_exception('wscouldnotupdateuser'); + throw new moodle_exception('wscouldnotupdateusernopermission'); } } diff --git a/user/lib.php b/user/lib.php index 60987b4c89..b4a8b2c672 100644 --- a/user/lib.php +++ b/user/lib.php @@ -122,7 +122,7 @@ $required = array('username','firstname','lastname','email', 'password'); foreach ($required as $req) { if (!isset($user->{$req})) { - throw new moodle_exception('missingerequiredfield'); + throw new moodle_exception('missingrequiredfield'); } } $password = hash_internal_user_password($user->password); @@ -134,10 +134,10 @@ } else { //we could not update properly the newly created user, we need to delete it $DB->delete_record('user',array('id' => $record->id)); - throw new moodle_exception('couldnotcreateuser'); + throw new moodle_exception('usernotcreated'); } } - throw new moodle_exception('couldnotcreateuser'); + throw new moodle_exception('usernotcreated'); } diff --git a/user/simpletest/testexternal.php b/user/simpletest/testexternal.php index 4e1e1071b2..34bebfdb0b 100644 --- a/user/simpletest/testexternal.php +++ b/user/simpletest/testexternal.php @@ -26,13 +26,13 @@ /** * Unit tests for (some of) user/external.php. * WARNING: DO NOT RUN THIS TEST ON A PRODUCTION SITE - * => DO NOT UNCOMMENT THESE TEST FUNCTIONS EXCEPT IF U R DEV + * => DO NOT UNCOMMENT THESE TEST FUNCTIONS EXCEPT IF YOU ARE DEVELOPER * => NONE OF THESE TEST FUNCTIONS SHOULD BE UNCOMMENT BY DEFAULT * => THESE TEST FUNCTIONS ARE DEPENDENT BETWEEEN EACH OTHER - * => THE FUNCTION ORDER CAN NOT BE CHANGE + * => THE FUNCTION ORDER MUST NOT BE CHANGED * * - * THESE TEST NEED TO BE RUN AS ADMIN!!! + * THIS TEST NEEDS TO BE RUN AS ADMIN!!! * @author Jerome Mouneyrac */ @@ -90,7 +90,7 @@ class user_external_test extends UnitTestCase { $user = array(); $user['username'] = 'mockuserfortestingY'; $params[] = $user; - $this->expectException(new moodle_exception('missingerequiredfield')); + $this->expectException(new moodle_exception('missingrequiredfield')); $result = user_external::tmp_create_users($params); }