"MDL-14129, fix print_error"

This commit is contained in:
dongsheng 2008-05-08 08:43:17 +00:00
parent e249043390
commit d3b7ea93de
9 changed files with 40 additions and 34 deletions

View File

@ -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");
}
}
@ -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');
}
?>

View File

@ -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;

View File

@ -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

View File

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

View File

@ -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)) {

View File

@ -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);
@ -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

View File

@ -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 = '';
@ -42,7 +42,7 @@
$status = restore_precheck($id,$file,$errorstr);
if (!$status) {
print_error("An error occured");
print_error("pleasereport");
}
?>

View File

@ -22,6 +22,7 @@ $string['phpvaron'] = 'The PHP server variable \'$a[0]\' is not turned On - $a[1
$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!';
?>

View File

@ -25,6 +25,7 @@ $string['cannotcreatesitedir'] = 'Cannot create site folder. The site administra
$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';
@ -47,6 +48,7 @@ $string['cannotmetacourse'] = 'Could not add the selected course to this meta co
$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.';
@ -65,6 +67,8 @@ $string['cannotupdatesubcate'] = 'Could not update a child category!';
$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.';