"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Wed, 25 Jun 2008 14:52:39 +0000 (14:52 +0000)
committerdongsheng <dongsheng>
Wed, 25 Jun 2008 14:52:39 +0000 (14:52 +0000)
lang/en_utf8/data.php
mod/data/field.php
mod/data/index.php
mod/data/lib.php
mod/data/preset.php
mod/data/templates.php
mod/data/view.php

index c8ab73383e50f95742ca1280ab26c9c09850f879..a8103df10bdf683c9653bd07fcaad2bef9f1fd18 100644 (file)
@@ -124,6 +124,7 @@ $string['forcelinkname'] = 'Forced name for the link';
 $string['foundrecords'] = 'Found records: $a->num/$a->max (<a href=\"$a->reseturl\">Reset filters</a>)';
 $string['foundnorecords'] = 'No records found (<a href=\"$a->reseturl\">Reset filters</a>)';
 $string['fromfile'] = 'Import from zip file';
+$string['generateerror'] = 'Not all files generated!';
 $string['guestrate'] = 'Guests are not allowed to rate entries.';
 $string['header'] = 'Header';
 $string['headeraddtemplate'] = 'Defines the interface when editing entries';
@@ -136,14 +137,14 @@ $string['headersingletemplate'] = 'Defines browsing interface for a single entry
 $string['importsuccess'] = 'The preset has been successfully applied.';
 $string['insufficiententries'] = 'more entries needed to view this database';
 $string['intro'] = 'Introduction';
+$string['invalidaccess'] = 'This page was not accessed correctly';
 $string['invalidfieldname'] = 'Please choose another name for this field';
 $string['invalidfieldid'] = 'Field ID is incorrect';
 $string['invalidfieldtype'] = 'Field Type is incorrect';
 $string['invalidid'] = 'Incorrect data ID';
-$string['invaliddata'] = 'Incorrect data';
 $string['invalidrecord'] = 'Incorrect record';
 $string['invalidratedata'] = 'Incorrect submitted ratings data';
-$string['invalidaccess'] = 'This page was not accessed correctly';
+$string['invildpreset'] = '$a is not a preset.';
 $string['invalidurl'] = 'The URL you just entered is not valid';
 $string['jstemplate'] = 'Javascript template';
 $string['latitude'] = 'Latitude';
@@ -160,6 +161,8 @@ $string['maxentries'] = 'Maximum entries';
 $string['maxsize'] = 'Maximum size';
 $string['menu'] = 'Menu';
 $string['menuchoose'] = 'Choose...';
+$string['missingfield'] = 'Programmer error: You must specify field and/or data when defining field class. ';
+$string['missingdata'] = 'Data id or object must be provided to field class';
 $string['modulename'] = 'Database';
 $string['modulenameplural'] = 'Databases';
 $string['more'] = 'More';
@@ -260,6 +263,7 @@ $string['type'] = 'Field type';
 $string['undefinedprocessactionmethod'] = 'No action method defined in Data_Preset to handle action \"$a\".';
 $string['unsupportedexport'] = '($a->fieldtype) cannot be exported.';
 $string['updatefield'] = 'Update an existing field';
+$string['updatingerror'] = 'There was an error updating the database';
 $string['uploadfile'] = 'Upload file';
 $string['uploadrecords'] = 'Upload entries from a file';
 $string['url'] = 'Url';
index ba689762887538ae673507e5fa6a893e234f714d..7ba49e9bd747ab4e857ff7de14a53e67b089179f 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
         if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
-            error('Course is misconfigured');
+            print_error('coursemisconf');
         }
         if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) {
-            error('Course module is incorrect');
+            print_error('invalidcoursemodule');
         }
 
     } else {
         if (! $data = $DB->get_record('data', array('id'=>$d))) {
-            error('Data ID is incorrect');
+            print_error('invalidid', 'data');
         }
         if (! $course = $DB->get_record('course', array('id'=>$data->course))) {
-            error('Course is misconfigured');
+            print_error('invalidcoursemodule');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
     }
 
                             $rec->defaultsort = 0;
                             $rec->defaultsortdir = 0;
                             if (!$DB->update_record('data', $rec)) {
-                                error('There was an error updating the database');
+                                print_error('updatingerror', 'data');
                             }
                         }
 
                 if ($DB->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('updatingerror', 'data');
                 }
                 exit;
             }
index e52c54e22d9a889c218a8b2c699451ddf063cc2d..f4e325bc3a9cc29d9f31dfc164a0eab7e65b8507 100755 (executable)
@@ -28,7 +28,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        error("Course ID is incorrect");
+        print_error('invalidcourseid');
     }
 
     require_course_login($course);
