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

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