From: dongsheng Date: Fri, 13 Jun 2008 07:07:45 +0000 (+0000) Subject: "MDL-14129, fix print_error" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4e244ba8b9934cbb5cfde07a974455011118ba6b;p=moodle.git "MDL-14129, fix print_error" --- diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 87e10cd088..4a6b3e03b8 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -23,6 +23,7 @@ $string['cannotaddnewinstance'] = 'Could not add a new instance of $a'; $string['cannotsaveconfig'] = 'Problem saving config \"$a[0]\" as \"$a[1]\" for plugin \"$a[2]\"'; $string['cannotsavecomment'] = 'Cannot save comment'; $string['cannotsavefile'] = 'Cannot save the file\"$a[0]\/$a[1]\"!'; +$string['cannotsaveagreement'] = 'Could not save your agreement'; $string['cannotcallscript'] = 'You cannot call this script in that way'; $string['cannotcreatebackupdir'] = 'Could not create backupdata folder. The site administrator needs to fix the file permissions'; $string['cannotcreatedefaultcat'] = 'Error creating a default category for context $a'; @@ -32,6 +33,7 @@ $string['cannotcreatelangbase'] = 'Error: Could not create base lang directory.' $string['cannotcreatetempdir'] = 'Cannot create temp dir.'; $string['cannotcreatesitedir'] = 'Cannot create site folder. The site administrator needs to fix the file permissions.'; $string['cannotcreateuploaddir'] = 'Cannot create upload folder. The site administrator needs to fix the file permissions'; +$string['cannotcreateuser'] = 'Error creating user record'; $string['cannotcreateorfindstructs'] = 'Error finding or creating section structures for this course'; $string['cannotcreatepopupwin'] = 'Undefined element - cannot create popup window.'; $string['cannotcustomizelocallang'] = 'You do not have permission to customize the strings translation. This permission is controlled by the capability "moodle/site:langeditlocal". Set this capability to allow you to edit local language packages in case you want to modify translations for your site.'; @@ -49,6 +51,7 @@ $stirng['cannoteditcommentexpired'] = 'You can\'t edit this. Time expired!'; $string['cannoteditsiteform'] = 'You cannot edit the site course using this form'; $string['cannoteditpostorblog'] = 'You can not post or edit blogs.'; $string['cannoteditmasterlang'] = 'You do not have permission to edit master language package. This permission is controlled by the capability "moodle/site:langeditmaster". Set this capability to allow you to edit master language packages in case you are the maintainer of a package.'; +$string['cannotedityourprofile'] = 'Can not edit own profile, sorry.'; $string['cannotfindcomponent'] = 'Cannot find component.'; $string['cannotfindcontext'] = 'Could not find context'; $string['cannotfindcategory'] = 'Cannot find category record from database by ID - $a'; @@ -117,7 +120,10 @@ $string['cannotupdaterole'] = 'Cannot update role!'; $string['cannotupdatemod'] = 'Could not update $a'; $string['cannotupdatemodcap'] = 'Could not update $a capabilities!'; $string['cannotupdateuser'] = 'updating user failed'; +$string['cannotupdateuseronexauth'] = 'Failed to update user data on external auth: $a. See the server logs for more details.'; +$strign['cannotupdatepasswordonextauth'] = 'Failed to update password on external auth: $a. See the server logs for more details.'; $string['cannotupdateplugincap'] = 'Could not update $a capabilities!'; +$string['cannotupdateprofile'] = 'Error updating user record'; $stirng['cannotupdaterss'] = 'Cannot update rss'; $string['cannotupdatesummary'] = 'Could not update the summary!'; $string['cannotupdatesubcate'] = 'Could not update a child category!'; diff --git a/user/addnote.php b/user/addnote.php index fce7e91e49..60ca56831e 100644 --- a/user/addnote.php +++ b/user/addnote.php @@ -7,7 +7,7 @@ $users = optional_param('userid', array(), PARAM_INT); // array of user id $contents = optional_param('contents', array(), PARAM_RAW); // array of user notes $states = optional_param('states', array(), PARAM_ALPHA); // array of notes states if (! $course = $DB->get_record('course', array('id'=>$id))) { - print_error("Course ID is incorrect"); + print_error('invalidcourseid'); } $context = get_context_instance(CONTEXT_COURSE, $id); @@ -18,7 +18,7 @@ require_capability('moodle/notes:manage', $context); if (!empty($users) && confirm_sesskey()) { if (count($users) != count($contents) || count($users) != count($states)) { - print_error('Parameters malformation', '', $CFG->wwwroot.'/user/index.php?id='.$id); + print_error('invalidformdata', '', $CFG->wwwroot.'/user/index.php?id='.$id); } $note = new object(); diff --git a/user/edit.php b/user/edit.php index 7844dc80a3..46ea23c061 100644 --- a/user/edit.php +++ b/user/edit.php @@ -12,7 +12,7 @@ $course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site) if (!$course = $DB->get_record('course', array('id'=>$course))) { - print_error('Course ID was incorrect'); + print_error('invalidcourseid'); } if ($course->id != SITEID) { @@ -31,7 +31,7 @@ // The user profile we are editing if (!$user = $DB->get_record('user', array('id'=>$userid))) { - print_error('User ID was incorrect'); + print_error('invaliduserid'); } // Guest can not be edited @@ -62,7 +62,7 @@ if ($user->id == $USER->id) { //editing own profile - require_login() MUST NOT be used here, it would result in infinite loop! if (!has_capability('moodle/user:editownprofile', $systemcontext)) { - print_error('Can not edit own profile, sorry.'); + print_error('cannotedityourprofile'); } } else { @@ -98,15 +98,14 @@ $usernew->timemodified = time(); if (!$DB->update_record('user', $usernew)) { - print_error('Error updating user record'); + print_error('cannotupdateprofile'); } // pass a true $userold here if (! $authplugin->user_update($user, $userform->get_data())) { // auth update failed, rollback for moodle $DB->update_record('user', $user); - print_error('Failed to update user data on external auth: '.$user->auth. - '. See the server logs for more details.'); + print_error('cannotupdateprofile'); } //update preferences diff --git a/user/editadvanced.php b/user/editadvanced.php index c40048f4ee..8d3f88ebae 100644 --- a/user/editadvanced.php +++ b/user/editadvanced.php @@ -13,7 +13,7 @@ $course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site) if (!$course = $DB->get_record('course', array('id'=>$course))) { - print_error('Course ID was incorrect'); + print_error('invalidcourseid'); } require_login($course->id); @@ -35,7 +35,7 @@ // editing existing user require_capability('moodle/user:update', $systemcontext); if (!$user = $DB->get_record('user', array('id'=>$id))) { - print_error('User ID was incorrect'); + print_error('invaliduserid'); } } @@ -89,26 +89,24 @@ $usernew->confirmed = 1; $usernew->password = hash_internal_user_password($usernew->newpassword); if (!$usernew->id = $DB->insert_record('user', $usernew)) { - print_error('Error creating user record'); + print_error('cannotcreateuser'); } } else { if (!$DB->update_record('user', $usernew)) { - print_error('Error updating user record'); + print_error('cannotupdateuser'); } // pass a true $userold here if (! $authplugin->user_update($user, $userform->get_data())) { // auth update failed, rollback for moodle $DB->update_record('user', $user); - print_error('Failed to update user data on external auth: '.$user->auth. - '. See the server logs for more details.'); + print_error('cannotupdateuseronexauth', '', '', $user->auth); } //set new password if specified if (!empty($usernew->newpassword)) { if ($authplugin->can_change_password()) { if (!$authplugin->user_update_password($usernew, $usernew->newpassword)){ - print_error('Failed to update password on external auth: ' . $usernew->auth . - '. See the server logs for more details.'); + print_error('cannotupdatepasswordonextauth', '', '', $usernew->auth); } } } diff --git a/user/extendenrol.php b/user/extendenrol.php index a84f13a9a7..ec5ddb2862 100644 --- a/user/extendenrol.php +++ b/user/extendenrol.php @@ -5,7 +5,7 @@ $id = required_param('id', PARAM_INT); // course id $users = optional_param('userid', array(), PARAM_INT); // array of user id if (! $course = $DB->get_record('course', array('id'=>$id))) { - print_error("Course ID is incorrect"); + print_error('invalidcourseid'); } $context = get_context_instance(CONTEXT_COURSE, $id); @@ -17,7 +17,7 @@ $today = time(); $today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0); if ((count($users) > 0) and ($form = data_submitted()) and confirm_sesskey()) { if (count($form->userid) != count($form->extendperiod) || count($form->userid) != count($form->extendbase)) { - print_error('Parameters malformation', '', $CFG->wwwroot.'/user/index.php?id='.$id); + print_error('invalidformdata', '', $CFG->wwwroot.'/user/index.php?id='.$id); } foreach ($form->userid as $k => $v) { diff --git a/user/groupaddnote.php b/user/groupaddnote.php index 0deff44691..bc3145ce78 100644 --- a/user/groupaddnote.php +++ b/user/groupaddnote.php @@ -8,7 +8,7 @@ $content = optional_param('content', '', PARAM_RAW); // note content $state = optional_param('state', '', PARAM_ALPHA); // note publish state if (! $course = $DB->get_record('course', array('id'=>$id))) { - print_error("Course ID is incorrect"); + print_error('invalidcourseid'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/user/groupextendenrol.php b/user/groupextendenrol.php index de0897c5a7..6f32af5ec1 100755 --- a/user/groupextendenrol.php +++ b/user/groupextendenrol.php @@ -5,7 +5,7 @@ $id = required_param('id', PARAM_INT); // course id $users = optional_param('userid', array(), PARAM_INT); // array of user id if (! $course = $DB->get_record('course', array('id'=>$id))) { - print_error("Course ID is incorrect"); + print_error('invalidcourseid'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/user/messageselect.php b/user/messageselect.php index 256e90cacd..c049e4713a 100644 --- a/user/messageselect.php +++ b/user/messageselect.php @@ -13,7 +13,7 @@ $deluser = optional_param('deluser',0,PARAM_INT); if (!$course = $DB->get_record('course', array('id'=>$id))) { - print_error("Invalid course id"); + print_error('invalidcourseid'); } require_login(); diff --git a/user/policy.php b/user/policy.php index 0545455f1e..00a58a6e88 100644 --- a/user/policy.php +++ b/user/policy.php @@ -14,7 +14,7 @@ if ($agree and confirm_sesskey()) { // User has agreed if (!isguestuser()) { // Don't remember guests if (!$DB->set_field('user', 'policyagreed', 1, array('id'=>$USER->id))) { - print_error('Could not save your agreement'); + print_error('cannotsaveagreement'); } } $USER->policyagreed = 1; diff --git a/user/tabs.php b/user/tabs.php index 1b6062bbd8..7deeada633 100644 --- a/user/tabs.php +++ b/user/tabs.php @@ -14,7 +14,7 @@ $filterselect = clean_param($filterselect, PARAM_INT); if (empty($currenttab) or empty($user) or empty($course)) { - //print_error('You cannot call this script in that way'); + //print_error('cannotcallscript'); } if (($filtertype == 'site' && $filterselect) || ($filtertype=='user' && $filterselect)) { diff --git a/user/view.php b/user/view.php index 79340dc43e..2e829f54df 100644 --- a/user/view.php +++ b/user/view.php @@ -17,11 +17,11 @@ } if (! $user = $DB->get_record("user", array("id"=>$id))) { - print_error("No such user in this course"); + print_error('invaliduserid'); } if (! $course = $DB->get_record("course", array("id"=>$course))) { - print_error("No such course id"); + print_error('invalidcourseid'); } /// Make sure the current user is allowed to see this user