update-db-1.8.5-1.8.6.inc.php 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. ==============================================================================
  5. * Chamilo LMS
  6. *
  7. * Update the Chamilo database from an older Dokeos version
  8. * Notice : This script has to be included by index.php
  9. * or update_courses.php (deprecated).
  10. *
  11. * @package chamilo.install
  12. * @todo
  13. * - conditional changing of tables. Currently we execute for example
  14. * ALTER TABLE `$dbNameForm`.`cours`
  15. * instructions without checking wether this is necessary.
  16. * - reorganise code into functions
  17. * @todo use database library
  18. ==============================================================================
  19. */
  20. $old_file_version = '1.8.5';
  21. $new_file_version = '1.8.6';
  22. /*
  23. ==============================================================================
  24. MAIN CODE
  25. ==============================================================================
  26. */
  27. // Check if we come from index.php or update_courses.php - otherwise display error msg
  28. if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
  29. // Check if the current Dokeos install is eligible for update
  30. if (!file_exists('../inc/conf/configuration.php')) {
  31. echo '<strong>'.get_lang('Error').' !</strong> Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.<br /><br />
  32. '.get_lang('PleasGoBackToStep1').'.
  33. <p><button type="submit" class="back" name="step1" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>
  34. </td></tr></table></form></body></html>';
  35. exit ();
  36. }
  37. $_configuration['db_glue'] = get_config_param('dbGlu');
  38. if ($singleDbForm) {
  39. $_configuration['table_prefix'] = get_config_param('courseTablePrefix');
  40. $_configuration['main_database'] = get_config_param('mainDbName');
  41. $_configuration['db_prefix'] = get_config_param('dbNamePrefix');
  42. }
  43. $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm);
  44. if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) {
  45. $dbScormForm = $dbPrefixForm.$dbScormForm;
  46. }
  47. if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
  48. $dbScormForm = $dbPrefixForm.'scorm';
  49. }
  50. /*
  51. -----------------------------------------------------------
  52. Normal upgrade procedure:
  53. start by updating main, statistic, user databases
  54. -----------------------------------------------------------
  55. */
  56. // If this script has been included by index.php, not update_courses.php, so
  57. // that we want to change the main databases as well...
  58. $only_test = false;
  59. $log = 0;
  60. if (defined('SYSTEM_INSTALLATION')) {
  61. if ($singleDbForm) {
  62. $dbStatsForm = $dbNameForm;
  63. $dbScormForm = $dbNameForm;
  64. $dbUserForm = $dbNameForm;
  65. }
  66. /**
  67. * Update the databases "pre" migration
  68. */
  69. include '../lang/english/create_course.inc.php';
  70. if ($languageForm != 'english') {
  71. // languageForm has been escaped in index.php
  72. include '../lang/'.$languageForm.'/create_course.inc.php';
  73. }
  74. // Get the main queries list (m_q_list)
  75. $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'main');
  76. if (count($m_q_list) > 0) {
  77. //now use the $m_q_list
  78. /**
  79. * We connect to the right DB first to make sure we can use the queries
  80. * without a database name
  81. */
  82. if (strlen($dbNameForm) > 40) {
  83. error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
  84. } elseif (!in_array($dbNameForm, $dblist)) {
  85. error_log('Database '.$dbNameForm.' was not found, skipping', 0);
  86. } else {
  87. Database::select_db($dbNameForm);
  88. foreach ($m_q_list as $query) {
  89. if ($only_test) {
  90. error_log("Database::query($dbNameForm,$query)", 0);
  91. } else {
  92. $res = Database::query($query);
  93. if ($log) {
  94. error_log("In $dbNameForm, executed: $query", 0);
  95. }
  96. }
  97. }
  98. }
  99. }
  100. // Filling the access_url_rel_user table with access_url_id by default = 1
  101. $query = "SELECT user_id FROM $dbNameForm.user";
  102. $result_users = Database::query($query);
  103. while ($row = Database::fetch_array($result_users, 'NUM')) {
  104. $user_id = $row[0];
  105. $sql = "INSERT INTO $dbNameForm.access_url_rel_user SET user_id=$user_id, access_url_id=1";
  106. $res = Database::query($sql);
  107. //Updating user image
  108. $query = "SELECT picture_uri FROM $dbNameForm.user WHERE user_id=$user_id";
  109. $res = Database::query($query);
  110. $picture_uri = Database::fetch_array($res, 'NUM');
  111. $file = $picture_uri[0];
  112. $dir = api_get_path(SYS_CODE_PATH).'upload/users/';
  113. $image_repository = file_exists($dir.$file) ? $dir.$file : $dir.$user_id.'/'.$file;
  114. if (!is_dir($dir.$user_id)) {
  115. @mkdir($dir.$user_id, $perm);
  116. }
  117. if (file_exists($image_repository)) {
  118. chmod($dir.$user_id, 0777);
  119. if (is_dir($dir.$user_id)) {
  120. $picture_location = $dir.$user_id.'/'.$file;
  121. $big_picture_location = $dir.$user_id.'/big_'.$file;
  122. $temp = new image($image_repository);
  123. $picture_infos = getimagesize($image_repository);
  124. $thumbwidth = 150;
  125. if (empty($thumbwidth) or $thumbwidth == 0) {
  126. $thumbwidth = 150;
  127. }
  128. $new_height = ($picture_infos[0] > 0) ? round(($thumbwidth / $picture_infos[0]) * $picture_infos[1]) : 0;
  129. $temp->resize($thumbwidth, $new_height, 0);
  130. $type = $picture_infos[2];
  131. // Original picture
  132. $big_temp = new image($image_repository);
  133. switch (!empty($type)) {
  134. case 2 : $temp->send_image('JPG', $picture_location);
  135. $big_temp->send_image('JPG', $big_picture_location);
  136. break;
  137. case 3 : $temp->send_image('PNG', $picture_location);
  138. $big_temp->send_image('JPG', $big_picture_location);
  139. break;
  140. case 1 : $temp->send_image('GIF',$picture_location);
  141. $big_temp->send_image('JPG', $big_picture_location);
  142. break;
  143. }
  144. if ($image_repository == $dir.$file) {
  145. @unlink($image_repository);
  146. }
  147. }
  148. }
  149. }
  150. // Filling the access_url_rel_session table with access_url_id by default = 1
  151. $query = "SELECT id FROM $dbNameForm.session";
  152. $result = Database::query($query);
  153. while ($row = Database::fetch_array($result, 'NUM')) {
  154. $sql = "INSERT INTO $dbNameForm.access_url_rel_session SET session_id=".$row[0].", access_url_id=1";
  155. $res = Database::query($sql);
  156. }
  157. // Since the parser of the migration DB does not work for this kind of inserts (HTML) we move it here
  158. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  159. (\'TemplateTitleCourseTitle\', \'TemplateTitleCourseTitleDescription\', \'coursetitle.gif\', \'
  160. <head>
  161. {CSS}
  162. <style type="text/css">
  163. .gris_title {
  164. color: silver;
  165. }
  166. h1
  167. {
  168. text-align: right;
  169. }
  170. </style>
  171. </head>
  172. <body>
  173. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  174. <tbody>
  175. <tr>
  176. <td style="vertical-align: middle; width: 50%;" colspan="1" rowspan="1">
  177. <h1>TITULUS 1<br />
  178. <span class="gris_title">TITULUS 2</span><br />
  179. </h1>
  180. </td>
  181. <td style="width: 50%;">
  182. <img style="width: 100px; height: 100px;" alt="dokeos logo" src="{COURSE_DIR}images/logo_dokeos.png"></td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. <p><br />
  187. <br />
  188. </p>
  189. </body>
  190. \');';
  191. $res = Database::query($sql);
  192. /*
  193. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  194. (\'TemplateTitleCheckList\', \'TemplateTitleCheckListDescription\', \'checklist.gif\', \'
  195. <head>
  196. {CSS}
  197. </head>
  198. <body>
  199. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  200. <tbody>
  201. <tr>
  202. <td style="vertical-align: top; width: 66%;">
  203. <h3>Lorem ipsum dolor sit amet</h3>
  204. <ul>
  205. <li>consectetur adipisicing elit</li>
  206. <li>sed do eiusmod tempor incididunt</li>
  207. <li>ut labore et dolore magna aliqua</li>
  208. </ul>
  209. <h3>Ut enim ad minim veniam</h3>
  210. <ul>
  211. <li>quis nostrud exercitation ullamco</li>
  212. <li>laboris nisi ut aliquip ex ea commodo consequat</li>
  213. <li>Excepteur sint occaecat cupidatat non proident</li>
  214. </ul>
  215. <h3>Sed ut perspiciatis unde omnis</h3>
  216. <ul>
  217. <li>iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam</li>
  218. <li>eaque ipsa quae ab illo inventore veritatis</li>
  219. <li>et quasi architecto beatae vitae dicta sunt explicabo.&nbsp;</li>
  220. </ul>
  221. </td>
  222. <td style="background: transparent url({IMG_DIR}postit.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; width: 33%; text-align: center; vertical-align: bottom;">
  223. <h3>Ut enim ad minima</h3>
  224. Veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur.<br />
  225. <h3>
  226. <img style="width: 180px; height: 144px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_smile.png "><br /></h3>
  227. </td>
  228. </tr>
  229. </tbody>
  230. </table>
  231. <p><br />
  232. <br />
  233. </p>
  234. </body>
  235. \');';
  236. $res = Database::query($sql);
  237. */
  238. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  239. (\'TemplateTitleTeacher\', \'TemplateTitleTeacherDescription\', \'yourinstructor.gif\', \'
  240. <head>
  241. {CSS}
  242. <style type="text/css">
  243. .text
  244. {
  245. font-weight: normal;
  246. }
  247. </style>
  248. </head>
  249. <body>
  250. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  251. <tbody>
  252. <tr>
  253. <td></td>
  254. <td style="height: 33%;"></td>
  255. <td></td>
  256. </tr>
  257. <tr>
  258. <td style="width: 25%;"></td>
  259. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: right; font-weight: bold;" colspan="1" rowspan="1">
  260. <span class="text">
  261. <br />
  262. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis pellentesque.</span>
  263. </td>
  264. <td style="width: 25%; font-weight: bold;">
  265. <img style="width: 180px; height: 241px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_case.png "></td>
  266. </tr>
  267. </tbody>
  268. </table>
  269. <p><br />
  270. <br />
  271. </p>
  272. </body>
  273. \');
  274. ';
  275. $res = Database::query($sql);
  276. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  277. (\'TemplateTitleLeftList\', \'TemplateTitleListLeftListDescription\', \'leftlist.gif\', \'
  278. <head>
  279. {CSS}
  280. </head>
  281. <body>
  282. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  283. <tbody>
  284. <tr>
  285. <td style="width: 66%;"></td>
  286. <td style="vertical-align: bottom; width: 33%;" colspan="1" rowspan="4">&nbsp;<img style="width: 180px; height: 248px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_reads.png "><br />
  287. </td>
  288. </tr>
  289. <tr align="right">
  290. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 66%;">Lorem
  291. ipsum dolor sit amet.
  292. </td>
  293. </tr>
  294. <tr align="right">
  295. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 66%;">
  296. Vivamus
  297. a quam.&nbsp;<br />
  298. </td>
  299. </tr>
  300. <tr align="right">
  301. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 66%;">
  302. Proin
  303. a est stibulum ante ipsum.</td>
  304. </tr>
  305. </tbody>
  306. </table>
  307. <p><br />
  308. <br />
  309. </p>
  310. </body>
  311. \');';
  312. $res = Database::query($sql);
  313. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  314. (\'TemplateTitleLeftRightList\', \'TemplateTitleLeftRightListDescription\', \'leftrightlist.gif\', \'
  315. <head>
  316. {CSS}
  317. </head>
  318. <body>
  319. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; height: 400px; width: 720px;" border="0" cellpadding="15" cellspacing="6">
  320. <tbody>
  321. <tr>
  322. <td></td>
  323. <td style="vertical-align: top;" colspan="1" rowspan="4">&nbsp;<img style="width: 180px; height: 294px;" alt="Trainer" src="{COURSE_DIR}images/trainer/trainer_join_hands.png "><br />
  324. </td>
  325. <td></td>
  326. </tr>
  327. <tr>
  328. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: right;">Lorem
  329. ipsum dolor sit amet.
  330. </td>
  331. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: left;">
  332. Convallis
  333. ut.&nbsp;Cras dui magna.</td>
  334. </tr>
  335. <tr>
  336. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: right;">
  337. Vivamus
  338. a quam.&nbsp;<br />
  339. </td>
  340. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: left;">
  341. Etiam
  342. lacinia stibulum ante.<br />
  343. </td>
  344. </tr>
  345. <tr>
  346. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: right;">
  347. Proin
  348. a est stibulum ante ipsum.</td>
  349. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: left;">
  350. Consectetuer
  351. adipiscing elit. <br />
  352. </td>
  353. </tr>
  354. </tbody>
  355. </table>
  356. <p><br />
  357. <br />
  358. </p>
  359. </body>
  360. \');';
  361. $res = Database::query($sql);
  362. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  363. (\'TemplateTitleRightList\', \'TemplateTitleRightListDescription\', \'rightlist.gif\', \'
  364. <head>
  365. {CSS}
  366. </head>
  367. <body style="direction: ltr;">
  368. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  369. <tbody>
  370. <tr>
  371. <td style="vertical-align: bottom; width: 50%;" colspan="1" rowspan="4"><img style="width: 300px; height: 199px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_points_right.png"><br />
  372. </td>
  373. <td style="width: 50%;"></td>
  374. </tr>
  375. <tr>
  376. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; text-align: left; width: 50%;">
  377. Convallis
  378. ut.&nbsp;Cras dui magna.</td>
  379. </tr>
  380. <tr>
  381. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; text-align: left; width: 50%;">
  382. Etiam
  383. lacinia.<br />
  384. </td>
  385. </tr>
  386. <tr>
  387. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; text-align: left; width: 50%;">
  388. Consectetuer
  389. adipiscing elit. <br />
  390. </td>
  391. </tr>
  392. </tbody>
  393. </table>
  394. <p><br />
  395. <br />
  396. </p>
  397. </body>
  398. \');';
  399. $res = Database::query($sql);
  400. /*
  401. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  402. (\'TemplateTitleComparison\', \'TemplateTitleComparisonDescription\', \'compare.gif\', \'
  403. <head>
  404. {CSS}
  405. </head>
  406. <body>
  407. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  408. <tr>
  409. <td style="height: 10%; width: 33%;"></td>
  410. <td style="vertical-align: top; width: 33%;" colspan="1" rowspan="2">&nbsp;<img style="width: 180px; height: 271px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_standing.png "><br />
  411. </td>
  412. <td style="height: 10%; width: 33%;"></td>
  413. </tr>
  414. <tr>
  415. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 33%; text-align: right;">
  416. Lorem ipsum dolor sit amet.
  417. </td>
  418. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; text-align: left; width: 33%;">
  419. Convallis
  420. ut.&nbsp;Cras dui magna.</td>
  421. </tr>
  422. </body>
  423. \');';
  424. $res = Database::query($sql);
  425. */
  426. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  427. (\'TemplateTitleDiagram\', \'TemplateTitleDiagramDescription\', \'diagram.gif\', \'
  428. <head>
  429. {CSS}
  430. </head>
  431. <body>
  432. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  433. <tbody>
  434. <tr>
  435. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; text-align: left; height: 33%; width: 33%;">
  436. <br />
  437. Etiam
  438. lacinia stibulum ante.
  439. Convallis
  440. ut.&nbsp;Cras dui magna.</td>
  441. <td colspan="1" rowspan="3">
  442. <img style="width: 350px; height: 267px;" alt="Alaska chart" src="{COURSE_DIR}images/diagrams/alaska_chart.png "></td>
  443. </tr>
  444. <tr>
  445. <td colspan="1" rowspan="1">
  446. <img style="width: 300px; height: 199px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_points_right.png "></td>
  447. </tr>
  448. <tr>
  449. </tr>
  450. </tbody>
  451. </table>
  452. <p><br />
  453. <br />
  454. </p>
  455. </body>
  456. \');
  457. ';
  458. $res = Database::query($sql);
  459. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  460. (\'TemplateTitleDesc\', \'TemplateTitleCheckListDescription\', \'description.gif\', \'
  461. <head>
  462. {CSS}
  463. </head>
  464. <body>
  465. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  466. <tbody>
  467. <tr>
  468. <td style="width: 50%; vertical-align: top;">
  469. <img style="width: 48px; height: 49px; float: left;" alt="01" src="{COURSE_DIR}images/small/01.png " hspace="5"><br />Lorem ipsum dolor sit amet<br /><br /><br />
  470. <img style="width: 48px; height: 49px; float: left;" alt="02" src="{COURSE_DIR}images/small/02.png " hspace="5">
  471. <br />Ut enim ad minim veniam<br /><br /><br />
  472. <img style="width: 48px; height: 49px; float: left;" alt="03" src="{COURSE_DIR}images/small/03.png " hspace="5">Duis aute irure dolor in reprehenderit<br /><br /><br />
  473. <img style="width: 48px; height: 49px; float: left;" alt="04" src="{COURSE_DIR}images/small/04.png " hspace="5">Neque porro quisquam est</td>
  474. <td style="vertical-align: top; width: 50%; text-align: right;" colspan="1" rowspan="1">
  475. <img style="width: 300px; height: 291px;" alt="Gearbox" src="{COURSE_DIR}images/diagrams/gearbox.jpg "><br /></td>
  476. </tr><tr></tr>
  477. </tbody>
  478. </table>
  479. <p><br />
  480. <br />
  481. </p>
  482. </body>
  483. \');
  484. ';
  485. $res = Database::query($sql);
  486. /*
  487. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  488. (\'TemplateTitleObjectives\', \'TemplateTitleObjectivesDescription\', \'courseobjectives.gif\', \'
  489. <head>
  490. {CSS}
  491. </head>
  492. <body>
  493. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  494. <tbody>
  495. <tr>
  496. <td style="vertical-align: bottom; width: 33%;" colspan="1" rowspan="2">
  497. <img style="width: 180px; height: 271px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_chair.png "><br />
  498. </td>
  499. <td style="height: 10%; width: 66%;"></td>
  500. </tr>
  501. <tr>
  502. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; text-align: left; width: 66%;">
  503. <h3>Lorem ipsum dolor sit amet</h3>
  504. <ul>
  505. <li>consectetur adipisicing elit</li>
  506. <li>sed do eiusmod tempor incididunt</li>
  507. <li>ut labore et dolore magna aliqua</li>
  508. </ul>
  509. <h3>Ut enim ad minim veniam</h3>
  510. <ul>
  511. <li>quis nostrud exercitation ullamco</li>
  512. <li>laboris nisi ut aliquip ex ea commodo consequat</li>
  513. <li>Excepteur sint occaecat cupidatat non proident</li>
  514. </ul>
  515. </td>
  516. </tr>
  517. </tbody>
  518. </table>
  519. <p><br />
  520. <br />
  521. </p>
  522. </body>
  523. \');';
  524. $res = Database::query($sql);
  525. */
  526. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  527. (\'TemplateTitleCycle\', \'TemplateTitleCycleDescription\', \'cyclechart.gif\', \'
  528. <head>
  529. {CSS}
  530. <style>
  531. .title
  532. {
  533. color: white; font-weight: bold;
  534. }
  535. </style>
  536. </head>
  537. <body>
  538. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="8" cellspacing="6">
  539. <tbody>
  540. <tr>
  541. <td style="text-align: center; vertical-align: bottom; height: 10%;" colspan="3" rowspan="1">
  542. <img style="width: 250px; height: 76px;" alt="arrow" src="{COURSE_DIR}images/diagrams/top_arrow.png ">
  543. </td>
  544. </tr>
  545. <tr>
  546. <td style="height: 5%; width: 45%; vertical-align: top; background-color: rgb(153, 153, 153); text-align: center;">
  547. <span class="title">Lorem ipsum</span>
  548. </td>
  549. <td style="height: 5%; width: 10%;"></td>
  550. <td style="height: 5%; vertical-align: top; background-color: rgb(153, 153, 153); text-align: center;">
  551. <span class="title">Sed ut perspiciatis</span>
  552. </td>
  553. </tr>
  554. <tr>
  555. <td style="background-color: rgb(204, 204, 255); width: 45%; vertical-align: top;">
  556. <ul>
  557. <li>dolor sit amet</li>
  558. <li>consectetur adipisicing elit</li>
  559. <li>sed do eiusmod tempor&nbsp;</li>
  560. <li>adipisci velit, sed quia non numquam</li>
  561. <li>eius modi tempora incidunt ut labore et dolore magnam</li>
  562. </ul>
  563. </td>
  564. <td style="width: 10%;"></td>
  565. <td style="background-color: rgb(204, 204, 255); width: 45%; vertical-align: top;">
  566. <ul>
  567. <li>ut enim ad minim veniam</li>
  568. <li>quis nostrud exercitation</li><li>ullamco laboris nisi ut</li>
  569. <li> Quis autem vel eum iure reprehenderit qui in ea</li>
  570. <li>voluptate velit esse quam nihil molestiae consequatur,</li>
  571. </ul>
  572. </td>
  573. </tr>
  574. <tr align="center">
  575. <td style="height: 10%; vertical-align: top;" colspan="3" rowspan="1">
  576. <img style="width: 250px; height: 76px;" alt="arrow" src="{COURSE_DIR}images/diagrams/bottom_arrow.png ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
  577. </td>
  578. </tr>
  579. </tbody>
  580. </table>
  581. <p><br />
  582. <br />
  583. </p>
  584. </body>
  585. \');';
  586. $res = Database::query($sql);
  587. /*
  588. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  589. (\'TemplateTitleLearnerWonder\', \'TemplateTitleLearnerWonderDescription\', \'learnerwonder.gif\', \'
  590. <head>
  591. {CSS}
  592. </head>
  593. <body>
  594. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  595. <tbody>
  596. <tr>
  597. <td style="width: 33%;" colspan="1" rowspan="4">
  598. <img style="width: 120px; height: 348px;" alt="learner wonders" src="{COURSE_DIR}images/silhouette.png "><br />
  599. </td>
  600. <td style="width: 66%;"></td>
  601. </tr>
  602. <tr align="center">
  603. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 66%;">
  604. Convallis
  605. ut.&nbsp;Cras dui magna.</td>
  606. </tr>
  607. <tr align="center">
  608. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 66%;">
  609. Etiam
  610. lacinia stibulum ante.<br />
  611. </td>
  612. </tr>
  613. <tr align="center">
  614. <td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 66%;">
  615. Consectetuer
  616. adipiscing elit. <br />
  617. </td>
  618. </tr>
  619. </tbody>
  620. </table>
  621. <p><br />
  622. <br />
  623. </p>
  624. </body>
  625. \');
  626. ';
  627. $res = Database::query($sql);
  628. */
  629. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  630. (\'TemplateTitleTimeline\', \'TemplateTitleTimelineDescription\', \'phasetimeline.gif\', \'
  631. <head>
  632. {CSS}
  633. <style>
  634. .title
  635. {
  636. font-weight: bold; text-align: center;
  637. }
  638. </style>
  639. </head>
  640. <body>
  641. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="8" cellspacing="5">
  642. <tbody>
  643. <tr class="title">
  644. <td style="vertical-align: top; height: 3%; background-color: rgb(224, 224, 224);">Lorem ipsum</td>
  645. <td style="height: 3%;"></td>
  646. <td style="vertical-align: top; height: 3%; background-color: rgb(237, 237, 237);">Perspiciatis</td>
  647. <td style="height: 3%;"></td>
  648. <td style="vertical-align: top; height: 3%; background-color: rgb(245, 245, 245);">Nemo enim</td>
  649. </tr>
  650. <tr>
  651. <td style="vertical-align: top; width: 30%; background-color: rgb(224, 224, 224);">
  652. <ul>
  653. <li>dolor sit amet</li>
  654. <li>consectetur</li>
  655. <li>adipisicing elit</li>
  656. </ul>
  657. <br />
  658. </td>
  659. <td>
  660. <img style="width: 32px; height: 32px;" alt="arrow" src="{COURSE_DIR}images/small/arrow.png ">
  661. </td>
  662. <td style="vertical-align: top; width: 30%; background-color: rgb(237, 237, 237);">
  663. <ul>
  664. <li>ut labore</li>
  665. <li>et dolore</li>
  666. <li>magni dolores</li>
  667. </ul>
  668. </td>
  669. <td>
  670. <img style="width: 32px; height: 32px;" alt="arrow" src="{COURSE_DIR}images/small/arrow.png ">
  671. </td>
  672. <td style="vertical-align: top; background-color: rgb(245, 245, 245); width: 30%;">
  673. <ul>
  674. <li>neque porro</li>
  675. <li>quisquam est</li>
  676. <li>qui dolorem&nbsp;&nbsp;</li>
  677. </ul>
  678. <br /><br />
  679. </td>
  680. </tr>
  681. </tbody>
  682. </table>
  683. <p><br />
  684. <br />
  685. </p>
  686. </body>
  687. \');
  688. ';
  689. $res = Database::query($sql);
  690. /*
  691. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  692. (\'TemplateTitleStopAndThink\', \'TemplateTitleStopAndThinkDescription\', \'stopthink.gif\', \'
  693. <head>
  694. {CSS}
  695. </head>
  696. <body>
  697. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  698. <tbody>
  699. <tr>
  700. <td style="vertical-align: bottom; width: 33%;" colspan="1" rowspan="2">
  701. <img style="width: 180px; height: 169px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_staring.png ">
  702. <br />
  703. </td>
  704. <td style="height: 10%; width: 66%;"></td>
  705. </tr>
  706. <tr>
  707. <td style="background: transparent url({IMG_DIR}postit.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; width: 66%; vertical-align: middle; text-align: center;">
  708. <h3>Attentio sectetur adipisicing elit</h3>
  709. <ul>
  710. <li>sed do eiusmod tempor incididunt</li>
  711. <li>ut labore et dolore magna aliqua</li>
  712. <li>quis nostrud exercitation ullamco</li>
  713. </ul><br /></td>
  714. </tr>
  715. </tbody>
  716. </table>
  717. <p><br />
  718. <br />
  719. </p>
  720. </body>
  721. \');';
  722. $res = Database::query($sql);
  723. */
  724. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  725. (\'TemplateTitleTable\', \'TemplateTitleCheckListDescription\', \'table.gif\', \'
  726. <head>
  727. {CSS}
  728. <style type="text/css">
  729. .title
  730. {
  731. font-weight: bold; text-align: center;
  732. }
  733. .items
  734. {
  735. text-align: right;
  736. }
  737. </style>
  738. </head>
  739. <body>
  740. <br />
  741. <h2>A table</h2>
  742. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px;" border="1" cellpadding="5" cellspacing="0">
  743. <tbody>
  744. <tr class="title">
  745. <td>City</td>
  746. <td>2005</td>
  747. <td>2006</td>
  748. <td>2007</td>
  749. <td>2008</td>
  750. </tr>
  751. <tr class="items">
  752. <td>Lima</td>
  753. <td>10,40</td>
  754. <td>8,95</td>
  755. <td>9,19</td>
  756. <td>9,76</td>
  757. </tr>
  758. <tr class="items">
  759. <td>New York</td>
  760. <td>18,39</td>
  761. <td>17,52</td>
  762. <td>16,57</td>
  763. <td>16,60</td>
  764. </tr>
  765. <tr class="items">
  766. <td>Barcelona</td>
  767. <td>0,10</td>
  768. <td>0,10</td>
  769. <td>0,05</td>
  770. <td>0,05</td>
  771. </tr>
  772. <tr class="items">
  773. <td>Paris</td>
  774. <td>3,38</td>
  775. <td >3,63</td>
  776. <td>3,63</td>
  777. <td>3,54</td>
  778. </tr>
  779. </tbody>
  780. </table>
  781. <br />
  782. </body>
  783. \');';
  784. $res = Database::query($sql);
  785. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  786. (\'TemplateTitleAudio\', \'TemplateTitleAudioDescription\', \'audiocomment.gif\', \'
  787. <head>
  788. {CSS}
  789. </head>
  790. <body>
  791. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  792. <tbody>
  793. <tr>
  794. <td>
  795. <div align="center">
  796. <span style="text-align: center;">
  797. <embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="300" height="20" bgcolor="#FFFFFF" src="{REL_PATH}main/inc/lib/mediaplayer/player.swf" allowfullscreen="false" allowscriptaccess="always" flashvars="file={COURSE_DIR}audio/ListeningComprehension.mp3&amp;autostart=true"></embed>
  798. </span></div>
  799. <br />
  800. </td>
  801. <td colspan="1" rowspan="3"><br />
  802. <img style="width: 300px; height: 341px; float: right;" alt="image" src="{COURSE_DIR}images/diagrams/head_olfactory_nerve.png "><br /></td>
  803. </tr>
  804. <tr>
  805. <td colspan="1" rowspan="1">
  806. <img style="width: 180px; height: 271px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_glasses.png"><br /></td>
  807. </tr>
  808. <tr>
  809. </tr>
  810. </tbody>
  811. </table>
  812. <p><br />
  813. <br />
  814. </p>
  815. </body>
  816. \');';
  817. $res = Database::query($sql);
  818. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  819. (\'TemplateTitleVideo\', \'TemplateTitleVideoDescription\', \'video.gif\', \'
  820. <head>
  821. {CSS}
  822. </head>
  823. <body>
  824. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  825. <tbody>
  826. <tr>
  827. <td style="width: 50%; vertical-align: top;">
  828. <div style="text-align: center;" id="player810625-parent">
  829. <div style="border-style: none; overflow: hidden; width: 320px; height: 240px; background-color: rgb(220, 220, 220);">
  830. <div id="player810625">
  831. <div id="player810625-config" style="overflow: hidden; display: none; visibility: hidden; width: 0px; height: 0px;">url={REL_PATH}main/default_course_document/video/flv/example.flv width=320 height=240 loop=false play=false downloadable=false fullscreen=true displayNavigation=true displayDigits=true align=left dispPlaylist=none playlistThumbs=false</div>
  832. </div>
  833. <embed
  834. type="application/x-shockwave-flash"
  835. src="{REL_PATH}main/inc/lib/mediaplayer/player.swf"
  836. width="320"
  837. height="240"
  838. id="single"
  839. name="single"
  840. quality="high"
  841. allowfullscreen="true"
  842. flashvars="width=320&height=240&autostart=false&file={REL_PATH}main/default_course_document/video/flv/example.flv&repeat=false&image=&showdownload=false&link={REL_PATH}main/default_course_document/video/flv/example.flv&showdigits=true&shownavigation=true&logo="
  843. />
  844. </div>
  845. </div>
  846. </td>
  847. <td style="background: transparent url({IMG_DIR}faded_grey.png) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; width: 50%;">
  848. <h3><br />
  849. </h3>
  850. <h3>Lorem ipsum dolor sit amet</h3>
  851. <ul>
  852. <li>consectetur adipisicing elit</li>
  853. <li>sed do eiusmod tempor incididunt</li>
  854. <li>ut labore et dolore magna aliqua</li>
  855. </ul>
  856. <h3>Ut enim ad minim veniam</h3>
  857. <ul>
  858. <li>quis nostrud exercitation ullamco</li>
  859. <li>laboris nisi ut aliquip ex ea commodo consequat</li>
  860. <li>Excepteur sint occaecat cupidatat non proident</li>
  861. </ul>
  862. </td>
  863. </tr>
  864. </tbody>
  865. </table>
  866. <p><br />
  867. <br />
  868. </p>
  869. <style type="text/css">body{}</style><!-- to fix a strange bug appearing with firefox when editing this template -->
  870. </body>
  871. \'); ';
  872. $res = Database::query($sql);
  873. $sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
  874. (\'TemplateTitleFlash\', \'TemplateTitleFlashDescription\', \'flash.gif\', \'
  875. <head>
  876. {CSS}
  877. </head>
  878. <body>
  879. <center>
  880. <table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 100%; height: 400px;" border="0" cellpadding="15" cellspacing="6">
  881. <tbody>
  882. <tr>
  883. <td align="center">
  884. <embed width="700" height="300" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="{COURSE_DIR}flash/SpinEchoSequence.swf" play="true" loop="true" menu="true"></embed></span><br />
  885. </td>
  886. </tr>
  887. </tbody>
  888. </table>
  889. <p><br />
  890. <br />
  891. </p>
  892. </center>
  893. </body>
  894. \'); ';
  895. $res = Database::query($sql);
  896. // Check if course_module exists, as it was not installed in Dokeos 1.8.5 because of a broken query, and $sql = 'INSERT it if necessary
  897. $query = "SELECT * FROM $dbNameForm.course_module";
  898. $result = Database::query($query);
  899. if ($result === false) {
  900. //the course_module table doesn't exist, create it
  901. $sql = "CREATE TABLE $dbNameForm.course_module (
  902. id int unsigned NOT NULL auto_increment,
  903. name varchar(100) NOT NULL,
  904. link varchar(255) NOT NULL,
  905. image varchar(100) default NULL,
  906. `row` int unsigned NOT NULL default '0',
  907. `column` int unsigned NOT NULL default '0',
  908. position varchar(20) NOT NULL default 'basic',
  909. PRIMARY KEY (id)
  910. )
  911. ";
  912. $result = Database::query($sql);
  913. if ($result !== false) {
  914. $sql = "INSERT INTO $dbNameForm.course_module (name, link, image, `row`,`column`, position) VALUES
  915. ('calendar_event','calendar/agenda.php','agenda.gif',1,1,'basic'),
  916. ('link','link/link.php','links.gif',4,1,'basic'),
  917. ('document','document/document.php','documents.gif',3,1,'basic'),
  918. ('student_publication','work/work.php','works.gif',3,2,'basic'),
  919. ('announcement','announcements/announcements.php','valves.gif',2,1,'basic'),
  920. ('user','user/user.php','members.gif',2,3,'basic'),
  921. ('forum','forum/index.php','forum.gif',1,2,'basic'),
  922. ('quiz','exercice/exercice.php','quiz.gif',2,2,'basic'),
  923. ('group','group/group.php','group.gif',3,3,'basic'),
  924. ('course_description','course_description/','info.gif',1,3,'basic'),
  925. ('chat','chat/chat.php','chat.gif',0,0,'external'),
  926. ('dropbox','dropbox/index.php','dropbox.gif',4,2,'basic'),
  927. ('tracking','tracking/courseLog.php','statistics.gif',1,3,'courseadmin'),
  928. ('homepage_link','link/link.php?action=addlink','npage.gif',1,1,'courseadmin'),
  929. ('course_setting','course_info/infocours.php','reference.gif',1,1,'courseadmin'),
  930. ('External','','external.gif',0,0,'external'),
  931. ('AddedLearnpath','','scormbuilder.gif',0,0,'external'),
  932. ('conference','conference/index.php?type=conference','conf.gif',0,0,'external'),
  933. ('conference','conference/index.php?type=classroom','conf.gif',0,0,'external'),
  934. ('learnpath','newscorm/lp_controller.php','scorm.gif',5,1,'basic'),
  935. ('blog','blog/blog.php','blog.gif',1,2,'basic'),
  936. ('blog_management','blog/blog_admin.php','blog_admin.gif',1,2,'courseadmin'),
  937. ('course_maintenance','course_info/maintenance.php','backup.gif',2,3,'courseadmin'),
  938. ('survey','survey/survey_list.php','survey.gif',2,1,'basic'),
  939. ('wiki','wiki/index.php','wiki.gif',2,3,'basic'),
  940. ('gradebook','gradebook/index.php','gradebook.gif',2,2,'basic'),
  941. ('glossary','glossary/index.php','glossary.gif',2,1,'basic'),
  942. ('notebook','notebook/index.php','notebook.gif',2,1,'basic')";
  943. $res = Database::query($sql);
  944. }
  945. }
  946. // Get the stats queries list (s_q_list)
  947. $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'stats');
  948. if (count($s_q_list) > 0) {
  949. // Now use the $s_q_list
  950. /**
  951. * We connect to the right DB first to make sure we can use the queries
  952. * without a database name
  953. */
  954. if (strlen($dbStatsForm) > 40) {
  955. error_log('Database name '.$dbStatsForm.' is too long, skipping', 0);
  956. } elseif (!in_array($dbStatsForm,$dblist)) {
  957. error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
  958. } else {
  959. Database::select_db($dbStatsForm);
  960. foreach ($s_q_list as $query) {
  961. if ($only_test) {
  962. error_log("Database::query($dbStatsForm,$query)", 0);
  963. } else {
  964. $res = Database::query($query);
  965. if ($log) {
  966. error_log("In $dbStatsForm, executed: $query", 0);
  967. }
  968. }
  969. }
  970. }
  971. }
  972. // Get the user queries list (u_q_list)
  973. $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user');
  974. if (count($u_q_list) > 0) {
  975. // Now use the $u_q_list
  976. /**
  977. * We connect to the right DB first to make sure we can use the queries
  978. * without a database name
  979. */
  980. if (strlen($dbUserForm) > 40) {
  981. error_log('Database name '.$dbUserForm.' is too long, skipping', 0);
  982. } elseif (!in_array($dbUserForm,$dblist)) {
  983. error_log('Database '.$dbUserForm.' was not found, skipping', 0);
  984. } else {
  985. Database::select_db($dbUserForm);
  986. foreach ($u_q_list as $query) {
  987. if ($only_test) {
  988. error_log("Database::query($dbUserForm,$query)", 0);
  989. error_log("In $dbUserForm, executed: $query", 0);
  990. } else {
  991. $res = Database::query($query);
  992. }
  993. }
  994. }
  995. }
  996. // The SCORM database doesn't need a change in the pre-migrate part - ignore
  997. }
  998. $prefix = '';
  999. if ($singleDbForm) {
  1000. $prefix = get_config_param ('table_prefix');
  1001. }
  1002. // Get the courses databases queries list (c_q_list)
  1003. $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course');
  1004. if (count($c_q_list) > 0) {
  1005. // Get the courses list
  1006. if (strlen($dbNameForm) > 40) {
  1007. error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
  1008. } elseif (!in_array($dbNameForm, $dblist)) {
  1009. error_log('Database '.$dbNameForm.' was not found, skipping', 0);
  1010. } else {
  1011. Database::select_db($dbNameForm);
  1012. $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
  1013. if ($res === false) { die('Error while querying the courses list in update_db-1.8.5-1.8.6.inc.php'); }
  1014. if (Database::num_rows($res) > 0) {
  1015. $i = 0;
  1016. $list = array();
  1017. while ($row = Database::fetch_array($res)) {
  1018. $list[] = $row;
  1019. $i++;
  1020. }
  1021. foreach ($list as $row_course) {
  1022. // Now use the $c_q_list
  1023. /**
  1024. * We connect to the right DB first to make sure we can use the queries
  1025. * without a database name
  1026. */
  1027. if (!$singleDbForm) { //otherwise just use the main one
  1028. Database::select_db($row_course['db_name']);
  1029. }
  1030. foreach ($c_q_list as $query) {
  1031. if ($singleDbForm) { //otherwise just use the main one
  1032. $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix{$row_course['db_name']}_$2$3", $query);
  1033. }
  1034. if ($only_test) {
  1035. error_log("Database::query(".$row_course['db_name'].",$query)", 0);
  1036. } else {
  1037. $res = Database::query($query);
  1038. if ($log) {
  1039. error_log("In ".$row_course['db_name'].", executed: $query", 0);
  1040. }
  1041. }
  1042. }
  1043. $t_d = $row_course['db_name'].".document";
  1044. $t_ip = $row_course['db_name'].".item_property";
  1045. if ($singleDbForm) {
  1046. $t_d = "$prefix{$row_course['db_name']}_document";
  1047. $t_ip = "$prefix{$row_course['db_name']}_item_property";
  1048. }
  1049. // Shared documents folder
  1050. $query = "INSERT INTO $t_d (path,title,filetype,size) VALUES ('/shared_folder','".get_lang('SharedDocumentsDirectory')."','folder','0')";
  1051. $myres = Database::query($query);
  1052. if ($myres !== false) {
  1053. $doc_id = Database::insert_id();
  1054. $query = "INSERT INTO $t_ip (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$doc_id,'FolderAdded',1,0,NULL,1)";
  1055. $myres = Database::query($query);
  1056. }
  1057. }
  1058. }
  1059. }
  1060. }
  1061. } else {
  1062. echo 'You are not allowed here !';
  1063. }