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 May 8, 2008
1 parent e249043 commit d3b7ea9
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 34 deletions.
10 changes: 5 additions & 5 deletions backup/backup_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
if (!empty($course->id)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (empty($to)) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
}
}

Expand All @@ -30,14 +30,14 @@

//Check site
if (!$site = get_site()) {
print_error("Site not found!");
print_error("siteisnotdefined", 'debug');
}
if ($count == 0) {
notice("No backupable modules are installed!");
}

if (!execute_sql("DELETE FROM {$CFG->prefix}backup_ids WHERE backup_code = '{$backupprefs->backup_unique_code}'",false)){
print_error('Couldn\'t delete previous backup ids.');
print_error('cannotdeletebackupids');
}

?>
Expand Down
8 changes: 4 additions & 4 deletions backup/backup_execute.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
if (!empty($course->id)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (empty($to)) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
}
}


//Check site
if (!$site = get_site()) {
print_error("Site not found!");
print_error("siteisnotdefined", 'debug');
}

$preferences = new StdClass;
Expand Down
8 changes: 4 additions & 4 deletions backup/backup_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
if (!empty($course->id)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (empty($to)) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
}
}

//Check site
if (!$site = get_site()) {
print_error("Site not found!");
print_error("siteisnotdefined", 'debug');
}

//Checks for the required files/functions to backup every mod
Expand Down
13 changes: 7 additions & 6 deletions backup/restore_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@

// check for session objects
if (empty($info) or empty($course_header)) {
print_error( 'important information missing from SESSION' );
print_error('sessionmissing', 'debug', '',
'info and course_header');
}


Expand Down Expand Up @@ -189,17 +190,17 @@
//Check admin
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
}
}

//Check site
if (!$site = get_site()) {
print_error("Site not found!");
print_error("siteisnotdefined", 'debug');
}

//Depending the selected restoreto:
Expand Down Expand Up @@ -271,9 +272,9 @@
} else if ((($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id != 0)) or ($restore->restoreto == 2)) {
//Final access control check
if ($restore->course_id == 0 and !user_can_create_courses()) {
print_error("You need to be a creator or admin to restore into new course!");
print_error("cannotrestoreadminorcreator");
} else if ($restore->course_id != 0 and !has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $restore->course_id))) {
print_error("You need to be an edit teacher or admin to restore into selected course!");
print_error("cannotrestoreadminoredit");
}
$show_continue_button = true;
//Check if we've selected any mod's user info and restore->users
Expand Down
10 changes: 5 additions & 5 deletions backup/restore_execute.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
&& !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
}
}

//Check site
if (!$site = get_site()) {
print_error("Site not found!");
print_error("siteisnotdefined", 'debug');
}
$errorstr = '';

$status = restore_execute($restore,$info,$course_header,$errorstr);

if (!$status) {
print_error ("An error has occurred and the restore could not be completed!");
print_error ("cannotrestore");
}

if (empty($restore->importing)) {
Expand Down
10 changes: 5 additions & 5 deletions backup/restore_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

//Get objects from session
if (!($info = $SESSION->info)) {
print_error( 'info object missing from session' );
print_error('sessionmissing' ,'debug', '', 'info');
}
if (!($course_header = $SESSION->course_header)) {
print_error( 'course_header object missing from session' );
print_error('sessionmissing' ,'debug', '', 'course_header');
}

$restore_gradebook_history = optional_param('restore_gradebook_history', 0, PARAM_INT);
Expand All @@ -26,17 +26,17 @@
//Check admin
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error('cannotuseadminadminorteacher', '', '$CFG->wwwroot/login/index.php');
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error('cannotuseadmin', '', '$CFG->wwwroot/login/index.php');
}
}

//Check site
if (!$site = get_site()) {
print_error("Site not found!");
print_error("siteisnotdefined", 'debug');
}

//Checks for the required files/functions to restore every mod
Expand Down
10 changes: 5 additions & 5 deletions backup/restore_precheck.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
&& !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
}
}

//Check site
if (!$site = get_site()) {
print_error("Site not found!");
print_error("siteisnotdefined", 'debug');
}

$errorstr = '';
Expand All @@ -42,7 +42,7 @@
$status = restore_precheck($id,$file,$errorstr);

if (!$status) {
print_error("An error occured");
print_error("pleasereport");
}

?>
1 change: 1 addition & 0 deletions lang/en_utf8/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$string['prefixcannotbeempty'] = 'Table prefix \"$a[0]\" cannot be empty for your target DB ($a[1])';
$string['prefixlimit'] = 'Table prefix \"$a\" maximum allowed length for Oracle DBs is 2cc.';
$string['withoutversion'] = 'Main version.php was not readable or specified';
$string['sessionmissing'] = '$a object missing from session';
$string['siteisnotdefined'] = 'Site is not defined!';

?>
4 changes: 4 additions & 0 deletions lang/en_utf8/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$string['cannotcreateorfindstructs'] = 'Error finding or creating section structures for this course';
$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.';
$string['cannotdeletelangcache'] = 'Language cache can not be deleted, please fix permissions in dataroot/cache/languages!';
$string['cannotdeletebackupids'] = 'Couldn\'t delete previous backup ids.';
$string['cannotdeletecourse'] = 'You do not have the permission to delete this course.';
$string['cannotdeleterole'] = 'It can not be deleted, because $a';
$string['cannotdeleterolewithid'] = 'Could not delete role with ID $a';
Expand All @@ -47,6 +48,7 @@
$string['cannotoverridebaserole'] = 'Can not override base role capabilities';
$string['cannotreadtmpfile'] = 'Error reading temporary 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['cannotsavefile'] = 'Cannot save the file \"$a\".';
$string['cannotsavemd5file'] = 'Cannot save md5 file.';
$string['cannotsavezipfile'] = 'Cannot save ZIP file.';
Expand All @@ -65,6 +67,8 @@
$string['cannotupdatesubcourse'] = 'Could not update a child course!';
$string['cannotuseadmin'] = 'You need to be an admin user to use this page.';
$string['cannotuseadminadminorteacher'] = 'You need to be a teacher or admin user to use this page.';
$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['cannotviewprofile'] = 'You can not view the profile of this user.';
$string['cantunenrollfrommetacourse'] = 'You can not unenrol from this meta course.';
Expand Down

0 comments on commit d3b7ea9

Please sign in to comment.