From 5a2a53316fda16270c85003eeb2987c61f304ccd Mon Sep 17 00:00:00 2001 From: dongsheng Date: Fri, 4 Apr 2008 02:54:20 +0000 Subject: [PATCH] MDL-14129, remove all the other error() call --- admin/auth_config.php | 2 +- admin/block.php | 8 +- admin/blocks.php | 12 +- admin/cliupgrade.php | 4 +- admin/delete.php | 2 +- admin/filter.php | 2 +- admin/filters.php | 6 +- admin/index.php | 34 ++-- admin/lang.php | 26 +-- admin/langdoc.php | 6 +- admin/langimport.php | 2 +- admin/maintenance.php | 2 +- admin/mnet/index.php | 8 +- admin/mnet/peers.php | 19 ++- admin/modules.php | 10 +- admin/multilangupgrade.php | 2 +- admin/register.php | 4 +- admin/replace.php | 2 +- admin/report/stats/index.php | 4 +- admin/roles/assign.php | 6 +- admin/roles/manage.php | 12 +- admin/roles/override.php | 10 +- admin/roles/tabs.php | 8 +- admin/upgradeforumread.php | 2 +- admin/upgradelogs.php | 2 +- admin/uploadpicture.php | 4 +- admin/uploaduser.php | 6 +- admin/user.php | 22 +-- admin/user/user_bulk_message.php | 2 +- .../edit_field_save/edit_field_save.class.php | 2 +- .../edit_index_save/edit_index_save.class.php | 2 +- .../edit_key_save/edit_key_save.class.php | 2 +- .../edit_table_save/edit_table_save.class.php | 2 +- .../edit_xml_file_save.class.php | 2 +- admin/xmldb/index.php | 2 +- auth/ldap/ntlmsso_attempt.php | 2 +- auth/ldap/ntlmsso_finish.php | 2 +- auth/mnet/auth.php | 26 +-- auth/mnet/jump.php | 4 +- auth/mnet/land.php | 2 +- auth/shibboleth/login.php | 2 +- backup/backup.php | 10 +- backup/backup_check.html | 10 +- backup/backup_execute.html | 8 +- backup/backup_form.html | 8 +- backup/lib.php | 10 +- backup/restore.php | 12 +- backup/restore_check.html | 12 +- backup/restore_execute.html | 10 +- backup/restore_form.html | 12 +- backup/restore_precheck.html | 10 +- backup/restorelib.php | 6 +- backup/try.php | 2 +- blocks/rss_client/block_rss_client_action.php | 28 ++-- blog/blogpage.php | 2 +- blog/edit.php | 30 ++-- blog/header.php | 6 +- blog/index.php | 32 ++-- blog/preferences.php | 4 +- calendar/event.php | 16 +- calendar/lib.php | 2 +- course/category.php | 12 +- course/delete.php | 10 +- course/edit.php | 8 +- course/editcategory.php | 10 +- course/editsection.php | 6 +- course/enrol.php | 4 +- course/format/lams/format.php | 2 +- course/format/topics/format.php | 2 +- course/import.php | 2 +- course/import/activities/index.php | 8 +- course/import/groups/index.php | 19 ++- course/importstudents.php | 6 +- course/index.php | 8 +- course/info.php | 8 +- course/lib.php | 16 +- course/loginas.php | 4 +- course/mod.php | 96 +++++------ course/modedit.php | 46 ++--- course/recent.php | 4 +- course/report.php | 2 +- course/report/log/graph.php | 6 +- course/report/log/index.php | 4 +- course/report/log/live.php | 4 +- course/report/outline/index.php | 4 +- course/report/stats/graph.php | 6 +- course/report/stats/index.php | 6 +- course/report/stats/report.php | 6 +- course/request.php | 2 +- course/reset.php | 2 +- course/scales.php | 2 +- course/search.php | 10 +- course/unenrol.php | 12 +- course/user.php | 12 +- course/view.php | 10 +- enrol/authorize/enrol.php | 4 +- enrol/authorize/enrol_form.php | 2 +- enrol/authorize/index.php | 6 +- enrol/authorize/locallib.php | 31 ++-- enrol/authorize/uploadcsv.php | 6 +- enrol/manual/enrol.php | 2 +- enrol/mnet/enrol.php | 4 +- enrol/paypal/ipn.php | 2 +- error/index.php | 2 +- file.php | 20 +-- files/index.php | 14 +- filter/algebra/pix.php | 2 +- filter/tex/lib.php | 4 +- filter/tex/pix.php | 2 +- grade/edit/letter/edit.php | 4 +- grade/edit/letter/index.php | 2 +- grade/edit/outcome/edit.php | 6 +- grade/edit/outcome/index.php | 2 +- grade/edit/scale/edit.php | 6 +- grade/edit/scale/index.php | 2 +- grade/edit/tree/action.php | 10 +- grade/edit/tree/calculation.php | 2 +- grade/edit/tree/category.php | 4 +- grade/edit/tree/grade.php | 14 +- grade/edit/tree/index.php | 4 +- grade/export/key.php | 10 +- grade/export/ods/dump.php | 2 +- grade/export/txt/dump.php | 2 +- grade/export/xls/dump.php | 2 +- grade/export/xml/dump.php | 2 +- grade/export/xml/grade_export_xml.php | 2 +- grade/import/csv/index.php | 4 +- grade/import/key.php | 10 +- grade/import/xml/fetch.php | 2 +- grade/import/xml/import.php | 6 +- grade/report/grader/lib.php | 2 +- grade/report/index.php | 2 +- grade/report/overview/index.php | 2 +- grade/report/user/index.php | 2 +- group/assign.php | 2 +- group/autogroup.php | 4 +- group/group.php | 12 +- group/grouping.php | 12 +- group/index.php | 4 +- group/members.php | 2 +- group/overview.php | 2 +- help.php | 2 +- index.php | 2 +- iplookup/index.php | 2 +- lib/accesslib.php | 24 +-- lib/adminlib.php | 42 ++--- lib/ajax/ajaxlib.php | 2 +- lib/authlib.php | 6 +- lib/blocklib.php | 158 +++++++++--------- lib/csvlib.class.php | 2 +- lib/deprecatedlib.php | 8 +- lib/dmllib.php | 6 +- lib/editor/htmlarea/coursefiles.php | 8 +- lib/editorlib.php | 6 +- lib/filelib.php | 4 +- lib/form/editorhelp.php | 2 +- lib/formslib.php | 6 +- lib/grade/grade_category.php | 6 +- lib/grade/grade_grade.php | 2 +- lib/grade/grade_item.php | 4 +- lib/grade/grade_object.php | 6 +- lib/gradelib.php | 6 +- lib/grouplib.php | 2 +- lib/locallib.php | 4 +- lib/moodlelib.php | 26 +-- lib/pagelib.php | 14 +- lib/questionlib.php | 53 +++++- lib/simpletest/testeventslib.php | 4 +- lib/speller/server-scripts/spellchecker.php | 2 +- lib/weblib.php | 14 +- login/change_password.php | 10 +- login/confirm.php | 10 +- login/forgot_password.php | 16 +- login/index.php | 2 +- login/signup.php | 4 +- message/discussion.php | 4 +- message/history.php | 6 +- message/index.php | 2 +- message/refresh.php | 2 +- message/send.php | 4 +- message/user.php | 4 +- mod/assignment/delete.php | 12 +- mod/assignment/grade.php | 6 +- mod/assignment/index.php | 2 +- mod/assignment/lib.php | 12 +- mod/assignment/mod_form.php | 2 +- mod/assignment/submissions.php | 12 +- mod/assignment/type/online/db/mysql.php | 4 +- mod/assignment/type/online/db/postgres7.php | 4 +- mod/assignment/type/online/file.php | 12 +- .../type/upload/assignment.class.php | 4 +- mod/assignment/type/upload/notes.php | 12 +- mod/assignment/upload.php | 12 +- mod/assignment/view.php | 12 +- mod/chat/gui_basic/index.php | 14 +- mod/chat/gui_header_js/chatinput.php | 2 +- mod/chat/gui_header_js/index.php | 10 +- mod/chat/gui_header_js/insert.php | 12 +- mod/chat/gui_header_js/jsupdate.php | 6 +- mod/chat/gui_header_js/jsupdated.php | 6 +- mod/chat/gui_header_js/users.php | 12 +- mod/chat/gui_sockets/chatinput.php | 2 +- mod/chat/gui_sockets/index.php | 12 +- mod/chat/index.php | 2 +- mod/chat/lib.php | 4 +- mod/chat/pagelib.php | 2 +- mod/chat/report.php | 6 +- mod/chat/view.php | 12 +- mod/choice/index.php | 2 +- mod/choice/lib.php | 6 +- mod/choice/report.php | 6 +- mod/choice/view.php | 6 +- mod/data/comment.php | 18 +- mod/data/edit.php | 18 +- mod/data/field.php | 16 +- mod/data/field/file/field.class.php | 2 +- mod/data/field/latlong/kml.php | 24 +-- mod/data/import.php | 16 +- mod/data/index.php | 2 +- mod/data/lib.php | 22 +-- mod/data/pagelib.php | 2 +- mod/data/preset.php | 50 +++--- mod/data/preset_new.php | 18 +- mod/data/rate.php | 22 +-- mod/data/report.php | 14 +- mod/data/tabs.php | 2 +- mod/data/templates.php | 12 +- mod/data/view.php | 20 +-- mod/exercise/assessments.php | 126 +++++++------- mod/exercise/index.php | 2 +- mod/exercise/lib.php | 8 +- mod/exercise/locallib.php | 90 +++++----- mod/exercise/submissions.php | 56 +++---- mod/exercise/upload.php | 10 +- mod/exercise/view.php | 18 +- mod/forum/discuss.php | 24 +-- mod/forum/index.php | 4 +- mod/forum/lib.php | 44 ++--- mod/forum/markposts.php | 6 +- mod/forum/post.php | 106 ++++++------ mod/forum/rate.php | 18 +- mod/forum/report.php | 18 +- mod/forum/search.php | 8 +- mod/forum/settracking.php | 8 +- mod/forum/subscribe.php | 18 +- mod/forum/subscribers.php | 10 +- mod/forum/user.php | 10 +- mod/forum/view.php | 18 +- mod/glossary/approve.php | 8 +- mod/glossary/comment.php | 48 +++--- mod/glossary/comments.php | 8 +- mod/glossary/deleteentry.php | 14 +- mod/glossary/edit.php | 20 +-- mod/glossary/editcategories.php | 14 +- mod/glossary/export.php | 6 +- mod/glossary/exportentry.php | 6 +- mod/glossary/exportfile.php | 6 +- mod/glossary/import.php | 16 +- mod/glossary/index.php | 2 +- mod/glossary/lib.php | 10 +- mod/glossary/print.php | 6 +- mod/glossary/rate.php | 18 +- mod/glossary/report.php | 14 +- mod/glossary/showentry.php | 4 +- mod/glossary/view.php | 14 +- mod/hotpot/attempt.php | 22 +-- mod/hotpot/grade.php | 6 +- mod/hotpot/index.php | 4 +- mod/hotpot/lib.php | 26 +-- mod/hotpot/report.php | 16 +- mod/hotpot/review.php | 20 +-- mod/hotpot/show.php | 2 +- mod/hotpot/template/default.php | 4 +- mod/hotpot/view.php | 16 +- mod/journal/edit.php | 12 +- mod/journal/index.php | 2 +- mod/journal/lib.php | 2 +- mod/journal/report.php | 8 +- mod/journal/view.php | 8 +- mod/label/view.php | 12 +- mod/lams/index.php | 2 +- mod/lams/view.php | 6 +- mod/lesson/action/addbranchtable.php | 2 +- mod/lesson/action/addcluster.php | 12 +- mod/lesson/action/addendofbranch.php | 14 +- mod/lesson/action/addendofcluster.php | 10 +- mod/lesson/action/confirmdelete.php | 4 +- mod/lesson/action/continue.php | 26 +-- mod/lesson/action/delete.php | 18 +- mod/lesson/action/editpage.php | 6 +- mod/lesson/action/insertpage.php | 20 +-- mod/lesson/action/move.php | 4 +- mod/lesson/action/moveit.php | 38 ++--- mod/lesson/action/updatepage.php | 16 +- mod/lesson/backuplib.php | 2 +- mod/lesson/edit.php | 4 +- mod/lesson/essay.php | 24 +-- mod/lesson/format.php | 10 +- mod/lesson/grade.php | 6 +- mod/lesson/highscores.php | 12 +- mod/lesson/import.php | 14 +- mod/lesson/importppt.php | 24 +-- mod/lesson/index.php | 2 +- mod/lesson/lesson.php | 2 +- mod/lesson/locallib.php | 24 +-- mod/lesson/mediafile.php | 8 +- mod/lesson/pagelib.php | 2 +- mod/lesson/report.php | 6 +- mod/lesson/restorelib.php | 4 +- mod/lesson/tabs.php | 2 +- mod/lesson/view.php | 38 ++--- mod/quiz/attempt.php | 18 +- mod/quiz/comment.php | 12 +- mod/quiz/edit.php | 22 +-- mod/quiz/editlib.php | 4 +- mod/quiz/grade.php | 6 +- mod/quiz/index.php | 2 +- mod/quiz/locallib.php | 2 +- mod/quiz/pagelib.php | 2 +- mod/quiz/quizfile.php | 22 +-- mod/quiz/report.php | 16 +- mod/quiz/report/analysis/report.php | 12 +- mod/quiz/report/grading/report.php | 8 +- mod/quiz/report/overview/report.php | 2 +- mod/quiz/report/regrade/report.php | 2 +- mod/quiz/review.php | 10 +- mod/quiz/reviewquestion.php | 30 ++-- mod/quiz/tabs.php | 2 +- mod/quiz/view.php | 12 +- mod/resource/index.php | 2 +- mod/resource/lib.php | 8 +- mod/resource/mod_form.php | 2 +- .../type/directory/resource.class.php | 2 +- mod/resource/type/file/localfile.php | 2 +- mod/resource/view.php | 12 +- mod/scorm/aicc.php | 8 +- mod/scorm/api.php | 16 +- mod/scorm/datamodel.php | 14 +- mod/scorm/index.php | 4 +- mod/scorm/loadSCO.php | 14 +- mod/scorm/locallib.php | 2 +- mod/scorm/player.php | 14 +- mod/scorm/report.php | 18 +- mod/scorm/view.php | 14 +- mod/survey/download.php | 14 +- mod/survey/graph.php | 10 +- mod/survey/index.php | 2 +- mod/survey/mod_form.php | 2 +- mod/survey/report.php | 12 +- mod/survey/save.php | 10 +- mod/survey/view.php | 10 +- mod/wiki/admin.php | 28 ++-- mod/wiki/ewiki/ewiki.php | 4 +- .../plugins/moodle/moodle_binary_store.php | 12 +- .../ewiki/plugins/moodle/moodle_wikidump.php | 16 +- mod/wiki/index.php | 2 +- mod/wiki/lib.php | 16 +- mod/wiki/overridelock.php | 16 +- mod/wiki/view.php | 14 +- mod/workshop/assess.php | 14 +- mod/workshop/assessments.php | 114 ++++++------- mod/workshop/index.php | 2 +- mod/workshop/lib.php | 14 +- mod/workshop/locallib.php | 98 +++++------ mod/workshop/submissions.php | 48 +++--- mod/workshop/upload.php | 8 +- mod/workshop/view.php | 8 +- mod/workshop/viewassessment.php | 10 +- notes/add.php | 4 +- notes/delete.php | 12 +- notes/edit.php | 6 +- notes/index.php | 4 +- question/category.php | 2 +- question/category_class.php | 22 +-- question/contextmove.php | 12 +- question/contextmoveq.php | 12 +- question/editlib.php | 22 +-- question/export.php | 8 +- question/file.php | 8 +- question/format.php | 6 +- question/format/blackboard_6/format.php | 8 +- question/format/coursetestmanager/format.php | 8 +- question/format/qti2/format.php | 22 +-- question/format/webct/format.php | 10 +- question/format/xml/format.php | 2 +- question/import.php | 12 +- question/preview.php | 12 +- question/question.php | 2 +- question/restorelib.php | 2 +- question/tabs.php | 2 +- question/type/calculated/questiontype.php | 18 +- .../type/datasetdependent/abstractqtype.php | 30 ++-- question/type/description/questiontype.php | 2 +- question/type/match/questiontype.php | 2 +- .../multianswer/edit_multianswer_form.php | 2 +- question/type/multianswer/questiontype.php | 8 +- question/type/multichoice/questiontype.php | 4 +- question/type/numerical/questiontype.php | 2 +- question/type/questiontype.php | 10 +- question/type/random/questiontype.php | 4 +- search/tests/index.php | 6 +- tag/edit.php | 4 +- tag/user.php | 4 +- theme/chameleon/ui/css.php | 2 +- theme/index.php | 4 +- theme/preview.php | 2 +- user/addnote.php | 4 +- user/edit.php | 10 +- user/editadvanced.php | 12 +- user/extendenrol.php | 4 +- user/filters/lib.php | 8 +- user/groupaddnote.php | 2 +- user/groupextendenrol.php | 2 +- user/index.php | 10 +- user/messageselect.php | 2 +- user/policy.php | 2 +- user/profile/definelib.php | 16 +- user/profile/lib.php | 4 +- user/tabs.php | 2 +- user/view.php | 6 +- userpix/index.php | 2 +- userpix/upgrade.php | 2 +- 422 files changed, 2327 insertions(+), 2287 deletions(-) diff --git a/admin/auth_config.php b/admin/auth_config.php index e8190c3e23d59..d0bc55d763569 100644 --- a/admin/auth_config.php +++ b/admin/auth_config.php @@ -34,7 +34,7 @@ $plugin = "auth/$auth"; $name = $matches[1]; if (!set_config($name, $value, $plugin)) { - error("Problem saving config $name as $value for plugin $plugin"); + print_error("Problem saving config $name as $value for plugin $plugin"); } } } diff --git a/admin/block.php b/admin/block.php index d21218f23c7d1..ffe68d0d77b74 100644 --- a/admin/block.php +++ b/admin/block.php @@ -9,14 +9,14 @@ $blockid = required_param('block', PARAM_INT); if(!$blockrecord = blocks_get_record($blockid)) { - error('This block does not exist'); + print_error('This block does not exist'); } admin_externalpage_setup('blocksetting'.$blockrecord->name); $block = block_instance($blockrecord->name); if($block === false) { - error('Problem in instantiating block object'); + print_error('Problem in instantiating block object'); } // Define the data we're going to silently include in the instance config form here, @@ -31,10 +31,10 @@ if ($config = data_submitted()) { if (!confirm_sesskey()) { - error(get_string('confirmsesskeybad', 'error')); + print_error('confirmsesskeybad', 'error'); } if(!$block->has_config()) { - error('This block does not support global configuration'); + print_error('This block does not support global configuration'); } $remove = array_keys($hiddendata); foreach($remove as $item) { diff --git a/admin/blocks.php b/admin/blocks.php index 277645a49b289..05131c396ede0 100644 --- a/admin/blocks.php +++ b/admin/blocks.php @@ -33,7 +33,7 @@ if (!empty($hide) && confirm_sesskey()) { if (!$block = get_record('block', 'id', $hide)) { - error("Block doesn't exist!"); + print_error("Block doesn't exist!"); } set_field('block', 'visible', '0', 'id', $block->id); // Hide block admin_get_root(true, false); // settings not required - only pages @@ -41,7 +41,7 @@ if (!empty($show) && confirm_sesskey() ) { if (!$block = get_record('block', 'id', $show)) { - error("Block doesn't exist!"); + print_error("Block doesn't exist!"); } set_field('block', 'visible', '1', 'id', $block->id); // Show block admin_get_root(true, false); // settings not required - only pages @@ -49,7 +49,7 @@ if (!empty($multiple) && confirm_sesskey()) { if (!$block = blocks_get_record($multiple)) { - error("Block doesn't exist!"); + print_error("Block doesn't exist!"); } $block->multiple = !$block->multiple; update_record('block', $block); @@ -61,7 +61,7 @@ print_heading($strmanageblocks); if (!$block = blocks_get_record($delete)) { - error("Block doesn't exist!"); + print_error("Block doesn't exist!"); } if (!block_is_compatible($block->name)) { @@ -123,7 +123,7 @@ /// Get and sort the existing blocks if (false === ($blocks = get_records('block'))) { - error('No blocks found!'); // Should never happen + print_error('No blocks found!'); // Should never happen } $incompatible = array(); @@ -143,7 +143,7 @@ } if(empty($blockbyname)) { - error('One or more blocks are registered in the database, but they all failed to load!'); + print_error('One or more blocks are registered in the database, but they all failed to load!'); } ksort($blockbyname); diff --git a/admin/cliupgrade.php b/admin/cliupgrade.php index c8a7b710c4c38..c5035da6b3d6d 100644 --- a/admin/cliupgrade.php +++ b/admin/cliupgrade.php @@ -1234,10 +1234,10 @@ mark_context_dirty('/'.SYSCONTEXTID); // do nothing } else { - error("Serious Error! Could not set up a default course category!"); + print_error("Serious Error! Could not set up a default course category!"); } } else { - error("Serious Error! Could not set up the site!"); + print_error("Serious Error! Could not set up the site!"); } } diff --git a/admin/delete.php b/admin/delete.php index 1498dbfcaa29d..bc70d504813e5 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -37,7 +37,7 @@ } if (!confirm_sesskey()) { - error('This script was called wrongly'); + print_error('This script was called wrongly'); } /// OK, here goes ... diff --git a/admin/filter.php b/admin/filter.php index ce75068ef8385..8c51c70f4ecbf 100644 --- a/admin/filter.php +++ b/admin/filter.php @@ -31,7 +31,7 @@ // check session key if (!confirm_sesskey()) { - error( get_string('confirmsesskeybad', 'error' ) ); + print_error('confirmsesskeybad', 'error'); } $configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php'; diff --git a/admin/filters.php b/admin/filters.php index 57d6c7c4c2b0a..acfad110568cb 100644 --- a/admin/filters.php +++ b/admin/filters.php @@ -53,7 +53,7 @@ case 'show': // check filterpath is valid if (!array_key_exists($filterpath, $installedfilters)) { - error("Filter $filterpath is not currently installed", $url); + print_error("Filter $filterpath is not currently installed", '', $url); } elseif (array_search($filterpath,$activefilters)) { // filterpath is already active - doubleclick?? } else { @@ -67,7 +67,7 @@ $key=array_search($filterpath, $activefilters); // check filterpath is valid if ($key===false) { - error("Filter $filterpath is not currently active", $url); + print_error("Filter $filterpath is not currently active", '', $url); } elseif ($key>=(count($activefilters)-1)) { // cannot be moved any further down - doubleclick?? } else { @@ -82,7 +82,7 @@ $key=array_search($filterpath, $activefilters); // check filterpath is valid if ($key===false) { - error("Filter $filterpath is not currently active", $url); + print_error("Filter $filterpath is not currently active", '', $url); } elseif ($key<1) { //cannot be moved any further up - doubleclick?? } else { diff --git a/admin/index.php b/admin/index.php index c429aa018ba43..4cea1b6b7cd54 100644 --- a/admin/index.php +++ b/admin/index.php @@ -50,29 +50,29 @@ $documentationlink = 'Installation docs'; if (ini_get_bool('session.auto_start')) { - error("The PHP server variable 'session.auto_start' should be Off - $documentationlink"); + print_error("The PHP server variable 'session.auto_start' should be Off - $documentationlink"); } if (ini_get_bool('magic_quotes_runtime')) { - error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink"); + print_error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink"); } if (!ini_get_bool('file_uploads')) { - error("The PHP server variable 'file_uploads' is not turned On - $documentationlink"); + print_error("The PHP server variable 'file_uploads' is not turned On - $documentationlink"); } if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') { //Enforce prefixes for everybody but mysql - error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')'); + print_error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')'); } if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc - error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.'); + print_error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.'); } /// Check that config.php has been edited if ($CFG->wwwroot == "http://example.com/moodle") { - error("Moodle has not been configured yet. You need to edit config.php first."); + print_error("Moodle has not been configured yet. You need to edit config.php first."); } @@ -80,7 +80,7 @@ $dirroot = dirname(realpath("../index.php")); if (!empty($dirroot) and $dirroot != $CFG->dirroot) { - error("Please fix your settings in config.php: + print_error("Please fix your settings in config.php:

You have:

\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";

but it should be: @@ -100,11 +100,11 @@ } if (is_readable("$CFG->dirroot/version.php")) { - include_once("$CFG->dirroot/version.php"); # defines $version + include_once("$CFG->dirroot/version.php"); // defines $version } if (!$version or !$release) { - error('Main version.php was not readable or specified');# without version, stop + print_error('Main version.php was not readable or specified'); // without version, stop } /// Check if the main tables have been installed yet or not. @@ -186,7 +186,7 @@ } else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) { $status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method } else { - error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory."); + print_error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory."); } // all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks @@ -223,7 +223,7 @@ notify($strdatabasesuccess, "green"); require_once $CFG->dirroot.'/mnet/lib.php'; } else { - error("Error: Main databases NOT set up successfully"); + print_error("Error: Main databases NOT set up successfully"); } print_continue('index.php'); print_footer('none'); @@ -367,7 +367,7 @@ moodle_install_roles(); set_config('rolesactive', 1); } else if (!update_capabilities()) { - error('Had trouble upgrading the core capabilities for the Roles System'); + print_error('Had trouble upgrading the core capabilities for the Roles System'); } // update core events events_update_definition(); @@ -383,7 +383,7 @@ print_footer('none'); exit; } else { - error('Upgrade failed! (Could not update version in config table)'); + print_error('Upgrade failed! (Could not update version in config table)'); } /// Main upgrade not success } else { @@ -401,7 +401,7 @@ } } else { if (!set_config("version", $version)) { - error("A problem occurred inserting current version into databases"); + print_error("A problem occurred inserting current version into databases"); } } @@ -409,7 +409,7 @@ if ($release <> $CFG->release) { // Update the release version if (!set_config("release", $release)) { - error("ERROR: Could not update release version in database!!"); + print_error("ERROR: Could not update release version in database!!"); } } @@ -495,7 +495,7 @@ $newsite->timemodified = time(); if (!$newid = insert_record('course', $newsite)) { - error("Serious Error! Could not set up the site!"); + print_error("Serious Error! Could not set up the site!"); } // make sure course context exists get_context_instance(CONTEXT_COURSE, $newid); @@ -508,7 +508,7 @@ $cat->name = get_string('miscellaneous'); $cat->depth = 1; if (!$catid = insert_record('course_categories', $cat)) { - error("Serious Error! Could not set up a default course category!"); + print_error("Serious Error! Could not set up a default course category!"); } // make sure category context exists get_context_instance(CONTEXT_COURSECAT, $catid); diff --git a/admin/lang.php b/admin/lang.php index 830c3e0863d25..ebec49bbbeec5 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -164,7 +164,7 @@ $stringfiles += lang_extra_locations(); } if (count($stringfiles) == 0) { - error("Could not find English language pack!"); + print_error("Could not find English language pack!"); } } elseif ($mode == 'helpfiles') { $helpfiles = lang_help_standard_locations(); @@ -172,7 +172,7 @@ $helpfiles += lang_help_extra_locations(); } if (count($helpfiles) == 0) { - error("Could not find help files in the English language pack!"); + print_error("Could not find help files in the English language pack!"); } } @@ -331,7 +331,7 @@ echo $o; if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) { - error("Could not find English language help files!"); + print_error("Could not find English language help files!"); } foreach ($files as $filekey => $file) { // check all the help files. @@ -343,7 +343,7 @@ } if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) { - error("Could not find English language docs files!"); + print_error("Could not find English language docs files!"); } foreach ($files as $filekey => $file) { // check all the docs files. if (!file_exists("$langdir/docs/$file")) { @@ -363,7 +363,7 @@ if (!file_exists($langbase) ){ if (!lang_make_directory($langbase) ){ - error('ERROR: Could not create base lang directory ' . $langbase); + print_error('ERROR: Could not create base lang directory ' . $langbase); } else { echo '

Created directory '. $langbase .'
'."
\n"; @@ -371,7 +371,7 @@ } if (!$uselocal && !file_exists($langdir)) { if (!lang_make_directory($langdir)) { - error('ERROR: Could not create directory '.$langdir); + print_error('ERROR: Could not create directory '.$langdir); } else { echo '
Created directory '. $langdir .'
'."
\n"; @@ -390,7 +390,7 @@ if ($currentfile <> '') { if (!$fileinfo = lang_get_file_info($currentfile, $stringfiles)) { - error('Unable to find info for: '.$currentfile); + print_error('Unable to find info for: '.$currentfile); } // check the filename is set up correctly, prevents bugs similar to MDL-10920 $location = $fileinfo['location']; @@ -400,7 +400,7 @@ if ($location || $plugin) { // file in an extra location if ($currentfile != "{$prefix}{$plugin}.php") { - error("Non-core filename mismatch. The file $currentfile should be {$prefix}{$plugin}.php"); + print_error("Non-core filename mismatch. The file $currentfile should be {$prefix}{$plugin}.php"); } if (!$uselocal) { notify($streditingnoncorelangfile); @@ -409,7 +409,7 @@ } else { // file in standard location if ($currentfile != $filename) { - error("Core filename mismatch. The file $currentfile should be $filename"); + print_error("Core filename mismatch. The file $currentfile should be $filename"); } } @@ -435,7 +435,7 @@ if (isset($_POST['currentfile'])){ // Save a file if (!confirm_sesskey()) { - error(get_string('confirmsesskeybad', 'error')); + print_error('confirmsesskeybad', 'error'); } $newstrings = array(); @@ -463,7 +463,7 @@ if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) { notify(get_string("changessaved")." ($saveinto/$currentfile)", "notifysuccess"); } else { - error("Could not save the file '$saveinto/$currentfile'!", "lang.php?mode=compare&currentfile=$currentfile"); + print_error("Could not save the file '$saveinto/$currentfile'!", '', "lang.php?mode=compare&currentfile=$currentfile"); } unset($packstring); } @@ -707,12 +707,12 @@ if (isset($_POST['currentfile'])) { // Save a file if (!confirm_sesskey()) { - error(get_string('confirmsesskeybad', 'error')); + print_error('confirmsesskeybad', 'error'); } if (lang_help_save_file($saveto, $currentfile, $_POST['filedata'])) { notify(get_string("changessaved")." ($saveto/$currentfile)", "notifysuccess"); } else { - error("Could not save the file '$currentfile'!", "lang.php?mode=helpfiles&currentfile=$currentfile&sesskey=$USER->sesskey"); + print_error("Could not save the file '$currentfile'!", '', "lang.php?mode=helpfiles&currentfile=$currentfile&sesskey=$USER->sesskey"); } } diff --git a/admin/langdoc.php b/admin/langdoc.php index e04fc68169659..b456ac1961afa 100755 --- a/admin/langdoc.php +++ b/admin/langdoc.php @@ -51,7 +51,7 @@ if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) { notify(get_string("changessaved")." ($langdir/$currentfile)", "green"); } else { - error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey"); + print_error("Could not save the file '$currentfile'!", '', "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey"); } } } @@ -63,7 +63,7 @@ // Get all files from /docs directory if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) { - error("Could not find English language docs files!"); + print_error("Could not find English language docs files!"); } $options = array(); @@ -83,7 +83,7 @@ // Get all files from /help directory if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) { - error("Could not find English language help files!"); + print_error("Could not find English language help files!"); } foreach ($files as $filekey => $file) { // check all the help files. diff --git a/admin/langimport.php b/admin/langimport.php index 6ace99dcc4302..d5d3d2d1f1f39 100755 --- a/admin/langimport.php +++ b/admin/langimport.php @@ -30,7 +30,7 @@ //reset and diagnose lang cache permissions @unlink($CFG->dataroot.'/cache/languages'); if (file_exists($CFG->dataroot.'/cache/languages')) { - error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!'); + print_error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!'); } get_list_of_languages(true); //refresh lang cache diff --git a/admin/maintenance.php b/admin/maintenance.php index aecd668f836cc..6f0498d3ebbe8 100644 --- a/admin/maintenance.php +++ b/admin/maintenance.php @@ -10,7 +10,7 @@ //Check folder exists if (! make_upload_directory(SITEID)) { // Site folder - error("Could not create site folder. The site administrator needs to fix the file permissions"); + print_error("Could not create site folder. The site administrator needs to fix the file permissions"); } $filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html'; diff --git a/admin/mnet/index.php b/admin/mnet/index.php index ee017d9bfa179..65117677f4d7d 100644 --- a/admin/mnet/index.php +++ b/admin/mnet/index.php @@ -17,19 +17,19 @@ if (!extension_loaded('openssl')) { admin_externalpage_print_header(); set_config('mnet_dispatcher_mode', 'off'); - print_error('requiresopenssl', 'mnet', '', NULL, true); + print_error('requiresopenssl', 'mnet'); } if (!$site = get_site()) { admin_externalpage_print_header(); set_config('mnet_dispatcher_mode', 'off'); - print_error('nosite', '', '', NULL, true); + print_error('nosite'); } if (!function_exists('curl_init') ) { admin_externalpage_print_header(); set_config('mnet_dispatcher_mode', 'off'); - print_error('nocurl', 'mnet', '', NULL, true); + print_error('nocurl', 'mnet'); } if (!isset($CFG->mnet_dispatcher_mode)) { @@ -43,7 +43,7 @@ if (set_config('mnet_dispatcher_mode', $form->mode)) { redirect('index.php', get_string('changessaved')); } else { - error('Invalid action parameter.', 'index.php'); + print_error('Invalid action parameter.', '', 'index.php'); } } } elseif (!empty($form->submit) && $form->submit == get_string('delete')) { diff --git a/admin/mnet/peers.php b/admin/mnet/peers.php index 09ae5d314aa22..2448c6441baf3 100644 --- a/admin/mnet/peers.php +++ b/admin/mnet/peers.php @@ -15,17 +15,17 @@ if (!extension_loaded('openssl')) { admin_externalpage_print_header(); - print_error('requiresopenssl', 'mnet', '', NULL, true); + print_error('requiresopenssl', 'mnet'); } if (!$site = get_site()) { admin_externalpage_print_header(); - print_error('nosite', '', '', NULL, true); + print_error('nosite', ''); } if (!function_exists('curl_init') ) { admin_externalpage_print_header(); - print_error('nocurl', 'mnet', '', NULL, true); + print_error('nocurl', 'mnet'); } /// Initialize variables. @@ -59,7 +59,7 @@ if(!function_exists('xmlrpc_encode_request')) { trigger_error("You must have xml-rpc enabled in your PHP build to use this feature."); - error(get_string('xmlrpc-missing', 'mnet'),'peers.php'); + print_error('xmlrpc-missing', 'mnet','peers.php'); exit; } @@ -82,7 +82,7 @@ $temp_wwwroot = clean_param($form->wwwroot, PARAM_URL); if ($temp_wwwroot !== $form->wwwroot) { trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc."); - error(get_string("invalidurl", 'mnet'),'peers.php'); + print_error("invalidurl", 'mnet','peers.php'); exit; } unset($temp_wwwroot); @@ -103,7 +103,7 @@ if (isset($form->public_key)) { $form->public_key = clean_param($form->public_key, PARAM_PEM); if (empty($form->public_key)) { - error(get_string("invalidpubkey", 'mnet'),'peers.php?step=update&hostid='.$mnet_peer->id); + print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id); exit; } else { $oldkey = $mnet_peer->public_key; @@ -116,7 +116,8 @@ foreach ($mnet_peer->error as $err) { $errmsg .= $err['code'] . ': ' . $err['text'].'
'; } - error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id); + //error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id); + print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $errmsg); exit; } } @@ -127,7 +128,7 @@ // PREVENT DUPLICATE RECORDS /////////////////////////////////////////// if ('input' == $form->step) { if ( isset($mnet_peer->id) && $mnet_peer->id > 0 ) { - error(get_string("hostexists", 'mnet', $mnet_peer->id),'peers.php?step=update&hostid='.$mnet_peer->id); + print_error("hostexists", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $mnet_peer->id); } } @@ -138,7 +139,7 @@ if ($bool) { redirect('peers.php?step=update&hostid='.$mnet_peer->id, get_string('changessaved')); } else { - error('Invalid action parameter.', 'index.php'); + print_error('Invalid action parameter.', '', 'index.php'); } } } diff --git a/admin/modules.php b/admin/modules.php index 1050864500733..8c53465b2d7a9 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -34,7 +34,7 @@ if (!empty($hide) and confirm_sesskey()) { if (!$module = get_record("modules", "name", $hide)) { - error("Module doesn't exist!"); + print_error("Module doesn't exist!"); } set_field("modules", "visible", "0", "id", $module->id); // Hide main module // Remember the visibility status in visibleold @@ -57,7 +57,7 @@ if (!empty($show) and confirm_sesskey()) { if (!$module = get_record("modules", "name", $show)) { - error("Module doesn't exist!"); + print_error("Module doesn't exist!"); } set_field("modules", "visible", "1", "id", $module->id); // Show main module set_field('course_modules', 'visible', '1', 'visibleold', @@ -89,11 +89,11 @@ } else { // Delete everything!! if ($delete == "forum") { - error("You can not delete the forum module!!"); + print_error("You can not delete the forum module!!"); } if (!$module = get_record("modules", "name", $delete)) { - error("Module doesn't exist!"); + print_error("Module doesn't exist!"); } // OK, first delete all the relevant instances from all course sections @@ -180,7 +180,7 @@ /// Get and sort the existing modules if (!$modules = get_records("modules")) { - error("No modules found!!"); // Should never happen + print_error("No modules found!!"); // Should never happen } foreach ($modules as $module) { diff --git a/admin/multilangupgrade.php b/admin/multilangupgrade.php index 1ab04d54170e4..257bea2c72151 100644 --- a/admin/multilangupgrade.php +++ b/admin/multilangupgrade.php @@ -25,7 +25,7 @@ if (!$tables = $db->Metatables() ) { // No tables yet at all. - error("no tables"); + print_error("no tables"); } print_simple_box_start('center'); diff --git a/admin/register.php b/admin/register.php index ce558f4824b0c..877b787a1f7ca 100644 --- a/admin/register.php +++ b/admin/register.php @@ -12,11 +12,11 @@ } if (!confirm_sesskey()) { - error(get_string('confirmsesskeybad', 'error')); + print_error('confirmsesskeybad', 'error'); } if (!$admin = get_admin()) { - error("No admins"); + print_error("No admins"); } if (!$admin->country and $CFG->country) { diff --git a/admin/replace.php b/admin/replace.php index 064b024c7a61e..98783ca50760e 100644 --- a/admin/replace.php +++ b/admin/replace.php @@ -35,7 +35,7 @@ print_simple_box_start('center'); if (!db_replace($search, $replace)) { - error('An error has occured during this process'); + print_error('An error has occured during this process'); } print_simple_box_end(); diff --git a/admin/report/stats/index.php b/admin/report/stats/index.php index 0cfd68de55844..149f769af2cb0 100644 --- a/admin/report/stats/index.php +++ b/admin/report/stats/index.php @@ -32,12 +32,12 @@ } if (!$course = get_record("course","id",$courseid)) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } if (!empty($userid)) { if (!$user = get_record('user','id',$userid)) { - error("That's an invalid user id"); + print_error("That's an invalid user id"); } } diff --git a/admin/roles/assign.php b/admin/roles/assign.php index fe574597abc0d..435b1a818c1e7 100755 --- a/admin/roles/assign.php +++ b/admin/roles/assign.php @@ -34,7 +34,7 @@ } if (! $context = get_context_instance_by_id($contextid)) { - error("Context ID was incorrect (can't find it)"); + print_error("Context ID was incorrect (can't find it)"); } $inmeta = 0; @@ -43,13 +43,13 @@ if ($course = get_record('course', 'id', $courseid)) { $inmeta = $course->metacourse; } else { - error('Invalid course id'); + print_error('Invalid course id'); } $coursecontext = $context; } else if (!empty($courseid)){ // we need this for user tabs in user context if (!$course = get_record('course', 'id', $courseid)) { - error('Invalid course id'); + print_error('Invalid course id'); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); diff --git a/admin/roles/manage.php b/admin/roles/manage.php index c362ecebfe5b9..727ca64baa9a8 100755 --- a/admin/roles/manage.php +++ b/admin/roles/manage.php @@ -222,7 +222,7 @@ $role->description = $description; if (!update_record('role', $role)) { - error('Could not update role!'); + print_error('Could not update role!'); } // set proper legacy type @@ -249,7 +249,7 @@ case 'delete': if (in_array($roleid, $defaultroles)) { - error('This role is used as one of the default system roles, it can not be deleted'); + print_error('This role is used as one of the default system roles, it can not be deleted'); } if ($confirm and data_submitted() and confirm_sesskey()) { if (!delete_role($roleid)) { @@ -257,7 +257,7 @@ // partially deleted a role sitewide...? mark_context_dirty($sitecontext->path); - error('Could not delete role with ID '.$roleid); + print_error('Could not delete role with ID '.$roleid); } // deleted a role sitewide... mark_context_dirty($sitecontext->path); @@ -286,7 +286,7 @@ $above = $roles[$rolesort[$role->sortorder - 1]]; if (!switch_roles($role, $above)) { - error("Cannot move role with ID $roleid"); + print_error("Cannot move role with ID $roleid"); } } } @@ -301,7 +301,7 @@ $below = $roles[$rolesort[$role->sortorder + 1]]; if (!switch_roles($role, $below)) { - error("Cannot move role with ID $roleid"); + print_error("Cannot move role with ID $roleid"); } } } @@ -436,7 +436,7 @@ $role = stripslashes_safe($newrole); } else { if(!$role = get_record('role', 'id', $roleid)) { - error('Incorrect role ID!'); + print_error('Incorrect role ID!'); } $role->legacytype = get_legacy_type($role->id); } diff --git a/admin/roles/override.php b/admin/roles/override.php index 27a6c8518dfd3..a49409ad774a9 100755 --- a/admin/roles/override.php +++ b/admin/roles/override.php @@ -9,24 +9,24 @@ $cancel = optional_param('cancel', 0, PARAM_BOOL); if (!$context = get_record('context', 'id', $contextid)) { - error('Bad context ID'); + print_error('Bad context ID'); } if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) { - error('No site ID'); + print_error('No site ID'); } if ($context->id == $sitecontext->id) { - error('Can not override base role capabilities'); + print_error('Can not override base role capabilities'); } if (!has_capability('moodle/role:override', $context)) { - error('You do not have permission to change overrides in this context!'); + print_error('You do not have permission to change overrides in this context!'); } if ($courseid) { if (!$course = get_record('course', 'id', $courseid)) { - error('Bad course ID'); + print_error('Bad course ID'); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); diff --git a/admin/roles/tabs.php b/admin/roles/tabs.php index be51f4a714b0b..e19b81c704c3e 100755 --- a/admin/roles/tabs.php +++ b/admin/roles/tabs.php @@ -61,16 +61,16 @@ case CONTEXT_MODULE: // get module type? if (!$cm = get_record('course_modules','id',$context->instanceid)) { - error('Bad course module ID'); + print_error('Bad course module ID'); } if (!$module = get_record('modules','id',$cm->module)) { //$module->name; - error('Bad module ID'); + print_error('Bad module ID'); } if (!$course = get_record('course','id',$cm->course)) { - error('Bad course ID'); + print_error('Bad course ID'); } if (!$instance = get_record($module->name, 'id', $cm->instance)) { - error("The required instance of this module doesn't exist"); + print_error("The required instance of this module doesn't exist"); } require_login($course); diff --git a/admin/upgradeforumread.php b/admin/upgradeforumread.php index c8db682c78036..edf0c4d791c83 100644 --- a/admin/upgradeforumread.php +++ b/admin/upgradeforumread.php @@ -9,7 +9,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); if ($CFG->version < 2005042300) { - error("This script does not work with this old version of Moodle"); + print_error("This script does not work with this old version of Moodle"); } if (!$site = get_site()) { diff --git a/admin/upgradelogs.php b/admin/upgradelogs.php index 2803e2c2370dd..fa27125d0abf7 100644 --- a/admin/upgradelogs.php +++ b/admin/upgradelogs.php @@ -8,7 +8,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); if ($CFG->version < 2004013101) { - error("This script does not work with this old version of Moodle"); + print_error("This script does not work with this old version of Moodle"); } if (!$site = get_site()) { diff --git a/admin/uploadpicture.php b/admin/uploadpicture.php index c785b02ac0c1b..99dce0de52c1a 100644 --- a/admin/uploadpicture.php +++ b/admin/uploadpicture.php @@ -35,11 +35,11 @@ require_capability('moodle/site:uploadusers', get_context_instance(CONTEXT_SYSTEM, SITEID)); if (!$site = get_site()) { - error("Could not find site-level course"); + print_error("Could not find site-level course"); } if (!$adminuser = get_admin()) { - error("Could not find site admin"); + print_error("Could not find site admin"); } $strfile = get_string('file'); diff --git a/admin/uploaduser.php b/admin/uploaduser.php index 550c1992e6802..b8f8854d9f8f0 100755 --- a/admin/uploaduser.php +++ b/admin/uploaduser.php @@ -92,9 +92,9 @@ unset($content); if ($readcount === false) { - error($cir->get_error(), $returnurl); + print_error($cir->get_error(), '', $returnurl); } else if ($readcount == 0) { - error(get_string('csvemptyfile', 'error'), $returnurl); + print_error('csvemptyfile', 'error', $returnurl); } // continue to form2 @@ -110,7 +110,7 @@ } if (!$columns = $cir->get_columns()) { - error('Error reading temporary file', $returnurl); + print_error('Error reading temporary file', '', $returnurl); } $mform = new admin_uploaduser_form2(null, $columns); // get initial date from form1 diff --git a/admin/user.php b/admin/user.php index 9ae92ee2bfe5b..eb1fd6f559796 100644 --- a/admin/user.php +++ b/admin/user.php @@ -22,7 +22,7 @@ $site = get_site(); if (!has_capability('moodle/user:update', $sitecontext) and !has_capability('moodle/user:delete', $sitecontext)) { - error('You do not have the required permission to edit/delete users.'); + print_error('You do not have the required permission to edit/delete users.'); } $stredit = get_string('edit'); @@ -40,7 +40,7 @@ if ($confirmuser and confirm_sesskey()) { if (!$user = get_record('user', 'id', $confirmuser)) { - error("No such user!", '', true); + print_error("No such user!"); } $auth = get_auth_plugin($user->auth); @@ -56,15 +56,15 @@ } else if ($delete and confirm_sesskey()) { // Delete a selected user, after confirmation if (!has_capability('moodle/user:delete', $sitecontext)) { - error('You do not have the required permission to delete a user.'); + print_error('You do not have the required permission to delete a user.'); } if (!$user = get_record('user', 'id', $delete)) { - error("No such user!", '', true); + print_error("No such user!"); } if (is_primary_admin($user->id)) { - error("You are not allowed to delete the primary admin user!", '', true); + print_error("You are not allowed to delete the primary admin user!"); } if ($confirm != md5($delete)) { @@ -84,17 +84,17 @@ } else if ($acl and confirm_sesskey()) { if (!has_capability('moodle/user:delete', $sitecontext)) { // TODO: this should be under a separate capability - error('You are not permitted to modify the MNET access control list.'); + print_error('You are not permitted to modify the MNET access control list.'); } if (!$user = get_record('user', 'id', $acl)) { - error("No such user.", '', true); + print_error("No such user."); } if (!is_mnet_remote_user($user)) { - error('Users in the MNET access control list must be remote MNET users.'); + print_error('Users in the MNET access control list must be remote MNET users.'); } $accessctrl = strtolower(required_param('accessctrl', PARAM_ALPHA)); if ($accessctrl != 'allow' and $accessctrl != 'deny') { - error('Invalid access parameter.'); + print_error('Invalid access parameter.'); } $aclrecord = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid); if (empty($aclrecord)) { @@ -103,12 +103,12 @@ $aclrecord->username = $user->username; $aclrecord->accessctrl = $accessctrl; if (!insert_record('mnet_sso_access_control', $aclrecord)) { - error("Database error - Couldn't modify the MNET access control list.", '', true); + print_error("Database error - Couldn't modify the MNET access control list."); } } else { $aclrecord->accessctrl = $accessctrl; if (!update_record('mnet_sso_access_control', $aclrecord)) { - error("Database error - Couldn't modify the MNET access control list.", '', true); + print_error("Database error - Couldn't modify the MNET access control list."); } } $mnethosts = get_records('mnet_host', '', '', 'id', 'id,wwwroot,name'); diff --git a/admin/user/user_bulk_message.php b/admin/user/user_bulk_message.php index 42751ccca0def..0015219a21bde 100755 --- a/admin/user/user_bulk_message.php +++ b/admin/user/user_bulk_message.php @@ -17,7 +17,7 @@ } if (empty($CFG->messaging)) { - error("Messaging is disabled on this site"); + print_error("Messaging is disabled on this site"); } //TODO: add support for large number of users diff --git a/admin/xmldb/actions/edit_field_save/edit_field_save.class.php b/admin/xmldb/actions/edit_field_save/edit_field_save.class.php index 41c2a8dd86acd..2d991345aa749 100644 --- a/admin/xmldb/actions/edit_field_save/edit_field_save.class.php +++ b/admin/xmldb/actions/edit_field_save/edit_field_save.class.php @@ -76,7 +76,7 @@ function invoke() { /// Do the job, setting result as needed if (!data_submitted('nomatch')) { ///Basic prevention - error('Wrong action call'); + print_error('Wrong action call'); } /// Get parameters diff --git a/admin/xmldb/actions/edit_index_save/edit_index_save.class.php b/admin/xmldb/actions/edit_index_save/edit_index_save.class.php index 2c2276d095862..5dee7f1f4b587 100644 --- a/admin/xmldb/actions/edit_index_save/edit_index_save.class.php +++ b/admin/xmldb/actions/edit_index_save/edit_index_save.class.php @@ -70,7 +70,7 @@ function invoke() { /// Do the job, setting result as needed if (!data_submitted('nomatch')) { ///Basic prevention - error('Wrong action call'); + print_error('Wrong action call'); } /// Get parameters diff --git a/admin/xmldb/actions/edit_key_save/edit_key_save.class.php b/admin/xmldb/actions/edit_key_save/edit_key_save.class.php index 3ca892a568d76..1fb2c47433a28 100644 --- a/admin/xmldb/actions/edit_key_save/edit_key_save.class.php +++ b/admin/xmldb/actions/edit_key_save/edit_key_save.class.php @@ -76,7 +76,7 @@ function invoke() { /// Do the job, setting result as needed if (!data_submitted('nomatch')) { ///Basic prevention - error('Wrong action call'); + print_error('Wrong action call'); } /// Get parameters diff --git a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php index 19f4c3c845177..a6429c5863bd0 100644 --- a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php +++ b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php @@ -66,7 +66,7 @@ function invoke() { /// Do the job, setting result as needed if (!data_submitted('nomatch')) { ///Basic prevention - error('Wrong action call'); + print_error('Wrong action call'); } /// Get parameters diff --git a/admin/xmldb/actions/edit_xml_file_save/edit_xml_file_save.class.php b/admin/xmldb/actions/edit_xml_file_save/edit_xml_file_save.class.php index 2147a7953ed2b..b989394ea4fa4 100644 --- a/admin/xmldb/actions/edit_xml_file_save/edit_xml_file_save.class.php +++ b/admin/xmldb/actions/edit_xml_file_save/edit_xml_file_save.class.php @@ -62,7 +62,7 @@ function invoke() { /// Do the job, setting result as needed if (!data_submitted('nomatch')) { ///Basic prevention - error('Wrong action call'); + print_error('Wrong action call'); } /// Get parameters diff --git a/admin/xmldb/index.php b/admin/xmldb/index.php index 55d098aadffd5..58964ccccf686 100644 --- a/admin/xmldb/index.php +++ b/admin/xmldb/index.php @@ -116,7 +116,7 @@ break; } } else { - error($xmldb_action->getError()); + print_error($xmldb_action->getError()); } } else { error ("Error: cannot instantiate class (actions/$action/$actionclass)"); diff --git a/auth/ldap/ntlmsso_attempt.php b/auth/ldap/ntlmsso_attempt.php index c9fc4695e2bfa..959f8dc6bf57c 100644 --- a/auth/ldap/ntlmsso_attempt.php +++ b/auth/ldap/ntlmsso_attempt.php @@ -7,7 +7,7 @@ /// Define variables used in page if (!$site = get_site()) { - error("No site found!"); + print_error("No site found!"); } $authsequence = get_enabled_auth_plugins(true); // auths, in sequence diff --git a/auth/ldap/ntlmsso_finish.php b/auth/ldap/ntlmsso_finish.php index c64e75570fd53..92b22ee8e4d9a 100644 --- a/auth/ldap/ntlmsso_finish.php +++ b/auth/ldap/ntlmsso_finish.php @@ -7,7 +7,7 @@ /// Define variables used in page if (!$site = get_site()) { - error("No site found!"); + print_error("No site found!"); } $authsequence = get_enabled_auth_plugins(true); // auths, in sequence diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index 87360ed576466..d9e89e167c422 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -62,7 +62,7 @@ function mnet_publishes() { * @return bool Authentication success or failure. */ function user_login($username, $password) { - return false; // error("Remote MNET users cannot login locally."); + return false; // print_error("Remote MNET users cannot login locally."); } /** @@ -175,12 +175,12 @@ function start_jump_session($mnethostid, $wantsurl) { or is_mnet_remote_user($USER) or $USER->username == 'guest' or empty($USER->id)) { - error(get_string('notpermittedtojump', 'mnet')); + print_error('notpermittedtojump', 'mnet'); } // check for SSO publish permission first if ($this->has_service($mnethostid, 'sso_sp') == false) { - error(get_string('hostnotconfiguredforsso', 'mnet')); + print_error('hostnotconfiguredforsso', 'mnet'); } // set RPC timeout to 30 seconds if not configured @@ -209,7 +209,7 @@ function start_jump_session($mnethostid, $wantsurl) { $mnet_session->expires = time() + (integer)ini_get('session.gc_maxlifetime'); $mnet_session->session_id = session_id(); if (! $mnet_session->id = insert_record('mnet_session', addslashes_object($mnet_session))) { - error(get_string('databaseerror', 'mnet')); + print_error('databaseerror', 'mnet'); } } else { $mnet_session->useragent = sha1($_SERVER['HTTP_USER_AGENT']); @@ -218,7 +218,7 @@ function start_jump_session($mnethostid, $wantsurl) { $mnet_session->expires = time() + (integer)ini_get('session.gc_maxlifetime'); $mnet_session->session_id = session_id(); if (false == update_record('mnet_session', addslashes_object($mnet_session))) { - error(get_string('databaseerror', 'mnet')); + print_error('databaseerror', 'mnet'); } } @@ -245,7 +245,7 @@ function confirm_mnet_session($token, $remotewwwroot) { // verify the remote host is configured locally before attempting RPC call if (! $remotehost = get_record('mnet_host', 'wwwroot', $remotewwwroot)) { - error(get_string('notpermittedtoland', 'mnet')); + print_error('notpermittedtoland', 'mnet'); } // get the originating (ID provider) host info @@ -268,12 +268,12 @@ function confirm_mnet_session($token, $remotewwwroot) { list($code, $message) = array_map('trim',explode(':', $errormessage, 2)); if($code == 702) { $site = get_site(); - print_error('mnet_session_prohibited','mnet', $remotewwwroot, format_string($site->fullname)); + print_error('mnet_session_prohibited', 'mnet', $remotewwwroot, format_string($site->fullname)); exit; } $message .= "ERROR $code:
$errormessage
"; } - error("RPC auth/mnet/user_authorise:
$message"); + print_error("RPC auth/mnet/user_authorise:
$message"); } unset($mnetrequest); @@ -291,15 +291,15 @@ function confirm_mnet_session($token, $remotewwwroot) { // TODO: refactor into a separate function if (empty($localuser) || ! $localuser->id) { if (empty($this->config->auto_add_remote_users)) { - error(get_string('nolocaluser', 'mnet')); + print_error('nolocaluser', 'mnet'); } $remoteuser->mnethostid = $remotehost->id; if (! insert_record('user', addslashes_object($remoteuser))) { - error(get_string('databaseerror', 'mnet')); + print_error('databaseerror', 'mnet'); } $firsttime = true; if (! $localuser = get_record('user', 'username', addslashes($remoteuser->username), 'mnethostid', $remotehost->id)) { - error(get_string('nolocaluser', 'mnet')); + print_error('nolocaluser', 'mnet'); } } @@ -372,7 +372,7 @@ function confirm_mnet_session($token, $remotewwwroot) { if (!$bool) { // TODO: Jonathan to clean up mess // Actually, this should never happen (modulo race conditions) - ML - error("updating user failed in mnet/auth/confirm_mnet_session "); + print_error("updating user failed in mnet/auth/confirm_mnet_session "); } // set up the session @@ -392,7 +392,7 @@ function confirm_mnet_session($token, $remotewwwroot) { $mnet_session->expires = time() + (integer)$session_gc_maxlifetime; $mnet_session->session_id = session_id(); if (! $mnet_session->id = insert_record('mnet_session', addslashes_object($mnet_session))) { - error(get_string('databaseerror', 'mnet')); + print_error('databaseerror', 'mnet'); } } else { $mnet_session->expires = time() + (integer)$session_gc_maxlifetime; diff --git a/auth/mnet/jump.php b/auth/mnet/jump.php index f05d7152fdd84..0058e5caafd9a 100644 --- a/auth/mnet/jump.php +++ b/auth/mnet/jump.php @@ -15,7 +15,7 @@ require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; if (!is_enabled_auth('mnet')) { - error('mnet is disabled'); + print_error('mnet is disabled'); } // grab the GET params - wantsurl could be anything - take it @@ -28,7 +28,7 @@ $url = $mnetauth->start_jump_session($hostid, $wantsurl); if (empty($url)) { - error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors + print_error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors } redirect($url); diff --git a/auth/mnet/land.php b/auth/mnet/land.php index 82ddd167c7eb9..3836d56e5ad26 100644 --- a/auth/mnet/land.php +++ b/auth/mnet/land.php @@ -20,7 +20,7 @@ } if (!is_enabled_auth('mnet')) { - error('mnet is disabled'); + print_error('mnet is disabled'); } // grab the GET params $token = required_param('token', PARAM_BASE64); diff --git a/auth/shibboleth/login.php b/auth/shibboleth/login.php index 32c14781204d8..e81b802224f33 100644 --- a/auth/shibboleth/login.php +++ b/auth/shibboleth/login.php @@ -21,7 +21,7 @@ /// Define variables used in page if (!$site = get_site()) { - error("No site found!"); + print_error("No site found!"); } if (empty($CFG->langmenu)) { diff --git a/backup/backup.php b/backup/backup.php index 3e45cc4cfd0dc..a4c352e6bc669 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -18,24 +18,24 @@ if (!empty($id)) { require_login($id); if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $id))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } else { require_login(); if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } if (!empty($to)) { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } //Check necessary functions exists. Thanks to gregb@crowncollege.edu @@ -96,7 +96,7 @@ //Get and check course if (! $course = get_record("course", "id", $id)) { - error("Course ID was incorrect (can't find it)"); + print_error("Course ID was incorrect (can't find it)"); } //Print header diff --git a/backup/backup_check.html b/backup/backup_check.html index 8b26f7ab13fcb..3ac2d23da4ee6 100644 --- a/backup/backup_check.html +++ b/backup/backup_check.html @@ -7,16 +7,16 @@ if (!empty($course->id)) { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) { if (empty($to)) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } else { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } } } else { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } @@ -30,14 +30,14 @@ //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } 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)){ - error('Couldn\'t delete previous backup ids.'); + print_error('Couldn\'t delete previous backup ids.'); } ?> diff --git a/backup/backup_execute.html b/backup/backup_execute.html index 16abc3a81ccb4..65fada8ab7746 100644 --- a/backup/backup_execute.html +++ b/backup/backup_execute.html @@ -7,23 +7,23 @@ if (!empty($course->id)) { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) { if (empty($to)) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } else { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } } } else { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } $preferences = new StdClass; diff --git a/backup/backup_form.html b/backup/backup_form.html index d16477508461f..934eff03ca272 100644 --- a/backup/backup_form.html +++ b/backup/backup_form.html @@ -7,22 +7,22 @@ if (!empty($course->id)) { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) { if (empty($to)) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } else { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } } } else { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } //Checks for the required files/functions to backup every mod diff --git a/backup/lib.php b/backup/lib.php index 1d9cfa12e8252..f54eef308d143 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -375,10 +375,10 @@ function upgrade_backup_db($continueto) { } } } else { - error("Upgrade of backup system failed! (Could not update version in config table)"); + print_error("Upgrade of backup system failed! (Could not update version in config table)"); } } else { - error("Backup tables could NOT be set up successfully!"); + print_error("Backup tables could NOT be set up successfully!"); } } @@ -448,10 +448,10 @@ function upgrade_backup_db($continueto) { } } } else { - error("Upgrade of backup system failed! (Could not update version in config table)"); + print_error("Upgrade of backup system failed! (Could not update version in config table)"); } } else { - error("Upgrade failed! See backup/version.php"); + print_error("Upgrade failed! See backup/version.php"); } } else if ($backup_version < $CFG->backup_version) { @@ -590,7 +590,7 @@ function backup_required_functions($justcheck=false) { if(!function_exists('utf8_encode')) { if (empty($justcheck)) { - error('You need to add XML support to your PHP installation'); + print_error('You need to add XML support to your PHP installation'); } else { return false; } diff --git a/backup/restore.php b/backup/restore.php index 0e4d82c2986cb..826bb96ce5727 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -53,23 +53,23 @@ require_login($id); if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { if (empty($to)) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$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))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } } } else { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } //Check necessary functions exists. Thanks to gregb@crowncollege.edu @@ -118,7 +118,7 @@ //Get and check course if (! $course = get_record("course", "id", $id)) { - error("Course ID was incorrect (can't find it)"); + print_error("Course ID was incorrect (can't find it)"); } //Print header @@ -161,7 +161,7 @@ } else if ($launch == "execute") { //Prevent multiple restore executions... if (empty($SESSION->cancontinue)) { - error("Multiple restore execution not allowed!"); + print_error("Multiple restore execution not allowed!"); } //Unset this for the future unset($SESSION->cancontinue); diff --git a/backup/restore_check.html b/backup/restore_check.html index 58ceac76f100f..710b708139375 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -45,7 +45,7 @@ // check for session objects if (empty($info) or empty($course_header)) { - error( 'important information missing from SESSION' ); + print_error( 'important information missing from SESSION' ); } @@ -189,17 +189,17 @@ //Check admin if (!empty($id)) { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } else { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } //Depending the selected restoreto: @@ -275,9 +275,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()) { - error("You need to be a creator or admin to restore into new course!"); + print_error("You need to be a creator or admin to restore into new course!"); } else if ($restore->course_id != 0 and !has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $restore->course_id))) { - error("You need to be an edit teacher or admin to restore into selected course!"); + print_error("You need to be an edit teacher or admin to restore into selected course!"); } $show_continue_button = true; //Check if we've selected any mod's user info and restore->users diff --git a/backup/restore_execute.html b/backup/restore_execute.html index 3406d7777cbf6..d87a8fc9d987c 100644 --- a/backup/restore_execute.html +++ b/backup/restore_execute.html @@ -24,30 +24,30 @@ if (!empty($id)) { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { if (empty($to)) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$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))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } } } else { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } $errorstr = ''; $status = restore_execute($restore,$info,$course_header,$errorstr); if (!$status) { - error ("An error has occurred and the restore could not be completed!"); + print_error ("An error has occurred and the restore could not be completed!"); } if (empty($restore->importing)) { diff --git a/backup/restore_form.html b/backup/restore_form.html index 9ee95c35d0568..31fb63d28ea6f 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -6,10 +6,10 @@ //Get objects from session if (!($info = $SESSION->info)) { - error( 'info object missing from session' ); + print_error( 'info object missing from session' ); } if (!($course_header = $SESSION->course_header)) { - error( 'course_header object missing from session' ); + print_error( 'course_header object missing from session' ); } $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))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } else { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } //Checks for the required files/functions to restore every mod @@ -757,4 +757,4 @@ } return true; } -?> \ No newline at end of file +?> diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html index 2f213a4ec92ea..a63ab16938031 100644 --- a/backup/restore_precheck.html +++ b/backup/restore_precheck.html @@ -16,23 +16,23 @@ if (!empty($id)) { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { if (empty($to)) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$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))) { - error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } } } else { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php"); + print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } $errorstr = ''; @@ -42,7 +42,7 @@ $status = restore_precheck($id,$file,$errorstr); if (!$status) { - error("An error occured"); + print_error("An error occured"); } ?> diff --git a/backup/restorelib.php b/backup/restorelib.php index 70207df345e86..424e46fffb0c2 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2426,7 +2426,7 @@ function restore_create_users($restore,$xml_file) { } else { // should not happen, as we check in restore_chech.php // but handle the error if it does - error("This backup file contains external Moodle Network Hosts that are not configured locally."); + print_error("This backup file contains external Moodle Network Hosts that are not configured locally."); } } unset($user->mnethosturl); @@ -6925,7 +6925,7 @@ function restore_read_xml ($xml_file,$todo,$preferences) { /** * @param string $errorstr passed by reference, if silent is true, - * errorstr will be populated and this function will return false rather than calling error() or notify() + * errorstr will be populated and this function will return false rather than calling print_error() or notify() * @param boolean $noredirect (optional) if this is passed, this function will not print continue, or * redirect to the next step in the restore process, instead will return $backup_unique_code */ @@ -7951,7 +7951,7 @@ function restore_open_html($restore,$course_header) { //Open file for writing //First, we check the course_id backup data folder exists and create it as necessary in CFG->dataroot if (!$dest_dir = make_upload_directory("$restore->course_id/backupdata")) { // Backup folder - error("Could not create backupdata folder. The site administrator needs to fix the file permissions"); + print_error("Could not create backupdata folder. The site administrator needs to fix the file permissions"); } $status = check_dir_exists($dest_dir,true); $restorelog_file = fopen("$dest_dir/restorelog.html","a"); diff --git a/backup/try.php b/backup/try.php index 92960c015e641..16d0c0e077d10 100644 --- a/backup/try.php +++ b/backup/try.php @@ -11,7 +11,7 @@ //Check site if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } //Check necessary functions exists. Thanks to gregb@crowncollege.edu diff --git a/blocks/rss_client/block_rss_client_action.php b/blocks/rss_client/block_rss_client_action.php index 049722c0061f2..ad4c0d26681ec 100644 --- a/blocks/rss_client/block_rss_client_action.php +++ b/blocks/rss_client/block_rss_client_action.php @@ -27,7 +27,7 @@ // Ensure that the logged in user is not using the guest account if (isguest()) { - error(get_string('noguestpost', 'forum'), $referrer); + print_error('noguestpost', 'forum', $referrer); } @@ -99,14 +99,15 @@ if ($act == 'updfeed') { if (!$managefeeds) { - error(get_string('noguestpost', 'forum'). - ' You are not allowed to make modifications to this RSS feed at this time.', - $referrer); + //print_error(get_string('noguestpost', 'forum'). + // ' You are not allowed to make modifications to this RSS feed at this time.', + // $referrer); + print_error('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.'); } if (empty($url)) { - error( 'URL not defined for rss feed' ); + print_error( 'URL not defined for rss feed' ); } // By capturing the output from fetch_rss this way @@ -141,7 +142,7 @@ $dataobject->url = addslashes($url); if (!update_record('block_rss_client', $dataobject)) { - error('There was an error trying to update rss feed with id:'. $rssid); + print_error('There was an error trying to update rss feed with id:'. $rssid); } $message .= '
'. get_string('feedupdated', 'block_rss_client'); @@ -153,11 +154,11 @@ $canaddsharedfeeds = has_capability('block/rss_client:createsharedfeeds', $context); if (!$canaddprivfeeds && !$canaddsharedfeeds) { - error('You do not have the permission to add RSS feeds'); + print_error('You do not have the permission to add RSS feeds'); } if (empty($url)) { - error('URL not defined for rss feed'); + print_error('URL not defined for rss feed'); } $dataobject->userid = $USER->id; $dataobject->description = ''; @@ -173,7 +174,7 @@ $rssid = insert_record('block_rss_client', $dataobject); if (!$rssid) { - error('There was an error trying to add a new rss feed:'. $url); + print_error('There was an error trying to add a new rss feed:'. $url); } // By capturing the output from fetch_rss this way @@ -199,7 +200,7 @@ $dataobject->title = addslashes($rss->channel['title']); } if (!update_record('block_rss_client', $dataobject)) { - error('There was an error trying to update rss feed with id:'. $rssid); + print_error('There was an error trying to update rss feed with id:'. $rssid); } $message .= '
'. get_string('feedadded', 'block_rss_client'); } @@ -222,9 +223,10 @@ } else if ($act == 'delfeed') { if (!$managefeeds) { - error(get_string('noguestpost', 'forum'). - ' You are not allowed to make modifications to this RSS feed at this time.', - $referrer); + //print_error(get_string('noguestpost', 'forum'). + // ' You are not allowed to make modifications to this RSS feed at this time.', + // $referrer); + print_error('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.'); } $file = $CFG->dataroot .'/cache/rsscache/'. $rssid .'.xml'; diff --git a/blog/blogpage.php b/blog/blogpage.php index 7e6366d99dd15..2d4fca3b62c9b 100644 --- a/blog/blogpage.php +++ b/blog/blogpage.php @@ -57,7 +57,7 @@ function init_full() { $courserecord = NULL; } else { if (! ($courserecord = get_record('course', 'id', $this->courseid)) ) { - error( 'You are tring to view an invalid course. Id: ('. $this->courseid .')' ); + print_error( 'You are tring to view an invalid course. Id: ('. $this->courseid .')' ); } } $this->full_init_done = true; diff --git a/blog/edit.php b/blog/edit.php index ee2b426c09d50..0e858febfaba6 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -12,32 +12,32 @@ require_login($courseid); if (empty($CFG->bloglevel)) { - error('Blogging is disabled!'); + print_error('Blogging is disabled!'); } if (isguest()) { - error(get_string('noguestpost', 'blog')); + print_error('noguestpost', 'blog'); } $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); if (!has_capability('moodle/blog:create', $sitecontext) and !has_capability('moodle/blog:manageentries', $sitecontext)) { - error('You can not post or edit blogs.'); + print_error('You can not post or edit blogs.'); } // Make sure that the person trying to edit have access right if ($id) { if (!$existing = get_record('post', 'id', $id)) { - error('Wrong blog post id'); + print_error('Wrong blog post id'); } if (!blog_user_can_edit_post($existing)) { - error(get_string('notallowedtoedit', 'blog')); + print_error('notallowedtoedit', 'blog'); } $userid = $existing->userid; $returnurl = $CFG->wwwroot.'/blog/index.php?userid='.$existing->userid; } else { if (!has_capability('moodle/blog:create', $sitecontext)) { - error(get_string('nopost', 'blog')); // manageentries is not enough for adding + print_error('nopost', 'blog'); // manageentries is not enough for adding } $existing = false; $userid = $USER->id; @@ -52,7 +52,7 @@ if ($action=='delete'){ if (!$existing) { - error('Incorrect blog post id'); + print_error('Incorrect blog post id'); } if (data_submitted() and $confirm and confirm_sesskey()) { do_delete($existing); @@ -83,12 +83,12 @@ case 'edit': if (!$existing) { - error('Incorrect blog post id'); + print_error('Incorrect blog post id'); } do_edit($fromform, $blogeditform); break; default : - error('Unknown action!'); + print_error('Unknown action!'); } redirect($returnurl); } @@ -105,7 +105,7 @@ case 'edit': if (!$existing) { - error('Incorrect blog post id'); + print_error('Incorrect blog post id'); } $post->id = $existing->id; $post->subject = $existing->subject; @@ -124,12 +124,12 @@ } break; default : - error('Unknown action!'); + print_error('Unknown action!'); } // done here in order to allow deleting of posts with wrong user id above if (!$user = get_record('user', 'id', $userid)) { - error('Incorrect user id'); + print_error('Incorrect user id'); } $navlinks = array(); $navlinks[] = array('name' => fullname($user), 'link' => "$CFG->wwwroot/user/view.php?id=$userid", 'type' => 'misc'); @@ -164,7 +164,7 @@ function do_delete($post) { add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id); if (!$status) { - error('Error occured while deleting post', $returnurl); + print_error('Error occured while deleting post', '', $returnurl); } } @@ -191,7 +191,7 @@ function do_add($post, $blogeditform) { add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject); } else { - error('There was an error adding this post in the database', $returnurl); + print_error('There was an error adding this post in the database', '', $returnurl); } } @@ -226,7 +226,7 @@ function do_edit($post, $blogeditform) { add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$USER->id.'&postid='.$post->id, $post->subject); } else { - error('There was an error updating this post in the database', $returnurl); + print_error('There was an error updating this post in the database', '', $returnurl); } } diff --git a/blog/header.php b/blog/header.php index deb58421fc68f..7835ede37ca34 100755 --- a/blog/header.php +++ b/blog/header.php @@ -17,7 +17,7 @@ if (!$course = get_record('course', 'id', $courseid)) { - error('The course number was incorrect ('. $courseid .')'); + print_error('The course number was incorrect ('. $courseid .')'); } // Bounds for block widths @@ -99,7 +99,7 @@ // needed also for user tabs later if (!$course = get_record('course', 'id', $courseid)) { - error('Wrong course id'); + print_error('Wrong course id'); } $navlinks = array(); @@ -165,7 +165,7 @@ case 'user': $participants = get_string('participants'); if (!$user = get_record('user', 'id', $filterselect)) { - error('Wrong user id'); + print_error('Wrong user id'); } if ($course->id != SITEID) { diff --git a/blog/index.php b/blog/index.php index f0b21b2a3a040..71ea5b705065d 100755 --- a/blog/index.php +++ b/blog/index.php @@ -24,7 +24,7 @@ if (empty($CFG->bloglevel)) { - error('Blogging is disabled!'); + print_error('Blogging is disabled!'); } $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); @@ -55,48 +55,48 @@ case 'site': if ($CFG->bloglevel < BLOG_SITE_LEVEL) { - error('Site blogs is not enabled'); + print_error('Site blogs is not enabled'); } if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) { require_login(); } if (!has_capability('moodle/blog:view', $sitecontext)) { - error('You do not have the required permissions to view all site blogs'); + print_error('You do not have the required permissions to view all site blogs'); } break; case 'course': if ($CFG->bloglevel < BLOG_COURSE_LEVEL) { - error('Course blogs is not enabled'); + print_error('Course blogs is not enabled'); } if (!$course = get_record('course', 'id', $filterselect)) { - error('Incorrect course id specified'); + print_error('Incorrect course id specified'); } $courseid = $course->id; $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); require_login($course); if (!has_capability('moodle/blog:view', $coursecontext)) { - error('You do not have the required permissions to view blogs in this course'); + print_error('You do not have the required permissions to view blogs in this course'); } break; case 'group': if ($CFG->bloglevel < BLOG_GROUP_LEVEL) { - error('Group blogs is not enabled'); + print_error('Group blogs is not enabled'); } // fix for MDL-9268 if (! $group = groups_get_group($filterselect)) { //TODO:check. - error('Incorrect group id specified'); + print_error('Incorrect group id specified'); } if (!$course = get_record('course', 'id', $group->courseid)) { - error('Incorrect course id specified'); + print_error('Incorrect course id specified'); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); $courseid = $course->id; require_login($course); if (!has_capability('moodle/blog:view', $coursecontext)) { - error('You do not have the required permissions to view blogs in this course/group'); + print_error('You do not have the required permissions to view blogs in this course/group'); } if (groups_get_course_groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $coursecontext)) { @@ -109,24 +109,24 @@ case 'user': if ($CFG->bloglevel < BLOG_USER_LEVEL) { - error('Blogs is not enabled'); + print_error('Blogs is not enabled'); } if (!$user = get_record('user', 'id', $filterselect)) { - error('Incorrect user id'); + print_error('Incorrect user id'); } if ($USER->id == $filterselect) { if (!has_capability('moodle/blog:create', $sitecontext) and !has_capability('moodle/blog:view', $sitecontext)) { - error('You do not have your own blog, sorry.'); + print_error('You do not have your own blog, sorry.'); } } else { $personalcontext = get_context_instance(CONTEXT_USER, $filterselect); if (!has_capability('moodle/blog:view', $sitecontext) and !has_capability('moodle/user:readuserblogs', $personalcontext)) { - error('You do not have the required permissions to read user blogs'); + print_error('You do not have the required permissions to read user blogs'); } if (!blog_user_can_view_user_post($filterselect)) { - error('You can not view blog of this user, sorry.'); + print_error('You can not view blog of this user, sorry.'); } } $userid = $filterselect; @@ -138,7 +138,7 @@ break; default: - error('Incorrect blog filter type specified'); + print_error('Incorrect blog filter type specified'); break; } diff --git a/blog/preferences.php b/blog/preferences.php index 3f5fdce78d265..81daa68b4147f 100755 --- a/blog/preferences.php +++ b/blog/preferences.php @@ -15,7 +15,7 @@ } if (empty($CFG->bloglevel)) { - error('Blogging is disabled!'); + print_error('Blogging is disabled!'); } require_capability('moodle/blog:view', $context); @@ -26,7 +26,7 @@ $pagesize = required_param('pagesize', PARAM_INT); if ($pagesize < 1) { - error('invalid page size'); + print_error('invalid page size'); } set_user_preference('blogpagesize', $pagesize); diff --git a/calendar/event.php b/calendar/event.php index ac650ac8106c1..3fe21b87e888c 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -107,10 +107,10 @@ $title = get_string('deleteevent', 'calendar'); $event = get_record('event', 'id', $eventid); if($event === false) { - error('Invalid event'); + print_error('Invalid event'); } if(!calendar_edit_event_allowed($event)) { - error('You are not authorized to do this'); + print_error('You are not authorized to do this'); } break; @@ -120,10 +120,10 @@ $repeats = optional_param('repeats', 0, PARAM_INT); if($event === false) { - error('Invalid event'); + print_error('Invalid event'); } if(!calendar_edit_event_allowed($event)) { - error('You are not authorized to do this'); + print_error('You are not authorized to do this'); } if($form = data_submitted()) { @@ -211,7 +211,7 @@ $form->timeduration = 0; } if(!calendar_add_event_allowed($form)) { - error('You are not authorized to do this'); + print_error('You are not authorized to do this'); } validate_form($form, $err); if (count($err) == 0) { @@ -488,7 +488,7 @@ case 'select': break; default: - error('Unsupported event type'); + print_error('Unsupported event type'); } $form->format = $defaultformat; @@ -504,7 +504,7 @@ $courseid = SITEID; } if (!$course = get_record('course', 'id', $courseid)) { - error('Incorrect course ID'); + print_error('Incorrect course ID'); } $groupid = groups_get_course_group($course); @@ -593,7 +593,7 @@ function validate_form(&$form, &$err) { // Timestamps must be >= course startdate $course = get_record('course', 'id', $form->courseid); if($course === false) { - error('Event belongs to invalid course'); + print_error('Event belongs to invalid course'); } else if($form->timestart < $course->startdate) { $err['timestart'] = get_string('errorbeforecoursestart', 'calendar'); diff --git a/calendar/lib.php b/calendar/lib.php index 73b4a90c9db81..7038eb10ac7bd 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -431,7 +431,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve // TODO: rewrite this hack somehow if (!calendar_edit_event_allowed($event)){ // cannot manage entries, eg. student if(!$assignment = get_record('assignment','id',$event->instance)){ - // error("assignment ID was incorrect"); + // print_error("assignment ID was incorrect"); continue; } // assign assignment to assignment object to use hidden_is_hidden method diff --git a/course/category.php b/course/category.php index 7cac89ee24adc..8ea03e539b029 100644 --- a/course/category.php +++ b/course/category.php @@ -24,19 +24,19 @@ } if (!$site = get_site()) { - error("Site isn't defined!"); + print_error("Site isn't defined!"); } if (empty($id)) { - error("Category not known!"); + print_error("Category not known!"); } if (!$context = get_context_instance(CONTEXT_COURSECAT, $id)) { - error("Category not known!"); + print_error("Category not known!"); } if (!$category = get_record("course_categories", "id", $id)) { - error("Category not known!"); + print_error("Category not known!"); } if (has_capability('moodle/course:create', $context)) { @@ -49,7 +49,7 @@ } else { if (!$category->visible) { - error(get_string('notavailable', 'error')); + print_error('notavailable', 'error'); } $navbaritem = print_course_search("", true, "navbar"); $adminediting = false; @@ -170,7 +170,7 @@ require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto)); if (! $destcategory = get_record("course_categories", "id", $data->moveto)) { - error("Error finding the category"); + print_error("Error finding the category"); } diff --git a/course/delete.php b/course/delete.php index 02ed485bcae50..697edf06885ec 100644 --- a/course/delete.php +++ b/course/delete.php @@ -9,11 +9,11 @@ require_login(); if (!can_delete_course($id)) { - error('You do not have the permission to delete this course.'); + print_error('You do not have the permission to delete this course.'); } if (!$site = get_site()) { - error("Site not found!"); + print_error("Site not found!"); } $strdeletecourse = get_string("deletecourse"); @@ -21,7 +21,7 @@ $strcategories = get_string("categories"); if (! $course = get_record("course", "id", $id)) { - error("Course ID was incorrect (can't find it)"); + print_error("Course ID was incorrect (can't find it)"); } $category = get_record("course_categories", "id", $course->category); @@ -49,11 +49,11 @@ } if ($delete != md5($course->timemodified)) { - error("The check variable was wrong - try again"); + print_error("The check variable was wrong - try again"); } if (!confirm_sesskey()) { - error(get_string('confirmsesskeybad', 'error')); + print_error('confirmsesskeybad', 'error'); } // OK checks done, delete the course now. diff --git a/course/edit.php b/course/edit.php index 4e1135707c5e1..46ded6b77ce7f 100644 --- a/course/edit.php +++ b/course/edit.php @@ -16,11 +16,11 @@ if($id == SITEID){ // don't allow editing of 'site course' using this from - error('You cannot edit the site course using this form'); + print_error('You cannot edit the site course using this form'); } if (!$course = get_record('course', 'id', $id)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } require_login($course->id); $category = get_record('course_categories', 'id', $course->category); @@ -30,12 +30,12 @@ $course = null; require_login(); if (!$category = get_record('course_categories', 'id', $categoryid)) { - error('Category ID was incorrect'); + print_error('Category ID was incorrect'); } require_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id)); } else { require_login(); - error('Either course id or category must be specified'); + print_error('Either course id or category must be specified'); } /// prepare course diff --git a/course/editcategory.php b/course/editcategory.php index 0b60a3d69fb74..cb4f284b0bf63 100644 --- a/course/editcategory.php +++ b/course/editcategory.php @@ -22,7 +22,7 @@ $resort = optional_param('resort', 0, PARAM_BOOL); if (!$site = get_site()) { - error("Site isn't defined!"); + print_error("Site isn't defined!"); } if ($categoryadd) { // Show Add category form: if $id is given, it is used as the parent category @@ -33,7 +33,7 @@ $strtitle = get_string("editcategorysettings"); $context = get_context_instance(CONTEXT_COURSECAT, $id); if (!$category = get_record("course_categories", "id", $id)) { - error("Category not known!"); + print_error("Category not known!"); } } @@ -83,7 +83,7 @@ } if (!update_record('course_categories', $newcategory)) { - error( "Could not update the category '$newcategory->name' "); + print_error( "Could not update the category '$newcategory->name' "); } else { if ($newcategory->parent == 0) { $redirect_link = 'index.php?categoryedit=on'; @@ -117,7 +117,7 @@ } else { if (!$category->visible) { - error(get_string('notavailable', 'error')); + print_error('notavailable', 'error'); } $navbaritem = print_course_search("", true, "navbar"); $adminediting = false; @@ -210,7 +210,7 @@ require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto)); if (!$destcategory = get_record("course_categories", "id", $data->moveto)) { - error("Error finding the destination category"); + print_error("Error finding the destination category"); } // TODO function to move the category } diff --git a/course/editsection.php b/course/editsection.php index 6e9b848a66825..7bb21abfb56a6 100644 --- a/course/editsection.php +++ b/course/editsection.php @@ -7,11 +7,11 @@ $id = required_param('id',PARAM_INT); // Week ID if (! $section = get_record("course_sections", "id", $id)) { - error("Course section is incorrect"); + print_error("Course section is incorrect"); } if (! $course = get_record("course", "id", $section->course)) { - error("Could not find the course!"); + print_error("Could not find the course!"); } require_login($course->id); @@ -25,7 +25,7 @@ $timenow = time(); if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) { - error("Could not update the summary!"); + print_error("Could not update the summary!"); } add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section"); diff --git a/course/enrol.php b/course/enrol.php index 0ebb95e60aa26..8826778dafd44 100644 --- a/course/enrol.php +++ b/course/enrol.php @@ -20,11 +20,11 @@ } if (! $course = get_record('course', 'id', $id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } if (! $context = get_context_instance(CONTEXT_COURSE, $course->id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } /// do not use when in course login as diff --git a/course/format/lams/format.php b/course/format/lams/format.php index a4ef5b4c7d6f1..98d346e116d97 100644 --- a/course/format/lams/format.php +++ b/course/format/lams/format.php @@ -39,7 +39,7 @@ if (($marker >=0) and has_capability('moodle/course:setcurrentsection', $context) and confirm_sesskey()) { $course->marker = $marker; if (! set_field("course", "marker", $marker, "id", $course->id)) { - error("Could not mark that topic for this course"); + print_error("Could not mark that topic for this course"); } } diff --git a/course/format/topics/format.php b/course/format/topics/format.php index d2df141caf247..3dc459d44b7fd 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -44,7 +44,7 @@ if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { $course->marker = $marker; if (! set_field("course", "marker", $marker, "id", $course->id)) { - error("Could not mark that topic for this course"); + print_error("Could not mark that topic for this course"); } } diff --git a/course/import.php b/course/import.php index 3c30c3832388f..f2dfaab811efc 100644 --- a/course/import.php +++ b/course/import.php @@ -6,7 +6,7 @@ $id = required_param('id', PARAM_INT); // course id to import TO if (!$course = get_record('course', 'id', $id)) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } require_login($course->id); diff --git a/course/import/activities/index.php b/course/import/activities/index.php index 8b593cacd2d87..f15f467f4d751 100644 --- a/course/import/activities/index.php +++ b/course/import/activities/index.php @@ -13,11 +13,11 @@ $strimportactivities = get_string('importactivities'); if (! ($course = get_record("course", "id", $id)) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } if (!$site = get_site()){ - error("Couldn't get site course"); + print_error("Couldn't get site course"); } require_login($course->id); @@ -28,7 +28,7 @@ $syscontext = get_context_instance(CONTEXT_SYSTEM, SITEID); if (!has_capability('moodle/course:manageactivities', $tocontext)) { - error("You need do not have the required permissions to import activities to this course"); + print_error("You need do not have the required permissions to import activities to this course"); } // if we're not a course creator , we can only import from our own courses. @@ -38,7 +38,7 @@ if ($from = get_record('course', 'id', $fromcourse)) { if (!has_capability('moodle/course:manageactivities', $fromcontext)) { - error("You need to have the required permissions in the course you are importing data from, as well"); + print_error("You need to have the required permissions in the course you are importing data from, as well"); } if (!empty($filename) && file_exists($CFG->dataroot.'/'.$filename) && !empty($SESSION->import_preferences)) { $restore = backup_to_restore_array($SESSION->import_preferences); diff --git a/course/import/groups/index.php b/course/import/groups/index.php index 231184f527926..e1e085fd950ed 100755 --- a/course/import/groups/index.php +++ b/course/import/groups/index.php @@ -9,7 +9,7 @@ $id = required_param('id', PARAM_INT); // Course id if (! $course = get_record('course', 'id', $id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } require_login($course->id); @@ -17,11 +17,11 @@ if (!has_capability('moodle/course:managegroups', $context)) { - error("You do not have the required permissions to manage groups."); + print_error("You do not have the required permissions to manage groups."); } //if (!confirm_sesskey()) { - // error(get_string('confirmsesskeybad', 'error')); + // print_error('confirmsesskeybad', 'error'); //} $strimportgroups = get_string("importgroups"); @@ -87,7 +87,7 @@ if ( !(isset($required[$h]) or isset($optionalDefaults[$h]) or isset($optional[$h])) ) { - error(get_string('invalidfieldname', 'error', $h), 'index.php?id='.$id.'&sesskey='.$USER->sesskey); + print_error('invalidfieldname', 'error', 'index.php?id='.$id.'&sesskey='.$USER->sesskey, $h); } if ( isset($required[$h]) ) { $required[$h] = 2; @@ -96,7 +96,7 @@ // check for required fields foreach ($required as $key => $value) { if ($value < 2) { - error(get_string('fieldrequired', 'error', $key), 'uploaduser.php?id='.$id.'&sesskey='.$USER->sesskey); + print_error('fieldrequired', 'error', 'uploaduser.php?id='.$id.'&sesskey='.$USER->sesskey, $key); } } $linenum = 2; // since header is line 1 @@ -121,10 +121,11 @@ foreach ($record as $name => $value) { // check for required values if (isset($required[$name]) and !$value) { - error(get_string('missingfield', 'error', $name). " ". - get_string('erroronline', 'error', $linenum) .". ". - get_string('processingstops', 'error'), - 'uploaduser.php?sesskey='.$USER->sesskey); + //error(get_string('missingfield', 'error', $name). " ". + // get_string('erroronline', 'error', $linenum) .". ". + // get_string('processingstops', 'error'), + // 'uploaduser.php?sesskey='.$USER->sesskey); + print_error('missingfield', 'error', 'uploaduser.php?sesskey='.$USER->sesskey, $name); } else if ($name == "groupname") { $newgroup->name = addslashes($value); diff --git a/course/importstudents.php b/course/importstudents.php index 845cd51a1bb24..f9d940599f42c 100644 --- a/course/importstudents.php +++ b/course/importstudents.php @@ -20,7 +20,7 @@ } if (! $course = get_record("course", "id", $id)) { - error("Course ID was incorrect (can't find it)"); + print_error("Course ID was incorrect (can't find it)"); } require_login($course->id); @@ -65,7 +65,7 @@ $addcourse = clean_param($addcourse, PARAM_INT); set_time_limit(180); if (!add_to_metacourse($course->id,$addcourse)) { - error("Could not add the selected course to this meta course!"); + print_error("Could not add the selected course to this meta course!"); } } } else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) { @@ -73,7 +73,7 @@ set_time_limit(180); $removecourse = clean_param($removecourse, PARAM_INT); if (! remove_from_metacourse($course->id,$removecourse)) { - error("Could not remove the selected course from this meta course!"); + print_error("Could not remove the selected course from this meta course!"); } } } else if ($showall and confirm_sesskey()) { diff --git a/course/index.php b/course/index.php index eb1f55494749f..fd8a4300d9ad5 100644 --- a/course/index.php +++ b/course/index.php @@ -19,7 +19,7 @@ $context = $sysctx; if (!$site = get_site()) { - error('Site isn\'t defined!'); + print_error('Site isn\'t defined!'); } if ($CFG->forcelogin) { @@ -120,7 +120,7 @@ if ($childcats = get_records('course_categories', 'parent', $deletecat->id)) { foreach ($childcats as $childcat) { if (! set_field('course_categories', 'parent', $deletecat->parent, 'id', $childcat->id)) { - error('Could not update a child category!', 'index.php'); + print_error('Could not update a child category!', 'index.php'); } } } @@ -131,7 +131,7 @@ if ($childcourses = get_records('course', 'category', $deletecat->id)) { foreach ($childcourses as $childcourse) { if (! set_field('course', 'category', $deletecat->parent, 'id', $childcourse->id)) { - error('Could not update a child course!', 'index.php'); + print_error('Could not update a child course!', 'index.php'); } } } @@ -163,7 +163,7 @@ unset($tempcat); $tempcat->name = get_string('miscellaneous'); if (!$tempcat->id = insert_record('course_categories', $tempcat)) { - error('Serious error: Could not create a default category!'); + print_error('Serious error: Could not create a default category!'); } $tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id); mark_context_dirty('/'.SYSCONTEXTID); diff --git a/course/info.php b/course/info.php index e5ecf3304f033..e3d1e7a92b280 100644 --- a/course/info.php +++ b/course/info.php @@ -9,16 +9,16 @@ $name = optional_param('name', false, PARAM_RAW); // Course short name if (!$id and !$name) { - error("Must specify course id or short name"); + print_error("Must specify course id or short name"); } if ($name) { if (! $course = get_record("course", "shortname", $name) ) { - error("That's an invalid short course name"); + print_error("That's an invalid short course name"); } } else { if (! $course = get_record("course", "id", $id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } } @@ -30,7 +30,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id); if ((!course_parent_visible($course) || (! $course->visible)) && !has_capability('moodle/course:viewhiddencourses', $context)) { - error(get_string('coursehidden'), $CFG->wwwroot .'/'); + print_error('coursehidden', '', $CFG->wwwroot .'/'); } print_header(get_string("summaryof", "", $course->fullname)); diff --git a/course/lib.php b/course/lib.php index 231fc8dca60e6..11f1259344db5 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1169,7 +1169,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname } asort($modnames, SORT_LOCALE_STRING); } else { - error("No modules are installed!"); + print_error("No modules are installed!"); } if ($rawmods = get_course_mods($courseid)) { @@ -1930,7 +1930,7 @@ function print_my_moodle() { global $USER, $CFG; if (empty($USER->id)) { - error("It shouldn't be possible to see My Moodle without being logged in."); + print_error("It shouldn't be possible to see My Moodle without being logged in."); } $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', array('summary')); @@ -2511,7 +2511,7 @@ function course_in_meta ($course) { */ function print_standard_coursemodule_settings($form, $features=null) { if (! $course = get_record('course', 'id', $form->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } print_groupmode_setting($form, $course); if (!empty($features->groupings)) { @@ -2527,12 +2527,12 @@ function print_groupmode_setting($form, $course=NULL) { if (empty($course)) { if (! $course = get_record('course', 'id', $form->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } } if ($form->coursemodule) { if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } $groupmode = groups_get_activity_groupmode($cm); } else { @@ -2560,12 +2560,12 @@ function print_grouping_settings($form, $course=NULL) { if (empty($course)) { if (! $course = get_record('course', 'id', $form->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } } if ($form->coursemodule) { if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } } else { $cm = null; @@ -2599,7 +2599,7 @@ function print_grouping_settings($form, $course=NULL) { function print_visible_setting($form, $course=NULL) { if (empty($course)) { if (! $course = get_record('course', 'id', $form->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } } if ($form->coursemodule) { diff --git a/course/loginas.php b/course/loginas.php index 3bddfe5aaf6c9..91f8efc60fd3a 100644 --- a/course/loginas.php +++ b/course/loginas.php @@ -46,7 +46,7 @@ } if (! $course = get_record('course', 'id', $id)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } /// User must be logged in @@ -65,7 +65,7 @@ require_login($course); require_capability('moodle/user:loginas', $coursecontext); if (!has_capability('moodle/course:view', $coursecontext, $userid, false)) { - error('This user is not in this course!'); + print_error('This user is not in this course!'); } if (has_capability('moodle/site:doanything', $coursecontext, $userid, false)) { print_error('nologinas'); diff --git a/course/mod.php b/course/mod.php index c230b3ea9d3e4..4e8b2ee312537 100644 --- a/course/mod.php +++ b/course/mod.php @@ -58,7 +58,7 @@ {$CFG->prefix}modules md WHERE cm.id = '$update' AND md.id = cm.module")){ - error('Invalid course module id!'); + print_error('Invalid course module id!'); } $returntomod = optional_param('return', 0, PARAM_BOOL); if (file_exists("../mod/$modname/mod_form.php")) { @@ -72,17 +72,17 @@ if (empty($mod->coursemodule)) { //add if (! $course = get_record("course", "id", $mod->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } $mod->instance = ''; $mod->coursemodule = ''; } else { //delete and update if (! $cm = get_record("course_modules", "id", $mod->coursemodule)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } if (! $course = get_record("course", "id", $cm->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } $mod->instance = $cm->instance; $mod->coursemodule = $cm->id; @@ -99,7 +99,7 @@ if (file_exists($modlib)) { include_once($modlib); } else { - error("This module is missing important code! ($modlib)"); + print_error("This module is missing important code! ($modlib)"); } $addinstancefunction = $mod->modulename."_add_instance"; $updateinstancefunction = $mod->modulename."_update_instance"; @@ -122,10 +122,10 @@ include_once($moderr); die; } - error("Could not update the $mod->modulename", "view.php?id=$course->id"); + print_error("Could not update the $mod->modulename", '', "view.php?id=$course->id"); } if (is_string($return)) { - error($return, "view.php?id=$course->id"); + print_error($return, '', "view.php?id=$course->id"); } if (isset($mod->visible)) { @@ -161,7 +161,7 @@ case "add": if (!course_allowed_module($course,$mod->modulename)) { - error("This module ($mod->modulename) has been disabled for this particular course"); + print_error("This module ($mod->modulename) has been disabled for this particular course"); } if (!isset($mod->name) || trim($mod->name) == '') { @@ -175,10 +175,10 @@ include_once($moderr); die; } - error("Could not add a new instance of $mod->modulename", "view.php?id=$course->id"); + print_error("Could not add a new instance of $mod->modulename", '', "view.php?id=$course->id"); } if (is_string($return)) { - error($return, "view.php?id=$course->id"); + print_error($return, '', "view.php?id=$course->id"); } if (!isset($mod->groupmode)) { // to deal with pre-1.5 modules @@ -198,14 +198,14 @@ // to each other, so we have to update one of them twice. if (! $mod->coursemodule = add_course_module($mod) ) { - error("Could not add a new course module"); + print_error("Could not add a new course module"); } if (! $sectionid = add_mod_to_section($mod) ) { - error("Could not add the new course module to that section"); + print_error("Could not add the new course module to that section"); } if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) { - error("Could not update the course module with the correct section"); + print_error("Could not update the course module with the correct section"); } if (!isset($mod->visible)) { // We get the section's visible field status @@ -250,7 +250,7 @@ "$mod->modulename $mod->instance", $mod->coursemodule); break; default: - error("No mode defined"); + print_error("No mode defined"); } @@ -269,21 +269,21 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) { if (! $cm = get_record("course_modules", "id", $USER->activitycopy)) { - error("The copied course module doesn't exist!"); + print_error("The copied course module doesn't exist!"); } if (!empty($movetosection)) { if (! $section = get_record("course_sections", "id", $movetosection)) { - error("This section doesn't exist"); + print_error("This section doesn't exist"); } $beforecm = NULL; } else { // normal moveto if (! $beforecm = get_record("course_modules", "id", $moveto)) { - error("The destination course module doesn't exist"); + print_error("The destination course module doesn't exist"); } if (! $section = get_record("course_sections", "id", $beforecm->section)) { - error("This section doesn't exist"); + print_error("This section doesn't exist"); } } @@ -292,7 +292,7 @@ require_capability('moodle/course:manageactivities', $context); if (!ismoving($section->course)) { - error("You need to copy something first!"); + print_error("You need to copy something first!"); } moveto_module($cm, $section, $beforecm); @@ -314,7 +314,7 @@ $id = required_param('id',PARAM_INT); if (! $cm = get_record("course_modules", "id", $id)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } require_login($cm->course); // needed to setup proper $COURSE @@ -328,7 +328,7 @@ } if (!set_field("course_modules", "indent", $cm->indent, "id", $cm->id)) { - error("Could not update the indent level on that course module"); + print_error("Could not update the indent level on that course module"); } if (SITEID == $cm->course) { @@ -341,7 +341,7 @@ } else if (!empty($hide) and confirm_sesskey()) { if (! $cm = get_record("course_modules", "id", $hide)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } require_login($cm->course); // needed to setup proper $COURSE @@ -362,7 +362,7 @@ } else if (!empty($show) and confirm_sesskey()) { if (! $cm = get_record("course_modules", "id", $show)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } require_login($cm->course); // needed to setup proper $COURSE @@ -370,11 +370,11 @@ require_capability('moodle/course:activityvisibility', $context); if (! $section = get_record("course_sections", "id", $cm->section)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if (! $module = get_record("modules", "id", $cm->module)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if ($module->visible and ($section->visible or (SITEID == $cm->course))) { @@ -394,7 +394,7 @@ $id = required_param( 'id', PARAM_INT ); if (! $cm = get_record("course_modules", "id", $id)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } require_login($cm->course); // needed to setup proper $COURSE @@ -415,7 +415,7 @@ } else if (!empty($copy) and confirm_sesskey()) { // value = course module if (! $cm = get_record("course_modules", "id", $copy)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } require_login($cm->course); // needed to setup proper $COURSE @@ -423,15 +423,15 @@ require_capability('moodle/course:manageactivities', $context); if (! $section = get_record("course_sections", "id", $cm->section)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if (! $module = get_record("modules", "id", $cm->module)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if (! $instance = get_record($module->name, "id", $cm->instance)) { - error("Could not find the instance of this module"); + print_error("Could not find the instance of this module"); } $USER->activitycopy = $copy; @@ -453,11 +453,11 @@ } else if (!empty($delete) and confirm_sesskey()) { // value = course module if (! $cm = get_record("course_modules", "id", $delete)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } if (! $course = get_record("course", "id", $cm->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } require_login($cm->course); // needed to setup proper $COURSE @@ -465,7 +465,7 @@ require_capability('moodle/course:manageactivities', $context); if (! $module = get_record("modules", "id", $cm->module)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if (! $instance = get_record($module->name, "id", $cm->instance)) { @@ -476,7 +476,7 @@ if (! delete_course_module($cm->id)) { notify("Could not delete the $module->name (coursemodule)"); } - error("The required instance of this module didn't exist. Module deleted.", + print_error("The required instance of this module didn't exist. Module deleted.", "$CFG->wwwroot/course/view.php?id=$course->id"); } @@ -510,11 +510,11 @@ } else if (!empty($update) and confirm_sesskey()) { // value = course module if (! $cm = get_record("course_modules", "id", $update)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } if (! $course = get_record("course", "id", $cm->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } require_login($course->id); // needed to setup proper $COURSE @@ -522,15 +522,15 @@ require_capability('moodle/course:manageactivities', $context); if (! $module = get_record("modules", "id", $cm->module)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if (! $form = get_record($module->name, "id", $cm->instance)) { - error("The required instance of this module doesn't exist"); + print_error("The required instance of this module doesn't exist"); } if (! $cw = get_record("course_sections", "id", $cm->section)) { - error("This course section doesn't exist"); + print_error("This course section doesn't exist"); } if (isset($return)) { @@ -568,11 +568,11 @@ if (! $cm = get_record("course_modules", "id", $duplicate)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } if (! $course = get_record("course", "id", $cm->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } require_login($course->id); // needed to setup proper $COURSE @@ -580,15 +580,15 @@ require_capability('moodle/course:manageactivities', $context); if (! $module = get_record("modules", "id", $cm->module)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if (! $form = get_record($module->name, "id", $cm->instance)) { - error("The required instance of this module doesn't exist"); + print_error("The required instance of this module doesn't exist"); } if (! $cw = get_record("course_sections", "id", $cm->section)) { - error("This course section doesn't exist"); + print_error("This course section doesn't exist"); } if (isset($return)) { @@ -627,18 +627,18 @@ $section = required_param('section',PARAM_INT); if (! $course = get_record("course", "id", $id)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } if (! $module = get_record("modules", "name", $add)) { - error("This module type doesn't exist"); + print_error("This module type doesn't exist"); } $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('moodle/course:manageactivities', $context); if (!course_allowed_module($course,$module->id)) { - error("This module has been disabled for this particular course"); + print_error("This module has been disabled for this particular course"); } require_login($course->id); // needed to setup proper $COURSE @@ -675,7 +675,7 @@ } } else { - error("No action was specified"); + print_error("No action was specified"); } require_login($course->id); // needed to setup proper $COURSE diff --git a/course/modedit.php b/course/modedit.php index c55880f3cfd35..8d28a2bb46dda 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -18,7 +18,7 @@ $course = required_param('course', PARAM_INT); if (! $course = get_record("course", "id", $course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } require_login($course); @@ -26,13 +26,13 @@ require_capability('moodle/course:manageactivities', $context); if (! $module = get_record("modules", "name", $add)) { - error("This module type doesn't exist"); + print_error("This module type doesn't exist"); } $cw = get_course_section($section, $course->id); if (!course_allowed_module($course, $module->id)) { - error("This module has been disabled for this particular course"); + print_error("This module has been disabled for this particular course"); } $cm = null; @@ -75,11 +75,11 @@ $navlinksinstancename = ''; } else if (!empty($update)) { if (! $cm = get_record("course_modules", "id", $update)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } if (! $course = get_record("course", "id", $cm->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } require_login($course); // needed to setup proper $COURSE @@ -87,15 +87,15 @@ require_capability('moodle/course:manageactivities', $context); if (! $module = get_record("modules", "id", $cm->module)) { - error("This module doesn't exist"); + print_error("This module doesn't exist"); } if (! $form = get_record($module->name, "id", $cm->instance)) { - error("The required instance of this module doesn't exist"); + print_error("The required instance of this module doesn't exist"); } if (! $cw = get_record("course_sections", "id", $cm->section)) { - error("This course section doesn't exist"); + print_error("This course section doesn't exist"); } $form->coursemodule = $cm->id; @@ -160,7 +160,7 @@ $CFG->pagepath .= '/mod'; } } else { - error('Invalid operation.'); + print_error('Invalid operation.'); } $modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php"; @@ -168,14 +168,14 @@ require_once($modmoodleform); } else { - error('No formslib form description file found for this activity.'); + print_error('No formslib form description file found for this activity.'); } $modlib = "$CFG->dirroot/mod/$module->name/lib.php"; if (file_exists($modlib)) { include_once($modlib); } else { - error("This module is missing important code! ($modlib)"); + print_error("This module is missing important code! ($modlib)"); } $mformclassname = 'mod_'.$module->name.'_mod_form'; @@ -192,17 +192,17 @@ if (empty($fromform->coursemodule)) { //add $cm = null; if (! $course = get_record("course", "id", $fromform->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } $fromform->instance = ''; $fromform->coursemodule = ''; } else { //update if (! $cm = get_record("course_modules", "id", $fromform->coursemodule)) { - error("This course module doesn't exist"); + print_error("This course module doesn't exist"); } if (! $course = get_record("course", "id", $cm->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } $fromform->instance = $cm->instance; $fromform->coursemodule = $cm->id; @@ -243,10 +243,10 @@ $returnfromfunc = $updateinstancefunction($fromform); if (!$returnfromfunc) { - error("Could not update the $fromform->modulename", "view.php?id=$course->id"); + print_error("Could not update the $fromform->modulename", '', "view.php?id=$course->id"); } if (is_string($returnfromfunc)) { - error($returnfromfunc, "view.php?id=$course->id"); + print_error($returnfromfunc, '', "view.php?id=$course->id"); } set_coursemodule_visible($fromform->coursemodule, $fromform->visible); @@ -273,15 +273,15 @@ } if (!course_allowed_module($course,$fromform->modulename)) { - error("This module ($fromform->modulename) has been disabled for this particular course"); + print_error("This module ($fromform->modulename) has been disabled for this particular course"); } $returnfromfunc = $addinstancefunction($fromform); if (!$returnfromfunc) { - error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id"); + print_error("Could not add a new instance of $fromform->modulename", '', "view.php?id=$course->id"); } if (is_string($returnfromfunc)) { - error($returnfromfunc, "view.php?id=$course->id"); + print_error($returnfromfunc, '', "view.php?id=$course->id"); } $fromform->instance = $returnfromfunc; @@ -290,14 +290,14 @@ // to each other, so we have to update one of them twice. if (! $fromform->coursemodule = add_course_module($fromform) ) { - error("Could not add a new course module"); + print_error("Could not add a new course module"); } if (! $sectionid = add_mod_to_section($fromform) ) { - error("Could not add the new course module to that section"); + print_error("Could not add the new course module to that section"); } if (! set_field("course_modules", "section", $sectionid, "id", $fromform->coursemodule)) { - error("Could not update the course module with the correct section"); + print_error("Could not update the course module with the correct section"); } // make sure visibility is set correctly (in particular in calendar) @@ -315,7 +315,7 @@ "view.php?id=$fromform->coursemodule", "$fromform->instance", $fromform->coursemodule); } else { - error("Data submitted is invalid."); + print_error("Data submitted is invalid."); } // sync idnumber with grade_item diff --git a/course/recent.php b/course/recent.php index c94e6ddb77676..086e9dceaba8a 100644 --- a/course/recent.php +++ b/course/recent.php @@ -9,7 +9,7 @@ $id = required_param('id', PARAM_INT); if (!$course = get_record('course', 'id', $id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } require_login($course); @@ -46,7 +46,7 @@ if (!empty($param->user)) { if (!$u = get_record('user', 'id', $param->user) ) { - error("That's an invalid user!"); + print_error("That's an invalid user!"); } $userinfo = fullname($u); } diff --git a/course/report.php b/course/report.php index 515e0bb5d4d8d..f024fce3267d4 100644 --- a/course/report.php +++ b/course/report.php @@ -6,7 +6,7 @@ $id = required_param('id', PARAM_INT); // course id to import TO if (!$course = get_record('course', 'id', $id)) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } require_login($course->id); diff --git a/course/report/log/graph.php b/course/report/log/graph.php index b2dd3117e4478..ef7309b18dec5 100644 --- a/course/report/log/graph.php +++ b/course/report/log/graph.php @@ -11,7 +11,7 @@ $date = optional_param('date', 0, PARAM_INT); // A time of a day (in GMT) if (! $course = get_record("course", "id", $id)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id); @@ -19,12 +19,12 @@ if (! (has_capability('moodle/site:viewreports', $context) or ($course->showreports and $USER->id == $user)) ) { - error("Sorry, you aren't allowed to see this."); + print_error("Sorry, you aren't allowed to see this."); } if ($user) { if (! $user = get_record("user", "id", $user)) { - error("Can not find that user"); + print_error("Can not find that user"); } } diff --git a/course/report/log/index.php b/course/report/log/index.php index 2c6030f53c236..7cfd457b76b86 100644 --- a/course/report/log/index.php +++ b/course/report/log/index.php @@ -35,7 +35,7 @@ if ($hostid == $CFG->mnet_localhost_id) { if (!$course = get_record('course', 'id', $id) ) { - error('That\'s an invalid course id'.$id); + print_error('That\'s an invalid course id'.$id); } } else { $course_stub = array_pop(get_records_select('mnet_log', " hostid='$hostid' AND course='$id' ", '', '*', '', '1')); @@ -66,7 +66,7 @@ if ($user) { if (!$u = get_record('user', 'id', $user) ) { - error('That\'s an invalid user!'); + print_error('That\'s an invalid user!'); } $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context)); } diff --git a/course/report/log/live.php b/course/report/log/live.php index 9fd1961535e0e..732abadf99d73 100644 --- a/course/report/log/live.php +++ b/course/report/log/live.php @@ -8,14 +8,14 @@ $page = optional_param('page', 0, PARAM_INT); // which page to show if (! $course = get_record("course", "id", $id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); if (!has_capability('moodle/site:viewreports', $context)) { - error('You need do not have the required permission to view this report'); + print_error('You need do not have the required permission to view this report'); } add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id); diff --git a/course/report/outline/index.php b/course/report/outline/index.php index 989543970fd2b..628cf0e61cdc5 100644 --- a/course/report/outline/index.php +++ b/course/report/outline/index.php @@ -8,7 +8,7 @@ $id = required_param('id',PARAM_INT); // course id if (!$course = get_record('course', 'id', $id)) { - error('Course id is incorrect.'); + print_error('Course id is incorrect.'); } require_login($course); @@ -32,7 +32,7 @@ print_heading(format_string($course->fullname)); if (!$logstart = get_field_sql("SELECT MIN(time) FROM {$CFG->prefix}log")) { - error('Logs not available'); + print_error('Logs not available'); } echo '
'.get_string('computedfromlogs', 'admin', userdate($logstart)).'
'; diff --git a/course/report/stats/graph.php b/course/report/stats/graph.php index 3444708b2dd15..34e51a9838da1 100644 --- a/course/report/stats/graph.php +++ b/course/report/stats/graph.php @@ -12,12 +12,12 @@ $roleid = optional_param('roleid',0,PARAM_INT); if (!$course = get_record("course","id",$courseid)) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } if (!empty($userid)) { if (!$user = get_record('user','id',$userid)) { - error("That's an invalid user id"); + print_error("That's an invalid user id"); } } @@ -25,7 +25,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id); if (!has_capability('moodle/site:viewreports', $context)) { - error('You need do not have the required permission to view reports for this course'); + print_error('You need do not have the required permission to view reports for this course'); } stats_check_uptodate($course->id); diff --git a/course/report/stats/index.php b/course/report/stats/index.php index 0ab3fdf9cecfd..7183df393b86d 100644 --- a/course/report/stats/index.php +++ b/course/report/stats/index.php @@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/course/report/stats/lib.php'); if (empty($CFG->enablestats)) { - error("Stats is not enabled."); + print_error("Stats is not enabled."); } $courseid = required_param('course', PARAM_INT); @@ -29,12 +29,12 @@ } if (!$course = get_record("course","id",$courseid)) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } if (!empty($userid)) { if (!$user = get_record('user','id',$userid)) { - error("That's an invalid user id"); + print_error("That's an invalid user id"); } } diff --git a/course/report/stats/report.php b/course/report/stats/report.php index fa5d2184854e6..6093ac84191a4 100644 --- a/course/report/stats/report.php +++ b/course/report/stats/report.php @@ -14,7 +14,7 @@ $reportoptions = stats_get_report_options($course->id, $mode); $timeoptions = report_stats_timeoptions($mode); if (empty($timeoptions)) { - error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id); + print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); } $table->width = 'auto'; @@ -31,7 +31,7 @@ .' ORDER BY u.lastname, u.firstname ASC'; if (!$us = get_records_sql($sql)) { - error('Cannot enter detailed view: No users found for this course.'); + print_error('Cannot enter detailed view: No users found for this course.'); } foreach ($us as $u) { @@ -68,7 +68,7 @@ if (!empty($report) && !empty($time)) { if ($report == STATS_REPORT_LOGINS && $course->id != SITEID) { - error('This type of report is only available for the site course'); + print_error('This type of report is only available for the site course'); } $param = stats_get_parameters($time,$report,$course->id,$mode); diff --git a/course/request.php b/course/request.php index 9af3d0ced372b..7469cfdc4d887 100644 --- a/course/request.php +++ b/course/request.php @@ -8,7 +8,7 @@ require_login(); if (isguest()) { - error("No guests here!"); + print_error("No guests here!"); } if (empty($CFG->enablecourserequests)) { diff --git a/course/reset.php b/course/reset.php index cf165cd51ccc0..61c07c205f0ef 100755 --- a/course/reset.php +++ b/course/reset.php @@ -14,7 +14,7 @@ $id = required_param('id', PARAM_INT); if (!$course = get_record('course', 'id', $id)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course); diff --git a/course/scales.php b/course/scales.php index 3759a1f45e47e..1ea5a7884df60 100644 --- a/course/scales.php +++ b/course/scales.php @@ -7,7 +7,7 @@ $id = required_param('id', PARAM_INT); // course id if (! $course = get_record("course", "id", $id)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } require_login($course); diff --git a/course/search.php b/course/search.php index a497cee6985c0..215a7109e490e 100644 --- a/course/search.php +++ b/course/search.php @@ -108,7 +108,7 @@ if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved if (! $destcategory = get_record("course_categories", "id", $data->moveto)) { - error("Error finding the category"); + print_error("Error finding the category"); } $courses = array(); @@ -124,7 +124,7 @@ if (!empty($blocklist) and confirm_sesskey()) { $blockid = $blocklist; if (!$blocks = get_records('block_instance', 'blockid', $blockid)) { - error( "Could not read data for blockid=$blockid" ); + print_error( "Could not read data for blockid=$blockid" ); } // run through blocks and get (unique) courses @@ -137,7 +137,7 @@ continue; } if (!$course = get_record('course', 'id', $courseid)) { - error( "Could not read data for courseid=$courseid" ); + print_error( "Could not read data for courseid=$courseid" ); } $courses[$courseid] = $course; } @@ -147,7 +147,7 @@ elseif (!empty($modulelist) and confirm_sesskey()) { $modulename = $modulelist; if (!$modules = get_records($modulename)) { - error( "Could not read data for module=$modulename" ); + print_error( "Could not read data for module=$modulename" ); } // run through modules and get (unique) courses @@ -158,7 +158,7 @@ continue; } if (!$course = get_record('course', 'id', $courseid)) { - error( "Could not read data for courseid=$courseid" ); + print_error( "Could not read data for courseid=$courseid" ); } $courses[$courseid] = $course; } diff --git a/course/unenrol.php b/course/unenrol.php index 03617c3e30d6c..74e877defac28 100644 --- a/course/unenrol.php +++ b/course/unenrol.php @@ -22,11 +22,11 @@ } if (! $course = get_record('course', 'id', $id) ) { - error('Invalid course id'); + print_error('Invalid course id'); } if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) { - error('Invalid context'); + print_error('Invalid context'); } require_login($course->id); @@ -43,7 +43,7 @@ // verify user may unassign all roles at course context foreach($roles as $role) { if (!user_can_assign($context, $role->roleid)) { - error('Can not unassign this user from role id:'.$role->roleid); + print_error('Can not unassign this user from role id:'.$role->roleid); } } @@ -59,7 +59,7 @@ if ($confirm and confirm_sesskey()) { if ($userid) { if (! role_unassign(0, $userid, 0, $context->id)) { - error("An error occurred while trying to unenrol that person."); + print_error("An error occurred while trying to unenrol that person."); } add_to_log($course->id, 'course', 'unenrol', "view.php?id=$course->id", $userid); @@ -67,7 +67,7 @@ } else { if (! role_unassign(0, $USER->id, 0, $context->id)) { - error("An error occurred while trying to unenrol you."); + print_error("An error occurred while trying to unenrol you."); } // force a refresh of mycourses @@ -88,7 +88,7 @@ if ($userid) { if (!$user = get_record('user', 'id', $userid)) { - error('That user does not exist!'); + print_error('That user does not exist!'); } $strunenrolsure = get_string('unenrolsure', '', fullname($user, true)); notice_yesno($strunenrolsure, "unenrol.php?id=$id&user=$user->id&confirm=yes&sesskey=".sesskey(), diff --git a/course/user.php b/course/user.php index 0707f9f337a46..8768086eacdaa 100644 --- a/course/user.php +++ b/course/user.php @@ -14,11 +14,11 @@ $perpage = optional_param('perpage', 100, PARAM_INT); if (! $course = get_record("course", "id", $id)) { - error("Course id is incorrect."); + print_error("Course id is incorrect."); } if (! $user = get_record("user", "id", $user)) { - error("User ID is incorrect"); + print_error("User ID is incorrect"); } //require_login($course); @@ -29,7 +29,7 @@ // if in either context, we can read report, then we can proceed if (!(has_capability('moodle/site:viewreports', $coursecontext) or ($course->showreports and $USER->id == $user->id) or has_capability('moodle/user:viewuseractivitiesreport', $personalcontext))) { - error("You are not allowed to look at this page"); + print_error("You are not allowed to look at this page"); } add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id"); @@ -102,7 +102,7 @@ case 'stats': if (empty($CFG->enablestats)) { - error("Stats is not enabled."); + print_error("Stats is not enabled."); } require_once($CFG->dirroot.'/lib/statslib.php'); @@ -127,7 +127,7 @@ $timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth); if (empty($timeoptions)) { - error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline'); + print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline'); } // use the earliest. @@ -146,7 +146,7 @@ $stats = get_records_sql($sql); if (empty($stats)) { - error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline'); + print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline'); } // MDL-10818, do not display broken graph when user has no permission to view graph diff --git a/course/view.php b/course/view.php index 4539d9c633c08..04f83fab402e4 100644 --- a/course/view.php +++ b/course/view.php @@ -22,20 +22,20 @@ if (empty($id) && empty($name) && empty($idnumber)) { - error("Must specify course id, short name or idnumber"); + print_error("Must specify course id, short name or idnumber"); } if (!empty($name)) { if (! ($course = get_record('course', 'shortname', $name)) ) { - error('Invalid short course name'); + print_error('Invalid short course name'); } } else if (!empty($idnumber)) { if (! ($course = get_record('course', 'idnumber', $idnumber)) ) { - error('Invalid course idnumber'); + print_error('Invalid course idnumber'); } } else { if (! ($course = get_record('course', 'id', $id)) ) { - error('Invalid course id'); + print_error('Invalid course id'); } } @@ -206,7 +206,7 @@ $section->id = insert_record('course_sections', $section); } if (! $sections = get_all_sections($course->id) ) { // Try again - error('Error finding or creating section structures for this course'); + print_error('Error finding or creating section structures for this course'); } } diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 529e387dea834..60d4c4ce4d55a 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -45,7 +45,7 @@ public function print_entry($course) if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 443) { // MDL-9836 if (empty($CFG->loginhttps)) { - error(get_string('httpsrequired', 'enrol_authorize')); + print_error('httpsrequired', 'enrol_authorize'); } else { $wwwsroot = str_replace('http:','https:', $CFG->wwwroot); redirect("$wwwsroot/course/enrol.php?id=$course->id"); @@ -92,7 +92,7 @@ public function print_entry($course) break; } if (!empty($authorizeerror)) { - error($authorizeerror); + print_error($authorizeerror); } } $frmenrol->display(); diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php index 744fa4ab3f8c4..eea8655f5895d 100755 --- a/enrol/authorize/enrol_form.php +++ b/enrol/authorize/enrol_form.php @@ -11,7 +11,7 @@ function definition() $paymentmethodsenabled = get_list_of_payment_methods(); $paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA); if (!in_array($paymentmethod, $paymentmethodsenabled)) { - error("Invalid payment method: $paymentmethod"); + print_error("Invalid payment method: $paymentmethod"); } $mform =& $this->_form; diff --git a/enrol/authorize/index.php b/enrol/authorize/index.php index ab4e53e6e2ceb..12d416756d1d7 100644 --- a/enrol/authorize/index.php +++ b/enrol/authorize/index.php @@ -5,7 +5,7 @@ require_once('const.php'); require_once('locallib.php'); require_once('localfuncs.php'); - require_once('authorizenetlib.php'); + require_once('authorizenet.class.php'); /// Parameters $orderid = optional_param('order', 0, PARAM_INT); @@ -14,13 +14,13 @@ /// Get course if (! $course = get_record('course', 'id', $courseid)) { - error('Could not find that course'); + print_error('Could not find that course'); } /// Only SITE users can access to this page require_login(); // Don't use $courseid! User may want to see old orders. if (has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) { - error("Guests cannot use this page."); + print_error("Guests cannot use this page."); } /// Load strings. All strings should be defined here. locallib.php uses these strings. diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index c8291e814fd3e..09f3e42ae5311 100644 --- a/enrol/authorize/locallib.php +++ b/enrol/authorize/locallib.php @@ -92,10 +92,11 @@ function authorize_print_orders($courseid, $userid) if ($perpage > 100) { $perpage = 100; } $perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100); $perpagemenu = popup_form($baseurl.'&status='.$status.'&course='.$courseid.'&perpage=',$perpagemenus,'perpagemenu',$perpage,'','','',true); - $table->define_columns(array('id', 'userid', 'timecreated', 'status', '')); + $table->define_columns(array('id', 'userid', 'timecreated', 'status', 'action')); $table->define_headers(array($authstrs->orderid, $authstrs->shopper, $strs->time, $strs->status, $perpagemenu)); $table->define_baseurl($baseurl."&status=$status&course=$courseid&perpage=$perpage"); + $table->no_sorting('action'); $table->sortable(true, 'id', SORT_DESC); $table->pageable(true); $table->setup(); @@ -210,15 +211,15 @@ function authorize_print_order($orderid) $confirm = optional_param('confirm', 0, PARAM_BOOL); if (!$order = get_record('enrol_authorize', 'id', $orderid)) { - error("Order $orderid not found.", "$CFG->wwwroot/enrol/authorize/index.php"); + print_error("Order $orderid not found.", '', "$CFG->wwwroot/enrol/authorize/index.php"); } if (!$course = get_record('course', 'id', $order->courseid)) { - error("Could not find that course id $order->courseid", "$CFG->wwwroot/enrol/authorize/index.php"); + print_error("Could not find that course id $order->courseid", '', "$CFG->wwwroot/enrol/authorize/index.php"); } if (!$user = get_record('user', 'id', $order->userid)) { - error("Could not find that user id $order->userid", "$CFG->wwwroot/enrol/authorize/index.php"); + print_error("Could not find that user id $order->userid", '', "$CFG->wwwroot/enrol/authorize/index.php"); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); @@ -226,7 +227,7 @@ function authorize_print_order($orderid) require_capability('enrol/authorize:managepayments', $coursecontext); } - $settled = authorize_settled($order); + $settled = AuthorizeNet::settled($order); $statusandactions = authorize_get_status_action($order); $color = authorize_get_status_color($statusandactions->status); @@ -280,7 +281,7 @@ function authorize_print_order($orderid) if ($confirm && confirm_sesskey()) { $message = ''; $extra = NULL; - if (AN_APPROVED == authorize_action($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) { + if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) { if (empty($CFG->an_test)) { if (enrol_into_course($course, $user, 'authorize')) { if (!empty($CFG->enrol_mailstudents)) { @@ -316,18 +317,18 @@ function authorize_print_order($orderid) } $upto = round($order->amount - $refunded, 2); if ($upto <= 0) { - error("Refunded to original amount: $order->amount", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); + print_error("Refunded to original amount: $order->amount", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); } $amount = round(optional_param('amount', $upto), 2); if ($amount > $upto) { - error("Can be refunded to $upto", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); + print_error("Can be refunded to $upto", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); } if ($confirm && confirm_sesskey()) { $extra = new stdClass; $extra->orderid = $orderid; $extra->amount = $amount; $message = ''; - $success = authorize_action($order, $message, $extra, AN_ACTION_CREDIT); + $success = AuthorizeNet::process($order, $message, $extra, AN_ACTION_CREDIT); if (AN_APPROVED == $success || AN_REVIEW == $success) { if (empty($CFG->an_test)) { if (empty($extra->id)) { @@ -375,7 +376,7 @@ function authorize_print_order($orderid) if ($confirm && confirm_sesskey()) { $extra = NULL; $message = ''; - if (AN_APPROVED == authorize_action($order, $message, $extra, AN_ACTION_VOID)) { + if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_VOID)) { if (empty($CFG->an_test)) { redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); } @@ -402,7 +403,7 @@ function authorize_print_order($orderid) $suborder = get_record_sql($sql); if (!$suborder) { // not found - error("Transaction can not be voided because of already been voided.", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); + print_error("Transaction can not be voided because of already been voided.", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); } $refundedstatus = authorize_get_status_action($suborder); unset($suborder->courseid); @@ -410,7 +411,7 @@ function authorize_print_order($orderid) if ($confirm && confirm_sesskey()) { $message = ''; $extra = NULL; - if (AN_APPROVED == authorize_action($suborder, $message, $extra, AN_ACTION_VOID)) { + if (AN_APPROVED == AuthorizeNet::process($suborder, $message, $extra, AN_ACTION_VOID)) { if (empty($CFG->an_test)) { if (!empty($unenrol)) { role_unassign(0, $order->userid, 0, $coursecontext->id); @@ -524,7 +525,7 @@ function authorize_get_status_action($order) switch ($order->status) { case AN_STATUS_AUTH: - if (authorize_expired($order)) { + if (AuthorizeNet::expired($order)) { if ($canmanage) { $ret->actions = array(ORDER_DELETE); } @@ -539,7 +540,7 @@ function authorize_get_status_action($order) return $ret; case AN_STATUS_AUTHCAPTURE: - if (authorize_settled($order)) { + if (AuthorizeNet::settled($order)) { if ($canmanage) { if (($order->paymentmethod == AN_METHOD_CC) || ($order->paymentmethod == AN_METHOD_ECHECK && !empty($order->refundinfo))) { $ret->actions = array(ORDER_REFUND); @@ -556,7 +557,7 @@ function authorize_get_status_action($order) return $ret; case AN_STATUS_CREDIT: - if (authorize_settled($order)) { + if (AuthorizeNet::settled($order)) { $ret->status = 'settled'; } else { diff --git a/enrol/authorize/uploadcsv.php b/enrol/authorize/uploadcsv.php index 0d68154de9889..940033abcd19e 100644 --- a/enrol/authorize/uploadcsv.php +++ b/enrol/authorize/uploadcsv.php @@ -76,13 +76,13 @@ function authorize_process_csv($filename) /// Open the file and get first line $handle = fopen($filename, "r"); if (!$handle) { - error('CANNOT OPEN CSV FILE'); + print_error('CANNOT OPEN CSV FILE'); } $firstline = fgetcsv($handle, 8192, ","); $numfields = count($firstline); if ($numfields != 49 && $numfields != 70) { @fclose($handle); - error('INVALID CSV FILE; Each line must include 49 or 70 fields'); + print_error('INVALID CSV FILE; Each line must include 49 or 70 fields'); } /// Re-sort fields @@ -97,7 +97,7 @@ function authorize_process_csv($filename) } if (empty($csvfields)) { @fclose($handle); - error("INVALID CSV FILE: First line must include 'Header Fields' and + print_error("INVALID CSV FILE: First line must include 'Header Fields' and the file must be type of
'Expanded Fields/Comma Separated'
or
'Expanded Fields with CAVV Result Code/Comma Separated'"); } diff --git a/enrol/manual/enrol.php b/enrol/manual/enrol.php index 78e51b8eec5c7..2346198f8135b 100644 --- a/enrol/manual/enrol.php +++ b/enrol/manual/enrol.php @@ -141,7 +141,7 @@ function check_entry($form, $course) { if (empty($course->password)) { // do not allow entry when no course password set // automatic login when manual primary, no login when secondary at all!! - error('illegal enrolment attempted'); + print_error('illegal enrolment attempted'); } $groupid = $this->check_group_entry($course->id, $form->password); diff --git a/enrol/mnet/enrol.php b/enrol/mnet/enrol.php index 650f3dc97ede7..dcb6f639a8b0a 100644 --- a/enrol/mnet/enrol.php +++ b/enrol/mnet/enrol.php @@ -363,7 +363,7 @@ function unenrol_user($user, $courseid) { // require_capability('moodle/role:assign', $context, NULL, false); if (!role_unassign(0, $userrecord->id, 0, $context->id)) { - error("An error occurred while trying to unenrol that person."); + print_error("An error occurred while trying to unenrol that person."); } return true; @@ -500,7 +500,7 @@ function fetch_remote_courses($mnethostid) { list($code, $errormessage) = array_map('trim',explode(':', $errormessage, 2)); $message .= "ERROR $code:
$errormessage
"; } - error("RPC enrol/mnet/available_courses:
$message"); + print_error("RPC enrol/mnet/available_courses:
$message"); } return false; } diff --git a/enrol/paypal/ipn.php b/enrol/paypal/ipn.php index e88367e272410..0781d4ce7ff24 100644 --- a/enrol/paypal/ipn.php +++ b/enrol/paypal/ipn.php @@ -18,7 +18,7 @@ /// Keep out casual intruders if (empty($_POST) or !empty($_GET)) { - error("Sorry, you can not use the script that way."); + print_error("Sorry, you can not use the script that way."); } /// Read all the data from PayPal and get it ready for later; diff --git a/error/index.php b/error/index.php index fefcb33adfa12..602d0fef1bc23 100644 --- a/error/index.php +++ b/error/index.php @@ -11,7 +11,7 @@ /// Work out who to send the message to if (!$admin = get_admin() ) { - error('Could not find an admin user!'); + print_error('Could not find an admin user!'); } $supportuser = new object; diff --git a/file.php b/file.php index 80ad8f810937d..c59c65cb8ee91 100644 --- a/file.php +++ b/file.php @@ -28,9 +28,9 @@ // relative path must start with '/', because of backup/restore!!! if (!$relativepath) { - error('No valid arguments supplied or incorrect server configuration'); + print_error('No valid arguments supplied or incorrect server configuration'); } else if ($relativepath{0} != '/') { - error('No valid arguments supplied, path does not start with slash!'); + print_error('No valid arguments supplied, path does not start with slash!'); } $pathname = $CFG->dataroot.$relativepath; @@ -38,24 +38,24 @@ // extract relative path components $args = explode('/', trim($relativepath, '/')); if (count($args) == 0) { // always at least courseid, may search for index.html in course root - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } // security: limit access to existing course subdirectories if (($args[0]!='blog') and (!$course = get_record_sql("SELECT * FROM {$CFG->prefix}course WHERE id='".(int)$args[0]."'"))) { - error('Invalid course ID'); + print_error('Invalid course ID'); } // security: prevent access to "000" or "1 something" directories // hack for blogs, needs proper security check too if (($args[0] != 'blog') and ($args[0] != $course->id)) { - error('Invalid course ID'); + print_error('Invalid course ID'); } // security: login to course if necessary if ($args[0] == 'blog') { if (empty($CFG->bloglevel)) { - error('Blogging is disabled!'); + print_error('Blogging is disabled!'); } else if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) { require_login(); } else if ($CFG->forcelogin) { @@ -76,7 +76,7 @@ // security: only editing teachers can access backups if ((count($args) >= 2) and (strtolower($args[1]) == 'backupdata')) { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) { - error('Access not allowed'); + print_error('Access not allowed'); } else { $lifetime = 0; //disable browser caching for backups } @@ -106,7 +106,7 @@ $lifetime = 0; // do not cache assignments, students may reupload them if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_COURSE, $course->id)) and $args[4] != $USER->id) { - error('Access not allowed'); + print_error('Access not allowed'); } } @@ -150,7 +150,7 @@ "AND r.type = 'file' " . "AND r.reference = '{$reference}'"; if (count_records_sql($sql)) { - error('Access not allowed'); + print_error('Access not allowed'); } } @@ -169,6 +169,6 @@ function not_found($courseid) { global $CFG; header('HTTP/1.0 404 not found'); - error(get_string('filenotfound', 'error'), $CFG->wwwroot.'/course/view.php?id='.$courseid); //this is not displayed on IIS?? + print_error('filenotfound', 'error', $CFG->wwwroot.'/course/view.php?id='.$courseid); //this is not displayed on IIS?? } ?> diff --git a/files/index.php b/files/index.php index 96d710c123887..3ff0190c7b477 100644 --- a/files/index.php +++ b/files/index.php @@ -25,13 +25,13 @@ if ($choose) { if (count(explode('.', $choose)) > 2) { - error('Incorrect format for choose parameter'); + print_error('Incorrect format for choose parameter'); } } if (! $course = get_record("course", "id", $id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } require_login($course); @@ -158,7 +158,7 @@ function set_value(txt) { if (! $basedir = make_upload_directory("$course->id")) { - error("The site administrator needs to fix the file permissions"); + print_error("The site administrator needs to fix the file permissions"); } $baseweb = $CFG->wwwroot; @@ -176,13 +176,13 @@ function set_value(txt) { if ($wdir == "/backupdata") { if (! make_upload_directory("$course->id/backupdata")) { // Backup folder - error("Could not create backupdata folder. The site administrator needs to fix the file permissions"); + print_error("Could not create backupdata folder. The site administrator needs to fix the file permissions"); } } if (!is_dir($basedir.$wdir)) { html_header($course, $wdir); - error("Requested directory does not exist.", "$CFG->wwwroot/files/index.php?id=$id"); + print_error("Requested directory does not exist.", '', "$CFG->wwwroot/files/index.php?id=$id"); } switch ($action) { @@ -474,7 +474,7 @@ function set_value(txt) { } if (!zip_files($files,"$basedir$wdir/$name")) { - error(get_string("zipfileserror","error")); + print_error("zipfileserror","error"); } clearfilelist(); @@ -532,7 +532,7 @@ function set_value(txt) { $file = basename($file); if (!unzip_file("$basedir$wdir/$file")) { - error(get_string("unzipfileserror","error")); + print_error("unzipfileserror","error"); } echo "
"; diff --git a/filter/algebra/pix.php b/filter/algebra/pix.php index 5d51d769743be..05804d84f6b68 100644 --- a/filter/algebra/pix.php +++ b/filter/algebra/pix.php @@ -35,7 +35,7 @@ $image = $args[0]; $pathname = $CFG->dataroot.'/filter/algebra/'.$image; } else { - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } if (!file_exists($pathname)) { diff --git a/filter/tex/lib.php b/filter/tex/lib.php index 7eeb949cedd59..4c358781bef7d 100644 --- a/filter/tex/lib.php +++ b/filter/tex/lib.php @@ -21,7 +21,7 @@ function tex_filter_get_executable($debug=false) { if (is_executable($custom_commandpath)) { return $custom_commandpath; } else { - error($error_message2.$error_message1); + print_error($error_message2.$error_message1); } } @@ -31,7 +31,7 @@ function tex_filter_get_executable($debug=false) { case "FreeBSD": return "$CFG->dirroot/filter/tex/mimetex.freebsd"; } - error($error_message1); + print_error($error_message1); } diff --git a/filter/tex/pix.php b/filter/tex/pix.php index 457703e54f858..377db43ad472c 100644 --- a/filter/tex/pix.php +++ b/filter/tex/pix.php @@ -36,7 +36,7 @@ $image = $args[0]; $pathname = $CFG->dataroot.'/filter/tex/'.$image; } else { - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } if (!file_exists($pathname)) { diff --git a/grade/edit/letter/edit.php b/grade/edit/letter/edit.php index 0377da37371b5..e93a8e125b999 100644 --- a/grade/edit/letter/edit.php +++ b/grade/edit/letter/edit.php @@ -32,7 +32,7 @@ $contextid = optional_param('id', SYSCONTEXTID, PARAM_INT); if (!$context = get_context_instance_by_id($contextid)) { - error('Incorrect context id'); + print_error('Incorrect context id'); } if ($context->contextlevel == CONTEXT_SYSTEM or $context->contextlevel == CONTEXT_COURSECAT) { @@ -49,7 +49,7 @@ $returnurl = $CFG->wwwroot.'/grade/edit/letter/index.php?id='.$context->instanceid; } else { - error('Incorrect context level'); + print_error('Incorrect context level'); } require_capability('moodle/grade:manageletters', $context); diff --git a/grade/edit/letter/index.php b/grade/edit/letter/index.php index 410471b5b95e5..310159d154ab4 100644 --- a/grade/edit/letter/index.php +++ b/grade/edit/letter/index.php @@ -37,7 +37,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id); if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:manageletters', $context)) { - error('Missing permission to view letter grades'); + print_error('Missing permission to view letter grades'); } $gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'letter', 'courseid'=>$courseid)); diff --git a/grade/edit/outcome/edit.php b/grade/edit/outcome/edit.php index ac0eaf8013776..f1c3aec2800a1 100644 --- a/grade/edit/outcome/edit.php +++ b/grade/edit/outcome/edit.php @@ -37,12 +37,12 @@ if ($id) { /// editing existing outcome if (!$outcome_rec = get_record('grade_outcomes', 'id', $id)) { - error('Incorrect outcome id'); + print_error('Incorrect outcome id'); } if ($outcome_rec->courseid) { $outcome_rec->standard = 0; if (!$course = get_record('course', 'id', $outcome_rec->courseid)) { - error('Incorrect course id'); + print_error('Incorrect course id'); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); @@ -51,7 +51,7 @@ } else { if ($courseid) { if (!$course = get_record('course', 'id', $courseid)) { - error('Incorrect course id'); + print_error('Incorrect course id'); } } $outcome_rec->standard = 1; diff --git a/grade/edit/outcome/index.php b/grade/edit/outcome/index.php index 99cc315553032..60bda49ec8d76 100644 --- a/grade/edit/outcome/index.php +++ b/grade/edit/outcome/index.php @@ -92,7 +92,7 @@ if (empty($outcome->courseid)) { require_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM)); } else if ($outcome->courseid != $courseid) { - error('Incorrect courseid!'); + print_error('Incorrect courseid!'); } if (!$outcome->can_delete()) { diff --git a/grade/edit/scale/edit.php b/grade/edit/scale/edit.php index 5842451f318b2..26b700e468fa3 100644 --- a/grade/edit/scale/edit.php +++ b/grade/edit/scale/edit.php @@ -37,12 +37,12 @@ if ($id) { /// editing existing scale if (!$scale_rec = get_record('scale', 'id', $id)) { - error('Incorrect scale id'); + print_error('Incorrect scale id'); } if ($scale_rec->courseid) { $scale_rec->standard = 0; if (!$course = get_record('course', 'id', $scale_rec->courseid)) { - error('Incorrect course id'); + print_error('Incorrect course id'); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); @@ -51,7 +51,7 @@ } else { if ($courseid) { if (!$course = get_record('course', 'id', $courseid)) { - error('Incorrect course id'); + print_error('Incorrect course id'); } } $scale_rec->standard = 1; diff --git a/grade/edit/scale/index.php b/grade/edit/scale/index.php index 2968220a155ce..0a950e26df6a0 100644 --- a/grade/edit/scale/index.php +++ b/grade/edit/scale/index.php @@ -76,7 +76,7 @@ if (empty($scale->courseid)) { require_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM)); } else if ($scale->courseid != $courseid) { - error('Incorrect courseid!'); + print_error('Incorrect courseid!'); } if (!$scale->can_delete()) { diff --git a/grade/edit/tree/action.php b/grade/edit/tree/action.php index 79f86aa53e5ed..c6722edd476c3 100644 --- a/grade/edit/tree/action.php +++ b/grade/edit/tree/action.php @@ -46,7 +46,7 @@ // what are we working with? if (!$element = $gtree->locate_element($eid)) { - error('Incorrect element id!', $returnurl); + print_error('Incorrect element id!', '', $returnurl); } $object = $element['object']; $type = $element['type']; @@ -56,7 +56,7 @@ case 'hide': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) { - error('No permission to hide!', $returnurl); + print_error('No permission to hide!', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); @@ -68,7 +68,7 @@ case 'show': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) { - error('No permission to show!', $returnurl); + print_error('No permission to show!', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); @@ -80,7 +80,7 @@ case 'lock': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:lock', $context)) { - error('No permission to lock!', $returnurl); + print_error('No permission to lock!', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); @@ -92,7 +92,7 @@ case 'unlock': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:unlock', $context)) { - error('No permission to unlock!', $returnurl); + print_error('No permission to unlock!', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); diff --git a/grade/edit/tree/calculation.php b/grade/edit/tree/calculation.php index fd79c2382a727..06e9e27850dea 100644 --- a/grade/edit/tree/calculation.php +++ b/grade/edit/tree/calculation.php @@ -46,7 +46,7 @@ $returnurl = $gpr->get_return_url($CFG->wwwroot.'/grade/report.php?id='.$course->id); if (!$grade_item = grade_item::fetch(array('id'=>$id, 'courseid'=>$course->id))) { - error('Incorect item id'); + print_error('Incorect item id'); } // activity items and items without grade can not have calculation diff --git a/grade/edit/tree/category.php b/grade/edit/tree/category.php index 853bcfe2912ab..073f4019caa17 100644 --- a/grade/edit/tree/category.php +++ b/grade/edit/tree/category.php @@ -48,7 +48,7 @@ if ($id) { if (!$grade_category = grade_category::fetch(array('id'=>$id, 'courseid'=>$course->id))) { - error('Incorrect category id!'); + print_error('Incorrect category id!'); } $grade_category->apply_forced_settings(); $category = $grade_category->get_record_data(); @@ -98,7 +98,7 @@ // Handle user preferences if (isset($data->pref_aggregationview)) { if (!grade_report::set_pref('aggregationview', $data->pref_aggregationview, $grade_category->id)) { - error("Could not set preference aggregationview to $value for this grade category"); + print_error("Could not set preference aggregationview to $value for this grade category"); } } diff --git a/grade/edit/tree/grade.php b/grade/edit/tree/grade.php index e0981c3b4df0a..5b0463c79d67b 100644 --- a/grade/edit/tree/grade.php +++ b/grade/edit/tree/grade.php @@ -50,27 +50,27 @@ // security checks! if (!empty($id)) { if (!$grade = get_record('grade_grades', 'id', $id)) { - error('Incorrect grade id'); + print_error('Incorrect grade id'); } if (!empty($itemid) and $itemid != $grade->itemid) { - error('Incorrect itemid'); + print_error('Incorrect itemid'); } $itemid = $grade->itemid; if (!empty($userid) and $userid != $grade->userid) { - error('Incorrect userid'); + print_error('Incorrect userid'); } $userid = $grade->userid; unset($grade); } else if (empty($userid) or empty($itemid)) { - error('Missing userid and itemid'); + print_error('Missing userid and itemid'); } if (!$grade_item = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$courseid))) { - error('Can not find grade_item'); + print_error('Can not find grade_item'); } // now verify grading user has access to all groups or is member of the same group when separate groups used in course @@ -83,10 +83,10 @@ } } if (!$ok) { - error('Can not grade this user'); + print_error('Can not grade this user'); } } else { - error('Can not grade this user'); + print_error('Can not grade this user'); } } diff --git a/grade/edit/tree/index.php b/grade/edit/tree/index.php index 17aa4aafa19a8..4c34e7f46d27a 100644 --- a/grade/edit/tree/index.php +++ b/grade/edit/tree/index.php @@ -59,7 +59,7 @@ } else { if (!$element = $gtree->locate_element($eid)) { - error('Incorrect element id!', $returnurl); + print_error('Incorrect element id!', '', $returnurl); } $object = $element['object']; } @@ -112,7 +112,7 @@ if ($eid and confirm_sesskey()) { $moveafter = required_param('moveafter', PARAM_ALPHANUM); if(!$after_el = $gtree->locate_element($moveafter)) { - error('Incorect element id in moveafter', $returnurl); + print_error('Incorect element id in moveafter', '', $returnurl); } $after = $after_el['object']; $parent = $after->get_parent_category(); diff --git a/grade/export/key.php b/grade/export/key.php index fdbc4f2f9737c..4fc2abcb84f40 100644 --- a/grade/export/key.php +++ b/grade/export/key.php @@ -34,22 +34,22 @@ if ($id) { if (!$key = get_record('user_private_key', 'id', $id)) { - error('Group ID was incorrect'); + print_error('Group ID was incorrect'); } if (empty($courseid)) { $courseid = $key->instance; } else if ($courseid != $key->instance) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } } else { if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } $key = new object(); } @@ -62,7 +62,7 @@ // extra security check if (!empty($key->userid) and $USER->id != $key->userid) { - error('You are not owner of this key'); + print_error('You are not owner of this key'); } $returnurl = $CFG->wwwroot.'/grade/export/keymanager.php?id='.$course->id; diff --git a/grade/export/ods/dump.php b/grade/export/ods/dump.php index e5c1d1689aa13..8f40b6269598a 100644 --- a/grade/export/ods/dump.php +++ b/grade/export/ods/dump.php @@ -34,7 +34,7 @@ require_user_key_login('grade/export', $id); // we want different keys for each course if (empty($CFG->gradepublishing)) { - error('Grade publishing disabled'); + print_error('Grade publishing disabled'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/grade/export/txt/dump.php b/grade/export/txt/dump.php index 1969f95c1e0dd..9897cc152b671 100644 --- a/grade/export/txt/dump.php +++ b/grade/export/txt/dump.php @@ -34,7 +34,7 @@ require_user_key_login('grade/export', $id); // we want different keys for each course if (empty($CFG->gradepublishing)) { - error('Grade publishing disabled'); + print_error('Grade publishing disabled'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/grade/export/xls/dump.php b/grade/export/xls/dump.php index 5ae4dd70a52be..7139e2f6cc080 100644 --- a/grade/export/xls/dump.php +++ b/grade/export/xls/dump.php @@ -34,7 +34,7 @@ require_user_key_login('grade/export', $id); // we want different keys for each course if (empty($CFG->gradepublishing)) { - error('Grade publishing disabled'); + print_error('Grade publishing disabled'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/grade/export/xml/dump.php b/grade/export/xml/dump.php index d0cff60b58edf..68a7aadd62a54 100644 --- a/grade/export/xml/dump.php +++ b/grade/export/xml/dump.php @@ -34,7 +34,7 @@ require_user_key_login('grade/export', $id); // we want different keys for each course if (empty($CFG->gradepublishing)) { - error('Grade publishing disabled'); + print_error('Grade publishing disabled'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/grade/export/xml/grade_export_xml.php b/grade/export/xml/grade_export_xml.php index 0f505780661fe..2379929e1c1af 100755 --- a/grade/export/xml/grade_export_xml.php +++ b/grade/export/xml/grade_export_xml.php @@ -50,7 +50,7 @@ function print_grades($feedback = false) { make_upload_directory('temp/gradeexport', false); $tempfilename = $CFG->dataroot .'/temp/gradeexport/'. md5(sesskey().microtime().$downloadfilename); if (!$handle = fopen($tempfilename, 'w+b')) { - error("Could not create a temporary file into which to dump the XML data."); + print_error("Could not create a temporary file into which to dump the XML data."); return false; } diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index 36d42847ee477..e4f1edaa47caf 100755 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -160,7 +160,7 @@ $filename = $CFG->dataroot.'/temp/gradeimport/cvs/'.$USER->id.'/'.$importcode; if (!file_exists($filename)) { - error('error processing upload file'); + print_error('error processing upload file'); } if ($fp = fopen($filename, "r")) { @@ -195,7 +195,7 @@ } else { // collision unlink($filename); // needs to be uploaded again, sorry - error('mapping collision detected, 2 fields maps to the same grade item '.$j); + print_error('mapping collision detected, 2 fields maps to the same grade item '.$j); } } } diff --git a/grade/import/key.php b/grade/import/key.php index df9a4d8063c5b..c4426db2d7d51 100644 --- a/grade/import/key.php +++ b/grade/import/key.php @@ -34,22 +34,22 @@ if ($id) { if (!$key = get_record('user_private_key', 'id', $id)) { - error('Group ID was incorrect'); + print_error('Group ID was incorrect'); } if (empty($courseid)) { $courseid = $key->instance; } else if ($courseid != $key->instance) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } } else { if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } $key = new object(); } @@ -62,7 +62,7 @@ // extra security check if (!empty($key->userid) and $USER->id != $key->userid) { - error('You are not owner of this key'); + print_error('You are not owner of this key'); } $returnurl = $CFG->wwwroot.'/grade/import/keymanager.php?id='.$course->id; diff --git a/grade/import/xml/fetch.php b/grade/import/xml/fetch.php index 1fed44e9aa9f6..a0c1715badac1 100644 --- a/grade/import/xml/fetch.php +++ b/grade/import/xml/fetch.php @@ -34,7 +34,7 @@ require_user_key_login('grade/import', $id); // we want different keys for each course if (empty($CFG->gradepublishing)) { - error('Grade publishing disabled'); + print_error('Grade publishing disabled'); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/grade/import/xml/import.php b/grade/import/xml/import.php index 960c40e24c948..f479aa8ca1a50 100644 --- a/grade/import/xml/import.php +++ b/grade/import/xml/import.php @@ -53,7 +53,7 @@ $text = download_file_content($url); if ($text === false) { - error('Can not read file'); + print_error('Can not read file'); } $error = ''; @@ -67,7 +67,7 @@ echo 'ok'; die; } else { - error('Grade import error'); //TODO: localize + print_error('Grade import error'); //TODO: localize } } else { @@ -85,7 +85,7 @@ } } else { - error($error); + print_error($error); } ?> diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index 230c94dc0cc69..2ad2d9d18ea6f 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -180,7 +180,7 @@ function process_data($data) { } if (!$grade_item = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$this->courseid))) { // we must verify course id here! - error('Incorrect grade item id'); + print_error('Incorrect grade item id'); } // Pre-process grade diff --git a/grade/report/index.php b/grade/report/index.php index f0fb7e2573dfc..2aa15701b94c3 100644 --- a/grade/report/index.php +++ b/grade/report/index.php @@ -43,7 +43,7 @@ } if (empty($reports)) { - error('No reports accessible', $CFG->wwwroot.'/course/view.php?id='.$course->id); // TODO: localize + print_error('No reports accessible', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); // TODO: localize } if (!isset($USER->grade_last_report)) { diff --git a/grade/report/overview/index.php b/grade/report/overview/index.php index 547c167c4355b..624a9035096d5 100644 --- a/grade/report/overview/index.php +++ b/grade/report/overview/index.php @@ -37,7 +37,7 @@ require_login($course); if (!$user = get_complete_user_data('id', $userid)) { - error("Incorrect userid"); + print_error("Incorrect userid"); } $context = get_context_instance(CONTEXT_COURSE, $course->id); diff --git a/grade/report/user/index.php b/grade/report/user/index.php index 2c019ffc57d94..64b09096b6750 100644 --- a/grade/report/user/index.php +++ b/grade/report/user/index.php @@ -44,7 +44,7 @@ } else { if (!get_complete_user_data('id', $userid)) { - error("Incorrect userid"); + print_error("Incorrect userid"); } } diff --git a/group/assign.php b/group/assign.php index 0c7211ad83bc4..fb8bf24a5a0b5 100644 --- a/group/assign.php +++ b/group/assign.php @@ -9,7 +9,7 @@ $groupingid = required_param('id', PARAM_INT); if (!$grouping = get_record('groupings', 'id', $groupingid)) { - error('Incorrect group id'); + print_error('Incorrect group id'); } if (! $course = get_record('course', 'id', $grouping->courseid)) { diff --git a/group/autogroup.php b/group/autogroup.php index add9d3561f031..642cbc2e2744f 100644 --- a/group/autogroup.php +++ b/group/autogroup.php @@ -19,7 +19,7 @@ $courseid = required_param('courseid', PARAM_INT); if (!$course = get_record('course', 'id', $courseid)) { - error('invalidcourse'); + print_error('invalidcourse'); } // Make sure that the user has permissions to manage groups. @@ -82,7 +82,7 @@ case 'idnumber': $orderby = 'idnumber'; break; default: - error('Unknown ordering'); + print_error('Unknown ordering'); } $users = groups_get_potential_members($data->courseid, $data->roleid, $orderby); $usercnt = count($users); diff --git a/group/group.php b/group/group.php index db3c508b2b640..31f13cdebb1b8 100644 --- a/group/group.php +++ b/group/group.php @@ -21,23 +21,23 @@ if ($id) { if (!$group = get_record('groups', 'id', $id)) { - error('Group ID was incorrect'); + print_error('Group ID was incorrect'); } $group->description = clean_text($group->description); if (empty($courseid)) { $courseid = $group->courseid; } else if ($courseid != $group->courseid) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } } else { if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } $group = new object(); $group->courseid = $course->id; @@ -83,11 +83,11 @@ if ($data->id) { if (!groups_update_group($data, $editform->_upload_manager)) { - error('Error updating group'); + print_error('Error updating group'); } } else { if (!$id = groups_create_group($data, $editform->_upload_manager)) { - error('Error creating group'); + print_error('Error creating group'); } $returnurl = $CFG->wwwroot.'/group/index.php?id='.$course->id.'&group='.$id; } diff --git a/group/grouping.php b/group/grouping.php index d1bde1beb2e41..a6bdb9c4f0f5f 100644 --- a/group/grouping.php +++ b/group/grouping.php @@ -20,23 +20,23 @@ if ($id) { if (!$grouping = get_record('groupings', 'id', $id)) { - error('Group ID was incorrect'); + print_error('Group ID was incorrect'); } $grouping->description = clean_text($grouping->description); if (empty($courseid)) { $courseid = $grouping->courseid; } else if ($courseid != $grouping->courseid) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } } else { if (!$course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } $grouping = new object(); $grouping->courseid = $course->id; @@ -84,12 +84,12 @@ if ($data->id) { if (!groups_update_grouping($data)) { - error('Error updating grouping'); + print_error('Error updating grouping'); } } else { if (!groups_create_grouping($data)) { - error('Error creating grouping'); + print_error('Error creating grouping'); } } diff --git a/group/index.php b/group/index.php index d70ebf2e1286a..c0ab841f31bf7 100644 --- a/group/index.php +++ b/group/index.php @@ -96,7 +96,7 @@ default: //ERROR. if (debugging()) { - error('Error, unknown button/action. Probably a user-interface bug!', $returnurl); + print_error('Error, unknown button/action. Probably a user-interface bug!', '', $returnurl); break; } } @@ -269,7 +269,7 @@ function groups_param_action($prefix = 'act_') { } if ($action && !preg_match('/^\w+$/', $action)) { $action = false; - error('Action had wrong type.'); + print_error('Action had wrong type.'); } ///if (debugging()) echo 'Debug: '.$action; return $action; diff --git a/group/members.php b/group/members.php index ecd75fb1cd36e..c3f476da371df 100644 --- a/group/members.php +++ b/group/members.php @@ -22,7 +22,7 @@ } if (!$group = get_record('groups', 'id', $groupid)) { - error('Incorrect group id'); + print_error('Incorrect group id'); } if (!$course = get_record('course', 'id', $group->courseid)) { diff --git a/group/overview.php b/group/overview.php index 737f1a405c46b..a1f3705eaafe6 100644 --- a/group/overview.php +++ b/group/overview.php @@ -18,7 +18,7 @@ $rooturl = $CFG->wwwroot.'/group/overview.php?id='.$courseid; if (!$course = get_record('course', 'id',$courseid)) { - error('invalidcourse'); + print_error('invalidcourse'); } // Make sure that the user has permissions to manage groups. diff --git a/help.php b/help.php index fb45f49f3de69..1ec4ab06ccc2a 100644 --- a/help.php +++ b/help.php @@ -144,7 +144,7 @@ function include_help_for_each_module($file, $langs, $helpdir) { global $CFG; if (!$modules = get_records('modules', 'visible', 1)) { - error('No modules found!!'); // Should never happen + print_error('No modules found!!'); // Should never happen } $grade = new stdClass(); diff --git a/index.php b/index.php index cc022d3b088d0..81ff29c4191af 100644 --- a/index.php +++ b/index.php @@ -192,7 +192,7 @@ require_once($CFG->dirroot .'/mod/forum/lib.php'); if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) { - error('Could not find or create a main news forum for the site'); + print_error('Could not find or create a main news forum for the site'); } if (!empty($USER->id)) { diff --git a/iplookup/index.php b/iplookup/index.php index 7e75bd80df342..f174dbdbe4b80 100644 --- a/iplookup/index.php +++ b/iplookup/index.php @@ -85,7 +85,7 @@ } else { $ipdata = download_file_content('http://netgeo.caida.org/perl/netgeo.cgi?target='.$ip); if ($ipdata === false) { - error('Can not connect to NetGeo server at http://netgeo.caida.org, please check proxy settings or better install MaxMind GeoLite City data file.'); + print_error('Can not connect to NetGeo server at http://netgeo.caida.org, please check proxy settings or better install MaxMind GeoLite City data file.'); } $matches = null; if (!preg_match('/LAT:\s*(-?\d+\.\d+)/s', $ipdata, $matches)) { diff --git a/lib/accesslib.php b/lib/accesslib.php index 60537a97a7bf2..a2d490ff5f0e2 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -852,10 +852,10 @@ function require_capability($capability, $context, $userid=NULL, $doanything=tru } else if ($context->contextlevel == CONTEXT_MODULE) { if (!$cm = get_record('course_modules', 'id', $context->instanceid)) { - error('Incorrect module'); + print_error('Incorrect module'); } if (!$course = get_record('course', 'id', $cm->course)) { - error('Incorrect course.'); + print_error('Incorrect course.'); } require_course_login($course, true, $cm); $errorlink = $CFG->wwwroot.'/course/view.php?id='.$cm->course; @@ -1885,10 +1885,10 @@ function moodle_install_roles() { /// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles if (!assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $systemcontext->id)) { - error('Could not assign moodle/site:doanything to the admin role'); + print_error('Could not assign moodle/site:doanything to the admin role'); } if (!update_capabilities()) { - error('Had trouble upgrading the core capabilities for the Roles System'); + print_error('Had trouble upgrading the core capabilities for the Roles System'); } /// Look inside user_admin, user_creator, user_teachers, user_students and @@ -2101,7 +2101,7 @@ function assign_legacy_capabilities($capability, $legacyperms) { $systemcontext = get_context_instance(CONTEXT_SYSTEM); if (!array_key_exists($type, $legacyroles)) { - error('Incorrect legacy role definition for type: '.$type); + print_error('Incorrect legacy role definition for type: '.$type); } if ($roles = get_roles_with_capability($legacyroles[$type], CAP_ALLOW)) { @@ -2558,7 +2558,7 @@ function get_context_instance($contextlevel, $instance=0) { /// check allowed context levels if (!in_array($contextlevel, $allowed_contexts)) { // fatal error, code must be fixed - probably typo or switched parameters - error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"'); + print_error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"'); } if (!is_array($instance)) { @@ -2686,11 +2686,11 @@ function create_role($name, $shortname, $description, $legacy='') { // check for duplicate role name if ($role = get_record('role','name', $name)) { - error('there is already a role with this name!'); + print_error('there is already a role with this name!'); } if ($role = get_record('role','shortname', $shortname)) { - error('there is already a role with this shortname!'); + print_error('there is already a role with this shortname!'); } $role = new object(); @@ -3249,7 +3249,7 @@ function get_cached_capabilities($component='moodle') { */ function get_default_capabilities($legacyrole) { if (!$allcaps = get_records('capabilities')) { - error('Error: no capabilitites defined!'); + print_error('Error: no capabilitites defined!'); } $alldefs = array(); $defaults = array(); @@ -3425,7 +3425,7 @@ function capabilities_cleanup($component, $newcapdef=NULL) { // Remove from capabilities cache. if (!delete_records('capabilities', 'name', $cachedcap->name)) { - error('Could not delete deprecated capability '.$cachedcap->name); + print_error('Could not delete deprecated capability '.$cachedcap->name); } else { $removedcount++; } @@ -3433,7 +3433,7 @@ function capabilities_cleanup($component, $newcapdef=NULL) { if($roles = get_roles_with_capability($cachedcap->name)) { foreach($roles as $role) { if (!unassign_capability($cachedcap->name, $role->id)) { - error('Could not unassign deprecated capability '. + print_error('Could not unassign deprecated capability '. $cachedcap->name.' from role '.$role->name); } } @@ -3837,7 +3837,7 @@ function get_child_contexts($context) { break; default: - error('This is an unknown context (' . $context->contextlevel . ') in get_child_contexts!'); + print_error('This is an unknown context (' . $context->contextlevel . ') in get_child_contexts!'); return false; } } diff --git a/lib/adminlib.php b/lib/adminlib.php index 857873b107648..f28f9da5c4054 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -15,7 +15,7 @@ function upgrade_main_savepoint($result, $version) { if ($result) { if ($CFG->version >= $version) { // something really wrong is going on in main upgrade script - error("Upgrade savepoint: Can not upgrade main version from $CFG->version to $version."); + print_error("Upgrade savepoint: Can not upgrade main version from $CFG->version to $version."); } set_config('version', $version); } else { @@ -149,7 +149,7 @@ function upgrade_plugins($type, $dir, $return) { /// Install capabilities if (!update_capabilities($type.'/'.$plug)) { - error('Could not set up the capabilities for '.$plugin->name.'!'); + print_error('Could not set up the capabilities for '.$plugin->name.'!'); } /// Install events events_update_definition($type.'/'.$plug); @@ -205,7 +205,7 @@ function upgrade_plugins($type, $dir, $return) { // OK so far, now update the plugins record set_config($pluginversion, $plugin->version); if (!update_capabilities($type.'/'.$plug)) { - error('Could not update '.$plugin->name.' capabilities!'); + print_error('Could not update '.$plugin->name.' capabilities!'); } events_update_definition($type.'/'.$plug); notify(get_string('modulesuccess', '', $plugin->name), 'notifysuccess'); @@ -218,7 +218,7 @@ function upgrade_plugins($type, $dir, $return) { } } else { upgrade_log_start(); - error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !'); + print_error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !'); } } @@ -253,7 +253,7 @@ function upgrade_activity_modules($return) { global $CFG, $db, $interactive; if (!$mods = get_list_of_plugins('mod') ) { - error('No modules installed!'); + print_error('No modules installed!'); } $updated_modules = false; @@ -372,7 +372,7 @@ function upgrade_activity_modules($return) { // OK so far, now update the modules record $module->id = $currmodule->id; if (! update_record('modules', $module)) { - error('Could not update '. $module->name .' record in modules table!'); + print_error('Could not update '. $module->name .' record in modules table!'); } remove_dir($CFG->dataroot . '/cache', true); // flush cache notify(get_string('modulesuccess', '', $module->name), 'notifysuccess'); @@ -385,7 +385,7 @@ function upgrade_activity_modules($return) { /// Update the capabilities table? if (!update_capabilities('mod/'.$module->name)) { - error('Could not update '.$module->name.' capabilities!'); + print_error('Could not update '.$module->name.' capabilities!'); } events_update_definition('mod/'.$module->name); @@ -393,7 +393,7 @@ function upgrade_activity_modules($return) { } else { upgrade_log_start(); - error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !'); + print_error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !'); } } else { // module not installed yet, so install it @@ -431,7 +431,7 @@ function upgrade_activity_modules($return) { /// Capabilities if (!update_capabilities('mod/'.$module->name)) { - error('Could not set up the capabilities for '.$module->name.'!'); + print_error('Could not set up the capabilities for '.$module->name.'!'); } /// Events @@ -450,10 +450,10 @@ function upgrade_activity_modules($return) { echo '
'; } } else { - error($module->name .' module could not be added to the module list!'); + print_error($module->name .' module could not be added to the module list!'); } } else { - error($module->name .' tables could NOT be set up successfully!'); + print_error($module->name .' tables could NOT be set up successfully!'); } } @@ -611,16 +611,16 @@ function create_admin_user($user_input=NULL) { $user = $user_input; } if (!$user->id = insert_record('user', $user)) { - error('SERIOUS ERROR: Could not create admin user record !!!'); + print_error('SERIOUS ERROR: Could not create admin user record !!!'); } if (!$user = get_record('user', 'id', $user->id)) { // Double check. - error('User ID was incorrect (can\'t find it)'); + print_error('User ID was incorrect (can\'t find it)'); } // Assign the default admin roles to the new user. if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) { - error('No admin role could be found'); + print_error('No admin role could be found'); } $sitecontext = get_context_instance(CONTEXT_SYSTEM); foreach ($adminroles as $adminrole) { @@ -638,7 +638,7 @@ function create_admin_user($user_input=NULL) { redirect("$CFG->wwwroot/user/editadvanced.php?id=$user->id"); // Edit thyself } } else { - error('Can not create admin!'); + print_error('Can not create admin!'); } } @@ -695,10 +695,10 @@ function upgrade_log_start() { /** * Terminate logging of output, flush all data, allow script aborting - * and reopen session for writing. Function error() does terminate the logging too. + * and reopen session for writing. Function print_error() does terminate the logging too. * * Please make sure that each upgrade_log_start() is properly terminated by - * this function or error(). + * this function or print_error(). * * This function may be called repeatedly. */ @@ -3951,13 +3951,13 @@ function admin_externalpage_setup($section) { $extpage =& $adminroot->locate($section); if (empty($extpage) or !is_a($extpage, 'admin_externalpage')) { - error(get_string('sectionerror','admin'), "$CFG->wwwroot/$CFG->admin/"); + print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/"); die; } // this eliminates our need to authenticate on the actual pages if (!($extpage->check_access())) { - error(get_string('accessdenied', 'admin')); + print_error('accessdenied', 'admin'); die; } @@ -4025,7 +4025,7 @@ function admin_externalpage_print_header($focus='') { case 'middle': echo ''; print_container_start(true); - $THEME->open_header_containers++; // this is hacky workaround for the error()/notice() autoclosing problems on admin pages + $THEME->open_header_containers++; // this is hacky workaround for the print_error()/notice() autoclosing problems on admin pages break; case 'right': @@ -4082,7 +4082,7 @@ function admin_externalpage_print_footer() { case 'middle': print_container_end(); - $THEME->open_header_containers--; // this is hacky workaround for the error()/notice() autoclosing problems on admin pages + $THEME->open_header_containers--; // this is hacky workaround for the print_error()/notice() autoclosing problems on admin pages echo ''; break; diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index ec953df4f13df..787e5a735b230 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -43,7 +43,7 @@ function ajax_get_lib($libname) { $testpath = str_replace($CFG->wwwroot, $CFG->dirroot, $libpath); if (!file_exists($testpath)) { - error('require_js: '.$libpath.' - file not found.'); + print_error('require_js: '.$libpath.' - file not found.'); } return $libpath; diff --git a/lib/authlib.php b/lib/authlib.php index 835e6afd68e70..a60a661378d30 100644 --- a/lib/authlib.php +++ b/lib/authlib.php @@ -73,7 +73,7 @@ class auth_plugin_base { * @return bool Authentication success or failure. */ function user_login($username, $password) { - error('Abstract user_login() method must be overriden.'); + print_error('Abstract user_login() method must be overriden.'); } /** @@ -180,7 +180,7 @@ function can_signup() { */ function user_signup($user, $notify=true) { //override when can signup - error('user_signup method must be overriden if signup enabled'); + print_error('user_signup method must be overriden if signup enabled'); } /** @@ -201,7 +201,7 @@ function can_confirm() { */ function user_confirm($username, $confirmsecret) { //override when can confirm - error('user_confirm method must be overriden if confirm enabled'); + print_error('user_confirm method must be overriden if confirm enabled'); } /** diff --git a/lib/blocklib.php b/lib/blocklib.php index 5a2d9c9dca1be..92bc24e80e83f 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -512,7 +512,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, unset($data->$item); } if(!$blockobject->instance_config_save($data,$pinned)) { - error('Error saving block configuration'); + print_error('Error saving block configuration'); } // And nothing more, continue with displaying the page } @@ -541,7 +541,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, break; case 'toggle': if(empty($instance)) { - error('Invalid block instance for '.$blockaction); + print_error('Invalid block instance for '.$blockaction); } $instance->visible = ($instance->visible) ? 0 : 1; if (!empty($pinned)) { @@ -552,13 +552,13 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, break; case 'delete': if(empty($instance)) { - error('Invalid block instance for '. $blockaction); + print_error('Invalid block instance for '. $blockaction); } blocks_delete_instance($instance, $pinned); break; case 'moveup': if(empty($instance)) { - error('Invalid block instance for '. $blockaction); + print_error('Invalid block instance for '. $blockaction); } if($instance->weight == 0) { @@ -595,7 +595,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, break; case 'movedown': if(empty($instance)) { - error('Invalid block instance for '. $blockaction); + print_error('Invalid block instance for '. $blockaction); } if($instance->weight == max(array_keys($pageblocks[$instance->position]))) { @@ -632,7 +632,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, break; case 'moveleft': if(empty($instance)) { - error('Invalid block instance for '. $blockaction); + print_error('Invalid block instance for '. $blockaction); } // Where is the instance going to be moved? @@ -643,7 +643,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid, break; case 'moveright': if(empty($instance)) { - error('Invalid block instance for '. $blockaction); + print_error('Invalid block instance for '. $blockaction); } // Where is the instance going to be moved? @@ -976,7 +976,7 @@ function blocks_repopulate_page($page) { $allblocks = blocks_get_record(); if(empty($allblocks)) { - error('Could not retrieve blocks from the database'); + print_error('Could not retrieve blocks from the database'); } // Assemble the information to correlate block names to ids @@ -1036,22 +1036,22 @@ function upgrade_blocks_db($continueto) { /// This function upgrades the blocks tables, if necessary /// It's called from admin/index.php - global $CFG, $db, $interactive; + global $CFG, $db, $interactive; require_once ($CFG->dirroot .'/blocks/version.php'); // Get code versions if (empty($CFG->blocks_version)) { // Blocks have never been installed. $strdatabaseupgrades = get_string('databaseupgrades'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); - } + } upgrade_log_start(); print_heading('blocks'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug=true; - } + } /// Both old .sql files and new install.xml are supported /// but we priorize install.xml (XMLDB) if present $status = false; @@ -1060,30 +1060,30 @@ function upgrade_blocks_db($continueto) { } else if (file_exists($CFG->dirroot . '/blocks/db/' . $CFG->dbtype . '.sql')) { $status = modify_database($CFG->dirroot . '/blocks/db/' . $CFG->dbtype . '.sql'); //Old method } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug = false; - } + } if ($status) { if (set_config('blocks_version', $blocks_version)) { notify(get_string('databasesuccess'), 'notifysuccess'); notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { print_continue($continueto); print_footer('none'); exit; - } else if (CLI_UPGRADE && ($interactive > CLI_SEMI) ) { - console_write(STDOUT,'askcontinue'); - if (read_boolean()){ - return ; - }else { - console_write(STDERR,'','',false); - } - } + } else if (CLI_UPGRADE && ($interactive > CLI_SEMI) ) { + console_write(STDOUT,'askcontinue'); + if (read_boolean()){ + return ; + }else { + console_write(STDERR,'','',false); + } + } } else { - error('Upgrade of blocks system failed! (Could not update version in config table)'); + print_error('Upgrade of blocks system failed! (Could not update version in config table)'); } } else { - error('Blocks tables could NOT be set up successfully!'); + print_error('Blocks tables could NOT be set up successfully!'); } } @@ -1101,12 +1101,12 @@ function upgrade_blocks_db($continueto) { if ($blocks_version > $CFG->blocks_version) { // Upgrade tables $strdatabaseupgrades = get_string('databaseupgrades'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript()); - } + } upgrade_log_start(); - + print_heading('blocks'); /// Run de old and new upgrade functions for the module @@ -1116,9 +1116,9 @@ function upgrade_blocks_db($continueto) { /// First, the old function if exists $oldupgrade_status = true; if ($oldupgrade && function_exists($oldupgrade_function)) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug = true; - } + } $oldupgrade_status = $oldupgrade_function($CFG->blocks_version); } else if ($oldupgrade) { notify ('Upgrade function ' . $oldupgrade_function . ' was not available in ' . @@ -1128,32 +1128,32 @@ function upgrade_blocks_db($continueto) { /// Then, the new function if exists and the old one was ok $newupgrade_status = true; if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug = true; - } + } $newupgrade_status = $newupgrade_function($CFG->blocks_version); } else if ($newupgrade) { notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' . '/blocks/db/upgrade.php'); } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug=false; - } + } /// Now analyze upgrade results if ($oldupgrade_status && $newupgrade_status) { // No upgrading failed if (set_config('blocks_version', $blocks_version)) { notify(get_string('databasesuccess'), 'notifysuccess'); notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { print_continue($continueto); print_footer('none'); exit; - } + } } else { - error('Upgrade of blocks system failed! (Could not update version in config table)'); + print_error('Upgrade of blocks system failed! (Could not update version in config table)'); } } else { - error('Upgrade failed! See blocks/version.php'); + print_error('Upgrade failed! See blocks/version.php'); } } else if ($blocks_version < $CFG->blocks_version) { @@ -1167,7 +1167,7 @@ function upgrade_blocks_db($continueto) { //into blocks table or do all the upgrade process if newer function upgrade_blocks_plugins($continueto) { - global $CFG, $db, $interactive; + global $CFG, $db, $interactive; $blocktitles = array(); $invalidblocks = array(); @@ -1186,12 +1186,12 @@ function upgrade_blocks_plugins($continueto) { $site = get_site(); if (!$blocks = get_list_of_plugins('blocks', 'db') ) { - error('No blocks installed!'); + print_error('No blocks installed!'); } include_once($CFG->dirroot .'/blocks/moodleblock.class.php'); if(!class_exists('block_base')) { - error('Class block_base is not defined or file not found for /blocks/moodleblock.class.php'); + print_error('Class block_base is not defined or file not found for /blocks/moodleblock.class.php'); } foreach ($blocks as $blockname) { @@ -1276,7 +1276,7 @@ function upgrade_blocks_plugins($continueto) { } else if ($currblock->version < $block->version) { if (empty($updated_blocks)) { $strblocksetup = get_string('blocksetup'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); @@ -1284,7 +1284,7 @@ function upgrade_blocks_plugins($continueto) { } $updated_blocks = true; upgrade_log_start(); - + print_heading('New version of '.$blocktitle.' ('.$block->name.') exists'); @set_time_limit(0); // To allow slow databases to complete the long SQL @@ -1295,9 +1295,9 @@ function upgrade_blocks_plugins($continueto) { /// First, the old function if exists $oldupgrade_status = true; if ($oldupgrade && function_exists($oldupgrade_function)) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug = true; - } + } $oldupgrade_status = $oldupgrade_function($currblock->version, $block); } else if ($oldupgrade) { notify ('Upgrade function ' . $oldupgrade_function . ' was not available in ' . @@ -1307,17 +1307,17 @@ function upgrade_blocks_plugins($continueto) { /// Then, the new function if exists and the old one was ok $newupgrade_status = true; if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug = true; - } + } $newupgrade_status = $newupgrade_function($currblock->version, $block); } else if ($newupgrade) { notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' . $fullblock . '/db/upgrade.php'); } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug=false; - } + } /// Now analyze upgrade results if ($oldupgrade_status && $newupgrade_status) { // No upgrading failed @@ -1327,11 +1327,11 @@ function upgrade_blocks_plugins($continueto) { // OK so far, now update the block record $block->id = $currblock->id; if (! update_record('block', $block)) { - error('Could not update block '. $block->name .' record in block table!'); + print_error('Could not update block '. $block->name .' record in block table!'); } $component = 'block/'.$block->name; if (!update_capabilities($component)) { - error('Could not update '.$block->name.' capabilities!'); + print_error('Could not update '.$block->name.' capabilities!'); } events_update_definition($component); @@ -1339,12 +1339,12 @@ function upgrade_blocks_plugins($continueto) { } else { notify('Upgrading block '. $block->name .' from '. $currblock->version .' to '. $block->version .' FAILED!'); } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { echo '
'; - } + } } else { upgrade_log_start(); - error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!'); + print_error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!'); } } else { // block not installed yet, so install it @@ -1363,26 +1363,26 @@ function upgrade_blocks_plugins($continueto) { if($conflictblock !== false && $conflictblock !== NULL) { // Duplicate block titles are not allowed, they confuse people // AND PHP's associative arrays ;) - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - error('Naming conflict: block '.$block->name.' has the same title with an existing block, '.$conflictblock.'!'); - } else if (CLI_UPGRADE) { - error('Naming conflict: block "'.$block->name.'" has the same title with an existing block, "'.$conflictblock.'"!'); - } + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + print_error('Naming conflict: block '.$block->name.' has the same title with an existing block, '.$conflictblock.'!'); + } else if (CLI_UPGRADE) { + print_error('Naming conflict: block "'.$block->name.'" has the same title with an existing block, "'.$conflictblock.'"!'); + } } if (empty($updated_blocks)) { $strblocksetup = get_string('blocksetup'); - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) { print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); } - } + } $updated_blocks = true; upgrade_log_start(); print_heading($block->name); - if (!defined('CLI_UPGRADE')||!CLI_UPGRADE) { + if (!defined('CLI_UPGRADE')||!CLI_UPGRADE) { $db->debug = true; - } + } @set_time_limit(0); // To allow slow databases to complete the long SQL /// Both old .sql files and new install.xml are supported @@ -1395,9 +1395,9 @@ function upgrade_blocks_plugins($continueto) { } else { $status = true; } - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug = false; - } + } if ($status) { if ($block->id = insert_record('block', $block)) { $blockobj->after_install(); @@ -1408,14 +1408,14 @@ function upgrade_blocks_plugins($continueto) { events_update_definition($component); notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess'); - if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE) { + if (!defined('CLI_UPGRADE')|| !CLI_UPGRADE) { echo '
'; - } + } } else { - error($block->name .' block could not be added to the block list!'); + print_error($block->name .' block could not be added to the block list!'); } } else { - error('Block '. $block->name .' tables could NOT be set up successfully!'); + print_error('Block '. $block->name .' tables could NOT be set up successfully!'); } } @@ -1452,18 +1452,18 @@ function upgrade_blocks_plugins($continueto) { upgrade_log_finish(); if (!empty($updated_blocks)) { - if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) { + if (!defined('CLI_UPGRADE') || !CLI_UPGRADE) { print_continue($continueto); print_footer('none'); die; - } else if ( CLI_UPGRADE && ($interactive > CLI_SEMI) ) { - console_write(STDOUT,'askcontinue'); - if (read_boolean()){ - return ; - }else { - console_write(STDERR,'','',false); - } - } + } else if ( CLI_UPGRADE && ($interactive > CLI_SEMI) ) { + console_write(STDOUT,'askcontinue'); + if (read_boolean()){ + return ; + }else { + console_write(STDERR,'','',false); + } + } } } diff --git a/lib/csvlib.class.php b/lib/csvlib.class.php index 662ceef41f113..bb6f701cf1c45 100644 --- a/lib/csvlib.class.php +++ b/lib/csvlib.class.php @@ -253,7 +253,7 @@ function get_new_iid($type) { global $USER; if (!$filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id, false)) { - error('Can not create temporary upload directory - verify moodledata permissions!'); + print_error('Can not create temporary upload directory - verify moodledata permissions!'); } // use current (non-conflicting) time stamp diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 2f49ef88df069..0d25719fc727f 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -49,10 +49,10 @@ function require_variable($var) { global $CFG; if (!empty($CFG->disableglobalshack)) { - error( 'The require_variable() function is deprecated.' ); + print_error( 'The require_variable() function is deprecated.' ); } if (! isset($var)) { - error('A required parameter was missing'); + print_error('A required parameter was missing'); } } @@ -67,7 +67,7 @@ function require_variable($var) { function optional_variable(&$var, $default=0) { global $CFG; if (!empty($CFG->disableglobalshack)) { - error( "The optional_variable() function is deprecated ($var, $default)." ); + print_error( "The optional_variable() function is deprecated ($var, $default)." ); } if (! isset($var)) { $var = $default; @@ -88,7 +88,7 @@ function nvl(&$var, $default='') { global $CFG; if (!empty($CFG->disableglobalshack)) { - error( "The nvl() function is deprecated ($var, $default)." ); + print_error( "The nvl() function is deprecated ($var, $default)." ); } return isset($var) ? $var : $default; } diff --git a/lib/dmllib.php b/lib/dmllib.php index c6ab9a7b4d1f7..9c24aa1a0cf42 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -673,7 +673,7 @@ function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) { strpos($sql, ' '.$CFG->prefix.'user_coursecreators ') || strpos($sql, ' '.$CFG->prefix.'user_admins ')) { if (debugging()) { var_dump(debug_backtrace()); } - error('This SQL relies on obsolete tables! Your code must be fixed by a developer.'); + print_error('This SQL relies on obsolete tables! Your code must be fixed by a developer.'); } } @@ -1459,7 +1459,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') { if (!empty($CFG->rolesactive)) { if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) { if (debugging()) { var_dump(debug_backtrace()); } - error('This SQL relies on obsolete tables ('.$table.')! Your code must be fixed by a developer.'); + print_error('This SQL relies on obsolete tables ('.$table.')! Your code must be fixed by a developer.'); } } @@ -1652,7 +1652,7 @@ function update_record($table, $dataobject) { if (!empty($CFG->rolesactive)) { if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) { if (debugging()) { var_dump(debug_backtrace()); } - error('This SQL relies on obsolete tables ('.$table.')! Your code must be fixed by a developer.'); + print_error('This SQL relies on obsolete tables ('.$table.')! Your code must be fixed by a developer.'); } } diff --git a/lib/editor/htmlarea/coursefiles.php b/lib/editor/htmlarea/coursefiles.php index 6f2206f4394dc..7a47f62f3ed8f 100644 --- a/lib/editor/htmlarea/coursefiles.php +++ b/lib/editor/htmlarea/coursefiles.php @@ -27,7 +27,7 @@ if (! $course = get_record("course", "id", $id) ) { - error("That's an invalid course id"); + print_error("That's an invalid course id"); } require_login($course); @@ -184,7 +184,7 @@ function reset_value() { } if (! $basedir = make_upload_directory("$course->id")) { - error("The site administrator needs to fix the file permissions"); + print_error("The site administrator needs to fix the file permissions"); } $baseweb = $CFG->wwwroot; @@ -439,7 +439,7 @@ function reset_value() { } if (!zip_files($files,"$basedir/$wdir/$name")) { - error(get_string("zipfileserror","error")); + print_error("zipfileserror","error"); } clearfilelist(); @@ -491,7 +491,7 @@ function reset_value() { $file = basename($file); if (!unzip_file("$basedir/$wdir/$file")) { - error(get_string("unzipfileserror","error")); + print_error("unzipfileserror","error"); } echo "
\n"; diff --git a/lib/editorlib.php b/lib/editorlib.php index 439792b6a48b9..c65366c09cdc7 100644 --- a/lib/editorlib.php +++ b/lib/editorlib.php @@ -66,11 +66,11 @@ function loadeditor($args) { // If args is an array search keys courseid and name. // Name represents editor name to load. if ( !array_key_exists('courseid', $args) ) { - error("Required variable courseid is missing!"); + print_error("Required variable courseid is missing!"); } if ( !array_key_exists('name', $args) ) { - error("Required variable name is missing!"); + print_error("Required variable name is missing!"); } $courseid = clean_param($args['courseid'], PARAM_INT); @@ -125,4 +125,4 @@ function error($message) { } } -?> \ No newline at end of file +?> diff --git a/lib/filelib.php b/lib/filelib.php index 6de33baf23542..c4e5d5268f30d 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -699,7 +699,7 @@ function get_records_csv($file, $table) { } if(!($handle = @fopen($file, 'r'))) { - error('get_records_csv failed to open '.$file); + print_error('get_records_csv failed to open '.$file); } $fieldnames = fgetcsv($handle, 4096); @@ -746,7 +746,7 @@ function put_records_csv($file, $records, $table = NULL) { echo "x"; if(!($fp = @fopen($CFG->dataroot.'/temp/'.$file, 'w'))) { - error('put_records_csv failed to open '.$file); + print_error('put_records_csv failed to open '.$file); } $proto = reset($records); diff --git a/lib/form/editorhelp.php b/lib/form/editorhelp.php index 794e14f5259b7..6b031fc69ed64 100644 --- a/lib/form/editorhelp.php +++ b/lib/form/editorhelp.php @@ -25,7 +25,7 @@ $topics[$i] = helplink('text', get_string('helptext')); break; default : - error('Unknown help topic '.$item); + print_error('Unknown help topic '.$item); } } else { $keyword = optional_param("keyword$i", '', PARAM_ALPHAEXT); diff --git a/lib/formslib.php b/lib/formslib.php index e2f3e7dea04c2..b4f81700f689a 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -182,7 +182,7 @@ function _process_submission($method) { // the _qf__.$this->_formname serves as a marker that form was actually submitted if (array_key_exists('_qf__'.$this->_formname, $submission) and $submission['_qf__'.$this->_formname] == 1) { if (!confirm_sesskey()) { - error('Incorrect sesskey submitted, form not accepted!'); + print_error('Incorrect sesskey submitted, form not accepted!'); } $files = $_FILES; } else { @@ -225,7 +225,7 @@ function _validate_files(&$files) { $files[$elname] = $this->_upload_manager->files[$elname]['tmp_name']; } } else { - error('Incorrect upload attempt!'); + print_error('Incorrect upload attempt!'); } } @@ -489,7 +489,7 @@ function display() { * If you need special handling of uploaded files, create instance of $this->_upload_manager here. */ function definition() { - error('Abstract form_definition() method in class '.get_class($this).' must be overriden, please fix the code.'); + print_error('Abstract form_definition() method in class '.get_class($this).' must be overriden, please fix the code.'); } /** diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php index d678c1a9da733..b5fc1880408f6 100644 --- a/lib/grade/grade_category.php +++ b/lib/grade/grade_category.php @@ -298,7 +298,7 @@ function delete($source=null) { function insert($source=null) { if (empty($this->courseid)) { - error('Can not insert grade category without course id!'); + print_error('Can not insert grade category without course id!'); } if (empty($this->parent)) { @@ -1046,11 +1046,11 @@ function set_parent($parentid, $source=null) { } if ($parentid == $this->id) { - error('Can not assign self as parent!'); + print_error('Can not assign self as parent!'); } if (empty($this->parent) and $this->is_course_category()) { - error('Course category can not have parent!'); + print_error('Course category can not have parent!'); } // find parent and check course id diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php index f23fd2432059a..694d2923a6cab 100644 --- a/lib/grade/grade_grade.php +++ b/lib/grade/grade_grade.php @@ -560,7 +560,7 @@ function get_hiding_affected(&$grade_grades, &$grade_items) { global $CFG; if (count($grade_grades) !== count($grade_items)) { - error('Incorrect size of arrays in params of grade_grade::get_hiding_affected()!'); + print_error('Incorrect size of arrays in params of grade_grade::get_hiding_affected()!'); } $dependson = array(); diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index 3db1376de888d..69b0957c0019c 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -370,7 +370,7 @@ function insert($source=null) { global $CFG; if (empty($this->courseid)) { - error('Can not insert grade item without course id!'); + print_error('Can not insert grade item without course id!'); } // load scale if needed @@ -1188,7 +1188,7 @@ function get_name() { */ function set_parent($parentid) { if ($this->is_course_item() or $this->is_category_item()) { - error('Can not set parent for category or course item!'); + print_error('Can not set parent for category or course item!'); } if ($this->categoryid == $parentid) { diff --git a/lib/grade/grade_object.php b/lib/grade/grade_object.php index b730ee81afe54..c96a972354083 100644 --- a/lib/grade/grade_object.php +++ b/lib/grade/grade_object.php @@ -110,7 +110,7 @@ function load_optional_fields() { * @return object grade_object instance or false if none found. */ function fetch($params) { - error('Abstract method fetch() not overridden in '.get_class($this)); + print_error('Abstract method fetch() not overridden in '.get_class($this)); } /** @@ -121,7 +121,7 @@ function fetch($params) { * @return array array of grade_object insatnces or false if none found. */ function fetch_all($params) { - error('Abstract method fetch_all() not overridden in '.get_class($this)); + print_error('Abstract method fetch_all() not overridden in '.get_class($this)); } /** @@ -133,7 +133,7 @@ function fetch_helper($table, $classname, $params) { if ($instances = grade_object::fetch_all_helper($table, $classname, $params)) { if (count($instances) > 1) { // we should not tolerate any errors here - problems might appear later - error('Found more than one record in fetch() !'); + print_error('Found more than one record in fetch() !'); } return reset($instances); } else { diff --git a/lib/gradelib.php b/lib/gradelib.php index 5bc322f6e2170..3987cd6b3a77d 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -840,7 +840,7 @@ function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null) if ($userid) { // one raw grade updated for one user if (empty($updated_item)) { - error("updated_item_id can not be null!"); + print_error("updated_item_id can not be null!"); } if ($course_item->needsupdate) { $updated_item->force_regrading(); @@ -951,7 +951,7 @@ function grade_grab_legacy_grades($courseid) { global $CFG; if (!$mods = get_list_of_plugins('mod') ) { - error('No modules installed!'); + print_error('No modules installed!'); } foreach ($mods as $mod) { @@ -997,7 +997,7 @@ function grade_grab_course_grades($courseid, $modname=null) { } if (!$mods = get_list_of_plugins('mod') ) { - error('No modules installed!'); + print_error('No modules installed!'); } foreach ($mods as $mod) { diff --git a/lib/grouplib.php b/lib/grouplib.php index 99773ff187cdf..136ed2035cae6 100644 --- a/lib/grouplib.php +++ b/lib/grouplib.php @@ -319,7 +319,7 @@ function groups_get_activity_groupmode($cm, $course=null) { $course = $COURSE; } else { if (!$course = get_record('course', 'id', $cm->course)) { - error('Incorrect course id in cm'); + print_error('Incorrect course id in cm'); } } diff --git a/lib/locallib.php b/lib/locallib.php index f300072a9b12f..d67abb39928d6 100644 --- a/lib/locallib.php +++ b/lib/locallib.php @@ -163,13 +163,13 @@ function upgrade_local_db($continueto) { } } } else { - error('Upgrade of local database customisations failed! (Could not update version in config table)'); + print_error('Upgrade of local database customisations failed! (Could not update version in config table)'); } } else { if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { $db->debug=false; } - error('Upgrade failed! See local/version.php'); + print_error('Upgrade failed! See local/version.php'); } } else if ($local_version < $CFG->local_version) { diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f4857630a5027..fdb4c7c3363d5 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -298,7 +298,7 @@ function required_param($parname, $type=PARAM_CLEAN) { } else if (isset($_GET[$parname])) { $param = $_GET[$parname]; } else { - error('A required parameter ('.$parname.') was missing'); + print_error('A required parameter ('.$parname.') was missing'); } return clean_param($param, $type); @@ -588,7 +588,7 @@ function clean_param($param, $type) { } default: // throw error, switched parameters in optional_param or another serious problem - error("Unknown parameter type: $type"); + print_error("Unknown parameter type: $type"); } } @@ -1800,7 +1800,7 @@ function course_setup($courseorid=0) { $COURSE = clone($course); } else { if (!$COURSE = get_record('course', 'id', $courseorid)) { - error('Invalid course ID'); + print_error('Invalid course ID'); } } } @@ -2139,7 +2139,7 @@ function require_user_key_login($script, $instance=null) { global $nomoodlecookie, $USER, $SESSION, $CFG; if (empty($nomoodlecookie)) { - error('Incorrect use of require_key_login() - session cookies must be disabled!'); + print_error('Incorrect use of require_key_login() - session cookies must be disabled!'); } /// extra safety @@ -2148,22 +2148,22 @@ function require_user_key_login($script, $instance=null) { $keyvalue = required_param('key', PARAM_ALPHANUM); if (!$key = get_record('user_private_key', 'script', $script, 'value', $keyvalue, 'instance', $instance)) { - error('Incorrect key'); + print_error('Incorrect key'); } if (!empty($key->validuntil) and $key->validuntil < time()) { - error('Expired key'); + print_error('Expired key'); } if ($key->iprestriction) { $remoteaddr = getremoteaddr(); if ($remoteaddr == '' or !address_in_subnet($remoteaddr, $key->iprestriction)) { - error('Client IP address mismatch'); + print_error('Client IP address mismatch'); } } if (!$user = get_record('user', 'id', $key->userid)) { - error('Incorrect user record'); + print_error('Incorrect user record'); } /// emulate normal session @@ -2206,7 +2206,7 @@ function create_user_key($script, $userid, $instance=null, $iprestriction=null, } if (!insert_record('user_private_key', $key)) { - error('Can not insert new key'); + print_error('Can not insert new key'); } return $key->value; @@ -2707,7 +2707,7 @@ function get_auth_plugin($auth) { // check the plugin exists first if (! exists_auth_plugin($auth)) { - error("Authentication plugin '$auth' not found."); + print_error("Authentication plugin '$auth' not found."); } // return auth plugin instance @@ -3466,7 +3466,7 @@ function remove_course_contents($courseid, $showfeedback=true) { $result = true; if (! $course = get_record('course', 'id', $courseid)) { - error('Course ID was incorrect (can\'t find it)'); + print_error('Course ID was incorrect (can\'t find it)'); } $strdeleted = get_string('deleted'); @@ -3517,7 +3517,7 @@ function remove_course_contents($courseid, $showfeedback=true) { } } } else { - error('No modules are installed!'); + print_error('No modules are installed!'); } /// Give local code a chance to delete its references to this course. @@ -4263,7 +4263,7 @@ function reset_password_and_mail($user) { $newpassword = generate_password(); if (!$userauth->user_update_password(addslashes_recursive($user), addslashes($newpassword))) { - error("Could not set user password!"); + print_error("Could not set user password!"); } $a = new object(); diff --git a/lib/pagelib.php b/lib/pagelib.php index c6053d3ef8b7e..2b10047aa5a49 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -32,7 +32,7 @@ function page_import_types($path) { if(is_file($file)) { require($file); if(!isset($DEFINEDPAGES)) { - error('Imported '.$file.' but found no page classes'); + print_error('Imported '.$file.' but found no page classes'); } return $types[$path] = $DEFINEDPAGES; } @@ -314,7 +314,7 @@ class page_course extends page_base { // Do NOT load up "expensive" resouces (e.g. SQL data) here! function init_quick($data) { if(empty($data->pageid) && !defined('ADMIN_STICKYBLOCKS')) { - error('Cannot quickly initialize page: empty course id'); + print_error('Cannot quickly initialize page: empty course id'); } parent::init_quick($data); } @@ -338,7 +338,7 @@ function init_full() { } if(empty($this->courserecord) && !defined('ADMIN_STICKYBLOCKS')) { - error('Cannot fully initialize page: invalid course id '. $this->id); + print_error('Cannot fully initialize page: invalid course id '. $this->id); } $this->context = get_context_instance(CONTEXT_COURSE, $this->id); @@ -588,18 +588,18 @@ function init_full() { return; } if(empty($this->activityname)) { - error('Page object derived from page_generic_activity but did not define $this->activityname'); + print_error('Page object derived from page_generic_activity but did not define $this->activityname'); } if (!$this->modulerecord = get_coursemodule_from_instance($this->activityname, $this->id)) { - error('Cannot fully initialize page: invalid '.$this->activityname.' instance id '. $this->id); + print_error('Cannot fully initialize page: invalid '.$this->activityname.' instance id '. $this->id); } $this->courserecord = get_record('course', 'id', $this->modulerecord->course); if(empty($this->courserecord)) { - error('Cannot fully initialize page: invalid course id '. $this->modulerecord->course); + print_error('Cannot fully initialize page: invalid course id '. $this->modulerecord->course); } $this->activityrecord = get_record($this->activityname, 'id', $this->id); if(empty($this->activityrecord)) { - error('Cannot fully initialize page: invalid '.$this->activityname.' id '. $this->id); + print_error('Cannot fully initialize page: invalid '.$this->activityname.' id '. $this->id); } $this->full_init_done = true; } diff --git a/lib/questionlib.php b/lib/questionlib.php index 543b7595ac106..64da4dac8d909 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -578,6 +578,41 @@ function questionbank_navigation_tabs(&$row, $contexts, $querystring) { } } +/** + * Load a set of questions, given a list of ids. The $join and $extrafields arguments can be used + * together to pull in extra data. See, for example, the usage in mod/quiz/attempt.php, and + * read the code below to see how the SQL is assembled. + * + * @param string $questionlist list of comma-separated question ids. + * @param string $extrafields + * @param string $join + * + * @return mixed array of question objects on success, a string error message on failure. + */ +function question_load_questions($questionlist, $extrafields = '', $join = '') { + global $CFG; + if ($join) { + $join = ' JOIN ' . $CFG->prefix . $join; + } + if ($extrafields) { + $extrafields = ', ' . $extrafields; + } + $sql = 'SELECT q.*' . $extrafields . ' FROM ' . $CFG->prefix . 'question q' . $join . + ' WHERE q.id IN (' . $questionlist . ')'; + + // Load the questions + if (!$questions = get_records_sql($sql)) { + return 'Could not load questions.'; + } + + // Load the question type specific information + if (!get_question_options($questions)) { + return 'Could not load the question options'; + } + + return $questions; +} + /** * Private function to factor common code out of get_question_options(). * @@ -829,7 +864,7 @@ function save_question_session(&$question, &$state) { $session->sumpenalty = $state->sumpenalty; $session->manualcomment = $state->manualcomment; if (!insert_record('question_sessions', $session)) { - error('Could not insert entry in question_sessions'); + print_error('Could not insert entry in question_sessions'); } } else { $session->newest = $state->id; @@ -906,7 +941,7 @@ function question_extract_responses($questions, $formdata, $defaultevent=QUESTIO if (false !== ($quid = question_get_id_from_name_prefix($key))) { // check if this is a valid id if (!isset($questions[$quid])) { - error('Form contained question that is not in questionids'); + print_error('Form contained question that is not in questionids'); } // Remove the name prefix from the name @@ -1315,7 +1350,7 @@ function get_question_image($question) { $img = ''; if (!$category = get_record('question_categories', 'id', $question->category)){ - error('invalid category id '.$question->category); + print_error('invalid category id '.$question->category); } $coursefilesdir = get_filesdir_from_context(get_context_instance_by_id($category->contextid)); @@ -1359,7 +1394,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad $comment = trim($comment); $state->manualcomment = $comment; if (!set_field('question_sessions', 'manualcomment', $comment, 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) { - error("Cannot save comment"); + print_error("Cannot save comment"); } // Update the attempt if the score has changed. @@ -1367,7 +1402,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad $attempt->sumgrades = $attempt->sumgrades - $state->last_graded->grade + $grade; $attempt->timemodified = time(); if (!update_record('quiz_attempts', $attempt)) { - error('Failed to save the current quiz attempt!'); + print_error('Failed to save the current quiz attempt!'); } } @@ -1443,7 +1478,7 @@ function question_new_attempt_uniqueid($modulename='quiz') { $attempt = new stdClass; $attempt->modulename = $modulename; if (!$id = insert_record('question_attempts', $attempt)) { - error('Could not create new entry in question_attempts table'); + print_error('Could not create new entry in question_attempts table'); } return $id; } @@ -1687,7 +1722,7 @@ function question_make_default_categories($contexts) { // If it already exists, just return it. foreach ($contexts as $key => $context) { if (!$categoryrs = get_recordset_select("question_categories", "contextid = '{$context->id}'", 'sortorder, name', '*', '', 1)) { - error('error getting category record'); + print_error('error getting category record'); } else { if (!$category = rs_fetch_record($categoryrs)){ // Otherwise, we need to make one @@ -1700,7 +1735,7 @@ function question_make_default_categories($contexts) { $category->sortorder = 999; // By default, all categories get this number, and are sorted alphabetically. $category->stamp = make_unique_id_code(); if (!$category->id = insert_record('question_categories', $category)) { - error('Error creating a default category for context '.print_context_name($context)); + print_error('Error creating a default category for context '.print_context_name($context)); } } } @@ -2113,7 +2148,7 @@ function get_filesdir_from_context($context){ $courseid = SITEID; break; default : - error('Unsupported contextlevel in category record!'); + print_error('Unsupported contextlevel in category record!'); } return $courseid; } diff --git a/lib/simpletest/testeventslib.php b/lib/simpletest/testeventslib.php index 4934a25a66d93..65bb588def65b 100755 --- a/lib/simpletest/testeventslib.php +++ b/lib/simpletest/testeventslib.php @@ -36,7 +36,7 @@ function sample_function_handler($eventdata) { return true; } - error('Incorrect eventadata submitted: '.$eventdata); + print_error('Incorrect eventadata submitted: '.$eventdata); } // test handler class with static method @@ -70,7 +70,7 @@ function static_method($eventdata) { return true; } - error('Incorrect eventadata submitted: '.$eventdata); + print_error('Incorrect eventadata submitted: '.$eventdata); } } diff --git a/lib/speller/server-scripts/spellchecker.php b/lib/speller/server-scripts/spellchecker.php index 1831184698b39..e6d26dc1400d7 100644 --- a/lib/speller/server-scripts/spellchecker.php +++ b/lib/speller/server-scripts/spellchecker.php @@ -3,7 +3,7 @@ require_login(); if (empty($CFG->aspellpath)) { - error('Spellchecker not configured'); + print_error('Spellchecker not configured'); } header('Content-type: text/html; charset=utf-8'); diff --git a/lib/weblib.php b/lib/weblib.php index fa271a3259dcf..2bb44ee8e6851 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -326,7 +326,7 @@ function moodle_url($url = null, $params = array()){ } $parts = parse_url($url); if ($parts === FALSE){ - error('invalidurl'); + print_error('invalidurl'); } if (isset($parts['query'])){ parse_str(str_replace('&', '&', $parts['query']), $this->params); @@ -703,7 +703,7 @@ function element_to_popup_window ($type=null, $url=null, $name=null, $linkname=n $options=null, $return=false, $id=null, $class=null) { if (is_null($url)) { - error('There must be an url to the popup. Can\'t create popup window.'); + print_error('There must be an url to the popup. Can\'t create popup window.'); } global $CFG; @@ -757,7 +757,7 @@ function element_to_popup_window ($type=null, $url=null, $name=null, $linkname=n "onclick=\"this.target='$name'; return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname"; break; default : - error('Undefined element - can\'t create popup window.'); + print_error('Undefined element - can\'t create popup window.'); break; } @@ -2402,7 +2402,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='', /// This makes sure that the header is never repeated twice on a page if (defined('HEADER_PRINTED')) { - debugging('print_header() was called more than once - this should not happen. Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().'); + debugging('print_header() was called more than once - this should not happen. Please check the code for this page closely. Note: print_error() and redirect() are now safe to call after print_header().'); return; } define('HEADER_PRINTED', 'true'); @@ -3721,7 +3721,7 @@ function build_navigation($extranavlinks, $cm = null) { 'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '. 'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER); if (!$cm->modname = get_field('modules', 'name', 'id', $cm->module)) { - error('Cannot get the module type in build navigation.'); + print_error('Cannot get the module type in build navigation.'); } } if (!isset($cm->name)) { @@ -3729,7 +3729,7 @@ function build_navigation($extranavlinks, $cm = null) { 'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '. 'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER); if (!$cm->name = get_field($cm->modname, 'name', 'id', $cm->instance)) { - error('Cannot get the module name in build navigation.'); + print_error('Cannot get the module name in build navigation.'); } } $navlinks[] = array( @@ -5797,7 +5797,7 @@ function editorhelpbutton(){ $titles[] = get_string('helptext'); break; default : - error('Unknown help topic '.$item); + print_error('Unknown help topic '.$item); } } $i++; diff --git a/login/change_password.php b/login/change_password.php index d6482463bae5c..81ca8dc9be1dc 100644 --- a/login/change_password.php +++ b/login/change_password.php @@ -13,7 +13,7 @@ $systemcontext = get_context_instance(CONTEXT_SYSTEM); if (!$course = get_record('course', 'id', $id)) { - error('No such course!'); + print_error('No such course!'); } // require proper login; guest user can not change password @@ -31,7 +31,7 @@ // do not allow "Logged in as" users to change any passwords if (!empty($USER->realuser)) { - error('Can not use this script when "Logged in as"!'); + print_error('Can not use this script when "Logged in as"!'); } if (is_mnet_remote_user($USER)) { @@ -39,14 +39,14 @@ if ($idprovider = get_record('mnet_host', 'id', $USER->mnethostid)) { $message .= get_string('userchangepasswordlink', 'mnet', $idprovider); } - error($message); + print_error($message); } // load the appropriate auth plugin $userauth = get_auth_plugin($USER->auth); if (!$userauth->can_change_password()) { - error(get_string('nopasswordchange', 'auth')); + print_error('nopasswordchange', 'auth'); } if ($changeurl = $userauth->change_password_url()) { @@ -65,7 +65,7 @@ } else if ($data = $mform->get_data()) { if (!$userauth->user_update_password(addslashes_recursive($USER), $data->newpassword1)) { - error(get_string('errorpasswordupdate', 'auth')); + print_error('errorpasswordupdate', 'auth'); } // register success changing password diff --git a/login/confirm.php b/login/confirm.php index f07a9865e4bb6..04251de1c638b 100644 --- a/login/confirm.php +++ b/login/confirm.php @@ -8,12 +8,12 @@ $s = optional_param('s', '', PARAM_CLEAN); // Old parameter: username if (empty($CFG->registerauth)) { - error("Sorry, you may not use this page."); + print_error("Sorry, you may not use this page."); } $authplugin = get_auth_plugin($CFG->registerauth); if (!$authplugin->can_confirm()) { - error("Sorry, you may not use this page."); + print_error("Sorry, you may not use this page."); } if (!empty($data) || (!empty($p) && !empty($s))) { @@ -45,7 +45,7 @@ // The user has confirmed successfully, let's log them in if (!$USER = get_complete_user_data('username', $username)) { - error("Something serious is wrong with the database"); + print_error("Something serious is wrong with the database"); } set_moodle_cookie($USER->username); @@ -65,10 +65,10 @@ print_footer(); exit; } else { - error("Invalid confirmation data"); + print_error("Invalid confirmation data"); } } else { - error(get_string("errorwhenconfirming")); + print_error("errorwhenconfirming"); } redirect("$CFG->wwwroot/"); diff --git a/login/forgot_password.php b/login/forgot_password.php index 286729db1d497..904cef44fe80a 100644 --- a/login/forgot_password.php +++ b/login/forgot_password.php @@ -41,14 +41,14 @@ $user = get_complete_user_data('username', $p_username); if (!empty($user) and $user->secret === '') { print_header($strforgotten, $strforgotten, $navigation); - error(get_string('secretalreadyused')); + print_error('secretalreadyused'); } else if (!empty($user) and $user->secret == stripslashes($p_secret)) { // make sure that url relates to a valid user // check this isn't guest user if (isguestuser($user)) { - error('You cannot reset the guest password'); + print_error('You cannot reset the guest password'); } // make sure user is allowed to change password @@ -57,13 +57,13 @@ // override email stop and mail new password $user->emailstop = 0; if (!reset_password_and_mail($user)) { - error('Error resetting password and mailing you'); + print_error('Error resetting password and mailing you'); } // Clear secret so that it can not be used again $user->secret = ''; if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) { - error('Error resetting user secret string'); + print_error('Error resetting user secret string'); } reset_login_count(); @@ -78,7 +78,7 @@ } else { print_header($strforgotten, $strforgotten, $navigation); - error(get_string('forgotteninvalidurl')); + print_error('forgotteninvalidurl'); } die; //never reached @@ -115,16 +115,16 @@ // set 'secret' string $user->secret = random_string(15); if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) { - error('error setting user secret string'); + print_error('error setting user secret string'); } if (!send_password_change_confirmation_email($user)) { - error('error sending password change confirmation email'); + print_error('error sending password change confirmation email'); } } else { if (!send_password_change_info($user)) { - error('error sending password change confirmation email'); + print_error('error sending password change confirmation email'); } } } diff --git a/login/index.php b/login/index.php index e8b24cb57368e..3a3da1d449e1b 100644 --- a/login/index.php +++ b/login/index.php @@ -56,7 +56,7 @@ /// Define variables used in page if (!$site = get_site()) { - error("No site found!"); + print_error("No site found!"); } if (empty($CFG->langmenu)) { diff --git a/login/signup.php b/login/signup.php index 1cac1cb109227..a3e6e2fcbe54e 100644 --- a/login/signup.php +++ b/login/signup.php @@ -15,12 +15,12 @@ function signup_captcha_enabled() { if (empty($CFG->registerauth)) { - error("Sorry, you may not use this page."); + print_error("Sorry, you may not use this page."); } $authplugin = get_auth_plugin($CFG->registerauth); if (!$authplugin->can_signup()) { - error("Sorry, you may not use this page."); + print_error("Sorry, you may not use this page."); } //HTTPS is potentially required in this page diff --git a/message/discussion.php b/message/discussion.php index e1cbaca524352..1ac476e9cc6d5 100644 --- a/message/discussion.php +++ b/message/discussion.php @@ -10,7 +10,7 @@ } if (empty($CFG->messaging)) { - error("Messaging is disabled on this site"); + print_error("Messaging is disabled on this site"); } /// Script parameters @@ -19,7 +19,7 @@ /// Check the user we are talking to is valid if (! $user = get_record('user', 'id', $userid)) { - error("User ID was incorrect"); + print_error("User ID was incorrect"); } /// Check if frame&jsless mode selected diff --git a/message/history.php b/message/history.php index f0d254d1e5e52..6b9f2b4df9694 100644 --- a/message/history.php +++ b/message/history.php @@ -11,19 +11,19 @@ } if (empty($CFG->messaging)) { - error("Messaging is disabled on this site"); + print_error("Messaging is disabled on this site"); } /// Script parameters $userid1 = required_param('user1', PARAM_INT); if (! $user1 = get_record("user", "id", $userid1)) { // Check it's correct - error("User ID 1 was incorrect"); + print_error("User ID 1 was incorrect"); } if (has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM, SITEID))) { // Able to see any discussion $userid2 = optional_param('user2', $USER->id, PARAM_INT); if (! $user2 = get_record("user", "id", $userid2)) { // Check - error("User ID 2 was incorrect"); + print_error("User ID 2 was incorrect"); } } else { $userid2 = $USER->id; // Can only see messages involving yourself diff --git a/message/index.php b/message/index.php index 21ed8814674b4..53c4511ac38c2 100644 --- a/message/index.php +++ b/message/index.php @@ -11,7 +11,7 @@ } if (empty($CFG->messaging)) { - error("Messaging is disabled on this site"); + print_error("Messaging is disabled on this site"); } /// Optional variables that may be passed in diff --git a/message/refresh.php b/message/refresh.php index 3f480dae708ae..891055413b71b 100644 --- a/message/refresh.php +++ b/message/refresh.php @@ -11,7 +11,7 @@ } if (empty($CFG->messaging)) { - error("Messaging is disabled on this site"); + print_error("Messaging is disabled on this site"); } /// Script parameters diff --git a/message/send.php b/message/send.php index c8d085a5331b4..a2c4206e87f2b 100644 --- a/message/send.php +++ b/message/send.php @@ -10,7 +10,7 @@ } if (empty($CFG->messaging)) { - error("Messaging is disabled on this site"); + print_error("Messaging is disabled on this site"); } if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) { @@ -42,7 +42,7 @@ /// Check the user we are talking to is valid if (! $user = get_record('user', 'id', $userid)) { - error("User ID was incorrect"); + print_error("User ID was incorrect"); } /// Check that the user is not blocking us!! diff --git a/message/user.php b/message/user.php index 9546f618102db..b715002488bf6 100644 --- a/message/user.php +++ b/message/user.php @@ -10,7 +10,7 @@ } if (empty($CFG->messaging)) { - error("Messaging is disabled on this site"); + print_error("Messaging is disabled on this site"); } /// Script parameters @@ -23,7 +23,7 @@ /// Check the user we are talking to is valid if (! $user = get_record('user', 'id', $userid)) { - error("User ID was incorrect"); + print_error("User ID was incorrect"); } /// Possibly change some contacts if requested diff --git a/mod/assignment/delete.php b/mod/assignment/delete.php index 402727b8d19b5..fe3e2039ee768 100644 --- a/mod/assignment/delete.php +++ b/mod/assignment/delete.php @@ -8,25 +8,25 @@ if ($id) { if (! $cm = get_coursemodule_from_id('assignment', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $assignment = get_record('assignment', 'id', $cm->instance)) { - error("assignment ID was incorrect"); + print_error("assignment ID was incorrect"); } if (! $course = get_record('course', 'id', $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } } else { if (!$assignment = get_record('assignment', 'id', $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record('course', 'id', $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance('assignment', $assignment->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } diff --git a/mod/assignment/grade.php b/mod/assignment/grade.php index a4bd1b84996c0..4bc1b99d674ae 100644 --- a/mod/assignment/grade.php +++ b/mod/assignment/grade.php @@ -5,15 +5,15 @@ $id = required_param('id', PARAM_INT); // Course module ID if (! $cm = get_coursemodule_from_id('assignment', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $assignment = get_record("assignment", "id", $cm->instance)) { - error("assignment ID was incorrect"); + print_error("assignment ID was incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); diff --git a/mod/assignment/index.php b/mod/assignment/index.php index 334266e95be04..39ac4bc4ecc95 100644 --- a/mod/assignment/index.php +++ b/mod/assignment/index.php @@ -7,7 +7,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 2ea77f7bf22ee..193286513a57e 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -52,7 +52,7 @@ function assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course if ($cm) { $this->cm = $cm; } else if (! $this->cm = get_coursemodule_from_id('assignment', $cmid)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id); @@ -62,13 +62,13 @@ function assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course } else if ($this->cm->course == $COURSE->id) { $this->course = $COURSE; } else if (! $this->course = get_record('course', 'id', $this->cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if ($assignment) { $this->assignment = $assignment; } else if (! $this->assignment = get_record('assignment', 'id', $this->cm->instance)) { - error('assignment ID was incorrect'); + print_error('assignment ID was incorrect'); } $this->assignment->cmidnumber = $this->cm->id; // compatibility with modedit assignment obj @@ -235,7 +235,7 @@ function view_feedback($submission=NULL) { /// We need the teacher info if (!$teacher = get_record('user', 'id', $graded_by)) { - error('Could not find the teacher'); + print_error('Could not find the teacher'); } /// Print the feedback @@ -782,7 +782,7 @@ function display_submission($extra_javascript = '') { $offset = required_param('offset', PARAM_INT);//offset for where to start looking for student. if (!$user = get_record('user', 'id', $userid)) { - error('No such user!'); + print_error('No such user!'); } if (!$submission = $this->get_submission($user->id)) { @@ -1485,7 +1485,7 @@ function get_submission($userid=0, $createnew=false, $teachermodified=false) { } $newsubmission = $this->prepare_new_submission($userid, $teachermodified); if (!insert_record("assignment_submissions", $newsubmission)) { - error("Could not insert a new empty submission"); + print_error("Could not insert a new empty submission"); } return get_record('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $userid); diff --git a/mod/assignment/mod_form.php b/mod/assignment/mod_form.php index 7bf25f53b3677..33a0eb0e28a75 100644 --- a/mod/assignment/mod_form.php +++ b/mod/assignment/mod_form.php @@ -12,7 +12,7 @@ function definition() { if($ass = get_record('assignment', 'id', (int)$this->_instance)) { $type = $ass->assignmenttype; } else { - error('incorrect assignment'); + print_error('incorrect assignment'); } } else { $type = required_param('type', PARAM_ALPHA); diff --git a/mod/assignment/submissions.php b/mod/assignment/submissions.php index 79e0caf594a33..14428765b18eb 100644 --- a/mod/assignment/submissions.php +++ b/mod/assignment/submissions.php @@ -9,25 +9,25 @@ if ($id) { if (! $cm = get_coursemodule_from_id('assignment', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $assignment = get_record("assignment", "id", $cm->instance)) { - error("assignment ID was incorrect"); + print_error("assignment ID was incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } } else { if (!$assignment = get_record("assignment", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } diff --git a/mod/assignment/type/online/db/mysql.php b/mod/assignment/type/online/db/mysql.php index 349ada611c6f7..eab82852791bb 100644 --- a/mod/assignment/type/online/db/mysql.php +++ b/mod/assignment/type/online/db/mysql.php @@ -52,7 +52,7 @@ function assignment_type_online_upgrade($oldversion) { $newcm->added = time(); if (! $newcm->id = add_course_module($newcm) ) { - error("Could not add a new course module"); + print_error("Could not add a new course module"); } /// And locate it above the old one @@ -65,7 +65,7 @@ function assignment_type_online_upgrade($oldversion) { $newcm->section = $section->section; // need relative reference if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) { // Add it before Journal - error("Could not add the new course module to that section"); + print_error("Could not add the new course module to that section"); } /// Convert any existing entries from users diff --git a/mod/assignment/type/online/db/postgres7.php b/mod/assignment/type/online/db/postgres7.php index 349ada611c6f7..eab82852791bb 100644 --- a/mod/assignment/type/online/db/postgres7.php +++ b/mod/assignment/type/online/db/postgres7.php @@ -52,7 +52,7 @@ function assignment_type_online_upgrade($oldversion) { $newcm->added = time(); if (! $newcm->id = add_course_module($newcm) ) { - error("Could not add a new course module"); + print_error("Could not add a new course module"); } /// And locate it above the old one @@ -65,7 +65,7 @@ function assignment_type_online_upgrade($oldversion) { $newcm->section = $section->section; // need relative reference if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) { // Add it before Journal - error("Could not add the new course module to that section"); + print_error("Could not add the new course module to that section"); } /// Convert any existing entries from users diff --git a/mod/assignment/type/online/file.php b/mod/assignment/type/online/file.php index 2a613364eb05c..63df4d05e45ed 100644 --- a/mod/assignment/type/online/file.php +++ b/mod/assignment/type/online/file.php @@ -8,29 +8,29 @@ $userid = required_param('userid', PARAM_INT); // User ID if (! $cm = get_coursemodule_from_id('assignment', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $assignment = get_record("assignment", "id", $cm->instance)) { - error("Assignment ID was incorrect"); + print_error("Assignment ID was incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $user = get_record("user", "id", $userid)) { - error("User is misconfigured"); + print_error("User is misconfigured"); } require_login($course->id, false, $cm); if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { - error("You can not view this assignment"); + print_error("You can not view this assignment"); } if ($assignment->assignmenttype != 'online') { - error("Incorrect assignment type"); + print_error("Incorrect assignment type"); } $assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course); diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php index e9bf56698799f..428d4aed644b4 100644 --- a/mod/assignment/type/upload/assignment.class.php +++ b/mod/assignment/type/upload/assignment.class.php @@ -105,7 +105,7 @@ function view_feedback($submission=NULL) { /// We need the teacher info if (!$teacher = get_record('user', 'id', $graded_by)) { - error('Could not find the teacher'); + print_error('Could not find the teacher'); } /// Print the feedback @@ -468,7 +468,7 @@ function upload() { case 'editnotes': $this->upload_notes(); default: - error('Error: Unknow upload action ('.$action.').'); + print_error('Error: Unknow upload action ('.$action.').'); } } diff --git a/mod/assignment/type/upload/notes.php b/mod/assignment/type/upload/notes.php index 0887c9eb741b2..77cc82a6bb1f0 100644 --- a/mod/assignment/type/upload/notes.php +++ b/mod/assignment/type/upload/notes.php @@ -10,29 +10,29 @@ $mode = optional_param('mode', '', PARAM_ALPHA); if (! $cm = get_coursemodule_from_id('assignment', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $assignment = get_record('assignment', 'id', $cm->instance)) { - error("Assignment ID was incorrect"); + print_error("Assignment ID was incorrect"); } if (! $course = get_record('course', 'id', $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $user = get_record('user', 'id', $userid)) { - error("User is misconfigured"); + print_error("User is misconfigured"); } require_login($course->id, false, $cm); if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { - error("You can not view this assignment"); + print_error("You can not view this assignment"); } if ($assignment->assignmenttype != 'upload') { - error("Incorrect assignment type"); + print_error("Incorrect assignment type"); } $assignmentinstance = new assignment_upload($cm->id, $assignment, $cm, $course); diff --git a/mod/assignment/upload.php b/mod/assignment/upload.php index e866cdff02381..759a4724c88f0 100644 --- a/mod/assignment/upload.php +++ b/mod/assignment/upload.php @@ -8,25 +8,25 @@ if ($id) { if (! $cm = get_coursemodule_from_id('assignment', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $assignment = get_record("assignment", "id", $cm->instance)) { - error("assignment ID was incorrect"); + print_error("assignment ID was incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } } else { if (!$assignment = get_record("assignment", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } diff --git a/mod/assignment/view.php b/mod/assignment/view.php index 495a719a14ce4..123b54a2d469c 100644 --- a/mod/assignment/view.php +++ b/mod/assignment/view.php @@ -8,25 +8,25 @@ if ($id) { if (! $cm = get_coursemodule_from_id('assignment', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $assignment = get_record("assignment", "id", $cm->instance)) { - error("assignment ID was incorrect"); + print_error("assignment ID was incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } } else { if (!$assignment = get_record("assignment", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } diff --git a/mod/chat/gui_basic/index.php b/mod/chat/gui_basic/index.php index 79509f18cf57e..58a5a48e5b2ef 100644 --- a/mod/chat/gui_basic/index.php +++ b/mod/chat/gui_basic/index.php @@ -11,15 +11,15 @@ $newonly = optional_param('newonly', 0, PARAM_BOOL); // show only new messages if (!$chat = get_record('chat', 'id', $id)) { - error('Could not find that chat room!'); + print_error('Could not find that chat room!'); } if (!$course = get_record('course', 'id', $chat->course)) { - error('Could not find the course this belongs to!'); + print_error('Could not find the course this belongs to!'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -30,7 +30,7 @@ if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if ($groupid = groups_get_activity_group($cm)) { if (!$group = groups_get_group($groupid, false)) { - error("That group (id $groupid) doesn't exist!"); + print_error("That group (id $groupid) doesn't exist!"); } $groupname = ': '.$group->name; } else { @@ -45,11 +45,11 @@ $strchats = get_string('modulenameplural', 'chat'); $stridle = get_String('idle', 'chat'); if (!$chat_sid = chat_login_user($chat->id, 'basic', $groupid, $course)) { - error('Could not log in to chat room!!'); + print_error('Could not log in to chat room!!'); } if (!$chatusers = chat_get_users($chat->id, $groupid, $cm->groupingid)) { - error(get_string('errornousers', 'chat')); + print_error('errornousers', 'chat'); } set_field('chat_users', 'lastping', time(), 'sid', $chat_sid); @@ -81,7 +81,7 @@ $newmessage->message = $message; $newmessage->timestamp = time(); if (!insert_record('chat_messages', $newmessage)) { - error('Could not insert a chat message!'); + print_error('Could not insert a chat message!'); } set_field('chat_users', 'lastmessageping', time(), 'sid', $chat_sid); diff --git a/mod/chat/gui_header_js/chatinput.php b/mod/chat/gui_header_js/chatinput.php index f01cdd1a72964..7d37c5cda9414 100644 --- a/mod/chat/gui_header_js/chatinput.php +++ b/mod/chat/gui_header_js/chatinput.php @@ -8,7 +8,7 @@ $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { - error('Not logged in!'); + print_error('Not logged in!'); } //Get the user theme diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php index f82eb5060b9ad..ee8984e782a75 100644 --- a/mod/chat/gui_header_js/index.php +++ b/mod/chat/gui_header_js/index.php @@ -7,15 +7,15 @@ $groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers if (!$chat = get_record('chat', 'id', $id)) { - error('Could not find that chat room!'); + print_error('Could not find that chat room!'); } if (!$course = get_record('course', 'id', $chat->course)) { - error('Could not find the course this belongs to!'); + print_error('Could not find the course this belongs to!'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -33,7 +33,7 @@ if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if ($groupid = groups_get_activity_group($cm)) { if (!$group = groups_get_group($groupid, false)) { - error("That group (id $groupid) doesn't exist!"); + print_error("That group (id $groupid) doesn't exist!"); } $groupname = ': '.$group->name; } else { @@ -47,7 +47,7 @@ $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!! if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course)) { - error('Could not log in to chat room!!'); + print_error('Could not log in to chat room!!'); } $params = "chat_sid=$chat_sid"; diff --git a/mod/chat/gui_header_js/insert.php b/mod/chat/gui_header_js/insert.php index 62f0dc8147e96..a7f84873ed673 100644 --- a/mod/chat/gui_header_js/insert.php +++ b/mod/chat/gui_header_js/insert.php @@ -7,25 +7,25 @@ $chat_message = required_param('chat_message', PARAM_RAW); if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { - error('Not logged in!'); + print_error('Not logged in!'); } if (!$chat = get_record('chat', 'id', $chatuser->chatid)) { - error('No chat found'); + print_error('No chat found'); } if (!$course = get_record('course', 'id', $chat->course)) { - error('Could not find the course this belongs to!'); + print_error('Could not find the course this belongs to!'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } require_login($course->id, false, $cm); if (isguest()) { - error('Guest does not have access to chat rooms'); + print_error('Guest does not have access to chat rooms'); } session_write_close(); @@ -50,7 +50,7 @@ $message->timestamp = time(); if (!insert_record('chat_messages', $message)) { - error('Could not insert a chat message!'); + print_error('Could not insert a chat message!'); } $chatuser->lastmessageping = time() - 2; diff --git a/mod/chat/gui_header_js/jsupdate.php b/mod/chat/gui_header_js/jsupdate.php index d288f0ed0dddf..9ec8d240d6018 100644 --- a/mod/chat/gui_header_js/jsupdate.php +++ b/mod/chat/gui_header_js/jsupdate.php @@ -10,17 +10,17 @@ $chat_lastrow = optional_param('chat_lastrow', 1, PARAM_INT); if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { - error('Not logged in!'); + print_error('Not logged in!'); } //Get the minimal course if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) { - error('incorrect course id'); + print_error('incorrect course id'); } //Get the user theme and enough info to be used in chat_format_message() which passes it along to if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future! - error('User does not exist!'); + print_error('User does not exist!'); } $USER->description = ''; diff --git a/mod/chat/gui_header_js/jsupdated.php b/mod/chat/gui_header_js/jsupdated.php index 4bee2b32f6ea3..ee7fd84c2fdb1 100644 --- a/mod/chat/gui_header_js/jsupdated.php +++ b/mod/chat/gui_header_js/jsupdated.php @@ -32,18 +32,18 @@ $chat_lastid = optional_param('chat_lastid', 0, PARAM_INT); if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { - error('Not logged in!'); + print_error('Not logged in!'); } //Get the minimal course if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) { - error('incorrect course id'); + print_error('incorrect course id'); } //Get the user theme and enough info to be used in chat_format_message() which passes it along to // chat_format_message_manually() -- and only id and timezone are used. if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future! - error('User does not exist!'); + print_error('User does not exist!'); } $USER->description = ''; diff --git a/mod/chat/gui_header_js/users.php b/mod/chat/gui_header_js/users.php index ea1ef674a765f..de13609f3da85 100644 --- a/mod/chat/gui_header_js/users.php +++ b/mod/chat/gui_header_js/users.php @@ -9,17 +9,17 @@ $beep = optional_param('beep', 0, PARAM_INT); // beep target if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { - error('Not logged in!'); + print_error('Not logged in!'); } //Get the minimal course if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) { - error('incorrect course id'); + print_error('incorrect course id'); } //Get the user theme and enough info to be used in chat_format_message() which passes it along to if (!$USER = get_record('user','id',$chatuser->userid)) { // no optimisation here, it would break again in future! - error('User does not exist!'); + print_error('User does not exist!'); } $USER->description = ''; @@ -29,7 +29,7 @@ $courseid = $chatuser->course; if (!$cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $courseid)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if ($beep) { @@ -41,7 +41,7 @@ $message->timestamp = time(); if (!insert_record('chat_messages', $message)) { - error('Could not insert a chat message!'); + print_error('Could not insert a chat message!'); } $chatuser->lastmessageping = time(); // A beep is a ping ;-) @@ -55,7 +55,7 @@ /// Get list of users if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid)) { - error(get_string('errornousers', 'chat')); + print_error('errornousers', 'chat'); } ob_start(); diff --git a/mod/chat/gui_sockets/chatinput.php b/mod/chat/gui_sockets/chatinput.php index 51697bcfe4d7a..3d32f4123c33d 100644 --- a/mod/chat/gui_sockets/chatinput.php +++ b/mod/chat/gui_sockets/chatinput.php @@ -8,7 +8,7 @@ $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { - error('Not logged in!'); + print_error('Not logged in!'); } //Get the user theme diff --git a/mod/chat/gui_sockets/index.php b/mod/chat/gui_sockets/index.php index a7953abaea7cd..30bfd4430e81b 100644 --- a/mod/chat/gui_sockets/index.php +++ b/mod/chat/gui_sockets/index.php @@ -7,21 +7,21 @@ $groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers if (!$chat = get_record('chat', 'id', $id)) { - error('Could not find that chat room!'); + print_error('Could not find that chat room!'); } if (!$course = get_record('course', 'id', $chat->course)) { - error('Could not find the course this belongs to!'); + print_error('Could not find the course this belongs to!'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } require_login($course->id, false, $cm); if (isguest()) { - error('Guest does not have access to chat rooms'); + print_error('Guest does not have access to chat rooms'); } if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) { @@ -33,7 +33,7 @@ if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if ($groupid = groups_get_activity_group($cm)) { if (!$group = groups_get_group($groupid, false)) { - error("That group (id $groupid) doesn't exist!"); + print_error("That group (id $groupid) doesn't exist!"); } $groupname = ': '.$group->name; } else { @@ -47,7 +47,7 @@ $strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!! if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) { - error('Could not log in to chat room!!'); + print_error('Could not log in to chat room!!'); } $params = "chat_sid=$chat_sid"; diff --git a/mod/chat/index.php b/mod/chat/index.php index a9a365fe9bbfc..c6bcaf0ee8cd6 100644 --- a/mod/chat/index.php +++ b/mod/chat/index.php @@ -6,7 +6,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record('course', 'id', $id)) { - error('Course ID is incorrect'); + print_error('Course ID is incorrect'); } require_course_login($course); diff --git a/mod/chat/lib.php b/mod/chat/lib.php index ae361b9aab592..ab5fa4215b008 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -496,7 +496,7 @@ function chat_login_user($chatid, $version, $groupid, $course) { $message->timestamp = time(); if (!insert_record('chat_messages', $message)) { - error('Could not insert a chat message!'); + print_error('Could not insert a chat message!'); } } } @@ -526,7 +526,7 @@ function chat_delete_old_users() { $message->timestamp = time(); if (!insert_record('chat_messages', $message)) { - error('Could not insert a chat message!'); + print_error('Could not insert a chat message!'); } } } diff --git a/mod/chat/pagelib.php b/mod/chat/pagelib.php index e1718f0509860..1243b3f38fe1a 100644 --- a/mod/chat/pagelib.php +++ b/mod/chat/pagelib.php @@ -19,7 +19,7 @@ class page_chat extends page_generic_activity { function init_quick($data) { if(empty($data->pageid)) { - error('Cannot quickly initialize page: empty course id'); + print_error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'chat'; parent::init_quick($data); diff --git a/mod/chat/report.php b/mod/chat/report.php index 44cfcd25a0e89..00bdf1a93b6c4 100644 --- a/mod/chat/report.php +++ b/mod/chat/report.php @@ -12,13 +12,13 @@ $confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL); if (! $cm = get_coursemodule_from_id('chat', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $chat = get_record('chat', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } if (! $course = get_record('course', 'id', $chat->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); diff --git a/mod/chat/view.php b/mod/chat/view.php index 9637f60366210..be086082ecc3f 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -13,30 +13,30 @@ if ($id) { if (! $cm = get_coursemodule_from_id('chat', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } chat_update_chat_times($cm->instance); if (! $chat = get_record('chat', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else { chat_update_chat_times($c); if (! $chat = get_record('chat', 'id', $c)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } if (! $course = get_record('course', 'id', $chat->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } diff --git a/mod/choice/index.php b/mod/choice/index.php index 2b5cdead0b701..b12652907b85e 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -6,7 +6,7 @@ $id = required_param('id',PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 51ea48b4e0f00..9917fecd29beb 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -264,7 +264,7 @@ function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $ $newanswer->optionid = $formanswer; $newanswer->timemodified = time(); if (! update_record("choice_answers", $newanswer)) { - error("Could not update your choice because of a database error"); + print_error("Could not update your choice because of a database error"); } add_to_log($courseid, "choice", "choose again", "view.php?id=$cm->id", $choice->id, $cm->id); } else { @@ -274,13 +274,13 @@ function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $ $newanswer->optionid = $formanswer; $newanswer->timemodified = time(); if (! insert_record("choice_answers", $newanswer)) { - error("Could not save your choice"); + print_error("Could not save your choice"); } add_to_log($courseid, "choice", "choose", "view.php?id=$cm->id", $choice->id, $cm->id); } } else { if (!($current->optionid==$formanswer)) { //check to see if current choice already selected - if not display error - error("this choice is full!"); + print_error("this choice is full!"); } } } diff --git a/mod/choice/report.php b/mod/choice/report.php index 6e0730f2c78bb..5e2a62e422cdf 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -9,11 +9,11 @@ $action = optional_param('action', '', PARAM_ALPHA); if (! $cm = get_coursemodule_from_id('choice', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course module is misconfigured"); + print_error("Course module is misconfigured"); } require_login($course->id, false, $cm); @@ -23,7 +23,7 @@ require_capability('mod/choice:readresponses', $context); if (!$choice = choice_get_choice($cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } $strchoice = get_string("modulename", "choice"); diff --git a/mod/choice/view.php b/mod/choice/view.php index b82864d4df9b3..0db511b476d98 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -8,17 +8,17 @@ $attemptids = optional_param('attemptid', array(), PARAM_INT); // array of attempt ids for delete action if (! $cm = get_coursemodule_from_id('choice', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_course_login($course, false, $cm); if (!$choice = choice_get_choice($cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } $strchoice = get_string('modulename', 'choice'); diff --git a/mod/data/comment.php b/mod/data/comment.php index f9c696de26c63..bc24ed021405b 100755 --- a/mod/data/comment.php +++ b/mod/data/comment.php @@ -15,16 +15,16 @@ if (! $record = get_record('data_records', 'id', $rid)) { - error('Record ID is incorrect'); + print_error('Record ID is incorrect'); } if (! $data = get_record('data', 'id', $record->dataid)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } require_login($course->id, false, $cm); @@ -33,13 +33,13 @@ if ($commentid) { if (! $comment = get_record('data_comments', 'id', $commentid)) { - error('Comment ID is misconfigured'); + print_error('Comment ID is misconfigured'); } if ($comment->recordid != $record->id) { - error('Comment ID is misconfigured'); + print_error('Comment ID is misconfigured'); } if (!has_capability('mod/data:managecomments', $context) && $comment->userid != $USER->id) { - error('Comment is not yours to edit!'); + print_error('Comment is not yours to edit!'); } } else { $comment = false; @@ -81,7 +81,7 @@ if (insert_record('data_comments',$newcomment)) { redirect('view.php?rid='.$record->id.'&page='.$page); } else { - error('Error while saving comment.'); + print_error('Error while saving comment.'); } break; @@ -100,7 +100,7 @@ if (update_record('data_comments',$updatedcomment)) { redirect('view.php?rid='.$record->id.'&page='.$page); } else { - error('Error while saving comment.'); + print_error('Error while saving comment.'); } break; diff --git a/mod/data/edit.php b/mod/data/edit.php index 58f7cc8c491f4..40eb0e7a0c53a 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)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $data = get_record('data', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else { if (! $data = get_record('data', 'id', $d)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } @@ -82,7 +82,7 @@ if ($rid) { // So do you have access? if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey() ) { - error(get_string('noaccess','data')); + print_error('noaccess','data'); } } @@ -180,7 +180,7 @@ } else { /// Add some new records if (!data_user_can_add_entry($data, $currentgroup, $groupmode)) { - error('Can not add entries!'); + print_error('Can not add entries!'); } /// Check if maximum number of entry as specified by this database is reached @@ -341,7 +341,7 @@ // Print the stuff that need to come after the form fields. if (!$fields = get_records('data_fields', 'dataid', $data->id)) { - error(get_string('nofieldindatabase', 'data')); + print_error('nofieldindatabase', 'data'); } foreach ($fields as $eachfield) { $field = data_get_field($eachfield, $data); diff --git a/mod/data/field.php b/mod/data/field.php index 541db45b0f60f..5a3d9b22063a2 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -42,24 +42,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('data', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $data = get_record('data', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else { if (! $data = get_record('data', 'id', $d)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } @@ -169,7 +169,7 @@ $rec->defaultsort = 0; $rec->defaultsortdir = 0; if (!update_record('data', $rec)) { - error('There was an error updating the database'); + print_error('There was an error updating the database'); } } @@ -206,7 +206,7 @@ if (update_record('data', $rec)) { redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id, get_string('changessaved'), 2); } else { - error('There was an error updating the database'); + print_error('There was an error updating the database'); } exit; } diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 37bb83065c08a..e806ff7fa0d59 100755 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -135,7 +135,7 @@ function update_content($recordid, $value, $name) { $oldcontent->fieldid = $this->field->id; $oldcontent->recordid = $recordid; if ($oldcontent->id = insert_record('data_content', $oldcontent)) { - error('Could not make an empty record!'); + print_error('Could not make an empty record!'); } } diff --git a/mod/data/field/latlong/kml.php b/mod/data/field/latlong/kml.php index 7af26312b5e43..e2609d238a44c 100644 --- a/mod/data/field/latlong/kml.php +++ b/mod/data/field/latlong/kml.php @@ -14,41 +14,41 @@ if ($rid) { if (! $record = get_record('data_records', 'id', $rid)) { - error('Record ID is incorrect'); + print_error('Record ID is incorrect'); } if (! $data = get_record('data', 'id', $record->dataid)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $field = get_record('data_fields', 'id', $fieldid)) { - error('Field ID is incorrect'); + print_error('Field ID is incorrect'); } if (! $field->type == 'latlong') { // Make sure we're looking at a latlong data type! - error('Field ID is incorrect'); + print_error('Field ID is incorrect'); } if (! $content = get_record('data_content', 'fieldid', $fieldid, 'recordid', $rid)) { - error('Field content not found'); + print_error('Field content not found'); } } else { // We must have $d if (! $data = get_record('data', 'id', $d)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $field = get_record('data_fields', 'id', $fieldid)) { - error('Field ID is incorrect'); + print_error('Field ID is incorrect'); } if (! $field->type == 'latlong') { // Make sure we're looking at a latlong data type! - error('Field ID is incorrect'); + print_error('Field ID is incorrect'); } $record = NULL; } diff --git a/mod/data/import.php b/mod/data/import.php index f66faa9a52e1a..a5ac877cab46a 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)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $data = get_record('data', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else { if (! $data = get_record('data', 'id', $d)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } @@ -102,7 +102,7 @@ $recordsadded = 0; if (!$records = data_get_records_csv($filename, $fielddelimiter, $fieldenclosure)) { - error('get_records_csv failed to read data from the uploaded file. Please check file for field name typos and formatting errors.'); + print_error('get_records_csv failed to read data from the uploaded file. Please check file for field name typos and formatting errors.'); } else { //$db->debug = true; $fieldnames = array_shift($records); @@ -176,7 +176,7 @@ function data_get_records_csv($filename, $fielddelimiter=',', $fieldenclosure="\ } if (!$fp = fopen($filename, "r")) { - error('get_records_csv failed to open '.$filename); + print_error('get_records_csv failed to open '.$filename); } $fieldnames = array(); $rows = array(); diff --git a/mod/data/index.php b/mod/data/index.php index 2e0be42a85416..6f8d6c7b106c0 100755 --- a/mod/data/index.php +++ b/mod/data/index.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/data/lib.php b/mod/data/lib.php index f35970584eb65..53ba3293361ad 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -40,18 +40,18 @@ class data_field_base { /// Base class for Database Field Types (see field/* function data_field_base($field=0, $data=0) { // Field or data or both, each can be id or object if (empty($field) && empty($data)) { - error('Programmer error: You must specify field and/or data when defining field class. '); + print_error('Programmer error: You must specify field and/or data when defining field class. '); } if (!empty($field)) { if (is_object($field)) { $this->field = $field; // Programmer knows what they are doing, we hope } else if (!$this->field = get_record('data_fields','id',$field)) { - error('Bad field ID encountered: '.$field); + print_error('Bad field ID encountered: '.$field); } if (empty($data)) { if (!$this->data = get_record('data','id',$this->field->dataid)) { - error('Bad data ID encountered in field data'); + print_error('Bad data ID encountered in field data'); } } } @@ -61,10 +61,10 @@ function data_field_base($field=0, $data=0) { // Field or data or both, each c if (is_object($data)) { $this->data = $data; // Programmer knows what they are doing, we hope } else if (!$this->data = get_record('data','id',$data)) { - error('Bad data ID encountered: '.$data); + print_error('Bad data ID encountered: '.$data); } } else { // No way to define it! - error('Data id or object must be provided to field class'); + print_error('Data id or object must be provided to field class'); } } @@ -1705,7 +1705,7 @@ function data_user_can_add_entry($data, $currentgroup, $groupmode) { global $USER; if (!$cm = get_coursemodule_from_instance('data', $data->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -1835,7 +1835,7 @@ function data_presets_export($course, $cm, $data) { /* Check all is well */ if (!is_directory_a_preset($tempfolder)) { - error("Not all files generated!"); + print_error("Not all files generated!"); } $filelist = array( @@ -1878,7 +1878,7 @@ function get_settings() { global $CFG; if (!is_directory_a_preset($this->folder)) { - error("$this->userid/$this->shortname Not a preset"); + print_error("$this->userid/$this->shortname Not a preset"); } /* Grab XML */ @@ -1929,7 +1929,7 @@ function get_settings() { function import_options() { if (!confirm_sesskey()) { - error("Sesskey Invalid"); + print_error("Sesskey Invalid"); } $strblank = get_string('blank', 'data'); @@ -1981,7 +1981,7 @@ function import_options() { echo "

$strwarning

"; } else if (empty($newfields)) { - error("New preset has no defined fields!"); + print_error("New preset has no defined fields!"); } echo '
'; @@ -2000,7 +2000,7 @@ function import() { $cid = optional_param("field_$nid", -1, PARAM_INT); if ($cid == -1) continue; - if (array_key_exists($cid, $preservedfields)) error("Not an injective map"); + if (array_key_exists($cid, $preservedfields)) print_error("Not an injective map"); else $preservedfields[$cid] = true; } diff --git a/mod/data/pagelib.php b/mod/data/pagelib.php index 0ff3a02b8341f..5e444b068e3f8 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)) { - error('Cannot quickly initialize page: empty course id'); + print_error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'data'; parent::init_quick($data); diff --git a/mod/data/preset.php b/mod/data/preset.php index 255159764a258..3d66a5a560c6d 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -25,26 +25,26 @@ if ($id) { if (! $cm = get_coursemodule_from_id('data', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $data = get_record('data', 'id', $cm->instance)) { - error('Module Incorrect'); + print_error('Module Incorrect'); } } else if ($d) { if (! $data = get_record('data', 'id', $d)) { - error('Database ID Incorrect'); + print_error('Database ID Incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } else { - error('Parameter missing'); + print_error('Parameter missing'); } // fill in missing properties needed for updating of instance @@ -53,7 +53,7 @@ $data->instance = $cm->instance; if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) { - error('Could not find context'); + print_error('Could not find context'); } require_login($course->id, false, $cm); @@ -61,7 +61,7 @@ require_capability('mod/data:managetemplates', $context); if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpresets', $context)) { - error('You are not allowed to access presets from other users'); + print_error('You are not allowed to access presets from other users'); } /* Need sesskey security check here for import instruction */ @@ -76,13 +76,13 @@ /***************** Deleting *****************/ case 'confirmdelete' : if (!confirm_sesskey()) { // GET request ok here - error("Sesskey Invalid"); + print_error("Sesskey Invalid"); } if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) { //ok can delete } else { - error("Invalid request"); + print_error("Invalid request"); } $path = data_preset_path($course, $userid, $shortname); @@ -105,19 +105,19 @@ case 'delete' : if (!data_submitted() and !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) { //ok can delete } else { - error("Invalid request"); + print_error("Invalid request"); } $presetpath = data_preset_path($course, $userid, $shortname); if (!clean_preset($presetpath)) { - error("Error deleting a preset!"); + print_error("Error deleting a preset!"); } @rmdir($presetpath); @@ -130,7 +130,7 @@ /***************** Importing *****************/ case 'importpreset' : if (!data_submitted() or !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } $pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname); @@ -143,18 +143,18 @@ /* Imports a zip file. */ case 'importzip' : if (!data_submitted() or !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } if (!make_upload_directory('temp/data/'.$USER->id)) { - error("Can't Create Directory"); + print_error("Can't Create Directory"); } $presetfile = $CFG->dataroot.'/temp/data/'.$USER->id; clean_preset($presetfile); if (!unzip_file($CFG->dataroot."/$course->id/$file", $presetfile, false)) { - error("Can't unzip file"); + print_error("Can't unzip file"); } $pimporter = new PresetImporter($course, $cm, $data, -$USER->id, $shortname); @@ -166,7 +166,7 @@ case 'finishimport': if (!data_submitted() or !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } $pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname); @@ -185,7 +185,7 @@ /* Exports as a zip file ready for download. */ case 'export': if (!data_submitted() or !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } echo '
'; @@ -197,7 +197,7 @@ 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)) error("Can't move zip"); + if (!rename($file, $perminantfile)) print_error("Can't move zip"); echo "".get_string('download', 'data').""; echo '
'; break; @@ -205,7 +205,7 @@ /***************** Exporting *****************/ case 'save1': if (!data_submitted() or !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } $strcontinue = get_string('continue'); @@ -227,7 +227,7 @@ case 'save2': if (!data_submitted() or !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } $strcontinue = get_string('continue'); @@ -263,7 +263,7 @@ case 'save3': if (!data_submitted() or !confirm_sesskey()) { - error("Invalid request"); + print_error("Invalid request"); } $name = optional_param('name', $data->name, PARAM_FILE); @@ -274,7 +274,7 @@ $file = data_presets_export($course, $cm, $data); if (!unzip_file($file, $CFG->dataroot.$presetdirectory, false)) { - error("Can't unzip to the preset directory"); + print_error("Can't unzip to the preset directory"); } notify(get_string('savesuccess', 'data'), 'notifysuccess'); break; diff --git a/mod/data/preset_new.php b/mod/data/preset_new.php index c482eda5db0fa..6e4a1ddf5fb05 100755 --- a/mod/data/preset_new.php +++ b/mod/data/preset_new.php @@ -26,30 +26,30 @@ if ($id) { if (! $cm = get_coursemodule_from_id('data', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $data = get_record('data', 'id', $cm->instance)) { - error('Module Incorrect'); + print_error('Module Incorrect'); } } else if ($d) { if (! $data = get_record('data', 'id', $d)) { - error('Database ID Incorrect'); + print_error('Database ID Incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } else { - error('Parameter missing'); + print_error('Parameter missing'); } if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) { - error('Could not find context'); + print_error('Could not find context'); } require_login($course->id, false, $cm); @@ -57,7 +57,7 @@ require_capability('mod/data:managetemplates', $context); if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpresets', $context)) { - error('You are not allowed to access presets from other users'); + print_error('You are not allowed to access presets from other users'); } /* Need sesskey security check here for import instruction */ diff --git a/mod/data/rate.php b/mod/data/rate.php index e756de4878a52..06950926c9305 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)) { - error("Incorrect data id"); + print_error("Incorrect data id"); } if (!$course = get_record('course', 'id', $data->course)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } if (!$cm = get_coursemodule_from_instance('data', $data->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } require_login($course, false, $cm); if (isguestuser()) { - error("Guests are not allowed to rate entries."); + print_error("Guests are not allowed to rate entries."); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/data:rate', $context); if (!$data->assessed) { - error("Rating of items not allowed!"); + print_error("Rating of items not allowed!"); } if (!$frmdata = data_submitted() or !confirm_sesskey()) { - error("This page was not accessed correctly"); + print_error("This page was not accessed correctly"); } $count = 0; @@ -41,11 +41,11 @@ } if (!$record = get_record('data_records', 'id', $recordid)) { - error("Record ID is incorrect"); + print_error("Record ID is incorrect"); } if ($data->id != $record->dataid) { - error("Incorrect record."); + print_error("Incorrect record."); } if ($record->userid == $USER->id) { @@ -64,7 +64,7 @@ } else if ($rating != $oldrating->rating) { $oldrating->rating = $rating; if (! update_record('data_ratings', $oldrating)) { - error("Could not update an old rating ($record->id = $rating)"); + print_error("Could not update an old rating ($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)) { - error("Could not insert a new rating ($record->id = $rating)"); + print_error("Could not insert a new rating ($record->id = $rating)"); } data_update_grades($data, $record->userid); } } if ($count == 0) { - error("Incorrect submitted ratings data"); + print_error("Incorrect submitted ratings data"); } if (!empty($_SERVER['HTTP_REFERER'])) { diff --git a/mod/data/report.php b/mod/data/report.php index fafbc549e2cb7..621d2f5cc984b 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)) { - error("Record ID is incorrect"); + print_error("Record ID is incorrect"); } if (!$data = get_record('data', 'id', $record->dataid)) { - error("Data ID is incorrect"); + print_error("Data ID is incorrect"); } if (!$course = get_record('course', 'id', $data->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!$data->assessed) { - error("This activity does not use ratings"); + print_error("This activity does not use ratings"); } if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) { - error("You can not view ratings"); + print_error("You can not view ratings"); } switch ($sort) { @@ -50,7 +50,7 @@ print_header($strratings); if (!$ratings = data_get_ratings($record->id, $sqlsort)) { - error("No ratings for this record!"); + print_error("No ratings for this record!"); } else { echo ""; diff --git a/mod/data/tabs.php b/mod/data/tabs.php index 75c59b4f290fc..7a11f4390ede8 100755 --- a/mod/data/tabs.php +++ b/mod/data/tabs.php @@ -26,7 +26,7 @@ if (empty($currenttab) or empty($data) or empty($course)) { - error('You cannot call this script in that way'); + print_error('You cannot call this script in that way'); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); diff --git a/mod/data/templates.php b/mod/data/templates.php index bb1acf3e64d09..ca94a363bb024 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -32,24 +32,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('data', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $data = get_record('data', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else { if (! $data = get_record('data', 'id', $d)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } diff --git a/mod/data/view.php b/mod/data/view.php index 4427a6aaa6432..146507cf03ea4 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -44,38 +44,38 @@ if ($id) { if (! $cm = get_coursemodule_from_id('data', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $data = get_record('data', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } $record = NULL; } else if ($rid) { if (! $record = get_record('data_records', 'id', $rid)) { - error('Record ID is incorrect'); + print_error('Record ID is incorrect'); } if (! $data = get_record('data', 'id', $record->dataid)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } else { // We must have $d if (! $data = get_record('data', 'id', $d)) { - error('Data ID is incorrect'); + print_error('Data ID is incorrect'); } if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $record = NULL; } diff --git a/mod/exercise/assessments.php b/mod/exercise/assessments.php index 0e5d2f9b68d11..5327aff1b362f 100644 --- a/mod/exercise/assessments.php +++ b/mod/exercise/assessments.php @@ -40,15 +40,15 @@ // get some esential stuff... if (! $cm = get_coursemodule_from_id('exercise', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $exercise = get_record("exercise", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } exercise_add_custom_scales($exercise); @@ -73,14 +73,14 @@ if ($action == 'adminamendgradinggrade' ) { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($aid)) { - error("Admin Amend Grading grade: assessment id missing"); + print_error("Admin Amend Grading grade: assessment id missing"); } if (!$assessment = get_record("exercise_assessments", "id", $aid)) { - error("Amin Amend Grading grade: assessment not found"); + print_error("Amin Amend Grading grade: assessment not found"); } print_heading(get_string("amend", "exercise")." ".get_string("gradeforstudentsassessment", "exercise", $course->student)); @@ -111,10 +111,10 @@ elseif ($action == 'adminconfirmdelete' ) { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($aid)) { - error("Admin confirm delete: assessment id missing"); + print_error("Admin confirm delete: assessment id missing"); } notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), @@ -127,10 +127,10 @@ elseif ($action == 'admindelete' ) { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($aid)) { - error("Admin delete: submission id missing"); + print_error("Admin delete: submission id missing"); } print_string("deleting", "exercise"); @@ -147,7 +147,7 @@ elseif ($action == 'adminlist') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($sid)) { @@ -163,7 +163,7 @@ elseif ($action == 'adminlistbystudent') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($userid)) { @@ -183,16 +183,16 @@ } if (! $submission = get_record("exercise_submissions", "id", $sid)) { - error("Assess submission is misconfigured - no submission record!"); + print_error("Assess submission is misconfigured - no submission record!"); } if (!$submissionowner = get_record("user", "id", $submission->userid)) { - error("Assess resubmission: user record not found"); + print_error("Assess resubmission: user record not found"); } // there can be an assessment record, if there isn't... if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) { - error("Assess resubmission: submission records not found"); + print_error("Assess resubmission: submission records not found"); } $lastone= ''; // just the last but one submission @@ -202,7 +202,7 @@ } // get the teacher's assessment of the student's previous submission if (!$prevassessment = exercise_get_submission_assessment($prevsubmission, $USER)) { - error("Assess resubmission: Previous assessment record not found"); + print_error("Assess resubmission: Previous assessment record not found"); } // copy this assessment with comments... $assessment = exercise_copy_assessment($prevassessment, $submission, true); @@ -223,7 +223,7 @@ } if (! $submission = get_record("exercise_submissions", "id", $sid)) { - error("Assess submission is misconfigured - no submission record!"); + print_error("Assess submission is misconfigured - no submission record!"); } // there can be an assessment record (for teacher submissions), if there isn't... @@ -237,7 +237,7 @@ $assessment->timecreated = $yearfromnow; $assessment->timegraded = 0; if (!$assessment->id = insert_record("exercise_assessments", $assessment)) { - error("Could not insert exercise assessment!"); + print_error("Could not insert exercise assessment!"); } } @@ -260,7 +260,7 @@ elseif ($action == 'editelements') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } $count = count_records("exercise_grades", "exerciseid", $exercise->id); @@ -457,7 +457,7 @@ elseif ($action == 'insertelements') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } $form = data_submitted(); @@ -476,7 +476,7 @@ $element->exerciseid = $exercise->id; $element->elementno = clean_param($key, PARAM_INT); if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } } @@ -503,7 +503,7 @@ $element->weight = $form->weight[$key]; } if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } } @@ -525,7 +525,7 @@ $element->weight = $form->weight[$key]; } if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } break; @@ -544,7 +544,7 @@ } $element->maxscore = $j - 1; if (!$element->id = insert_record("exercise_elements", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } // let's not fool around here, dump the junk! @@ -560,7 +560,7 @@ $element->rubricno = $j; $element->description = $form->rubric[$i][$j]; if (!$element->id = insert_record("exercise_rubrics", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } } @@ -574,7 +574,7 @@ elseif ($action == 'listungradedstudentsubmissions') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } exercise_list_ungraded_assessments($exercise, "student"); print_continue("view.php?id=$cm->id"); @@ -586,7 +586,7 @@ elseif ($action == 'listungradedstudentassessments') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } exercise_list_ungraded_assessments($exercise, "teacher"); print_continue("view.php?id=$cm->id"); @@ -605,7 +605,7 @@ elseif ($action == 'regradestudentassessments' ) { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } // get all the student assessments if ($assessments = exercise_get_teacher_submission_assessments($exercise)) { @@ -613,12 +613,12 @@ if ($studentassessment->timegraded > 0) { if (!$submissions = get_records_select("exercise_submissions", "userid = $studentassessment->userid AND exerciseid = $exercise->id", "timecreated ASC")) { - error("Regrade student assessments: student submission not found"); + print_error("Regrade student assessments: student submission not found"); } foreach ($submissions as $submission) { // only the first one is relavant if (!$teacherassessments = get_records("exercise_assessments", "submissionid", $submission->id, "timecreated ASC")) { - error("Regrade student assessments: teacher assessment(s) not found"); + print_error("Regrade student assessments: teacher assessment(s) not found"); } foreach ($teacherassessments as $teacherassessment) { // only the first one is relavent $newgrade = exercise_compare_assessments($exercise, $studentassessment, $teacherassessment); @@ -638,20 +638,20 @@ elseif ($action == 'teacherassessment') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($aid)) { - error("assessment id missing"); + print_error("assessment id missing"); } if (empty($sid)) { error ("no sid"); } if (!$assessment = get_record("exercise_assessments", "id", $aid)) { - error("Teacher assessment: User's assessment record not found"); + print_error("Teacher assessment: User's assessment record not found"); } if (!$submission = get_record("exercise_submissions", "id", $sid)) { - error("Teacher assessment: User's submission record not found"); + print_error("Teacher assessment: User's submission record not found"); } exercise_print_teacher_assessment_form($exercise, $assessment, $submission, $_SERVER["HTTP_REFERER"]); } @@ -661,7 +661,7 @@ elseif ($action == 'teachertable') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } exercise_print_teacher_table($course); @@ -676,10 +676,10 @@ $form = data_submitted(); if (empty($aid)) { - error("assessment id missing"); + print_error("assessment id missing"); } if (! $assessment = get_record("exercise_assessments", "id", $aid)) { - error("exercise assessment is misconfigured"); + print_error("exercise assessment is misconfigured"); } // first get the assignment elements for maxscores and weights... @@ -706,7 +706,7 @@ $element->elementno = clean_param($key, PARAM_INT); $element->feedback = clean_param($thefeedback, PARAM_CLEAN); if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } $grade = 0; // set to satisfy save to db @@ -722,7 +722,7 @@ $element->feedback = clean_param($form->feedback[$key], PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } // now work out the grade... @@ -751,7 +751,7 @@ $element->feedback = clean_param($form->feedback[$i], PARAM_CLEAN); $element->grade = $form->grade[$i]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } if (empty($form->grade[$i])){ $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; @@ -765,7 +765,7 @@ $element->elementno = $i; $element->grade = $form->grade[$i]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100.0 / $exercise->grade; @@ -788,7 +788,7 @@ $element->elementno = 0; $element->grade = $form->grade[0]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } // now save the adjustment in element one unset($element); @@ -797,7 +797,7 @@ $element->elementno = 1; $element->grade = $form->grade[1]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade; // check the grade for sanity! @@ -819,7 +819,7 @@ $element->feedback = clean_param($form->feedback[$key], PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } // now work out the grade... @@ -887,7 +887,7 @@ elseif ($action == 'updateteacherassessment') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } $timenow = time(); @@ -895,10 +895,10 @@ // first do the (teacher's) assessment of the student's submission if (! $submission = get_record("exercise_submissions", "id", $form->sid)) { - error("Update teacher assessment: student's submission record not found"); + print_error("Update teacher assessment: student's submission record not found"); } if (!$assessment = exercise_get_submission_assessment($submission, $USER)) { - error("Update teacher assessment: teacher's assessment record not found"); + print_error("Update teacher assessment: teacher's assessment record not found"); } // first get the assignment elements for maxscores and weights... @@ -925,7 +925,7 @@ $element->elementno = clean_param($key, PARAM_INT); $element->feedback = clean_param($thefeedback, PARAM_CLEAN); if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } $grade = 0; // set to satisfy save to db @@ -941,7 +941,7 @@ $element->feedback = clean_param($form->feedback[$key], PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } // now work out the grade... @@ -970,7 +970,7 @@ $element->feedback = clean_param($form->feedback[$i], PARAM_CLEAN); $element->grade = $form->grade[$i]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } if (empty($form->grade[$i])){ $error += $EXERCISE_EWEIGHTS[$elements[$i]->weight]; @@ -984,7 +984,7 @@ $element->elementno = $i; $element->grade = $form->grade[$i]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $exercise->grade; echo "

".get_string("weightederrorcount", "exercise", intval($error + 0.5))."

\n"; @@ -998,7 +998,7 @@ $element->elementno = 0; $element->grade = $form->grade[0]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } // now save the adjustment in element one unset($element); @@ -1007,7 +1007,7 @@ $element->elementno = 1; $element->grade = $form->grade[1]; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]) * 100 / $exercise->grade; break; @@ -1022,7 +1022,7 @@ $element->feedback = clean_param($form->feedback[$key], PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("exercise_grades", $element)) { - error("Could not insert exercise element!"); + print_error("Could not insert exercise element!"); } } // now work out the grade... @@ -1055,7 +1055,7 @@ // now calculate the (grading) grade of the student's assessment... if (!$stassessment = get_record("exercise_assessments", "id", $form->said)) { - error("Update teacher assessment: student's assessment record not found"); + print_error("Update teacher assessment: student's assessment record not found"); } $gradinggrade = exercise_compare_assessments($exercise, $assessment, $stassessment); // ...and save the grade for the assessment @@ -1100,17 +1100,17 @@ elseif ($action == 'updategradinggrade') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($aid)) { - error("submission id missing"); + print_error("submission id missing"); } // normalise gradinggrade $gradinggrade = $_POST['gradinggrade'] * 100 / $exercise->gradinggrade; if (!set_field("exercise_assessments", "gradinggrade", $gradinggrade, "id", $aid)) { - error("Update grading grade: asseesment not updated"); + print_error("Update grading grade: asseesment not updated"); } redirect("submissions.php?id=$cm->id&action=adminlist", get_string("savedok", "exercise"), 1); } @@ -1120,7 +1120,7 @@ elseif ($action == 'userconfirmdelete' ) { if (empty($aid)) { - error("User confirm delete: assessment id missing"); + print_error("User confirm delete: assessment id missing"); } notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("assessment", "exercise")), @@ -1132,7 +1132,7 @@ elseif ($action == 'userdelete' ) { if (empty($aid)) { - error("User delete: assessment id missing"); + print_error("User delete: assessment id missing"); } print_string("deleting", "exercise"); @@ -1149,12 +1149,12 @@ elseif ($action == 'viewassessment') { if (empty($aid)) { - error("assessment id missing"); + print_error("assessment id missing"); } // get the assessment record if (!$assessment = get_record("exercise_assessments", "id", $aid)) { - error("Assessment record not found"); + print_error("Assessment record not found"); } // show assessment but don't allow changes @@ -1166,7 +1166,7 @@ /*************** no man's land **************************************/ else { - error("Fatal Error: Unknown Action: ".$action."\n"); + print_error("Fatal Error: Unknown Action: ".$action."\n"); } print_footer($course); diff --git a/mod/exercise/index.php b/mod/exercise/index.php index 7b50f834f829d..6a8084c31f7e3 100644 --- a/mod/exercise/index.php +++ b/mod/exercise/index.php @@ -7,7 +7,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_login($course->id); diff --git a/mod/exercise/lib.php b/mod/exercise/lib.php index 1d7ec9b2bbd39..28abcb5a70f55 100644 --- a/mod/exercise/lib.php +++ b/mod/exercise/lib.php @@ -167,7 +167,7 @@ function exercise_cron() { continue; } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { @@ -280,11 +280,11 @@ function exercise_delete_instance($id) { function exercise_grades($exerciseid) { /// Must return an array of grades, indexed by user, and a max grade. if (!$exercise = get_record("exercise", "id", $exerciseid)) { - error("Exercise record not found"); + print_error("Exercise record not found"); } if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (!$return->maxgrade = ($exercise->grade + $exercise->gradinggrade)) { @@ -707,7 +707,7 @@ function exercise_get_user_submissions($exercise, $user) { // return submission of user oldest first, newest last // teachers submit "exercises" if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (isteacher($course->id, $user->id)) { return get_records_select("exercise_submissions", diff --git a/mod/exercise/locallib.php b/mod/exercise/locallib.php index 365ee1e634e9c..d8364a128e38b 100644 --- a/mod/exercise/locallib.php +++ b/mod/exercise/locallib.php @@ -81,7 +81,7 @@ function exercise_add_custom_scales($exercise) { global $EXERCISE_SCALES; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if ($scales = get_records("scale", "courseid", $course->id, "name ASC")) { @@ -168,7 +168,7 @@ function exercise_copy_assessment($assessment, $submission, $withfeedback = fals $newassessment->teachercomment = addslashes($assessment->teachercomment); } if (!$newassessment->id = insert_record("exercise_assessments", $newassessment)) { - error("Copy Assessment: Could not insert exercise assessment!"); + print_error("Copy Assessment: Could not insert exercise assessment!"); } if ($grades = get_records("exercise_grades", "assessmentid", $assessment->id)) { @@ -183,7 +183,7 @@ function exercise_copy_assessment($assessment, $submission, $withfeedback = fals } $grade->assessmentid = $newassessment->id; if (!$grade->id = insert_record("exercise_grades", $grade)) { - error("Copy Assessment: Could not insert exercise grade!"); + print_error("Copy Assessment: Could not insert exercise grade!"); } } } @@ -298,7 +298,7 @@ function exercise_count_unassessed_student_submissions($exercise) { global $CFG; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $timenow = time(); $n = 0; @@ -740,10 +740,10 @@ function exercise_list_submissions_for_admin($exercise) { global $CFG, $USER; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $groupid = get_current_group($course->id); @@ -802,7 +802,7 @@ function exercise_list_submissions_for_admin($exercise) { $title =''; foreach ($assessments as $assessment) { if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { - error("exercise_list_submissions_for_admin: Submission record not found!"); + print_error("exercise_list_submissions_for_admin: Submission record not found!"); } $title .= $submission->title; // test for allocated assesments which have not been done @@ -830,7 +830,7 @@ function exercise_list_submissions_for_admin($exercise) { if (isset($table->data)) { if ($groupid) { if (! groups_group_exists($groupid)) { //TODO: - error("List unassessed student submissions: group not found"); + print_error("List unassessed student submissions: group not found"); } print_heading("$group->name ".get_string("studentassessments", "exercise", $course->student). " [$nassessments]"); @@ -943,7 +943,7 @@ function exercise_list_submissions_for_admin($exercise) { if (isset($table->data)) { if ($groupid) { if (! groups_group_exists($groupid)) { - error("List unassessed student submissions: group not found"); + print_error("List unassessed student submissions: group not found"); } print_heading("$group->name ".get_string("studentsubmissions", "exercise", $course->student). " [$nsubmissions]"); @@ -997,7 +997,7 @@ function exercise_list_teacher_assessments($exercise, $user) { $timenow = time(); if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $table->head = array (get_string("title", "exercise"), get_string("action", "exercise"), get_string("comment", "exercise")); $table->align = array ("left", "left", "left"); @@ -1043,10 +1043,10 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) global $CFG; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $strexercises = get_string("modulenameplural", "exercise"); @@ -1080,7 +1080,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) $assessment->timecreated = $yearfromnow; $assessment->mailed = 1; // no need to email to the teacher! if (!$assessment->id = insert_record("exercise_assessments", $assessment)) { - error("Could not insert exercise assessment!"); + print_error("Could not insert exercise assessment!"); } break; } @@ -1089,7 +1089,7 @@ function exercise_list_teacher_submissions($exercise, $user, $reassess = false) } else { // get hold of the teacher submission if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) { - error("List teacher submissions: submission record not found"); + print_error("List teacher submissions: submission record not found"); } } print_simple_box_start("center"); @@ -1178,10 +1178,10 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { $timenow = time(); if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $table->head = array (get_string("title", "exercise"), get_string("submittedby", "exercise"), @@ -1197,7 +1197,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { $groupid = get_current_group($course->id); if ($groupid) { if (! groups_group_exists($groupid)) { - error("List unassessed student submissions: group not found"); + print_error("List unassessed student submissions: group not found"); } print_heading(get_string("studentsubmissionsforassessment", "exercise", $group->name)); } @@ -1263,7 +1263,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { if (isteacher($course->id, $assessment->userid)) { $teacherassessed = true; if (!$teacher = get_record("user", "id", $assessment->userid)) { - error("List unassessed student submissions: teacher record not found"); + print_error("List unassessed student submissions: teacher record not found"); } $comment = get_string("resubmissionfor", "exercise", fullname($teacher)); @@ -1291,7 +1291,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { // no teacher's assessment // find who did the previous assessment if (!$submissions = exercise_get_user_submissions($exercise, $submissionowner)) { - error("List unassessed student submissions: submission records not found"); + print_error("List unassessed student submissions: submission records not found"); } // get the oldest submission, exercise_get_user_submissions returns that first foreach ($submissions as $tempsubmission) { @@ -1304,7 +1304,7 @@ function exercise_list_unassessed_student_submissions($exercise, $user) { foreach ($assessments as $assessment) { if (isteacher($course->id, $assessment->userid)) { if (!$teacher = get_record("user", "id", $assessment->userid)) { - error("List unassessed student submissions: teacher record not found"); + print_error("List unassessed student submissions: teacher record not found"); } $comment = get_string("resubmissionfor", "exercise", fullname($teacher)); @@ -1377,10 +1377,10 @@ function exercise_list_ungraded_assessments($exercise, $stype) { global $CFG; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } // lists all the assessments of student submissions for grading by teacher @@ -1431,10 +1431,10 @@ function exercise_list_user_submissions($exercise, $user) { global $CFG; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $timenow = time(); @@ -1498,10 +1498,10 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch global $CFG, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $timenow = time(); @@ -1576,7 +1576,7 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch userid)) { - error("Exercise_print_assessment_form: could not find user record"); + print_error("Exercise_print_assessment_form: could not find user record"); } if ($assessmentowner->id == $USER->id) { $formtitle = get_string("yourassessment", "exercise"); @@ -2035,10 +2035,10 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch function exercise_print_assessments_by_user_for_admin($exercise, $user) { if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if ($assessments =exercise_get_user_assessments($exercise, $user)) { @@ -2059,10 +2059,10 @@ function exercise_print_assessments_by_user_for_admin($exercise, $user) { function exercise_print_assessments_for_admin($exercise, $submission) { if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if ($assessments = exercise_get_assessments($submission)) { @@ -2083,10 +2083,10 @@ function exercise_print_assessments_for_admin($exercise, $submission) { function exercise_print_assignment_info($exercise) { if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } // print standard assignment heading $strdifference = format_time($exercise->deadline - time()); @@ -2133,7 +2133,7 @@ function exercise_print_feedback($course, $submission) { global $CFG, $RATING; if (! $teacher = get_record("user", "id", $submission->teacher)) { - error("Weird exercise error"); + print_error("Weird exercise error"); } echo "\n
"; @@ -2168,7 +2168,7 @@ function exercise_print_league_table($exercise) { // print an order table of (student) submissions in grade order, only print the student's best submission when // there are multiple submissions if (! $course = get_record("course", "id", $exercise->course)) { - error("Print league table: Course is misconfigured"); + print_error("Print league table: Course is misconfigured"); } $groupid = get_current_group($course->id); $nentries = $exercise->showleaguetable; @@ -2196,7 +2196,7 @@ function exercise_print_league_table($exercise) { continue; } if (!$user = get_record("user", "id", $submission->userid)) { - error("Print league table: user not found"); + print_error("Print league table: user not found"); } if ($exercise->anonymous and isstudent($course->id)) { $table->data[] = array(exercise_print_submission_title($exercise, $submission), @@ -2224,10 +2224,10 @@ function exercise_print_submission_assessments($exercise, $submission) { // Returns a list of grades for this submission if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $str = ''; @@ -2342,16 +2342,16 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss global $CFG, $USER, $EXERCISE_SCALES, $EXERCISE_EWEIGHTS; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $timenow = time(); if(!$submissionowner = get_record("user", "id", $submission->userid)) { - error("Print teacher assessment form: User record not found"); + print_error("Print teacher assessment form: User record not found"); } echo "
@@ -2406,7 +2406,7 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss // get the assignment elements... if (!$elementsraw = get_records("exercise_elements", "exerciseid", $exercise->id, "elementno ASC")) { - error("Teacher assessment form: Elements not found"); + print_error("Teacher assessment form: Elements not found"); } foreach ($elementsraw as $element) { $elements[] = $element; // to renumber index 0,1,2... @@ -2817,7 +2817,7 @@ function exercise_print_teacher_table($course) { $table->cellspacing = 0; if (!$teachers = get_course_teachers($course->id, "u.firstname, u.lastname")) { - error("No teachers on this course!"); + print_error("No teachers on this course!"); } for ($j = 0; $j < count($exercises); $j++) { $grand[$j] = 0; @@ -2861,10 +2861,10 @@ function exercise_print_upload_form($exercise) { global $CFG; if (! $course = get_record("course", "id", $exercise->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } echo "
"; diff --git a/mod/exercise/submissions.php b/mod/exercise/submissions.php index 68d5bb4d9b3f4..e3aa4c7ced4a6 100644 --- a/mod/exercise/submissions.php +++ b/mod/exercise/submissions.php @@ -32,15 +32,15 @@ // get some essential stuff... if (! $cm = get_coursemodule_from_id('exercise', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $exercise = get_record("exercise", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -59,10 +59,10 @@ if ($action == 'adminamendtitle' ) { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($sid)) { - error("Admin Amend Title: submission id missing"); + print_error("Admin Amend Title: submission id missing"); } $submission = get_record("exercise_submissions", "id", $sid); @@ -92,14 +92,14 @@ elseif ($action == 'adminclearlate' ) { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($sid)) { - error("Admin clear late flag: submission id missing"); + print_error("Admin clear late flag: submission id missing"); } if (!$submission = get_record("exercise_submissions", "id", $sid)) { - error("Admin clear late flag: can not get submission record"); + print_error("Admin clear late flag: can not get submission record"); } if (set_field("exercise_submissions", "late", 0, "id", $sid)) { print_heading(get_string("clearlateflag", "exercise")." ".get_string("ok")); @@ -115,18 +115,18 @@ elseif ($action == 'adminconfirmdelete' ) { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($sid)) { - error("Admin confirm delete: submission id missing"); + print_error("Admin confirm delete: submission id missing"); } if (!$submission = get_record("exercise_submissions", "id", $sid)) { - error("Admin delete: can not get submission record"); + print_error("Admin delete: can not get submission record"); } if (isteacher($course->id, $submission->userid)) { if (!isteacheredit($course->id)) { - error("Only teacher with editing permissions can delete teacher submissions."); + print_error("Only teacher with editing permissions can delete teacher submissions."); } if ($assessments = exercise_get_assessments($submission)) { echo "

".get_string("deletesubmissionwarning", "exercise", count($assessments)). @@ -142,14 +142,14 @@ elseif ($action == 'admindelete' ) { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($sid)) { - error("Admin delete: submission id missing"); + print_error("Admin delete: submission id missing"); } if (!$submission = get_record("exercise_submissions", "id", $sid)) { - error("Admin delete: can not get submission record"); + print_error("Admin delete: can not get submission record"); } print_string("deleting", "exercise"); // first get any assessments... @@ -176,13 +176,13 @@ elseif ($action == 'adminlateflag' ) { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($sid)) { - error("Admin confirm late flag: submission id missing"); + print_error("Admin confirm late flag: submission id missing"); } if (!$submission = get_record("exercise_submissions", "id", $sid)) { - error("Admin confirm late flag: can not get submission record"); + print_error("Admin confirm late flag: can not get submission record"); } notice_yesno(get_string("clearlateflag","exercise")."?", @@ -195,7 +195,7 @@ elseif ($action == 'adminlist' ) { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } echo "

Exercise Version-> $module->version

"; @@ -209,10 +209,10 @@ elseif ($action == 'adminupdatetitle' ) { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (empty($sid)) { - error("Admin Update Title: submission id missing"); + print_error("Admin Update Title: submission id missing"); } if (set_field("exercise_submissions", "title", $title, "id", $sid)) { @@ -304,7 +304,7 @@ exit; } if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } exercise_list_unassessed_student_submissions($exercise, $USER); print_continue("view.php?id=$cm->id"); @@ -331,7 +331,7 @@ $form = (object)$_POST; if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } // save the number of league table entries from the form... @@ -355,7 +355,7 @@ $form = (object)$_POST; if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } // save the weights from the form... @@ -379,7 +379,7 @@ elseif ($action == 'userconfirmdelete' ) { if (empty($sid)) { - error("User Confirm Delete: submission id missing"); + print_error("User Confirm Delete: submission id missing"); } notice_yesno(get_string("confirmdeletionofthisitem","exercise", get_string("submission", "exercise")), @@ -391,11 +391,11 @@ elseif ($action == 'userdelete' ) { if (empty($sid)) { - error("User Delete: submission id missing"); + print_error("User Delete: submission id missing"); } if (!$submission = get_record("exercise_submissions", "id", $sid)) { - error("User Delete: can not get submission record"); + print_error("User Delete: can not get submission record"); } print_string("deleting", "exercise"); // first get any assessments... @@ -422,7 +422,7 @@ else { - error("Fatal Error: Unknown Action: ".$action."\n"); + print_error("Fatal Error: Unknown Action: ".$action."\n"); } diff --git a/mod/exercise/upload.php b/mod/exercise/upload.php index 8a6796c0733ed..d7ec94ed852f9 100644 --- a/mod/exercise/upload.php +++ b/mod/exercise/upload.php @@ -11,15 +11,15 @@ // get some esential stuff... if (! $cm = get_coursemodule_from_id('exercise', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $exercise = get_record("exercise", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -71,7 +71,7 @@ $newsubmission->late = 1; } if (!$newsubmission->id = insert_record("exercise_submissions", $newsubmission)) { - error("exercise upload: Failure to create new submission record!"); + print_error("exercise upload: Failure to create new submission record!"); } $dir = exercise_file_area_name($exercise, $newsubmission); if ($um->save_files($dir)) { @@ -81,7 +81,7 @@ // upload manager will print errors. // clear resubmit flags if (!set_field("exercise_submissions", "resubmit", 0, "exerciseid", $exercise->id, "userid", $USER->id)) { - error("Exercise Upload: unable to reset resubmit flag"); + print_error("Exercise Upload: unable to reset resubmit flag"); } } // upload manager will print errors. diff --git a/mod/exercise/view.php b/mod/exercise/view.php index 5ee7fc7addc3f..5bad9a8aace0a 100644 --- a/mod/exercise/view.php +++ b/mod/exercise/view.php @@ -25,15 +25,15 @@ // get some esential stuff... if (! $cm = get_coursemodule_from_id('exercise', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $exercise = get_record("exercise", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -136,7 +136,7 @@ elseif ($action == 'makeleaguetableavailable') { if (!isteacheredit($course->id)) { - error("Only teachers with editing permissions can do this."); + print_error("Only teachers with editing permissions can do this."); } set_field("exercise", "phase", 3, "id", "$exercise->id"); @@ -155,7 +155,7 @@ elseif ($action == 'openexercise') { if (!isteacheredit($course->id)) { - error("Only teachers with editing permissions can do this."); + print_error("Only teachers with editing permissions can do this."); } // move to phase 2, check that teacher has made enough submissions @@ -177,7 +177,7 @@ elseif ($action == 'setupassignment') { if (!isteacher($course->id)) { - error("Only teachers with editing permissions can do this."); + print_error("Only teachers with editing permissions can do this."); } set_field("exercise", "phase", 1, "id", "$exercise->id"); @@ -312,7 +312,7 @@ elseif ($action == 'submitassignment') { if (!has_capability('mod/exercise:assess', $context)) { - error("Only teachers with editing permissions can do this."); + print_error("Only teachers with editing permissions can do this."); } exercise_print_assignment_info($exercise); @@ -332,7 +332,7 @@ elseif ($action == 'teachersview') { if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } /// Check to see if groups are being used in this exercise @@ -404,7 +404,7 @@ /*************** no man's land **************************************/ else { - error("Fatal Error: Unknown Action: ".$action."\n"); + print_error("Fatal Error: Unknown Action: ".$action."\n"); } print_footer($course); diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index fd3d5bd7a9669..3f019815a3d5c 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -14,11 +14,11 @@ $postid = optional_param('postid', 0, PARAM_INT); // Used for tracking read posts if user initiated. if (!$discussion = get_record('forum_discussions', 'id', $d)) { - error("Discussion ID was incorrect or no longer exists"); + print_error("Discussion ID was incorrect or no longer exists"); } if (!$course = get_record('course', 'id', $discussion->course)) { - error("Course ID is incorrect - discussion is faulty"); + print_error("Course ID is incorrect - discussion is faulty"); } if (!$forum = get_record('forum', 'id', $discussion->forum)) { @@ -26,7 +26,7 @@ } if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } require_course_login($course, true, $cm); @@ -38,7 +38,7 @@ if (!($USER->id == $discussion->userid || (($discussion->timestart == 0 || $discussion->timestart <= time()) && ($discussion->timeend == 0 || $discussion->timeend > time())))) { - error('Discussion ID was incorrect or no longer exists', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); + print_error('Discussion ID was incorrect or no longer exists', '', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); } } @@ -49,19 +49,19 @@ require_capability('mod/forum:movediscussions', $modcontext); if ($forum->type == 'single') { - error('Cannot move discussion from a simple single discussion forum', $return); + print_error('Cannot move discussion from a simple single discussion forum', '', $return); } if (!$forumto = get_record('forum', 'id', $move)) { - error('You can\'t move to that forum - it doesn\'t exist!', $return); + print_error('You can\'t move to that forum - it doesn\'t exist!', '', $return); } if (!$cmto = get_coursemodule_from_instance('forum', $forumto->id, $course->id)) { - error('Target forum not found in this course.', $return); + print_error('Target forum not found in this course.', '', $return); } if (!coursemodule_visible_for_user($cmto)) { - error('Forum not visible', $return); + print_error('Forum not visible', '', $return); } if (!forum_move_attachments($discussion, $forumto->id)) { @@ -77,8 +77,8 @@ // the regeneration of the feeds since the discussions have been // moved. if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($forumto)) { - error('Could not purge the cached RSS feeds for the source and/or'. - 'destination forum(s) - check your file permissionsforums', $return); + print_error('Could not purge the cached RSS feeds for the source and/or'. + 'destination forum(s) - check your file permissionsforums', '', $return); } redirect($return.'&moved=-1&sesskey='.sesskey()); @@ -109,12 +109,12 @@ } if (! $post = forum_get_post_full($parent)) { - error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); + print_error("Discussion no longer exists", '', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); } if (!forum_user_can_view_post($post, $course, $cm, $forum, $discussion)) { - error('You do not have permissions to view this post', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id"); + print_error('You do not have permissions to view this post', '', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id"); } if ($mark == 'read' or $mark == 'unread') { diff --git a/mod/forum/index.php b/mod/forum/index.php index 282a3ae8ba93b..b567c69efea02 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -9,11 +9,11 @@ if ($id) { if (! $course = get_record('course', 'id', $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } } else { if (! $course = get_site()) { - error("Could not find a top-level course!"); + print_error("Could not find a top-level course!"); } } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index b3872402d4f24..178058e42b2cd 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -63,7 +63,7 @@ function forum_add_instance($forum) { $discussion->mailnow = false; if (! forum_add_discussion($discussion, $discussion->intro)) { - error('Could not add the discussion for this forum'); + print_error('Could not add the discussion for this forum'); } } @@ -114,11 +114,11 @@ function forum_update_instance($forum) { notify('Warning! There is more than one discussion in this forum - using the most recent'); $discussion = array_pop($discussions); } else { - error('Could not find the discussion in this forum'); + print_error('Could not find the discussion in this forum'); } } if (! $post = get_record('forum_posts', 'id', $discussion->firstpost)) { - error('Could not find the first post in this forum discussion'); + print_error('Could not find the first post in this forum discussion'); } $post->subject = $forum->name; @@ -126,18 +126,18 @@ function forum_update_instance($forum) { $post->modified = $forum->timemodified; if (! update_record('forum_posts', ($post))) { - error('Could not update the first post'); + print_error('Could not update the first post'); } $discussion->name = $forum->name; if (! update_record('forum_discussions', ($discussion))) { - error('Could not update the discussion'); + print_error('Could not update the discussion'); } } if (!update_record('forum', $forum)) { - error('Can not update forum'); + print_error('Can not update forum'); } $forum = stripslashes_recursive($forum); @@ -791,7 +791,7 @@ function forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $u if (!isset($userto->viewfullnames[$forum->id])) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); $viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id); @@ -941,7 +941,7 @@ function forum_user_complete($course, $user, $mod, $forum) { if ($posts = forum_get_user_posts($forum->id, $user->id)) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $discussions = get_records('forum_discussions', 'forum', $forum->id); // TODO: improve @@ -1508,7 +1508,7 @@ function forum_get_readable_forums($userid, $courseid=0) { global $CFG, $USER; if (!$forummod = get_record('modules', 'name', 'forum')) { - error('The forum module is not installed'); + print_error('The forum module is not installed'); } if ($courseid) { @@ -2206,7 +2206,7 @@ function forum_make_mail_post($course, $forum, $discussion, $post, $userfrom, $u if (!isset($userto->viewfullnames[$forum->id])) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); $viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id); @@ -2246,7 +2246,7 @@ function forum_make_mail_post($course, $forum, $discussion, $post, $userfrom, $u $groups = $userfrom->groups[$forum->id]; } else { if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $group = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid); } @@ -2682,7 +2682,7 @@ function forum_print_discussion_header(&$post, $forum, $group=-1, $datestring="" if (empty($modcontext)) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } @@ -3858,7 +3858,7 @@ function forum_user_can_post_discussion($forum, $currentgroup=-1, $groupmode=-1, if (!$cm) { debugging('missing cm', DEBUG_DEVELOPER); if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -3931,7 +3931,7 @@ function forum_user_can_post($forum, $user=NULL, $cm=NULL, $context=NULL) { if (!$cm) { debugging('missing cm', DEBUG_DEVELOPER); if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -4047,7 +4047,7 @@ function forum_user_can_see_post($forum, $discussion, $post, $user=NULL, $cm=NUL if (!$cm) { debugging('missing cm', DEBUG_DEVELOPER); if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } @@ -4107,7 +4107,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis if (!$cm) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -5635,7 +5635,7 @@ function forum_check_throttling($forum) { } if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); if(!has_capability('mod/forum:throttlingapplies', $modcontext)) { @@ -5657,7 +5657,7 @@ function forum_check_throttling($forum) { $a->blockperiod = get_string('secondstotime'.$forum->blockperiod); if ($forum->blockafter <= $numposts) { - error(get_string('forumblockingtoomanyposts','error',$a),$CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id); + print_error('forumblockingtoomanyposts', 'error', $CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id, $a); } if ($forum->warnafter <= $numposts) { notify(get_string('forumblockingalmosttoomanyposts','forum',$a)); @@ -5890,14 +5890,14 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(), $mod->groupmode = 0; if (!$cmid = add_course_module($mod)) { - error('Could not create new course module instance for the teacher forum'); + print_error('Could not create new course module instance for the teacher forum'); } else { $mod->coursemodule = $cmid; if (!$sectionid = add_mod_to_section($mod)) { - error('Could not add converted teacher forum instance to section 0 in the course'); + print_error('Could not add converted teacher forum instance to section 0 in the course'); } else { if (!set_field('course_modules', 'section', $sectionid, 'id', $cmid)) { - error('Could not update course module with section id'); + print_error('Could not update course module with section id'); } } } @@ -5905,7 +5905,7 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(), // Change the forum type to general. $forum->type = 'general'; if (!update_record('forum', $forum)) { - error('Could not change forum from type teacher to type general'); + print_error('Could not change forum from type teacher to type general'); } $context = get_context_instance(CONTEXT_MODULE, $cmid); diff --git a/mod/forum/markposts.php b/mod/forum/markposts.php index aca13d435532f..8c46035687509 100644 --- a/mod/forum/markposts.php +++ b/mod/forum/markposts.php @@ -11,11 +11,11 @@ $returnpage = optional_param('returnpage', 'index.php', PARAM_FILE); // Page to return to. if (! $forum = get_record("forum", "id", $f)) { - error("Forum ID was incorrect"); + print_error("Forum ID was incorrect"); } if (! $course = get_record("course", "id", $forum->course)) { - error("Forum doesn't belong to a course!"); + print_error("Forum doesn't belong to a course!"); } if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) { @@ -66,7 +66,7 @@ // add_to_log($course->id, "forum", "mark unread", "view.php?f=$forum->id", $forum->id, $cm->id); // redirect($returnto, get_string("nowtracking", "forum", $info), 1); // } else { -// error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]); +// print_error("Could not start tracking that forum", '', $_SERVER["HTTP_REFERER"]); // } } diff --git a/mod/forum/post.php b/mod/forum/post.php index 7d42ba5040a70..803ab30353b20 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -29,25 +29,25 @@ if (!empty($forum)) { // User is starting a new discussion in a forum if (! $forum = get_record('forum', 'id', $forum)) { - error('The forum number was incorrect'); + print_error('The forum number was incorrect'); } } else if (!empty($reply)) { // User is writing a new reply if (! $parent = forum_get_post_full($reply)) { - error('Parent post ID was incorrect'); + print_error('Parent post ID was incorrect'); } if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) { - error('This post is not part of a discussion!'); + print_error('This post is not part of a discussion!'); } if (! $forum = get_record('forum', 'id', $discussion->forum)) { - error('The forum number was incorrect'); + print_error('The forum number was incorrect'); } } if (! $course = get_record('course', 'id', $forum->course)) { - error('The course number was incorrect'); + print_error('The course number was incorrect'); } if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { // For the logs - error('Could not get the course module for the forum instance.'); + print_error('Could not get the course module for the forum instance.'); } else { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } @@ -69,13 +69,13 @@ if (!empty($forum)) { // User is starting a new discussion in a forum if (! $forum = get_record("forum", "id", $forum)) { - error("The forum number was incorrect ($forum)"); + print_error("The forum number was incorrect ($forum)"); } if (! $course = get_record("course", "id", $forum->course)) { - error("The course number was incorrect ($forum->course)"); + print_error("The course number was incorrect ($forum->course)"); } if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { - error("Incorrect course module"); + print_error("Incorrect course module"); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); @@ -91,7 +91,7 @@ } if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) { - error(get_string("activityiscurrentlyhidden")); + print_error("activityiscurrentlyhidden"); } if (isset($_SERVER["HTTP_REFERER"])) { @@ -125,19 +125,19 @@ } else if (!empty($reply)) { // User is writing a new reply if (! $parent = forum_get_post_full($reply)) { - error("Parent post ID was incorrect"); + print_error("Parent post ID was incorrect"); } if (! $discussion = get_record("forum_discussions", "id", $parent->discussion)) { - error("This post is not part of a discussion!"); + print_error("This post is not part of a discussion!"); } if (! $forum = get_record("forum", "id", $discussion->forum)) { - error("The forum number was incorrect ($discussion->forum)"); + print_error("The forum number was incorrect ($discussion->forum)"); } if (! $course = get_record("course", "id", $discussion->course)) { - error("The course number was incorrect ($discussion->course)"); + print_error("The course number was incorrect ($discussion->course)"); } if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { - error("Incorrect cm"); + print_error("Incorrect cm"); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); @@ -162,7 +162,7 @@ } } if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) { - error(get_string("activityiscurrentlyhidden")); + print_error("activityiscurrentlyhidden"); } // Load up the $post variable. @@ -186,37 +186,37 @@ } else if (!empty($edit)) { // User is editing their own post if (! $post = forum_get_post_full($edit)) { - error("Post ID was incorrect"); + print_error("Post ID was incorrect"); } if ($post->parent) { if (! $parent = forum_get_post_full($post->parent)) { - error("Parent post ID was incorrect ($post->parent)"); + print_error("Parent post ID was incorrect ($post->parent)"); } } if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) { - error("This post is not part of a discussion! ($edit)"); + print_error("This post is not part of a discussion! ($edit)"); } if (! $forum = get_record("forum", "id", $discussion->forum)) { - error("The forum number was incorrect ($discussion->forum)"); + print_error("The forum number was incorrect ($discussion->forum)"); } if (! $course = get_record("course", "id", $discussion->course)) { - error("The course number was incorrect ($discussion->course)"); + print_error("The course number was incorrect ($discussion->course)"); } if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { - error('Could not get the course module for the forum instance.'); + print_error('Could not get the course module for the forum instance.'); } else { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } if (!($forum->type == 'news' && !$post->parent && $discussion->timestart > time())) { if (((time() - $post->created) > $CFG->maxeditingtime) and !has_capability('mod/forum:editanypost', $modcontext)) { - error( get_string("maxtimehaspassed", "forum", format_time($CFG->maxeditingtime)) ); + print_error('maxtimehaspassed', 'forum', '', format_time($CFG->maxeditingtime)); } } if (($post->userid <> $USER->id) and !has_capability('mod/forum:editanypost', $modcontext)) { - error("You can't edit other people's posts!"); + print_error("You can't edit other people's posts!"); } @@ -233,19 +233,19 @@ }else if (!empty($delete)) { // User is deleting a post if (! $post = forum_get_post_full($delete)) { - error("Post ID was incorrect"); + print_error("Post ID was incorrect"); } if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) { - error("This post is not part of a discussion!"); + print_error("This post is not part of a discussion!"); } if (! $forum = get_record("forum", "id", $discussion->forum)) { - error("The forum number was incorrect ($discussion->forum)"); + print_error("The forum number was incorrect ($discussion->forum)"); } if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { - error('Could not get the course module for the forum instance.'); + print_error('Could not get the course module for the forum instance.'); } if (!$course = get_record('course', 'id', $forum->course)) { - error('Incorrect course'); + print_error('Incorrect course'); } require_login($course, false, $cm); @@ -253,7 +253,7 @@ if ( !(($post->userid == $USER->id && has_capability('mod/forum:deleteownpost', $modcontext)) || has_capability('mod/forum:deleteanypost', $modcontext)) ) { - error("You can't delete this post!"); + print_error("You can't delete this post!"); } @@ -266,7 +266,7 @@ forum_go_back_to("discuss.php?d=$post->discussion")); } else if ($replycount && !has_capability('mod/forum:deleteanypost', $modcontext)) { - error(get_string("couldnotdeletereplies", "forum"), + print_error("couldnotdeletereplies", "forum", forum_go_back_to("discuss.php?d=$post->discussion")); } else { @@ -297,7 +297,7 @@ redirect(forum_go_back_to($discussionurl)); } else { - error("An error occurred while deleting record $post->id"); + print_error("An error occurred while deleting record $post->id"); } } @@ -308,7 +308,7 @@ if ($replycount) { if (!has_capability('mod/forum:deleteanypost', $modcontext)) { - error(get_string("couldnotdeletereplies", "forum"), + print_error("couldnotdeletereplies", "forum", forum_go_back_to("discuss.php?d=$post->discussion")); } print_header(); @@ -342,27 +342,27 @@ } else if (!empty($prune)) { // Pruning if (!$post = forum_get_post_full($prune)) { - error("Post ID was incorrect"); + print_error("Post ID was incorrect"); } if (!$discussion = get_record("forum_discussions", "id", $post->discussion)) { - error("This post is not part of a discussion!"); + print_error("This post is not part of a discussion!"); } if (!$forum = get_record("forum", "id", $discussion->forum)) { - error("The forum number was incorrect ($discussion->forum)"); + print_error("The forum number was incorrect ($discussion->forum)"); } if ($forum->type == 'single') { - error('Discussions from this forum cannot be split'); + print_error('Discussions from this forum cannot be split'); } if (!$post->parent) { - error('This is already the first post in the discussion'); + print_error('This is already the first post in the discussion'); } if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { // For the logs - error('Could not get the course module for the forum instance.'); + print_error('Could not get the course module for the forum instance.'); } else { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } if (!has_capability('mod/forum:splitdiscussions', $modcontext)) { - error("You can't split discussions!"); + print_error("You can't split discussions!"); } if (!empty($name)) { // User has confirmed the prune @@ -380,7 +380,7 @@ $newdiscussion->timeend = $discussion->timeend; if (!$newid = insert_record('forum_discussions', $newdiscussion)) { - error('Could not create new discussion'); + print_error('Could not create new discussion'); } $newpost = new object(); @@ -389,7 +389,7 @@ $newpost->subject = $name; if (!update_record("forum_posts", $newpost)) { - error('Could not update the original post'); + print_error('Could not update the original post'); } forum_change_discussionid($post->id, $newid); @@ -424,7 +424,7 @@ print_footer($course); die; } else { - error("No operation specified"); + print_error("No operation specified"); } @@ -434,7 +434,7 @@ } if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { // For the logs - error('Could not get the course module for the forum instance.'); + print_error('Could not get the course module for the forum instance.'); } $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -474,13 +474,13 @@ if ( !(($realpost->userid == $USER->id && (has_capability('mod/forum:replypost', $modcontext) || has_capability('mod/forum:startdiscussion', $modcontext))) || has_capability('mod/forum:editanypost', $modcontext)) ) { - error("You can not update this post"); + print_error("You can not update this post"); } $updatepost = $fromform; //realpost $updatepost->forum = $forum->id; if (!forum_update_post($updatepost, $message)) { - error(get_string("couldnotupdate", "forum"), $errordestination); + print_error("couldnotupdate", "forum", $errordestination); } // MDL-11818 @@ -488,7 +488,7 @@ $forum->intro = $updatepost->message; $forum->timemodified = time(); if (!update_record("forum", $forum)) { - error(get_string("couldnotupdate", "forum"), $errordestination); + print_error("couldnotupdate", "forum", $errordestination); } } @@ -554,7 +554,7 @@ redirect(forum_go_back_to("$discussionurl#p$fromform->id"), $message.$subscribemessage, $timemessage); } else { - error(get_string("couldnotadd", "forum"), $errordestination); + print_error("couldnotadd", "forum", $errordestination); } exit; @@ -597,7 +597,7 @@ redirect(forum_go_back_to("view.php?f=$fromform->forum"), $message.$subscribemessage, $timemessage); } else { - error(get_string("couldnotadd", "forum"), $errordestination); + print_error("couldnotadd", "forum", $errordestination); } exit; @@ -620,7 +620,7 @@ if ($post->discussion) { if (! $toppost = get_record("forum_posts", "discussion", $post->discussion, "parent", 0)) { - error("Could not find top parent of post $post->id"); + print_error("Could not find top parent of post $post->id"); } } else { $toppost->subject = ($forum->type == "news") ? get_string("addanewtopic", "forum") : @@ -664,10 +664,10 @@ // checkup if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post, null, $cm)) { - error("You cannot reply to this post"); + print_error("You cannot reply to this post"); } if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum, -1, -1, $cm, $modcontext)) { - error("You cannot start a new discussion in this forum"); + print_error("You cannot start a new discussion in this forum"); } if ($forum->type == 'qanda' @@ -681,7 +681,7 @@ if (!empty($parent)) { if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) { - error('This post is not part of a discussion!'); + print_error('This post is not part of a discussion!'); } forum_print_post($parent, $discussion, $forum, $cm, $course, false, false, false); diff --git a/mod/forum/rate.php b/mod/forum/rate.php index 7ad6b57effbf7..5d08ce716ffbf 100644 --- a/mod/forum/rate.php +++ b/mod/forum/rate.php @@ -9,15 +9,15 @@ $forumid = required_param('forumid', PARAM_INT); // The forum the rated posts are from if (!$forum = get_record('forum', 'id', $forumid)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } if (!$course = get_record('course', 'id', $forum->course)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } else { $forum->cmidnumber = $cm->id; //MDL-12961 } @@ -25,11 +25,11 @@ require_login($course, false, $cm); if (isguestuser()) { - error("Guests are not allowed to rate entries."); + print_error("Guests are not allowed to rate entries."); } if (!$forum->assessed) { - error("Rating of items not allowed!"); + print_error("Rating of items not allowed!"); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -50,7 +50,7 @@ WHERE fp.id = '$postid' AND fp.discussion = fd.id AND fd.forum = $forum->id"; if (!$post = get_record_sql($sql)) { - error("Incorrect postid - $postid"); + print_error("Incorrect postid - $postid"); } $discussionid = $post->discussion; @@ -71,7 +71,7 @@ $oldrating->rating = $rating; $oldrating->time = time(); if (! update_record('forum_ratings', $oldrating)) { - error("Could not update an old rating ($post->id = $rating)"); + print_error("Could not update an old rating ($post->id = $rating)"); } forum_update_grades($forum, $post->userid); } @@ -84,7 +84,7 @@ $newrating->rating = $rating; if (! insert_record('forum_ratings', $newrating)) { - error("Could not insert a new rating ($postid = $rating)"); + print_error("Could not insert a new rating ($postid = $rating)"); } forum_update_grades($forum, $post->userid); } @@ -97,7 +97,7 @@ } } else { - error("This page was not accessed correctly"); + print_error("This page was not accessed correctly"); } ?> diff --git a/mod/forum/report.php b/mod/forum/report.php index ede8b138f8349..1ed70073d53bc 100644 --- a/mod/forum/report.php +++ b/mod/forum/report.php @@ -9,37 +9,37 @@ $sort = optional_param('sort', '', PARAM_ALPHA); if (! $post = get_record('forum_posts', 'id', $id)) { - error("Post ID was incorrect"); + print_error("Post ID was incorrect"); } if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) { - error("Discussion ID was incorrect"); + print_error("Discussion ID was incorrect"); } if (! $forum = get_record('forum', 'id', $discussion->forum)) { - error("Forum ID was incorrect"); + print_error("Forum ID was incorrect"); } if (! $course = get_record('course', 'id', $forum->course)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } if (! $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } require_login($course, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!$forum->assessed) { - error("This activity does not use ratings"); + print_error("This activity does not use ratings"); } if (!has_capability('mod/forum:viewrating', $context)) { - error("You do not have the capability to view post ratings"); + print_error("You do not have the capability to view post ratings"); } if (!has_capability('mod/forum:viewanyrating', $context) and $USER->id != $post->userid) { - error("You can only look at results for posts that you made"); + print_error("You can only look at results for posts that you made"); } switch ($sort) { @@ -58,7 +58,7 @@ print_header("$strratings: ".format_string($post->subject)); if (!$ratings = forum_get_ratings($post->id, $sqlsort)) { - error("No ratings for this post: \"".format_string($post->subject)."\""); + print_error("No ratings for this post: \"".format_string($post->subject)."\""); } else { echo "
"; diff --git a/mod/forum/search.php b/mod/forum/search.php index dcdc15ba1e671..0f02417a0704e 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -85,7 +85,7 @@ } if (! $course = get_record("course", "id", $id)) { - error("Course id is incorrect."); + print_error("Course id is incorrect."); } require_course_login($course); @@ -182,14 +182,14 @@ // Replace the simple subject with the three items forum name -> thread name -> subject // (if all three are appropriate) each as a link. if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) { - error('Discussion ID was incorrect'); + print_error('Discussion ID was incorrect'); } if (! $forum = get_record('forum', 'id', "$discussion->forum")) { - error("Could not find forum $discussion->forum"); + print_error("Could not find forum $discussion->forum"); } if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $post->subject = highlight($strippedsearch, $post->subject); diff --git a/mod/forum/settracking.php b/mod/forum/settracking.php index 92238d73015e4..0835cd0b3870c 100644 --- a/mod/forum/settracking.php +++ b/mod/forum/settracking.php @@ -9,11 +9,11 @@ $returnpage = optional_param('returnpage', 'index.php', PARAM_FILE); // Page to return to. if (! $forum = get_record("forum", "id", $id)) { - error("Forum ID was incorrect"); + print_error("Forum ID was incorrect"); } if (! $course = get_record("course", "id", $forum->course)) { - error("Forum doesn't belong to a course!"); + print_error("Forum doesn't belong to a course!"); } if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) { @@ -48,7 +48,7 @@ add_to_log($course->id, "forum", "stop tracking", "view.php?f=$forum->id", $forum->id, $cm->id); redirect($returnto, get_string("nownottracking", "forum", $info), 1); } else { - error("Could not stop tracking that forum", $_SERVER["HTTP_REFERER"]); + print_error("Could not stop tracking that forum", $_SERVER["HTTP_REFERER"]); } } else { // subscribe @@ -56,7 +56,7 @@ add_to_log($course->id, "forum", "start tracking", "view.php?f=$forum->id", $forum->id, $cm->id); redirect($returnto, get_string("nowtracking", "forum", $info), 1); } else { - error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]); + print_error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]); } } diff --git a/mod/forum/subscribe.php b/mod/forum/subscribe.php index 26c96b88ce645..8938ce97d2f61 100644 --- a/mod/forum/subscribe.php +++ b/mod/forum/subscribe.php @@ -10,11 +10,11 @@ $user = optional_param('user',0,PARAM_INT); if (! $forum = get_record("forum", "id", $id)) { - error("Forum ID was incorrect"); + print_error("Forum ID was incorrect"); } if (! $course = get_record("course", "id", $forum->course)) { - error("Forum doesn't belong to a course!"); + print_error("Forum doesn't belong to a course!"); } if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { @@ -26,10 +26,10 @@ if ($user) { if (!has_capability('mod/forum:managesubscriptions', $context)) { - error('You do not have the permission to subscribe/unsubscribe other people!'); + print_error('You do not have the permission to subscribe/unsubscribe other people!'); } if (!$user = get_record("user", "id", $user)) { - error("User ID was incorrect"); + print_error("User ID was incorrect"); } } else { $user = $USER; @@ -39,7 +39,7 @@ and !forum_is_subscribed($user->id, $forum->id) and !has_capability('moodle/site:accessallgroups', $context)) { if (!mygroupid($course->id)) { - error('Sorry, but you must be a group member to subscribe.'); + print_error('Sorry, but you must be a group member to subscribe.'); } } @@ -86,22 +86,22 @@ add_to_log($course->id, "forum", "unsubscribe", "view.php?f=$forum->id", $forum->id, $cm->id); redirect($returnto, get_string("nownotsubscribed", "forum", $info), 1); } else { - error("Could not unsubscribe you from that forum", $_SERVER["HTTP_REFERER"]); + print_error("Could not unsubscribe you from that forum", '', $_SERVER["HTTP_REFERER"]); } } else { // subscribe if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !has_capability('mod/forum:managesubscriptions', $context)) { - error(get_string('disallowsubscribe', 'forum'),$_SERVER["HTTP_REFERER"]); + print_error('disallowsubscribe', 'forum', $_SERVER["HTTP_REFERER"]); } if (!has_capability('mod/forum:viewdiscussion', $context)) { - error("Could not subscribe you to that forum", $_SERVER["HTTP_REFERER"]); + print_error("Could not subscribe you to that forum", '', $_SERVER["HTTP_REFERER"]); } if (forum_subscribe($user->id, $forum->id) ) { add_to_log($course->id, "forum", "subscribe", "view.php?f=$forum->id", $forum->id, $cm->id); redirect($returnto, get_string("nowsubscribed", "forum", $info), 1); } else { - error("Could not subscribe you to that forum", $_SERVER["HTTP_REFERER"]); + print_error("Could not subscribe you to that forum", '', $_SERVER["HTTP_REFERER"]); } } diff --git a/mod/forum/subscribers.php b/mod/forum/subscribers.php index 6e0fbf179b97d..061610c010076 100644 --- a/mod/forum/subscribers.php +++ b/mod/forum/subscribers.php @@ -8,11 +8,11 @@ $edit = optional_param('edit',-1,PARAM_BOOL); // Turn editing on and off if (! $forum = get_record("forum", "id", $id)) { - error("Forum ID is incorrect"); + print_error("Forum ID is incorrect"); } if (! $course = get_record("course", "id", $forum->course)) { - error("Could not find this course!"); + print_error("Could not find this course!"); } if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { @@ -24,7 +24,7 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!has_capability('mod/forum:viewsubscribers', $context)) { - error('You do not have the permission to view forum subscribers'); + print_error('You do not have the permission to view forum subscribers'); } unset($SESSION->fromdiscussion); @@ -101,13 +101,13 @@ foreach ($frm->addselect as $addsubscriber) { if (! forum_subscribe($addsubscriber, $id)) { - error("Could not add subscriber with id $addsubscriber to this forum!"); + print_error("Could not add subscriber with id $addsubscriber to this forum!"); } } } else if (!empty($frm->remove) and !empty($frm->removeselect)) { foreach ($frm->removeselect as $removesubscriber) { if (! forum_unsubscribe($removesubscriber, $id)) { - error("Could not remove subscriber with id $removesubscriber from this forum!"); + print_error("Could not remove subscriber with id $removesubscriber from this forum!"); } } } else if (!empty($frm->showall)) { diff --git a/mod/forum/user.php b/mod/forum/user.php index e84205a1f4ce1..3362310c51f40 100644 --- a/mod/forum/user.php +++ b/mod/forum/user.php @@ -17,11 +17,11 @@ } if (! $user = get_record("user", "id", $id)) { - error("User ID is incorrect"); + print_error("User ID is incorrect"); } if (! $course = get_record("course", "id", $course)) { - error("Course id is incorrect."); + print_error("Course id is incorrect."); } $syscontext = get_context_instance(CONTEXT_SYSTEM); @@ -98,7 +98,7 @@ if (!isset($discussions[$post->discussion])) { if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) { - error('Discussion ID was incorrect'); + print_error('Discussion ID was incorrect'); } $discussions[$post->discussion] = $discussion; } else { @@ -107,7 +107,7 @@ if (!isset($forums[$discussion->forum])) { if (! $forum = get_record('forum', 'id', $discussion->forum)) { - error("Could not find forum $discussion->forum"); + print_error("Could not find forum $discussion->forum"); } $forums[$discussion->forum] = $forum; } else { @@ -116,7 +116,7 @@ if (!isset($cms[$forum->id])) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $cms[$forum->id] = $cm; unset($cm); // do not use cm directly, it would break caching diff --git a/mod/forum/view.php b/mod/forum/view.php index e79ac11a744e6..40b71148f0c95 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -18,13 +18,13 @@ if ($id) { if (! $cm = get_coursemodule_from_id('forum', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $forum = get_record("forum", "id", $cm->instance)) { - error("Forum ID was incorrect"); + print_error("Forum ID was incorrect"); } $strforums = get_string("modulenameplural", "forum"); $strforum = get_string("modulename", "forum"); @@ -33,23 +33,23 @@ } else if ($f) { if (! $forum = get_record("forum", "id", $f)) { - error("Forum ID was incorrect or no longer exists"); + print_error("Forum ID was incorrect or no longer exists"); } if (! $course = get_record("course", "id", $forum->course)) { - error("Forum is misconfigured - don't know what course it's from"); + print_error("Forum is misconfigured - don't know what course it's from"); } $strforums = get_string("modulenameplural", "forum"); $strforum = get_string("modulename", "forum"); if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { - error("Course Module missing"); + print_error("Course Module missing"); } $buttontext = update_module_button($cm->id, $course->id, $strforum); } else { - error('Must specify a course module or a forum ID'); + print_error('Must specify a course module or a forum ID'); } if (!$buttontext) { @@ -210,11 +210,11 @@ notify("Warning! There is more than one discussion in this forum - using the most recent"); $discussion = array_pop($discussions); } else { - error("Could not find the discussion in this forum"); + print_error("Could not find the discussion in this forum"); } } if (! $post = forum_get_post_full($discussion->firstpost)) { - error("Could not find the first post in this forum"); + print_error("Could not find the first post in this forum"); } if ($mode) { set_user_preference("forum_displaymode", $mode); diff --git a/mod/glossary/approve.php b/mod/glossary/approve.php index 8f717061e94a0..5d03612522f62 100644 --- a/mod/glossary/approve.php +++ b/mod/glossary/approve.php @@ -10,15 +10,15 @@ $hook = optional_param('hook','ALL', PARAM_CLEAN); if (! $cm = get_coursemodule_from_id('glossary', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -31,7 +31,7 @@ $newentry->timemodified = time(); // wee need this date here to speed up recent activity, TODO: use timestamp in approved field instead in 2.0 if (! update_record("glossary_entries", $newentry)) { - error("Could not update your glossary"); + print_error("Could not update your glossary"); } else { add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&eid=$eid", "$eid",$cm->id); } diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index c9c7e0592e084..fa6e690137f46 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -7,7 +7,7 @@ $action = optional_param('action','add', PARAM_ACTION); if (isguest()) { - error('Guests are not allowed to post comments!'); + print_error('Guests are not allowed to post comments!'); } switch ($action) { @@ -21,7 +21,7 @@ glossary_comment_edit(); die; default: - error('Incorrect action specified'); + print_error('Incorrect action specified'); } /** @@ -33,23 +33,23 @@ function glossary_comment_add() { $eid = optional_param('eid', 0, PARAM_INT); // Entry ID if (!$entry = get_record('glossary_entries', 'id', $eid)) { - error('Entry is incorrect'); + print_error('Entry is incorrect'); } if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) { - error('Incorrect glossary'); + print_error('Incorrect glossary'); } if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (!$course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); /// Both the configuration and capability must allow comments if (!$glossary->allowcomments or !has_capability('mod/glossary:comment', $context)) { - error('You can\'t add comments to this glossary!'); + print_error('You can\'t add comments to this glossary!'); } $mform = new mod_glossary_comment_form(); @@ -70,7 +70,7 @@ function glossary_comment_add() { $newcomment->userid = $USER->id; if (!$newcomment->id = insert_record('glossary_comments', $newcomment)) { - error('Could not insert this new comment'); + print_error('Could not insert this new comment'); } else { add_to_log($course->id, 'glossary', 'add comment', "comments.php?id=$cm->id&eid=$entry->id", "$newcomment->id", $cm->id); } @@ -94,28 +94,28 @@ function glossary_comment_delete() { $confirm = optional_param('confirm', 0, PARAM_BOOL); // delete confirmation if (!$comment = get_record('glossary_comments', 'id', $cid)) { - error('Comment is incorrect'); + print_error('Comment is incorrect'); } if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) { - error('Entry is incorrect'); + print_error('Entry is incorrect'); } if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) { - error('Incorrect glossary'); + print_error('Incorrect glossary'); } if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (!$course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (($comment->userid <> $USER->id) and !has_capability('mod/glossary:managecomments', $context)) { - error('You can\'t delete other people\'s comments!'); + print_error('You can\'t delete other people\'s comments!'); } if (!$glossary->allowcomments and !has_capability('mod/glossary:managecomments', $context)) { - error('You can\'t delete comments in this glossary!'); + print_error('You can\'t delete comments in this glossary!'); } if (data_submitted() and $confirm) { @@ -147,32 +147,32 @@ function glossary_comment_edit() { $cid = optional_param('cid', 0, PARAM_INT); // Comment ID if (!$comment = get_record('glossary_comments', 'id', $cid)) { - error('Comment is incorrect'); + print_error('Comment is incorrect'); } if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) { - error('Entry is incorrect'); + print_error('Entry is incorrect'); } if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) { - error('Incorrect glossary'); + print_error('Incorrect glossary'); } if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (!$course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!$glossary->allowcomments and !has_capability('mod/glossary:managecomments', $context)) { - error('You can\'t edit comments in this glossary!'); + print_error('You can\'t edit comments in this glossary!'); } if (($comment->userid <> $USER->id) and !has_capability('mod/glossary:managecomments', $context)) { - error('You can\'t edit other people\'s comments!'); + print_error('You can\'t edit other people\'s comments!'); } $ineditperiod = ((time() - $comment->timemodified < $CFG->maxeditingtime) || $glossary->editalways); if ((!has_capability('mod/glossary:comment', $context) or !$ineditperiod) and !has_capability('mod/glossary:managecomments', $context)) { - error('You can\'t edit this. Time expired!'); + print_error('You can\'t edit this. Time expired!'); } $mform = new mod_glossary_comment_form(); @@ -189,7 +189,7 @@ function glossary_comment_edit() { $updatedcomment->timemodified = time(); if (!update_record('glossary_comments', $updatedcomment)) { - error('Could not update this comment'); + print_error('Could not update this comment'); } else { add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&eid=$entry->id", "$updatedcomment->id",$cm->id); } diff --git a/mod/glossary/comments.php b/mod/glossary/comments.php index cf13f26c1d57f..ca3c03087d3be 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)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $entry = get_record("glossary_entries", "id", $eid)) { - error("Entry is incorrect"); + print_error("Entry is incorrect"); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index e3a8ab01137a7..b1a62d1b25a30 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -17,15 +17,15 @@ if (! $cm = get_coursemodule_from_id('glossary', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $entry = get_record("glossary_entries","id", $entry)) { - error("Entry ID was incorrect"); + print_error("Entry ID was incorrect"); } 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)) { - error("Glossary is incorrect"); + print_error("Glossary is incorrect"); } @@ -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 - error("You can't delete other people's entries!"); + print_error("You can't delete other people's entries!"); } $ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways); if (!$ineditperiod and !$manageentries) { - error("You can't delete this. Time expired!"); + print_error("You can't delete this. Time expired!"); } /// If data submitted, then process and store. @@ -63,7 +63,7 @@ $dbentry->glossaryid = $entry->sourceglossaryid; $dbentry->sourceglossaryid = 0; if (! update_record('glossary_entries', $dbentry)) { - error("Could not update your glossary"); + print_error("Could not update your glossary"); } } else { diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 7a2734ffd30cb..3f304b8e01347 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -14,34 +14,34 @@ $hook = optional_param('hook', '', PARAM_ALPHANUM); // CategoryID if (! $cm = get_coursemodule_from_id('glossary', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); if ( isguest() ) { - error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]); + print_error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if ($e) { // if entry is specified if (!$entry = get_record("glossary_entries", "id", $e)) { - error("Incorrect entry id"); + print_error("Incorrect entry id"); } $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 - error(get_string('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 @@ "view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id, $cm->id); } else { - error("Could not update your glossary"); + print_error("Could not update your glossary"); } } else { @@ -117,7 +117,7 @@ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id,$cm->id); } else { - error("Could not insert this new entry"); + print_error("Could not insert this new entry"); } } @@ -174,9 +174,9 @@ $ineditperiod = ((time() - $fromdb->timecreated < $CFG->maxeditingtime) || $glossary->editalways); if ((!$ineditperiod || $USER->id != $fromdb->userid) and !has_capability('mod/glossary:manageentries', $context)) { if ( $USER->id != $fromdb->userid ) { - error(get_string('errcannoteditothers', 'glossary')); + print_error('errcannoteditothers', 'glossary'); } elseif (!$ineditperiod) { - error(get_string('erredittimeexpired', 'glossary')); + print_error('erredittimeexpired', 'glossary'); } die; } diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index ca1b584b9ff9e..d0da1fea4040f 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)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if ($hook > 0) { if ($category = get_record("glossary_categories","id",$hook)) { //Check it belongs to the same glossary if ($category->glossaryid != $glossary->id) { - error("Glossary is incorrect"); + print_error("Glossary is incorrect"); } } else { - error("Category is incorrect"); + print_error("Category is incorrect"); } } @@ -68,7 +68,7 @@ $cat->usedynalink = $usedynalink; if ( !update_record("glossary_categories", $cat) ) { - error("Weird error. The category was not updated."); + print_error("Weird error. The category was not updated."); 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) ) { - error("Weird error. The category was not inserted."); + print_error("Weird error. The category was not inserted."); redirect("editcategories.php?id=$cm->id"); } else { diff --git a/mod/glossary/export.php b/mod/glossary/export.php index 0f91fabf214ba..ae77f1497eb63 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -10,15 +10,15 @@ $cat = optional_param('cat',0, PARAM_ALPHANUM); if (! $cm = get_coursemodule_from_id('glossary', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 5013abd96d619..05e2a09820016 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)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $glossary = get_record('glossary', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } $strglossaries = get_string('modulenameplural', 'glossary'); @@ -66,7 +66,7 @@ $dbentry->sourceglossaryid = $glossary->id; if (! update_record('glossary_entries', $dbentry)) { - error('Could not export the entry to the main glossary'); + print_error('Could not export the entry to the main glossary'); } else { print_simple_box_start('center', '60%'); echo '

'.$entryexported.'

'; diff --git a/mod/glossary/exportfile.php b/mod/glossary/exportfile.php index b88059b5ce254..6df185d19cc4e 100644 --- a/mod/glossary/exportfile.php +++ b/mod/glossary/exportfile.php @@ -12,15 +12,15 @@ $cat = optional_param('cat',0, PARAM_ALPHANUM); if (! $cm = get_coursemodule_from_id('glossary', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); diff --git a/mod/glossary/import.php b/mod/glossary/import.php index 56edc02a42aae..26bf0b8bb12d6 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)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } 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')) { - error("Glossary module doesn't exist"); + print_error("Glossary module doesn't exist"); } $mod->module = $currmodule->id; $mod->course = $course->id; @@ -155,21 +155,21 @@ $mod->section = 0; if (! $mod->coursemodule = add_course_module($mod) ) { - error("Could not add a new course module"); + print_error("Could not add a new course module"); } if (! $sectionid = add_mod_to_section($mod) ) { - error("Could not add the new course module to that section"); + print_error("Could not add the new course module to that section"); } //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)) { - error("Could not update the course module with the correct visibility"); + print_error("Could not update the course module with the correct visibility"); } if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) { - error("Could not update the course module with the correct section"); + print_error("Could not update the course module with the correct section"); } 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 6b53b9e266908..5537e15d8b19b 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -11,7 +11,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 7b41ebb02fa88..ef27bfc5c66f5 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -49,7 +49,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)) { - error("This format doesn't exist!"); + print_error("This format doesn't exist!"); } if ($returnid = 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)) { - error("This format doesn't exist!"); + print_error("This format doesn't exist!"); } if ($return = update_record("glossary", $glossary)) { @@ -1644,13 +1644,13 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) { if ( $entries ) { foreach ( $entries as $entry ) { if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) { - error('Glossary ID was incorrect or no longer exists'); + print_error('Glossary ID was incorrect or no longer exists'); } if (! $course = get_record('course', 'id', $glossary->course)) { - error('Glossary is misconfigured - don\'t know what course it\'s from'); + print_error('Glossary is misconfigured - don\'t know what course it\'s from'); } if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid, $glossary->course) ) { - error('Glossary is misconfigured - don\'t know what course module it is'); + print_error('Glossary is misconfigured - don\'t know what course module it is'); } //If displayformat is present, override glossary->displayformat diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 779cafc7a4989..278659aaa20c7 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -15,15 +15,15 @@ $sortkey = optional_param('sortkey','UPDATE', PARAM_ALPHA); // Sorting key if (! $cm = get_coursemodule_from_id('glossary', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if ( !$entriesbypage = $glossary->entbypage ) { diff --git a/mod/glossary/rate.php b/mod/glossary/rate.php index 3d086b7f76c62..c323e72c1c261 100644 --- a/mod/glossary/rate.php +++ b/mod/glossary/rate.php @@ -9,27 +9,27 @@ $glossaryid = required_param('glossaryid', PARAM_INT); // The forum the rated posts are from if (!$glossary = get_record('glossary', 'id', $glossaryid)) { - error("Incorrect glossary id"); + print_error("Incorrect glossary id"); } if (!$course = get_record('course', 'id', $glossary->course)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } require_login($course, false, $cm); if (isguestuser()) { - error("Guests are not allowed to rate entries."); + print_error("Guests are not allowed to rate entries."); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!$glossary->assessed) { - error("Rating of items not allowed!"); + print_error("Rating of items not allowed!"); } if ($glossary->assessed == 2) { @@ -52,7 +52,7 @@ } if ($entry->glossaryid != $glossary->id) { - error("This is not valid entry!"); + print_error("This is not valid entry!"); } if ($glossary->assesstimestart and $glossary->assesstimefinish) { @@ -77,7 +77,7 @@ $oldrating->rating = $rating; $oldrating->time = time(); if (! update_record("glossary_ratings", $oldrating)) { - error("Could not update an old rating ($entry = $rating)"); + print_error("Could not update an old rating ($entry = $rating)"); } glossary_update_grades($glossary, $entry->userid); } @@ -90,7 +90,7 @@ $newrating->rating = $rating; if (! insert_record("glossary_ratings", $newrating)) { - error("Could not insert a new rating ($entry->id = $rating)"); + print_error("Could not insert a new rating ($entry->id = $rating)"); } glossary_update_grades($glossary, $entry->userid); } @@ -99,7 +99,7 @@ redirect($returnurl, get_string("ratingssaved", "glossary")); } else { - error("This page was not accessed correctly"); + print_error("This page was not accessed correctly"); } ?> diff --git a/mod/glossary/report.php b/mod/glossary/report.php index 93496ca637985..b89d56d3bd162 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)) { - error("Entry ID was incorrect"); + print_error("Entry ID was incorrect"); } if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) { - error("Glossary ID was incorrect"); + print_error("Glossary ID was incorrect"); } if (! $course = get_record('course', 'id', $glossary->course)) { - error("Course ID was incorrect"); + print_error("Course ID was incorrect"); } if (! $cm = get_coursemodule_from_instance('glossary', $glossary->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } require_login($course, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!$glossary->assessed) { - error("This activity does not use ratings"); + print_error("This activity does not use ratings"); } if (!has_capability('mod/glossary:manageentries', $context) and $USER->id != $entry->userid) { - error("You can only look at results for your own entries"); + print_error("You can only look at results for your own entries"); } switch ($sort) { @@ -51,7 +51,7 @@ print_header("$strratings: $entry->concept"); if (!$ratings = glossary_get_ratings($entry->id, $sqlsort)) { - error("No ratings for this entry: \"$entry->concept\""); + print_error("No ratings for this entry: \"$entry->concept\""); } else { echo "
"; diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index 9d4338badb8a7..1650643fe5cc7 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -16,7 +16,7 @@ $glossary = get_record('glossary','id',$entry->glossaryid); $entry->glossaryname = format_string($glossary->name,true); if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id)) { - error("Could not determine which course module this belonged to!"); + print_error("Could not determine which course module this belonged to!"); } if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) { redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course, get_string('activityiscurrentlyhidden')); @@ -27,7 +27,7 @@ } else if ($concept) { $entries = glossary_get_entries_search($concept, $courseid); } else { - error('No valid entry specified'); + print_error('No valid entry specified'); } if ($entries) { diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 166afef13b1e5..efac7625e8848 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -21,27 +21,27 @@ if (!empty($id)) { if (! $cm = get_coursemodule_from_id('glossary', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else if (!empty($g)) { if (! $glossary = get_record("glossary", "id", $g)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $glossary->course)) { - error("Could not determine which course this belonged to!"); + print_error("Could not determine which course this belonged to!"); } if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id)) { - error("Could not determine which course module this belonged to!"); + print_error("Could not determine which course module this belonged to!"); } $id = $cm->id; } else { - error("Must specify glossary ID or course module ID"); + print_error("Must specify glossary ID or course module ID"); } require_course_login($course->id, true, $cm); diff --git a/mod/hotpot/attempt.php b/mod/hotpot/attempt.php index 790d92b9b32f2..b64e8bc0bf69b 100644 --- a/mod/hotpot/attempt.php +++ b/mod/hotpot/attempt.php @@ -6,19 +6,19 @@ // get attempt, hotpot, course and course_module records if (! $attempt = get_record("hotpot_attempts", "id", $attemptid)) { - error("Hot Potatoes attempt record $attemptid could not be accessed: ".$db->ErrorMsg()); + print_error("Hot Potatoes attempt record $attemptid could not be accessed: ".$db->ErrorMsg()); } if ($attempt->userid != $USER->id) { - error("User ID is incorrect"); + print_error("User ID is incorrect"); } if (! $hotpot = get_record("hotpot", "id", $attempt->hotpot)) { - error("Hot Potatoes ID is incorrect (attempt id = $attempt->id)"); + print_error("Hot Potatoes ID is incorrect (attempt id = $attempt->id)"); } if (! $course = get_record("course", "id", $hotpot->course)) { - error("Course ID is incorrect (hotpot id = $hotpot->id)"); + print_error("Course ID is incorrect (hotpot id = $hotpot->id)"); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { - error("Course Module ID is incorrect"); + print_error("Course Module ID is incorrect"); } // make sure this user is enrolled in this course @@ -82,7 +82,7 @@ $attempt->id = insert_record("hotpot_attempts", $attempt); if (empty($attempt->id)) { - error("Could not insert attempt record: ".$db->ErrorMsg(), $next_url); + print_error("Could not insert attempt record: ".$db->ErrorMsg(), '', $next_url); } // add attempt details record, if necessary @@ -91,7 +91,7 @@ $details->attempt = $attempt->id; $details->details = $attempt->details; if (! insert_record("hotpot_details", $details, false)) { - error("Could not insert attempt details record: ".$db->ErrorMsg(), $next_url); + print_error("Could not insert attempt details record: ".$db->ErrorMsg(), '', $next_url); } } } else { @@ -112,7 +112,7 @@ // update the attempt record if (! update_record("hotpot_attempts", $attempt)) { - error("Could not update attempt record: ".$db->ErrorMsg(), $next_url); + print_error("Could not update attempt record: ".$db->ErrorMsg(), '', $next_url); } // update grades for this user @@ -134,7 +134,7 @@ $details->attempt = $attempt->id; $details->details = $attempt->details; if (! insert_record("hotpot_details", $details)) { - error("Could not insert attempt details record: ".$db->ErrorMsg(), $next_url); + print_error("Could not insert attempt details record: ".$db->ErrorMsg(), '', $next_url); } } } @@ -214,8 +214,8 @@ function hotpot_set_attempt_details(&$attempt) { } if (!$ok) { return; - // error('Quiz type is missing or invalid'); - // error(get_string('error_invalidquiztype', 'hotpot')); + // print_error('Quiz type is missing or invalid'); + // print_error('error_invalidquiztype', 'hotpot'); // // script finishes here if quiztype is invalid // diff --git a/mod/hotpot/grade.php b/mod/hotpot/grade.php index 1afda285f854c..0b7e9eef47623 100644 --- a/mod/hotpot/grade.php +++ b/mod/hotpot/grade.php @@ -5,15 +5,15 @@ $id = required_param('id', PARAM_INT); // Course module ID if (! $cm = get_coursemodule_from_id('hotpot', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { - error("hotpot ID was incorrect"); + print_error("hotpot ID was incorrect"); } if (! $course = get_record("course", "id", $hotpot->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); diff --git a/mod/hotpot/index.php b/mod/hotpot/index.php index 7077710f8da8a..88870004c4351 100644 --- a/mod/hotpot/index.php +++ b/mod/hotpot/index.php @@ -8,7 +8,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_login($course->id); @@ -163,7 +163,7 @@ if ($attempt->details) { hotpot_add_attempt_details($attempt); if (! update_record('hotpot_attempts', $attempt)) { - error("Could not update attempt record: ".$db->ErrorMsg(), $next_url); + print_error("Could not update attempt record: ".$db->ErrorMsg(), '', $next_url); } } $attemptcount++; diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index ea663bed829f8..fcea20a8d208b 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -455,7 +455,7 @@ function hotpot_is_visible(&$cm) { if (!isset($cm->sectionvisible)) { if (! $section = get_record('course_sections', 'id', $cm->section)) { - error('Course module record contains invalid section'); + print_error('Course module record contains invalid section'); } $cm->sectionvisible = $section->visible; } @@ -569,7 +569,7 @@ function hotpot_add_chain(&$hotpot) { $hotpot->reference = addslashes($hotpot->reference); if (!$hotpot->instance = insert_record("hotpot", $hotpot)) { - error("Could not add a new instance of $hotpot->modulename", "view.php?id=$hotpot->course"); + print_error("Could not add a new instance of $hotpot->modulename", '', "view.php?id=$hotpot->course"); } // store (hotpot table) id of start of chain @@ -582,14 +582,14 @@ function hotpot_add_chain(&$hotpot) { } if (! $hotpot->coursemodule = add_course_module($hotpot)) { - error("Could not add a new course module"); + print_error("Could not add a new course module"); } if (! $sectionid = add_mod_to_section($hotpot) ) { - error("Could not add the new course module to that section"); + print_error("Could not add the new course module to that section"); } if (! set_field("course_modules", "section", $sectionid, "id", $hotpot->coursemodule)) { - error("Could not update the course module with the correct section"); + print_error("Could not update the course module with the correct section"); } add_to_log($hotpot->course, "course", "add mod", @@ -868,7 +868,7 @@ function hotpot_update_chain(&$hotpot) { // update $thishotpot, if required if ($require_update && !update_record("hotpot", $thishotpot)) { - error("Could not update the $hotpot->modulename", "view.php?id=$hotpot->course"); + print_error("Could not update the $hotpot->modulename", '', "view.php?id=$hotpot->course"); } } } // end foreach $ids @@ -1586,7 +1586,7 @@ function hotpot_xml_quiz(&$obj, $read_file=true, $parse_xml=true, $convert_urls= // check xmlize functions are available if (! function_exists("xmlize")) { - error('xmlize functions are not available'); + print_error('xmlize functions are not available'); } $this->read_file = $read_file; @@ -1611,7 +1611,7 @@ function hotpot_xml_quiz(&$obj, $read_file=true, $parse_xml=true, $convert_urls= if (empty($this->course) || empty($this->reference)) { $this->error = get_string('error_nocourseorfilename', 'hotpot'); if ($this->report_errors) { - error($this->error); + print_error($this->error); } return; } @@ -1647,7 +1647,7 @@ function hotpot_xml_quiz(&$obj, $read_file=true, $parse_xml=true, $convert_urls= if (!file_exists($this->filepath) || !is_readable($this->filepath)) { $this->error = get_string('error_couldnotopensourcefile', 'hotpot', $this->filepath); if ($this->report_errors) { - error($this->error, $this->course_homeurl); + print_error($this->error, '', $this->course_homeurl); } return; } @@ -1754,7 +1754,7 @@ function hotpot_xml_quiz(&$obj, $read_file=true, $parse_xml=true, $convert_urls= if (!file_exists($this->template_filepath) || !is_readable($this->template_filepath)) { $this->error = get_string('error_couldnotopentemplate', 'hotpot', $this->template_dir); if ($this->report_errors) { - error($this->error, $this->course_homeurl); + print_error($this->error, '', $this->course_homeurl); } return; } @@ -2206,7 +2206,7 @@ function hotpot_add_response(&$attempt, &$question, &$response) { if (!$question->id = get_field('hotpot_questions', 'id', 'hotpot', $attempt->hotpot, 'md5key', $question->md5key, 'name', $question->name)) { // add question record if (!$question->id = insert_record('hotpot_questions', $question)) { - error("Could not add question record (attempt_id=$attempt->id): ".$db->ErrorMsg(), $next_url); + print_error("Could not add question record (attempt_id=$attempt->id): ".$db->ErrorMsg(), '', $next_url); } } @@ -2231,7 +2231,7 @@ function hotpot_add_response(&$attempt, &$question, &$response) { // add response record if(!$response->id = insert_record('hotpot_responses', $response)) { - error("Could not add response record (attempt_id=$attempt->id, question_id=$question->id): ".$db->ErrorMsg(), $next_url); + print_error("Could not add response record (attempt_id=$attempt->id, question_id=$question->id): ".$db->ErrorMsg(), '', $next_url); } // we can stop looping now @@ -2385,7 +2385,7 @@ function hotpot_string_id($str) { // try and add the new string record if (!$id = insert_record('hotpot_strings', $record)) { global $db; - error("Could not add string record for '".htmlspecialchars($str)."': ".$db->ErrorMsg()); + print_error("Could not add string record for '".htmlspecialchars($str)."': ".$db->ErrorMsg()); } } } diff --git a/mod/hotpot/report.php b/mod/hotpot/report.php index bc233a3e7da0f..d7b2c2a1f4b06 100644 --- a/mod/hotpot/report.php +++ b/mod/hotpot/report.php @@ -10,24 +10,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('hotpot', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else { if (! $hotpot = get_record("hotpot", "id", $hp)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $hotpot->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } @@ -331,7 +331,7 @@ /// Open the selected hotpot report and display it if (! is_readable("report/$mode/report.php")) { - error("Report not known (".clean_text($mode).")", $course_homeurl); + print_error("Report not known (".clean_text($mode).")", '', $course_homeurl); } include("report/default.php"); // Parent class @@ -340,7 +340,7 @@ $report = new hotpot_report(); if (! $report->display($hotpot, $cm, $course, $users, $attempts, $questions, $formdata)) { - error("Error occurred during report processing!", $course_homeurl); + print_error("Error occurred during report processing!", '', $course_homeurl); } if ($formdata['reportformat']=='htm') { diff --git a/mod/hotpot/review.php b/mod/hotpot/review.php index 0eef8953cf2f6..583cf178574f4 100644 --- a/mod/hotpot/review.php +++ b/mod/hotpot/review.php @@ -9,27 +9,27 @@ if ($id) { if (! $cm = get_coursemodule_from_id('hotpot', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else { if (! $hotpot = get_record("hotpot", "id", $hp)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $hotpot->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) { - error("Attempt ID was incorrect"); + print_error("Attempt ID was incorrect"); } require_login($course, true, $cm); @@ -37,13 +37,13 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!has_capability('mod/hotpot:viewreport',$context)) { if (!$hotpot->review) { - error(get_string("noreview", "quiz")); + print_error("noreview", "quiz"); } //if (time() < $hotpot->timeclose) { - // error(get_string("noreviewuntil", "quiz", userdate($hotpot->timeclose))); + // print_error("noreviewuntil", "quiz", '', userdate($hotpot->timeclose)); //} if ($attempt->userid != $USER->id) { - error("This is not your attempt!"); + print_error("This is not your attempt!"); } } add_to_log($course->id, "hotpot", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id"); diff --git a/mod/hotpot/show.php b/mod/hotpot/show.php index a87d3318cff0a..23d7b1dca0963 100644 --- a/mod/hotpot/show.php +++ b/mod/hotpot/show.php @@ -11,7 +11,7 @@ require_login($params->course); if (!has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $params->course))) { - error("You are not allowed to view this page!"); + print_error("You are not allowed to view this page!"); } if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM, SITEID))) { $params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES, PARAM_INT); diff --git a/mod/hotpot/template/default.php b/mod/hotpot/template/default.php index b570e4b3400f3..307199c0fd6e5 100644 --- a/mod/hotpot/template/default.php +++ b/mod/hotpot/template/default.php @@ -6,7 +6,7 @@ function read_template($filename, $tag='temporary') { // try and open the template file if (!file_exists($filepath) || !is_readable($filepath)) { $msg = 'Could not open the '.$this->parent->template_dir.' template file "'.$filepath.'"'; - error($msg, $this->parent->course_homeurl); + print_error($msg, '', $this->parent->course_homeurl); } // read in the template and close the file $this->$tag = file_get_contents($filepath); @@ -40,7 +40,7 @@ function expand_blocks($tag) { } } else { $msg = 'Template block expand method not found: "'.$method.'"'; - error($msg, $this->parent->course_homeurl); + print_error($msg, '', $this->parent->course_homeurl); } } } diff --git a/mod/hotpot/view.php b/mod/hotpot/view.php index c04afd7d93354..b5d8e405f109d 100644 --- a/mod/hotpot/view.php +++ b/mod/hotpot/view.php @@ -13,24 +13,24 @@ if ($id) { if (! $cm = get_coursemodule_from_id('hotpot', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else { if (! $hotpot = get_record("hotpot", "id", $hp)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $hotpot->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } @@ -113,7 +113,7 @@ } // open and parse the source file if(!$hp = new hotpot_xml_quiz($hotpot)) { - error("Quiz is unavailable at the moment"); + print_error("Quiz is unavailable at the moment"); } $get_js = optional_param('js', '', PARAM_ALPHA); $get_css = optional_param('css', '', PARAM_ALPHA); @@ -146,7 +146,7 @@ $attemptid = hotpot_add_attempt($hotpot->id); if (! is_numeric($attemptid)) { - error('Could not insert attempt record: '.$db->ErrorMsg); + print_error('Could not insert attempt record: '.$db->ErrorMsg); } } $hp->adjust_media_urls(); diff --git a/mod/journal/edit.php b/mod/journal/edit.php index 79ed2eada6ee3..136d96f3dd825 100644 --- a/mod/journal/edit.php +++ b/mod/journal/edit.php @@ -5,21 +5,21 @@ $id = required_param('id', PARAM_INT); // Course Module ID if (! $cm = get_coursemodule_from_id('journal', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); if (isguest()) { - error("Guests are not allowed to edit journals", $_SERVER["HTTP_REFERER"]); + print_error("Guests are not allowed to edit journals", '', $_SERVER["HTTP_REFERER"]); } if (! $journal = get_record("journal", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } $entry = get_record("journal_entries", "userid", $USER->id, "journal", $journal->id); @@ -39,7 +39,7 @@ $newentry->format = $form->format; $newentry->modified = $timenow; if (! update_record("journal_entries", $newentry)) { - error("Could not update your journal"); + print_error("Could not update your journal"); } add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id", $cm->id); } else { @@ -49,7 +49,7 @@ $newentry->format = $form->format; $newentry->modified = $timenow; if (! $newentry->id = insert_record("journal_entries", $newentry)) { - error("Could not insert a new journal entry"); + print_error("Could not insert a new journal entry"); } add_to_log($course->id, "journal", "add entry", "view.php?id=$cm->id", "$newentry->id", $cm->id); } diff --git a/mod/journal/index.php b/mod/journal/index.php index 0a9a90791d848..4a06991c9a0a1 100644 --- a/mod/journal/index.php +++ b/mod/journal/index.php @@ -6,7 +6,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 90e9c9aa471e1..47c48f20ad8fb 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -506,7 +506,7 @@ function journal_print_feedback($course, $entry, $grades) { global $CFG; if (! $teacher = get_record('user', 'id', $entry->teacher)) { - error('Weird journal error'); + print_error('Weird journal error'); } echo '
'; diff --git a/mod/journal/report.php b/mod/journal/report.php index 441f9d86f767c..58762c6656c0c 100644 --- a/mod/journal/report.php +++ b/mod/journal/report.php @@ -6,21 +6,21 @@ $id = required_param('id', PARAM_INT); // course module if (! $cm = get_coursemodule_from_id('journal', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course module is misconfigured"); + print_error("Course module is misconfigured"); } require_login($course->id, false, $cm); if (!isteacher($course->id)) { - error("Only teachers can look at this page"); + print_error("Only teachers can look at this page"); } if (! $journal = get_record("journal", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } // make some easy ways to access the entries. diff --git a/mod/journal/view.php b/mod/journal/view.php index 7dad3fcd82634..0283f5f68bd05 100644 --- a/mod/journal/view.php +++ b/mod/journal/view.php @@ -6,23 +6,23 @@ $id = required_param('id', PARAM_INT); // Course Module ID if (! $cm = get_coursemodule_from_id('journal', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, true, $cm); if (! $journal = get_record("journal", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } add_to_log($course->id, "journal", "view", "view.php?id=$cm->id", $journal->id, $cm->id); if (! $cw = get_record("course_sections", "id", $cm->section)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } $strjournal = get_string("modulename", "journal"); diff --git a/mod/label/view.php b/mod/label/view.php index 74a8b3011261d..f450a55dd3f74 100644 --- a/mod/label/view.php +++ b/mod/label/view.php @@ -7,26 +7,26 @@ if ($id) { if (! $cm = get_coursemodule_from_id('label', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $label = get_record("label", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else { if (! $label = get_record("label", "id", $l)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $label->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("label", $label->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } diff --git a/mod/lams/index.php b/mod/lams/index.php index 94fae61b8142c..97789e928d6fb 100644 --- a/mod/lams/index.php +++ b/mod/lams/index.php @@ -8,7 +8,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_login($course->id); diff --git a/mod/lams/view.php b/mod/lams/view.php index 527c7ab159d74..c3755a10cd601 100644 --- a/mod/lams/view.php +++ b/mod/lams/view.php @@ -10,15 +10,15 @@ $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or if (! $cm = get_coursemodule_from_id('lams', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $lams = get_record("lams", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course, true, $cm); diff --git a/mod/lesson/action/addbranchtable.php b/mod/lesson/action/addbranchtable.php index 3fb28ef18e0b6..7b1ffba6dde0e 100644 --- a/mod/lesson/action/addbranchtable.php +++ b/mod/lesson/action/addbranchtable.php @@ -20,7 +20,7 @@ $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); if (!optional_param('firstpage', 0, PARAM_INT)) { if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Add page: first page not found"); + print_error("Add page: first page not found"); } while (true) { if ($apageid) { diff --git a/mod/lesson/action/addcluster.php b/mod/lesson/action/addcluster.php index baf5aa0b6ad01..fc8025ea24785 100644 --- a/mod/lesson/action/addcluster.php +++ b/mod/lesson/action/addcluster.php @@ -16,11 +16,11 @@ if ($pageid == 0) { if (!$page = get_record("lesson_pages", "prevpageid", 0, "lessonid", $lesson->id)) { - error("Error: Add cluster: page record not found"); + print_error("Error: Add cluster: page record not found"); } } else { if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Error: Add cluster: page record not found"); + print_error("Error: Add cluster: page record not found"); } } $newpage = new stdClass; @@ -36,12 +36,12 @@ $newpage->title = get_string("clustertitle", "lesson"); $newpage->contents = get_string("clustertitle", "lesson"); if (!$newpageid = insert_record("lesson_pages", $newpage)) { - error("Insert page: new page not inserted"); + print_error("Insert page: new page not inserted"); } // update the linked list... if ($pageid != 0) { if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { - error("Add cluster: unable to update link"); + print_error("Add cluster: unable to update link"); } } @@ -51,7 +51,7 @@ if ($page->nextpageid) { // the new page is not the last page if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { - error("Insert page: unable to update previous link"); + print_error("Insert page: unable to update previous link"); } } // ..and the single "answer" @@ -61,7 +61,7 @@ $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_CLUSTERJUMP; if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { - error("Add cluster: answer record not inserted"); + print_error("Add cluster: answer record not inserted"); } lesson_set_message(get_string('addedcluster', 'lesson'), 'notifysuccess'); redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); diff --git a/mod/lesson/action/addendofbranch.php b/mod/lesson/action/addendofbranch.php index 5decb9f2f9fe5..83c025017274b 100644 --- a/mod/lesson/action/addendofbranch.php +++ b/mod/lesson/action/addendofbranch.php @@ -15,17 +15,17 @@ // the new page is not the first page (end of branch always comes after an existing page) if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Add end of branch: page record not found"); + print_error("Add end of branch: page record not found"); } // chain back up to find the (nearest branch table) $btpageid = $pageid; if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { - error("Add end of branch: btpage record not found"); + print_error("Add end of branch: btpage record not found"); } while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) { $btpageid = $btpage->prevpageid; if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { - error("Add end of branch: btpage record not found"); + print_error("Add end of branch: btpage record not found"); } } if ($btpage->qtype == LESSON_BRANCHTABLE) { @@ -38,16 +38,16 @@ $newpage->title = get_string("endofbranch", "lesson"); $newpage->contents = get_string("endofbranch", "lesson"); if (!$newpageid = insert_record("lesson_pages", $newpage)) { - error("Insert page: new page not inserted"); + print_error("Insert page: new page not inserted"); } // update the linked list... if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { - error("Add end of branch: unable to update link"); + print_error("Add end of branch: unable to update link"); } if ($page->nextpageid) { // the new page is not the last page if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { - error("Insert page: unable to update previous link"); + print_error("Insert page: unable to update previous link"); } } // ..and the single "answer" @@ -57,7 +57,7 @@ $newanswer->timecreated = $timenow; $newanswer->jumpto = $btpageid; if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { - error("Add end of branch: answer record not inserted"); + print_error("Add end of branch: answer record not inserted"); } lesson_set_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess'); diff --git a/mod/lesson/action/addendofcluster.php b/mod/lesson/action/addendofcluster.php index be1d261d9ff6d..23a085259b9a3 100644 --- a/mod/lesson/action/addendofcluster.php +++ b/mod/lesson/action/addendofcluster.php @@ -15,7 +15,7 @@ // the new page is not the first page (end of cluster always comes after an existing page) if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Error: Could not find page"); + print_error("Error: Could not find page"); } // could put code in here to check if the user really can insert an end of cluster @@ -29,16 +29,16 @@ $newpage->title = get_string("endofclustertitle", "lesson"); $newpage->contents = get_string("endofclustertitle", "lesson"); if (!$newpageid = insert_record("lesson_pages", $newpage)) { - error("Insert page: end of cluster page not inserted"); + print_error("Insert page: end of cluster page not inserted"); } // update the linked list... if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { - error("Add end of cluster: unable to update link"); + print_error("Add end of cluster: unable to update link"); } if ($page->nextpageid) { // the new page is not the last page if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { - error("Insert end of cluster: unable to update previous link"); + print_error("Insert end of cluster: unable to update previous link"); } } // ..and the single "answer" @@ -48,7 +48,7 @@ $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_NEXTPAGE; if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { - error("Add end of cluster: answer record not inserted"); + print_error("Add end of cluster: answer record not inserted"); } lesson_set_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess'); redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); \ No newline at end of file diff --git a/mod/lesson/action/confirmdelete.php b/mod/lesson/action/confirmdelete.php index 586312a6326c0..580d44bd928b4 100644 --- a/mod/lesson/action/confirmdelete.php +++ b/mod/lesson/action/confirmdelete.php @@ -10,7 +10,7 @@ $pageid = required_param('pageid', PARAM_INT); if (!$thispage = get_record("lesson_pages", "id", $pageid)) { - error("Confirm delete: the page record not found"); + print_error("Confirm delete: the page record not found"); } print_heading(get_string("deletingpage", "lesson", format_string($thispage->title))); // print the jumps to this page @@ -19,7 +19,7 @@ echo "

\n"; foreach ($answers as $answer) { if (!$title = get_field("lesson_pages", "title", "id", $answer->pageid)) { - error("Confirm delete: page title not found"); + print_error("Confirm delete: page title not found"); } echo $title."
\n"; } diff --git a/mod/lesson/action/continue.php b/mod/lesson/action/continue.php index e23fc86d36947..e0c13f34be45b 100644 --- a/mod/lesson/action/continue.php +++ b/mod/lesson/action/continue.php @@ -22,7 +22,7 @@ $timer = new stdClass; if (!has_capability('mod/lesson:manage', $context)) { if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) { - error('Error: could not find records'); + print_error('Error: could not find records'); } else { $timer = array_pop($timer); // this will get the latest start time record } @@ -43,14 +43,14 @@ $timer->lessontime = time(); if (!update_record("lesson_timer", $timer)) { - error("Error: could not update lesson_timer table"); + print_error("Error: could not update lesson_timer table"); } } // record answer (if necessary) and show response (if none say if answer is correct or not) $pageid = required_param('pageid', PARAM_INT); if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Continue: Page record not found"); + print_error("Continue: Page record not found"); } // set up some defaults $answerid = 0; @@ -69,7 +69,7 @@ $useranswer = clean_param($useranswer, PARAM_RAW); if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); + print_error("Continue: No answers found"); } $correctanswer = false; foreach ($answers as $answer) { @@ -94,7 +94,7 @@ $useranswer = stripslashes(clean_param($useranswer, PARAM_RAW)); $userresponse = addslashes($useranswer); if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); + print_error("Continue: No answers found"); } $i=0; foreach ($answers as $answer) { @@ -197,7 +197,7 @@ } $answerid = required_param('answerid', PARAM_INT); if (!$answer = get_record("lesson_answers", "id", $answerid)) { - error("Continue: answer record not found"); + print_error("Continue: answer record not found"); } if (lesson_iscorrect($pageid, $answer->jumpto)) { $correctanswer = true; @@ -230,7 +230,7 @@ $userresponse = implode(",", $useranswers); // get the answers in a set order, the id order if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); + print_error("Continue: No answers found"); } $ncorrect = 0; $nhits = 0; @@ -345,7 +345,7 @@ } $answerid = required_param('answerid', PARAM_INT); if (!$answer = get_record("lesson_answers", "id", $answerid)) { - error("Continue: answer record not found"); + print_error("Continue: answer record not found"); } if (lesson_iscorrect($pageid, $answer->jumpto)) { $correctanswer = true; @@ -374,7 +374,7 @@ } if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); + print_error("Continue: No answers found"); } $ncorrect = 0; @@ -455,7 +455,7 @@ } $studentanswer = $userresponse = $useranswer; if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); + print_error("Continue: No answers found"); } foreach ($answers as $answer) { if (strpos($answer->answer, ':')) { @@ -511,7 +511,7 @@ $branch->timeseen = time(); if (!insert_record("lesson_branch", $branch)) { - error("Error: could not insert row into lesson_branch table"); + print_error("Error: could not insert row into lesson_branch table"); } // this is called when jumping to random from a branch table @@ -571,7 +571,7 @@ $attempt->retry = $nretakes - 1; // they are going through on review, $nretakes will be too high } if (!$newattemptid = insert_record("lesson_attempts", $attempt)) { - error("Continue: attempt not inserted"); + print_error("Continue: attempt not inserted"); } // "number of attempts remaining" message if $lesson->maxattempts > 1 // displaying of message(s) is at the end of page for more ergonomic display @@ -721,7 +721,7 @@ } } elseif ($newpageid != LESSON_CLUSTERJUMP && $pageid != 0 && $newpageid > 0) { // going to check to see if the page that the user is going to view next, is a cluster page. If so, dont display, go into the cluster. The $newpageid > 0 is used to filter out all of the negative code jumps. if (!$page = get_record("lesson_pages", "id", $newpageid)) { - error("Error: could not find page"); + print_error("Error: could not find page"); } if ($page->qtype == LESSON_CLUSTER) { $newpageid = lesson_cluster_jump($lesson->id, $USER->id, $page->id); diff --git a/mod/lesson/action/delete.php b/mod/lesson/action/delete.php index 48aa1a84371e6..b747b50477d61 100644 --- a/mod/lesson/action/delete.php +++ b/mod/lesson/action/delete.php @@ -10,7 +10,7 @@ $pageid = required_param('pageid', PARAM_INT); if (!$thispage = get_record("lesson_pages", "id", $pageid)) { - error("Delete: page record not found"); + print_error("Delete: page record not found"); } // first delete all the associated records... @@ -24,32 +24,32 @@ if (!$thispage->prevpageid) { // this is the first page... if (!$page = get_record("lesson_pages", "id", $thispage->nextpageid)) { - error("Delete: next page not found"); + print_error("Delete: next page not found"); } if (!set_field("lesson_pages", "prevpageid", 0, "id", $page->id)) { - error("Delete: unable to set prevpage link"); + print_error("Delete: unable to set prevpage link"); } } elseif (!$thispage->nextpageid) { // this is the last page... if (!$page = get_record("lesson_pages", "id", $thispage->prevpageid)) { - error("Delete: prev page not found"); + print_error("Delete: prev page not found"); } if (!set_field("lesson_pages", "nextpageid", 0, "id", $page->id)) { - error("Delete: unable to set nextpage link"); + print_error("Delete: unable to set nextpage link"); } } else { // page is in the middle... if (!$prevpage = get_record("lesson_pages", "id", $thispage->prevpageid)) { - error("Delete: prev page not found"); + print_error("Delete: prev page not found"); } if (!$nextpage = get_record("lesson_pages", "id", $thispage->nextpageid)) { - error("Delete: next page not found"); + print_error("Delete: next page not found"); } if (!set_field("lesson_pages", "nextpageid", $nextpage->id, "id", $prevpage->id)) { - error("Delete: unable to set next link"); + print_error("Delete: unable to set next link"); } if (!set_field("lesson_pages", "prevpageid", $prevpage->id, "id", $nextpage->id)) { - error("Delete: unable to set prev link"); + print_error("Delete: unable to set prev link"); } } lesson_set_message(get_string('deletedpage', 'lesson').': '.format_string($thispage->title, true), 'notifysuccess'); diff --git a/mod/lesson/action/editpage.php b/mod/lesson/action/editpage.php index dbf47605934ab..aee538b99b6e8 100644 --- a/mod/lesson/action/editpage.php +++ b/mod/lesson/action/editpage.php @@ -12,7 +12,7 @@ $redirect = optional_param('redirect', '', PARAM_ALPHA); if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Edit page: page record not found"); + print_error("Edit page: page record not found"); } $page->qtype = optional_param('qtype', $page->qtype, PARAM_INT); @@ -34,12 +34,12 @@ } $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Edit page: first page not found"); + print_error("Edit page: first page not found"); } while (true) { if ($apageid) { if (!$apage = get_record("lesson_pages", "id", $apageid)) { - error("Edit page: apage record not found"); + print_error("Edit page: apage record not found"); } // removed != LESSON_ENDOFBRANCH... if (trim($page->title)) { // ...nor nuffin pages diff --git a/mod/lesson/action/insertpage.php b/mod/lesson/action/insertpage.php index e4217dd73e0cb..aeda9b80c860f 100644 --- a/mod/lesson/action/insertpage.php +++ b/mod/lesson/action/insertpage.php @@ -21,7 +21,7 @@ if ($form->pageid) { // the new page is not the first page if (!$page = get_record("lesson_pages", "id", $form->pageid)) { - error("Insert page: page record not found"); + print_error("Insert page: page record not found"); } $newpage->lessonid = clean_param($lesson->id, PARAM_INT); $newpage->prevpageid = clean_param($form->pageid, PARAM_INT); @@ -48,16 +48,16 @@ $newpage->title = addslashes($newpage->title); $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { - error("Insert page: new page not inserted"); + print_error("Insert page: new page not inserted"); } // update the linked list (point the previous page to this new one) if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $newpage->prevpageid)) { - error("Insert page: unable to update next link"); + print_error("Insert page: unable to update next link"); } if ($page->nextpageid) { // new page is not the last page if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { - error("Insert page: unable to update previous link"); + print_error("Insert page: unable to update previous link"); } } } else { @@ -90,7 +90,7 @@ $newpage->title = addslashes($newpage->title); $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { - error("Insert page: new first page not inserted"); + print_error("Insert page: new first page not inserted"); } } else { // there are existing pages put this at the start @@ -119,11 +119,11 @@ $newpage->title = addslashes($newpage->title); $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { - error("Insert page: first page not inserted"); + print_error("Insert page: first page not inserted"); } // update the linked list if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $newpage->nextpageid)) { - error("Insert page: unable to update link"); + print_error("Insert page: unable to update link"); } } } @@ -140,7 +140,7 @@ } $newanswerid = insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - error("Insert Page: answer record not inserted"); + print_error("Insert Page: answer record not inserted"); } } else { if ($form->qtype == LESSON_MATCHING) { @@ -166,7 +166,7 @@ } $newanswerid = insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - error("Insert Page: answer record $i not inserted"); + print_error("Insert Page: answer record $i not inserted"); } } else { if ($form->qtype == LESSON_MATCHING) { @@ -176,7 +176,7 @@ $newanswer->timecreated = $timenow; $newanswerid = insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - error("Insert Page: answer record $i not inserted"); + print_error("Insert Page: answer record $i not inserted"); } } } else { diff --git a/mod/lesson/action/move.php b/mod/lesson/action/move.php index fb296e753027d..0eca9f1c506b4 100644 --- a/mod/lesson/action/move.php +++ b/mod/lesson/action/move.php @@ -12,7 +12,7 @@ print_heading(get_string("moving", "lesson", format_string($title))); if (!$page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) { - error("Move: first page not found"); + print_error("Move: first page not found"); } echo "

\n"; @@ -29,7 +29,7 @@ } if ($page->nextpageid) { if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) { - error("Teacher view: Next page not found!"); + print_error("Teacher view: Next page not found!"); } } else { // last page reached diff --git a/mod/lesson/action/moveit.php b/mod/lesson/action/moveit.php index 2e2d095916501..08172e0707c56 100644 --- a/mod/lesson/action/moveit.php +++ b/mod/lesson/action/moveit.php @@ -10,7 +10,7 @@ $pageid = required_param('pageid', PARAM_INT); // page to move if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Moveit: page not found"); + print_error("Moveit: page not found"); } $after = required_param('after', PARAM_INT); // target page @@ -23,7 +23,7 @@ // (when the pages are in a ring this will in effect be the first page) if ($page->nextpageid) { if (!$after = get_field("lesson_pages", "id", "lessonid", $lesson->id, "nextpageid", 0)) { - error("Moveit: last page id not found"); + print_error("Moveit: last page id not found"); } } else { // the page being moved is the last page, so the new last page will be @@ -35,66 +35,66 @@ } else { // the current first page remains the first page if (!$newfirstpageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Moveit: current first page id not found"); + print_error("Moveit: current first page id not found"); } } // the rest is all unconditional... // second step. join pages into a ring if (!$firstpageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Moveit: firstpageid not found"); + print_error("Moveit: firstpageid not found"); } if (!$lastpageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "nextpageid", 0)) { - error("Moveit: lastpage not found"); + print_error("Moveit: lastpage not found"); } if (!set_field("lesson_pages", "prevpageid", $lastpageid, "id", $firstpageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } if (!set_field("lesson_pages", "nextpageid", $firstpageid, "id", $lastpageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } // third step. remove the page to be moved if (!$prevpageid = get_field("lesson_pages", "prevpageid", "id", $pageid)) { - error("Moveit: prevpageid not found"); + print_error("Moveit: prevpageid not found"); } if (!$nextpageid = get_field("lesson_pages", "nextpageid", "id", $pageid)) { - error("Moveit: nextpageid not found"); + print_error("Moveit: nextpageid not found"); } if (!set_field("lesson_pages", "nextpageid", $nextpageid, "id", $prevpageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } if (!set_field("lesson_pages", "prevpageid", $prevpageid, "id", $nextpageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } // fourth step. insert page to be moved in new place... if (!$nextpageid = get_field("lesson_pages", "nextpageid", "id", $after)) { - error("Movit: nextpageid not found"); + print_error("Movit: nextpageid not found"); } if (!set_field("lesson_pages", "nextpageid", $pageid, "id", $after)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } if (!set_field("lesson_pages", "prevpageid", $pageid, "id", $nextpageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } // ...and set the links in the moved page if (!set_field("lesson_pages", "prevpageid", $after, "id", $pageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } if (!set_field("lesson_pages", "nextpageid", $nextpageid, "id", $pageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } // fifth step. break the ring if (!$newlastpageid = get_field("lesson_pages", "prevpageid", "id", $newfirstpageid)) { - error("Moveit: newlastpageid not found"); + print_error("Moveit: newlastpageid not found"); } if (!set_field("lesson_pages", "prevpageid", 0, "id", $newfirstpageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } if (!set_field("lesson_pages", "nextpageid", 0, "id", $newlastpageid)) { - error("Moveit: unable to update link"); + print_error("Moveit: unable to update link"); } lesson_set_message(get_string('movedpage', 'lesson'), 'notifysuccess'); redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); diff --git a/mod/lesson/action/updatepage.php b/mod/lesson/action/updatepage.php index d54e179f62162..7b978ccfbd760 100644 --- a/mod/lesson/action/updatepage.php +++ b/mod/lesson/action/updatepage.php @@ -48,7 +48,7 @@ $page->title = addslashes($page->title); if (!update_record("lesson_pages", $page)) { - error("Update page: page not updated"); + print_error("Update page: page not updated"); } if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_ESSAY || $page->qtype == LESSON_CLUSTER || $page->qtype == LESSON_ENDOFCLUSTER) { // there's just a single answer with a jump @@ -66,13 +66,13 @@ foreach ($answers as $answer) { if ($answer->id != clean_param($form->answerid[0], PARAM_INT)) { if (!delete_records("lesson_answers", "id", $answer->id)) { - error("Update page: unable to delete answer record"); + print_error("Update page: unable to delete answer record"); } } } } if (!update_record("lesson_answers", $oldanswer)) { - error("Update page: EOB not updated"); + print_error("Update page: EOB not updated"); } } else { // it's an "ordinary" page @@ -107,7 +107,7 @@ $oldanswer->score = clean_param($form->score[$i], PARAM_INT); } if (!update_record("lesson_answers", $oldanswer)) { - error("Update page: answer $i not updated"); + print_error("Update page: answer $i not updated"); } } else { // it's a new answer @@ -133,7 +133,7 @@ } $newanswerid = insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - error("Update page: answer record not inserted"); + print_error("Update page: answer record not inserted"); } } } else { @@ -142,7 +142,7 @@ if ($form->answerid[$i]) { // need to delete blanked out answer if (!delete_records("lesson_answers", "id", clean_param($form->answerid[$i], PARAM_INT))) { - error("Update page: unable to delete answer record"); + print_error("Update page: unable to delete answer record"); } } } else { @@ -159,13 +159,13 @@ $oldanswer->timemodified = $timenow; $oldanswer->answer = NULL; if (!update_record("lesson_answers", $oldanswer)) { - error("Update page: answer $i not updated"); + print_error("Update page: answer $i not updated"); } } } elseif (!empty($form->answerid[$i])) { // need to delete blanked out answer if (!delete_records("lesson_answers", "id", clean_param($form->answerid[$i], PARAM_INT))) { - error("Update page: unable to delete answer record"); + print_error("Update page: unable to delete answer record"); } } } diff --git a/mod/lesson/backuplib.php b/mod/lesson/backuplib.php index a7259d840f944..451f9e46662d8 100644 --- a/mod/lesson/backuplib.php +++ b/mod/lesson/backuplib.php @@ -175,7 +175,7 @@ function backup_lesson_pages ($bf, $preferences, $lessonid) { // move to the next (logical) page if ($page->nextpageid) { if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) { - error("Lesson Backup: Next page not found!"); + print_error("Lesson Backup: Next page not found!"); } } else { // last page reached diff --git a/mod/lesson/edit.php b/mod/lesson/edit.php index a267e1b7ed4f7..e92507ea71048 100644 --- a/mod/lesson/edit.php +++ b/mod/lesson/edit.php @@ -24,13 +24,13 @@ if ($firstpage = get_record('lesson_pages', 'lessonid', $lesson->id, 'prevpageid', 0)) { if (!$pages = get_records('lesson_pages', 'lessonid', $lesson->id)) { - error('Could not find lesson pages'); + print_error('Could not find lesson pages'); } } if ($pageid) { if (!$singlepage = get_record('lesson_pages', 'id', $pageid)) { - error('Could not find page ID: '.$pageid); + print_error('Could not find page ID: '.$pageid); } } diff --git a/mod/lesson/essay.php b/mod/lesson/essay.php index bdccd0653fc21..2bda00e150c3a 100644 --- a/mod/lesson/essay.php +++ b/mod/lesson/essay.php @@ -65,16 +65,16 @@ $attemptid = required_param('attemptid', PARAM_INT); if (!$attempt = get_record('lesson_attempts', 'id', $attemptid)) { - error('Error: could not find attempt'); + print_error('Error: could not find attempt'); } if (!$page = get_record('lesson_pages', 'id', $attempt->pageid)) { - error('Error: could not find lesson page'); + print_error('Error: could not find lesson page'); } if (!$user = get_record('user', 'id', $attempt->userid)) { - error('Error: could not find users'); + print_error('Error: could not find users'); } if (!$answer = get_record('lesson_answers', 'lessonid', $lesson->id, 'pageid', $page->id)) { - error('Error: could not find answer'); + print_error('Error: could not find answer'); } break; case 'update': @@ -86,10 +86,10 @@ $attemptid = required_param('attemptid', PARAM_INT); if (!$attempt = get_record('lesson_attempts', 'id', $attemptid)) { - error('Error: could not find essay'); + print_error('Error: could not find essay'); } if (!$grades = get_records_select('lesson_grades', "lessonid = $lesson->id and userid = $attempt->userid", 'completed', '*', $attempt->retry, 1)) { - error('Error: could not find grades'); + print_error('Error: could not find grades'); } $essayinfo = new stdClass; @@ -108,7 +108,7 @@ $attempt->useranswer = addslashes(serialize($essayinfo)); if (!update_record('lesson_attempts', $attempt)) { - error('Could not update essay score'); + print_error('Could not update essay score'); } // Get grade information @@ -132,7 +132,7 @@ redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id"); } else { - error('Something is wrong with the form data'); + print_error('Something is wrong with the form data'); } break; case 'email': // Sending an email(s) to a single user or all @@ -142,7 +142,7 @@ if ($userid = optional_param('userid', 0, PARAM_INT)) { $queryadd = " AND userid = $userid"; if (! $users = get_records('user', 'id', $userid)) { - error('Error: could not find users'); + print_error('Error: could not find users'); } } else { $queryadd = ''; @@ -152,13 +152,13 @@ WHERE a.lessonid = '$lesson->id' and u.id = a.userid ORDER BY u.lastname")) { - error('Error: could not find users'); + print_error('Error: could not find users'); } } // Get lesson pages that are essay if (!$pages = get_records_select('lesson_pages', "lessonid = $lesson->id AND qtype = ".LESSON_ESSAY)) { - error('Error: could not find lesson pages'); + print_error('Error: could not find lesson pages'); } // Get only the attempts that are in response to essay questions @@ -214,7 +214,7 @@ // Log it add_to_log($course->id, 'lesson', 'update email essay grade', "essay.php?id=$cm->id", format_string($pages[$attempt->pageid]->title,true).': '.fullname($users[$attempt->userid]), $cm->id); } else { - error('Emailing Failed'); + print_error('Emailing Failed'); } } } diff --git a/mod/lesson/format.php b/mod/lesson/format.php index c547c7b01f850..7fbf98c6c46fe 100644 --- a/mod/lesson/format.php +++ b/mod/lesson/format.php @@ -92,11 +92,11 @@ function importprocess($filename, $lesson, $pageid) { $newpage->nextpageid = $page->nextpageid; // insert the page and reset $pageid if (!$newpageid = insert_record("lesson_pages", $newpage)) { - error("Format: Could not insert new page!"); + print_error("Format: Could not insert new page!"); } // update the linked list if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { - error("Format: unable to update link"); + print_error("Format: unable to update link"); } } else { @@ -108,7 +108,7 @@ function importprocess($filename, $lesson, $pageid) { $newpage->nextpageid = 0; // this is the only page $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { - error("Insert page: new first page not inserted"); + print_error("Insert page: new first page not inserted"); } } else { // there are existing pages put this at the start @@ -116,11 +116,11 @@ function importprocess($filename, $lesson, $pageid) { $newpage->nextpageid = $page->id; $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { - error("Insert page: first page not inserted"); + print_error("Insert page: first page not inserted"); } // update the linked list if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->id)) { - error("Insert page: unable to update link"); + print_error("Insert page: unable to update link"); } } } diff --git a/mod/lesson/grade.php b/mod/lesson/grade.php index 66d2c197e10fb..740730e371805 100644 --- a/mod/lesson/grade.php +++ b/mod/lesson/grade.php @@ -5,15 +5,15 @@ $id = required_param('id', PARAM_INT); // Course module ID if (! $cm = get_coursemodule_from_id('lesson', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $lesson = get_record("lesson", "id", $cm->instance)) { - error("lesson ID was incorrect"); + print_error("lesson ID was incorrect"); } if (! $course = get_record("course", "id", $lesson->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); diff --git a/mod/lesson/highscores.php b/mod/lesson/highscores.php index 858f5eb7a3c0e..b411a5dec4e38 100644 --- a/mod/lesson/highscores.php +++ b/mod/lesson/highscores.php @@ -26,7 +26,7 @@ case 'add': // Ensure that we came from view.php if (!confirm_sesskey() or !data_submitted("$CFG->wwwroot/mod/lesson/view.php")) { - error('Incorrect Form Data'); + print_error('Incorrect Form Data'); } break; @@ -55,19 +55,19 @@ } if (!$grades = get_records_select('lesson_grades', "lessonid = $lesson->id", 'completed')) { - error('Error: could not find grades'); + print_error('Error: could not find grades'); } if (!$newgrade = get_record_sql("SELECT * FROM {$CFG->prefix}lesson_grades WHERE lessonid = $lesson->id AND userid = $USER->id ORDER BY completed DESC", true)) { - error('Error: could not find newest grade'); + print_error('Error: could not find newest grade'); } // Check for multiple submissions if (record_exists('lesson_high_scores', 'gradeid', $newgrade->id)) { - error('Only one posting per grade'); + print_error('Only one posting per grade'); } // Find out if we need to delete any records @@ -116,7 +116,7 @@ $newhighscore->nickname = $name; if (!insert_record('lesson_high_scores', $newhighscore)) { - error("Insert of new high score Failed!"); + print_error("Insert of new high score Failed!"); } // Log it @@ -125,7 +125,7 @@ lesson_set_message(get_string('postsuccess', 'lesson'), 'notifysuccess'); redirect("$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id&link=1"); } else { - error('Something is wrong with the form data'); + print_error('Something is wrong with the form data'); } break; } diff --git a/mod/lesson/import.php b/mod/lesson/import.php index 8e41a64c38ab3..809e09a2a5224 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -16,15 +16,15 @@ $pageid = optional_param('pageid', '', PARAM_INT); // Page ID if (! $cm = get_coursemodule_from_id('lesson', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $lesson = get_record("lesson", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } @@ -52,7 +52,7 @@ } else { // Valid file is found if (! is_readable("$CFG->dirroot/question/format/$form->format/format.php")) { - error("Format not known ($form->format)"); + print_error("Format not known ($form->format)"); } require("format.php"); // Parent class @@ -62,15 +62,15 @@ $format = new $classname(); if (! $format->importpreprocess()) { // Do anything before that we need to - error("Error occurred during pre-processing!"); + print_error("Error occurred during pre-processing!"); } if (! $format->importprocess($_FILES['newfile']['tmp_name'], $lesson, $pageid)) { // Process the uploaded file - error("Error occurred during processing!"); + print_error("Error occurred during processing!"); } if (! $format->importpostprocess()) { // In case anything needs to be done after - error("Error occurred during post-processing!"); + print_error("Error occurred during post-processing!"); } echo "
"; diff --git a/mod/lesson/importppt.php b/mod/lesson/importppt.php index a407515be3ba8..2d61a9daf4e43 100644 --- a/mod/lesson/importppt.php +++ b/mod/lesson/importppt.php @@ -21,20 +21,20 @@ global $matches; if (! $cm = get_coursemodule_from_id('lesson', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } // allows for adaption for multiple modules if(! $modname = get_field('modules', 'name', 'id', $cm->module)) { - error("Could not find module name"); + print_error("Could not find module name"); } if (! $mod = get_record($modname, "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -68,10 +68,10 @@ $objects = $mod_create_objects($pageobjects, $mod->id); // function to preps the data to be sent to DB if(! $mod_save_objects($objects, $mod->id, $pageid)) { // sends it to DB - error("could not save"); + print_error("could not save"); } } else { - error('could not get data'); + print_error('could not get data'); } echo "
"; @@ -324,7 +324,7 @@ function build_list($list, &$i, $depth) { // set the depth number. So B1 is depth 1 and B2 is depth 2 and so on $this_depth = substr($class, 1); if (!is_numeric($this_depth)) { - error("Depth not parsed!"); + print_error("Depth not parsed!"); } } if ($this_depth < $depth) { @@ -544,13 +544,13 @@ function lesson_save_objects($branchtables, $lessonid, $after) { // insert the page if(!$id = insert_record('lesson_pages', $branchtable->page)) { - error("insert page"); + print_error("insert page"); } // update the link of the page previous to the one we just updated if ($prevpageid != 0) { // if not the first page if (!set_field("lesson_pages", "nextpageid", $id, "id", $prevpageid)) { - error("Insert page: unable to update next link $prevpageid"); + print_error("Insert page: unable to update next link $prevpageid"); } } @@ -558,7 +558,7 @@ function lesson_save_objects($branchtables, $lessonid, $after) { foreach ($branchtable->answers as $answer) { $answer->pageid = $id; if(!insert_record('lesson_answers', $answer)) { - error("insert answer $id"); + print_error("insert answer $id"); } } @@ -568,7 +568,7 @@ function lesson_save_objects($branchtables, $lessonid, $after) { // all done with inserts. Now check to update our last page (this is when we import between two lesson pages) if ($nextpageid != 0) { // if the next page is not the end of lesson if (!set_field("lesson_pages", "prevpageid", $id, "id", $nextpageid)) { - error("Insert page: unable to update next link $prevpageid"); + print_error("Insert page: unable to update next link $prevpageid"); } } @@ -582,7 +582,7 @@ function book_save_objects($chapters, $bookid, $pageid='0') { // nothing fancy, just save them all in order foreach ($chapters as $chapter) { if (!$chapter->id = insert_record('book_chapters', $chapter)) { - error('Could not update your book'); + print_error('Could not update your book'); } } return true; diff --git a/mod/lesson/index.php b/mod/lesson/index.php index ea33f44ebca7b..4433fc6d92799 100644 --- a/mod/lesson/index.php +++ b/mod/lesson/index.php @@ -14,7 +14,7 @@ $id = required_param('id', PARAM_INT); // course if (!$course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_login($course->id); diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index 902bae5b2096d..f4c0e194423d5 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -55,7 +55,7 @@ include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php'); break; default: - error("Fatal Error: Unknown action\n"); + print_error("Fatal Error: Unknown action\n"); } print_footer($course); diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index b6ab81fe8aa81..a25a4d03a230b 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -270,26 +270,26 @@ function lesson_print_header($cm, $course, $lesson, $currenttab = '') { function lesson_get_basics($cmid = 0, $lessonid = 0) { if ($cmid) { if (!$cm = get_coursemodule_from_id('lesson', $cmid)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (!$course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (!$lesson = get_record('lesson', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else if ($lessonid) { if (!$lesson = get_record('lesson', 'id', $lessonid)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } if (!$course = get_record('course', 'id', $lesson->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (!$cm = get_coursemodule_from_instance('lesson', $lesson->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } else { - error('No course module ID or lesson ID were passed'); + print_error('No course module ID or lesson ID were passed'); } return array($cm, $course, $lesson); @@ -1064,7 +1064,7 @@ function lesson_cluster_jump($lessonid, $userid, $pageid) { // get the lesson pages if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lessonid")) { - error("Error: could not find records in lesson_pages table"); + print_error("Error: could not find records in lesson_pages table"); } // find the start of the cluster while ($pageid != 0) { // this condition should not be satisfied... should be a cluster page @@ -1192,7 +1192,7 @@ function lesson_unseen_question_jump($lesson, $user, $pageid) { // get the lesson pages if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lesson")) { - error("Error: could not find records in lesson_pages table"); + print_error("Error: could not find records in lesson_pages table"); } if ($pageid == LESSON_UNSEENBRANCHPAGE) { // this only happens when a student leaves in the middle of an unseen question within a branch series @@ -1249,12 +1249,12 @@ function lesson_unseen_branch_jump($lessonid, $userid) { if (!$seenbranches = get_records_select("lesson_branch", "lessonid = $lessonid AND userid = $userid AND retry = $retakes", "timeseen DESC")) { - error("Error: could not find records in lesson_branch table"); + print_error("Error: could not find records in lesson_branch table"); } // get the lesson pages if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lessonid")) { - error("Error: could not find records in lesson_pages table"); + print_error("Error: could not find records in lesson_pages table"); } // this loads all the viewed branch tables into $seen untill it finds the branch table with the flag @@ -1301,7 +1301,7 @@ function lesson_unseen_branch_jump($lessonid, $userid) { function lesson_random_question_jump($lessonid, $pageid) { // get the lesson pages if (!$lessonpages = get_records_select("lesson_pages", "lessonid = $lessonid")) { - error("Error: could not find records in lesson_pages table"); + print_error("Error: could not find records in lesson_pages table"); } // go up the pages till branch table diff --git a/mod/lesson/mediafile.php b/mod/lesson/mediafile.php index fc52550fb256b..2839c1713aa66 100644 --- a/mod/lesson/mediafile.php +++ b/mod/lesson/mediafile.php @@ -19,15 +19,15 @@ $printclose = optional_param('printclose', 0, PARAM_INT); if (! $cm = get_coursemodule_from_id('lesson', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $lesson = get_record('lesson', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } require_login($course->id, false, $cm); @@ -142,7 +142,7 @@ //} else if ($mimetype == "application/x-shockwave-flash") { // It's a flash file - // error('Flash is not supported yet'); + // print_error('Flash is not supported yet'); } else if ($mimetype == "audio/x-pn-realaudio") { // It's a realmedia file diff --git a/mod/lesson/pagelib.php b/mod/lesson/pagelib.php index 868366fb9f5e2..c1291bd111b30 100644 --- a/mod/lesson/pagelib.php +++ b/mod/lesson/pagelib.php @@ -70,7 +70,7 @@ function print_header($title = '', $morenavlinks = array()) { $activityname = format_string($this->activityrecord->name); if ($this->lessonpageid === NULL) { - error('Programmer error: must set the lesson page ID'); + print_error('Programmer error: must set the lesson page ID'); } if (empty($title)) { $title = "{$this->courserecord->shortname}: $activityname"; diff --git a/mod/lesson/report.php b/mod/lesson/report.php index a0f0803cfbf17..15cf1c821983b 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -344,10 +344,10 @@ $try = optional_param('try', NULL, PARAM_INT); if (! $lessonpages = get_records("lesson_pages", "lessonid", $lesson->id)) { - error("Could not find Lesson Pages"); + print_error("Could not find Lesson Pages"); } if (! $pageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Could not find first page"); + print_error("Could not find first page"); } // now gather the stats into an object @@ -912,7 +912,7 @@ } else { - error("Fatal Error: Unknown Action: ".$action."\n"); + print_error("Fatal Error: Unknown Action: ".$action."\n"); } /// Finish the page diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index 38e4363d7f22f..9e35c8b5b9fb4 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -184,7 +184,7 @@ function lesson_pages_restore_mods($lessonid,$info,$restore,$userdata=false) { //Fix the forwards link of the previous page if ($prevpageid) { if (!set_field("lesson_pages", "nextpageid", $newid, "id", $prevpageid)) { - error("Lesson restorelib: unable to update link"); + print_error("Lesson restorelib: unable to update link"); } } $prevpageid = $newid; @@ -254,7 +254,7 @@ function lesson_pages_restore_mods($lessonid,$info,$restore,$userdata=false) { $page = backup_getid($restore->backup_unique_code,"lesson_pages",$answer->jumpto); if ($page) { if (!set_field("lesson_answers", "jumpto", $page->new_id, "id", $answer->id)) { - error("Lesson restorelib: unable to reset jump"); + print_error("Lesson restorelib: unable to reset jump"); } } } diff --git a/mod/lesson/tabs.php b/mod/lesson/tabs.php index 3c88a5b0393f7..4f27e65d09f05 100644 --- a/mod/lesson/tabs.php +++ b/mod/lesson/tabs.php @@ -12,7 +12,7 @@ /// This file to be included so we can assume config.php has already been included. if (empty($lesson)) { - error('You cannot call this script in that way'); + print_error('You cannot call this script in that way'); } if (!isset($currenttab)) { $currenttab = ''; diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 3243160def9bf..d1f5705f7dbee 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -250,7 +250,7 @@ // get the first page if (!$firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) { - error('Navigation: first page not found'); + print_error('Navigation: first page not found'); } lesson_print_header($cm, $course, $lesson); if ($lesson->timed) { @@ -309,7 +309,7 @@ } // start at the first page if (!$pageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) { - error('Navigation: first page not found'); + print_error('Navigation: first page not found'); } /// This is the code for starting a timed test if(!isset($USER->startlesson[$lesson->id]) && !has_capability('mod/lesson:manage', $context)) { @@ -321,7 +321,7 @@ $startlesson->lessontime = time(); if (!insert_record('lesson_timer', $startlesson)) { - error('Error: could not insert row into lesson_timer table'); + print_error('Error: could not insert row into lesson_timer table'); } if ($lesson->timed) { lesson_set_message(get_string('maxtimewarning', 'lesson', $lesson->maxtime), 'center'); @@ -339,10 +339,10 @@ $retries = 0; } if (!delete_records('lesson_attempts', 'userid', $USER->id, 'lessonid', $lesson->id, 'retry', $retries)) { - error('Error: could not delete old attempts'); + print_error('Error: could not delete old attempts'); } if (!delete_records('lesson_branch', 'userid', $USER->id, 'lessonid', $lesson->id, 'retry', $retries)) { - error('Error: could not delete old seen branches'); + print_error('Error: could not delete old seen branches'); } } } @@ -350,7 +350,7 @@ add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id); if (!$page = get_record('lesson_pages', 'id', $pageid)) { - error('Navigation: the page record not found'); + print_error('Navigation: the page record not found'); } if ($page->qtype == LESSON_CLUSTER) { //this only gets called when a user starts up a new lesson and the first page is a cluster page @@ -359,14 +359,14 @@ $pageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid); // get new page info if (!$page = get_record('lesson_pages', 'id', $pageid)) { - error('Navigation: the page record not found'); + print_error('Navigation: the page record not found'); } add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id); } else { // get the next page $pageid = $page->nextpageid; if (!$page = get_record('lesson_pages', 'id', $pageid)) { - error('Navigation: the page record not found'); + print_error('Navigation: the page record not found'); } } } elseif ($page->qtype == LESSON_ENDOFCLUSTER) { // Check for endofclusters @@ -408,7 +408,7 @@ break; } } else { - error('Navigation: No answers on EOB'); + print_error('Navigation: No answers on EOB'); } } @@ -425,7 +425,7 @@ $timer = new stdClass; if(!has_capability('mod/lesson:manage', $context)) { if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) { - error('Error: could not find records'); + print_error('Error: could not find records'); } else { $timer = array_pop($timer); // this will get the latest start time record } @@ -464,7 +464,7 @@ if (!has_capability('mod/lesson:manage', $context)) { $timer->lessontime = time(); if (!update_record('lesson_timer', $timer)) { - error('Error: could not update lesson_timer table'); + print_error('Error: could not update lesson_timer table'); } } @@ -546,7 +546,7 @@ $retries = count_records('lesson_grades', "lessonid", $lesson->id, "userid", $USER->id); $retries--; if (! $attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND userid = $USER->id AND pageid = $page->id AND retry = $retries", "timeseen")) { - error("Previous attempt record could not be found!"); + print_error("Previous attempt record could not be found!"); } $attempt = end($attempts); } @@ -829,14 +829,14 @@ if (!has_capability('mod/lesson:manage', $context)) { unset($USER->startlesson[$lesson->id]); if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) { - error('Error: could not find records'); + print_error('Error: could not find records'); } else { $timer = array_pop($timer); // this will get the latest start time record } $timer->lessontime = time(); if (!update_record("lesson_timer", $timer)) { - error("Error: could not update lesson_timer table"); + print_error("Error: could not update lesson_timer table"); } } @@ -889,21 +889,21 @@ if (!$lesson->practice) { if (isset($USER->modattempts[$lesson->id])) { // if reviewing, make sure update old grade record if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $USER->id", "completed")) { - error("Could not find Grade Records"); + print_error("Could not find Grade Records"); } $oldgrade = end($grades); $grade->id = $oldgrade->id; if (!$update = update_record("lesson_grades", $grade)) { - error("Navigation: grade not updated"); + print_error("Navigation: grade not updated"); } } else { if (!$newgradeid = insert_record("lesson_grades", $grade)) { - error("Navigation: grade not inserted"); + print_error("Navigation: grade not inserted"); } } } else { if (!delete_records("lesson_attempts", "lessonid", $lesson->id, "userid", $USER->id, "retry", $ntries)) { - error("Could not delete lesson attempts"); + print_error("Could not delete lesson attempts"); } } } else { @@ -916,7 +916,7 @@ $grade->completed = time(); if (!$lesson->practice) { if (!$newgradeid = insert_record("lesson_grades", $grade)) { - error("Navigation: grade not inserted"); + print_error("Navigation: grade not inserted"); } } echo get_string("eolstudentoutoftimenoanswers", "lesson"); diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index bbd185e1accbe..31fec0ea51fe6 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -28,23 +28,23 @@ if ($id) { if (! $cm = get_coursemodule_from_id('quiz', $id)) { - error("There is no coursemodule with id $id"); + print_error("There is no coursemodule with id $id"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $quiz = get_record("quiz", "id", $cm->instance)) { - error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing"); + print_error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing"); } } else { if (! $quiz = get_record("quiz", "id", $q)) { - error("There is no quiz with id $q"); + print_error("There is no quiz with id $q"); } if (! $course = get_record("course", "id", $quiz->course)) { - error("The course with id $quiz->course that the quiz with id $q belongs to is missing"); + print_error("The course with id $quiz->course that the quiz with id $q belongs to is missing"); } if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) { - error("The course module for the quiz with id $q is missing"); + print_error("The course module for the quiz with id $q is missing"); } } @@ -122,7 +122,7 @@ $messages = $accessmanager->prevent_access() + $accessmanager->prevent_new_attempt($attemptnumber - 1, $lastattempt); if (!$canpreview && $messages) { - error($accessmanager->print_messages($messages, true), + print_error($accessmanager->print_messages($messages, true), '', $CFG->wwwroot . '/mod/quiz/view.php?q=' . $quiz->id); } $accessmanager->do_password_check($canpreview); @@ -187,7 +187,7 @@ /// Restore the question sessions to their most recent states creating new sessions where required. if (!$states = get_question_states($questions, $quiz, $attempt, $lastattemptid)) { - error('Could not restore question sessions'); + print_error('Could not restore question sessions'); } /// If we are starting a new attempt, save all the newly created states. @@ -285,7 +285,7 @@ if (!$newattempt) { $messages = $accessmanager->prevent_access(); if (!$canpreview && $messages) { - error($accessmanager->print_messages($messages, true), + print_error($accessmanager->print_messages($messages, true), '', $CFG->wwwroot . '/mod/quiz/view.php?q=' . $quiz->id); } $accessmanager->do_password_check($canpreview); diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php index 721570a42b71b..c361577dab193 100644 --- a/mod/quiz/comment.php +++ b/mod/quiz/comment.php @@ -13,18 +13,18 @@ $questionid =required_param('question', PARAM_INT); // question id if (! $attempt = get_record('quiz_attempts', 'uniqueid', $attemptid)) { - error('No such attempt ID exists'); + print_error('No such attempt ID exists'); } if (! $quiz = get_record('quiz', 'id', $attempt->quiz)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } if (! $course = get_record('course', 'id', $quiz->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } // Teachers are only allowed to comment and grade on closed attempts if (!($attempt->timefinish > 0)) { - error('Attempt has not closed yet'); + print_error('Attempt has not closed yet'); } $cm = get_coursemodule_from_instance('quiz', $quiz->id); @@ -36,7 +36,7 @@ // Load question if (! $question = get_record('question', 'id', $questionid)) { - error('Question for this session is missing'); + print_error('Question for this session is missing'); } $question->maxgrade = get_field('quiz_question_instances', 'grade', 'quiz', $quiz->id, 'question', $question->id); // Some of the questions code is optimised to work with several questions @@ -45,7 +45,7 @@ $questions[$key] = &$question; // Add additional questiontype specific information to the question objects. if (!get_question_options($questions)) { - error("Unable to load questiontype specific question information"); + print_error("Unable to load questiontype specific question information"); } // Load state diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 76f2384c2f629..97fbf0bbcf67e 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -101,7 +101,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ // Get the course object and related bits. if (! $course = get_record("course", "id", $quiz->course)) { - error("This course doesn't exist"); + print_error("This course doesn't exist"); } // Log this visit. @@ -133,7 +133,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ // Avoid duplicate page breaks $quiz->questions = str_replace(',0,0', ',0', $quiz->questions); if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) { - error('Could not save question list'); + print_error('Could not save question list'); } } } @@ -150,7 +150,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ // Avoid duplicate page breaks $quiz->questions = str_replace(',0,0', ',0', $quiz->questions); if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) { - error('Could not save question list'); + print_error('Could not save question list'); } } } @@ -174,7 +174,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ $randomcount = required_param('randomcount', PARAM_INT); // load category if (! $category = get_record('question_categories', 'id', $categoryid)) { - error('Category ID is incorrect'); + print_error('Category ID is incorrect'); } $catcontext = get_context_instance_by_id($category->contextid); require_capability('moodle/question:useall', $catcontext); @@ -209,7 +209,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ $question->qtype = RANDOM; $question = $QTYPES[RANDOM]->save_question($question, $form, $course); if(!isset($question->id)) { - error('Could not insert new random question!'); + print_error('Could not insert new random question!'); } quiz_add_quiz_question($question->id, $quiz); } @@ -220,12 +220,12 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ if (isset($_REQUEST['questionsperpage'])) { $quiz->questionsperpage = required_param('questionsperpage', PARAM_INT); if (!set_field('quiz', 'questionsperpage', $quiz->questionsperpage, 'id', $quiz->id)) { - error('Could not save number of questions per page'); + print_error('Could not save number of questions per page'); } } $quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage); if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id)) { - error('Could not save layout'); + print_error('Could not save layout'); } } if (isset($_REQUEST['delete']) and confirm_sesskey()) { /// Remove a question from the quiz @@ -272,14 +272,14 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ $quiz->questions = str_replace(',0,0', ',0', $quiz->questions); } if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) { - error('Could not save question list'); + print_error('Could not save question list'); } } // If rescaling is required save the new maximum if (isset($_REQUEST['maxgrade'])) { if (!quiz_set_grade(optional_param('maxgrade', 0), $quiz)) { - error('Could not set a new maximum grade for the quiz'); + print_error('Could not set a new maximum grade for the quiz'); } } } @@ -319,7 +319,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ $sumgrades = quiz_print_question_list($quiz, $thispageurl, false, $quiz_showbreaks, $quiz_reordertool); if (!set_field('quiz', 'sumgrades', $sumgrades, 'id', $quiz->instance)) { - error('Failed to set sumgrades'); + print_error('Failed to set sumgrades'); } print_box_end(); @@ -346,7 +346,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){ $sumgrades = quiz_print_question_list($quiz, $thispageurl, true, $quiz_showbreaks, $quiz_reordertool); if (!set_field('quiz', 'sumgrades', $sumgrades, 'id', $quiz->instance)) { - error('Failed to set sumgrades'); + print_error('Failed to set sumgrades'); } print_box_end(); diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index 67f2c0b0c1677..1ea548f590b47 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -43,7 +43,7 @@ function quiz_delete_quiz_question($id, &$quiz) { $quiz->questions = str_replace(',0,0', ',0', $quiz->questions); // save new questionlist in database if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->instance)) { - error('Could not save question list'); + print_error('Could not save question list'); } delete_records('quiz_question_instances', 'quiz', $quiz->instance, 'question', $question); return true; @@ -86,7 +86,7 @@ function quiz_add_quiz_question($id, &$quiz) { // Save new questionslist in database $quiz->questions = implode(",", $questions); if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id)) { - error('Could not save question list'); + print_error('Could not save question list'); } // update question grades diff --git a/mod/quiz/grade.php b/mod/quiz/grade.php index 04e802344652c..dcbe4917553b3 100644 --- a/mod/quiz/grade.php +++ b/mod/quiz/grade.php @@ -5,15 +5,15 @@ $id = required_param('id', PARAM_INT); // Course module ID if (! $cm = get_coursemodule_from_id('quiz', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $quiz = get_record('quiz', 'id', $cm->instance)) { - error('quiz ID was incorrect'); + print_error('quiz ID was incorrect'); } if (! $course = get_record('course', 'id', $quiz->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } require_login($course->id, false, $cm); diff --git a/mod/quiz/index.php b/mod/quiz/index.php index 3193bda57d657..e29ee821bcb16 100644 --- a/mod/quiz/index.php +++ b/mod/quiz/index.php @@ -11,7 +11,7 @@ $id = required_param('id', PARAM_INT); if (!$course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } $coursecontext = get_context_instance(CONTEXT_COURSE, $id); require_login($course->id); diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index e98499d8dc391..f570613b16666 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -92,7 +92,7 @@ function quiz_create_attempt($quiz, $attemptnumber, $lastattempt, $timenow, $isp } else { /// Build on last attempt. if (empty($lastattempt)) { - error(get_string('cannotfindprevattempt', 'quiz')); + print_error('cannotfindprevattempt', 'quiz'); } $attempt = $lastattempt; } diff --git a/mod/quiz/pagelib.php b/mod/quiz/pagelib.php index d6d43b0ac0f54..698dd341870de 100644 --- a/mod/quiz/pagelib.php +++ b/mod/quiz/pagelib.php @@ -20,7 +20,7 @@ class page_quiz extends page_generic_activity { function init_quick($data) { if(empty($data->pageid)) { - error('Cannot quickly initialize page: empty course id'); + print_error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'quiz'; parent::init_quick($data); diff --git a/mod/quiz/quizfile.php b/mod/quiz/quizfile.php index 44d3b0f9348a7..049870d54ba75 100644 --- a/mod/quiz/quizfile.php +++ b/mod/quiz/quizfile.php @@ -20,13 +20,13 @@ $relativepath = get_file_argument('quizfile.php'); if (!$relativepath) { - error('No valid arguments supplied or incorrect server configuration'); + print_error('No valid arguments supplied or incorrect server configuration'); } // extract relative path components $args = explode('/', trim($relativepath, '/')); if (count($args) < 3) { // always at least category, question and path - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } $quizid = (int)array_shift($args); @@ -34,11 +34,11 @@ $relativepath = implode ('/', $args); if (!($question = get_record('question', 'id', $questionid))) { - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } if (!($questioncategory = get_record('question_categories', 'id', $question->category))) { - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } ///////////////////////////////////// @@ -48,7 +48,7 @@ if ($questioncategory->publish) { require_login(); if (!isteacherinanycourse()) { - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } } else { require_login($questioncategory->course); @@ -57,10 +57,10 @@ } } else { if (!($quiz = get_record('quiz', 'id', $quizid))) { - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } if (!($course = get_record('course', 'id', $quiz->course))) { - error('No valid arguments supplied'); + print_error('No valid arguments supplied'); } require_login($course->id); @@ -71,7 +71,7 @@ // and ! ($quiz->review && time() > $quiz->timeclose) // || !quiz_get_user_attempts($quiz->id, $USER->id) ) //{ - // error("Logged-in user is not allowed to view this quiz"); + // print_error("Logged-in user is not allowed to view this quiz"); //} /////////////////////////////////////////////////// @@ -82,14 +82,14 @@ // For now, let's not worry about this. The following check doesn't // work for randomly selected questions and it gets complicated //if (!in_array($question->id, explode(',', $quiz->questions), FALSE)) { - // error("Specified question is not on the specified quiz"); + // print_error("Specified question is not on the specified quiz"); //} } // Have the question check whether it uses this file or not if (!$QTYPES[$question->qtype]->uses_quizfile($question, $relativepath)) { - error("The specified file path is not on the specified question"); + print_error("The specified file path is not on the specified question"); } @@ -106,6 +106,6 @@ send_file($pathname, $filename, $lifetime); } else { header('HTTP/1.0 404 not found'); - error(get_string('filenotfound', 'error')); //this is not displayed on IIS?? + print_error('filenotfound', 'error'); //this is not displayed on IIS?? } ?> diff --git a/mod/quiz/report.php b/mod/quiz/report.php index 33f01a307479f..4b24e6cd3d361 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -12,26 +12,26 @@ if ($id) { if (! $cm = get_coursemodule_from_id('quiz', $id)) { - error("There is no coursemodule with id $id"); + print_error("There is no coursemodule with id $id"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $quiz = get_record("quiz", "id", $cm->instance)) { - error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing"); + print_error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing"); } } else { if (! $quiz = get_record("quiz", "id", $q)) { - error("There is no quiz with id $q"); + print_error("There is no quiz with id $q"); } if (! $course = get_record("course", "id", $quiz->course)) { - error("The course with id $quiz->course that the quiz with id $q belongs to is missing"); + print_error("The course with id $quiz->course that the quiz with id $q belongs to is missing"); } if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) { - error("The course module for the quiz with id $q is missing"); + print_error("The course module for the quiz with id $q is missing"); } } @@ -61,7 +61,7 @@ $mode = clean_param($mode, PARAM_SAFEDIR); if (! is_readable("report/$mode/report.php")) { - error("Report not known ($mode)"); + print_error("Report not known ($mode)"); } include("report/default.php"); // Parent class @@ -70,7 +70,7 @@ $report = new quiz_report(); if (! $report->display($quiz, $cm, $course)) { // Run the report! - error("Error occurred during pre-processing!"); + print_error("Error occurred during pre-processing!"); } /// Print footer diff --git a/mod/quiz/report/analysis/report.php b/mod/quiz/report/analysis/report.php index 5eae82d89fbf4..dac42cf6bad7a 100644 --- a/mod/quiz/report/analysis/report.php +++ b/mod/quiz/report/analysis/report.php @@ -142,17 +142,17 @@ function display($quiz, $cm, $course) { /// This function just displays the " AND q.id IN ($questionlist)"; if (!$quizquestions = get_records_sql($sql)) { - error('No questions found'); + print_error('No questions found'); } // Load the question type specific information if (!get_question_options($quizquestions)) { - error('Could not load question options'); + print_error('Could not load question options'); } // Restore the question sessions to their most recent states // creating new sessions where required if (!$states = get_question_states($quizquestions, $quiz, $attempt)) { - error('Could not restore question sessions'); + print_error('Could not restore question sessions'); } $numbers = explode(',', $questionlist); $statsrow = array(); @@ -488,17 +488,17 @@ function get_questions_atttempts_data ($quiz,&$questions,&$attempts,$attemptsele " AND q.id IN ($questionlist)"; if (!$quizquestions = get_records_sql($sql)) { - error('No questions found'); + print_error('No questions found'); } // Load the question type specific information if (!get_question_options($quizquestions)) { - error('Could not load question options'); + print_error('Could not load question options'); } // Restore the question sessions to their most recent states // creating new sessions where required if (!$states = get_question_states($quizquestions, $quiz, $attempt)) { - error('Could not restore question sessions'); + print_error('Could not restore question sessions'); } $numbers = explode(',', $questionlist); $statsrow = array(); diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index 3298bcd7ee9b3..de08bf6cd76a2 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -43,7 +43,7 @@ function display($quiz, $cm, $course) { if (!empty($questionid)) { if (! $question = get_record('question', 'id', $questionid)) { - error("Question with id $questionid not found"); + print_error("Question with id $questionid not found"); } $question->maxgrade = get_field('quiz_question_instances', 'grade', 'quiz', $quiz->id, 'question', $question->id); @@ -56,7 +56,7 @@ function display($quiz, $cm, $course) { // We need to add additional questiontype specific information to // the question objects. if (!get_question_options($questions)) { - error("Unable to load questiontype specific question information"); + print_error("Unable to load questiontype specific question information"); } // This will have extended the question object so that it now holds // all the information about the questions that may be needed later. @@ -73,7 +73,7 @@ function display($quiz, $cm, $course) { foreach($data->manualgrades as $uniqueid => $response) { // get our attempt if (! $attempt = get_record('quiz_attempts', 'uniqueid', $uniqueid)) { - error('No such attempt ID exists'); + print_error('No such attempt ID exists'); } // Load the state for this attempt (The questions array was created earlier) @@ -311,7 +311,7 @@ function is_graded($question, $attempt) { WHERE sess.newest = state.id AND sess.attemptid = $attempt->uniqueid AND sess.questionid = $question->id")) { - error('Could not find question state'); + print_error('Could not find question state'); } return question_state_is_graded($state); diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index 75865a6fb9dc1..1774e9316542c 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -127,7 +127,7 @@ function display($quiz, $cm, $course) { " WHERE i.quiz = '$quiz->id' AND q.id = i.question". " AND q.id IN ($questionlist)"; if (!$questions = get_records_sql($sql)) { - error('No questions found'); + print_error('No questions found'); } $number = 1; foreach ($questionids as $key => $id) { diff --git a/mod/quiz/report/regrade/report.php b/mod/quiz/report/regrade/report.php index 2c0ea4d2b00d3..8f00b09cbc025 100644 --- a/mod/quiz/report/regrade/report.php +++ b/mod/quiz/report/regrade/report.php @@ -31,7 +31,7 @@ function display($quiz, $cm, $course) { AND i.question = q.id"; if (! $questions = get_records_sql($sql)) { - error("Failed to get questions for regrading!"); + print_error("Failed to get questions for regrading!"); } get_question_options($questions); diff --git a/mod/quiz/review.php b/mod/quiz/review.php index c6bf8deebd100..b6e7cf8c8569e 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -18,16 +18,16 @@ $showall = optional_param('showall', 0, PARAM_BOOL); if (!$attempt = quiz_load_attempt($attemptid)) { - error("No such attempt ID exists"); + print_error("No such attempt ID exists"); } if (! $quiz = get_record("quiz", "id", $attempt->quiz)) { - error("The quiz with id $attempt->quiz belonging to attempt $attempt is missing"); + print_error("The quiz with id $attempt->quiz belonging to attempt $attempt is missing"); } if (! $course = get_record("course", "id", $quiz->course)) { - error("The course with id $quiz->course that the quiz with id $quiz->id belongs to is missing"); + print_error("The course with id $quiz->course that the quiz with id $quiz->id belongs to is missing"); } if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) { - error("The course module for the quiz with id $quiz->id is missing"); + print_error("The course module for the quiz with id $quiz->id is missing"); } /// Check login and get contexts. @@ -81,7 +81,7 @@ /// Restore the question sessions to their most recent states creating new sessions where required. if (!$states = get_question_states($questions, $quiz, $attempt)) { - error('Could not restore question sessions'); + print_error('Could not restore question sessions'); } /// Work out appropriate title. diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index b1018a2149ba5..aa1441bcb9e29 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -21,39 +21,39 @@ if ($stateid) { if (! $state = get_record('question_states', 'id', $stateid)) { - error('Invalid state id'); + print_error('Invalid state id'); } if (! $attempt = get_record('quiz_attempts', 'uniqueid', $state->attempt)) { - error('No such attempt ID exists'); + print_error('No such attempt ID exists'); } } elseif ($attemptid) { if (! $attempt = get_record('quiz_attempts', 'id', $attemptid)) { - error('No such attempt ID exists'); + print_error('No such attempt ID exists'); } if (! $neweststateid = get_field('question_sessions', 'newest', 'attemptid', $attempt->uniqueid, 'questionid', $questionid)) { // newest_state not set, probably because this is an old attempt from the old quiz module code if (! $state = get_record('question_states', 'question', $questionid, 'attempt', $attempt->uniqueid)) { - error('Invalid question id'); + print_error('Invalid question id'); } } else { if (! $state = get_record('question_states', 'id', $neweststateid)) { - error('Invalid state id'); + print_error('Invalid state id'); } } } else { - error('Parameter missing'); + print_error('Parameter missing'); } if (! $question = get_record('question', 'id', $state->question)) { - error('Question for this state is missing'); + print_error('Question for this state is missing'); } if (! $quiz = get_record('quiz', 'id', $attempt->quiz)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } if (! $course = get_record('course', 'id', $quiz->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } require_login($course->id, false, $cm); @@ -66,18 +66,18 @@ // If not even responses are to be shown in review then we // don't allow any review if (!($quiz->review & QUIZ_REVIEW_RESPONSES)) { - error(get_string("noreview", "quiz")); + print_error("noreview", "quiz"); } if ((time() - $attempt->timefinish) > 120) { // always allow review right after attempt if ((!$quiz->timeclose or time() < $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_OPEN)) { - error(get_string("noreviewuntil", "quiz", userdate($quiz->timeclose))); + print_error("noreviewuntil", "quiz", '', userdate($quiz->timeclose)); } if ($quiz->timeclose and time() >= $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_CLOSED)) { - error(get_string("noreview", "quiz")); + print_error("noreview", "quiz"); } } if ($attempt->userid != $USER->id) { - error('This is not your attempt!'); + print_error('This is not your attempt!'); } } @@ -101,7 +101,7 @@ $questions[$key] = &$question; // Add additional questiontype specific information to the question objects. if (!get_question_options($questions)) { - error("Unable to load questiontype specific question information"); + print_error("Unable to load questiontype specific question information"); } $session = get_record('question_sessions', 'attemptid', $attempt->uniqueid, 'questionid', $question->id); diff --git a/mod/quiz/tabs.php b/mod/quiz/tabs.php index 55d3b96f09009..a6f9b75c6b6ec 100644 --- a/mod/quiz/tabs.php +++ b/mod/quiz/tabs.php @@ -8,7 +8,7 @@ */ if (empty($quiz)) { - error('You cannot call this script in that way'); + print_error('You cannot call this script in that way'); } if (!isset($currenttab)) { $currenttab = ''; diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 13a33fb879757..c28ebc0ca9090 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -13,23 +13,23 @@ if ($id) { if (! $cm = get_coursemodule_from_id('quiz', $id)) { - error("There is no coursemodule with id $id"); + print_error("There is no coursemodule with id $id"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $quiz = get_record("quiz", "id", $cm->instance)) { - error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing"); + print_error("The quiz with id $cm->instance corresponding to this coursemodule $id is missing"); } } else { if (! $quiz = get_record("quiz", "id", $q)) { - error("There is no quiz with id $q"); + print_error("There is no quiz with id $q"); } if (! $course = get_record("course", "id", $quiz->course)) { - error("The course with id $quiz->course that the quiz with id $q belongs to is missing"); + print_error("The course with id $quiz->course that the quiz with id $q belongs to is missing"); } if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) { - error("The course module for the quiz with id $q is missing"); + print_error("The course module for the quiz with id $q is missing"); } } diff --git a/mod/resource/index.php b/mod/resource/index.php index 807c029d1b36e..a611aa9245d02 100644 --- a/mod/resource/index.php +++ b/mod/resource/index.php @@ -5,7 +5,7 @@ $id = required_param( 'id', PARAM_INT ); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course, true); diff --git a/mod/resource/lib.php b/mod/resource/lib.php index 3cc8b2d62c08a..252426f3a3571 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -39,15 +39,15 @@ function resource_base($cmid=0) { if ($cmid) { if (! $this->cm = get_coursemodule_from_id('resource', $cmid)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $this->course = get_record("course", "id", $this->cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $this->resource = get_record("resource", "id", $this->cm->instance)) { - error("Resource ID was incorrect"); + print_error("Resource ID was incorrect"); } $this->strresource = get_string("modulename", "resource"); @@ -598,7 +598,7 @@ function resource_renamefiles($course, $wdir, $oldname, $name) { $status .= "
  • wwwroot/mod/resource/view.php?id=$resource->cmid\" target=\"_blank\">$resource->name: $resource->reference ==> $r->reference
  • "; if (!empty($CFG->resource_autofilerename)) { if (!update_record('resource', $r)) { - error("Error updating resource with ID $r->id."); + print_error("Error updating resource with ID $r->id."); } } } diff --git a/mod/resource/mod_form.php b/mod/resource/mod_form.php index ed7a6156904ae..b3dbe33a5a02f 100644 --- a/mod/resource/mod_form.php +++ b/mod/resource/mod_form.php @@ -13,7 +13,7 @@ function definition() { if($res = get_record('resource', 'id', (int)$this->_instance)) { $type = $res->type; } else { - error('incorrect assignment'); + print_error('incorrect assignment'); } } else { $type = required_param('type', PARAM_ALPHA); diff --git a/mod/resource/type/directory/resource.class.php b/mod/resource/type/directory/resource.class.php index 292e4616252c5..e517f0342251f 100644 --- a/mod/resource/type/directory/resource.class.php +++ b/mod/resource/type/directory/resource.class.php @@ -55,7 +55,7 @@ function display() { if ($subdir) { $relativepath = "$relativepath$subdir"; if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) { - error("Access not allowed!"); + print_error("Access not allowed!"); } $subs = explode('/', $subdir); diff --git a/mod/resource/type/file/localfile.php b/mod/resource/type/file/localfile.php index bf5232d7e8098..29b3cae7ff92c 100644 --- a/mod/resource/type/file/localfile.php +++ b/mod/resource/type/file/localfile.php @@ -8,7 +8,7 @@ require_login(); if (!$CFG->resource_allowlocalfiles) { - error('You cannot access this script'); + print_error('You cannot access this script'); } print_header(get_string('localfilechoose', 'resource')); diff --git a/mod/resource/view.php b/mod/resource/view.php index aeb9c392c529d..9a344baf71a0a 100644 --- a/mod/resource/view.php +++ b/mod/resource/view.php @@ -8,27 +8,27 @@ if ($r) { // Two ways to specify the resource if (! $resource = get_record('resource', 'id', $r)) { - error('Resource ID was incorrect'); + print_error('Resource ID was incorrect'); } if (! $cm = get_coursemodule_from_instance('resource', $resource->id, $resource->course)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } else if ($id) { if (! $cm = get_coursemodule_from_id('resource', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $resource = get_record('resource', 'id', $cm->instance)) { - error('Resource ID was incorrect'); + print_error('Resource ID was incorrect'); } } else { - error('No valid parameters!!'); + print_error('No valid parameters!!'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Incorrect course id'); + print_error('Incorrect course id'); } require_course_login($course, true, $cm); diff --git a/mod/scorm/aicc.php b/mod/scorm/aicc.php index 64b2de3a26c72..a17de5384b416 100755 --- a/mod/scorm/aicc.php +++ b/mod/scorm/aicc.php @@ -14,7 +14,7 @@ if (isset($SESSION->scorm_scoid)) { $scoid = $SESSION->scorm_scoid; } else { - error('Invalid script call'); + print_error('Invalid script call'); } $mode = 'normal'; if (isset($SESSION->scorm_mode)) { @@ -32,10 +32,10 @@ if ($sco = scorm_get_sco($scoid, SCO_ONLY)) { if (!$scorm = get_record('scorm','id',$sco->scorm)) { - error('Invalid script call'); + print_error('Invalid script call'); } } else { - error('Invalid script call'); + print_error('Invalid script call'); } if ($scorm = get_record('scorm','id',$sco->scorm)) { @@ -129,7 +129,7 @@ echo 'Max_Time_Allowed = '.$userdata->maxtimeallowed."\n"; echo 'Time_Limit_Action = '.$userdata->timelimitaction."\n"; } else { - error('Sco not found'); + print_error('Sco not found'); } } break; diff --git a/mod/scorm/api.php b/mod/scorm/api.php index 97b4c3817e8d5..c6dd808411fd3 100644 --- a/mod/scorm/api.php +++ b/mod/scorm/api.php @@ -11,26 +11,26 @@ if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else if (!empty($a)) { if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } else { - error('A required parameter is missing'); + print_error('A required parameter is missing'); } require_login($course->id, false, $cm); @@ -62,7 +62,7 @@ $userdata->$key = $value; } } else { - error('Sco not found'); + print_error('Sco not found'); } $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) { diff --git a/mod/scorm/datamodel.php b/mod/scorm/datamodel.php index d7c6d8766eafc..c0a4e0c73ff7f 100755 --- a/mod/scorm/datamodel.php +++ b/mod/scorm/datamodel.php @@ -11,26 +11,26 @@ if (!empty($id)) { if (! $cm = get_record("course_modules", "id", $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else if (!empty($a)) { if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } else { - error('A required parameter is missing'); + print_error('A required parameter is missing'); } require_login($course->id, false, $cm); diff --git a/mod/scorm/index.php b/mod/scorm/index.php index 5e4fc4ffc136f..72089d765e8ab 100755 --- a/mod/scorm/index.php +++ b/mod/scorm/index.php @@ -7,10 +7,10 @@ if (!empty($id)) { if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } } else { - error('A required parameter is missing'); + print_error('A required parameter is missing'); } require_course_login($course); diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php index fb3804656ff55..f6225c44a7500 100755 --- a/mod/scorm/loadSCO.php +++ b/mod/scorm/loadSCO.php @@ -10,26 +10,26 @@ if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $scorm = get_record('scorm', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else if (!empty($a)) { if (! $scorm = get_record('scorm', 'id', $a)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } if (! $course = get_record('course', 'id', $scorm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } else { - error('A required parameter is missing'); + print_error('A required parameter is missing'); } require_login($course->id, false, $cm); diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 6440daa8426ad..5996e05130567 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -467,7 +467,7 @@ function scorm_course_format_display($user,$course) { // The module SCORM activity with the least id is the course $scorm = current($scorms); if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } $colspan = ''; $headertext = '
    '.get_string('name').': '.format_string($scorm->name).''; diff --git a/mod/scorm/player.php b/mod/scorm/player.php index d6ca13d317f41..7ac0f3f372041 100755 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -17,26 +17,26 @@ if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else if (!empty($a)) { if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } else { - error('A required parameter is missing'); + print_error('A required parameter is missing'); } require_login($course->id, false, $cm); diff --git a/mod/scorm/report.php b/mod/scorm/report.php index 661eac7c4c573..f60422ade4f51 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -13,30 +13,30 @@ if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $scorm = get_record('scorm', 'id', $cm->instance)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } } else { if (!empty($b)) { if (! $sco = get_record('scorm_scoes', 'id', $b)) { - error('Scorm activity is incorrect'); + print_error('Scorm activity is incorrect'); } $a = $sco->scorm; } if (!empty($a)) { if (! $scorm = get_record('scorm', 'id', $a)) { - error('Course module is incorrect'); + print_error('Course module is incorrect'); } if (! $course = get_record('course', 'id', $scorm->course)) { - error('Course is misconfigured'); + print_error('Course is misconfigured'); } if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } } } @@ -44,7 +44,7 @@ require_login($course->id, false, $cm); if (!has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE,$cm->id))) { - error('You are not allowed to use this script'); + print_error('You are not allowed to use this script'); } add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id); @@ -403,7 +403,7 @@ } print_simple_box_end(); } else { - error('Missing script parameter'); + print_error('Missing script parameter'); } } diff --git a/mod/scorm/view.php b/mod/scorm/view.php index cbfe4b16bde0b..19ecf86d5d7d6 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -9,26 +9,26 @@ if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else if (!empty($a)) { if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } else { - error('A required parameter is missing'); + print_error('A required parameter is missing'); } require_login($course->id, false, $cm); diff --git a/mod/survey/download.php b/mod/survey/download.php index bb8f28cd11202..eb966aae06aed 100644 --- a/mod/survey/download.php +++ b/mod/survey/download.php @@ -9,18 +9,18 @@ $group = optional_param('group', 0, PARAM_INT); if (! $cm = get_record("course_modules", "id", $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); require_capability('mod/survey:download', get_context_instance(CONTEXT_MODULE, $cm->id)) ; if (! $survey = get_record("survey", "id", $cm->instance)) { - error("Survey ID was incorrect"); + print_error("Survey ID was incorrect"); } add_to_log($course->id, "survey", "download", "download.php?id=$cm->id&type=$type", "$survey->id", $cm->id); @@ -99,7 +99,7 @@ // Get and collate all the results in one big array if (! $aaa = get_records("survey_answers", "survey", "$survey->id", "time ASC")) { - error("There are no answers for this survey yet."); + print_error("There are no answers for this survey yet."); } foreach ($aaa as $a) { @@ -153,7 +153,7 @@ $col = 0; $row++; if (! $u = get_record("user", "id", $user)) { - error("Error finding student # $user"); + print_error("Error finding student # $user"); } if ($n = get_record("survey_analysis", "survey", $survey->id, "userid", $user)) { $notes = $n->notes; @@ -223,7 +223,7 @@ $col = 0; $row++; if (! $u = get_record("user", "id", $user)) { - error("Error finding student # $user"); + print_error("Error finding student # $user"); } if ($n = get_record("survey_analysis", "survey", $survey->id, "userid", $user)) { $notes = $n->notes; @@ -283,7 +283,7 @@ foreach ($results as $user => $rest) { if (! $u = get_record("user", "id", $user)) { - error("Error finding student # $user"); + print_error("Error finding student # $user"); } echo $survey->id."\t"; echo strip_tags(format_string($survey->name,true))."\t"; diff --git a/mod/survey/graph.php b/mod/survey/graph.php index 62e10d58ccde9..4d2e9c5edc7db 100644 --- a/mod/survey/graph.php +++ b/mod/survey/graph.php @@ -11,11 +11,11 @@ $qid = optional_param('qid', 0, PARAM_INT); // Group ID if (! $cm = get_coursemodule_from_id('survey', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); @@ -25,14 +25,14 @@ if (!has_capability('mod/survey:readresponses', $context)) { if ($type != "student.png" or $sid != $USER->id ) { - error("Sorry, you aren't allowed to see this."); + print_error("Sorry, you aren't allowed to see this."); } else if ($groupmode and !groups_is_member($group)) { - error("Sorry, you aren't allowed to see this."); + print_error("Sorry, you aren't allowed to see this."); } } if (! $survey = get_record("survey", "id", $cm->instance)) { - error("Survey ID was incorrect"); + print_error("Survey ID was incorrect"); } /// Check to see if groups are being used in this survey diff --git a/mod/survey/index.php b/mod/survey/index.php index 217bb13ae8aa0..26327b212f044 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -6,7 +6,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/survey/mod_form.php b/mod/survey/mod_form.php index 2c0f4696fe1f3..573f1256bf4b9 100644 --- a/mod/survey/mod_form.php +++ b/mod/survey/mod_form.php @@ -18,7 +18,7 @@ function definition() { $mform->addRule('name', null, 'required', null, 'client'); if (!$options = get_records_menu("survey", "template", 0, "name", "id, name")) { - error('No survey templates found!'); + print_error('No survey templates found!'); } foreach ($options as $id => $name) { diff --git a/mod/survey/report.php b/mod/survey/report.php index a585b73f546a8..ea1a154c56dd7 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -16,11 +16,11 @@ $qid = implode (',', $qids); if (! $cm = get_coursemodule_from_id('survey', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); @@ -30,11 +30,11 @@ require_capability('mod/survey:readresponses', $context); if (! $survey = get_record("survey", "id", $cm->instance)) { - error("Survey ID was incorrect"); + print_error("Survey ID was incorrect"); } if (! $template = get_record("survey", "id", $survey->template)) { - error("Template ID was incorrect"); + print_error("Template ID was incorrect"); } $showscales = ($template->name != 'ciqname'); @@ -257,7 +257,7 @@ case "question": if (!$question = get_record("survey_questions", "id", $qid)) { - error("Question doesn't exist"); + print_error("Question doesn't exist"); } $question->text = get_string($question->text, "survey"); @@ -317,7 +317,7 @@ case "student": if (!$user = get_record("user", "id", $student)) { - error("Student doesn't exist"); + print_error("Student doesn't exist"); } print_heading(get_string("analysisof", "survey", fullname($user))); diff --git a/mod/survey/save.php b/mod/survey/save.php index 5998987c045b9..328ab4a2d63c5 100644 --- a/mod/survey/save.php +++ b/mod/survey/save.php @@ -7,17 +7,17 @@ // Make sure this is a legitimate posting if (!$formdata = data_submitted("$CFG->wwwroot/mod/survey/view.php")) { - error("You are not supposed to use this script like that."); + print_error("You are not supposed to use this script like that."); } $id = required_param('id', PARAM_INT); // Course Module ID if (! $cm = get_coursemodule_from_id('survey', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); @@ -26,7 +26,7 @@ require_capability('mod/survey:participate', $context); if (! $survey = get_record("survey", "id", $cm->instance)) { - error("Survey ID was incorrect"); + print_error("Survey ID was incorrect"); } add_to_log($course->id, "survey", "submit", "view.php?id=$cm->id", "$survey->id", "$cm->id"); @@ -83,7 +83,7 @@ } if (! insert_record("survey_answers", $newdata)) { - error("Encountered a problem trying to store your results. Sorry."); + print_error("Encountered a problem trying to store your results. Sorry."); } } diff --git a/mod/survey/view.php b/mod/survey/view.php index 230ee0061e3aa..bf1e346d10d04 100644 --- a/mod/survey/view.php +++ b/mod/survey/view.php @@ -6,11 +6,11 @@ $id = required_param('id', PARAM_INT); // Course Module ID if (! $cm = get_coursemodule_from_id('survey', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); @@ -20,7 +20,7 @@ require_capability('mod/survey:participate', $context); if (! $survey = get_record("survey", "id", $cm->instance)) { - error("Survey ID was incorrect"); + print_error("Survey ID was incorrect"); } $trimmedintro = trim($survey->intro); if (empty($trimmedintro)) { @@ -29,7 +29,7 @@ } if (! $template = get_record("survey", "id", $survey->template)) { - error("Template ID was incorrect"); + print_error("Template ID was incorrect"); } $showscales = ($template->name != 'ciqname'); @@ -115,7 +115,7 @@ // Get all the major questions and their proper order if (! $questions = get_records_list("survey_questions", "id", $survey->questions)) { - error("Couldn't find any questions in this survey!!"); + print_error("Couldn't find any questions in this survey!!"); } $questionorder = explode( ",", $survey->questions); diff --git a/mod/wiki/admin.php b/mod/wiki/admin.php index 77c207a3ab679..fea6e1a2dcab2 100644 --- a/mod/wiki/admin.php +++ b/mod/wiki/admin.php @@ -14,26 +14,26 @@ if ($id) { if (! $cm = get_coursemodule_from_id('wiki', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $wiki = get_record("wiki", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else { if (! $wiki = get_record("wiki", "id", $a)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $wiki->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } } @@ -58,18 +58,18 @@ /// Is an Action given ? if(!$action) { - error(get_string("noadministrationaction","wiki")); + print_error("noadministrationaction","wiki"); } /// Correct Action ? if(!in_array($action, array("setpageflags", "removepages", "strippages", "checklinks", "revertpages"))) { - error("Unknown action '$action'","wiki"); + print_error("Unknown action '$action'","wiki"); } /// May the User administrate it ? if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false || wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course) === false) { - error(get_string("notadministratewiki","wiki")); + print_error("notadministratewiki","wiki"); } $canedit = wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course); @@ -77,7 +77,7 @@ if(in_array($action,array("removepages","strippages","revertpages"))) { if(!($wiki->wtype=="student" || ($wiki->wtype=="group" and $canedit) || wiki_is_teacher($wiki))) { add_to_log($course->id, "wiki", "hack", "", $wiki->name.": Tried to trick admin.php with action=$action."); - error("Hack attack detected !"); + print_error("Hack attack detected !"); } } @@ -214,7 +214,7 @@ } } break; - default: error("No such Wiki-Admin action: $action"); + default: print_error("No such Wiki-Admin action: $action"); break; } } @@ -228,7 +228,7 @@ if(!$ret) { redirect($redirect, get_string("pagesremoved","wiki"), 1); } else { - error($ret); + print_error($ret); } exit; case "strippages": @@ -240,7 +240,7 @@ if(!$ret) { redirect($redirect, get_string("pagesstripped","wiki"), 1); } else { - error($ret); + print_error($ret); } exit; case "checklinks": @@ -254,7 +254,7 @@ case "setpageflags": # No confirmation needed break; - default: error("No such action '$action' with confirmation"); + default: print_error("No such action '$action' with confirmation"); } } diff --git a/mod/wiki/ewiki/ewiki.php b/mod/wiki/ewiki/ewiki.php index 6b38174ae73fa..4ba72c4ae8166 100644 --- a/mod/wiki/ewiki/ewiki.php +++ b/mod/wiki/ewiki/ewiki.php @@ -299,9 +299,9 @@ // Binary Handling starts here #### MOODLE CHANGE TO BE COMPATIBLE WITH PHP 4.1 #if(headers_sent($file,$line)) { - # error("Headers already sent: $file:$line"); + # print_error("Headers already sent: $file:$line"); if(headers_sent()) { - error("Headers already sent."); + print_error("Headers already sent."); } $pf($GLOBALS); } diff --git a/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php b/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php index 0d05f959c9303..f2ef2b5c92122 100644 --- a/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php +++ b/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php @@ -42,12 +42,12 @@ function moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid) { global $CFG; $entry=wiki_get_entry($wiki, $course, $userid, $groupid); if(!$entry) { - error("Cannot get entry."); + print_error("Cannot get entry."); } $dir=make_upload_directory("$course->id/$CFG->moddata/wiki/$wiki->id/$entry->id/".$meta["section"]); if(substr($id, 0, strlen(EWIKI_IDF_INTERNAL))!=EWIKI_IDF_INTERNAL) { - error("Binary entry does not start with ".EWIKI_IDF_INTERNAL.substr($id, 0, strlen(EWIKI_IDF_INTERNAL))); + print_error("Binary entry does not start with ".EWIKI_IDF_INTERNAL.substr($id, 0, strlen(EWIKI_IDF_INTERNAL))); } $id = substr($id,strlen(EWIKI_IDF_INTERNAL)); $id = clean_filename($id); @@ -61,14 +61,14 @@ function moodle_binary_store_file(&$filename, &$id, &$meta, $ext=".bin") { # READ-Only global $_FILES, $CFG, $course, $wiki, $groupid, $userid, $ewiki_title, $cm; if(!$wiki->ewikiacceptbinary) { - error("This wiki does not accept binaries"); + print_error("This wiki does not accept binaries"); return 0; } $entry=wiki_get_entry($wiki, $course, $userid, $groupid); if(!$entry->id) { - error("Cannot get entry."); + print_error("Cannot get entry."); } require_once($CFG->dirroot.'/lib/uploadlib.php'); @@ -81,7 +81,7 @@ function moodle_binary_store_file(&$filename, &$id, &$meta, $ext=".bin") { } return true; } - error($um->print_upload_log(true)); + print_error($um->print_upload_log(true)); return false; } @@ -94,7 +94,7 @@ function moodle_binary_store_get_file($id, &$meta) { #-- check for file if(!$wiki->ewikiacceptbinary) { - error("This wiki does not accept binaries"); + print_error("This wiki does not accept binaries"); return 0; } diff --git a/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php b/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php index 1d9fded5b06d6..1e857bd71956b 100644 --- a/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php +++ b/mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php @@ -239,7 +239,7 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir $exportdir=$CFG->dataroot."/".$course->id."/".$exportdestinations; } else { add_to_log($course->id, "wiki", "hack", "", format_string($wiki->name,true).": Tried to export a wiki as non-teacher into $exportdestinations."); - error("You are not a teacher !"); + print_error("You are not a teacher !"); } } else { $exportbasedir=tempnam("/tmp","WIKIEXPORT"); @@ -249,7 +249,7 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir $exportdir=$exportbasedir."/".$wname; @mkdir($exportdir); if(!is_dir($exportdir)) { - error("Cannot create temporary directory $exportdir !"); + print_error("Cannot create temporary directory $exportdir !"); } } @@ -346,12 +346,12 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir #-- add file // Let's make sure the file exists and is writable first. if (!$handle = fopen($exportdir."/".$fn, 'w')) { - error("Cannot open file ($exportdir/$fn)"); + print_error("Cannot open file ($exportdir/$fn)"); } // Write $content to our opened file. if (fwrite($handle, $content) === FALSE) { - error("Cannot write to file ($exportdir/$fn)"); + print_error("Cannot write to file ($exportdir/$fn)"); } fclose($handle); @@ -387,12 +387,12 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir // Let's make sure the file exists and is writable first. $indexname="index".$html_ext; if (!$handle = fopen($exportdir."/".$indexname, 'w')) { - error("Cannot open file ($exportdir/$indexname)"); + print_error("Cannot open file ($exportdir/$indexname)"); } // Write $somecontent to our opened file. if (fwrite($handle, $str_formatted) === FALSE) { - error("Cannot write to file ($exportdir/$indexname)"); + print_error("Cannot write to file ($exportdir/$indexname)"); } fclose($handle); @@ -418,10 +418,10 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir Header("X-Content-Type: application/zip"); Header("Content-Location: $archivename"); if(!@readfile("$exportbasedir/$archivename")) { - error("Cannot read $exportbasedir/$archivename"); + print_error("Cannot read $exportbasedir/$archivename"); } if(!deldir($exportbasedir)) { - error("Cannot delete $exportbasedir"); + print_error("Cannot delete $exportbasedir"); } #exit(); return false; diff --git a/mod/wiki/index.php b/mod/wiki/index.php index 313891df4ad1e..20927812ecd7e 100644 --- a/mod/wiki/index.php +++ b/mod/wiki/index.php @@ -9,7 +9,7 @@ $id = required_param('id', PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php index 66a2066561702..64e2716645776 100644 --- a/mod/wiki/lib.php +++ b/mod/wiki/lib.php @@ -29,7 +29,7 @@ function wiki_context($wiki) { $wiki = $wiki->id; } if (! $cm = get_coursemodule_from_instance('wiki', $wiki)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } return get_context_instance(CONTEXT_MODULE, $cm->id); @@ -409,7 +409,7 @@ function wiki_get_default_entry(&$wiki, &$course, $userid=0, $groupid=0) { // Whatever groups are in the course, pick one $coursegroups = groups_get_all_groups($course->id); if(!$coursegroups || count($coursegroups)==0) { - error("Can't access wiki in group mode when no groups are configured for the course"); + print_error("Can't access wiki in group mode when no groups are configured for the course"); } $unkeyed=array_values($coursegroups); // Make sure first item is index 0 $groupid=$unkeyed[0]->id; @@ -421,7 +421,7 @@ function wiki_get_default_entry(&$wiki, &$course, $userid=0, $groupid=0) { if (wiki_can_add_entry($wiki, $USER, $course, $userid, $groupid)) { wiki_add_entry($wiki, $course, $userid, $groupid); if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) { - error("Could not add wiki entry."); + print_error("Could not add wiki entry."); } } } @@ -465,7 +465,7 @@ function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) { // Whatever groups are in the course, pick one $coursegroups = groups_get_all_groups($course->id); if(!$coursegroups || count($coursegroups)==0) { - error("Can't access wiki in group mode when no groups are configured for the course"); + print_error("Can't access wiki in group mode when no groups are configured for the course"); } $unkeyed=array_values($coursegroups); // Make sure first item is index 0 $groupid=$unkeyed[0]->id; @@ -477,7 +477,7 @@ function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) { if ($groupid and wiki_user_can_access_group_wiki($wiki, $groupid, $course)) { $wentry = wiki_get_group_entry($wiki, $groupid); } else { - error("Cannot access any groups for this wiki"); + print_error("Cannot access any groups for this wiki"); } } /// If mode is 'nogroups', then groupid is zero. @@ -1684,7 +1684,7 @@ function wiki_obtain_lock($wikiid,$pagename) { } else { // Not locked any more. Get rid of the old lock record. if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wikiid)) { - error('Unable to delete lock record'); + print_error('Unable to delete lock record'); } } } @@ -1699,7 +1699,7 @@ function wiki_obtain_lock($wikiid,$pagename) { $newlock->wikiid=$wikiid; $newlock->pagename=$pagename; if(!$lockid=insert_record('wiki_locks',$newlock)) { - error('Unable to insert lock record'); + print_error('Unable to insert lock record'); } } @@ -1734,7 +1734,7 @@ function wiki_release_lock($wikiid,$pagename) { $lockid=$_SESSION[SESSION_WIKI_LOCKS][$key]; unset($_SESSION[SESSION_WIKI_LOCKS][$key]); if(!delete_records('wiki_locks','id',$lockid)) { - error("Unable to delete lock record."); + print_error("Unable to delete lock record."); } } } diff --git a/mod/wiki/overridelock.php b/mod/wiki/overridelock.php index 0b83b9bed5778..1aa088b509451 100644 --- a/mod/wiki/overridelock.php +++ b/mod/wiki/overridelock.php @@ -15,36 +15,36 @@ $page=required_param('page',PARAM_RAW); if (! $cm = get_coursemodule_from_id('wiki', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $wiki = get_record("wiki", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if(!confirm_sesskey()) { - error("Session key not set"); + print_error("Session key not set"); } if(!data_submitted()) { - error("Only POST requests accepted"); + print_error("Only POST requests accepted"); } require_course_login($course, true, $cm); $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); if(!has_capability('mod/wiki:overridelock', $modcontext)) { - error("You do not have the capability to override editing locks"); + print_error("You do not have the capability to override editing locks"); } $actions = explode('/', $page,2); if(count($actions)!=2) { - error("Unsupported page value"); + print_error("Unsupported page value"); } $pagename=addslashes($actions[1]); if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wiki->id)) { - error('Unable to delete lock record'); + print_error('Unable to delete lock record'); } redirect("view.php?id=$id&page=".urlencode($page)); diff --git a/mod/wiki/view.php b/mod/wiki/view.php index f2439cc1a49a4..b832e1771b678 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -38,26 +38,26 @@ if ($id) { if (! $cm = get_coursemodule_from_id('wiki', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $wiki = get_record("wiki", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else { if (! $wiki = get_record("wiki", "id", $wid)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } if (! $course = get_record("course", "id", $wiki->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $id = $cm->id; $_REQUEST["id"] = $id; @@ -102,7 +102,7 @@ list($ok,$lock)=wiki_obtain_lock($wiki_entry->id,$pagename); if(!$ok) { $strsavenolock=get_string('savenolock','wiki'); - error($strsavenolock,$CFG->wwwroot.'/mod/wiki/view.php?id='.$cm->id.'&page=view/'.urlencode($pagename)); + print_error($strsavenolock, '', $CFG->wwwroot.'/mod/wiki/view.php?id='.$cm->id.'&page=view/'.urlencode($pagename)); } } diff --git a/mod/workshop/assess.php b/mod/workshop/assess.php index 3a1a8a5dd613d..7275ed3639ef4 100644 --- a/mod/workshop/assess.php +++ b/mod/workshop/assess.php @@ -11,16 +11,16 @@ $sid = optional_param('sid', 0, PARAM_INT); if (! $submission = get_record('workshop_submissions', 'id', $sid)) { - error("Incorrect submission id"); + print_error("Incorrect submission id"); } if (! $workshop = get_record("workshop", "id", $submission->workshopid)) { - error("Submission is incorrect"); + print_error("Submission is incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Workshop is misconfigured"); + print_error("Workshop is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("No coursemodule found"); + print_error("No coursemodule found"); } require_login($course->id, false, $cm); @@ -89,7 +89,7 @@ $assessment->generalcomment = ''; $assessment->teachercomment = ''; if (!$assessment->id = insert_record("workshop_assessments", $assessment)) { - error("Could not insert workshop assessment!"); + print_error("Could not insert workshop assessment!"); } // if it's the teacher and the workshop is error banded set all the elements to Yes if (workshop_is_teacher($workshop) and ($workshop->gradingstrategy == 2)) { @@ -101,7 +101,7 @@ $element->feedback = ''; $element->grade = 1; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } // now set the adjustment @@ -112,7 +112,7 @@ $element->elementno = $i; $element->grade = 0; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } } diff --git a/mod/workshop/assessments.php b/mod/workshop/assessments.php index 7bb8e9743325a..db1c8d09cd067 100644 --- a/mod/workshop/assessments.php +++ b/mod/workshop/assessments.php @@ -43,23 +43,23 @@ // get some useful stuff... if ($id) { if (! $cm = get_coursemodule_from_id('workshop', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $workshop = get_record("workshop", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } } else if ($wid) { if (! $workshop = get_record("workshop", "id", $wid)) { - error("Workshop id is incorrect"); + print_error("Workshop id is incorrect"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("No coursemodule found"); + print_error("No coursemodule found"); } } else { - error("No id given"); + print_error("No id given"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } require_login($course->id, false, $cm); @@ -80,11 +80,11 @@ print_heading_with_help(get_string("addacomment", "workshop"), "addingacomment", "workshop"); // get assessment record if (!$assessmentid = $aid) { // comes from link or hidden form variable - error("Assessment id not given"); + print_error("Assessment id not given"); } $assessment = get_record("workshop_assessments", "id", $assessmentid); if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error("Submission not found"); + print_error("Submission not found"); } ?>
    @@ -117,13 +117,13 @@ elseif ($action == 'addstockcomment') { if (empty($aid) or ($elementno<0)) { - error("Workshop Assessment ID and/or Element Number missing"); + print_error("Workshop Assessment ID and/or Element Number missing"); } require_capability('mod/workshop:manage', $context); if (!$assessment = get_record("workshop_assessments", "id", $aid)) { - error("workshop assessment is misconfigured"); + print_error("workshop assessment is misconfigured"); } $form = data_submitted('nomatch'); //Nomatch because we can come from assess.php @@ -142,7 +142,7 @@ } if (!$element->id = insert_record("workshop_stockcomments", $comment)) { - error("Could not insert comment into comment bank"); + print_error("Could not insert comment into comment bank"); } // now upate the assessment (just the elements, the assessment itself is not updated) @@ -176,7 +176,7 @@ $element->elementno = $i; $element->feedback = clean_param($form->{"feedback_$i"}, PARAM_CLEAN); if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } $grade = 0; // set to satisfy save to db @@ -192,7 +192,7 @@ $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } // now work out the grade... @@ -221,7 +221,7 @@ $element->feedback = clean_param($form->{"feedback_$i"}, PARAM_CLEAN); $element->grade = $form->grade[$i]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } if (empty($form->grade[$i])){ $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight]; @@ -235,7 +235,7 @@ $element->elementno = $i; $element->grade = $form->grade[$i]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade; // do sanity check @@ -255,7 +255,7 @@ $element->elementno = 0; $element->grade = $form->grade[0]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } // now save the adjustment in element one unset($element); @@ -264,7 +264,7 @@ $element->elementno = 1; $element->grade = $form->grade[1]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]); break; @@ -279,7 +279,7 @@ $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } // now work out the grade... @@ -316,7 +316,7 @@ elseif ($action == 'confirmdelete' ) { if (empty($aid)) { - error("Confirm delete: assessment id missing"); + print_error("Confirm delete: assessment id missing"); } notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")), @@ -328,7 +328,7 @@ elseif ($action == 'delete' ) { if (empty($aid)) { - error("Delete: submission id missing"); + print_error("Delete: submission id missing"); } print_string("deleting", "workshop"); @@ -375,7 +375,7 @@ $timenow = time(); // assessment id comes from link or hidden form variable if (!$assessment = get_record("workshop_assessments", "id", $aid)) { - error("Assessment : agree assessment failed"); + print_error("Assessment : agree assessment failed"); } //save time of agreement set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id); @@ -403,13 +403,13 @@ print_heading_with_help(get_string("editacomment", "workshop"), "editingacomment", "workshop"); // get the comment record... if (!$comment = get_record("workshop_comments", "id", $cid)) { - error("Edit Comment: Comment not found"); + print_error("Edit Comment: Comment not found"); } if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { - error("Edit Comment: Assessment not found"); + print_error("Edit Comment: Assessment not found"); } if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error("Edit Comment: Submission not found"); + print_error("Edit Comment: Submission not found"); } ?> @@ -638,11 +638,11 @@ print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop"); // get assessment record if (!$assessmentid = $aid) { - error("Assessment id not given"); + print_error("Assessment id not given"); } $assessment = get_record("workshop_assessments", "id", $assessmentid); if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error("Submission not found"); + print_error("Submission not found"); } // get the teacher's assessment first if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) { @@ -666,7 +666,7 @@ $form = (object)$_POST; if (!$assessment = get_record("workshop_assessments", "id", $aid)) { - error("Unable to insert comment"); + print_error("Unable to insert comment"); } // save the comment... $comment->workshopid = $workshop->id; @@ -675,7 +675,7 @@ $comment->timecreated = $timenow; $comment->comments = clean_param($form->comments, PARAM_CLEAN); if (!$comment->id = insert_record("workshop_comments", $comment)) { - error("Could not insert workshop comment!"); + print_error("Could not insert workshop comment!"); } add_to_log($course->id, "workshop", "comment", "view.php?id=$cm->id", "$comment->id"); @@ -705,7 +705,7 @@ $element->workshopid = $workshop->id; $element->elementno = $key; if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); + print_error("Could not insert workshop element!"); } } } @@ -732,7 +732,7 @@ $element->weight = $form->weight[$key]; } if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); + print_error("Could not insert workshop element!"); } } } @@ -753,7 +753,7 @@ $element->weight = $form->weight[$key]; } if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); + print_error("Could not insert workshop element!"); } } break; @@ -772,7 +772,7 @@ } $element->maxscore = $j - 1; if (!$element->id = insert_record("workshop_elements", $element)) { - error("Could not insert workshop element!"); + print_error("Could not insert workshop element!"); } } // let's not fool around here, dump the junk! @@ -788,7 +788,7 @@ $element->rubricno = $j; $element->description = $form->rubric[$i][$j]; if (!$element->id = insert_record("workshop_rubrics", $element)) { - error("Could not insert workshop element!"); + print_error("Could not insert workshop element!"); } } } @@ -853,19 +853,19 @@ elseif ($action == 'removestockcomment') { if (empty($aid) or empty($stockcommentid)) { - error("Workshop Assessment id and/or Stock Comment id missing"); + print_error("Workshop Assessment id and/or Stock Comment id missing"); } require_capability('mod/workshop:manage', $context); if (!$assessment = get_record("workshop_assessments", "id", $aid)) { - error("workshop assessment is misconfigured"); + print_error("workshop assessment is misconfigured"); } $form = data_submitted('nomatch'); //Nomatch because we can come from assess.php // delete the comment from the stock comments table if (!delete_records("workshop_stockcomments", "id", $stockcommentid)) { - error("Could not remove comment from the comment bank"); + print_error("Could not remove comment from the comment bank"); } // now upate the assessment (just the elements, the assessment itself is not updated) @@ -899,7 +899,7 @@ $element->elementno = $i; $element->feedback = clean_param($form->{"feedback_$i"}, PARAM_CLEAN); if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } $grade = 0; // set to satisfy save to db @@ -915,7 +915,7 @@ $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } // now work out the grade... @@ -944,7 +944,7 @@ $element->feedback = clean_param($form->{"feedback_$i"}, PARAM_CLEAN); $element->grade = $form->grade[$i]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } if (empty($form->grade[$i])){ $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight]; @@ -958,7 +958,7 @@ $element->elementno = $i; $element->grade = $form->grade[$i]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade; // do sanity check @@ -978,7 +978,7 @@ $element->elementno = 0; $element->grade = $form->grade[0]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } // now save the adjustment in element one unset($element); @@ -987,7 +987,7 @@ $element->elementno = 1; $element->grade = $form->grade[1]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]); break; @@ -1002,7 +1002,7 @@ $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } // now work out the grade... @@ -1039,11 +1039,11 @@ elseif ($action == 'updateassessment') { if (empty($aid)) { - error("Workshop Assessment id missing"); + print_error("Workshop Assessment id missing"); } if (! $assessment = get_record("workshop_assessments", "id", $aid)) { - error("workshop assessment is misconfigured"); + print_error("workshop assessment is misconfigured"); } // first get the assignment elements for maxscores and weights... @@ -1076,7 +1076,7 @@ $element->elementno = $i; $element->feedback = clean_param($form->{"feedback_$i"}, PARAM_CLEAN); if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } $grade = 0; // set to satisfy save to db @@ -1092,7 +1092,7 @@ $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } // now work out the grade... @@ -1121,7 +1121,7 @@ $element->feedback = $form->{"feedback_$i"}; $element->grade = clean_param($form->grade[$i], PARAM_CLEAN); if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } if (empty($form->grade[$i])){ $error += $WORKSHOP_EWEIGHTS[$elements[$i]->weight]; @@ -1135,7 +1135,7 @@ $element->elementno = $i; $element->grade = $form->grade[$i]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } $grade = ($elements[intval($error + 0.5)]->maxscore + $form->grade[$i]) * 100 / $workshop->grade; // do sanity check @@ -1155,7 +1155,7 @@ $element->elementno = 0; $element->grade = $form->grade[0]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } // now save the adjustment in element one unset($element); @@ -1164,7 +1164,7 @@ $element->elementno = 1; $element->grade = $form->grade[1]; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } $grade = ($elements[$form->grade[0]]->maxscore + $form->grade[1]); break; @@ -1179,7 +1179,7 @@ $element->feedback = clean_param($form->{"feedback_$key"}, PARAM_CLEAN); $element->grade = $thegrade; if (!$element->id = insert_record("workshop_grades", $element)) { - error("Could not insert workshop grade!"); + print_error("Could not insert workshop grade!"); } } // now work out the grade... @@ -1287,10 +1287,10 @@ // get the comment record... if (!$comment = get_record("workshop_comments", "id", $_POST['cid'])) { - error("Update to Comment failed"); + print_error("Update to Comment failed"); } if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) { - error("Update Comment: Assessment not found"); + print_error("Update Comment: Assessment not found"); } //save the comment for the assessment... if (isset($form->comments)) { @@ -1317,7 +1317,7 @@ $form = (object)$_POST; if (!$assessment = get_record("workshop_assessments", "id", $_POST['aid'])) { - error("Update Grading failed"); + print_error("Update Grading failed"); } //save the comment and grade for the assessment if (isset($form->teachercomment)) { @@ -1339,7 +1339,7 @@ elseif ($action == 'viewallassessments') { if (!$submission = get_record("workshop_submissions", "id", $sid)) { - error("View All Assessments: submission record not found"); + print_error("View All Assessments: submission record not found"); } if ($assessments = workshop_get_assessments($submission)) { @@ -1353,7 +1353,7 @@ /*************** no man's land **************************************/ else { - error("Fatal Error: Unknown Action: ".$action."\n"); + print_error("Fatal Error: Unknown Action: ".$action."\n"); } print_footer($course); diff --git a/mod/workshop/index.php b/mod/workshop/index.php index 5bc2ad7572c47..04ae72f12e78e 100644 --- a/mod/workshop/index.php +++ b/mod/workshop/index.php @@ -7,7 +7,7 @@ $id = required_param('id',PARAM_INT); // course if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } require_course_login($course); diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index 4f52c53a326ff..86a90b19748a9 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -35,7 +35,7 @@ function workshop_context($workshop) { $workshop = $workshop->id; } if (! $cm = get_coursemodule_from_instance('workshop', $workshop)) { - error('Course Module ID was incorrect'); + print_error('Course Module ID was incorrect'); } return get_context_instance(CONTEXT_MODULE, $cm->id); @@ -195,11 +195,11 @@ function workshop_cron () { continue; } if (! $course = get_record("course", "id", $workshop->course)) { - error("Could not find course id $workshop->course"); + print_error("Could not find course id $workshop->course"); continue; } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { @@ -294,11 +294,11 @@ function workshop_cron () { continue; } if (! $course = get_record("course", "id", $workshop->course)) { - error("Could not find course id $workshop->course"); + print_error("Could not find course id $workshop->course"); continue; } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { @@ -388,11 +388,11 @@ function workshop_cron () { continue; } if (! $course = get_record("course", "id", $workshop->course)) { - error("Could not find course id $workshop->course"); + print_error("Could not find course id $workshop->course"); continue; } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); continue; } if (! $submissionowner = get_record("user", "id", "$submission->userid")) { diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 58b7d91a45531..7ad7ff13b9b08 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -193,7 +193,7 @@ function workshop_copy_assessment($assessment, $submission, $withfeedback = fals $newassessment->teachercomment = addslashes($assessment->teachercomment); } if (!$newassessment->id = insert_record("workshop_assessments", $newassessment)) { - error("Copy Assessment: Could not insert workshop assessment!"); + print_error("Copy Assessment: Could not insert workshop assessment!"); } if ($grades = get_records("workshop_grades", "assessmentid", $assessment->id)) { @@ -207,7 +207,7 @@ function workshop_copy_assessment($assessment, $submission, $withfeedback = fals } $grade->assessmentid = $newassessment->id; if (!$grade->id = insert_record("workshop_grades", $grade)) { - error("Copy Assessment: Could not insert workshop grade!"); + print_error("Copy Assessment: Could not insert workshop grade!"); } } } @@ -313,10 +313,10 @@ function workshop_count_student_submissions_for_assessment($workshop, $user) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $timenow = time(); @@ -822,10 +822,10 @@ function workshop_list_all_submissions($workshop, $user) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); @@ -931,7 +931,7 @@ function workshop_list_all_ungraded_assessments($workshop) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $table->head = array (get_string("title", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop")); @@ -971,10 +971,10 @@ function workshop_list_assessed_submissions($workshop, $user) { $timenow = time(); if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $table->head = array (get_string("title","workshop"), get_string("action","workshop"), get_string("comment","workshop")); @@ -1061,10 +1061,10 @@ function workshop_list_peer_assessments($workshop, $user) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); @@ -1137,10 +1137,10 @@ function workshop_list_self_assessments($workshop, $user) { $timenow = time(); if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); @@ -1184,10 +1184,10 @@ function workshop_list_student_submissions($workshop, $user) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $timenow = time(); @@ -1254,7 +1254,7 @@ function workshop_list_student_submissions($workshop, $user) { $assessment->grade = -1; // set impossible grade $assessment->timecreated = $yearfromnow; if (!$assessment->id = insert_record("workshop_assessments", $assessment)) { - error("List Student submissions: Could not insert workshop assessment!"); + print_error("List Student submissions: Could not insert workshop assessment!"); } $nassessed++; // is user up to quota? @@ -1313,13 +1313,13 @@ function workshop_list_submissions_for_admin($workshop, $order) { global $CFG, $USER; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (groupmode($course, $cm) == SEPARATEGROUPS) { $groupid = get_current_group($course->id); @@ -1402,7 +1402,7 @@ function workshop_list_submissions_for_admin($workshop, $order) { $title =''; foreach ($assessments as $assessment) { if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { - error("Workshop_list_submissions_for_admin: Submission $assessment->submissionid not found!"); + print_error("Workshop_list_submissions_for_admin: Submission $assessment->submissionid not found!"); } $title .= $submission->title; if ($workshop->agreeassessments and !$assessment->timeagreed and @@ -1497,7 +1497,7 @@ function workshop_list_submissions_for_admin($workshop, $order) { if ($submissions = workshop_get_student_submissions($workshop, $order)) { foreach ($submissions as $submission) { if (!$user = get_record("user", "id", $submission->userid)) { - error("workshop_list_submissions_for_admin: failure to get user record"); + print_error("workshop_list_submissions_for_admin: failure to get user record"); } // check group membership, if necessary if ($groupid) { @@ -1559,10 +1559,10 @@ function workshop_list_teacher_assessments_by_user($workshop, $user) { $timenow = time(); if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); @@ -1611,10 +1611,10 @@ function workshop_list_teacher_submissions($workshop, $user) { $reassessthreshold = 80; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop")); $table->align = array ("left", "left", "left"); @@ -1652,7 +1652,7 @@ function workshop_list_teacher_submissions($workshop, $user) { $assessment->grade = -1; // set impossible grade $assessment->timecreated = $yearfromnow; if (!$assessment->id = insert_record("workshop_assessments", $assessment)) { - error("Could not insert workshop assessment!"); + print_error("Could not insert workshop assessment!"); } $nassessed++; if ($nassessed >= $workshop->ntassessments) { @@ -1713,10 +1713,10 @@ function workshop_list_unassessed_student_submissions($workshop, $user) { $timenow = time(); if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (groupmode($course, $cm) == SEPARATEGROUPS) { @@ -1783,7 +1783,7 @@ function workshop_list_unassessed_teacher_submissions($workshop, $user) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $table->head = array (get_string("title", "workshop"), get_string("action", "workshop"), @@ -1826,7 +1826,7 @@ function workshop_list_ungraded_assessments($workshop, $stype) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"), @@ -1875,7 +1875,7 @@ function workshop_list_user_submissions($workshop, $user) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $timenow = time(); @@ -1935,7 +1935,7 @@ function workshop_phase($workshop, $style='') { else { return get_string('phase5'.$style, 'workshop'); } - error('Something is wrong with the workshop dates'); + print_error('Something is wrong with the workshop dates'); } @@ -1947,10 +1947,10 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges global $CFG, $USER, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS; if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if ($assessment) { if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) { @@ -2647,7 +2647,7 @@ function workshop_print_assessment($workshop, $assessment = false, $allowchanges function workshop_print_assessments_by_user_for_admin($workshop, $user) { if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if ($assessments = workshop_get_user_assessments_done($workshop, $user)) { @@ -2667,7 +2667,7 @@ function workshop_print_assessments_by_user_for_admin($workshop, $user) { function workshop_print_assessments_for_admin($workshop, $submission) { if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if ($assessments =workshop_get_assessments($submission)) { @@ -2689,10 +2689,10 @@ function workshop_print_assignment_info($workshop) { global $CFG; if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } // print standard assignment heading print_heading(format_string($workshop->name), "center"); @@ -2750,7 +2750,7 @@ function workshop_print_key($workshop) { // print an explaination of the grades if (!$course = get_record("course", "id", $workshop->course)) { - error("Print key: course not found"); + print_error("Print key: course not found"); } echo "
    \n"; echo "

    {} ".get_string("assessmentby", "workshop", $course->student).";  \n"; @@ -2771,10 +2771,10 @@ function workshop_print_league_table($workshop) { // print an order table of (student) submissions showing teacher's and student's assessments if (! $course = get_record("course", "id", $workshop->course)) { - error("Print league table: Course is misconfigured"); + print_error("Print league table: Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } // set $groupid if workshop is in SEPARATEGROUPS mode if (groupmode($course, $cm) == SEPARATEGROUPS) { @@ -2816,10 +2816,10 @@ function workshop_print_league_table($workshop) { $n = 1; while (list($submissionid, $grade) = each($grades)) { if (!$submission = get_record("workshop_submissions", "id", $submissionid)) { - error("Print league table: submission not found"); + print_error("Print league table: submission not found"); } if (!$user = get_record("user", "id", $submission->userid)) { - error("Print league table: user not found"); + print_error("Print league table: user not found"); } if ($workshop->anonymous and workshop_is_student($workshop)) { $table->data[] = array(workshop_print_submission_title($workshop, $submission), @@ -2849,7 +2849,7 @@ function workshop_print_submission($workshop, $submission) { global $CFG; if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } print_simple_box(format_text($submission->description), 'center'); if ($workshop->nattachments) { @@ -2885,7 +2885,7 @@ function workshop_print_submission_assessments($workshop, $submission, $type) { global $USER, $CFG; // Returns the teacher or peer grade and a hyperlinked list of grades for this submission if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $str = ''; // get the assessments in grade order, highest first @@ -2959,7 +2959,7 @@ function workshop_print_submission_title($workshop, $submission) { // Arguments are objects if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (!$submission->timecreated) { // a "no submission" @@ -2986,10 +2986,10 @@ function workshop_print_upload_form($workshop) { global $CFG; if (! $course = get_record("course", "id", $workshop->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $usehtmleditor = can_use_html_editor(); @@ -3026,7 +3026,7 @@ function workshop_print_user_assessments($workshop, $user, &$gradinggrade) { // Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } $gradinggrade = 0; $n = 0; diff --git a/mod/workshop/submissions.php b/mod/workshop/submissions.php index 000165b4a13d1..505d74dc2c704 100644 --- a/mod/workshop/submissions.php +++ b/mod/workshop/submissions.php @@ -34,13 +34,13 @@ // get some useful stuff... if (! $cm = get_coursemodule_from_id('workshop', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $workshop = get_record("workshop", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -66,7 +66,7 @@ require_capability('mod/workshop:manage', $context); if (empty($sid)) { - error("Admin Amend Title: submission id missing"); + print_error("Admin Amend Title: submission id missing"); } $submission = get_record("workshop_submissions", "id", $sid); @@ -99,11 +99,11 @@ require_capability('mod/workshop:manage', $context); if (empty($sid)) { - error("Admin clear late flag: submission id missing"); + print_error("Admin clear late flag: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $sid)) { - error("Admin clear late flag: can not get submission record"); + print_error("Admin clear late flag: can not get submission record"); } if (set_field("workshop_submissions", "late", 0, "id", $sid)) { print_heading(get_string("clearlateflag", "workshop")." ".get_string("ok")); @@ -119,7 +119,7 @@ elseif ($action == 'confirmdelete' ) { if (empty($sid)) { - error("Confirm delete: submission id missing"); + print_error("Confirm delete: submission id missing"); } notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), "submissions.php?action=delete&id=$cm->id&sid=$sid", "view.php?id=$cm->id#sid=$sid"); @@ -130,18 +130,18 @@ elseif ($action == 'delete' ) { if (empty($sid)) { - error("Delete: submission id missing"); + print_error("Delete: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $sid)) { - error("Admin delete: can not get submission record"); + print_error("Admin delete: can not get submission record"); } // students are only allowed to delete their own submission and only up to the deadline if (!(workshop_is_teacher($workshop) or (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend) and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) { - error("You are not authorized to delete this submission"); + print_error("You are not authorized to delete this submission"); } print_string("deleting", "workshop"); @@ -170,10 +170,10 @@ require_capability('mod/workshop:manage', $context); if (empty($sid)) { - error("Admin confirm late flag: submission id missing"); + print_error("Admin confirm late flag: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $sid)) { - error("Admin confirm late flag: can not get submission record"); + print_error("Admin confirm late flag: can not get submission record"); } notice_yesno(get_string("clearlateflag","workshop")."?", @@ -198,7 +198,7 @@ require_capability('mod/workshop:manage', $context); if (empty($sid)) { - error("Admin Update Title: submission id missing"); + print_error("Admin Update Title: submission id missing"); } if (set_field("workshop_submissions", "title", $title, "id", $sid)) { @@ -212,10 +212,10 @@ elseif ($action == 'confirmremoveattachments' ) { if (empty($sid)) { - error("Admin confirm delete: submission id missing"); + print_error("Admin confirm delete: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $sid)) { - error("Admin delete: can not get submission record"); + print_error("Admin delete: can not get submission record"); } notice_yesno(get_string("confirmremoveattachments","workshop"), @@ -228,17 +228,17 @@ elseif ($action == 'editsubmission' ) { if (empty($sid)) { - error("Edit submission: submission id missing"); + print_error("Edit submission: submission id missing"); } $usehtmleditor = can_use_html_editor(); $submission = get_record("workshop_submissions", "id", $sid); print_heading(get_string("editsubmission", "workshop")); if ($submission->userid <> $USER->id) { - error("Edit submission: Userids do not match"); + print_error("Edit submission: Userids do not match"); } if (($submission->timecreated < ($timenow - $CFG->maxeditingtime)) and ($workshop->assessmentstart < $timenow)) { - error(get_string('notallowed', 'workshop')); + print_error('notallowed', 'workshop'); } ?> @@ -342,7 +342,7 @@ class=\"icon\" alt=\"".get_string('file')."\" />". $form = data_submitted(); if (empty($form->sid)) { - error("Update submission: submission id missing"); + print_error("Update submission: submission id missing"); } $submission = get_record("workshop_submissions", "id", $form->sid); @@ -351,7 +351,7 @@ class=\"icon\" alt=\"".get_string('file')."\" />". if (!(workshop_is_teacher($workshop) or (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend) and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) { - error("You are not authorized to delete these attachments"); + print_error("You are not authorized to delete these attachments"); } // amend title... just in case they were modified @@ -374,7 +374,7 @@ class=\"icon\" alt=\"".get_string('file')."\" />". elseif ($action == 'showsubmission' ) { if (empty($sid)) { - error("Show submission: submission id missing"); + print_error("Show submission: submission id missing"); } $submission = get_record("workshop_submissions", "id", $sid); @@ -412,7 +412,7 @@ class=\"icon\" alt=\"".get_string('file')."\" />". elseif ($action == 'updatesubmission') { if (empty($sid)) { - error("Update submission: submission id missing"); + print_error("Update submission: submission id missing"); } $submission = get_record("workshop_submissions", "id", $sid); @@ -420,7 +420,7 @@ class=\"icon\" alt=\"".get_string('file')."\" />". if (!(workshop_is_teacher($workshop) or (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend) and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) { - error("You are not authorized to update your submission"); + print_error("You are not authorized to update your submission"); } // check existence of title @@ -453,7 +453,7 @@ class=\"icon\" alt=\"".get_string('file')."\" />". else { - error("Fatal Error: Unknown Action: ".$action."\n"); + print_error("Fatal Error: Unknown Action: ".$action."\n"); } diff --git a/mod/workshop/upload.php b/mod/workshop/upload.php index 5d040de7fe972..62a572c34f2c4 100644 --- a/mod/workshop/upload.php +++ b/mod/workshop/upload.php @@ -8,13 +8,13 @@ if (! $cm = get_record("course_modules", "id", $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $workshop = get_record("workshop", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -63,7 +63,7 @@ $newsubmission->late = 1; } if (!$newsubmission->id = insert_record("workshop_submissions", $newsubmission)) { - error("Workshop submission: Failure to create new submission record!"); + print_error("Workshop submission: Failure to create new submission record!"); } // see if this is a resubmission by looking at the previous submissions... if ($submissions and ($workshop->submissionstart > time())) { // ...but not teacher submissions diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 49266aa43380e..b6beb135da68d 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -26,13 +26,13 @@ // get some useful stuff... if (! $cm = get_coursemodule_from_id('workshop', $id)) { - error("Course Module ID was incorrect"); + print_error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); + print_error("Course is misconfigured"); } if (! $workshop = get_record("workshop", "id", $cm->instance)) { - error("Course module is incorrect"); + print_error("Course module is incorrect"); } require_login($course->id, false, $cm); @@ -569,7 +569,7 @@ function workshop_sortfunction($a, $b) { /*************** no man's land **************************************/ else { - error("Fatal Error: Unknown Action: ".$action."\n"); + print_error("Fatal Error: Unknown Action: ".$action."\n"); } diff --git a/mod/workshop/viewassessment.php b/mod/workshop/viewassessment.php index 81648b2c04450..93020f543901e 100644 --- a/mod/workshop/viewassessment.php +++ b/mod/workshop/viewassessment.php @@ -10,19 +10,19 @@ $frameset = optional_param('frameset', '', PARAM_ALPHA); if (! $assessment = get_record("workshop_assessments", "id", $aid)) { - error("Assessment id is incorrect"); + print_error("Assessment id is incorrect"); } if (! $submission = get_record('workshop_submissions', 'id', $assessment->submissionid)) { - error("Incorrect submission id"); + print_error("Incorrect submission id"); } if (! $workshop = get_record("workshop", "id", $submission->workshopid)) { - error("Submission is incorrect"); + print_error("Submission is incorrect"); } if (! $course = get_record("course", "id", $workshop->course)) { - error("Workshop is misconfigured"); + print_error("Workshop is misconfigured"); } if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) { - error("No coursemodule found"); + print_error("No coursemodule found"); } if (!$redirect) { diff --git a/notes/add.php b/notes/add.php index 58b5cf44a30ff..cab3524be3441 100644 --- a/notes/add.php +++ b/notes/add.php @@ -9,7 +9,7 @@ /// locate course information if (!($course = get_record('course', 'id', $courseid))) { - error('Incorrect course id found'); + print_error('Incorrect course id found'); } /// require login to access notes @@ -24,7 +24,7 @@ /// locate user information if (!($user = get_record('user', 'id', $userid))) { - error('Incorrect user id found'); + print_error('Incorrect user id found'); } /// build-up form diff --git a/notes/delete.php b/notes/delete.php index dc17409b3ccaf..4faceeb6235b9 100644 --- a/notes/delete.php +++ b/notes/delete.php @@ -8,17 +8,17 @@ // locate note information if (!$note = note_load($noteid)) { - error('Incorrect note id specified'); + print_error('Incorrect note id specified'); } // locate course information if (!$course = get_record('course', 'id', $note->courseid)) { - error('Incorrect course id found'); + print_error('Incorrect course id found'); } // locate user information if (!$user = get_record('user', 'id', $note->userid)) { - error('Incorrect user id found'); + print_error('Incorrect user id found'); } // require login to access notes @@ -29,7 +29,7 @@ // check capability if (!has_capability('moodle/notes:manage', $context)) { - error('You may not delete this note'); + print_error('You may not delete this note'); } if (data_submitted() && confirm_sesskey()) { @@ -38,7 +38,7 @@ if (note_delete($noteid)) { add_to_log($note->courseid, 'notes', 'delete', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id , 'delete note'); } else { - error('Error occured while deleting post', $returnurl); + print_error('Error occured while deleting post', '', $returnurl); } redirect($returnurl); } else { @@ -60,4 +60,4 @@ note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD); print_footer(); } -?> \ No newline at end of file +?> diff --git a/notes/edit.php b/notes/edit.php index bf6f36f3714be..f6ffe05ecae75 100644 --- a/notes/edit.php +++ b/notes/edit.php @@ -8,17 +8,17 @@ /// locate note information if (!$note = note_load($noteid)) { - error('Incorrect note id specified'); + print_error('Incorrect note id specified'); } /// locate course information if (!$course = get_record('course', 'id', $note->courseid)) { - error('Incorrect course id found'); + print_error('Incorrect course id found'); } /// locate user information if (!$user = get_record('user', 'id', $note->userid)) { - error('Incorrect user id found'); + print_error('Incorrect user id found'); } /// require login to access notes diff --git a/notes/index.php b/notes/index.php index 3c2832c21a24b..8b82b04e203e4 100644 --- a/notes/index.php +++ b/notes/index.php @@ -27,13 +27,13 @@ /// locate course information if (!$course = get_record('course', 'id', $courseid)) { - error('Incorrect course id specified'); + print_error('Incorrect course id specified'); } /// locate user information if ($userid) { if (!$user = get_record('user', 'id', $userid)) { - error('Incorrect user id specified'); + print_error('Incorrect user id specified'); } $filtertype = 'user'; $filterselect = $user->id; diff --git a/question/category.php b/question/category.php index 25e87b64206e7..2fc0379b8af14 100644 --- a/question/category.php +++ b/question/category.php @@ -48,7 +48,7 @@ } if ($param->delete && ($questionstomove = count_records("question", "category", $param->delete))){ if (!$category = get_record("question_categories", "id", $param->delete)) { // security - error("No such category {$param->delete}!", $thispageurl->out()); + print_error("No such category {$param->delete}!", '', $thispageurl->out()); } $categorycontext = get_context_instance_by_id($category->contextid); $qcobject->moveform = new question_move_form($thispageurl, diff --git a/question/category_class.php b/question/category_class.php index c4af0dbcf9203..879f353de74e0 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -273,7 +273,7 @@ function edit_single_category($categoryid) { $this->catform->set_data($category); $this->catform->display(); } else { - error("Category $categoryid not found"); + print_error("Category $categoryid not found"); } } @@ -324,11 +324,11 @@ function delete_category($categoryid) { global $CFG; question_can_delete_cat($categoryid); if (!$category = get_record("question_categories", "id", $categoryid)) { // security - error("No such category $cat!", $this->pageurl->out()); + print_error("No such category $cat!", '', $this->pageurl->out()); } /// Send the children categories to live with their grandparent if (!set_field("question_categories", "parent", $category->parent, "parent", $category->id)) { - error("Could not update a child category!", $this->pageurl->out()); + print_error("Could not update a child category!", '', $this->pageurl->out()); } /// Finally delete the category itself @@ -353,7 +353,7 @@ function display_move_form($questionsincategory, $category){ function move_questions($oldcat, $newcat){ if (!set_field('question', 'category', $newcat, 'category', $oldcat)) { - error("Error while moving questions from category '$oldcat' to '$newcat'", $this->pageurl->out()); + print_error("Error while moving questions from category '$oldcat' to '$newcat'", '', $this->pageurl->out()); } } @@ -363,7 +363,7 @@ function move_questions($oldcat, $newcat){ */ function add_category($newparent, $newcategory, $newinfo) { if (empty($newcategory)) { - error(get_string('categorynamecantbeblank', 'quiz')); + print_error('categorynamecantbeblank', 'quiz'); } list($parentid, $contextid) = explode(',', $newparent); //moodle_form makes sure select element output is legal no need for further cleaning @@ -371,7 +371,7 @@ function add_category($newparent, $newcategory, $newinfo) { if ($parentid) { if(!(get_field('question_categories', 'contextid', 'id', $parentid) == $contextid)) { - error("Could not insert the new question category '$newcategory' illegal contextid '$contextid'."); + print_error("Could not insert the new question category '$newcategory' illegal contextid '$contextid'."); } } @@ -383,7 +383,7 @@ function add_category($newparent, $newcategory, $newinfo) { $cat->sortorder = 999; $cat->stamp = make_unique_id_code(); if (!insert_record("question_categories", $cat)) { - error("Could not insert the new question category '$newcategory'"); + print_error("Could not insert the new question category '$newcategory'"); } else { redirect($this->pageurl->out());//always redirect after successful action } @@ -396,7 +396,7 @@ function add_category($newparent, $newcategory, $newinfo) { function update_category($updateid, $newparent, $newname, $newinfo) { global $CFG, $QTYPES; if (empty($newname)) { - error(get_string('categorynamecantbeblank', 'quiz')); + print_error('categorynamecantbeblank', 'quiz'); } list($parentid, $tocontextid) = explode(',', $newparent); @@ -425,13 +425,13 @@ function update_category($updateid, $newparent, $newname, $newinfo) { if ($oldcat->contextid == $tocontextid){ // not moving contexts $cat->parent = $parentid; if (!update_record("question_categories", $cat)) { - error("Could not update the category '$newname'", $this->pageurl->out()); + print_error("Could not update the category '$newname'", '', $this->pageurl->out()); } else { redirect($this->pageurl->out()); } } else { if (!update_record("question_categories", $cat)) { - error("Could not update the category '$newname'", $this->pageurl->out()); + print_error("Could not update the category '$newname'", '', $this->pageurl->out()); } else { redirect($CFG->wwwroot.'/question/contextmove.php?'. $this->pageurl->get_query_string(array('cattomove' => $updateid, @@ -439,7 +439,7 @@ function update_category($updateid, $newparent, $newname, $newinfo) { } } } else { - error("Cannot move the category '$newname'. It is the last in this context.", $this->pageurl->out()); + print_error("Cannot move the category '$newname'. It is the last in this context.", '', $this->pageurl->out()); } } diff --git a/question/contextmove.php b/question/contextmove.php index 7ee5908835794..83e40122fd88d 100644 --- a/question/contextmove.php +++ b/question/contextmove.php @@ -26,7 +26,7 @@ list($toparent, $contextto) = explode(',', $toparent); if (!empty($toparent)){//not top level category, make it a child of $toparent if (!$toparent = get_record('question_categories', 'id', $toparent)){ - error('Invalid category id for parent!', $onerrorurl); + print_error('Invalid category id for parent!', '', $onerrorurl); } $contextto = $toparent->contextid; } else { @@ -35,10 +35,10 @@ $toparent->contextid = $contextto; } if (!$cattomove = get_record('question_categories', 'id', $cattomove)){ - error('Invalid category id to move!', $onerrorurl); + print_error('Invalid category id to move!', '', $onerrorurl); } if ($cattomove->contextid == $contextto){ - error("You shouldn't have got here if you're not moving a category to another context.", $onerrorurl); + print_error("You shouldn't have got here if you're not moving a category to another context.", '', $onerrorurl); } $cattomove->categorylist = question_categorylist($cattomove->id); @@ -130,7 +130,7 @@ case QUESTION_FILEMOVELINKSONLY : break; default : - error('Invalid action selected!', $onerrorurl); + print_error('Invalid action selected!', '', $onerrorurl); } switch ($urlaction){ //now search and replace urls in questions. @@ -176,11 +176,11 @@ $cat->parent = $toparent->id; //set context of category we are moving and all children also! if (!execute_sql("UPDATE {$CFG->prefix}question_categories SET contextid = {$contextto->id} WHERE id IN ({$cattomove->categorylist})", false)){ - error("Could not move the category '$newname' to ".$contexttostring, $onerrorurl); + print_error("Could not move the category '$newname' to ".$contexttostring, '', $onerrorurl); } //finally set the new parent id if (!update_record("question_categories", $cat)) { - error("Could not update the category '$updatename'", $onerrorurl); + print_error("Could not update the category '$updatename'", '', $onerrorurl); } $thispageurl->remove_params('cattomove', 'toparent', 'totop'); redirect($CFG->wwwroot."/question/category.php?".$thispageurl->get_query_string(array('cat'=>"{$cattomove->id},{$contextto->id}"))); diff --git a/question/contextmoveq.php b/question/contextmoveq.php index 43f04ba1fdbf0..9bcd9dce2cc75 100644 --- a/question/contextmoveq.php +++ b/question/contextmoveq.php @@ -42,7 +42,7 @@ } $thispageurl->param('courseid', $COURSE->id); } else { - error('Need to pass courseid or cmid to this script.'); + print_error('Need to pass courseid or cmid to this script.'); } $contexts = new question_edit_contexts($thiscontext); @@ -70,7 +70,7 @@ $questions[$id]->context = get_context_instance_by_id($questions[$id]->contextid); $thisfilesid = get_filesdir_from_context($questions[$id]->context); if ($fromcoursefilesid && $thisfilesid != $fromcoursefilesid){ - error('You can\'t use this script to move questions that have files associated with them from different areas.'); + print_error('You can\'t use this script to move questions that have files associated with them from different areas.'); } else { $fromcoursefilesid = $thisfilesid; } @@ -136,7 +136,7 @@ case QUESTION_FILEDONOTHING : break; default : - error('Invalid action selected!', $returnurl); + print_error('Invalid action selected!', '', $returnurl); } //now search and replace urls in questions. switch ($urlaction){ @@ -152,7 +152,7 @@ case QUESTION_FILEDONOTHING : break; default : - error('Invalid action selected!', $returnurl); + print_error('Invalid action selected!', '', $returnurl); break; } @@ -161,7 +161,7 @@ } //now move questions if (!execute_sql("UPDATE {$CFG->prefix}question SET category = {$tocat->id} WHERE id IN ({$ids})", false)){ - error("Could not move the questions {$ids} to category ".$tocat->name, $returnurl); + print_error("Could not move the questions {$ids} to category ".$tocat->name, '', $returnurl); } redirect($returnurl); } @@ -239,4 +239,4 @@ } $contextmoveform->display(); print_footer($COURSE); -?> \ No newline at end of file +?> diff --git a/question/editlib.php b/question/editlib.php index 7e1b22077d739..5c0ab344371f7 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -21,9 +21,9 @@ function get_module_from_cmid($cmid){ {$CFG->prefix}modules md WHERE cm.id = '$cmid' AND md.id = cm.module")){ - error('cmunknown'); + print_error('cmunknown'); } elseif (!$modrec =get_record($cmrec->modname, 'id', $cmrec->instance)) { - error('cmunknown'); + print_error('cmunknown'); } $modrec->instance = $modrec->id; $modrec->cmid = $cmrec->id; @@ -85,7 +85,7 @@ function question_can_delete_cat($todelete){ $contextid = $record->contextid; $count = $record->count; if ($count < 2) { - error('You can\'t delete that category it is the default category for this context.'); + print_error('You can\'t delete that category it is the default category for this context.'); } else { require_capability('moodle/question:managecategory', get_context_instance_by_id($contextid)); } @@ -418,7 +418,7 @@ function question_showbank_actions($pageurl, $cm){ $category = required_param('category', PARAM_SEQUENCE); list($tocategoryid, $contextid) = explode(',', $category); if (! $tocategory = get_record('question_categories', 'id', $tocategoryid, 'contextid', $contextid)) { - error('Could not find category record'); + print_error('Could not find category record'); } $tocontext = get_context_instance_by_id($contextid); require_capability('moodle/question:add', $tocontext); @@ -449,7 +449,7 @@ function question_showbank_actions($pageurl, $cm){ foreach ($questionids as $questionid){ //move question if (!set_field('question', 'category', $tocategory->id, 'id', $questionid)) { - error('Could not update category field'); + print_error('Could not update category field'); } } redirect($returnurl); @@ -481,7 +481,7 @@ function question_showbank_actions($pageurl, $cm){ record_exists('question_states', 'originalquestion', $questionid)) { if (!set_field('question', 'hidden', 1, 'id', $questionid)) { question_require_capability_on($questionid, 'edit'); - error('Was not able to hide question'); + print_error('Was not able to hide question'); } } else { delete_question($questionid); @@ -490,7 +490,7 @@ function question_showbank_actions($pageurl, $cm){ } redirect($pageurl->out()); } else { - error("Confirmation string was incorrect"); + print_error("Confirmation string was incorrect"); } @@ -502,7 +502,7 @@ function question_showbank_actions($pageurl, $cm){ $unhide = required_param('unhide', PARAM_INT); question_require_capability_on($unhide, 'edit'); if(!set_field('question', 'hidden', 0, 'id', $unhide)) { - error("Failed to unhide the question."); + print_error("Failed to unhide the question."); } redirect($pageurl->out()); } @@ -680,7 +680,7 @@ function question_edit_setup($edittab, $requirecmid = false, $requirecourseid = if (!empty($pagevars['cat'])){ $catparts = explode(',', $pagevars['cat']); if (!$catparts[0] || (FALSE !== array_search($catparts[1], $contextlistarr)) || !count_records_select("question_categories", "id = '".$catparts[0]."' AND contextid = $catparts[1]")) { - error(get_string('invalidcategory', 'quiz')); + print_error('invalidcategory', 'quiz'); } } else { $category = $defaultcategory; @@ -886,12 +886,12 @@ function require_login_in_context($contextorid = null){ } else if ($context && ($context->contextlevel == CONTEXT_MODULE)) { if ($cm = get_record('course_modules','id',$context->instanceid)) { if (!$course = get_record('course', 'id', $cm->course)) { - error('Incorrect course.'); + print_error('Incorrect course.'); } require_course_login($course, true, $cm); } else { - error('Incorrect course module id.'); + print_error('Incorrect course module id.'); } } else if ($context && ($context->contextlevel == CONTEXT_SYSTEM)) { if (!empty($CFG->forcelogin)) { diff --git a/question/export.php b/question/export.php index 77babbaecb266..c428fa41a1361 100644 --- a/question/export.php +++ b/question/export.php @@ -81,7 +81,7 @@ if (! is_readable("format/$from_form->format/format.php")) { - error("Format not known ($from_form->format)"); + print_error("Format not known ($from_form->format)"); } // load parent class for import/export @@ -104,15 +104,15 @@ $qformat->setContexttofile(!empty($from_form->contexttofile)); if (! $qformat->exportpreprocess()) { // Do anything before that we need to - error($txt->exporterror, $thispageurl->out()); + print_error($txt->exporterror, '', $thispageurl->out()); } if (! $qformat->exportprocess()) { // Process the export data - error($txt->exporterror, $thispageurl->out()); + print_error($txt->exporterror, '', $thispageurl->out()); } if (! $qformat->exportpostprocess()) { // In case anything needs to be done after - error($txt->exporterror, $thispageurl->out()); + print_error($txt->exporterror, '', $thispageurl->out()); } echo "


    "; diff --git a/question/file.php b/question/file.php index 841a317bf5c55..549b470be31f7 100644 --- a/question/file.php +++ b/question/file.php @@ -20,9 +20,9 @@ // relative path must start with '/', because of backup/restore!!! if (!$relativepath) { - error('No valid arguments supplied or incorrect server configuration'); + print_error('No valid arguments supplied or incorrect server configuration'); } else if ($relativepath{0} != '/') { - error('No valid arguments supplied, path does not start with slash!'); + print_error('No valid arguments supplied, path does not start with slash!'); } $pathname = $CFG->dataroot.'/questionattempt'.$relativepath; @@ -32,7 +32,7 @@ // check for the right number of directories in the path if (count($args) != 3) { - error('Invalid arguments supplied'); + print_error('Invalid arguments supplied'); } // security: require login @@ -81,6 +81,6 @@ function question_attempt_not_found() { global $CFG; header('HTTP/1.0 404 not found'); - error(get_string('filenotfound', 'error'), $CFG->wwwroot); //this is not displayed on IIS?? + print_error('filenotfound', 'error', $CFG->wwwroot); //this is not displayed on IIS?? } ?> diff --git a/question/format.php b/question/format.php index a199e9c877e67..2df8f3fc05420 100644 --- a/question/format.php +++ b/question/format.php @@ -294,7 +294,7 @@ function importprocess() { $question->timecreated = time(); if (!$question->id = insert_record("question", $question)) { - error( get_string('cannotinsert','quiz') ); + print_error('cannotinsert','quiz'); } $this->questionids[] = $question->id; @@ -384,7 +384,7 @@ function create_category_path($catpath, $delimiter='/') { $category->sortorder = 999; $category->stamp = make_unique_id_code(); if (!($id = insert_record('question_categories', $category))) { - error( "cannot create new category - $catname" ); + print_error( "cannot create new category - $catname" ); } $category->id = $id; $parent = $id; @@ -618,7 +618,7 @@ function exportprocess() { // create a directory for the exports (if not already existing) if (! $export_dir = make_upload_directory($this->question_get_export_dir())) { - error( get_string('cannotcreatepath','quiz',$export_dir) ); + print_error('cannotcreatepath', 'quiz', $export_dir); } $path = $CFG->dataroot.'/'.$this->question_get_export_dir(); diff --git a/question/format/blackboard_6/format.php b/question/format/blackboard_6/format.php index efd791587071c..a326da0aad270 100644 --- a/question/format/blackboard_6/format.php +++ b/question/format/blackboard_6/format.php @@ -159,7 +159,7 @@ function readdata($filename) { if ($this->check_and_create_import_dir($unique_code)) { if(is_readable($filename)) { if (!copy($filename, "$temp_dir/bboard.zip")) { - error("Could not copy backup file"); + print_error("Could not copy backup file"); } if(unzip_file("$temp_dir/bboard.zip", '', false)) { // assuming that the information is in res0001.dat @@ -178,12 +178,12 @@ function readdata($filename) { } } else { - error("Could not find question data file in zip"); + print_error("Could not find question data file in zip"); } } else { print "filename: $filename
    tempdir: $temp_dir
    "; - error("Could not unzip file."); + print_error("Could not unzip file."); } } else { @@ -191,7 +191,7 @@ function readdata($filename) { } } else { - error("Could not create temporary directory"); + print_error("Could not create temporary directory"); } } diff --git a/question/format/coursetestmanager/format.php b/question/format/coursetestmanager/format.php index f5676bb2e9f91..c75578f30ccf8 100755 --- a/question/format/coursetestmanager/format.php +++ b/question/format/coursetestmanager/format.php @@ -43,7 +43,7 @@ function importprocess($filename) { if ((PHP_OS == "Linux") and !isset($hostname)) { // copy the file to a semi-permanent location if (! $basedir = make_upload_directory("$COURSE->id")) { - error("The site administrator needs to fix the file permissions for the data directory"); + print_error("The site administrator needs to fix the file permissions for the data directory"); } if (!isset($hostname_access_error)) { $bname=basename($filename); @@ -101,7 +101,7 @@ function importprocess($filename) { if (PHP_OS == "WINNT") { // copy the file to a semi-permanent location if (! $basedir = make_upload_directory("$COURSE->id")) { - error("The site administrator needs to fix the file permissions for the data directory"); + print_error("The site administrator needs to fix the file permissions for the data directory"); } $bname=basename($filename); $cleanfilename = clean_filename($bname); @@ -124,7 +124,7 @@ function importprocess($filename) { } // print the intermediary form if (!$categories = question_category_options($COURSE->id, true)) { - error("No categories!"); + print_error("No categories!"); } print_heading_with_help($strimportquestions, "import", "quiz"); print_simple_box_start("center"); @@ -264,7 +264,7 @@ function importprocess($filename) { $question->createdby = $USER->id; $question->timecreated = time(); if (!$question->id = insert_record("question", $question)) { - error("Could not insert new question!"); + print_error("Could not insert new question!"); } $this->questionids[] = $question->id; // Now to save all the answers and type-specific options diff --git a/question/format/qti2/format.php b/question/format/qti2/format.php index 42b49ad1734bd..03765607380bb 100644 --- a/question/format/qti2/format.php +++ b/question/format/qti2/format.php @@ -110,7 +110,7 @@ function indent_xhtml($source, $indenter = ' ') { function importpreprocess() { global $CFG; - error("Sorry, importing this format is not yet implemented!", + print_error("Sorry, importing this format is not yet implemented!", '', "$CFG->wwwroot/mod/quiz/import.php?category=$category->id"); } @@ -241,7 +241,7 @@ function exportprocess() { // create a directory for the exports (if not already existing) if (!$export_dir = make_upload_directory($this->question_get_export_dir().'/'.$this->filename)) { - error( get_string('cannotcreatepath','quiz',$export_dir) ); + print_error('cannotcreatepath', 'quiz', '', $export_dir); } $path = $CFG->dataroot.'/'.$this->question_get_export_dir().'/'.$this->filename; @@ -274,13 +274,13 @@ function exportprocess() { $expout = $smarty->fetch('imsmanifest.tpl'); $filepath = $path.'/imsmanifest.xml'; if (empty($expout)) { - error("Unkown error - empty imsmanifest.xml"); + print_error("Unkown error - empty imsmanifest.xml"); } if (!$fh=fopen($filepath,"w")) { - error("Cannot open for writing: $filepath"); + print_error("Cannot open for writing: $filepath"); } if (!fwrite($fh, $expout)) { - error("Cannot write exported questions to $filepath"); + print_error("Cannot write exported questions to $filepath"); } fclose($fh); @@ -295,10 +295,10 @@ function exportprocess() { $filepath = $path.'/'.$this->get_assesment_item_id($question) . ".xml"; if (!$fh=fopen($filepath,"w")) { - error("Cannot open for writing: $filepath"); + print_error("Cannot open for writing: $filepath"); } if (!fwrite($fh, $expout)) { - error("Cannot write exported questions to $filepath"); + print_error("Cannot write exported questions to $filepath"); } fclose($fh); @@ -332,13 +332,13 @@ function export_quiz($course, $quiz, $questions, $result, $redirect, $submiturl $this->xml_entitize($result); $this->xml_entitize($submiturl); if (! $this->exportpreprocess(0, $course)) { // Do anything before that we need to - error("Error occurred during pre-processing!", $redirect); + print_error("Error occurred during pre-processing!", '', $redirect); } if (! $this->exportprocess_quiz($quiz, $questions, $result, $submiturl, $course)) { // Process the export data - error("Error occurred during processing!", $redirect); + print_error("Error occurred during processing!", '', $redirect); } if (! $this->exportpostprocess()) { // In case anything needs to be done after - error("Error occurred during post-processing!", $redirect); + print_error("Error occurred during post-processing!", '', $redirect); } } @@ -675,7 +675,7 @@ function & init_smarty() { $path = $CFG->dataroot."/smarty_c"; if (!is_dir($path)) { if (!mkdir($path, $CFG->directorypermissions)) { - error("Cannot create path: $path"); + print_error("Cannot create path: $path"); } } $smarty = new Smarty; diff --git a/question/format/webct/format.php b/question/format/webct/format.php index 6557c9688f862..85cf161c963a4 100644 --- a/question/format/webct/format.php +++ b/question/format/webct/format.php @@ -106,21 +106,21 @@ function qformat_webct_convert_formula($formula) { for ($i = 1 ; $deep ; ++$i) { if (!ereg('^(.*[^[:alnum:]_])?([[:alnum:]_]*([)(])([^)(]*[)(]){'.$i.'})$', $splits[0], $regs)) { - error("Parenthesis before ** is not properly started in $splits[0]**"); + print_error("Parenthesis before ** is not properly started in $splits[0]**"); } if ('(' == $regs[3]) { --$deep; } else if (')' == $regs[3]) { ++$deep; } else { - error("Impossible character $regs[3] detected as parenthesis character"); + print_error("Impossible character $regs[3] detected as parenthesis character"); } } $base = $regs[2]; $splits[0] = $regs[1]; } else { - error("Bad base before **: $splits[0]**"); + print_error("Bad base before **: $splits[0]**"); } // Find $exp (similar to above but a little easier) @@ -136,14 +136,14 @@ function qformat_webct_convert_formula($formula) { for ($i = 1 ; $deep ; ++$i) { if (!ereg('^([+-]?[[:alnum:]_]*([)(][^)(]*){'.$i.'}([)(]))(.*)', $splits[1], $regs)) { - error("Parenthesis after ** is not properly closed in **$splits[1]"); + print_error("Parenthesis after ** is not properly closed in **$splits[1]"); } if (')' == $regs[3]) { --$deep; } else if ('(' == $regs[3]) { ++$deep; } else { - error("Impossible character $regs[3] detected as parenthesis character"); + print_error("Impossible character $regs[3] detected as parenthesis character"); } } $exp = $regs[1]; diff --git a/question/format/xml/format.php b/question/format/xml/format.php index 36d70334cedd2..e2e77039e54c1 100755 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -996,7 +996,7 @@ function writequestion( $question ) { default: // try support by optional plugin if (!$data = $this->try_exporting_using_qtypes( $question->qtype, $question )) { - error( "Unsupported question type $question->qtype" ); + print_error( "Unsupported question type $question->qtype" ); } $expout .= $data; } diff --git a/question/import.php b/question/import.php index ee11b55dee37e..4d6faeec02303 100644 --- a/question/import.php +++ b/question/import.php @@ -95,12 +95,12 @@ if (file_exists($importfile)) { $fileisgood = true; } else { - error(get_string('uploadproblem', 'moodle', $form->choosefile)); + print_error('uploadproblem', 'moodle', $form->choosefile); } } else { // must be upload file if (!$importfile = $import_form->get_importfile_name()) { - error(get_string('uploadproblem', 'moodle')); + print_error('uploadproblem', 'moodle'); }else { $fileisgood = true; } @@ -110,7 +110,7 @@ if ($fileisgood) { if (! is_readable("format/$form->format/format.php")) { - error(get_string('formatnotfound','quiz', $form->format)); + print_error('formatnotfound','quiz', $form->format); } require_once("format.php"); // Parent class @@ -131,17 +131,17 @@ // Do anything before that we need to if (! $qformat->importpreprocess()) { - error($txt->importerror, $thispageurl->out()); + print_error($txt->importerror, '', $thispageurl->out()); } // Process the uploaded file if (! $qformat->importprocess()) { - error($txt->importerror, $thispageurl->out()); + print_error($txt->importerror, '', $thispageurl->out()); } // In case anything needs to be done after if (! $qformat->importpostprocess()) { - error($txt->importerror, $thispageurl->out()); + print_error($txt->importerror, '', $thispageurl->out()); } echo "
    "; diff --git a/question/preview.php b/question/preview.php index 2246b13fec136..06c04779bf11c 100644 --- a/question/preview.php +++ b/question/preview.php @@ -60,7 +60,7 @@ } // Load the question information if (!$questions = get_records('question', 'id', $id)) { - error('Could not load question'); + print_error('Could not load question'); } if (empty($quizid)) { $quiz = new cmoptions; @@ -69,7 +69,7 @@ require_login($courseid, false); $quiz->course = $courseid; } else if (!$quiz = get_record('quiz', 'id', $quizid)) { - error("Quiz id $quizid does not exist"); + print_error("Quiz id $quizid does not exist"); } else { require_login($quiz->course, false, get_coursemodule_from_instance('quiz', $quizid, $quiz->course)); } @@ -86,11 +86,11 @@ $quiz->questions = $id; if (!$category = get_record("question_categories", "id", $questions[$id]->category)) { - error("This question doesn't belong to a valid category!"); + print_error("This question doesn't belong to a valid category!"); } if (!question_has_capability_on($questions[$id], 'use', $questions[$id]->category)){ - error("You can't preview these questions!"); + print_error("You can't preview these questions!"); } if (isset($COURSE)){ $quiz->course = $COURSE->id; @@ -98,7 +98,7 @@ // Load the question type specific information if (!get_question_options($questions)) { - error(get_string('newattemptfail', 'quiz')); + print_error('newattemptfail', 'quiz'); } // Create a dummy quiz attempt @@ -133,7 +133,7 @@ // Create an empty session for the question if (!$newstates = get_question_states($questions, $quiz, $attempt)) { - error(get_string('newattemptfail', 'quiz')); + print_error('newattemptfail', 'quiz'); } $SESSION->quizpreview->states = array($newstates); $states =& $SESSION->quizpreview->states; diff --git a/question/question.php b/question/question.php index ccede2d6ffe52..39fbb7c25dde0 100644 --- a/question/question.php +++ b/question/question.php @@ -41,7 +41,7 @@ $module = null; $cm = null; } else { - error('Need to pass courseid or cmid to this script.'); + print_error('Need to pass courseid or cmid to this script.'); } $contexts = new question_edit_contexts($thiscontext); diff --git a/question/restorelib.php b/question/restorelib.php index 1600ccfe71ba6..8ed49822dec75 100644 --- a/question/restorelib.php +++ b/question/restorelib.php @@ -821,7 +821,7 @@ function question_states_restore_mods($attempt_id,$info,$restore) { //It depends of the question type !! //We get the question first if (!$question = get_record("question","id",$state->question)) { - error("Can't find the record for question $state->question for which I am trying to restore a state"); + print_error("Can't find the record for question $state->question for which I am trying to restore a state"); } //Depending on the qtype, we make different recodes if ($state->answer) { diff --git a/question/tabs.php b/question/tabs.php index 3f6868c5356e5..1cd757d29f17d 100644 --- a/question/tabs.php +++ b/question/tabs.php @@ -12,7 +12,7 @@ $currenttab = ''; } if (!isset($COURSE)) { - error('No course specified'); + print_error('No course specified'); } $tabs = array(); diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index f87c9493e5d9f..a587a684b1071 100644 --- a/question/type/calculated/questiontype.php +++ b/question/type/calculated/questiontype.php @@ -247,7 +247,7 @@ function import_datasets($question){ if ( $todo=='create'){ if (!$datasetdef->id = insert_record( 'question_dataset_definitions', $datasetdef)) { - error("Unable to create dataset $defid"); + print_error("Unable to create dataset $defid"); } } // Create relation to the dataset: @@ -256,7 +256,7 @@ function import_datasets($question){ $questiondataset->datasetdefinition = $datasetdef->id; if (!insert_record('question_datasets', $questiondataset)) { - error("Unable to create relation to dataset $dataset->name $todo"); + print_error("Unable to create relation to dataset $dataset->name $todo"); } if ($todo=='create'){ // add the items foreach ($dataset->datasetitem as $dataitem ){ @@ -265,7 +265,7 @@ function import_datasets($question){ $datasetitem->itemnumber = $dataitem->itemnumber ; $datasetitem->value = $dataitem->value ; if (!insert_record('question_dataset_items', $datasetitem)) { - error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name"); + print_error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name"); } } } @@ -322,7 +322,7 @@ function validate_form($form) { foreach ($calculatedmessages as $msg) { $errorstring .= $msg . '
    '; } - error($errorstring); + print_error($errorstring); } break; @@ -623,11 +623,11 @@ function save_dataset_items($question, $fromform){ // Reuse any previously used record $addeditem->id = $fromform->itemid[$i]; if (!update_record('question_dataset_items', $addeditem)) { - error("Error: Unable to update dataset item"); + print_error("Error: Unable to update dataset item"); } } else { if (!insert_record('question_dataset_items', $addeditem)) { - error("Error: Unable to insert dataset item"); + print_error("Error: Unable to insert dataset item"); } } @@ -674,7 +674,7 @@ function save_dataset_items($question, $fromform){ } //pp echo "
    "; print_r( $datasetitem );
                             if (!insert_record('question_dataset_items', $datasetitem)) {
    -                            error("Error: Unable to insert new dataset item");
    +                            print_error("Error: Unable to insert new dataset item");
                             }                        
                         }
                     }//for number added
    @@ -698,7 +698,7 @@ function save_dataset_items($question, $fromform){
                         $datasetdef->itemcount= $newmaxnumber ;        
                         if (!update_record('question_dataset_definitions',
                                            $datasetdef)) {
    -                         error("Error: Unable to update itemcount");
    +                         print_error("Error: Unable to update itemcount");
                         }
                     }
                 }
    @@ -720,7 +720,7 @@ function generate_dataset_item($options) {
                 return sprintf("%.".$regs[4]."f",$nbr);
      
             } else {
    -            error("The distribution $regs[1] caused problems");
    +            print_error("The distribution $regs[1] caused problems");
             }
             return '';
         }
    diff --git a/question/type/datasetdependent/abstractqtype.php b/question/type/datasetdependent/abstractqtype.php
    index 54edd15fc0d98..323ff36331150 100644
    --- a/question/type/datasetdependent/abstractqtype.php
    +++ b/question/type/datasetdependent/abstractqtype.php
    @@ -36,7 +36,7 @@ function create_session_and_responses(&$question, &$state, $cmoptions, $attempt)
                                      {$CFG->prefix}question_datasets b
                                 WHERE b.question = $question->id
                                 AND   a.id = b.datasetdefinition")) {
    -            error("Couldn't get the specified dataset for a calculated " .
    +            print_error("Couldn't get the specified dataset for a calculated " .
                       "question! (question: {$question->id}");
             }
     
    @@ -131,7 +131,7 @@ function print_next_wizard_page(&$question, &$form, $course) {
                     require("$CFG->dirroot/question/type/datasetdependent/datasetitems.php");
                     break;
                 default:
    -                error('Incorrect or no wizard page specified!');
    +                print_error('Incorrect or no wizard page specified!');
                     break;
             }
         }
    @@ -160,7 +160,7 @@ function &next_wizard_form($submiturl, $question, $wizardnow){
                     $mform =& new question_dataset_dependent_items_form("$submiturl?wizardnow=datasetitems", $question, $regenerate);
                     break;
                 default:
    -                error('Incorrect or no wizard page specified!');
    +                print_error('Incorrect or no wizard page specified!');
                     break;
             }
     
    @@ -313,7 +313,7 @@ function save_question($question, $form, $course) {
                     $this->save_dataset_items($question, $form);
                     break;
                 default:
    -                error('Incorrect or no wizard page specified!');
    +                print_error('Incorrect or no wizard page specified!');
                     break;
             }
             return $question;
    @@ -388,7 +388,7 @@ function save_dataset_definitions($form) {
     
                 if (!$datasetdef->id = insert_record(
                         'question_dataset_definitions', $datasetdef)) {
    -                error("Unable to create dataset $defid");
    +                print_error("Unable to create dataset $defid");
                 }
     
                 if (0 != $datasetdef->category) {
    @@ -419,7 +419,7 @@ function save_dataset_definitions($form) {
                 $questiondataset->datasetdefinition = $datasetdef->id;
                 if (!insert_record('question_datasets',
                                    $questiondataset)) {
    -                error("Unable to create relation to dataset $name");
    +                print_error("Unable to create relation to dataset $name");
                 }
                 unset($datasetdefinitions[$defid]);
             }
    @@ -468,7 +468,7 @@ function save_as_new_dataset_definitions($form, $initialid) {
                        $datasetdef->itemcount =0;
                        if (!$datasetdef->id = insert_record(
                             'question_dataset_definitions', $datasetdef)) {
    -                        error("Unable to create dataset $defid");
    +                        print_error("Unable to create dataset $defid");
                        }
                        //copy the dataitems
                        $olditems = get_records_sql( // Use number as key!!
    @@ -480,7 +480,7 @@ function save_as_new_dataset_definitions($form, $initialid) {
                             foreach($olditems as $item ){
                                 $item->definition = $datasetdef->id;
                             if (!insert_record('question_dataset_items', $item)) {
    -                            error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
    +                            print_error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
                             }
                             $itemcount++;
                             }
    @@ -496,7 +496,7 @@ function save_as_new_dataset_definitions($form, $initialid) {
                     $questiondataset->datasetdefinition = $datasetdef->id;
                     if (!insert_record('question_datasets',
                                        $questiondataset)) {
    -                    error("Unable to create relation to dataset $name");
    +                    print_error("Unable to create relation to dataset $name");
                     }
                     unset($datasetdefinitions[$defid]);
                     continue;
    @@ -504,7 +504,7 @@ function save_as_new_dataset_definitions($form, $initialid) {
                 // really new one code similar to save_dataset_definitions()
                 if (!$datasetdef->id = insert_record(
                         'question_dataset_definitions', $datasetdef)) {
    -                error("Unable to create dataset $defid");
    +                print_error("Unable to create dataset $defid");
                 }
     
                 if (0 != $datasetdef->category) {
    @@ -535,7 +535,7 @@ function save_as_new_dataset_definitions($form, $initialid) {
                 $questiondataset->datasetdefinition = $datasetdef->id;
                 if (!insert_record('question_datasets',
                                    $questiondataset)) {
    -                error("Unable to create relation to dataset $name");
    +                print_error("Unable to create relation to dataset $name");
                 }
                 unset($datasetdefinitions[$defid]);
             }
    @@ -608,7 +608,7 @@ function save_question($question, &$form, $course) {
     
                     break;
                 default:
    -                error('Incorrect or no wizard page specified!');
    +                print_error('Incorrect or no wizard page specified!');
                     break;
             }
             return $question;
    @@ -633,7 +633,7 @@ function pick_question_dataset($question, $datasetitem) {
                             AND q.datasetdefinition = d.id
                             AND d.id = i.definition
                             AND i.itemnumber = $datasetitem")) {
    -            error("Couldn't get the specified dataset for a dataset dependent " .
    +            print_error("Couldn't get the specified dataset for a dataset dependent " .
                       "question! (question: {$question->id}, " .
                       "datasetitem: {$datasetitem})");
             }
    @@ -642,7 +642,7 @@ function pick_question_dataset($question, $datasetitem) {
         }
     
         function create_virtual_qtype() {
    -        error("No virtual question type for question type ".$this->name());
    +        print_error("No virtual question type for question type ".$this->name());
         }
     
         function get_virtual_qtype() {
    @@ -757,7 +757,7 @@ function find_dataset_names($text) {
     
         function create_virtual_nameprefix($nameprefix, $datasetinput) {
             if (!ereg('([0-9]+)' . $this->name() . '$', $nameprefix, $regs)) {
    -            error("Wrongly formatted nameprefix $nameprefix");
    +            print_error("Wrongly formatted nameprefix $nameprefix");
             }
             $virtualqtype = $this->get_virtual_qtype();
             return $nameprefix . $regs[1] . $virtualqtype->name();
    diff --git a/question/type/description/questiontype.php b/question/type/description/questiontype.php
    index 8fb0894ec07c3..1a2434b55371d 100644
    --- a/question/type/description/questiontype.php
    +++ b/question/type/description/questiontype.php
    @@ -50,7 +50,7 @@ function print_question(&$question, &$state, $number, $cmoptions, $options) {
             } else if (!empty($cmoptions->course)) {
                 $cmorcourseid = '&courseid='.$cmoptions->course;
             } else {
    -            error('Need to provide courseid or cmid to print_question.');
    +            print_error('Need to provide courseid or cmid to print_question.');
             }
     
             // For editing teachers print a link to an editing popup window
    diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php
    index 8e90af878f5cb..6ab57da88feef 100644
    --- a/question/type/match/questiontype.php
    +++ b/question/type/match/questiontype.php
    @@ -674,7 +674,7 @@ function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destin
                     $subquestion->questiontext = question_replace_file_links_in_html($subquestion->questiontext, $fromcourseid, $tocourseid, $url, $destination, $subquestionchanged);
                     if ($subquestionchanged){//need to update rec in db
                         if (!update_record('question_match_sub', addslashes_recursive($subquestion))) {
    -                        error('Couldn\'t update \'question_match_sub\' record '.$subquestion->id);
    +                        print_error('Couldn\'t update \'question_match_sub\' record '.$subquestion->id);
                         }
     
                     }
    diff --git a/question/type/multianswer/edit_multianswer_form.php b/question/type/multianswer/edit_multianswer_form.php
    index 055cfd9f7ff67..38bb9fc5f1e25 100644
    --- a/question/type/multianswer/edit_multianswer_form.php
    +++ b/question/type/multianswer/edit_multianswer_form.php
    @@ -99,7 +99,7 @@ function set_data($question) {
                                 $parsableanswerdef .= 'NUMERICAL:';
                                 break;
                             default:
    -                            error("questiontype $wrapped->qtype not recognized");
    +                            print_error("questiontype $wrapped->qtype not recognized");
                         }
                         $separator= '';
                         foreach ($wrapped->options->answers as $subanswer) {
    diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php
    index cc320d5d7d2a3..a57c9376e3aa8 100644
    --- a/question/type/multianswer/questiontype.php
    +++ b/question/type/multianswer/questiontype.php
    @@ -87,7 +87,7 @@ function save_question_options($question) {
                                  delete_records('question_numerical', 'question', $oldwrappedid);
                                 break;
                             default:
    -                            error("questiontype $wrapped->qtype not recognized");
    +                            print_error("questiontype $wrapped->qtype not recognized");
                         }
                     }
                 }
    @@ -378,7 +378,7 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
                         echo $feedbackimg;
                         break;
                     default:
    -                    error("Unable to recognize questiontype ($wrapped->qtype) of
    +                    print_error("Unable to recognize questiontype ($wrapped->qtype) of
                                question part $positionkey.");
                         break;
                }
    @@ -602,7 +602,7 @@ function restore_recode_answer($state, $restore) {
                 $answer = $exploded[1];
                 // $sequence is an ordered array of the question ids.
                 if (!$sequence = get_field('question_multianswer', 'sequence', 'question', $state->question)) {
    -                error("The cloze question $state->question is missing its options");
    +                print_error("The cloze question $state->question is missing its options");
                 }
                 $sequence = explode(',', $sequence);
                 // The id of the current question.
    @@ -729,7 +729,7 @@ function qtype_multianswer_extract_question($text) {
                 $wrapped->partiallycorrectfeedback = '';
                 $wrapped->incorrectfeedback = '';
             } else {
    -            error("Cannot identify qtype $answerregs[2]");
    +            print_error("Cannot identify qtype $answerregs[2]");
                 return false;
             }
     
    diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php
    index 0c1207d1d56f5..5e0459c50ef7c 100644
    --- a/question/type/multichoice/questiontype.php
    +++ b/question/type/multichoice/questiontype.php
    @@ -656,7 +656,7 @@ function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destin
             $newoptions->incorrectfeedback = question_replace_file_links_in_html($question->options->incorrectfeedback, $fromcourseid, $tocourseid, $url, $destination, $optionschanged);
             if ($optionschanged){
                 if (!update_record('question_multichoice', addslashes_recursive($newoptions))) {
    -                error('Couldn\'t update \'question_multichoice\' record '.$newoptions->id);
    +                print_error('Couldn\'t update \'question_multichoice\' record '.$newoptions->id);
                 }
             }
             $answerchanged = false;
    @@ -664,7 +664,7 @@ function replace_file_links($question, $fromcourseid, $tocourseid, $url, $destin
                 $answer->answer = question_replace_file_links_in_html($answer->answer, $fromcourseid, $tocourseid, $url, $destination, $answerchanged);
                 if ($answerchanged){
                     if (!update_record('question_answers', addslashes_recursive($answer))){
    -                    error('Couldn\'t update \'question_answers\' record '.$answer->id);
    +                    print_error('Couldn\'t update \'question_answers\' record '.$answer->id);
                     }
                 }
             }
    diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php
    index d0c2d20f510cd..0c08fdc409221 100644
    --- a/question/type/numerical/questiontype.php
    +++ b/question/type/numerical/questiontype.php
    @@ -344,7 +344,7 @@ function get_tolerance_interval(&$answer) {
                     $min = $answer->answer / $quotient;
                     break;
                 default:
    -                error("Unknown tolerance type $answer->tolerancetype");
    +                print_error("Unknown tolerance type $answer->tolerancetype");
             }
     
             $answer->min = $min;
    diff --git a/question/type/questiontype.php b/question/type/questiontype.php
    index e6654ffb5d393..1a8ba309c2c65 100644
    --- a/question/type/questiontype.php
    +++ b/question/type/questiontype.php
    @@ -282,7 +282,7 @@ function save_question($question, $form, $course) {
                 $question->modifiedby = $USER->id;
                 $question->timemodified = time();
                 if (!update_record('question', $question)) {
    -                error('Could not update question!');
    +                print_error('Could not update question!');
                 }
             } else {         // Question is a new one
                 if (isset($form->categorymoveto)){
    @@ -302,7 +302,7 @@ function save_question($question, $form, $course) {
                 $question->timecreated = time();
                 $question->timemodified = time();
                 if (!$question->id = insert_record('question', $question)) {
    -                error('Could not insert new question!');
    +                print_error('Could not insert new question!');
                 }
             }
     
    @@ -316,7 +316,7 @@ function save_question($question, $form, $course) {
             $result = $this->save_question_options($form);
     
             if (!empty($result->error)) {
    -            error($result->error);
    +            print_error($result->error);
             }
     
             if (!empty($result->notice)) {
    @@ -332,7 +332,7 @@ function save_question($question, $form, $course) {
     
             // Give the question a unique version stamp determined by question_hash()
             if (!set_field('question', 'version', question_hash($question), 'id', $question->id)) {
    -            error('Could not update question version field');
    +            print_error('Could not update question version field');
             }
     
             return $question;
    @@ -824,7 +824,7 @@ function print_question(&$question, &$state, $number, $cmoptions, $options) {
                 $context = get_context_instance(CONTEXT_COURSE, $cmoptions->course);
                 $cmorcourseid = '&courseid='.$cmoptions->course;
             } else {
    -            error('Need to provide courseid or cmid to print_question.');
    +            print_error('Need to provide courseid or cmid to print_question.');
             }
     
             // For editing teachers print a link to an editing popup window
    diff --git a/question/type/random/questiontype.php b/question/type/random/questiontype.php
    index 17f80e22a53db..20c85465798a5 100644
    --- a/question/type/random/questiontype.php
    +++ b/question/type/random/questiontype.php
    @@ -54,11 +54,11 @@ function save_question($question, $form, $course) {
             $form->name = '';
             $question = parent::save_question($question, $form, $course);
             if (!$category = get_record('question_categories', 'id', $question->category)) {
    -            error('Could retrieve question category');
    +            print_error('Could retrieve question category');
             }
             $question->name = $this->question_name($category);
             if (!set_field('question', 'name', $question->name, 'id', $question->id)) {
    -            error('Could not update random question name');
    +            print_error('Could not update random question name');
             }
             return $question;
         }
    diff --git a/search/tests/index.php b/search/tests/index.php
    index f09e3cc9ebe8d..8b111808f534b 100644
    --- a/search/tests/index.php
    +++ b/search/tests/index.php
    @@ -26,11 +26,11 @@
     print_header("$strsearch", "$site->fullname" , $navigation, "", "", true, " ", navmenu($site));
       
     if (empty($CFG->enableglobalsearch)) {
    -    error('Global searching is not enabled.');
    +    print_error('Global searching is not enabled.');
     }
     
     if (!isadmin()) {
    -    error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
    +    print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
     } //if
     
     mtrace('
    Server Time: '.date('r',time()));
    @@ -103,4 +103,4 @@
     mtrace("
    Back to query page or Start indexing."); mtrace('
    '); print_footer(); -?> \ No newline at end of file +?> diff --git a/tag/edit.php b/tag/edit.php index 8fee2b462eaa0..3da6fc63324d2 100644 --- a/tag/edit.php +++ b/tag/edit.php @@ -9,7 +9,7 @@ require_login(); if (empty($CFG->usetags)) { - error(get_string('tagsaredisabled', 'tag')); + print_error('tagsaredisabled', 'tag'); } $tag_id = optional_param('id', 0, PARAM_INT); @@ -89,7 +89,7 @@ // rename tag if needed if (!tag_rename($tag->id, $tagnew->rawname)) { - error('Error updating tag record'); + print_error('Error updating tag record'); } //updated related tags diff --git a/tag/user.php b/tag/user.php index b683b889d70c8..7259e0e654f56 100644 --- a/tag/user.php +++ b/tag/user.php @@ -10,7 +10,7 @@ require_login(); if (empty($CFG->usetags)) { - error('Tags are disabled!'); + print_error('Tags are disabled!'); } if (isguestuser()) { @@ -51,7 +51,7 @@ break; default: - error('No action was specified'); + print_error('No action was specified'); break; } diff --git a/theme/chameleon/ui/css.php b/theme/chameleon/ui/css.php index 3b78f645ff29a..63125fbc867c7 100644 --- a/theme/chameleon/ui/css.php +++ b/theme/chameleon/ui/css.php @@ -10,7 +10,7 @@ $id = optional_param('id', SITEID, PARAM_INT); if (!$course = get_record('course', 'id', $id)) { - error('Incorrect course id'); + print_error('Incorrect course id'); } course_setup($course); // we should not require login here diff --git a/theme/index.php b/theme/index.php index 8ef5e4cecbdfb..371e66b77c2b2 100644 --- a/theme/index.php +++ b/theme/index.php @@ -23,7 +23,7 @@ if ($choose and confirm_sesskey()) { if (!is_dir($CFG->themedir .'/'. $choose)) { - error("This theme is not installed!"); + print_error("This theme is not installed!"); } if (set_config("theme", $choose)) { theme_setup($choose); @@ -47,7 +47,7 @@ admin_externalpage_print_footer(); exit; } else { - error("Could not set the theme!"); + print_error("Could not set the theme!"); } } diff --git a/theme/preview.php b/theme/preview.php index 196b9454a35a5..64995f3701626 100644 --- a/theme/preview.php +++ b/theme/preview.php @@ -9,7 +9,7 @@ } if (! $site = get_site()) { - error("Site doesn't exist!"); + print_error("Site doesn't exist!"); } require_login(); diff --git a/user/addnote.php b/user/addnote.php index fbf6861231f51..56fafed8485c2 100644 --- a/user/addnote.php +++ b/user/addnote.php @@ -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 = get_record('course', 'id', $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } $context = get_context_instance(CONTEXT_COURSE, $id); @@ -18,7 +18,7 @@ if (!empty($users) && confirm_sesskey()) { if (count($users) != count($contents) || count($users) != count($states)) { - error('Parameters malformation', $CFG->wwwroot.'/user/index.php?id='.$id); + print_error('Parameters malformation', '', $CFG->wwwroot.'/user/index.php?id='.$id); } $note = new object(); diff --git a/user/edit.php b/user/edit.php index 9dd872ba2b743..d237145aff78f 100644 --- a/user/edit.php +++ b/user/edit.php @@ -12,7 +12,7 @@ $course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site) if (!$course = get_record('course', 'id', $course)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } if ($course->id != SITEID) { @@ -31,7 +31,7 @@ // The user profile we are editing if (!$user = get_record('user', 'id', $userid)) { - error('User ID was incorrect'); + print_error('User ID was incorrect'); } // Guest can not be edited @@ -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)) { - error('Can not edit own profile, sorry.'); + print_error('Can not edit own profile, sorry.'); } } else { @@ -98,14 +98,14 @@ $usernew->timemodified = time(); if (!update_record('user', $usernew)) { - error('Error updating user record'); + print_error('Error updating user record'); } // pass a true $userold here if (! $authplugin->user_update($user, $userform->get_data(false))) { // auth update failed, rollback for moodle update_record('user', addslashes_object($user)); - error('Failed to update user data on external auth: '.$user->auth. + print_error('Failed to update user data on external auth: '.$user->auth. '. See the server logs for more details.'); } diff --git a/user/editadvanced.php b/user/editadvanced.php index 9382a3f1da5bd..3be1401a805d2 100644 --- a/user/editadvanced.php +++ b/user/editadvanced.php @@ -13,7 +13,7 @@ $course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site) if (!$course = get_record('course', 'id', $course)) { - error('Course ID was incorrect'); + print_error('Course ID was incorrect'); } require_login($course->id); @@ -35,7 +35,7 @@ // editing existing user require_capability('moodle/user:update', $systemcontext); if (!$user = get_record('user', 'id', $id)) { - error('User ID was incorrect'); + print_error('User ID was incorrect'); } } @@ -89,17 +89,17 @@ $usernew->confirmed = 1; $usernew->password = hash_internal_user_password($usernew->newpassword); if (!$usernew->id = insert_record('user', $usernew)) { - error('Error creating user record'); + print_error('Error creating user record'); } } else { if (!update_record('user', $usernew)) { - error('Error updating user record'); + print_error('Error updating user record'); } // pass a true $userold here if (! $authplugin->user_update($user, $userform->get_data(false))) { // auth update failed, rollback for moodle update_record('user', addslashes_object($user)); - error('Failed to update user data on external auth: '.$user->auth. + print_error('Failed to update user data on external auth: '.$user->auth. '. See the server logs for more details.'); } @@ -107,7 +107,7 @@ if (!empty($usernew->newpassword)) { if ($authplugin->can_change_password()) { if (!$authplugin->user_update_password($usernew, $usernew->newpassword)){ - error('Failed to update password on external auth: ' . $usernew->auth . + print_error('Failed to update password on external auth: ' . $usernew->auth . '. See the server logs for more details.'); } } diff --git a/user/extendenrol.php b/user/extendenrol.php index 33926c2bd0603..1054766ac3e5e 100644 --- a/user/extendenrol.php +++ b/user/extendenrol.php @@ -5,7 +5,7 @@ $users = optional_param('userid', array(), PARAM_INT); // array of user id if (! $course = get_record('course', 'id', $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } $context = get_context_instance(CONTEXT_COURSE, $id); @@ -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)) { - error('Parameters malformation', $CFG->wwwroot.'/user/index.php?id='.$id); + print_error('Parameters malformation', '', $CFG->wwwroot.'/user/index.php?id='.$id); } foreach ($form->userid as $k => $v) { diff --git a/user/filters/lib.php b/user/filters/lib.php index e4f3445e3bef3..08a65dda4dc7d 100644 --- a/user/filters/lib.php +++ b/user/filters/lib.php @@ -224,7 +224,7 @@ function user_filter_type($name, $label, $advanced) { * @return string the filtering condition or null if the filter is disabled */ function get_sql_filter($data) { - error('Abstract method get_sql_filter() called - must be implemented'); + print_error('Abstract method get_sql_filter() called - must be implemented'); } /** @@ -233,7 +233,7 @@ function get_sql_filter($data) { * @return mixed array filter data or false when filter not set */ function check_data($formdata) { - error('Abstract method check_data() called - must be implemented'); + print_error('Abstract method check_data() called - must be implemented'); } /** @@ -241,7 +241,7 @@ function check_data($formdata) { * @param object $mform a MoodleForm object to setup */ function setupForm(&$mform) { - error('Abstract method setupForm() called - must be implemented'); + print_error('Abstract method setupForm() called - must be implemented'); } /** @@ -250,6 +250,6 @@ function setupForm(&$mform) { * @return string active filter label */ function get_label($data) { - error('Abstract method get_label() called - must be implemented'); + print_error('Abstract method get_label() called - must be implemented'); } } diff --git a/user/groupaddnote.php b/user/groupaddnote.php index 7c74af82f6e80..faaa4d90b75d5 100644 --- a/user/groupaddnote.php +++ b/user/groupaddnote.php @@ -8,7 +8,7 @@ $state = optional_param('state', '', PARAM_ALPHA); // note publish state if (! $course = get_record('course', 'id', $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/user/groupextendenrol.php b/user/groupextendenrol.php index aa9f2a7ae07a6..76a2813399078 100755 --- a/user/groupextendenrol.php +++ b/user/groupextendenrol.php @@ -5,7 +5,7 @@ $users = optional_param('userid', array(), PARAM_INT); // array of user id if (! $course = get_record('course', 'id', $id)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } $context = get_context_instance(CONTEXT_COURSE, $id); diff --git a/user/index.php b/user/index.php index 9739c804967b2..257b1c6fb418f 100644 --- a/user/index.php +++ b/user/index.php @@ -25,17 +25,17 @@ if ($contextid) { if (! $context = get_context_instance_by_id($contextid)) { - error("Context ID is incorrect"); + print_error("Context ID is incorrect"); } if (! $course = get_record('course', 'id', $context->instanceid)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } } else { if (! $course = get_record('course', 'id', $courseid)) { - error("Course ID is incorrect"); + print_error("Course ID is incorrect"); } if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) { - error("Context ID is incorrect"); + print_error("Context ID is incorrect"); } } // not needed anymore @@ -520,7 +520,7 @@ if ($roleid) { if (!$currentrole = get_record('role','id',$roleid)) { - error('That role does not exist'); + print_error('That role does not exist'); } $a->number = $totalcount; // MDL-12217, use course specific rolename diff --git a/user/messageselect.php b/user/messageselect.php index 059598e32ef96..3ab50d83fbb87 100644 --- a/user/messageselect.php +++ b/user/messageselect.php @@ -13,7 +13,7 @@ $deluser = optional_param('deluser',0,PARAM_INT); if (!$course = get_record('course','id',$id)) { - error("Invalid course id"); + print_error("Invalid course id"); } require_login(); diff --git a/user/policy.php b/user/policy.php index e200d928968ad..f9b24a9beb7e3 100644 --- a/user/policy.php +++ b/user/policy.php @@ -14,7 +14,7 @@ if ($agree and confirm_sesskey()) { // User has agreed if (!isguestuser()) { // Don't remember guests if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) { - error('Could not save your agreement'); + print_error('Could not save your agreement'); } } $USER->policyagreed = 1; diff --git a/user/profile/definelib.php b/user/profile/definelib.php index 1b889c620807b..2852db2a9c636 100644 --- a/user/profile/definelib.php +++ b/user/profile/definelib.php @@ -154,11 +154,11 @@ function define_save($data) { if (empty($data->id)) { unset($data->id); if (!$data->id = insert_record('user_info_field', $data)) { - error('Error creating new field'); + print_error('Error creating new field'); } } else { if (!update_record('user_info_field', $data)) { - error('Error updating field'); + print_error('Error updating field'); } } } @@ -223,11 +223,11 @@ function profile_reorder_categories() { function profile_delete_category($id) { /// Retrieve the category if (!$category = get_record('user_info_category', 'id', $id)) { - error('Incorrect category id'); + print_error('Incorrect category id'); } if (!$categories = get_records_select('user_info_category', '', 'sortorder ASC')) { - error('Error no categories!?!?'); + print_error('Error no categories!?!?'); } unset($categories[$category->id]); @@ -262,7 +262,7 @@ function profile_delete_category($id) { /// Finally we get to delete the category if (!delete_records('user_info_category', 'id', $category->id)) { - error('Error while deliting category'); + print_error('Error while deliting category'); } profile_reorder_categories(); return true; @@ -273,7 +273,7 @@ function profile_delete_field($id) { /// Remove any user data associated with this field if (!delete_records('user_info_data', 'fieldid', $id)) { - error('Error deleting custom field data'); + print_error('Error deleting custom field data'); } /// Try to remove the record from the database @@ -414,11 +414,11 @@ function profile_edit_category($id, $redirect) { unset($data->id); $data->sortorder = count_records('user_info_category') + 1; if (!insert_record('user_info_category', $data, false)) { - error('There was a problem adding the record to the database'); + print_error('There was a problem adding the record to the database'); } } else { if (!update_record('user_info_category', $data)) { - error('There was a problem updating the record in the database'); + print_error('There was a problem updating the record in the database'); } } profile_reorder_categories(); diff --git a/user/profile/lib.php b/user/profile/lib.php index d406ad3a43899..c45074e936fb7 100644 --- a/user/profile/lib.php +++ b/user/profile/lib.php @@ -43,7 +43,7 @@ function profile_field_base($fieldid=0, $userid=0) { * @param form instance of the moodleform class */ function edit_field_add(&$mform) { - error('This abstract method must be overriden'); + print_error('This abstract method must be overriden'); } @@ -96,7 +96,7 @@ function edit_save_data($usernew) { if ($dataid = get_field('user_info_data', 'id', 'userid', $data->userid, 'fieldid', $data->fieldid)) { $data->id = $dataid; if (!update_record('user_info_data', $data)) { - error('Error updating custom profile field!'); + print_error('Error updating custom profile field!'); } } else { insert_record('user_info_data', $data); diff --git a/user/tabs.php b/user/tabs.php index a329943fd00b0..545b7e2bd3011 100644 --- a/user/tabs.php +++ b/user/tabs.php @@ -14,7 +14,7 @@ $filterselect = clean_param($filterselect, PARAM_INT); if (empty($currenttab) or empty($user) or empty($course)) { - //error('You cannot call this script in that way'); + //print_error('You cannot call this script in that way'); } if (($filtertype == 'site' && $filterselect) || ($filtertype=='user' && $filterselect)) { diff --git a/user/view.php b/user/view.php index bbd03126be75a..2b535032a8886 100644 --- a/user/view.php +++ b/user/view.php @@ -17,11 +17,11 @@ } if (! $user = get_record("user", "id", $id) ) { - error("No such user in this course"); + print_error("No such user in this course"); } if (! $course = get_record("course", "id", $course) ) { - error("No such course id"); + print_error("No such course id"); } /// Make sure the current user is allowed to see this user @@ -116,7 +116,7 @@ if (!$gtrue) { $navigation = build_navigation($navlinks); print_header("$strpersonalprofile: ", "$strpersonalprofile: ", $navigation, "", "", true, " ", navmenu($course)); - error(get_string("groupnotamember"), "../course/view.php?id=$course->id"); + print_error("groupnotamember", '', "../course/view.php?id=$course->id"); } } } diff --git a/userpix/index.php b/userpix/index.php index bb5f349815073..a88ae2e34a6b9 100644 --- a/userpix/index.php +++ b/userpix/index.php @@ -14,7 +14,7 @@ require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); if (!$users = get_records("user", "picture", "1", "lastaccess DESC", "id,firstname,lastname")) { - error("no users!"); + print_error("no users!"); } $title = get_string("users"); diff --git a/userpix/upgrade.php b/userpix/upgrade.php index 161499d8452fe..c0fe0a7babf90 100644 --- a/userpix/upgrade.php +++ b/userpix/upgrade.php @@ -10,7 +10,7 @@ require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); if (!$users = get_records("user", "picture", "1", "lastaccess DESC", "id,firstname,lastname")) { - error("no users!"); + print_error("no users!"); } $title = get_string("users");