Skip to content

Commit

Permalink
"MDL-14129, fix print_error"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Jun 15, 2008
1 parent d36e651 commit 5c22165
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
7 changes: 7 additions & 0 deletions lang/en_utf8/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
$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.';
Expand All @@ -75,6 +76,7 @@
$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';
Expand All @@ -90,6 +92,8 @@
$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';
Expand Down Expand Up @@ -132,6 +136,7 @@
$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!';
Expand All @@ -143,6 +148,7 @@
$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.';
Expand Down Expand Up @@ -209,6 +215,7 @@
$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.';
Expand Down
6 changes: 3 additions & 3 deletions login/change_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,15 +31,15 @@

// 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)) {
$message = get_string('usercannotchangepassword', 'mnet');
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
Expand Down
8 changes: 4 additions & 4 deletions login/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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);
Expand All @@ -65,7 +65,7 @@
print_footer();
exit;
} else {
print_error("Invalid confirmation data");
print_error('invalidconfirmdata');
}
} else {
print_error("errorwhenconfirming");
Expand Down
12 changes: 6 additions & 6 deletions login/forgot_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// 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
Expand All @@ -57,13 +57,13 @@
// 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();
Expand Down Expand Up @@ -115,16 +115,16 @@
// 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');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

/// Define variables used in page
if (!$site = get_site()) {
print_error("No site found!");
print_error('siteisnotdefined', 'debug');
}

if (empty($CFG->langmenu)) {
Expand Down

0 comments on commit 5c22165

Please sign in to comment.