From 60e40dda6cf7fecdf815886c35f6937c4fcf7bd8 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Fri, 12 Dec 2008 04:53:32 +0000 Subject: [PATCH] "MDL-14129, remove the rest error() in moodle2" --- admin/dbtransfer/index.php | 2 +- admin/report/courseoverview/index.php | 2 +- auth/shibboleth/login.php | 2 +- backup/restore.php | 2 +- blocks/rss_client/block_rss_client_action.php | 10 ++-------- course/report/log/indexlive.php | 2 +- course/report/stats/index.php | 2 +- group/delete.php | 6 +++--- lang/en_utf8/block_rss_client.php | 1 + lang/en_utf8/error.php | 2 ++ lang/en_utf8/question.php | 1 + lib/dml/pdo_moodle_database.php | 8 ++++---- lib/packer/zip_archive.php | 6 +++--- mod/quiz/addrandom.php | 6 +++--- mod/scorm/loadSCO.php | 6 +++--- question/type/questiontype.php | 2 +- 16 files changed, 29 insertions(+), 31 deletions(-) diff --git a/admin/dbtransfer/index.php b/admin/dbtransfer/index.php index 66bc1d8fae..76bb6c9418 100644 --- a/admin/dbtransfer/index.php +++ b/admin/dbtransfer/index.php @@ -18,7 +18,7 @@ if ($data = $form->get_data()) { } if ($targetdb->get_tables()) { // TODO add exception or string... - error('Sorry, tables already exist in selected database. Can not continue.'); + print_error('ddltablealreadyexists'); } admin_externalpage_print_header(); dbtransfer_transfer_database($DB, $targetdb); diff --git a/admin/report/courseoverview/index.php b/admin/report/courseoverview/index.php index 645ce9665b..b819514133 100644 --- a/admin/report/courseoverview/index.php +++ b/admin/report/courseoverview/index.php @@ -15,7 +15,7 @@ if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3); } else { - error("Stats is not enabled."); + print_error('statsdisable'); } } diff --git a/auth/shibboleth/login.php b/auth/shibboleth/login.php index 32c1478120..d27c117906 100644 --- a/auth/shibboleth/login.php +++ b/auth/shibboleth/login.php @@ -21,7 +21,7 @@ httpsrequired(); /// Define variables used in page if (!$site = get_site()) { - error("No site found!"); + print_error('nosite'); } if (empty($CFG->langmenu)) { diff --git a/backup/restore.php b/backup/restore.php index 602bdd4264..f79fd96499 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -25,7 +25,7 @@ //Get and check course if (! $course = get_record("course", "id", $id)) { - error("Course ID was incorrect (can't find it)"); + print_error('invalidcourseid'); } // To some reasons, course_startdateoffset value was lost during restoring // See MDL-17469 diff --git a/blocks/rss_client/block_rss_client_action.php b/blocks/rss_client/block_rss_client_action.php index f8171255e9..7982681987 100644 --- a/blocks/rss_client/block_rss_client_action.php +++ b/blocks/rss_client/block_rss_client_action.php @@ -102,10 +102,7 @@ if (isset($rss_record)) { 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('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.'); + print_error('cannotmakemodification', 'rss_client', $referrer); } @@ -227,10 +224,7 @@ if ($act == 'updfeed') { } 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('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.'); + print_error('cannotmakemodification', 'rss_client', $referrer); } $file = $CFG->dataroot .'/cache/rsscache/'. $rssid .'.xml'; diff --git a/course/report/log/indexlive.php b/course/report/log/indexlive.php index 8c59224a92..67aa3c6f21 100644 --- a/course/report/log/indexlive.php +++ b/course/report/log/indexlive.php @@ -9,7 +9,7 @@ $id = optional_param('id', 0, PARAM_INT);// Course ID if (!$course = $DB->get_record('course', array('id'=>$id)) ) { - error('That\'s an invalid course id'.$id); + print_error('invalidcourseid'); } require_login($course); diff --git a/course/report/stats/index.php b/course/report/stats/index.php index 453c33abc4..73c0c22010 100644 --- a/course/report/stats/index.php +++ b/course/report/stats/index.php @@ -66,7 +66,7 @@ if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3); } else { - error("Stats is not enabled."); + print_error('statsdisable'); } } diff --git a/group/delete.php b/group/delete.php index f06e2d8f40..8589380635 100644 --- a/group/delete.php +++ b/group/delete.php @@ -18,7 +18,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); // Make sure course is OK and user has access to manage groups if (!$course = $DB->get_record('course', array('id' => $courseid))) { - error('Course ID was incorrect'); + print_error('invalidcourseid'); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); @@ -29,10 +29,10 @@ $groupidarray = explode(',',$groupids); $groupnames = array(); foreach($groupidarray as $groupid) { if (!$group = $DB->get_record('groups', array('id' => $groupid))) { - error('Group ID was incorrect'); + print_error('invalidgroupid'); } if ($courseid != $group->courseid) { - error('Group not on required course'); + print_error('groupunknown', '', '', $group->courseid); } $groupnames[] = format_string($group->name); } diff --git a/lang/en_utf8/block_rss_client.php b/lang/en_utf8/block_rss_client.php index dabd66071f..280fd944cc 100644 --- a/lang/en_utf8/block_rss_client.php +++ b/lang/en_utf8/block_rss_client.php @@ -6,6 +6,7 @@ $string['addfeed'] = 'Add a news feed URL:'; $string['addheadlineblock'] = 'Add RSS headline block'; $string['addnew'] = 'Add New'; $string['blockname'] = 'RSS Client'; +$string['cannotmakemodification'] = 'You are not allowed to make modifications to this RSS feed at this time.'; $string['choosefeedlabel'] = 'Choose the feeds which you would like to make available in this block:'; $string['clientchannellink'] = 'Source site...'; $string['clientnumentries'] = 'The default number of entries to show per feed.'; diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 959fc82715..8afb051cca 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -97,6 +97,7 @@ $string['cannotopencsv'] = 'Cannot open CSV file'; $string['cannotopenforwrit'] = 'Cannot open for writing: $a'; $string['cannotopenfile'] = 'Cannot open file ($a)'; $string['cannotopentemplate'] = 'Cannot open template file ($a)'; +$string['cannotopenzip'] = 'Can not open zip file, probably zip extension bug on 64bit os'; $string['cannotoverridebaserole'] = 'Cannot override base role capabilities'; $string['cannotoverriderolehere'] = 'You are not allowed to override this role (id = $a->roleid) in this context ($a->context)'; $string['cannotreadtmpfile'] = 'Error reading temporary file'; @@ -408,6 +409,7 @@ $string['tagnotfound'] = 'The specified tag was not found in the database'; $string['tagdisabled'] = 'Tags are disabled!'; $string['themenotinstall'] = 'This theme is not installed!'; $string['transactionvoid'] = 'Transaction cannot be voided because it has already been voided'; +$string['TODO'] = 'TODO'; $string['importformatnotimplement'] = 'Sorry, importing this format is not yet implemented!'; $string['unicodeupgradeerror'] = 'Sorry, but your database is not already in Unicode, and this version of Moodle is not able to migrate your database to Unicode. Please upgrade to Moodle 1.7.x first and perform the Unicode migration from the Admin page. After that is done you should be able to migrate to Moodle $a'; $string['unspecifycourseid'] = 'Must specify course id, short name or idnumber'; diff --git a/lang/en_utf8/question.php b/lang/en_utf8/question.php index 2f87805d45..fb5c859d19 100644 --- a/lang/en_utf8/question.php +++ b/lang/en_utf8/question.php @@ -114,6 +114,7 @@ $string['maketoplevelitem'] = 'Move to top level'; $string['missingoption'] = 'The cloze question $a is missing its options'; $string['missingimportantcode'] = 'This question type is missing important code: $a.'; $string['missingcourseorcmid'] = 'Need to provide courseid or cmid to print_question.'; +$string['missingcourseorcmidtolink'] = 'Need to provide courseid or cmid to get_question_edit_link.'; $string['modified'] = 'Last saved'; $string['move']= 'Move from $a and change links.'; $string['movecategory']= 'Move Category'; diff --git a/lib/dml/pdo_moodle_database.php b/lib/dml/pdo_moodle_database.php index 8cfbb654e7..0714ab9420 100644 --- a/lib/dml/pdo_moodle_database.php +++ b/lib/dml/pdo_moodle_database.php @@ -498,8 +498,8 @@ abstract class pdo_moodle_database extends moodle_database { array_unshift($params, $newvalue); break; default: - $this->lastError = 'Unknown parameter type in file ' . __FILE__ . ' on line ' . __LINE__ . '.'; - error($this->lastError); + $this->lastError = __FILE__ . ' LINE: ' . __LINE__ . '.'; + print_error(unknowparamtype, 'error', '', $this->lastError); } } $sql = "UPDATE {{$table}} SET $newfield $select"; @@ -508,11 +508,11 @@ abstract class pdo_moodle_database extends moodle_database { } public function sql_concat() { - error('TODO'); + print_error('TODO'); } public function sql_concat_join($separator="' '", $elements=array()) { - error('TODO'); + print_error('TODO'); } public function begin_sql() { diff --git a/lib/packer/zip_archive.php b/lib/packer/zip_archive.php index 4933e1c8e4..c889235d6e 100644 --- a/lib/packer/zip_archive.php +++ b/lib/packer/zip_archive.php @@ -194,7 +194,7 @@ class zip_archive extends file_archive { $this->close(); $res = $this->open($this->archivepathname, file_archive::OPEN, $this->encoding); if ($res !== true) { - error('Can not open zip file, probably zip extension bug on 64bit os'); //TODO ?? + print_error('cannotopenzip'); //TODO ?? } } @@ -225,7 +225,7 @@ class zip_archive extends file_archive { $this->close(); $res = $this->open($this->archivepathname, file_archive::OPEN, $this->encoding); if ($res !== true) { - error('Can not open zip file, probably zip extension bug on 64bit os'); //TODO ?? + print_error('cannotopenzip'); //TODO ?? } } $this->usedmem += strlen($contents); @@ -301,4 +301,4 @@ class zip_archive extends file_archive { return ($this->pos < $this->count()); } -} \ No newline at end of file +} diff --git a/mod/quiz/addrandom.php b/mod/quiz/addrandom.php index e5c4e4caf3..66696b8d94 100644 --- a/mod/quiz/addrandom.php +++ b/mod/quiz/addrandom.php @@ -47,7 +47,7 @@ // Get the course object and related bits. if (! $course = $DB->get_record("course", array("id"=> $quiz->course))) { - error("This course doesn't exist"); + print_error('invalidcourseid'); } //you need mod/quiz:manage in addition to question capabilities to access this page. require_capability('mod/quiz:manage', $contexts->lowest()); @@ -60,7 +60,7 @@ print_header_simple($streditingquiz, '', $navigation, "", "", true, $strupdatemodule); if (!$quizname = $DB->get_field($cm->modname, 'name', array('id'=> $cm->instance))) { - error('Cannot get the module name in build navigation.'); + print_error('invalidcoursemodule'); } print_heading(get_string("addrandomquestiontoquiz","quiz",$quizname), 'left', 2); @@ -69,4 +69,4 @@ $qcobject->display_randomquestion_user_interface($addonpage); print_footer($course); -?> \ No newline at end of file +?> diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php index 3e9d77188b..5cf4110d94 100755 --- a/mod/scorm/loadSCO.php +++ b/mod/scorm/loadSCO.php @@ -38,9 +38,9 @@ $timenow = time(); if ($scorm->timeclose !=0) { if ($scorm->timeopen > $timenow) { - error(get_string("notopenyet", "scorm", userdate($scorm->timeopen))); + print_error('notopenyet', 'scorm', null, userdate($scorm->timeopen)); } else if ($timenow > $scorm->timeclose) { - error(get_string("expired", "scorm", userdate($scorm->timeclose))); + print_error('expired', 'scorm', null, userdate($scorm->timeclose)); } } @@ -198,4 +198,4 @@ } ?> - \ No newline at end of file + diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 86a83d891b..9ee48227eb 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -1030,7 +1030,7 @@ class default_questiontype { } else if (!empty($cmoptions->course)) { $linkurl .= '&courseid=' . $cmoptions->course; } else { - error('Need to provide courseid or cmid to get_question_edit_link.'); + print_error('missingcourseorcmidtolink', 'question'); } /// Work out the contents of the link. -- 2.39.5