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

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