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 13, 2008
1 parent f857fa9 commit 4e244ba
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 25 deletions.
6 changes: 6 additions & 0 deletions lang/en_utf8/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
$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';
Expand All @@ -32,6 +33,7 @@
$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.';
Expand All @@ -49,6 +51,7 @@
$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';
Expand Down Expand Up @@ -117,7 +120,10 @@
$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!';
Expand Down
4 changes: 2 additions & 2 deletions user/addnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$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);
Expand All @@ -18,7 +18,7 @@

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();
Expand Down
11 changes: 5 additions & 6 deletions user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions user/editadvanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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');
}
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions user/extendenrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$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);
Expand All @@ -17,7 +17,7 @@
$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) {
Expand Down
2 changes: 1 addition & 1 deletion user/groupaddnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$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);
Expand Down
2 changes: 1 addition & 1 deletion user/groupextendenrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$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);
Expand Down
2 changes: 1 addition & 1 deletion user/messageselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion user/policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion user/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e244ba

Please sign in to comment.