From 5c22165459bcf6ff2a11f4f5c456aac8c9537afd Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sun, 15 Jun 2008 10:06:06 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- lang/en_utf8/error.php | 7 +++++++ login/change_password.php | 6 +++--- login/confirm.php | 8 ++++---- login/forgot_password.php | 12 ++++++------ login/index.php | 2 +- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index b365ce87a6..08beca639d 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -67,6 +67,7 @@ $string['cannotfindinfo'] = 'Cannot find info for: \"$a\"'; $string['cannotfindlang'] = 'Cannot find \"$a\" language pack!'; $string['cannotfindsite'] = 'Cannot find site-level course'; $string['cannotfindteacher'] = 'Cannot find teacher.'; +$string['cannotfinduser'] = 'Cannot find user named \"$a\"'; $string['cannotimportgrade'] = 'Grade import error'; $string['cannotimportformat'] = 'Sorry, importing this format is not yet implemented!'; $string['cannotnetgeo'] = 'Can not connect to NetGeo server at http://netgeo.caida.org, please check proxy settings or better install MaxMind GeoLite City data file.'; @@ -75,6 +76,7 @@ $string['cannotgetcats'] = 'Cannot get category record'; $string['cannotgetdata'] = 'Cannot get data'; $string['cannotgradeuser'] = 'Can not grade this user'; $string['cannothaveparentcate'] = 'Course category can not have parent!'; +$string['cannotmailconfirm'] = 'error sending password change confirmation email'; $string['cannotmapfield'] = 'mapping collision detected, 2 fields maps to the same grade item $a'; $string['cannotmarktopic'] = 'Could not mark that topic for this course'; $string['cannotmoverolewithid'] = 'Cannot move role with ID $a'; @@ -90,6 +92,8 @@ $string['cannotreaduploadfile'] = 'Could not read uploaded file'; $string['cannotreadfile'] = 'Can not read file'; $string['cannotremovefrommeta'] = 'Could not remove the selected course from this meta course!'; $string['cannotrestore'] = 'An error has occurred and the restore could not be completed!'; +$string['cannotresetguestpwd'] = 'You cannot reset the guest password'; +$string['cannotresetmail'] = 'Error resetting password and mailing you'; $string['cannotsaveblock'] = 'Error saving block configuration'; $string['cannotsavefile'] = 'Cannot save the file \"$a\".'; $string['cannotinitpage'] = 'Cannot quickly initialize page, course id: $a'; @@ -132,6 +136,7 @@ $string['cannotupdateplugincap'] = 'Could not update $a capabilities!'; $string['cannotupdateprofile'] = 'Error updating user record'; $string['cannotupdatecustomprofile'] = 'Error updating user custom record'; $stirng['cannotupdaterss'] = 'Cannot update rss'; +$string['cannotupdatesecret'] = 'Error resetting user secret string'; $string['cannotupdatesummary'] = 'Could not update the summary!'; $string['cannotupdatesubcate'] = 'Could not update a child category!'; $string['cannotupdatesubcourse'] = 'Could not update a child course!'; @@ -143,6 +148,7 @@ $string['cannotunassigncap'] = 'Could not unassign deprecated capability $a[0] f $string['cannotrestoreadminorcreator'] = 'You need to be a creator or admin user to restore into new course!'; $string['cannotrestoreadminoredit'] = 'You need to be a edit teacher or admin user to restore into selected course!'; $string['cannotusepage'] = 'Only teacher and administrator can use this page.'; +$string['cannotusepage2'] = 'Sorry, you may not use this page.'; $string['cannotviewprofile'] = 'You can not view the profile of this user.'; $string['cantunenrollfrommetacourse'] = 'You can not unenrol from this meta course.'; $string['cantunenrollinthisrole'] = 'You can not unenrol from this course while you are in your current role.'; @@ -209,6 +215,7 @@ $string['invalidcourse'] = 'Invalid course'; $string['invalidcourseid'] = 'You are trying to use an invalid course ID: ($a)'; $string['invalidcourselevel'] = 'Incorrect context level'; $string['invalidcoursemodule'] = 'Invalid course module ID'; +$string['invalidconfirmdata'] = 'Invalid confirmation data'; $string['invalidcontext'] = 'Invalid context'; $string['invalidcomment'] = 'Comment is incorrect'; $string['invaliddata'] = 'Data submitted is invalid.'; diff --git a/login/change_password.php b/login/change_password.php index 94a9b28b96..ecb40b3868 100644 --- a/login/change_password.php +++ b/login/change_password.php @@ -13,7 +13,7 @@ $systemcontext = get_context_instance(CONTEXT_SYSTEM); if (!$course = $DB->get_record('course', array('id'=>$id))) { - print_error('No such course!'); + print_error('invalidcourseid'); } // require proper login; guest user can not change password @@ -31,7 +31,7 @@ // do not allow "Logged in as" users to change any passwords if (!empty($USER->realuser)) { - print_error('Can not use this script when "Logged in as"!'); + print_error('cannotcallscript'); } if (is_mnet_remote_user($USER)) { @@ -39,7 +39,7 @@ if ($idprovider = $DB->get_record('mnet_host', array('id'=>$USER->mnethostid))) { $message .= get_string('userchangepasswordlink', 'mnet', $idprovider); } - print_error($message); + print_error('userchangepasswordlink', 'mnet', '', $message); } // load the appropriate auth plugin diff --git a/login/confirm.php b/login/confirm.php index 04251de1c6..5e4a15e9a3 100644 --- a/login/confirm.php +++ b/login/confirm.php @@ -8,12 +8,12 @@ $s = optional_param('s', '', PARAM_CLEAN); // Old parameter: username if (empty($CFG->registerauth)) { - print_error("Sorry, you may not use this page."); + print_error('cannotusepage2'); } $authplugin = get_auth_plugin($CFG->registerauth); if (!$authplugin->can_confirm()) { - print_error("Sorry, you may not use this page."); + print_error('cannotusepage2'); } if (!empty($data) || (!empty($p) && !empty($s))) { @@ -45,7 +45,7 @@ // The user has confirmed successfully, let's log them in if (!$USER = get_complete_user_data('username', $username)) { - print_error("Something serious is wrong with the database"); + print_error('cannotfinduser', '', '', $username); } set_moodle_cookie($USER->username); @@ -65,7 +65,7 @@ print_footer(); exit; } else { - print_error("Invalid confirmation data"); + print_error('invalidconfirmdata'); } } else { print_error("errorwhenconfirming"); diff --git a/login/forgot_password.php b/login/forgot_password.php index c39e09f94a..123861f82f 100644 --- a/login/forgot_password.php +++ b/login/forgot_password.php @@ -48,7 +48,7 @@ if ($p_secret !== false) { // check this isn't guest user if (isguestuser($user)) { - print_error('You cannot reset the guest password'); + print_error('cannotresetguestpwd'); } // make sure user is allowed to change password @@ -57,13 +57,13 @@ if ($p_secret !== false) { // override email stop and mail new password $user->emailstop = 0; if (!reset_password_and_mail($user)) { - print_error('Error resetting password and mailing you'); + print_error('cannotresetmail'); } // Clear secret so that it can not be used again $user->secret = ''; if (!$DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id))) { - print_error('Error resetting user secret string'); + print_error('cannotupdatesecret'); } reset_login_count(); @@ -115,16 +115,16 @@ if ($mform->is_cancelled()) { // set 'secret' string $user->secret = random_string(15); if (!$DB->set_field('user', 'secret', $user->secret, array('id'=>$user->id))) { - print_error('error setting user secret string'); + print_error('cannotupdatesecret'); } if (!send_password_change_confirmation_email($user)) { - print_error('error sending password change confirmation email'); + print_error('cannotmailconfirm'); } } else { if (!send_password_change_info($user)) { - print_error('error sending password change confirmation email'); + print_error('cannotmailconfirm'); } } } diff --git a/login/index.php b/login/index.php index 01551bf4db..f8a61df48c 100644 --- a/login/index.php +++ b/login/index.php @@ -56,7 +56,7 @@ httpsrequired(); /// Define variables used in page if (!$site = get_site()) { - print_error("No site found!"); + print_error('siteisnotdefined', 'debug'); } if (empty($CFG->langmenu)) { -- 2.39.5