remove old readme
[atutor.git] / docs / install / include / classes / TableConversion.class.php
1 <?php\r
2 /************************************************************************/\r
3 /* ATutor                                                                                                                               */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2002-2010                                              */\r
6 /* Inclusive Design Institute                                           */\r
7 /* http://atutor.ca                                                                                                             */\r
8 /*                                                                                                                                              */\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
13 // $Id$\r
14 \r
15 /* Constances, refer to /include/lib/constants.inc.php */\r
16 /* files */\r
17 define('WORKSPACE_COURSE',     1); // aka Course Files\r
18 define('WORKSPACE_PERSONAL',   2); // aka My Files\r
19 define('WORKSPACE_ASSIGNMENT', 3);\r
20 define('WORKSPACE_GROUP',      4);\r
21 /* links */\r
22 define('LINK_CAT_COURSE',       1);\r
23 define('LINK_CAT_GROUP',        2);\r
24 define('LINK_CAT_SELF',         3);\r
25 \r
26 /**\r
27  * This class handles different types of conversions for the ATutor tables.\r
28  * Table entries based on the course's Primary Language will be converted by convertTableByClass($,$)\r
29  * Table entries based on the System Defualt Language will be converted by convertTableBySysDefualt()\r
30  * @access                      public\r
31  * @author                      Harris Wong\r
32  * @precondition        MySQL connected, mbstring lib enabled.\r
33  * @date                        Dec 12, 2007\r
34  */\r
35  class ConversionDriver{\r
36          /** variable */\r
37         var $sys_default_lang;\r
38         var $table_prefix;\r
39 \r
40          /** \r
41           * Constructor\r
42           * @param      table_prefix\r
43           */\r
44          function ConversionDriver($table_prefix){\r
45                  $this->sys_default_lang = 'iso-8859-1';\r
46                  $this->table_prefix = $table_prefix;\r
47          }\r
48 \r
49          /**\r
50           * This function runs all the table that uses the system default language\r
51           */\r
52          function convertTableBySysDefault(){\r
53                 global $errors;\r
54 \r
55                 $temp_table = new CourseCategoriesTable($this->table_prefix, 'course_cats', $this->sys_default_lang);\r
56                 if (!$temp_table->convert()){\r
57                         $errors[]= $this->table_prefix.'course_cats was not converted.';\r
58                         $_SESSION['redo_conversion'][$course_title]['CourseCategoriesTable'] = array($this->table_prefix, 'course_cats', $char_set, $course_id);\r
59                 }\r
60 \r
61                 $temp_table = new MembersTable($this->table_prefix, 'members', $this->sys_default_lang);\r
62                 if (!$temp_table->convert()){\r
63                         $errors[]= $this->table_prefix.'members was not converted.';\r
64                         $_SESSION['redo_conversion'][$course_title]['MembersTable'] = array($this->table_prefix, 'members', $char_set, $course_id);\r
65                 }\r
66          }\r
67 \r
68         /**\r
69          * This function runs all the table that uses the system default language\r
70          * Particular for 1.6.1, since 1.6 didn't convret all table\r
71          */\r
72         function convertTableBySysDefault_161(){\r
73                 global $errors;\r
74 \r
75                 $temp_table = new AdminsTable($this->table_prefix, 'admins', $this->sys_default_lang);\r
76                 if (!$temp_table->convert()){\r
77                         $errors[]= $this->table_prefix.'admins was not converted.';\r
78                         $_SESSION['redo_conversion'][$course_title]['AdminsTable'] = array($this->table_prefix, 'admins', $this->sys_default_lang, $course_id);\r
79                 }\r
80 \r
81                 $temp_table = new AdminLogTable($this->table_prefix, 'admin_log', $this->sys_default_lang);\r
82                 if (!$temp_table->convert()){\r
83                         $errors[]= $this->table_prefix.'admin_log was not converted.';\r
84                         $_SESSION['redo_conversion'][$course_title]['AdminLogTable'] = array($this->table_prefix, 'admin_log', $this->sys_default_lang, $course_id);\r
85                 }\r
86 \r
87                 $temp_table = new AutoEnrollTable($this->table_prefix, 'auto_enroll', $this->sys_default_lang);\r
88                 if (!$temp_table->convert()){\r
89                         $errors[]= $this->table_prefix.'auto_enroll was not converted.';\r
90                         $_SESSION['redo_conversion'][$course_title]['AutoEnrollTable'] = array($this->table_prefix, 'auto_enroll', $this->sys_default_lang, $course_id);\r
91                 }\r
92 \r
93                 $temp_table = new AutoEnrollCoursesTable($this->table_prefix, 'auto_enroll_courses', $this->sys_default_lang);\r
94                 if (!$temp_table->convert()){\r
95                         $errors[]= $this->table_prefix.'auto_enroll_courses was not converted.';\r
96                         $_SESSION['redo_conversion'][$course_title]['AutoEnrollCourses'] = array($this->table_prefix, 'auto_enroll_courses', $this->sys_default_lang, $course_id);\r
97                 }\r
98 \r
99                 $temp_table = new ConfigTable($this->table_prefix, 'config', $this->sys_default_lang);\r
100                 if (!$temp_table->convert()){\r
101                         $errors[]= $this->table_prefix.'config was not converted.';\r
102                         $_SESSION['redo_conversion'][$course_title]['ConfigTable'] = array($this->table_prefix, 'config', $this->sys_default_lang, $course_id);\r
103                 }\r
104 \r
105                 $temp_table = new CourseAccessTable($this->table_prefix, 'course_access', $this->sys_default_lang);\r
106                 if (!$temp_table->convert()){\r
107                         $errors[]= $this->table_prefix.'course_access was not converted.';\r
108                         $_SESSION['redo_conversion'][$course_title]['CourseAccessTable'] = array($this->table_prefix, 'course_access', $this->sys_default_lang, $course_id);\r
109                 }\r
110 \r
111                 $temp_table = new CourseStatsTable($this->table_prefix, 'course_stats', $this->sys_default_lang);\r
112                 if (!$temp_table->convert()){\r
113                         $errors[]= $this->table_prefix.'course_stats was not converted.';\r
114                         $_SESSION['redo_conversion'][$course_title]['CourseStatsTable'] = array($this->table_prefix, 'course_stats', $this->sys_default_lang, $course_id);\r
115                 }\r
116 \r
117                 $temp_table = new FeedsTable($this->table_prefix, 'feeds', $this->sys_default_lang);\r
118                 if (!$temp_table->convert()){\r
119                         $errors[]= $this->table_prefix.'feeds was not converted.';\r
120                         $_SESSION['redo_conversion'][$course_title]['FeedsTable'] = array($this->table_prefix, 'feeds', $this->sys_default_lang, $course_id);\r
121                 }\r
122 \r
123                 $temp_table = new FileStorageGroupsTable($this->table_prefix, 'file_storage_groups', $this->sys_default_lang);\r
124                 if (!$temp_table->convert()){\r
125                         $errors[]= $this->table_prefix.'file_storage_groups was not converted.';\r
126                         $_SESSION['redo_conversion'][$course_title]['FileStorageGroupsTable'] = array($this->table_prefix, 'file_storage_groups', $this->sys_default_lang, $course_id);\r
127                 }\r
128 \r
129                 $temp_table = new ForumsAccessedTable($this->table_prefix, 'forums_accessed', $this->sys_default_lang);\r
130                 if (!$temp_table->convert()){\r
131                         $errors[]= $this->table_prefix.'forums_accessed was not converted.';\r
132                         $_SESSION['redo_conversion'][$course_title]['ForumsAccessedTable'] = array($this->table_prefix, 'forums_accessed', $this->sys_default_lang, $course_id);\r
133                 }\r
134 \r
135                 $temp_table = new ForumsCoursesTable($this->table_prefix, 'forums_courses', $this->sys_default_lang);\r
136                 if (!$temp_table->convert()){\r
137                         $errors[]= $this->table_prefix.'forums_courses was not converted.';\r
138                         $_SESSION['redo_conversion'][$course_title]['ForumsCoursesTable'] = array($this->table_prefix, 'forums_courses', $this->sys_default_lang, $course_id);\r
139                 }\r
140 \r
141                 $temp_table = new ForumsGroupsTable($this->table_prefix, 'forums_groups', $this->sys_default_lang);\r
142                 if (!$temp_table->convert()){\r
143                         $errors[]= $this->table_prefix.'forums_groups was not converted.';\r
144                         $_SESSION['redo_conversion'][$course_title]['ForumsGroupsTable'] = array($this->table_prefix, 'forums_groups', $this->sys_default_lang, $course_id);\r
145                 }\r
146 \r
147                 $temp_table = new ForumsSubscriptionsTable($this->table_prefix, 'forums_subscriptions', $this->sys_default_lang);\r
148                 if (!$temp_table->convert()){\r
149                         $errors[]= $this->table_prefix.'forums_subscriptions was not converted.';\r
150                         $_SESSION['redo_conversion'][$course_title]['ForumsSubscriptionsTable'] = array($this->table_prefix, 'forums_subscriptions', $this->sys_default_lang, $course_id);\r
151                 }\r
152 \r
153                 $temp_table = new GroupsMembersTable($this->table_prefix, 'groups_members', $this->sys_default_lang);\r
154                 if (!$temp_table->convert()){\r
155                         $errors[]= $this->table_prefix.'groups_members was not converted.';\r
156                         $_SESSION['redo_conversion'][$course_title]['GroupsMembersTable'] = array($this->table_prefix, 'groups_members', $this->sys_default_lang, $course_id);\r
157                 }\r
158 \r
159                 $temp_table = new HandbookNotesTable($this->table_prefix, 'handbook_notes', $this->sys_default_lang);\r
160                 if (!$temp_table->convert()){\r
161                         $errors[]= $this->table_prefix.'handbook_notes was not converted.';\r
162                         $_SESSION['redo_conversion'][$course_title]['HandbookNotesTable'] = array($this->table_prefix, 'handbook_notes', $this->sys_default_lang, $course_id);\r
163                 }\r
164 \r
165                 $temp_table = new InstructorApprovalsTable($this->table_prefix, 'instructor_approvals', $this->sys_default_lang);\r
166                 if (!$temp_table->convert()){\r
167                         $errors[]= $this->table_prefix.'instructor_approvals was not converted.';\r
168                         $_SESSION['redo_conversion'][$course_title]['InstructorApprovalsTable'] = array($this->table_prefix, 'instructor_approvals', $this->sys_default_lang, $course_id);\r
169                 }\r
170 \r
171                 $temp_table = new LanguagesTable($this->table_prefix, 'languages', $this->sys_default_lang);\r
172                 if (!$temp_table->convert()){\r
173                         $errors[]= $this->table_prefix.'languages was not converted.';\r
174                         $_SESSION['redo_conversion'][$course_title]['LanguagesTable'] = array($this->table_prefix, 'languages', $this->sys_default_lang, $course_id);\r
175                 }\r
176 \r
177                 $temp_table = new LanguagePagesTable($this->table_prefix, 'language_pages', $this->sys_default_lang);\r
178                 if (!$temp_table->convert()){\r
179                         $errors[]= $this->table_prefix.'language_pages was not converted.';\r
180                         $_SESSION['redo_conversion'][$course_title]['LanguagePagesTable'] = array($this->table_prefix, 'language_pages', $this->sys_default_lang, $course_id);\r
181                 }\r
182 \r
183                 $temp_table = new LanguageTextTable($this->table_prefix, 'language_text', $this->sys_default_lang);\r
184                 if (!$temp_table->convert()){\r
185                         $errors[]= $this->table_prefix.'language_text was not converted.';\r
186                         $_SESSION['redo_conversion'][$course_title]['LanguageTextTable'] = array($this->table_prefix, 'language_text', $this->sys_default_lang, $course_id);\r
187                 }\r
188 \r
189                 $temp_table = new MailQueueTable($this->table_prefix, 'mail_queue', $this->sys_default_lang);\r
190                 if (!$temp_table->convert()){\r
191                         $errors[]= $this->table_prefix.'mail_queue was not converted.';\r
192                         $_SESSION['redo_conversion'][$course_title]['MailQueueTable'] = array($this->table_prefix, 'mail_queue', $this->sys_default_lang, $course_id);\r
193                 }\r
194 \r
195                 $temp_table = new MasterListTable($this->table_prefix, 'master_list', $this->sys_default_lang);\r
196                 if (!$temp_table->convert()){\r
197                         $errors[]= $this->table_prefix.'master_list was not converted.';\r
198                         $_SESSION['redo_conversion'][$course_title]['MasterListTable'] = array($this->table_prefix, 'master_list', $this->sys_default_lang, $course_id);\r
199                 }\r
200         \r
201                 $temp_table = new MemberTrackTable($this->table_prefix, 'member_track', $this->sys_default_lang);\r
202                 if (!$temp_table->convert()){\r
203                         $errors[]= $this->table_prefix.'member_track was not converted.';\r
204                         $_SESSION['redo_conversion'][$course_title]['MemberTrackTable'] = array($this->table_prefix, 'member_track', $this->sys_default_lang, $course_id);\r
205                 }\r
206 \r
207                 $temp_table = new ModulesTable($this->table_prefix, 'modules', $this->sys_default_lang);\r
208                 if (!$temp_table->convert()){\r
209                         $errors[]= $this->table_prefix.'modules was not converted.';\r
210                         $_SESSION['redo_conversion'][$course_title]['ModulesTable'] = array($this->table_prefix, 'modules', $this->sys_default_lang, $course_id);\r
211                 }\r
212 \r
213                 $temp_table = new PollsMembersTable($this->table_prefix, 'polls_members', $this->sys_default_lang);\r
214                 if (!$temp_table->convert()){\r
215                         $errors[]= $this->table_prefix.'polls_members was not converted.';\r
216                         $_SESSION['redo_conversion'][$course_title]['PollsMembersTable'] = array($this->table_prefix, 'polls_members', $this->sys_default_lang, $course_id);\r
217                 }\r
218 \r
219                 $temp_table = new RelatedContentTable($this->table_prefix, 'related_content', $this->sys_default_lang);\r
220                 if (!$temp_table->convert()){\r
221                         $errors[]= $this->table_prefix.'related_content was not converted.';\r
222                         $_SESSION['redo_conversion'][$course_title]['RelatedContentTable'] = array($this->table_prefix, 'related_content', $this->sys_default_lang, $course_id);\r
223                 }\r
224 \r
225                 $temp_table = new TestsGroupsTable($this->table_prefix, 'tests_groups', $this->sys_default_lang);\r
226                 if (!$temp_table->convert()){\r
227                         $errors[]= $this->table_prefix.'tests_groups was not converted.';\r
228                         $_SESSION['redo_conversion'][$course_title]['TestsGroupsTable'] = array($this->table_prefix, 'tests_groups', $this->sys_default_lang, $course_id);\r
229                 }\r
230 \r
231                 $temp_table = new TestsQuestionsAssocTable($this->table_prefix, 'tests_questions_assoc', $this->sys_default_lang);\r
232                 if (!$temp_table->convert()){\r
233                         $errors[]= $this->table_prefix.'tests_questions_assoc was not converted.';\r
234                         $_SESSION['redo_conversion'][$course_title]['TestsQuestionsAssocTable'] = array($this->table_prefix, 'tests_questions_assoc', $this->sys_default_lang, $course_id);\r
235                 }\r
236 \r
237                 $temp_table = new TestsResultsTable($this->table_prefix, 'tests_results', $this->sys_default_lang);\r
238                 if (!$temp_table->convert()){\r
239                         $errors[]= $this->table_prefix.'tests_results was not converted.';\r
240                         $_SESSION['redo_conversion'][$course_title]['TestsResultsTable'] = array($this->table_prefix, 'tests_results', $this->sys_default_lang, $course_id);\r
241                 }\r
242 \r
243                 $temp_table = new ThemesTable($this->table_prefix, 'themes', $this->sys_default_lang);\r
244                 if (!$temp_table->convert()){\r
245                         $errors[]= $this->table_prefix.'themes was not converted.';\r
246                         $_SESSION['redo_conversion'][$course_title]['ThemesTable'] = array($this->table_prefix, 'themes', $this->sys_default_lang, $course_id);\r
247                 }\r
248 \r
249                 $temp_table = new UsersOnlineTable($this->table_prefix, 'users_online', $this->sys_default_lang);\r
250                 if (!$temp_table->convert()){\r
251                         $errors[]= $this->table_prefix.'users_online was not converted.';\r
252                         $_SESSION['redo_conversion'][$course_title]['UsersOnlineTable'] = array($this->table_prefix, 'users_online', $this->sys_default_lang, $course_id);\r
253                 }\r
254         }\r
255 \r
256          /**\r
257           * This function runs through all the table that are class dependent.\r
258           */\r
259          function convertTableByClass($course_title, $char_set, $course_id){\r
260                  global $errors;\r
261                 //Run through all ATutor table and convert only those rows with the above courses.\r
262                 //todo: implement a driver class inside the TableConversion class.\r
263                 $temp_table = new AssignmentsTable($this->table_prefix, 'assignments', $char_set, $course_id);\r
264                 if (!$temp_table->convert()){\r
265                         $errors[]= $course_title.': '.$this->table_prefix.'assignments was not converted.';\r
266                         $_SESSION['redo_conversion'][$course_title]['AssignmentsTable'] = array($this->table_prefix, 'assignments', $char_set, $course_id);\r
267                 }\r
268 \r
269                 $temp_table = new BackupsTable($this->table_prefix, 'backups', $char_set, $course_id);\r
270                 if (!$temp_table->convert()){\r
271                         $errors[]= $course_title.': '.$this->table_prefix.'backups was not converted.';\r
272                         $_SESSION['redo_conversion'][$course_title]['BackupsTable'] = array($this->table_prefix, 'backups', $char_set, $course_id);\r
273                 }\r
274 \r
275                 $temp_table = new BlogPostsTable($this->table_prefix, 'blog_posts', $char_set, $course_id);\r
276                 if (!$temp_table->convert()){\r
277                         $errors[]= $course_title.': '.$this->table_prefix.'blog_posts was not converted.';\r
278                         $_SESSION['redo_conversion'][$course_title]['BlogPostsTable'] = array($this->table_prefix, 'blog_posts', $char_set, $course_id);\r
279                 }\r
280                 \r
281                 $temp_table = new ContentTable($this->table_prefix, 'content', $char_set, $course_id);\r
282                 if (!$temp_table->convert()){\r
283                         $errors[]= $course_title.': '.$this->table_prefix.'content was not converted.';\r
284                         $_SESSION['redo_conversion'][$course_title]['ContentTable'] = array($this->table_prefix, 'content', $char_set, $course_id);\r
285                 }\r
286                 \r
287                 $temp_table = new CoursesTable($this->table_prefix, 'courses', $char_set, $course_id);\r
288                 if (!$temp_table->convert()){\r
289                         $errors[]= $course_title.': '.$this->table_prefix.'courses was not converted.';\r
290                         $_SESSION['redo_conversion'][$course_title]['CoursesTable'] = array($this->table_prefix, 'courses', $char_set, $course_id);\r
291                 }\r
292                 \r
293                 $temp_table = new CourseEnrollmentTable($this->table_prefix, 'course_enrollment', $char_set, $course_id);\r
294                 if (!$temp_table->convert()){\r
295                         $errors[]= $course_title.': '.$this->table_prefix.'course_enrollment was not converted.';\r
296                         $_SESSION['redo_conversion'][$course_title]['CourseEnrollmentTable'] = array($this->table_prefix, 'course_enrollment', $char_set, $course_id);\r
297                 }\r
298 \r
299                 $temp_table = new ExternalResourcesTable($this->table_prefix, 'external_resources', $char_set, $course_id);\r
300                 if (!$temp_table->convert()){\r
301                         $errors[]= $course_title.': '.$this->table_prefix.'external_resources was not converted.';\r
302                         $_SESSION['redo_conversion'][$course_title]['ExternalResourcesTable'] = array($this->table_prefix, 'external_resources', $char_set, $course_id);\r
303                 }\r
304 \r
305                 $temp_table = new FaqTopicsTable($this->table_prefix, 'faq_topics', $char_set, $course_id);\r
306                 if (!$temp_table->convert()){\r
307                         $errors[]= $course_title.': '.$this->table_prefix.'faq_topics was not converted.';\r
308                         $_SESSION['redo_conversion'][$course_title]['FaqTopicsTable'] = array($this->table_prefix, 'faq_topics', $char_set, $course_id);\r
309                 }\r
310                 \r
311                 $temp_table = new FoldersTable($this->table_prefix, 'folders', $char_set, $course_id);\r
312                 if (!$temp_table->convert()){\r
313                         $errors[]= $course_title.': '.$this->table_prefix.'folders was not converted.';\r
314                         $_SESSION['redo_conversion'][$course_title]['FoldersTable'] = array($this->table_prefix, 'folders', $char_set, $course_id);\r
315                 }\r
316 \r
317                 $temp_table = new FilesTable($this->table_prefix, 'files', $char_set, $course_id);\r
318                 if (!$temp_table->convert()){\r
319                         $errors[]= $course_title.': '.$this->table_prefix.'files was not converted.';\r
320                         $_SESSION['redo_conversion'][$course_title]['FilesTable'] = array($this->table_prefix, 'files', $char_set, $course_id);\r
321                 }\r
322                 \r
323                 $temp_table = new ForumsTable($this->table_prefix, 'forums', $char_set, $course_id);\r
324                 if (!$temp_table->convert()){\r
325                         $errors[]= $course_title.': '.$this->table_prefix.'forums was not converted.';\r
326                         $_SESSION['redo_conversion'][$course_title]['ForumsTable'] = array($this->table_prefix, 'forums', $char_set, $course_id);\r
327                 }\r
328 \r
329                 $temp_table = new GlossaryTable($this->table_prefix, 'glossary', $char_set, $course_id);\r
330                 if (!$temp_table->convert()){\r
331                         $errors[]= $course_title.': '.$this->table_prefix.'glossary was not converted.';\r
332                         $_SESSION['redo_conversion'][$course_title]['GlossaryTable'] = array($this->table_prefix, 'glossary', $char_set, $course_id);\r
333                 }\r
334 \r
335                 $temp_table = new GroupsTypesTable($this->table_prefix, 'groups_types', $char_set, $course_id);\r
336                 if (!$temp_table->convert()){\r
337                         $errors[]= $course_title.': '.$this->table_prefix.'groups_types was not converted.';\r
338                         $_SESSION['redo_conversion'][$course_title]['GroupsTypesTable'] = array($this->table_prefix, 'groups_types', $char_set, $course_id);\r
339                 }\r
340 \r
341                 $temp_table = new LinksCategoriesTable($this->table_prefix, 'links_categories', $char_set, $course_id);\r
342                 if (!$temp_table->convert()){\r
343                         $errors[]= $course_title.': '.$this->table_prefix.'links_categories was not converted.';\r
344                         $_SESSION['redo_conversion'][$course_title]['LinksCategoriesTable'] = array($this->table_prefix, 'links_categories', $char_set, $course_id);\r
345                 }\r
346 \r
347                 $temp_table = new MessagesTable($this->table_prefix, 'messages', $char_set, $course_id);\r
348                 if (!$temp_table->convert()){\r
349                         $errors[]= $course_title.': '.$this->table_prefix.'messages was not converted.';\r
350                         $_SESSION['redo_conversion'][$course_title]['MessagesTable'] = array($this->table_prefix, 'messages', $char_set, $course_id);\r
351                 }\r
352 \r
353                 $temp_table = new MessagesSentTable($this->table_prefix, 'messages_sent', $char_set, $course_id);\r
354                 if (!$temp_table->convert()){\r
355                         $errors[]= $course_title.': '.$this->table_prefix.'messages_sent was not converted.';\r
356                         $_SESSION['redo_conversion'][$course_title]['MessagesSentTable'] = array($this->table_prefix, 'messages_sent', $char_set, $course_id);\r
357                 }\r
358 \r
359                 $temp_table = new NewsTable($this->table_prefix, 'news', $char_set, $course_id);\r
360                 if (!$temp_table->convert()){\r
361                         $errors[]= $course_title.': '.$this->table_prefix.'news was not converted.';\r
362                         $_SESSION['redo_conversion'][$course_title]['NewsTable'] = array($this->table_prefix, 'news', $char_set, $course_id);\r
363                 }\r
364 \r
365                 $temp_table = new PollsTable($this->table_prefix, 'polls', $char_set, $course_id);\r
366                 if (!$temp_table->convert()){\r
367                         $errors[]= $course_title.': '.$this->table_prefix.'polls was not converted.';\r
368                         $_SESSION['redo_conversion'][$course_title]['PollsTable'] = array($this->table_prefix, 'polls', $char_set, $course_id);\r
369                 }\r
370 \r
371                 $temp_table = new ReadingListTable($this->table_prefix, 'reading_list', $char_set, $course_id);\r
372                 if (!$temp_table->convert()){\r
373                         $errors[]= $course_title.': '.$this->table_prefix.'reading_list was not converted.';\r
374                         $_SESSION['redo_conversion'][$course_title]['ReadingListTable'] = array($this->table_prefix, 'reading_list', $char_set, $course_id);\r
375                 }\r
376 \r
377                 $temp_table = new TestsTable($this->table_prefix, 'tests', $char_set, $course_id);\r
378                 if (!$temp_table->convert()){\r
379                         $errors[]= $course_title.': '.$this->table_prefix.'tests was not converted.';\r
380                         $_SESSION['redo_conversion'][$course_title]['TestsTable'] = array($this->table_prefix, 'tests', $char_set, $course_id);\r
381                 }\r
382 \r
383                 $temp_table = new TestQuestionsTable($this->table_prefix, 'tests_questions', $char_set, $course_id);\r
384                 if (!$temp_table->convert()){\r
385                         $errors[]= $course_title.': '.$this->table_prefix.'tests_questions was not converted.';\r
386                         $_SESSION['redo_conversion'][$course_title]['TestQuestionsTable'] = array($this->table_prefix, 'tests_questions', $char_set, $course_id);\r
387                 }\r
388 \r
389                 $temp_table = new TestsQuestionsCategoriesTable($this->table_prefix, 'tests_questions_categories', $char_set, $course_id);\r
390                 if (!$temp_table->convert()){\r
391                         $errors[]= $course_title.': '.$this->table_prefix.'tests_questions_categories was not converted.';\r
392                         $_SESSION['redo_conversion'][$course_title]['TestsQuestionsCategoriesTable'] = array($this->table_prefix, 'tests_questions_categories', $char_set, $course_id);\r
393                 }\r
394          }\r
395 \r
396          /**\r
397           * This function runs through all the table that are class dependent.\r
398           * Particular for the tables that haven't been converted during 1.5.5 to 1.6\r
399           */\r
400          function convertTableByClass_161($course_title, $char_set, $course_id){\r
401                  global $errors;\r
402                 //Run through all ATutor table and convert only those rows with the above courses.\r
403                 //todo: implement a driver class inside the TableConversion class.\r
404 /*              $temp_table = new MessagesTable($this->table_prefix, 'messages', $char_set, $course_id);\r
405                 if (!$temp_table->convert()){\r
406                         $errors[]= $course_title.': '.$this->table_prefix.'messages was not converted.';\r
407                         $_SESSION['redo_conversion'][$course_title]['MessagesTable'] = array($this->table_prefix, 'messages', $char_set, $course_id);\r
408                 }\r
409 */\r
410          }\r
411 \r
412          /**\r
413           * This function will alter all table's charset to UTF-8\r
414           */\r
415          function alter_all_charset(){\r
416                  global $errors;\r
417                  $sql = 'SHOW TABLES';\r
418                  $result = mysql_query($sql);\r
419                  if (mysql_numrows($result) > 0) {\r
420                          while ($row = mysql_fetch_array($result)){\r
421                                  $sql = 'ALTER TABLE `'.$row[0].'` CONVERT TO CHARACTER SET utf8';\r
422                                  mysql_query($sql);\r
423                          }\r
424                  }\r
425          }\r
426  }\r
427 \r
428 \r
429 /**\r
430 * This class will handle utf8 conversion on all tables associated with a specific course.\r
431 * This class can be potentially upgraded to a automated table parser to optimize codes, instead of having \r
432 * different abstract classes for each individual table inside ATutor.  \r
433 * Note: Keeping in mind that this class will not be used a lot after 1.6 conversion.  \r
434 * @access                       public\r
435 * @author                       Harris Wong\r
436 * @precondition         MySQL connected, mbstring lib enabled.\r
437 * @date                         Nov 28, 2007\r
438 */\r
439 class ATutorTable{\r
440         /** variables */\r
441         var $table;\r
442         var $table_prefix;\r
443         var $from_encoding;\r
444         var $courseID;\r
445         var $to_encoding;\r
446 \r
447         /**\r
448          * Constructor\r
449          * @param       table prefix\r
450          * @param       table is the table name of which we want to covert\r
451          * @param       from_encoding is the encoding which the content will be converted from.\r
452          * @param       foreign_ID is the primary key/foreign key of the table.  $foreign_ID will be the primary key when\r
453          *                      the table has a "course_id" column, foreign key when it doesn't.  \r
454          *                      foreign_ID is an empty string if this table does not depend on courses, such as members, \r
455          *                      course categories tables.\r
456          */\r
457         function ATutorTable($table_prefix, $table, $from_encoding, $foreign_ID=''){\r
458                 $this->table_prefix = $table_prefix;\r
459                 $this->table = $table;\r
460                 $this->from_encoding = $from_encoding;\r
461                 $this->foreign_ID= $foreign_ID;\r
462                 $this->to_encoding = "UTF-8";\r
463                 //check if mb_string library is enabled, die o/w\r
464                  if (!extension_loaded('mbstring')){\r
465                          die("Please have mbstring library enabled");\r
466                  }\r
467                 \r
468                 //Alter table\r
469                 $this->alterTable();\r
470         }\r
471 \r
472 \r
473         /**\r
474          * alterTable\r
475          * Perform mysql ALTER table function, to switch to UTF-8 tables.\r
476          */\r
477         function alterTable(){\r
478                 $query = 'ALTER TABLE `'.$this->table_prefix.$this->table.'` CONVERT TO CHARACTER SET utf8';\r
479                 mysql_query($query);\r
480         }\r
481 \r
482 \r
483         /**\r
484          * getContent\r
485          * This method will get all the contents from this table with the given courseID.\r
486          * @param courseDependent = false when this table isn't related to course encoding, true if it is related (default)\r
487          * @return      result set, and null on failure or 0 rows\r
488          */\r
489         function getContent($courseDependent = true){\r
490                 if ($courseDependent) {\r
491                         $sql = "SELECT * FROM `".$this->table_prefix.$this->table."` WHERE course_id=".$this->foreign_ID;\r
492                 } else {\r
493                         $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table;\r
494                 }\r
495                 $result = mysql_query($sql);\r
496                 if ($result && mysql_num_rows($result)>0){\r
497                         return $result;\r
498                 }\r
499                 return false;\r
500         }\r
501 \r
502         /**\r
503          * convert\r
504          * Abstract class that convert the table contents to UTF8\r
505          * @return mysql_query's return object\r
506          */\r
507         function convert(){/* Abstract */}\r
508         \r
509         \r
510         /**\r
511          * executeSQL\r
512          * This runs the sql statement\r
513          * @param value_array contains all the new values mapped by their column names\r
514          * @param primary_key is the primary key of this table.\r
515          */\r
516         function generate_sql($value_array, $primary_key_col, $primary_key){\r
517                 $sql = "UPDATE `".$this->table_prefix.$this->table."` SET ";\r
518                 $i = 1;\r
519                 foreach($value_array as $column_name=>$column_value){\r
520                         $column_value = mysql_real_escape_string($column_value);\r
521                         $column_name = mysql_real_escape_string($column_name);\r
522                         $sql .= "`$column_name`='$column_value'";\r
523                         if ($i < sizeof($value_array)) {\r
524                                 $sql .= ', ';\r
525                         }\r
526                         $i++;\r
527                 }\r
528                 //If there are more than 1 key\r
529                 if (is_array($primary_key_col)){\r
530                         $j = 1;\r
531                         $sql .= " WHERE ";\r
532                         foreach ($primary_key_col as $k=>$v){\r
533                                 $v = mysql_real_escape_string($v);\r
534                                 $sql .= $v.'='.$primary_key[$k];\r
535                                 if ($j < sizeof($primary_key_col)){\r
536                                         $sql .= " AND ";\r
537                                 }\r
538                                 $j++;\r
539                         }\r
540                 } else {\r
541                         $sql .= " WHERE `$primary_key_col`=";\r
542                         if (preg_match('/^[0-9]+$/', $primary_key)==1){\r
543                                 $sql .= $primary_key;\r
544                         } else {\r
545                                 //prim key is a string, put it around a pair of quotes\r
546                                 $sql .= "'$primary_key'";\r
547                         }\r
548                 }\r
549 //              echo "<hr/>";\r
550                 return $sql;\r
551         }\r
552 }\r
553 \r
554 \r
555 /**\r
556  * Class for Admins\r
557  * Default language iso-8859-1.\r
558  * Note: This class is independent from courses\r
559  */\r
560 class AdminsTable extends ATutorTable{\r
561         function convert(){\r
562                 $rs = $this->getContent(false);\r
563                 $result = true;\r
564                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
565                         //Store the key for updating purposes.\r
566                         $key_col = 'login';\r
567                         //Convert all neccessary entries\r
568                         $value_array['real_name'] = mb_convert_encoding($row['real_name'], $this->to_encoding, $this->from_encoding);\r
569                         //Generate SQL\r
570                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
571                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
572                         echo mysql_error();\r
573                 }\r
574                 return $result;\r
575         }\r
576 }\r
577 \r
578 /**\r
579  * Class for AdminLog\r
580  * Default language iso-8859-1.\r
581  * Note: This class is independent from courses\r
582  */\r
583 class AdminLogTable extends ATutorTable{\r
584         function convert(){\r
585                 $rs = $this->getContent(false);\r
586                 $result = true;\r
587                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
588                         //Store the key for updating purposes.\r
589                         $key_col = 'time';\r
590                         //Convert all neccessary entries\r
591                         $value_array['operation'] = mb_convert_encoding($row['operation'], $this->to_encoding, $this->from_encoding);\r
592                         $value_array['table'] = mb_convert_encoding($row['table'], $this->to_encoding, $this->from_encoding);\r
593                         $value_array['details'] = mb_convert_encoding($row['details'], $this->to_encoding, $this->from_encoding);\r
594                         //Generate SQL\r
595                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
596                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
597                 }\r
598                 return $result;\r
599         }\r
600 }\r
601 \r
602 /** \r
603  * Class for Assignments\r
604  */\r
605 class AssignmentsTable extends ATutorTable{\r
606         function convert(){\r
607                 $rs = $this->getContent();\r
608                 $result = true;\r
609                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
610                         //Store the key for updating purposes.\r
611                         $key_col = 'assignment_id';\r
612                         //Convert all neccessary entries\r
613                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
614 \r
615                         //Convert Folders table, that is related to assignments.\r
616                         $folders = new FoldersTable($this->table_prefix, 'folders', $this->from_encoding, $row[$key_col]);\r
617                         $result &= $folders->convert(WORKSPACE_ASSIGNMENT);\r
618                         //Convert Files table, that is related to assignments.\r
619                         $files_table = new FilesTable($this->table_prefix, 'files', $this->from_encoding, $row[$key_col]);\r
620                         $result &= $files_table->convert(WORKSPACE_ASSIGNMENT);\r
621 \r
622                         //Generate SQL\r
623                         //echo (mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]))) ;\r
624                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
625                 } \r
626                 //Needs to alter related tables\r
627                 if (!$rs) {                     \r
628                         new FoldersTable($this->table_prefix, 'folders', '');\r
629                         new FilesTable($this->table_prefix, 'files', '');\r
630                 }\r
631                 return $result;\r
632         }\r
633 }\r
634 \r
635 /**\r
636  * Class for auto_enroll\r
637  * Default language iso-8859-1.\r
638  * Note: This class is independent from courses\r
639  */\r
640 class AutoEnrollTable extends ATutorTable{\r
641         function convert(){\r
642                 $rs = $this->getContent(false);\r
643                 $result = true;\r
644                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
645                         //Store the key for updating purposes.\r
646                         $key_col = 'auto_enroll_id';\r
647                         //Convert all neccessary entries\r
648                         $value_array['associate_string'] = mb_convert_encoding($row['associate_string'], $this->to_encoding, $this->from_encoding);\r
649                         $value_array['name'] = mb_convert_encoding($row['name'], $this->to_encoding, $this->from_encoding);\r
650 \r
651                         //Generate SQL\r
652                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
653                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
654                 }\r
655                 return $result;\r
656         }\r
657 }\r
658 \r
659 /**\r
660  * Class for auto_enroll_courses\r
661  * Default language iso-8859-1.\r
662  * Note: This class is independent from courses\r
663  */\r
664 class AutoEnrollCoursesTable extends ATutorTable{\r
665         //Nothing to convert in this table except the table structure.\r
666         function convert(){\r
667                 return true;\r
668         }\r
669 }\r
670 \r
671 \r
672 /** \r
673  * Class for Backups\r
674  */\r
675 class BackupsTable extends ATutorTable{\r
676         function convert(){\r
677                 $rs = $this->getContent();\r
678                 $result = true;\r
679                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
680                         //Store the key for updating purposes.\r
681                         $key_col = 'backup_id';\r
682                         //Convert all neccessary entries\r
683                         $value_array['date'] = $row['date'];\r
684                         $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);\r
685                         $value_array['system_file_name'] = mb_convert_encoding($row['system_file_name'], $this->to_encoding, $this->from_encoding);\r
686                         $value_array['file_name'] = mb_convert_encoding($row['file_name'], $this->to_encoding, $this->from_encoding);\r
687                         $value_array['contents'] = mb_convert_encoding($row['contents'], $this->to_encoding, $this->from_encoding);\r
688                         //Generate SQL\r
689                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
690                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
691                 }\r
692                 return $result;\r
693         }\r
694 }\r
695 \r
696 /** \r
697  * Class for Blog posts\r
698  */\r
699 class BlogPostsTable extends ATutorTable{\r
700         function convert(){\r
701                 $rs = $this->getContent();\r
702                 $result = true;\r
703                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
704                         //Store the key for updating purposes.\r
705                         $key_col = 'post_id';\r
706                         //Convert all neccessary entries\r
707                         $value_array['date'] = $row['date'];\r
708                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
709                         $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);\r
710                         //Convert sub post comment.\r
711                         $commentPosts = new BlogPostsCommentsTable($this->table_prefix, 'blog_posts_comments', $this->from_encoding, $row[$key_col]);\r
712                         $result &= $commentPosts->convert();\r
713                         //Generate SQL\r
714                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
715                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
716                 }\r
717                 //Needs to alter related tables\r
718                 if (!$rs) {                     \r
719                         new BlogPostsCommentsTable($this->table_prefix, 'blog_posts_comments', '');\r
720                 }\r
721                 return $result;\r
722         }\r
723 }\r
724 \r
725 /** \r
726  * Class for Blog posts comments\r
727  * Used only by BlogPostsTable\r
728  * Foreign key = post_id\r
729  */\r
730 class BlogPostsCommentsTable extends ATutorTable{\r
731         //Overrider\r
732         function getContent(){\r
733                 $sql = "SELECT * FROM `".$this->table_prefix.$this->table."` WHERE post_id=".$this->foreign_ID;\r
734                 $result = mysql_query($sql);\r
735                 if ($result && mysql_num_rows($result)>0){\r
736                         return $result;\r
737                 }\r
738                 return false;\r
739         }\r
740 \r
741         function convert(){\r
742                 $rs = $this->getContent();\r
743                 $result = true;\r
744                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
745                         //Store the key for updating purposes.\r
746                         $key_col = 'comment_id';\r
747                         //Convert all neccessary entries\r
748                         $value_array['date'] = $row['date'];\r
749                         $value_array['text'] = mb_convert_encoding($row['text'], $this->to_encoding, $this->from_encoding);\r
750                         //Generate SQL\r
751                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
752                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
753                 }\r
754                 return $result;\r
755         }\r
756 }\r
757 \r
758 /**\r
759  * Class for config\r
760  * Default language iso-8859-1.\r
761  * Note: This class is independent from courses\r
762  */\r
763 class ConfigTable extends ATutorTable{\r
764         function convert(){\r
765                 //nothing to convert\r
766                 return true;\r
767         }\r
768 }\r
769 \r
770 /**\r
771  * Class for course_access\r
772  * Default language iso-8859-1.\r
773  * Note: This class is independent from courses\r
774  */\r
775 class CourseAccessTable extends ATutorTable{\r
776         function convert(){\r
777                 //nothing to convert\r
778                 return true;\r
779         }\r
780 }\r
781 \r
782 /**\r
783  * Class for course_stats\r
784  * Default language iso-8859-1.\r
785  * Note: This class is independent from courses\r
786  */\r
787 class CourseStatsTable extends ATutorTable{\r
788         function convert(){\r
789                 //nothing to convert\r
790                 return true;\r
791         }\r
792 }\r
793 \r
794 /**\r
795  * Class for Content\r
796  */\r
797 class ContentTable extends ATutorTable{\r
798         function convert(){\r
799                 $rs = $this->getContent();\r
800                 $result = true;\r
801                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
802                         //Store the key for updating purposes.\r
803                         $key_col = 'content_id';\r
804                         //Convert all neccessary entries\r
805                         $value_array['last_modified'] = $row['last_modified'];\r
806                         $value_array['keywords'] = mb_convert_encoding($row['keywords'], $this->to_encoding, $this->from_encoding);\r
807                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
808                         $value_array['text'] = mb_convert_encoding($row['text'], $this->to_encoding, $this->from_encoding);\r
809                         //Generate SQL\r
810                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
811                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
812                 }\r
813                 return $result;\r
814         }\r
815 }\r
816 \r
817 \r
818 /**\r
819  * Class for Courses\r
820  */\r
821 class CoursesTable extends ATutorTable{\r
822         function convert(){\r
823                 $rs = $this->getContent();\r
824                 $result = true;\r
825                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
826                         //Store the key for updating purposes.\r
827                         $key_col = 'course_id';\r
828                         //Convert all neccessary entries\r
829                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
830                         $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);\r
831 //                      $value_array['preferences'] = mb_convert_encoding($row['preferences'], $this->to_encoding, $this->from_encoding);\r
832                         $value_array['copyright'] = mb_convert_encoding($row['copyright'], $this->to_encoding, $this->from_encoding);\r
833                         $value_array['banner'] = mb_convert_encoding($row['banner'], $this->to_encoding, $this->from_encoding);\r
834                         /* The following should not needed to be converted after they are deprecated */\r
835 //                      $value_array['header'] = mb_convert_encoding($row['header'], $this->to_encoding, $this->from_encoding);\r
836 //                      $value_array['footer'] = mb_convert_encoding($row['footer'], $this->to_encoding, $this->from_encoding);                 \r
837 //                      $value_array['banner_text'] = mb_convert_encoding($row['banner_text'], $this->to_encoding, $this->from_encoding);\r
838 //                      $value_array['banner_styles'] = mb_convert_encoding($row['banner_styles'], $this->to_encoding, $this->from_encoding);                   \r
839 \r
840                         //Generate SQL\r
841 //                      echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
842                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
843                 }\r
844                 return $result;\r
845         }\r
846 }\r
847 \r
848 \r
849 /**\r
850  * Class for Courses enrollment\r
851  */\r
852 class CourseEnrollmentTable extends ATutorTable{\r
853         function convert(){\r
854                 $rs = $this->getContent();\r
855                 $result = true;\r
856                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
857                         //Store the key for updating purposes.\r
858                         $key_col = 'course_id';\r
859                         $key_col2 = 'member_id';\r
860                         //Convert all neccessary entries\r
861                         $value_array['role'] = mb_convert_encoding($row['role'], $this->to_encoding, $this->from_encoding);\r
862                         //Generate SQL\r
863                         //echo $this->generate_sql($value_array, array($key_col, $key_col2), array($row[$key_col], $row[$key_col2]));\r
864                         $result &= mysql_query($this->generate_sql($value_array, array($key_col, $key_col2), array($row[$key_col], $row[$key_col2])));\r
865                 }\r
866                 return $result;\r
867         }\r
868 }\r
869 \r
870 \r
871 /**\r
872  * Class for Course Categories\r
873  * Course Categories are created by admins, the language encoding should be based on\r
874  * the admin's language setting for >= 1.5.1\r
875  * Otherwise, default it to iso-8859-1.\r
876  * Note: This class is independent from courses\r
877  */\r
878 class CourseCategoriesTable extends ATutorTable{\r
879         function convert(){\r
880                 $rs = $this->getContent(false);\r
881                 $result = true;\r
882                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
883                         //Store the key for updating purposes.\r
884                         $key_col = 'cat_id';\r
885                         //Convert all neccessary entries\r
886                         $value_array['cat_name'] = mb_convert_encoding($row['cat_name'], $this->to_encoding, $this->from_encoding);\r
887                         //Generate SQL\r
888                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
889                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
890                 }\r
891                 return $result;\r
892         }\r
893 }\r
894 \r
895 \r
896 /**\r
897  * Class for External resources\r
898  */\r
899 class ExternalResourcesTable extends ATutorTable{\r
900         function convert(){\r
901                 $rs = $this->getContent();\r
902                 $result = true;\r
903                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
904                         //Store the key for updating purposes.\r
905                         $key_col = 'resource_id';\r
906                         //Convert all neccessary entries\r
907                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
908                         $value_array['author'] = mb_convert_encoding($row['author'], $this->to_encoding, $this->from_encoding);\r
909                         $value_array['publisher'] = mb_convert_encoding($row['publisher'], $this->to_encoding, $this->from_encoding);\r
910                         $value_array['comments'] = mb_convert_encoding($row['comments'], $this->to_encoding, $this->from_encoding);\r
911                         //Generate SQL\r
912                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
913                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
914                 }\r
915                 return $result;\r
916         }\r
917 }\r
918 \r
919 \r
920 /**\r
921  * Class for Faq topics\r
922  */\r
923 class FaqTopicsTable extends ATutorTable{\r
924         function convert(){\r
925                 $rs = $this->getContent();\r
926                 $result = true;\r
927                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
928                         //Store the key for updating purposes.\r
929                         $key_col = 'topic_id';\r
930                         //Convert all neccessary entries\r
931                         $value_array['name'] = mb_convert_encoding($row['name'], $this->to_encoding, $this->from_encoding);\r
932                         //Convert faq entries\r
933                         $faqEntries = new FaqEntriesTable($this->table_prefix, 'faq_entries', $this->from_encoding, $row[$key_col]);\r
934                         $faqEntries->convert();\r
935                         //Generate SQL\r
936                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
937                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
938                 }\r
939                 //Needs to alter related tables\r
940                 if (!$rs) {                     \r
941                         new FaqEntriesTable($this->table_prefix, 'faq_entries', '');\r
942                 }\r
943                 return $result;\r
944         }\r
945 }\r
946 \r
947 /**\r
948  * Class for Faq Entries \r
949  * Used only by FaqTopicsTable\r
950  * Foreign key = topic_id\r
951  */\r
952 class FaqEntriesTable extends ATutorTable{\r
953         //Overrider\r
954         function getContent(){\r
955                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE topic_id='.$this->foreign_ID;\r
956                 $result = mysql_query($sql);\r
957                 if ($result && mysql_num_rows($result)>0){\r
958                         return $result;\r
959                 }\r
960                 return false;\r
961         }\r
962 \r
963         function convert(){\r
964                 $rs = $this->getContent();\r
965                 $result = true;\r
966                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
967                         //Store the key for updating purposes.\r
968                         $key_col = 'entry_id';\r
969                         //Convert all neccessary entries\r
970                         $value_array['revised_date'] = $row['revised_date'];\r
971                         $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);\r
972                         $value_array['answer'] = mb_convert_encoding($row['answer'], $this->to_encoding, $this->from_encoding);\r
973                         //Generate SQL\r
974                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
975                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
976                 }\r
977                 return $result;\r
978         }\r
979 }\r
980 \r
981 \r
982 /**\r
983  * Class for feeds\r
984  * Default language iso-8859-1.\r
985  * Note: This class is independent from courses\r
986  */\r
987 class FeedsTable extends ATutorTable{\r
988         function convert(){\r
989                 $rs = $this->getContent(false);\r
990                 $result = true;\r
991                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
992                         //Store the key for updating purposes.\r
993                         $key_col = 'feed_id';\r
994                         //Convert all neccessary entries\r
995                         $value_array['url'] = mb_convert_encoding($row['url'], $this->to_encoding, $this->from_encoding);\r
996 \r
997                         //Generate SQL\r
998                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
999                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1000                 }\r
1001                 return $result;\r
1002         }\r
1003 }\r
1004 \r
1005 /**\r
1006  * Class for Forums \r
1007  */\r
1008 class ForumsTable extends ATutorTable{\r
1009         //Overrider\r
1010         function getContent(){\r
1011                 $sql = 'SELECT this_forum.* FROM `'.$this->table_prefix.$this->table.'` this_forum NATURAL JOIN `'.$this->table_prefix.'forums_courses` this_course WHERE this_course.course_id='.$this->foreign_ID;\r
1012                 $result = mysql_query($sql);\r
1013                 if ($result && mysql_num_rows($result)>0){\r
1014                         return $result;\r
1015                 }\r
1016                 return false;\r
1017         }\r
1018 \r
1019         function convert(){\r
1020                 $rs = $this->getContent();\r
1021                 $result = true;\r
1022                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1023                         //Store the key for updating purposes.\r
1024                         $key_col = 'forum_id';\r
1025                         //Convert all neccessary entries\r
1026                         $value_array['last_post'] = $row['last_post'];\r
1027                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
1028                         $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);\r
1029                         //Convert faq entries\r
1030                         $forumThread= new ForumsThreadsTable($this->table_prefix, 'forums_threads', $this->from_encoding, $row[$key_col]);\r
1031                         $result &= $forumThread->convert();\r
1032                         //Generate SQL\r
1033                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1034                         $result = mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1035                 }\r
1036                 //Needs to alter related tables\r
1037                 if (!$rs) {                     \r
1038                         new ForumsThreadsTable($this->table_prefix, 'forums_threads', '');\r
1039                 }\r
1040                 return $result;\r
1041         }\r
1042 }\r
1043 \r
1044 /**\r
1045  * Class for forums_accessed\r
1046  * Default language iso-8859-1.\r
1047  * Note: This class is independent from courses\r
1048  */\r
1049 class ForumsAccessedTable extends ATutorTable{\r
1050         function convert(){\r
1051                 //nothing to convert\r
1052                 return true;\r
1053         }\r
1054 }\r
1055 \r
1056 /**\r
1057  * Class for forums_courses\r
1058  * Default language iso-8859-1.\r
1059  * Note: This class is independent from courses\r
1060  */\r
1061 class ForumsCoursesTable extends ATutorTable{\r
1062         function convert(){\r
1063                 //nothing to convert\r
1064                 return true;\r
1065         }\r
1066 }\r
1067 \r
1068 /**\r
1069  * Class for forums_groups\r
1070  * Default language iso-8859-1.\r
1071  * Note: This class is independent from courses\r
1072  */\r
1073 class ForumsGroupsTable extends ATutorTable{\r
1074         function convert(){\r
1075                 //nothing to convert\r
1076                 return true;\r
1077         }\r
1078 }\r
1079 \r
1080 /**\r
1081  * Class for forums_subscriptions\r
1082  * Default language iso-8859-1.\r
1083  * Note: This class is independent from courses\r
1084  */\r
1085 class ForumsSubscriptionsTable extends ATutorTable{\r
1086         function convert(){\r
1087                 //nothing to convert\r
1088                 return true;\r
1089         }\r
1090 }\r
1091 \r
1092 /**\r
1093  * Class for Forums threads\r
1094  * Used only by ForumsTable\r
1095  * Foreign key = forum_id\r
1096  */\r
1097 class ForumsThreadsTable extends ATutorTable{\r
1098         //Overrider\r
1099         function getContent(){\r
1100                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE forum_id='.$this->foreign_ID;\r
1101                 $result = mysql_query($sql);\r
1102                 if ($result && mysql_num_rows($result)>0){\r
1103                         return $result;\r
1104                 }\r
1105                 return false;\r
1106         }\r
1107 \r
1108         function convert(){\r
1109                 $rs = $this->getContent();\r
1110                 $result = true;\r
1111                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1112                         //Store the key for updating purposes.\r
1113                         $key_col = 'post_id';\r
1114                         //Convert all neccessary entries\r
1115                         $value_array['last_comment'] = $row['last_comment'];\r
1116                         $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);\r
1117                         $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);\r
1118                         //Generate SQL\r
1119                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1120                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1121                 }\r
1122                 return $result;\r
1123         }\r
1124 }\r
1125 \r
1126 \r
1127 /**\r
1128  * Class for Folders\r
1129  * Associated with Groups, Links\r
1130  */\r
1131  class FoldersTable extends ATutorTable{\r
1132         /*\r
1133          * Overrider\r
1134          * owner_id means category_id, owner_type refers to the different link type defined in the constants.inc.php.\r
1135          * @param       $owner_type are defined by the constances, which are course, groups, self\r
1136          */\r
1137         function getContent($owner_type){\r
1138                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE owner_type='.$owner_type.' AND owner_id='.$this->foreign_ID;\r
1139                 $result = mysql_query($sql);\r
1140                 if ($result && mysql_num_rows($result)>0){\r
1141                         return $result;\r
1142                 }\r
1143                 return false;\r
1144         }\r
1145 \r
1146         /*\r
1147          * @param       $owner_type are defined by the constances, which are course, groups, self; defaulted to be WORKSPACE_COURSE\r
1148          */\r
1149         function convert($owner_type=WORKSPACE_COURSE){\r
1150                 $rs = $this->getContent($owner_type);\r
1151                 $result = true;\r
1152                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1153                         //Store the key for updating purposes.\r
1154                         $key_col = 'folder_id';\r
1155                         //Convert all neccessary entries\r
1156                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
1157                         //Generate SQL\r
1158                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1159                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1160                 }\r
1161                 return $result;\r
1162         }\r
1163  }\r
1164 \r
1165 /**\r
1166  * Class for Files\r
1167  * Associated with Groups, Links\r
1168  */\r
1169  class FilesTable extends ATutorTable{\r
1170         /*\r
1171          * Overrider\r
1172          * owner_id means category_id, owner_type refers to the different link type defined in the constants.inc.php.\r
1173          * @param       $owner_type are defined by the constances, which are course, groups, self\r
1174          */\r
1175         function getContent($owner_type){\r
1176                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE owner_type='.$owner_type.' AND owner_id='.$this->foreign_ID;\r
1177                 $result = mysql_query($sql);\r
1178                 if ($result && mysql_num_rows($result)>0){\r
1179                         return $result;\r
1180                 }\r
1181                 return false;\r
1182         }\r
1183 \r
1184         /*\r
1185          * @param       $owner_type are defined by the constances, which are course, groups, self; defaulted to be WORKSPACE_COURSE\r
1186          */\r
1187         function convert($owner_type=WORKSPACE_COURSE){\r
1188                 $rs = $this->getContent($owner_type);\r
1189                 $result = true;\r
1190                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1191                         //Store the key for updating purposes.\r
1192                         $key_col = 'file_id';\r
1193                         //Convert all neccessary entries\r
1194                         $value_array['date'] = $row['date'];\r
1195                         $value_array['file_name'] = mb_convert_encoding($row['file_name'], $this->to_encoding, $this->from_encoding);\r
1196                         $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);\r
1197                         //Convert faq entries\r
1198                         $filesComments= new FilesCommentsTable($this->table_prefix, 'files_comments', $this->from_encoding, $row[$key_col]);\r
1199                         $result &= $filesComments->convert();\r
1200                         //Generate SQL\r
1201                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1202                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1203                 }\r
1204                 //Needs to alter related tables\r
1205                 if (!$rs) {                     \r
1206                         new FilesCommentsTable($this->table_prefix, 'files_comments', '');\r
1207                 }\r
1208                 return $result;\r
1209         }\r
1210  }\r
1211 \r
1212 \r
1213 /**\r
1214  * Class for Files comments \r
1215  * Used only by FilesTable\r
1216  * Foreign key = file_id\r
1217  */\r
1218 class FilesCommentsTable extends ATutorTable{\r
1219         //Overrider\r
1220         function getContent(){\r
1221                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE file_id='.$this->foreign_ID;\r
1222                 $result = mysql_query($sql);\r
1223                 if ($result && mysql_num_rows($result)>0){\r
1224                         return $result;\r
1225                 }\r
1226                 return false;\r
1227         }\r
1228 \r
1229         function convert(){\r
1230                 $rs = $this->getContent();\r
1231                 $result = true;\r
1232                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1233                         //Store the key for updating purposes.\r
1234                         $key_col = 'comment_id';\r
1235                         //Convert all neccessary entries\r
1236                         $value_array['date'] = $row['date'];\r
1237                         $value_array['comment'] = mb_convert_encoding($row['comment'], $this->to_encoding, $this->from_encoding);\r
1238                         //Generate SQL\r
1239                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1240                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1241                 }\r
1242                 return $result;\r
1243         }\r
1244 }\r
1245 \r
1246 /**\r
1247  * Class for file_storage_groups\r
1248  * Default language iso-8859-1.\r
1249  * Note: This class is independent from courses\r
1250  */\r
1251 class FileStorageGroupsTable extends ATutorTable{\r
1252         function convert(){\r
1253                 //nothing to convert\r
1254                 return true;\r
1255         }\r
1256 }\r
1257 \r
1258 /**\r
1259  * Class for Glossary \r
1260  */\r
1261 class GlossaryTable extends ATutorTable{\r
1262         function convert(){\r
1263                 $rs = $this->getContent();\r
1264                 $result = true;\r
1265                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1266                         //Store the key for updating purposes.\r
1267                         $key_col = 'word_id';\r
1268                         //Convert all neccessary entries\r
1269                         $value_array['word'] = mb_convert_encoding($row['word'], $this->to_encoding, $this->from_encoding);\r
1270                         $value_array['definition'] = mb_convert_encoding($row['definition'], $this->to_encoding, $this->from_encoding);\r
1271                         //Generate SQL\r
1272                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1273                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1274                 }\r
1275                 return $result;\r
1276         }\r
1277 }\r
1278 \r
1279 \r
1280 /**\r
1281  * Class for Group types\r
1282  */\r
1283 class GroupsTypesTable extends ATutorTable{\r
1284         function convert(){\r
1285                 $rs = $this->getContent();\r
1286                 $result = true;\r
1287                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1288                         //Store the key for updating purposes.\r
1289                         $key_col = 'type_id';\r
1290                         //Convert all neccessary entries\r
1291                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
1292                         \r
1293                         //Convert group table\r
1294                         $groups = new GroupsTable($this->table_prefix, 'groups', $this->from_encoding, $row[$key_col]);\r
1295                         $result &= $groups->convert();\r
1296                         //Convert links table, that has owner_type=group\r
1297                         $linkscats = new LinksCategoriesTable($this->table_prefix, 'links_categories', $this->from_encoding, $row[$key_col]);\r
1298                         $result &= $linkscats->convert(LINK_CAT_GROUP);\r
1299                         //Convert folder tables, that has owner_type=group\r
1300                         $folders = new FoldersTable($this->table_prefix, 'folders', $this->from_encoding, $row[$key_col]);\r
1301                         $result &= $folders->convert(WORKSPACE_GROUP);\r
1302                         //Convert file tables, that has owner_type=group\r
1303                         $files_table = new FilesTable($this->table_prefix, 'files', $this->from_encoding, $row[$key_col]);\r
1304                         $result &= $files_table->convert(WORKSPACE_GROUP);\r
1305 \r
1306                         //Generate SQL\r
1307                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1308                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1309                 }\r
1310                 //Needs to alter related tables\r
1311                 if (!$rs) {                     \r
1312                         new GroupsTable($this->table_prefix, 'groups', '');\r
1313                         new LinksCategoriesTable($this->table_prefix, 'links_categories', '');\r
1314                         new FoldersTable($this->table_prefix, 'folders', '');\r
1315                         new FilesTable($this->table_prefix, 'files', '');\r
1316                 }\r
1317                 return $result;\r
1318         }\r
1319 }\r
1320 \r
1321 /**\r
1322  * Class for Groups\r
1323  * Used only by GroupTypesTable\r
1324  * Foreign key = type_id\r
1325  */\r
1326 class GroupsTable extends ATutorTable{\r
1327         //Overrider\r
1328         function getContent(){\r
1329                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE type_id='.$this->foreign_ID;\r
1330                 $result = mysql_query($sql);\r
1331                 if ($result && mysql_num_rows($result)>0){\r
1332                         return $result;\r
1333                 }\r
1334                 return false;\r
1335         }\r
1336 \r
1337         function convert(){\r
1338                 $rs = $this->getContent();\r
1339                 $result = true;\r
1340                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1341                         //Store the key for updating purposes.\r
1342                         $key_col = 'group_id';\r
1343                         //Convert all neccessary entries\r
1344                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
1345                         $value_array['description'] = mb_convert_encoding($row['description'], $this->to_encoding, $this->from_encoding);\r
1346                         //Generate SQL\r
1347                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1348                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1349                 }\r
1350                 return $result;\r
1351         }\r
1352 }\r
1353 \r
1354 /**\r
1355  * Class for groups_members\r
1356  * Default language iso-8859-1.\r
1357  * Note: This class is independent from courses\r
1358  */\r
1359 class GroupsMembersTable extends ATutorTable{\r
1360         function convert(){\r
1361                 //nothing to convert\r
1362                 return true;\r
1363         }\r
1364 }\r
1365 \r
1366 /**\r
1367  * Class for handbooks_notes\r
1368  * Default language iso-8859-1.\r
1369  * Note: This class is independent from courses\r
1370  */\r
1371 class HandbookNotesTable extends ATutorTable{\r
1372         function convert(){\r
1373                 $rs = $this->getContent(false);\r
1374                 $result = true;\r
1375                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1376                         //Store the key for updating purposes.\r
1377                         $key_col = 'note_id';\r
1378                         //Convert all neccessary entries\r
1379                         $value_array['section'] = mb_convert_encoding($row['section'], $this->to_encoding, $this->from_encoding);\r
1380                         $value_array['page'] = mb_convert_encoding($row['page'], $this->to_encoding, $this->from_encoding);\r
1381                         $value_array['note'] = mb_convert_encoding($row['note'], $this->to_encoding, $this->from_encoding);\r
1382                         //Generate SQL\r
1383                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1384                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1385                 }\r
1386                 return $result;\r
1387         }\r
1388 }\r
1389 \r
1390 /**\r
1391  * Class for instructor_approvals\r
1392  * Default language iso-8859-1.\r
1393  * Note: This class is independent from courses\r
1394  */\r
1395 class InstructorApprovalsTable extends ATutorTable{\r
1396         function convert(){\r
1397                 $rs = $this->getContent(false);\r
1398                 $result = true;\r
1399                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1400                         //Store the key for updating purposes.\r
1401                         $key_col = 'member_id';\r
1402                         //Convert all neccessary entries\r
1403                         $value_array['notes'] = mb_convert_encoding($row['notes'], $this->to_encoding, $this->from_encoding);\r
1404                         //Generate SQL\r
1405                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1406                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1407                 }\r
1408                 return $result;\r
1409         }\r
1410 }\r
1411 \r
1412 /**\r
1413  * Class for lanaguages\r
1414  * Default language iso-8859-1.\r
1415  * Note: This class is independent from courses\r
1416  */\r
1417 class LanguagesTable extends ATutorTable{\r
1418         function convert(){\r
1419                 //will only have english language remains.\r
1420                 return true;\r
1421         }\r
1422 }\r
1423 \r
1424 /**\r
1425  * Class for lanaguage_pages\r
1426  * Default language iso-8859-1.\r
1427  * Note: This class is independent from courses\r
1428  */\r
1429 class LanguagePagesTable extends ATutorTable{\r
1430         function convert(){\r
1431                 //will only have iso88591, which is in ascii\r
1432                 return true;\r
1433         }\r
1434 }\r
1435 \r
1436 /**\r
1437  * Class for language_text\r
1438  * Default language iso-8859-1.\r
1439  * Note: This class is independent from courses\r
1440  */\r
1441 class LanguageTextTable extends ATutorTable{\r
1442         function convert(){\r
1443                 //will only have iso88591, which is in ascii\r
1444                 return true;\r
1445         }\r
1446 }\r
1447 \r
1448 /**\r
1449  * Class for Links Categories\r
1450  * Links' owner_id can be of courses, groups, self.\r
1451  */\r
1452 class LinksCategoriesTable extends ATutorTable{\r
1453         /*\r
1454          * Overrider\r
1455          * owner_id means category_id, owner_type refers to the different link type defined in the constants.inc.php.\r
1456          * @param       $owner_type are defined by the constances\r
1457          */\r
1458         function getContent($owner_type){\r
1459                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE owner_type='.$owner_type.' AND owner_id='.$this->foreign_ID;\r
1460                 $result = mysql_query($sql);\r
1461                 if ($result && mysql_num_rows($result)>0){\r
1462                         return $result;\r
1463                 }\r
1464                 return false;\r
1465         }\r
1466 \r
1467         /*\r
1468          * @param       $owner_type are defined by the constances, which are course, groups, self; defaulted to be LINK_CAT_COURSE\r
1469          */\r
1470         function convert($owner_type=LINK_CAT_COURSE){\r
1471                 $rs = $this->getContent($owner_type);\r
1472                 $result = true;\r
1473                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1474                         //Store the key for updating purposes.\r
1475                         $key_col = 'cat_id';\r
1476                         //Convert all neccessary entries\r
1477                         $value_array['name'] = mb_convert_encoding($row['name'], $this->to_encoding, $this->from_encoding);\r
1478                         //Convert links table\r
1479                         $linkscats = new LinksTable($this->table_prefix, 'links', $this->from_encoding, $row[$key_col]);\r
1480                         $result &= $linkscats->convert();\r
1481                         //Generate SQL\r
1482                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1483                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1484                 }\r
1485                 //Needs to alter related tables\r
1486                 if (!$rs) {                     \r
1487                         new LinksTable($this->table_prefix, 'links', '');\r
1488                 }\r
1489                 return $result;\r
1490         }\r
1491 }\r
1492 \r
1493 /**\r
1494  * Class for Links\r
1495  * Used only by LinksCategoriesTable\r
1496  * Foreign key = cat_id\r
1497  */\r
1498  class LinksTable extends ATutorTable{\r
1499         //Overrider\r
1500         function getContent(){\r
1501                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE cat_id='.$this->foreign_ID;\r
1502                 $result = mysql_query($sql);\r
1503                 if ($result && mysql_num_rows($result)>0){\r
1504                         return $result;\r
1505                 }\r
1506                 return false;\r
1507         }\r
1508 \r
1509         function convert(){\r
1510                 $rs = $this->getContent();\r
1511                 $result = true;\r
1512                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1513                         //Store the key for updating purposes.\r
1514                         $key_col = 'link_id';\r
1515                         //Convert all neccessary entries\r
1516                         $value_array['LinkName'] = mb_convert_encoding($row['LinkName'], $this->to_encoding, $this->from_encoding);\r
1517                         $value_array['Description'] = mb_convert_encoding($row['Description'], $this->to_encoding, $this->from_encoding);\r
1518                         $value_array['SubmitName'] = mb_convert_encoding($row['SubmitName'], $this->to_encoding, $this->from_encoding);\r
1519                         //Generate SQL\r
1520                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1521                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1522                 }\r
1523                 return $result;\r
1524         }\r
1525  }\r
1526 \r
1527 /**\r
1528  * Class for mail_queue\r
1529  * Default language iso-8859-1.\r
1530  * Note: This class is independent from courses\r
1531  */\r
1532 class MailQueueTable extends ATutorTable{\r
1533         function convert(){\r
1534                 $rs = $this->getContent(false);\r
1535                 $result = true;\r
1536                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1537                         //Store the key for updating purposes.\r
1538                         $key_col = 'mail_id';\r
1539                         //Convert all neccessary entries\r
1540                         $value_array['to_name'] = mb_convert_encoding($row['to_name'], $this->to_encoding, $this->from_encoding);\r
1541                         $value_array['from_name'] = mb_convert_encoding($row['from_name'], $this->to_encoding, $this->from_encoding);\r
1542                         $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);\r
1543                         $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);\r
1544                         //Generate SQL\r
1545                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1546                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1547                 }\r
1548                 return $result;\r
1549         }\r
1550 }\r
1551 \r
1552 /**\r
1553  * Class for master_list\r
1554  * Default language iso-8859-1.\r
1555  * Note: This class is independent from courses\r
1556  */\r
1557 class MasterListTable extends ATutorTable{\r
1558         function convert(){\r
1559                 //nothong to convert\r
1560                 return true;\r
1561         }\r
1562 }\r
1563 \r
1564 /**\r
1565  * Class for Members \r
1566  * Note: This class is independent from courses\r
1567  */\r
1568 class MembersTable extends ATutorTable{\r
1569         function convert(){\r
1570                 $rs = $this->getContent(false);\r
1571                 $result = true;\r
1572                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1573                         //Store the key for updating purposes.\r
1574                         $key_col = 'member_id';\r
1575                         //Convert all neccessary entries\r
1576                         $value_array['first_name'] = mb_convert_encoding($row['first_name'], $this->to_encoding, $this->from_encoding);\r
1577                         $value_array['second_name'] = mb_convert_encoding($row['second_name'], $this->to_encoding, $this->from_encoding);\r
1578                         $value_array['last_name'] = mb_convert_encoding($row['last_name'], $this->to_encoding, $this->from_encoding);\r
1579                         $value_array['address'] = mb_convert_encoding($row['address'], $this->to_encoding, $this->from_encoding);\r
1580                         $value_array['city'] = mb_convert_encoding($row['city'], $this->to_encoding, $this->from_encoding);\r
1581                         $value_array['province'] = mb_convert_encoding($row['province'], $this->to_encoding, $this->from_encoding);\r
1582                         $value_array['creation_date'] = $row['creation_date'];\r
1583                         //Generate SQL\r
1584                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1585                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1586                 }\r
1587                 return $result;\r
1588         }\r
1589 }\r
1590 \r
1591 /**\r
1592  * Class for member_track\r
1593  * Default language iso-8859-1.\r
1594  * Note: This class is independent from courses\r
1595  */\r
1596 class MemberTrackTable extends ATutorTable{\r
1597         function convert(){\r
1598                 //nothong to convert\r
1599                 return true;\r
1600         }\r
1601 }\r
1602 \r
1603 /**\r
1604  * Class for Messages\r
1605  */\r
1606 class MessagesTable extends ATutorTable{\r
1607         function convert(){\r
1608                 $rs = $this->getContent();\r
1609                 $result = true; \r
1610                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1611                         //Store the key for updating purposes.\r
1612                         $key_col = 'message_id';\r
1613                         //Convert all neccessary entries\r
1614                         $value_array['date_sent'] = $row['date_sent'];\r
1615                         $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);\r
1616                         $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);\r
1617                         //Generate SQL\r
1618                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1619                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1620                 }\r
1621                 return $result;\r
1622         }\r
1623 }\r
1624 \r
1625 \r
1626 /**\r
1627  * Class for Messages Sent\r
1628  */\r
1629 class MessagesSentTable extends ATutorTable{\r
1630         function convert(){\r
1631                 $rs = $this->getContent();\r
1632                 $result = true; \r
1633                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1634                         //Store the key for updating purposes.\r
1635                         $key_col = 'message_id';\r
1636                         //Convert all neccessary entries\r
1637                         $value_array['date_sent'] = $row['date_sent'];\r
1638                         $value_array['subject'] = mb_convert_encoding($row['subject'], $this->to_encoding, $this->from_encoding);\r
1639                         $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);\r
1640                         //Generate SQL\r
1641                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1642                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1643                 }\r
1644                 return $result;\r
1645         }\r
1646 }\r
1647 \r
1648 \r
1649 /**\r
1650  * Class for modules\r
1651  * Default language iso-8859-1.\r
1652  * Note: This class is independent from courses\r
1653  */\r
1654 class ModulesTable extends ATutorTable{\r
1655         function convert(){\r
1656                 //nothong to convert\r
1657                 return true;\r
1658         }\r
1659 }\r
1660 \r
1661 \r
1662 /**\r
1663  * Class for News\r
1664  */\r
1665 class NewsTable extends ATutorTable{\r
1666         function convert(){\r
1667                 $rs = $this->getContent();\r
1668                 $result = true;\r
1669                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1670                         //Store the key for updating purposes.\r
1671                         $key_col = 'news_id';\r
1672                         //Convert all neccessary entries\r
1673                         $value_array['date'] = $row['date'];\r
1674                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
1675                         $value_array['body'] = mb_convert_encoding($row['body'], $this->to_encoding, $this->from_encoding);\r
1676                         //Generate SQL\r
1677                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1678                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1679                 }\r
1680                 return $result;\r
1681         }\r
1682 }\r
1683 \r
1684 \r
1685 /**\r
1686  * Class for Polls\r
1687  */\r
1688 class PollsTable extends ATutorTable{\r
1689         function convert(){\r
1690                 $rs = $this->getContent();\r
1691                 $result = true;\r
1692                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1693                         //Store the key for updating purposes.\r
1694                         $key_col = 'poll_id';\r
1695                         //Convert all neccessary entries\r
1696                         $value_array['created_date'] = $row['created_date'];\r
1697                         $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);\r
1698                         $value_array['choice1'] = mb_convert_encoding($row['choice1'], $this->to_encoding, $this->from_encoding);\r
1699                         $value_array['choice2'] = mb_convert_encoding($row['choice2'], $this->to_encoding, $this->from_encoding);\r
1700                         $value_array['choice3'] = mb_convert_encoding($row['choice3'], $this->to_encoding, $this->from_encoding);\r
1701                         $value_array['choice4'] = mb_convert_encoding($row['choice4'], $this->to_encoding, $this->from_encoding);\r
1702                         $value_array['choice5'] = mb_convert_encoding($row['choice5'], $this->to_encoding, $this->from_encoding);\r
1703                         $value_array['choice6'] = mb_convert_encoding($row['choice6'], $this->to_encoding, $this->from_encoding);\r
1704                         $value_array['choice7'] = mb_convert_encoding($row['choice7'], $this->to_encoding, $this->from_encoding);\r
1705                         //Generate SQL\r
1706                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1707                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1708                 }\r
1709                 return $result;\r
1710         }\r
1711 }\r
1712 \r
1713 /**\r
1714  * Class for PollsMembers\r
1715  * Default language iso-8859-1.\r
1716  * Note: This class is independent from courses\r
1717  */\r
1718 class PollsMembersTable extends ATutorTable{\r
1719         function convert(){\r
1720                 //nothong to convert\r
1721                 return true;\r
1722         }\r
1723 }\r
1724 \r
1725 /**\r
1726  * Class for RelatedContent\r
1727  * Default language iso-8859-1.\r
1728  * Note: This class is independent from courses\r
1729  */\r
1730 class RelatedContentTable extends ATutorTable{\r
1731         function convert(){\r
1732                 //nothong to convert\r
1733                 return true;\r
1734         }\r
1735 }\r
1736 \r
1737 /**\r
1738  * Class for Readlig list\r
1739  */\r
1740 class ReadingListTable extends ATutorTable{\r
1741         function convert(){\r
1742                 $rs = $this->getContent();\r
1743                 $result = true;\r
1744                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1745                         //Store the key for updating purposes.\r
1746                         $key_col = 'reading_id';\r
1747                         //Convert all neccessary entries\r
1748                         $value_array['comment'] = mb_convert_encoding($row['comment'], $this->to_encoding, $this->from_encoding);\r
1749                         //Generate SQL\r
1750                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1751                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1752                 }\r
1753                 return $result;\r
1754         }\r
1755 }\r
1756 \r
1757 \r
1758 /**\r
1759  * Class for Tests\r
1760  */\r
1761 class TestsTable extends ATutorTable{\r
1762         function convert(){\r
1763                 $rs = $this->getContent();\r
1764                 $result = true;\r
1765                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1766                         //Store the key for updating purposes.\r
1767                         $key_col = 'test_id';\r
1768                         //Convert all neccessary entries\r
1769                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
1770                         $value_array['instructions'] = mb_convert_encoding($row['instructions'], $this->to_encoding, $this->from_encoding);\r
1771                         //Generate SQL\r
1772                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1773                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1774                 }\r
1775                 return $result;\r
1776         }\r
1777 }\r
1778 \r
1779 \r
1780 /**\r
1781  * Class for Test questions\r
1782  */\r
1783 class TestQuestionsTable extends ATutorTable{\r
1784         function convert(){\r
1785                 $rs = $this->getContent();\r
1786                 $result = true;\r
1787                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1788                         //Store the key for updating purposes.\r
1789                         $key_col = 'question_id';\r
1790                         //Convert all neccessary entries\r
1791                         $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);\r
1792                         $value_array['feedback'] = mb_convert_encoding($row['feedback'], $this->to_encoding, $this->from_encoding);\r
1793                         $value_array['question'] = mb_convert_encoding($row['question'], $this->to_encoding, $this->from_encoding);\r
1794                         $value_array['choice_0'] = mb_convert_encoding($row['choice_0'], $this->to_encoding, $this->from_encoding);\r
1795                         $value_array['choice_1'] = mb_convert_encoding($row['choice_1'], $this->to_encoding, $this->from_encoding);\r
1796                         $value_array['choice_2'] = mb_convert_encoding($row['choice_2'], $this->to_encoding, $this->from_encoding);\r
1797                         $value_array['choice_3'] = mb_convert_encoding($row['choice_3'], $this->to_encoding, $this->from_encoding);\r
1798                         $value_array['choice_4'] = mb_convert_encoding($row['choice_4'], $this->to_encoding, $this->from_encoding);\r
1799                         $value_array['choice_5'] = mb_convert_encoding($row['choice_5'], $this->to_encoding, $this->from_encoding);\r
1800                         $value_array['choice_6'] = mb_convert_encoding($row['choice_6'], $this->to_encoding, $this->from_encoding);\r
1801                         $value_array['choice_7'] = mb_convert_encoding($row['choice_7'], $this->to_encoding, $this->from_encoding);\r
1802                         $value_array['choice_8'] = mb_convert_encoding($row['choice_8'], $this->to_encoding, $this->from_encoding);\r
1803                         $value_array['choice_9'] = mb_convert_encoding($row['choice_9'], $this->to_encoding, $this->from_encoding);\r
1804                         $value_array['option_0'] = mb_convert_encoding($row['option_0'], $this->to_encoding, $this->from_encoding);\r
1805                         $value_array['option_1'] = mb_convert_encoding($row['option_1'], $this->to_encoding, $this->from_encoding);\r
1806                         $value_array['option_2'] = mb_convert_encoding($row['option_2'], $this->to_encoding, $this->from_encoding);\r
1807                         $value_array['option_3'] = mb_convert_encoding($row['option_3'], $this->to_encoding, $this->from_encoding);\r
1808                         $value_array['option_4'] = mb_convert_encoding($row['option_4'], $this->to_encoding, $this->from_encoding);\r
1809                         $value_array['option_5'] = mb_convert_encoding($row['option_5'], $this->to_encoding, $this->from_encoding);\r
1810                         $value_array['option_6'] = mb_convert_encoding($row['option_6'], $this->to_encoding, $this->from_encoding);\r
1811                         $value_array['option_7'] = mb_convert_encoding($row['option_7'], $this->to_encoding, $this->from_encoding);\r
1812                         $value_array['option_8'] = mb_convert_encoding($row['option_8'], $this->to_encoding, $this->from_encoding);\r
1813                         $value_array['option_9'] = mb_convert_encoding($row['option_9'], $this->to_encoding, $this->from_encoding);\r
1814 \r
1815                         //Convert links table\r
1816                         $tests_answers = new TestsAnswersTable($this->table_prefix, 'tests_answers', $this->from_encoding, $row[$key_col]);\r
1817                         $result &= $tests_answers->convert();\r
1818 \r
1819                         //Generate SQL\r
1820                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1821                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1822                 }\r
1823                 //Needs to alter related tables\r
1824                 if (!$rs) {                     \r
1825                         new TestsAnswersTable($this->table_prefix, 'tests_answers', '');\r
1826                 }\r
1827                 return $result;\r
1828         }\r
1829 }\r
1830 \r
1831 \r
1832 /**\r
1833  * Class for Test answers\r
1834  * Used only by TestQuestionTable\r
1835  * Foreign key = question_id, since question is one-to-many answers mapping.\r
1836  */\r
1837  class TestsAnswersTable extends ATutorTable{\r
1838         //Overrider\r
1839         function getContent(){\r
1840                 $sql = 'SELECT * FROM `'.$this->table_prefix.$this->table.'` WHERE question_id='.$this->foreign_ID;\r
1841                 $result = mysql_query($sql);\r
1842                 if ($result && mysql_num_rows($result)>0){\r
1843                         return $result;\r
1844                 }\r
1845                 return false;\r
1846         }\r
1847 \r
1848         function convert(){\r
1849                 $rs = $this->getContent();\r
1850                 $result = true;\r
1851                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1852                         //Store the key for updating purposes.\r
1853                         $key_col1 = 'question_id';\r
1854                         $key_col2 = 'result_id';\r
1855                         $key_col3 = 'member_id';\r
1856                         //Convert all neccessary entries\r
1857                         $value_array['answer'] = mb_convert_encoding($row['answer'], $this->to_encoding, $this->from_encoding);\r
1858                         $value_array['notes'] = mb_convert_encoding($row['notes'], $this->to_encoding, $this->from_encoding);\r
1859                         //Generate SQL\r
1860                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1861                         $result &= mysql_query($this->generate_sql($value_array, array($key_col1, $key_col2, $key_col3), \r
1862                                 array($row[$key_col1], $row[$key_col2], $row[$key_col3])));\r
1863                 }\r
1864                 return $result;\r
1865         }\r
1866  }\r
1867 \r
1868 /**\r
1869  * Class for tests_groups\r
1870  * Default language iso-8859-1.\r
1871  * Note: This class is independent from courses\r
1872  */\r
1873 class TestsGroupsTable extends ATutorTable{\r
1874         function convert(){\r
1875                 //nothong to convert\r
1876                 return true;\r
1877         }\r
1878 }\r
1879 \r
1880 /**\r
1881  * Class for tests_questions_assoc\r
1882  * Default language iso-8859-1.\r
1883  * Note: This class is independent from courses\r
1884  */\r
1885 class TestsQuestionsAssocTable extends ATutorTable{\r
1886         function convert(){\r
1887                 $rs = $this->getContent(false);\r
1888                 $result = true;\r
1889                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1890                         //Store the key for updating purposes.\r
1891                         $key_col = 'test_id';\r
1892                         $key_col2 = 'question_id';\r
1893                         //Convert all neccessary entries\r
1894                         $value_array['weight'] = mb_convert_encoding($row['weight'], $this->to_encoding, $this->from_encoding);\r
1895                         //Generate SQL\r
1896                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1897                         $result &= mysql_query($this->generate_sql($value_array, array($key_col, $key_col2), array($row[$key_col], $row[$key_col2])));\r
1898                 }\r
1899                 return $result;\r
1900         }\r
1901 }\r
1902 \r
1903 /**\r
1904  * Class for Tests questions category\r
1905  */\r
1906 class TestsQuestionsCategoriesTable extends ATutorTable{\r
1907         function convert(){\r
1908                 $rs = $this->getContent();\r
1909                 $result = true;\r
1910                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1911                         //Store the key for updating purposes.\r
1912                         $key_col = 'category_id';\r
1913                         //Convert all neccessary entries\r
1914                         $value_array['title'] = mb_convert_encoding($row['title'], $this->to_encoding, $this->from_encoding);\r
1915                         //Generate SQL\r
1916                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1917                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1918                 }\r
1919                 return $result;\r
1920         }\r
1921 }\r
1922 \r
1923 \r
1924 /**\r
1925  * Class for tests_results\r
1926  * Default language iso-8859-1.\r
1927  * Note: This class is independent from courses\r
1928  */\r
1929 class TestsResultsTable extends ATutorTable{\r
1930         function convert(){\r
1931                 //nothong to convert\r
1932                 return true;\r
1933         }\r
1934 }\r
1935 \r
1936 \r
1937 /**\r
1938  * Class for themes\r
1939  * Default language iso-8859-1.\r
1940  * Note: This class is independent from courses\r
1941  */\r
1942 class ThemesTable extends ATutorTable{\r
1943         function convert(){\r
1944                 $rs = $this->getContent(false);\r
1945                 $result = true;\r
1946                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1947                         //Store the key for updating purposes.\r
1948                         $key_col = 'title';\r
1949                         //Convert all neccessary entries\r
1950                         $value_array['extra_info'] = mb_convert_encoding($row['extra_info'], $this->to_encoding, $this->from_encoding);\r
1951                         //Generate SQL\r
1952                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1953                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1954                 }\r
1955                 return $result;\r
1956         }\r
1957 }\r
1958 \r
1959 \r
1960 /**\r
1961  * Class for users_online\r
1962  * Default language iso-8859-1.\r
1963  * Note: This class is independent from courses\r
1964  */\r
1965 class UsersOnlineTable extends ATutorTable{\r
1966         function convert(){\r
1967                 $rs = $this->getContent(false);\r
1968                 $result = true;\r
1969                 while ($rs!=false && $row = mysql_fetch_assoc($rs)){\r
1970                         //Store the key for updating purposes.\r
1971                         $key_col = 'member_id';\r
1972                         //Convert all neccessary entries\r
1973                         $value_array['login'] = mb_convert_encoding($row['login'], $this->to_encoding, $this->from_encoding);\r
1974                         //Generate SQL\r
1975                         //echo $this->generate_sql($value_array, $key_col, $row[$key_col]);\r
1976                         $result &= mysql_query($this->generate_sql($value_array, $key_col, $row[$key_col]));\r
1977                 }\r
1978                 return $result;\r
1979         }\r
1980 }\r
1981 ?>\r