index abd2248c3f8e283bb9dee5e730f3dd978f1a8d3d..d88748c401cbf6a0977feb568177dbd0a1996ef1 100755 (executable)
@@ -52,18 +52,18 @@ class data_field_base {     // Base class for Database Field Types (see field/*/
         global $DB;
 
         if (empty($field) && empty($data)) {
-            error('Programmer error: You must specify field and/or data when defining field class. ');
+            print_error('missingfield', 'data');
         }
 
         if (!empty($field)) {
             if (is_object($field)) {
                 $this->field = $field;  // Programmer knows what they are doing, we hope
             } else if (!$this->field = $DB->get_record('data_fields', array('id'=>$field))) {
-                error('Bad field ID encountered: '.$field);
+                print_error('invalidfieldid', 'data');
             }
             if (empty($data)) {
                 if (!$this->data = $DB->get_record('data', array('id'=>$this->field->dataid))) {
-                    error('Bad data ID encountered in field data');
+                    print_error('invalidid', 'data');
                 }
             }
         }
@@ -73,10 +73,10 @@ class data_field_base {     // Base class for Database Field Types (see field/*/
                 if (is_object($data)) {
                     $this->data = $data;  // Programmer knows what they are doing, we hope
                 } else if (!$this->data = $DB->get_record('data', array('id'=>$data))) {
-                    error('Bad data ID encountered: '.$data);
+                    print_error('invalidid', 'data');
                 }
             } else {                      // No way to define it!
-                error('Data id or object must be provided to field class');
+                print_error('missingdata', 'data');
             }
         }
 
@@ -1766,7 +1766,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('invalidcoursemodule');
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
@@ -1842,7 +1842,7 @@ class PresetImporter {
         global $CFG, $DB;
 
         if (!is_directory_a_preset($this->folder)) {
-            error("$this->userid/$this->shortname Not a preset");
+            print_error('invildpreset', 'data', '', $this->userid.'/'.$this->shortname);
         }
 
         /* Grab XML */
@@ -1916,7 +1916,7 @@ class PresetImporter {
 
     function import_options() {
         if (!confirm_sesskey()) {
-            error("Sesskey Invalid");
+            print_error('invalidsesskey');
         }
 
         $strblank = get_string('blank', 'data');
@@ -1968,7 +1968,7 @@ class PresetImporter {
             echo "<p>$strwarning</p>";
 
         } else if (empty($newfields)) {
-            error("New preset has no defined fields!");
+            print_error('nodefinedfields', 'data');
         }
 
         echo '<div class="overwritesettings"><label for="overwritesettings">'.get_string('overwritesettings', 'data').'</label>';
@@ -1993,7 +1993,9 @@ class PresetImporter {
                 $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('notinjectivemap', 'data');
+                } 
                 else $preservedfields[$cid] = true;
             }
 
index 156f222cabd752456c83bab3fe038377b58b6554..78e02748c403a67465184153e636a4b52bad5a57 100644 (file)
@@ -475,8 +475,7 @@ function data_presets_export($course, $cm, $data) {
 
     // Check if all files have been generated
     if (! is_directory_a_preset($exportdir)) {
-        error('Not all files generated!');
-        // should be migrated to print_error()
+        print_error('generateerror', 'data');
     }
 
     $filelist = array(
index a2519e8c4d16bab9df8554de70a71b549ac496ba..ad3c0b4150b8be938e737dbe44df5142ac9dd31b 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
         if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
-            error('Course is misconfigured');
+            print_error('coursemisconf');
         }
         if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) {
-            error('Course module is incorrect');
+            print_error('invalidcoursemodule');
         }
 
     } else {
         if (! $data = $DB->get_record('data', array('id'=>$d))) {
-            error('Data ID is incorrect');
+            print_error('invalidid', 'data');
         }
         if (! $course = $DB->get_record('course', array('id'=>$data->course))) {
-            error('Course is misconfigured');
+            print_error('coursemisconf');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
     }
 
index 9a5652fe0abfbc24c422884278962c14b5cc68ec..d9d750cb5880c93c106ce128155149c14529b07b 100755 (executable)
 
     if ($id) {
         if (! $cm = get_coursemodule_from_id('data', $id)) {
-            error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
         if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
-            error('Course is misconfigured');
+            print_error('coursemisconf');
         }
         if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) {
-            error('Course module is incorrect');
+            print_error('invalidcoursemodule');
         }
         $record = NULL;
 
     } else if ($rid) {
         if (! $record = $DB->get_record('data_records', array('id'=>$rid))) {
-            error('Record ID is incorrect');
+            print_error('invalidrecord', 'data');
         }
         if (! $data = $DB->get_record('data', array('id'=>$record->dataid))) {
-            error('Data ID is incorrect');
+            print_error('invalidid', 'data');
         }
         if (! $course = $DB->get_record('course', array('id'=>$data->course))) {
-            error('Course is misconfigured');
+            print_error('coursemisconf');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
     } else {   // We must have $d
         if (! $data = $DB->get_record('data', array('id'=>$d))) {
-            error('Data ID is incorrect');
+            print_error('invalidid', 'data');
         }
         if (! $course = $DB->get_record('course', array('id'=>$data->course))) {
-            error('Course is misconfigured');
+            print_error('coursemisconf');
         }
         if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
-            error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
         $record = NULL;
     }