From: dongsheng Date: Fri, 23 May 2008 08:12:14 +0000 (+0000) Subject: "MDL-14129, fix print_error call" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ec60b8e6da22254b4b81d8b0295c30f798f33140;p=moodle.git "MDL-14129, fix print_error call" --- diff --git a/mod/data/comment.php b/mod/data/comment.php index bc24ed0214..bed2afe83f 100755 --- a/mod/data/comment.php +++ b/mod/data/comment.php @@ -15,16 +15,16 @@ if (! $record = get_record('data_records', 'id', $rid)) { - print_error('Record ID is incorrect'); + print_error('invalidrecord', 'data'); } if (! $data = get_record('data', 'id', $record->dataid)) { - print_error('Data ID is incorrect'); + print_error('invalidid', 'data'); } if (! $course = get_record('course', 'id', $data->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } require_login($course->id, false, $cm); @@ -33,13 +33,13 @@ if ($commentid) { if (! $comment = get_record('data_comments', 'id', $commentid)) { - print_error('Comment ID is misconfigured'); + print_error('commentmisconf'); } if ($comment->recordid != $record->id) { - print_error('Comment ID is misconfigured'); + print_error('commentmisconf'); } if (!has_capability('mod/data:managecomments', $context) && $comment->userid != $USER->id) { - print_error('Comment is not yours to edit!'); + print_error('cannoteditcomment'); } } else { $comment = false; @@ -81,7 +81,7 @@ if (insert_record('data_comments',$newcomment)) { redirect('view.php?rid='.$record->id.'&page='.$page); } else { - print_error('Error while saving comment.'); + print_error('cannotsavecomment'); } break; @@ -100,7 +100,7 @@ if (update_record('data_comments',$updatedcomment)) { redirect('view.php?rid='.$record->id.'&page='.$page); } else { - print_error('Error while saving comment.'); + print_error('cannotsavecomment'); } break; diff --git a/mod/data/edit.php b/mod/data/edit.php index 40eb0e7a0c..b699caace0 100755 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -35,24 +35,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('data', $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 (! $data = get_record('data', 'id', $cm->instance)) { - print_error('Course module is incorrect'); + print_error('invalidcoursemodule'); } } else { if (! $data = get_record('data', 'id', $d)) { - print_error('Data ID is incorrect'); + print_error('invalidid', 'data'); } if (! $course = get_record('course', 'id', $data->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } } @@ -180,7 +180,7 @@ } else { /// Add some new records if (!data_user_can_add_entry($data, $currentgroup, $groupmode)) { - print_error('Can not add entries!'); + print_error('cannotadd', 'data'); } /// Check if maximum number of entry as specified by this database is reached diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 24a8c49489..4837e4e27f 100755 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -133,7 +133,7 @@ class data_field_file extends data_field_base { $oldcontent->fieldid = $this->field->id; $oldcontent->recordid = $recordid; if ($oldcontent->id = insert_record('data_content', $oldcontent)) { - print_error('Could not make an empty record!'); + print_error('cannotinsertempty', 'data'); } } diff --git a/mod/data/field/latlong/kml.php b/mod/data/field/latlong/kml.php index e2609d238a..45c449bdee 100644 --- a/mod/data/field/latlong/kml.php +++ b/mod/data/field/latlong/kml.php @@ -14,41 +14,41 @@ $rid = optional_param('rid', 0, PARAM_INT); //record id if ($rid) { if (! $record = get_record('data_records', 'id', $rid)) { - print_error('Record ID is incorrect'); + print_error('invalidrecord', 'data'); } if (! $data = get_record('data', 'id', $record->dataid)) { - print_error('Data ID is incorrect'); + print_error('invalidid', 'data'); } if (! $course = get_record('course', 'id', $data->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } if (! $field = get_record('data_fields', 'id', $fieldid)) { - print_error('Field ID is incorrect'); + print_error('invalidfieldid', 'data'); } if (! $field->type == 'latlong') { // Make sure we're looking at a latlong data type! - print_error('Field ID is incorrect'); + print_error('invalidfieldtype', 'data'); } if (! $content = get_record('data_content', 'fieldid', $fieldid, 'recordid', $rid)) { - print_error('Field content not found'); + print_error('nofieldcontent', 'data'); } } else { // We must have $d if (! $data = get_record('data', 'id', $d)) { - print_error('Data ID is incorrect'); + print_error('invalidid', 'data'); } if (! $course = get_record('course', 'id', $data->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } if (! $field = get_record('data_fields', 'id', $fieldid)) { - print_error('Field ID is incorrect'); + print_error('invalidfieldid', 'data'); } if (! $field->type == 'latlong') { // Make sure we're looking at a latlong data type! - print_error('Field ID is incorrect'); + print_error('invalidfieldtype', 'data'); } $record = NULL; } diff --git a/mod/data/import.php b/mod/data/import.php index 855998c9cb..22bdccfda8 100755 --- a/mod/data/import.php +++ b/mod/data/import.php @@ -36,24 +36,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('data', $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 (! $data = get_record('data', 'id', $cm->instance)) { - print_error('Course module is incorrect'); + print_error('invalidcoursemodule'); } } else { if (! $data = get_record('data', 'id', $d)) { - print_error('Data ID is incorrect'); + print_error('invalidid', 'data'); } if (! $course = get_record('course', 'id', $data->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('coursemisconf'); } } diff --git a/mod/data/pagelib.php b/mod/data/pagelib.php index 5e444b068e..b0b80ea16b 100755 --- a/mod/data/pagelib.php +++ b/mod/data/pagelib.php @@ -22,7 +22,7 @@ class page_data extends page_generic_activity { function init_quick($data) { if(empty($data->pageid)) { - print_error('Cannot quickly initialize page: empty course id'); + print_error('invalidcourseid'); } $this->activityname = 'data'; parent::init_quick($data); diff --git a/mod/data/preset.php b/mod/data/preset.php index bb25ba7bb9..ac57b89c08 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -25,26 +25,26 @@ unset($fullname); if ($id) { if (! $cm = get_coursemodule_from_id('data', $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 (! $data = get_record('data', 'id', $cm->instance)) { - print_error('Module Incorrect'); + print_error('invalidid', 'data'); } } else if ($d) { if (! $data = get_record('data', 'id', $d)) { - print_error('Database ID Incorrect'); + print_error('invalidid', 'data'); } if (! $course = get_record('course', 'id', $data->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } } else { - print_error('Parameter missing'); + print_error('missingparameter'); } // fill in missing properties needed for updating of instance @@ -53,7 +53,7 @@ $data->cmidnumber = $cm->idnumber; $data->instance = $cm->instance; if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) { - print_error('Could not find context'); + print_error('cannotfindcontext'); } require_login($course->id, false, $cm); @@ -61,7 +61,7 @@ require_login($course->id, false, $cm); require_capability('mod/data:managetemplates', $context); if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpresets', $context)) { - print_error('You are not allowed to access presets from other users'); + print_error('cannotaccesspresentsother', 'data'); } /* Need sesskey security check here for import instruction */ @@ -76,13 +76,13 @@ switch ($action) { /***************** Deleting *****************/ case 'confirmdelete' : if (!confirm_sesskey()) { // GET request ok here - print_error("Sesskey Invalid"); + print_error('invalidsesskey'); } if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) { //ok can delete } else { - print_error("Invalid request"); + print_error('invalidrequest'); } $path = data_preset_path($course, $userid, $shortname); @@ -105,19 +105,19 @@ switch ($action) { case 'delete' : if (!data_submitted() and !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) { //ok can delete } else { - print_error("Invalid request"); + print_error('invalidrequest'); } $presetpath = data_preset_path($course, $userid, $shortname); if (!clean_preset($presetpath)) { - print_error("Error deleting a preset!"); + print_error('cannotdeletepreset', 'data'); } @rmdir($presetpath); @@ -130,7 +130,7 @@ switch ($action) { /***************** Importing *****************/ case 'importpreset' : if (!data_submitted() or !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } $pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname); @@ -143,18 +143,18 @@ switch ($action) { /* Imports a zip file. */ case 'importzip' : if (!data_submitted() or !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } if (!make_upload_directory('temp/data/'.$USER->id)) { - print_error("Can't Create Directory"); + print_error('nopermissiontomkdir'); } $presetfile = $CFG->dataroot.'/temp/data/'.$USER->id; clean_preset($presetfile); if (!unzip_file($CFG->dataroot."/$course->id/$file", $presetfile, false)) { - print_error("Can't unzip file"); + print_error('cannotunzipfile'); } $pimporter = new PresetImporter($course, $cm, $data, -$USER->id, $shortname); @@ -166,7 +166,7 @@ switch ($action) { case 'finishimport': if (!data_submitted() or !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } $pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname); @@ -185,7 +185,7 @@ switch ($action) { /* Exports as a zip file ready for download. */ case 'export': if (!data_submitted() or !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } echo '
'; @@ -197,7 +197,8 @@ switch ($action) { make_upload_directory("$course->id/moddata/data/$data->id"); /* now just move the zip into this folder to allow a nice download */ - if (!rename($file, $perminantfile)) print_error("Can't move zip"); + if (!rename($file, $perminantfile)) + print_error('cannotmovezip'); echo "".get_string('download', 'data').""; echo '
'; break; @@ -205,7 +206,7 @@ switch ($action) { /***************** Exporting *****************/ case 'save1': if (!data_submitted() or !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } $strcontinue = get_string('continue'); @@ -227,7 +228,7 @@ switch ($action) { case 'save2': if (!data_submitted() or !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } $strcontinue = get_string('continue'); @@ -263,7 +264,7 @@ switch ($action) { case 'save3': if (!data_submitted() or !confirm_sesskey()) { - print_error("Invalid request"); + print_error('invalidrequest'); } $name = optional_param('name', $data->name, PARAM_FILE); @@ -274,7 +275,7 @@ switch ($action) { $file = data_presets_export($course, $cm, $data); if (!unzip_file($file, $CFG->dataroot.$presetdirectory, false)) { - print_error("Can't unzip to the preset directory"); + print_error('cannotunziptopreset', 'data'); } notify(get_string('savesuccess', 'data'), 'notifysuccess'); break; diff --git a/mod/data/preset_new.php b/mod/data/preset_new.php index 6e4a1ddf5f..ed7a0459ed 100755 --- a/mod/data/preset_new.php +++ b/mod/data/preset_new.php @@ -26,30 +26,30 @@ unset($fullname); if ($id) { if (! $cm = get_coursemodule_from_id('data', $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 (! $data = get_record('data', 'id', $cm->instance)) { - print_error('Module Incorrect'); + print_error('invalidid', 'data'); } } else if ($d) { if (! $data = get_record('data', 'id', $d)) { - print_error('Database ID Incorrect'); + print_error('invalidid', 'data'); } if (! $course = get_record('course', 'id', $data->course)) { - print_error('Course is misconfigured'); + print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('Course Module ID was incorrect'); + print_error('invalidcoursemodule'); } } else { - print_error('Parameter missing'); + print_error('missingparameter'); } if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) { - print_error('Could not find context'); + print_error('cannotfindcontext'); } require_login($course->id, false, $cm); @@ -57,7 +57,7 @@ require_login($course->id, false, $cm); require_capability('mod/data:managetemplates', $context); if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpresets', $context)) { - print_error('You are not allowed to access presets from other users'); + print_error('cannotaccesspresentsother', 'data'); } /* Need sesskey security check here for import instruction */ diff --git a/mod/data/rate.php b/mod/data/rate.php index 06950926c9..d4b38ad6df 100755 --- a/mod/data/rate.php +++ b/mod/data/rate.php @@ -5,32 +5,32 @@ $dataid = required_param('dataid', PARAM_INT); // The forum the rated posts are from if (!$data = get_record('data', 'id', $dataid)) { - print_error("Incorrect data id"); + print_error('invalidid', 'data'); } if (!$course = get_record('course', 'id', $data->course)) { - print_error("Course ID was incorrect"); + print_error('invalidcourseid'); } if (!$cm = get_coursemodule_from_instance('data', $data->id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } require_login($course, false, $cm); if (isguestuser()) { - print_error("Guests are not allowed to rate entries."); + print_error('guestrate', 'data'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/data:rate', $context); if (!$data->assessed) { - print_error("Rating of items not allowed!"); + print_error('cannotrate', 'data'); } if (!$frmdata = data_submitted() or !confirm_sesskey()) { - print_error("This page was not accessed correctly"); + print_error('invalidaccess', 'data'); } $count = 0; @@ -41,11 +41,11 @@ } if (!$record = get_record('data_records', 'id', $recordid)) { - print_error("Record ID is incorrect"); + print_error('invalidid', 'data'); } if ($data->id != $record->dataid) { - print_error("Incorrect record."); + print_error('invalidrecord', 'data'); } if ($record->userid == $USER->id) { @@ -64,7 +64,7 @@ } else if ($rating != $oldrating->rating) { $oldrating->rating = $rating; if (! update_record('data_ratings', $oldrating)) { - print_error("Could not update an old rating ($record->id = $rating)"); + print_error('cannotupdaterate', 'data', '', array($record->id, $rating)); } data_update_grades($data, $record->userid); @@ -76,14 +76,14 @@ $newrating->recordid = $record->id; $newrating->rating = $rating; if (! insert_record('data_ratings', $newrating)) { - print_error("Could not insert a new rating ($record->id = $rating)"); + print_error('cannotinsertrate', 'data', '', array($record->id, $rating)); } data_update_grades($data, $record->userid); } } if ($count == 0) { - print_error("Incorrect submitted ratings data"); + print_error('invalidratedata', 'data'); } if (!empty($_SERVER['HTTP_REFERER'])) { diff --git a/mod/data/report.php b/mod/data/report.php index 621d2f5cc9..75e7af8884 100755 --- a/mod/data/report.php +++ b/mod/data/report.php @@ -9,30 +9,30 @@ $sort = optional_param('sort', '', PARAM_ALPHA); if (!$record = get_record('data_records', 'id', $id)) { - print_error("Record ID is incorrect"); + print_error('invalidrecord', 'data'); } if (!$data = get_record('data', 'id', $record->dataid)) { - print_error("Data ID is incorrect"); + print_error('invalidid', 'data'); } if (!$course = get_record('course', 'id', $data->course)) { - print_error("Course is misconfigured"); + print_error('coursemisconf'); } if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error("Course Module ID was incorrect"); + print_error('invalidcoursemodule'); } require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!$data->assessed) { - print_error("This activity does not use ratings"); + print_error('norating', 'data'); } if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) { - print_error("You can not view ratings"); + print_error('cannotviewrate', 'data'); } switch ($sort) { @@ -50,7 +50,7 @@ print_header($strratings); if (!$ratings = data_get_ratings($record->id, $sqlsort)) { - print_error("No ratings for this record!"); + print_error('noratingforrecord', 'data'); } else { echo ""; diff --git a/mod/data/tabs.php b/mod/data/tabs.php index 7a11f4390e..0ff7dafe2a 100755 --- a/mod/data/tabs.php +++ b/mod/data/tabs.php @@ -26,7 +26,7 @@ if (empty($currenttab) or empty($data) or empty($course)) { - print_error('You cannot call this script in that way'); + print_error('cannotcallscript'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id);