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

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