]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14442, some error checking added"
authordongsheng <dongsheng>
Wed, 14 May 2008 02:54:18 +0000 (02:54 +0000)
committerdongsheng <dongsheng>
Wed, 14 May 2008 02:54:18 +0000 (02:54 +0000)
lang/en_utf8/error.php
mod/data/import.php

index 3b5cd26764b1d42df345a4ea73ee37338365f096..26e55cbcb0f74001b9bc2f50d37f791d9745eafc 100644 (file)
@@ -51,6 +51,7 @@ $string['cannotreadtmpfile'] = 'Error reading temporary file';
 $string['cannotremovefrommeta'] = 'Could not remove the selected course from this meta course!';
 $string['cannotrestore'] = 'An error has occurred and the restore could not be completed!';
 $string['cannotsavefile'] = 'Cannot save the file \"$a\".';
+$string['cannotinsertrecord'] = 'Could not insert new record ID $a';
 $string['cannotsavemd5file'] = 'Cannot save md5 file.';
 $string['cannotsavezipfile'] = 'Cannot save ZIP file.';
 $string['cannotsetupcategory'] = 'Serious Error! Could not set up a default course category!';
@@ -59,6 +60,7 @@ $string['cannotunzipfile'] = 'Cannot unzip file.';
 $string['cannotupdatecategory'] = 'Could not update the category ($a)';
 $string['cannotupdatecm'] = 'Could not update the course module with the correct section';
 $string['cannotupdatelevel'] = 'Could not update the indent level on that course module';
+$string['cannotupdaterecord'] = 'Could not update record ID $a';
 $string['cannotupdaterole'] = 'Cannot update role!';
 $string['cannotupdatemod'] = 'Could not update the $a';
 $string['cannotupdateuser'] = 'updating user failed';
index 8e24d1bcbd6b1b65ee7d2f3c58f5565c34f7ed8e..c073a5cdc3a3cda42151e61efc38f0b9639c5492 100755 (executable)
                         $content = new object();
                         $content->recordid = $recordid;
                         $content->fieldid = $field->id;
-                        insert_record('data_content', $content);
+                        if (! insert_record('data_content', $content)) {
+                            print_error('cannotinsertrecord', '', '', $recordid);
+                        }
                     }
                     // Fill data_content with the values imported from the CSV file:
                     foreach ($record as $key => $value) {
                         }
                         $oldcontent = get_record('data_content', 'fieldid', $field->id, 'recordid', $recordid);
                         $content->id = $oldcontent->id;
-                        update_record('data_content', $content);
+                        if (! update_record('data_content', $content)) {
+                            print_error('cannotupdaterecord', '', '', $recordid);
+                        }
                     }
                     $recordsadded++;
                     print get_string('added', 'moodle', $recordsadded) . ". " . get_string('entry', 'data') . " (ID $recordid)<br />\n";