2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
15 exit(__FILE__ . ' no longer used');
\r
18 * Class for creating AbstractTable Objects
\r
20 * @author Joel Kronenberg
\r
23 class TableFactory {
\r
25 * The database handler.
\r
33 * The ATutor version this backup was created with.
\r
41 * The course ID we're restoring into.
\r
49 * The directory unzip backup is found.
\r
59 * @param string $version The backup version.
\r
60 * @param resource $db The database handler.
\r
61 * @param int $course_id The ID of this course.
\r
62 * @param string $import_dir The directory where the backup was unzipped to.
\r
65 function TableFactory ($version, $db, $course_id, $import_dir) {
\r
66 $this->version = $version;
\r
68 $this->course_id = $course_id;
\r
69 $this->import_dir = $import_dir;
\r
73 * Create and return the specified AbstractTable Object.
\r
76 * @param string $table_name The name of the table to create an Object for.
\r
77 * @return AbstractTable Object|NULL if $table_name does not match available Objects.
\r
78 * @See AbstractTable
\r
81 function createTable($table_name) {
\r
82 // static hash to keep track of new ID mappings:
\r
85 switch ($table_name) {
\r
87 return new CourseStatsTable($this->version, $this->db, $this->course_id, $this->import_dir, $garbage);
\r
92 return new PollsTable($this->version, $this->db, $this->course_id, $this->import_dir, $garbage);
\r
97 return new TestsTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
100 case 'tests_questions_categories':
\r
101 return new TestsQuestionsCategoriesTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
104 case 'tests_questions_assoc':
\r
105 return new TestsQuestionsAssocTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
108 case 'tests_questions':
\r
109 return new TestsQuestionsTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
113 return new NewsTable($this->version, $this->db, $this->course_id, $this->import_dir, $garbage);
\r
117 return new GroupsTable($this->version, $this->db, $this->course_id, $this->import_dir, $garbage);
\r
121 return new ForumsTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
124 case 'forums_courses':
\r
125 return new ForumsCoursesTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
129 return new GlossaryTable($this->version, $this->db, $this->course_id, $this->import_dir, $garbage);
\r
132 case 'resource_links':
\r
133 return new ResourceLinksTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
136 case 'resource_categories':
\r
137 return new ResourceCategoriesTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
141 return new ContentTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
144 case 'related_content':
\r
145 return new RelatedContentTable($this->version, $this->db, $this->course_id, $this->import_dir, $id_map);
\r
149 if (class_exists($table_name . 'Table')) {
\r
150 $table_name = $table_name . 'Table';
\r
151 return new $table_name($this->version, $this->db, $this->course_id, $this->import_dir, $garbage);
\r
160 * Class for restoring backup tables
\r
162 * @author Joel Kronenberg
\r
165 class AbstractTable {
\r
167 * The ATutor version this backup was created with.
\r
169 * @access protected
\r
175 * The database handler.
\r
183 * The CSV table file handler.
\r
191 * The course ID we're restoring into.
\r
199 * The directory unzip backup is found.
\r
207 * A hash table associated old ID's (key) with their new ID's (value).
\r
212 var $old_ids_to_new_ids;
\r
217 * @param string $version The backup version.
\r
218 * @param resource $db The database handler.
\r
219 * @param int $course_id The ID of this course.
\r
220 * @param string $import_dir The directory where the backup was unzipped to.
\r
221 * @param array $old_ids_to_new_ids Reference.
\r
224 function AbstractTable($version, $db, $course_id, $import_dir, &$old_ids_to_new_ids) {
\r
227 $this->course_id = $course_id;
\r
228 $this->version = $version;
\r
229 $this->import_dir = $import_dir;
\r
231 $this->old_ids_to_new_ids = $old_ids_to_new_ids;
\r
233 if (!isset($this->old_ids_to_new_ids[$this->tableName])) {
\r
234 $this->old_ids_to_new_ids[$this->tableName] = array();
\r
238 // -- public methods below:
\r
241 * Restores the table defined in the CSV file, one row at a time.
\r
249 function restore() {
\r
252 // skipLock is used specificially with the `forums_courses` table
\r
253 if (!isset($this->skipLock)) {
\r
254 $this->lockTable();
\r
260 foreach ($this->rows as $row) {
\r
262 $sql = $this->generateSQL($row);
\r
263 mysql_query($sql, $db);
\r
265 //debug(mysql_error($this->db));
\r
268 if (!isset($this->skipLock)) {
\r
269 $this->unlockTable();
\r
273 // -- protected methods below:
\r
276 * Converts escaped white space characters to their correct representation.
\r
278 * @access protected
\r
279 * @param string $input The string to convert.
\r
280 * @return string The converted string.
\r
281 * @See Backup::quoteCSV()
\r
283 function translateWhitespace($input) {
\r
284 $input = str_replace('\n', "\n", $input);
\r
285 $input = str_replace('\r', "\r", $input);
\r
286 $input = str_replace('\x00', "\0", $input);
\r
288 $input = addslashes($input);
\r
293 // find the index offset
\r
294 function findOffset($id) {
\r
295 return $this->rows[$id]['index_offset'];
\r
298 // -- private methods below:
\r
299 function getNextID() {
\r
302 $sql = 'SELECT MAX(' . $this->primaryIDField . ') AS next_id FROM ' . TABLE_PREFIX . $this->tableName;
\r
303 $result = mysql_query($sql, $db);
\r
304 $next_index = mysql_fetch_assoc($result);
\r
305 return ($next_index['next_id'] + 1);
\r
309 * Gets the member_id of the instructor who owns a course in the context of a backup restore
\r
311 * @param int $id The backup course to query on
\r
312 * @access protected
\r
313 * @return int The member_id who owns the corresponding backup course
\r
315 function resolveBkpOwner($id) {
\r
318 $sql = 'SELECT member_id FROM ' . TABLE_PREFIX . 'courses WHERE course_id = '. $id;
\r
320 $result = mysql_query($sql, $db);
\r
323 echo 'Fatal SQL error occured in TableBackup:resolveBkpOwner: ' . mysql_error() .
\r
324 ' ' . mysql_error($db) .
\r
325 ' Check that the course your are restoring to exists.';
\r
329 $row = mysql_fetch_assoc($result);
\r
332 echo 'Fatal SQL error occured in TableBackup:resolveBkpOwner: ' . mysql_error() .
\r
333 ' ' . mysql_error($db) .
\r
334 ' Check that the course your are restoring to exists.';
\r
338 return $row['member_id'];
\r
342 * Reads the CSV table file into array $this->rows.
\r
348 * @See closeTable()
\r
351 function getRows() {
\r
355 $next_id = $this->getNextID();
\r
357 while ($row = @fgetcsv($this->fp, 70000)) {
\r
359 $row[0] = trim($row[0]);
\r
360 if ($row[0] == '') {
\r
364 $row = $this->translateText($row);
\r
365 $row = $this->convert($row);
\r
367 $row['index_offset'] = $i;
\r
368 $row['new_id'] = $next_id++;
\r
369 if ($this->getOldID($row) === FALSE) {
\r
370 $this->rows[] = $row;
\r
372 $this->rows[$this->getOldID($row)] = $row;
\r
373 $this->old_ids_to_new_ids[$this->tableName][$this->getOldID($row)] = $row['new_id'];
\r
378 $this->closeFile();
\r
382 * Converts $row to be ready for inserting into the db.
\r
384 * @param array $row The row to convert.
\r
386 * @return array The converted row.
\r
388 * @see translateWhitespace()
\r
390 function translateText($row) {
\r
392 global $backup_tables;
\r
395 foreach ($backup_tables[$this->tableName]['fields'] as $field) {
\r
396 if ($field[1] == TEXT) {
\r
397 $row[$count] = $this->translateWhitespace($row[$count]);
\r
405 * Locks the database table for writing or/and also lock the courses table for resolving restore issues
\r
406 * in the admin context
\r
411 * @See unlockTable()
\r
413 function lockTable() {
\r
417 if ($_SESSION['member_id'])
\r
418 $lock_sql = 'LOCK TABLES ' . TABLE_PREFIX . $this->tableName. ' WRITE';
\r
419 else // admin context
\r
420 $lock_sql = 'LOCK TABLES ' . TABLE_PREFIX . $this->tableName. ', ' . TABLE_PREFIX . 'courses WRITE';
\r
422 $result = mysql_query($lock_sql, $db);
\r
426 * UnLocks the database table.
\r
433 function unlockTable() {
\r
435 $lock_sql = 'UNLOCK TABLES';
\r
436 $result = mysql_query($lock_sql, $db);
\r
440 * Opens the CSV table file for reading.
\r
447 function openFile() {
\r
448 $this->fp = @fopen($this->import_dir . $this->tableName . '.csv', 'rb');
\r
452 * Closes the CSV table file.
\r
459 function closeFile() {
\r
460 @fclose($this->fp);
\r
464 * Gets the entry/row's new ID based on it's old entry ID.
\r
466 * @param int $id The old entry ID.
\r
467 * @access protected
\r
468 * @return int The new entry ID
\r
471 function getNewID($id) {
\r
472 return $this->rows[$id]['new_id'];
\r
475 // -- abstract methods below:
\r
477 * Gets the entry/row ID as it appears in the CSV file, or FALSE if n/a.
\r
479 * @param array $row The old entry row from the CSV file.
\r
481 * @return boolean|int The old ID or FALSE if not applicable.
\r
484 function getOldID($row) { /* abstract */ }
\r
487 * Convert the entry/row to the current ATutor version.
\r
489 * @param array $row The old entry row from the CSV file.
\r
491 * @return array The converted row.
\r
494 function convert($row) { /* abstract */ }
\r
497 * Generate the SQL for this table.
\r
499 * Precondition: $row has passed through convert() and
\r
502 * @param array $row The old entry row from the CSV file.
\r
504 * @return string The SQL query.
\r
508 function generateSQL($row) { /* abstract */ }
\r
511 //---------------------------------------------------------------------
\r
515 * Extends AbstractTable and provides table specific methods and members.
\r
517 * @author Joel Kronenberg
\r
518 * @author Heidi Hazelton
\r
521 class ForumsTable extends AbstractTable {
\r
523 * The ATutor database table name (w/o prefix).
\r
524 * Also the CSV file name (w/o extension).
\r
527 * @var const string
\r
529 var $tableName = 'forums';
\r
532 * The ATutor database table primary ID field.
\r
535 * @var const string
\r
537 var $primaryIDField = 'forum_id';
\r
539 // -- private methods below:
\r
540 function getOldID($row) {
\r
544 function convert($row) {
\r
545 if (version_compare($this->version, '1.4.3', '<')) {
\r
546 // previous versions didn't have a forum_id field
\r
549 for($i=5; $i>0; $i--) {
\r
550 $row[$i] = $row[$i-1];
\r
557 function generateSQL($row) {
\r
558 $sql = 'INSERT INTO '.TABLE_PREFIX.'forums VALUES ';
\r
559 $sql .= '('.$row['new_id']. ',';
\r
560 $sql .= "'".$row[1]."',"; // title
\r
561 $sql .= "'".$row[2]."',"; // description
\r
562 $sql .= "$row[3],"; // num_topics
\r
563 $sql .= "$row[4],"; // num_posts
\r
564 $sql .= "'".$row[5]."')"; // last_post
\r
569 //---------------------------------------------------------------------
\r
571 * ForumsCoursesTable
\r
572 * Extends AbstractTable and provides table specific methods and members.
\r
574 * @author Heidi Hazelton
\r
577 class ForumsCoursesTable extends AbstractTable {
\r
580 * The ATutor database table name (w/o prefix).
\r
581 * Also the CSV file name (w/o extension).
\r
584 * @var const string
\r
586 var $tableName = 'forums';
\r
589 * The ATutor database table primary ID field.
\r
592 * @var const string
\r
594 var $primaryIDField = 'forum_id';
\r
597 * Whether or not lock this table.
\r
598 * This is a special case, b/c we read from the `forums` table
\r
599 * but insert into the `forums_courses` table. Hence, we lock a different
\r
600 * table than we actually insert into (ie. why we don't need/want a lock).
\r
603 * @var const boolean
\r
605 var $skipLock = TRUE;
\r
607 // -- private methods below:
\r
608 function getOldID($row) {
\r
612 function convert($row) {
\r
616 function generateSQL($row) {
\r
618 if (version_compare($this->version, '1.4.3', '<')) {
\r
619 $id = $this->count;
\r
623 $sql = 'INSERT INTO '.TABLE_PREFIX.'forums_courses VALUES ';
\r
624 $sql .= '('.$this->old_ids_to_new_ids['forums'][$id] . ','; // forum_id
\r
625 $sql .= $this->course_id .")"; // course_id
\r
630 //---------------------------------------------------------------------
\r
631 class GlossaryTable extends AbstractTable {
\r
632 var $tableName = 'glossary';
\r
633 var $primaryIDField = 'word_id';
\r
635 function getOldID($row) {
\r
640 function convert($row) {
\r
645 function generateSQL($row) {
\r
647 $sql = 'INSERT INTO '.TABLE_PREFIX.'glossary VALUES ';
\r
648 $sql .= '('.$row['new_id'].','; // word_id
\r
649 $sql .= $this->course_id . ','; // course_id
\r
650 $sql .= "'".$row[1]."',"; // word
\r
651 $sql .= "'".$row[2]."',"; // definition
\r
652 if ($row[3] == 0) {
\r
655 $sql .= $this->getNewID($row[3]); // related word
\r
662 //---------------------------------------------------------------------
\r
663 class ResourceCategoriesTable extends AbstractTable {
\r
664 var $tableName = 'resource_categories';
\r
666 var $primaryIDField = 'CatID';
\r
668 function getOldID($row) {
\r
673 function convert($row) {
\r
678 function generateSQL($row) {
\r
679 $sql = 'INSERT INTO '.TABLE_PREFIX.'resource_categories VALUES ';
\r
680 $sql .= '('.$row['new_id'].',';
\r
681 $sql .= $this->course_id .',';
\r
683 $sql .= "'".$row[1]."',";
\r
686 if ($row[2] == 0) {
\r
689 $sql .= $this->getNewID($row[2]); // category parent
\r
697 //---------------------------------------------------------------------
\r
698 class ResourceLinksTable extends AbstractTable {
\r
699 var $tableName = 'resource_links';
\r
701 var $primaryIDField = 'LinkID';
\r
703 function getOldID($row) {
\r
708 function convert($row) {
\r
709 // handle the white space issue as well
\r
714 function generateSQL($row) {
\r
716 $sql = 'INSERT INTO '.TABLE_PREFIX.'resource_links VALUES ';
\r
717 $sql .= '('.$row['new_id'].', ';
\r
718 $sql .= $this->old_ids_to_new_ids['resource_categories'][$row[0]] . ',';
\r
720 $sql .= "'".$row[1]."',"; // URL
\r
721 $sql .= "'".$row[2]."',"; // LinkName
\r
722 $sql .= "'".$row[3]."',"; // Description
\r
723 $sql .= $row[4].','; // Approved
\r
724 $sql .= "'".$row[5]."',"; // SubmitName
\r
725 $sql .= "'".$row[6]."',"; // SubmitEmail
\r
726 $sql .= "'".$row[7]."',"; // SubmitDate
\r
727 $sql .= $row[8]. ')';
\r
732 //---------------------------------------------------------------------
\r
733 class NewsTable extends AbstractTable {
\r
734 var $tableName = 'news';
\r
735 var $primaryIDField = 'news_id';
\r
737 function getOldID($row) {
\r
742 function convert($row) {
\r
747 function generateSQL($row) {
\r
749 $sql = 'INSERT INTO '.TABLE_PREFIX.'news VALUES ';
\r
750 $sql .= '('.$row['new_id'].',';
\r
751 $sql .= $this->course_id.',';
\r
754 * Admin user does not possess a member_id, assign ownership to instructor of restored course
\r
756 if (isset($_SESSION['member_id'])) {
\r
757 $sql .= $_SESSION['member_id'] . ',';
\r
758 } else { // admin context
\r
759 $sql .= $this->resolveBkpOwner($this->course_id) . ',';
\r
762 $sql .= "'".$row[0]."',"; // date
\r
763 $sql .= "'".$row[1]."',"; // formatting
\r
764 $sql .= "'".$row[2]."',"; // title
\r
765 $sql .= "'".$row[3]."')"; // body
\r
771 //---------------------------------------------------------------------
\r
772 // -- tests (`tests`, `tests_questions`, `tests_categories`, `tests_questions_assoc`, `content_test_assco`)
\r
773 class TestsTable extends AbstractTable {
\r
774 var $tableName = 'tests';
\r
775 var $primaryIDField = 'test_id';
\r
777 function getOldID($row) {
\r
782 function convert($row) {
\r
783 // handle the white space issue as well
\r
784 if (version_compare($this->version, '1.4', '<')) {
\r
791 if (version_compare($this->version, '1.4.2', '<')) {
\r
795 if (version_compare($this->version, '1.4.3', '<')) {
\r
803 function generateSQL($row) {
\r
805 $sql = 'INSERT INTO '.TABLE_PREFIX.'tests VALUES ';
\r
806 $sql .= '('.$row['new_id'].',';
\r
807 $sql .= $this->course_id.',';
\r
809 $sql .= "'".$row[1]."',"; // title
\r
810 $sql .= "'".$row[2]."',"; // format
\r
811 $sql .= "'".$row[3]."',"; // start_date
\r
812 $sql .= "'".$row[4]."',"; // end_date
\r
813 $sql .= "'".$row[5]."',"; // randomize_order
\r
814 $sql .= "'".$row[6]."',"; // num_questions
\r
815 $sql .= "'".$row[7]."',"; // instructions
\r
816 $sql .= '0,'; // content_id
\r
817 $sql .= $row[9] . ','; // release_result
\r
818 $sql .= $row[10] . ','; // random
\r
819 $sql .= $row[11] . ','; // difficulty
\r
820 $sql .= $row[12] . ','; // num_takes
\r
821 $sql .= $row[13] . ','; // anonymous
\r
822 $sql .= "'".$row[14]."'"; // out_of
\r
828 //---------------------------------------------------------------------
\r
829 class TestsQuestionsTable extends AbstractTable {
\r
830 var $tableName = 'tests_questions';
\r
831 var $primaryIDField = 'question_id';
\r
833 function getOldID($row) {
\r
838 function convert($row) {
\r
839 if (version_compare($this->version, '1.4.3', '<')) {
\r
840 // basically, rework the fields then recreate the `tests_questions_assoc.csv` file.
\r
841 // create the tests_questions_assoc file using $row[0] as the `test_id` and $row['new_id'] as the new question ID
\r
843 $test_id = $row[0];
\r
846 $required = $row[4];
\r
849 $row[0] = $count; // question id
\r
850 $row[1] = 0; // category id
\r
851 $row[2] = $row[2]; // type
\r
853 for($i = 3; $i < 27; $i++) {
\r
854 $row[$i] = $row[$i+2];
\r
857 $assoc_data = "$test_id,$count,$weight,$order,$required\n";
\r
858 $fp = fopen($this->import_dir . 'tests_questions_assoc.csv', 'ab');
\r
859 fwrite($fp, $assoc_data);
\r
867 function generateSQL($row) {
\r
870 if (!isset($this->old_ids_to_new_ids['tests_questions_categories'][$row[1]])) {
\r
871 $this->old_ids_to_new_ids['tests_questions_categories'][$row[1]] = 0;
\r
874 $sql = 'INSERT INTO '.TABLE_PREFIX.'tests_questions VALUES ';
\r
875 $sql .= '('.$row['new_id'].',' . $this->old_ids_to_new_ids['tests_questions_categories'][$row[1]] . ',';
\r
876 $sql .= $this->course_id;
\r
878 for ($i=2; $i <= 26; $i++) {
\r
879 $sql .= ",'".$row[$i]."'";
\r
887 //---------------------------------------------------------------------
\r
888 class TestsQuestionsAssocTable extends AbstractTable {
\r
889 var $tableName = 'tests_questions_assoc';
\r
890 var $primaryIDField = 'question_id';
\r
892 function getOldID($row) {
\r
897 function convert($row) {
\r
902 function generateSQL($row) {
\r
904 $sql = 'INSERT INTO '.TABLE_PREFIX.'tests_questions_assoc VALUES ';
\r
905 $sql .= '(' . $this->old_ids_to_new_ids['tests'][$row[0]].',' . $this->old_ids_to_new_ids['tests_questions'][$row[1]];
\r
906 $sql .= ",'$row[2]','$row[3]','$row[4]')";
\r
911 //---------------------------------------------------------------------
\r
912 class TestsQuestionsCategoriesTable extends AbstractTable {
\r
913 var $tableName = 'tests_questions_categories';
\r
914 var $primaryIDField = 'category_id';
\r
916 function getOldID($row) {
\r
921 function convert($row) {
\r
926 function generateSQL($row) {
\r
928 $sql = 'INSERT INTO '.TABLE_PREFIX.'tests_questions_categories VALUES ';
\r
929 $sql .= '('.$row['new_id'].',';
\r
930 $sql .= $this->course_id;
\r
931 $sql .= ',"'.$row[1].'"';
\r
937 //---------------------------------------------------------------------
\r
939 class PollsTable extends AbstractTable {
\r
940 var $tableName = 'polls';
\r
941 var $primaryIDField = 'poll_id';
\r
943 function getOldID($row) {
\r
948 function convert($row) {
\r
953 function generateSQL($row) {
\r
955 $sql = 'INSERT INTO '.TABLE_PREFIX.'polls VALUES ';
\r
956 $sql .= '('.$row['new_id'].',';
\r
957 $sql .= $this->course_id.',';
\r
958 $sql .= "'$row[0]',"; // question
\r
959 $sql .= "'$row[1]',"; // created date
\r
960 $sql .= "0,"; // total
\r
962 for ($i=2; $i<=8; $i++) {
\r
963 $sql .= "'".$row[$i]."',0,";
\r
966 $sql = substr($sql, 0, -1);
\r
973 //---------------------------------------------------------------------
\r
974 class ContentTable extends AbstractTable {
\r
975 var $tableName = 'content';
\r
977 var $primaryIDField = 'content_id';
\r
984 * @param string $version The backup version.
\r
985 * @param resource $db The database handler.
\r
986 * @param int $course_id The ID of this course.
\r
987 * @param string $import_dir The directory where the backup was unzipped to.
\r
988 * @param array $old_id_to_new_id Reference to either the parent ID's or to store current ID's.
\r
991 function ContentTable($version, $db, $course_id, $import_dir, &$old_id_to_new_id) {
\r
992 // special case for `content` -- we need the max ordering
\r
994 $sql = 'SELECT MAX(ordering) AS ordering FROM '.TABLE_PREFIX.'content WHERE content_parent_id=0 AND course_id='.$course_id;
\r
995 $result = mysql_query($sql, $db);
\r
996 $ordering = mysql_fetch_assoc($result);
\r
997 $this->ordering = $ordering['ordering'] +1;
\r
999 parent::AbstractTable($version, $db, $course_id, $import_dir, $old_id_to_new_id);
\r
1002 function getOldID($row) {
\r
1007 function convert($row) {
\r
1012 function generateSQL($row) {
\r
1013 $sql = 'INSERT INTO '.TABLE_PREFIX.'content VALUES ';
\r
1014 $sql .= '('.$row['new_id'].','; // content_id
\r
1015 $sql .= $this->course_id .','; // course_id
\r
1016 if ($row[1] == 0) { // content_parent_id
\r
1019 $sql .= $this->getNewID($row[1]);
\r
1023 if ($row[1] == 0) {
\r
1024 // find the new ordering:
\r
1025 $sql .= $this->ordering . ',';
\r
1026 $this->ordering ++;
\r
1028 $sql .= $row[2].',';
\r
1031 $sql .= "'".$row[3]."',"; // last_modified
\r
1032 $sql .= $row[4] . ','; // revision
\r
1033 $sql .= $row[5] . ','; // formatting
\r
1034 $sql .= "'".$row[6]."',"; // release_date
\r
1035 $sql .= "'".$row[7]."',"; // keywords
\r
1036 $sql .= "'".$row[8]."',"; // content_path
\r
1037 $sql .= "'".$row[9]."',"; // title
\r
1038 $sql .= "'".$row[10]."',0)"; // text
\r
1044 //---------------------------------------------------------------------
\r
1045 class ContentTestsAssocTable extends AbstractTable {
\r
1046 var $tableName = 'content_tests_assoc';
\r
1047 var $primaryIDField = 'test_id';
\r
1049 function getOldID($row) {
\r
1054 function convert($row) {
\r
1059 function generateSQL($row) {
\r
1061 $sql = 'INSERT INTO '.TABLE_PREFIX.'content_tests_assoc VALUES ';
\r
1062 $sql .= '(' . $this->old_ids_to_new_ids['content'][$row[0]].',' . $this->old_ids_to_new_ids['tests'][$row[1]].')';
\r
1067 //---------------------------------------------------------------------
\r
1068 class RelatedContentTable extends AbstractTable {
\r
1069 var $tableName = 'related_content';
\r
1071 var $primaryIDField = 'content_id';
\r
1073 function getOldID($row) {
\r
1078 function convert($row) {
\r
1083 function generateSQL($row) {
\r
1084 $sql = 'INSERT INTO '.TABLE_PREFIX.'related_content VALUES ';
\r
1085 $sql .= '('.$this->old_ids_to_new_ids['content'][$row['0']].','. $this->old_ids_to_new_ids['content'][$row[1]].')';
\r
1091 //---------------------------------------------------------------------
\r
1092 class CourseStatsTable extends AbstractTable {
\r
1093 var $tableName = 'course_stats';
\r
1094 var $primaryIDField = 'login_date'; // never actually used
\r
1096 function getOldID($row) {
\r
1100 function getParentID($row) {
\r
1105 function convert($row) {
\r
1110 function generateSQL($row) {
\r
1112 $sql = 'INSERT INTO '.TABLE_PREFIX.'course_stats VALUES ';
\r
1113 $sql .= '('.$this->course_id.",";
\r
1114 $sql .= "'".$row[0]."',"; // login_date
\r
1115 $sql .= "'".$row[1]."',"; // guests
\r
1116 $sql .= "'".$row[2]."'"; // members
\r
1123 //---------------------------------------------------------------------
\r
1124 class GroupsTable extends AbstractTable {
\r
1125 var $tableName = 'groups';
\r
1126 var $primaryIDField = 'group_id';
\r
1128 function getOldID($row) {
\r
1132 function getParentID($row) {
\r
1137 function convert($row) {
\r
1142 function generateSQL($row) {
\r
1144 $sql = 'INSERT INTO '.TABLE_PREFIX.'groups VALUES ';
\r
1145 $sql .= '('.$row['new_id'] . ',' . $this->course_id.",";
\r
1146 $sql .= "'".$row[0]."'"; // title
\r