From 771dc7b298b52cebc562a925934e52242d45f812 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Fri, 12 Dec 2008 05:45:43 +0000 Subject: [PATCH] "MDL-14129, fix error() in moodle2" --- admin/lang.php | 2 +- admin/roles/tabs.php | 2 +- admin/xmldb/index.php | 7 ++++-- auth/ldap/auth.php | 10 ++++---- backup/backup_execute.html | 3 +-- backup/restore_check.html | 4 +-- backup/restore_precheck.html | 2 +- backup/restorelib.php | 8 +++--- blog/header.php | 2 +- blog/lib.php | 2 +- grade/import/csv/index.php | 4 +-- grade/report/lib.php | 2 +- lang/en_utf8/access.php | 1 + lang/en_utf8/admin.php | 1 + lang/en_utf8/auth.php | 2 ++ lang/en_utf8/error.php | 4 +++ lang/en_utf8/glossary.php | 1 + lang/en_utf8/grades.php | 1 + lang/en_utf8/xmldb.php | 1 + lib/accesslib.php | 6 ++--- mod/glossary/formats.php | 2 +- mod/lesson/essay.php | 4 +-- mod/lesson/format.php | 2 +- mod/resource/type/ims/deploy.php | 28 ++++++++++----------- mod/resource/type/ims/preview.php | 2 +- mod/resource/type/ims/repository_deploy.php | 16 +++++++----- mod/resource/type/ims/resource.class.php | 2 +- question/type/questiontype.php | 4 +-- 28 files changed, 71 insertions(+), 54 deletions(-) diff --git a/admin/lang.php b/admin/lang.php index abb1ed2389..d0349f1d37 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -181,7 +181,7 @@ if ($mode == 'missing') { if (!file_exists($langdir)) { - error ('to edit this language pack, you need to put it in '.$CFG->dataroot.'/lang'); + print_error('invalidlangpack'); } // Following variables store the HTML output to be echo-ed diff --git a/admin/roles/tabs.php b/admin/roles/tabs.php index 05116468e0..830004dcc4 100755 --- a/admin/roles/tabs.php +++ b/admin/roles/tabs.php @@ -164,7 +164,7 @@ if ($currenttab != 'update') { break; default: - error ('This is an unknown context (' . $context->contextlevel . ') in admin/roles/tabs.php!'); + print_error('unknowncontext'); return false; } diff --git a/admin/xmldb/index.php b/admin/xmldb/index.php index ca048aea9a..16a00f9fa5 100644 --- a/admin/xmldb/index.php +++ b/admin/xmldb/index.php @@ -111,10 +111,13 @@ print_error('xmldberror'); } } else { - error ("Error: cannot instantiate class (actions/$action/$actionclass)"); + $a = new stdclass; + $a->action = $action; + $a->actionclass = $actionclass; + print_error('cannotinstantiateclass', 'xmldb', '', $a); } } else { - error ("Error: wrong action specified ($action)"); + print_error('invalidaction'); } if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) { diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 2cddfe5a2b..c2f674c64d 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -355,7 +355,7 @@ class auth_plugin_ldap extends auth_plugin_base { // strings (UCS-2 Little Endian format) and surrounded with // double quotes. See http://support.microsoft.com/?kbid=269190 if (!function_exists('mb_convert_encoding')) { - print_error ('auth_ldap_no_mbstring', 'auth'); + print_error('auth_ldap_no_mbstring', 'auth'); } // First create the user account, and mark it as disabled. @@ -366,7 +366,7 @@ class auth_plugin_ldap extends auth_plugin_base { $userdn = 'cn=' . $this->ldap_addslashes($extusername) . ',' . $this->config->create_context; if (!ldap_add($ldapconnection, $userdn, $newuser)) { - print_error ('auth_ldap_ad_create_req', 'auth'); + print_error('auth_ldap_ad_create_req', 'auth'); } // Now set the password @@ -376,7 +376,7 @@ class auth_plugin_ldap extends auth_plugin_base { if(!ldap_modify($ldapconnection, $userdn, $newuser)) { // Something went wrong: delete the user account and error out ldap_delete ($ldapconnection, $userdn); - print_error ('auth_ldap_ad_create_req', 'auth'); + print_error('auth_ldap_ad_create_req', 'auth'); } $uadd = true; break; @@ -918,7 +918,7 @@ class auth_plugin_ldap extends auth_plugin_base { & (~AUTH_AD_ACCOUNTDISABLE); break; default: - error ('auth: ldap user_activate() does not support selected usertype:"'.$this->config->user_type.'" (..yet)'); + print_error('user_activatenotsupportusertype', 'auth', '', $this->config->user_type); } $result = ldap_modify($ldapconnection, $userdn, $newinfo); ldap_close($ldapconnection); @@ -953,7 +953,7 @@ class auth_plugin_ldap extends auth_plugin_base { | AUTH_AD_ACCOUNTDISABLE; break; default: - error ('auth: ldap user_disable() does not support selected usertype (..yet)'); + print_error('user_disablenotsupportusertype', 'auth'); } $result = ldap_modify($ldapconnection, $userdn, $newinfo); ldap_close($ldapconnection); diff --git a/backup/backup_execute.html b/backup/backup_execute.html index 5eb083d024..7c4bfc86ae 100644 --- a/backup/backup_execute.html +++ b/backup/backup_execute.html @@ -69,8 +69,7 @@ echo ""; if (!$status) { - error ("The backup did not complete successfully", - "$CFG->wwwroot/course/view.php?id=$course->id"); + print_error('error', 'error', "$CFG->wwwroot/course/view.php?id=$course->id"); } if (empty($to)) { diff --git a/backup/restore_check.html b/backup/restore_check.html index 0a0eca910a..6c2a4c6bd3 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -313,7 +313,7 @@ echo ""; } else { //Show error - error ("Something was wrong checking restore preferences"); + print_error('error'); } //If we are here. Something must be wrong. Debug !!! @@ -321,7 +321,7 @@ print_object($restore); print_object($info); print_object($course_header); - error ("Something must be wrong"); + print_error('error'); } ?> diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html index 84b7eb44e2..e14d2fbe87 100644 --- a/backup/restore_precheck.html +++ b/backup/restore_precheck.html @@ -6,7 +6,7 @@ //Checks we have the file variable if (!isset($file)) { - error ("File not specified"); + print_error('nofile'); } //Check login diff --git a/backup/restorelib.php b/backup/restorelib.php index ba6ebd4194..4899a94774 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -7284,7 +7284,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); //Check the file exists if (!is_file($file)) { if (!defined('RESTORE_SILENTLY')) { - error ("File not exists ($file)"); + print_error('nofile'); } else { $errorstr = "File not exists ($file)"; return false; @@ -7294,9 +7294,9 @@ define('RESTORE_GROUPS_GROUPINGS', 3); //Check the file name ends with .zip if (!substr($file,-4) == ".zip") { if (!defined('RESTORE_SILENTLY')) { - error ("File has an incorrect extension"); + print_error('incorrectext'); } else { - $errorstr = 'File has an incorrect extension'; + $errorstr = get_string('incorrectext', 'error'); return false; } } @@ -7463,7 +7463,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); if (!$status) { if (!defined('RESTORE_SILENTLY')) { - error ("An error has ocurred"); + print_error('error'); } else { $errorstr = "An error has occured"; // helpful! :P return false; diff --git a/blog/header.php b/blog/header.php index 619bd8862f..58b0d23f85 100755 --- a/blog/header.php +++ b/blog/header.php @@ -231,7 +231,7 @@ $navlinks = array(); break; default: - error ('Error unknown filtertype'); + print_error('unknownfiletype'); break; } diff --git a/blog/lib.php b/blog/lib.php index de5501c626..d5ec5104a0 100755 --- a/blog/lib.php +++ b/blog/lib.php @@ -162,7 +162,7 @@ /* if (!blog_user_can_view_user_post($template['userid'])) { - error ('you can not view this post'); + print_error('cannotviewuserblog', 'blog'); }*/ $stredit = get_string('edit'); diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index 7c4e95a741..ace73d7e4b 100755 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -177,7 +177,7 @@ if ($formdata = $mform->get_data()) { $h = trim($h); $header[$i] = $h; // remove whitespace } } else { - error ('could not open file'); + print_error('cannotopenfile'); } $map = array(); @@ -481,7 +481,7 @@ if ($formdata = $mform->get_data()) { // temporary file can go now unlink($filename); } else { - error ('import file '.$filename.' not readable'); + print_error('cannotreadfil'); } } else { diff --git a/grade/report/lib.php b/grade/report/lib.php index 7667802983..f1e2556ca4 100755 --- a/grade/report/lib.php +++ b/grade/report/lib.php @@ -144,7 +144,7 @@ abstract class grade_report { global $CFG, $COURSE, $DB; if (empty($CFG->gradebookroles)) { - error ('no roles defined in admin->appearance->graderoles'); + print_error('norolesdefined', 'grades'); } diff --git a/lang/en_utf8/access.php b/lang/en_utf8/access.php index 27bbdfa0d1..0331636991 100644 --- a/lang/en_utf8/access.php +++ b/lang/en_utf8/access.php @@ -10,6 +10,7 @@ $string['accessstatement'] = 'Accessibility statement'; $string['activitynext'] = 'Next activity'; $string['activityprev'] = 'Previous activity'; $string['breadcrumb'] = 'Breadcrumb trail'; +$string['cannotdeleterolenoadmin'] = 'You can not delete this role because there is no other admin roles with users assigned'; $string['currentweek'] = 'This week '; $string['currenttopic'] = 'This topic '; $string['monthnext'] = 'Next month'; diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 295d973fcd..51422a6d01 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -450,6 +450,7 @@ $string['installedlangs'] = 'Installed language packs'; $string['intcachemax'] = 'Int. cache max'; $string['invalidsection'] = 'Invalid section.'; $string['invaliduserchangeme'] = 'Username \"changeme\" is reserved -- you cannot create an account with it.'; +$string['invalidlangpack'] = 'to edit this language pack, you need to put it in language folder.'; $string['ipblocker'] = 'IP Blocker'; $string['ipblocked'] = 'This site is not available currently.'; $string['iplookup'] = 'IP address lookup'; diff --git a/lang/en_utf8/auth.php b/lang/en_utf8/auth.php index db94c0bc6e..2224928b0f 100644 --- a/lang/en_utf8/auth.php +++ b/lang/en_utf8/auth.php @@ -9,6 +9,8 @@ $string['forgottenpassword'] = 'If you enter a URL here, it will be used as the $string['forgottenpasswordurl'] = 'Forgotten password URL'; $string['pluginnotenabled'] = 'Authentication plugin \'$a\' is not enabled.'; $string['pluginnotinstalled'] = 'Authentication plugin \'$a\' is not installed.'; +$string['user_activatenotsupportusertype'] = 'auth: ldap user_activate() does not support selected usertype: $a'; +$string['user_disablenotsupportusertype'] = 'auth: ldap user_disable() does not support selected usertype (..yet)'; // synchronization $string['auth_sync_script'] ='Cron synchronization script'; $string['auth_dbinsertuser'] ='Inserted user $a[0] id $a[1]'; diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 8afb051cca..79204fd5ad 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -239,6 +239,7 @@ $string['guestnoeditprofileother'] = 'The guest user profile cannot be edited'; $string['guestnorate'] = 'Guests are not allowed to rate entries'; $string['guestsarenotallowed'] = 'The guest user is not allowed to do this'; $string['hashpoolproblem'] = 'Incorrect pool file content $a.'; +$string['incorrectext'] = 'File has an incorrect extension'; $string['invalidaction'] = 'Invalid action parameter'; $string['invalidactivityid'] = 'Invalid Activity ID'; $string['invalidarguments'] = 'No valid arguments supplied'; @@ -336,6 +337,7 @@ $string['needcoursecategroyid'] = 'Either course id or category must be specifie $string['noblocks'] = 'No blocks found!'; $string['nodata'] = 'No data'; $string['noformdesc'] = 'No formslib form description file found for this activity.'; +$string['nofile'] = 'File not specified'; $string['nocategorydelete'] = 'Category \'$a\' cannot be deleted!'; $string['nocontext'] = 'Sorry, but that course is not a valid context'; $string['noinstances'] = 'There are no instances of $a in this course!'; @@ -423,6 +425,8 @@ $string['unknowformat'] = 'Format not known ($a)'; $string['unknowncourse'] = 'Unknown course named \"$a\"'; $string['unknowncourseidnumber'] = 'Unknown Course ID \"$a\"'; $string['unknowncourserequest'] = 'Unknown course request'; +$string['unknowncontext'] = 'This is an unknown context.'; +$string['unknownfiletype'] = 'Error unknown filtertype'; $string['unknownhelp'] = 'Unknown help topic $a'; $string['unknowngroup'] = 'Unknown group \"$a\"'; $string['unknownrole'] = 'Unknown role \"$a\"'; diff --git a/lang/en_utf8/glossary.php b/lang/en_utf8/glossary.php index 8d136af9a1..54dea3622c 100644 --- a/lang/en_utf8/glossary.php +++ b/lang/en_utf8/glossary.php @@ -149,6 +149,7 @@ $string['importentries'] = 'Import entries'; $string['importentriesfromxml'] = 'Import entries from XML file'; $string['includegroupbreaks'] = 'Include group breaks'; $string['invalidid'] = 'Incorrect glossary id'; +$string['invalidglossaryformat'] = 'Invalid Glossary Format'; $string['isglobal'] = 'Is this glossary global?'; $string['letter'] = 'letter'; $string['linkcategory'] = 'Automatically link this category'; diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index 1b261ee395..0deccd54a0 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -354,6 +354,7 @@ $string['noselectedcategories'] = 'no categories were selected.'; $string['noselecteditems'] = 'no items were selected.'; $string['notteachererror'] = 'You must be a teacher to use this feature.'; $string['nousersloaded'] = 'No users loaded'; +$string['norolesdefined' ] = 'no roles defined in admin->appearance->graderoles'; $string['numberofgrades'] = 'Number of grades'; $string['onascaleof'] = ' on a scale of $a->grademin to $a->grademax'; $string['operations'] = 'Operations'; diff --git a/lang/en_utf8/xmldb.php b/lang/en_utf8/xmldb.php index f9c4bef65f..ad0963140c 100644 --- a/lang/en_utf8/xmldb.php +++ b/lang/en_utf8/xmldb.php @@ -7,6 +7,7 @@ $string['back'] = 'Back'; $string['backtomainview'] = 'Back To Main'; $string['binaryincorrectlength'] = 'Incorrect length for binary field'; $string['cannotuseidfield'] = 'Cannot insert the \"id\" field. It is an autonumeric column'; +$string['cannotinstantiateclass'] = 'Error: cannot instantiate class (actions/$a->action/$a->actionclass)'; $string['change'] = 'Change'; $string['charincorrectlength'] = 'Incorrect length for char field'; $string['checkbigints'] = 'Check bigints'; diff --git a/lib/accesslib.php b/lib/accesslib.php index 3603875fb4..b74c4139fd 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -2627,7 +2627,7 @@ function delete_role($roleid) { } } if ($status !== true) { - error ('You can not delete this role because there is no other admin roles with users assigned'); + print_error('cannotdeleterolenoadmin', 'access'); } } } @@ -3455,7 +3455,7 @@ function print_context_name($context, $withprefix = true, $short = false) { break; default: - error ('This is an unknown context (' . $context->contextlevel . ') in print_context_name!'); + print_error('unknowncontext'); return false; } @@ -4045,7 +4045,7 @@ function get_component_string($component, $contextlevel) { break; default: - error ('This is an unknown context $contextlevel (' . $contextlevel . ') in get_component_string!'); + print_error('unknowncontext'); return false; } diff --git a/mod/glossary/formats.php b/mod/glossary/formats.php index e59c2bff67..47fd883e65 100644 --- a/mod/glossary/formats.php +++ b/mod/glossary/formats.php @@ -11,7 +11,7 @@ admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it if ( !$displayformat = $DB->get_record("glossary_formats", array("id"=>$id))) { - error ("Invalid Glossary Format"); + print_error('invalidglossaryformat', 'glossary'); } $form = data_submitted(); diff --git a/mod/lesson/essay.php b/mod/lesson/essay.php index 12f6db8ba3..0f4fcb7dc3 100644 --- a/mod/lesson/essay.php +++ b/mod/lesson/essay.php @@ -174,13 +174,13 @@ $params["userid"] = $userid; } if (!$attempts = $DB->get_records_select('lesson_attempts', "pageid $usql".$queryadd, $params)) { - error ('No one has answered essay questions yet...'); + print_error('nooneansweredthisquestion', 'lesson'); } // Get the answers list($answerUsql, $parameters) = $DB->get_in_or_equal(array_keys($pages)); $parameters["lessonid"] = $lesson->id; if (!$answers = $DB->get_records_select('lesson_answers', "lessonid = :lessonid AND pageid $answerUsql", $parameters, '', 'pageid, score')) { - error ('Could not find answer records.'); + print_error('cannotfindanswer', 'lesson'); } $options = new stdClass; $options->noclean = true; diff --git a/mod/lesson/format.php b/mod/lesson/format.php index 7e7b306dcd..faa1a3c512 100644 --- a/mod/lesson/format.php +++ b/mod/lesson/format.php @@ -88,7 +88,7 @@ class qformat_default { if ($pageid) { // the new page follows on from this page if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) { - error ("Format: Page $pageid not found"); + print_error('invalidpageid', 'lesson'); } $newpage->prevpageid = $pageid; $newpage->nextpageid = $page->nextpageid; diff --git a/mod/resource/type/ims/deploy.php b/mod/resource/type/ims/deploy.php index 0eb1fd20f5..631d628040 100644 --- a/mod/resource/type/ims/deploy.php +++ b/mod/resource/type/ims/deploy.php @@ -86,43 +86,43 @@ /// Create directories if (!$resourcedir = make_upload_directory($courseid.'/'.$CFG->moddata.'/resource/'.$resource->id)) { - error (get_string('errorcreatingdirectory', 'error', $CFG->moddata.'/resource/'.$resource->id)); + print_error('errorcreatingdirectory', 'error', '', $CFG->moddata.'/resource/'.$resource->id); } /// Ensure it's empty if (!delete_dir_contents($resourcedir)) { - error (get_string('errorcleaningdirectory', 'error', $resourcedir)); + print_error('errorcleaningdirectory', 'error', '', $resourcedir); } /// Copy files $origin = $CFG->dataroot.'/'.$courseid.'/'.$file; if (!is_file($origin)) { - error (get_string('filenotfound' , 'error', $file)); + print_error('filenotfound' , 'error', '', $file); } $mimetype = mimeinfo("type", $file); if ($mimetype != "application/zip") { - error (get_string('invalidfiletype', 'error', $file)); + print_error('invalidfiletype', 'error', '', $file); } $resourcefile = $resourcedir.'/'.basename($origin); if (!backup_copy_file($origin, $resourcefile)) { - error (get_string('errorcopyingfiles', 'error')); + print_error('errorcopyingfiles', 'error'); } /// Unzip files if (!unzip_file($resourcefile, '', false)) { - error (get_string('errorunzippingfiles', 'error')); + print_error('errorunzippingfiles', 'error'); } /// Check for imsmanifest if (!file_exists($resourcedir.'/imsmanifest.xml')) { - error (get_string('filenotfound', 'error', 'imsmanifest.xml')); + print_error('filenotfound', 'error', '', 'imsmanifest.xml'); } /// Load imsmanifest to memory (instead of using a full parser, /// we are going to use xmlize intensively (because files aren't too big) if (!$imsmanifest = ims_file2var ($resourcedir.'/imsmanifest.xml')) { - error (get_string ('errorreadingfile', 'error', 'imsmanifest.xml')); + print_error('errorreadingfile', 'error', '', 'imsmanifest.xml'); } /// Check if the first line is a proper one, because I've seen some @@ -134,7 +134,7 @@ $imsmanifest = substr($imsmanifest, $inixml); } } else { - error (get_string ('invalidxmlfile', 'error', 'imsmanifest.xml')); + print_error('invalidxmlfile', 'error', '', 'imsmanifest.xml'); } /// xmlize the variable @@ -143,7 +143,7 @@ /// Extract every manifest present in the imsmanifest file. /// Returns a tree structure. if (!$manifests = ims_extract_manifests($data)) { - error (get_string('nonmeaningfulcontent', 'error')); + print_error('nonmeaningfulcontent', 'error'); } /// Process every manifest found in inverse order so every one @@ -160,7 +160,7 @@ /// Parse XML-content package data /// First we select an organization an load all the items if (!$items = ims_process_organizations($data['manifest']['#']['organizations']['0'])) { - error (get_string('nonmeaningfulcontent', 'error')); + print_error('nonmeaningfulcontent', 'error'); } /// Detect if all the resources share a common xml:base tag @@ -168,7 +168,7 @@ /// Now, we load all the resources available (keys are identifiers) if (!$resources = ims_load_resources($data['manifest']['#']['resources']['0']['#']['resource'], $manifest_base, $resources_base)) { - error (get_string('nonmeaningfulcontent', 'error')); + print_error('nonmeaningfulcontent', 'error'); } ///Now we assign to each item, its resource (by identifier) foreach ($items as $key=>$item) { @@ -181,13 +181,13 @@ /// Create the INDEX (moodle_inx.ser - where the order of the pages are stored serialized) file if (!ims_save_serialized_file($resourcedir.'/moodle_inx.ser', $items)) { - error (get_string('errorcreatingfile', 'error', 'moodle_inx.ser')); + print_error('errorcreatingfile', 'error', '', 'moodle_inx.ser'); } /// Create the HASH file (moodle_hash.ser - where the hash of the ims is stored serialized) file $hash = $resource_obj->calculatefilehash($resourcefile); if (!ims_save_serialized_file($resourcedir.'/moodle_hash.ser', $hash)) { - error (get_string('errorcreatingfile', 'error', 'moodle_hash.ser')); + print_error('errorcreatingfile', 'error', '', 'moodle_hash.ser'); } /// End button (go to view mode) diff --git a/mod/resource/type/ims/preview.php b/mod/resource/type/ims/preview.php index 3ed5f3dbbb..9840a3af5e 100644 --- a/mod/resource/type/ims/preview.php +++ b/mod/resource/type/ims/preview.php @@ -30,7 +30,7 @@ /// Load serialized IMS CP index to memory only once. if (empty($items)) { if (!$items = ims_load_serialized_file($deploydir.'/moodle_inx.ser')) { - error (get_string('errorreadingfile', 'error', 'moodle_inx.ser')); + print_error('errorreadingfile', 'error', '', 'moodle_inx.ser'); } } diff --git a/mod/resource/type/ims/repository_deploy.php b/mod/resource/type/ims/repository_deploy.php index 8c58ead3c1..4aae690db3 100644 --- a/mod/resource/type/ims/repository_deploy.php +++ b/mod/resource/type/ims/repository_deploy.php @@ -105,7 +105,7 @@ /// Load imsmanifest to memory (instead of using a full parser, /// we are going to use xmlize intensively (because files aren't too big) if (!$imsmanifest = ims_file2var ($resourcedir.'/imsmanifest.xml')) { - error (get_string ('errorreadingfile', 'error', 'imsmanifest.xml')); + print_error('errorreadingfile', 'error', '', 'imsmanifest.xml'); } /// Check if the first line is a proper one, because I've seen some @@ -124,7 +124,7 @@ return; } else { - error (get_string ('invalidxmlfile', 'error', 'imsmanifest.xml')); + print_error('invalidxmlfile', 'error', '', 'imsmanifest.xml'); } } @@ -138,7 +138,7 @@ /// Extract every manifest present in the imsmanifest file. /// Returns a tree structure. if (!$manifests = ims_extract_manifests($data)) { - error (get_string('nonmeaningfulcontent', 'error')); + print_error('nonmeaningfulcontent', 'error'); } /// Process every manifest found in inverse order so every one @@ -156,7 +156,11 @@ /// First we select an organization an load all the items if (!$items = ims_process_organizations($data['manifest']['#']['organizations']['0'])) { - if ($all == 'force') return; else error (get_string('nonmeaningfulcontent', 'error')); + if ($all == 'force') { + return; + } else { + print_error('nonmeaningfulcontent', 'error'); + } } /// Detect if all the resources share a common xml:base tag @@ -164,7 +168,7 @@ /// Now, we load all the resources available (keys are identifiers) if (!$resources = ims_load_resources($data['manifest']['#']['resources']['0']['#']['resource'], $manifest_base, $resources_base)) { - error (get_string('nonmeaningfulcontent', 'error')); + print_error('nonmeaningfulcontent', 'error'); } ///Now we assign to each item, its resource (by identifier) foreach ($items as $key=>$item) { @@ -178,7 +182,7 @@ /// Create the INDEX (moodle_inx.ser - where the order of the pages are stored serialized) file $items['title'] = $title; if (!ims_save_serialized_file($resourcedir.'/moodle_inx.ser', $items)) { - error (get_string('errorcreatingfile', 'error', 'moodle_inx.ser')); + print_error('errorcreatingfile', 'error', '', 'moodle_inx.ser'); } /// No zip so no HASH diff --git a/mod/resource/type/ims/resource.class.php b/mod/resource/type/ims/resource.class.php index 0ab7c2ba66..d1a4bca280 100644 --- a/mod/resource/type/ims/resource.class.php +++ b/mod/resource/type/ims/resource.class.php @@ -416,7 +416,7 @@ class resource_ims extends resource_base { $resourcedir = $CFG->repository . $resource->reference; } if (!$items = ims_load_serialized_file($resourcedir.'/moodle_inx.ser')) { - error (get_string('errorreadingfile', 'error', 'moodle_inx.ser')); + print_error('errorreadingfile', 'error', '', 'moodle_inx.ser'); } } diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 9ee48227eb..4adccba2d8 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -1611,7 +1611,7 @@ class default_questiontype { /// If anything has changed, update it in the database. if ($updateqrec){ if (!$DB->update_record('question', $question)){ - error ('Couldn\'t update question '.$question->name); + print_error('cannotupdatequestion', 'question'); } } @@ -1630,7 +1630,7 @@ class default_questiontype { /// If anything has changed, update it in the database. if ($answerchanged){ if (!$DB->update_record('question_answers', $answer)){ - error ('Couldn\'t update question ('.$question->name.') answer '.$answer->id); + print_error('cannotupdatequestion', 'question'); } } } -- 2.39.5