From: dongsheng Date: Fri, 6 Jun 2008 03:15:53 +0000 (+0000) Subject: "MDL-14129, fix print_error" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5973a4c49efc4740532692689875501ce4588502;p=moodle.git "MDL-14129, fix print_error" --- diff --git a/mod/glossary/comments.php b/mod/glossary/comments.php index ca3c03087d..897d91bfae 100644 --- a/mod/glossary/comments.php +++ b/mod/glossary/comments.php @@ -10,19 +10,19 @@ global $USER, $CFG; if (! $cm = get_coursemodule_from_id('glossary', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = get_record("course", "id", $cm->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - print_error("Course module is incorrect"); + print_error('invalidcousemodule'); } if (! $entry = get_record("glossary_entries", "id", $eid)) { - print_error("Entry is incorrect"); + print_error('invalidentry'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index b1a62d1b25..e59663b56d 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -17,15 +17,15 @@ if (! $cm = get_coursemodule_from_id('glossary', $id)) { - print_error("Course Module ID was incorrect"); + print_error("invalidcoursemodule"); } if (! $course = get_record("course", "id", $cm->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $entry = get_record("glossary_entries","id", $entry)) { - print_error("Entry ID was incorrect"); + print_error('invalidentry'); } require_login($course->id, false, $cm); @@ -33,7 +33,7 @@ $manageentries = has_capability('mod/glossary:manageentries', $context); if (! $glossary = get_record("glossary", "id", $cm->instance)) { - print_error("Glossary is incorrect"); + print_error('invalidid', 'glossary'); } @@ -45,11 +45,11 @@ navmenu($course, $cm)); if (($entry->userid != $USER->id) and !$manageentries) { // guest id is never matched, no need for special check here - print_error("You can't delete other people's entries!"); + print_error('nopermissiontodelentry'); } $ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways); if (!$ineditperiod and !$manageentries) { - print_error("You can't delete this. Time expired!"); + print_error('errdeltimeexpired', 'glossary'); } /// If data submitted, then process and store. @@ -63,7 +63,7 @@ $dbentry->glossaryid = $entry->sourceglossaryid; $dbentry->sourceglossaryid = 0; if (! update_record('glossary_entries', $dbentry)) { - print_error("Could not update your glossary"); + print_error('cantupdateglossary', 'glossary'); } } else { diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 69f535651b..3575db4c10 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -14,34 +14,34 @@ $mode = optional_param('mode', '', PARAM_ALPHA); // categories if by catego $hook = optional_param('hook', '', PARAM_ALPHANUM); // CategoryID if (! $cm = get_coursemodule_from_id('glossary', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (! $course = get_record("course", "id", $cm->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } require_login($course->id, false, $cm); if ( isguest() ) { - print_error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]); + print_error('guestnoedit', 'glossary', $_SERVER["HTTP_REFERER"]); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - print_error("Course module is incorrect"); + print_error('invalidid', 'glossary'); } if ($e) { // if entry is specified if (!$entry = get_record("glossary_entries", "id", $e)) { - print_error("Incorrect entry id"); + print_error('invalidentry'); } $ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways); if (!has_capability('mod/glossary:manageentries', $context) and !($entry->userid == $USER->id and ($ineditperiod and has_capability('mod/glossary:write', $context)))) { //expired edit time is the most probable cause here - print_error('erredittimeexpired', 'glossary', "view.php?id=$cm->id&mode=entry&hook=$e"); + print_error('erredittimeexpired', 'glossary', 'view.php?id=$cm->id&mode=entry&hook=$e'); } } else { // new entry require_capability('mod/glossary:write', $context); @@ -98,7 +98,7 @@ if ($mform->is_cancelled()){ "view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id, $cm->id); } else { - print_error("Could not update your glossary"); + print_error('cantupdateglossary', 'glossary'); } } else { @@ -117,7 +117,7 @@ if ($mform->is_cancelled()){ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id,$cm->id); } else { - print_error("Could not insert this new entry"); + print_error('cantinsertent', 'glossary'); } } diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index d0da1fea40..0413b2d3b0 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -17,25 +17,25 @@ $action = strtolower($action); if (! $cm = get_coursemodule_from_id('glossary', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = get_record("course", "id", $cm->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - print_error("Course module is incorrect"); + print_error('invalidcoursemodule'); } if ($hook > 0) { if ($category = get_record("glossary_categories","id",$hook)) { //Check it belongs to the same glossary if ($category->glossaryid != $glossary->id) { - print_error("Glossary is incorrect"); + print_error('invalidid', 'glossary'); } } else { - print_error("Category is incorrect"); + print_error('invalidcategoryid'); } } @@ -68,7 +68,7 @@ $cat->usedynalink = $usedynalink; if ( !update_record("glossary_categories", $cat) ) { - print_error("Weird error. The category was not updated."); + print_error('cannotupdatecategory'); redirect("editcategories.php?id=$cm->id"); } else { add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id); @@ -158,7 +158,7 @@ $cat->glossaryid = $glossary->id; if ( ! $cat->id = insert_record("glossary_categories", $cat) ) { - print_error("Weird error. The category was not inserted."); + print_error('cannotinsertcategory'); redirect("editcategories.php?id=$cm->id"); } else { diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 05e2a09820..8df0522ac1 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -27,11 +27,11 @@ require_capability('mod/glossary:export', $context); if (! $course = get_record('course', 'id', $cm->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $glossary = get_record('glossary', 'id', $cm->instance)) { - print_error('Course module is incorrect'); + print_error('invalidid', 'glossary'); } $strglossaries = get_string('modulenameplural', 'glossary'); @@ -66,7 +66,7 @@ $dbentry->sourceglossaryid = $glossary->id; if (! update_record('glossary_entries', $dbentry)) { - print_error('Could not export the entry to the main glossary'); + print_error('cantexportentry', 'glossary'); } else { print_simple_box_start('center', '60%'); echo '

'.$entryexported.'

'; diff --git a/mod/glossary/import.php b/mod/glossary/import.php index ca1b8c5b53..1e6041a2f6 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -16,15 +16,15 @@ $hook = optional_param('hook', 'ALL', PARAM_ALPHANUM); if (! $cm = get_coursemodule_from_id('glossary', $id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } if (! $course = get_record("course", "id", $cm->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - print_error("Course module is incorrect"); + print_error('invalidid', 'glossary'); } require_login($course->id, false, $cm); @@ -147,7 +147,7 @@ // to each other, so we have to update one of them twice. if (! $currmodule = get_record("modules", "name", 'glossary')) { - print_error("Glossary module doesn't exist"); + print_error('modulenotexist', 'debug', '', 'Glossary'); } $mod->module = $currmodule->id; $mod->course = $course->id; @@ -155,21 +155,21 @@ $mod->section = 0; if (! $mod->coursemodule = add_course_module($mod) ) { - print_error("Could not add a new course module"); + print_error('cannotaddcoursemodule'); } if (! $sectionid = add_mod_to_section($mod) ) { - print_error("Could not add the new course module to that section"); + print_error('cannotaddcoursemoduletosection'); } //We get the section's visible field status $visible = get_field("course_sections","visible","id",$sectionid); if (! set_field("course_modules", "visible", $visible, "id", $mod->coursemodule)) { - print_error("Could not update the course module with the correct visibility"); + print_error('cannotupdatemod', '', '', $mod->coursemodule); } if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) { - print_error("Could not update the course module with the correct section"); + print_error('cannotupdatemod', '', '', $mod->coursemodule); } add_to_log($course->id, "course", "add mod", "../mod/$mod->modulename/view.php?id=$mod->coursemodule", diff --git a/mod/glossary/index.php b/mod/glossary/index.php index 8386a22e1c..8e2976b4b0 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -11,7 +11,7 @@ $id = required_param('id', PARAM_INT); // course if (!$course = $DB->get_record('course', array('id'=>$id))) { - print_error("Course ID is incorrect"); + print_error('invalidcourseid'); } require_course_login($course); diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index b1cfc98345..755c09ff17 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -50,7 +50,7 @@ function glossary_add_instance($glossary) { //Check displayformat is a valid one $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE'); if (!in_array($glossary->displayformat, $formats)) { - print_error("This format doesn't exist!"); + print_error('unknowformat', '', '', $glossary->displayformat); } if ($returnid = $DB->insert_record("glossary", $glossary)) { @@ -92,7 +92,7 @@ function glossary_update_instance($glossary) { //Check displayformat is a valid one $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE'); if (!in_array($glossary->displayformat, $formats)) { - print_error("This format doesn't exist!"); + print_error('unknowformat', '', '', $glossary->displayformat); } if ($return = $DB->update_record("glossary", $glossary)) { @@ -1652,13 +1652,13 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) { if ( $entries ) { foreach ( $entries as $entry ) { if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) { - print_error('Glossary ID was incorrect or no longer exists'); + print_error('invalidid', 'glossary'); } if (! $course = get_record('course', 'id', $glossary->course)) { - print_error('Glossary is misconfigured - don\'t know what course it\'s from'); + print_error('coursemisconf'); } if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid, $glossary->course) ) { - print_error('Glossary is misconfigured - don\'t know what course module it is'); + print_error('invalidid', 'glossary'); } //If displayformat is present, override glossary->displayformat diff --git a/mod/glossary/report.php b/mod/glossary/report.php index b89d56d3bd..537255d101 100644 --- a/mod/glossary/report.php +++ b/mod/glossary/report.php @@ -9,30 +9,30 @@ $sort = optional_param('sort', '', PARAM_ALPHA); if (! $entry = get_record('glossary_entries', 'id', $id)) { - print_error("Entry ID was incorrect"); + print_error('invalidentry'); } if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) { - print_error("Glossary ID was incorrect"); + print_error('invalidid', 'glossary'); } if (! $course = get_record('course', 'id', $glossary->course)) { - print_error("Course ID was incorrect"); + print_error('invalidcourseid'); } if (! $cm = get_coursemodule_from_instance('glossary', $glossary->id, $course->id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } require_login($course, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!$glossary->assessed) { - print_error("This activity does not use ratings"); + print_error('nopermissiontorate'); } if (!has_capability('mod/glossary:manageentries', $context) and $USER->id != $entry->userid) { - print_error("You can only look at results for your own entries"); + print_error('nopermissiontoviewresult', 'glossary'); } switch ($sort) {