install.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * Script for install all ilm in iassign table.
  4. *
  5. * This file replaces:
  6. * STATEMENTS section in db/install.xml
  7. * lib.php/modulename_install() post installation hook partially defaults.php.
  8. *
  9. * Release Notes:
  10. * - v 1.4 2017/02/16
  11. * + Insert iVProgH5, updated iGeom, iGraf, iComb, iHanoi
  12. * - v 1.3 2013/12/12
  13. * + Language support in iLM
  14. * - v 1.2 2013/09/19
  15. * + Change path file for ilm, consider version in pathname
  16. *
  17. * @author Patricia Alves Rodrigues
  18. * @author Leônidas O. Brandão
  19. * @version v 1.3 2019/03/13
  20. * @version v 1.2 2013/09/19
  21. * @package mod_iassign_db
  22. * @since 2010/09/27
  23. * @copyright iMath (http://www.matematica.br) and LInE (http://line.ime.usp.br) - Computer Science Dep. of IME-USP (Brazil)
  24. *
  25. * <b>License</b>
  26. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27. */
  28. require_once ($CFG->dirroot . '/mod/iassign/locallib.php');
  29. function xmldb_iassign_install() {
  30. global $DB, $USER, $CFG;
  31. $records = array(
  32. // iLM in HTML/CSS/JavaScript format
  33. //
  34. // iVProg4 1.0.20190717 - HTML5 - 2019
  35. array_combine(
  36. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  37. array('iVProg4', 'http://www.usp.br/line/ivprog/', '1.0.20190717', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}', 'ivph', 'ilm/iVProg4/1.0.20190717/ivprog4/', 'index.html', 800, 600, 1, time(), $USER->id, time(), 1)),
  38. // iVProgH 0.0.2 - HTML5 - 2014
  39. array_combine(
  40. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  41. array('iVProgH', 'http://www.matematica.br/ivprogh', '0.0.2', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}', 'ivph', 'ilm/iVProgH/0.0.2/ivprogh/', 'main.html', 800, 600, 1, time(), $USER->id, time(), 1)),
  42. // fractions 0.1.2017.11.22 - HTML5
  43. array_combine(
  44. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  45. array('iFractions', 'http://www.matematica.br/ifractions', '0.1.2017.11.22', 'HTML5', '{"en":"Interactive Fractions game","pt_br":"Jogo interativa de frações"}', 'frc', 'ilm/iFractions/0.1.2017.11.22/ifractions/', 'index.html', 1000, 600, 1, time(), $USER->id, time(), 1)),
  46. // iLM in Java/JAR format
  47. //
  48. // iGeom 5.9.22
  49. array_combine(
  50. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  51. array('iGeom', 'http://www.matematica.br/igeom', '5.9.22', 'Java', '{"en":"Interactive Geometry on the Internet","pt_br":"Geometria Interativa na Internet"}', 'geo', 'ilm/iGeom/5.9.22/iGeom.jar', 'IGeomApplet.class', 800, 600, 1, time(), $USER->id, time(), 1)),
  52. // iGraf 4.4.0.10
  53. array_combine(
  54. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  55. array('iGraf', 'http://www.matematica.br/igraf', '4.4.0.10', 'Java', '{"en":"Interactive Graphic on the Internet","pt_br":"Gráficos Interativos na Internet"}', 'grf', 'ilm/iGraf/4.4.0.10/iGraf.jar', 'igraf.IGraf.class', 840, 600, 1, time(), $USER->id, time(), 1)),
  56. // iComb 0.9.5
  57. array_combine(
  58. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  59. array('iComb', 'http://www.matematica.br/icomb', '0.9.5', 'Java', '{"en":"Combinatorics Interactive on the Internet","pt_br":"Combinatória Interativa na Internet"}', 'icb,cmb', 'ilm/iComb/0.9.5/iComb.jar', 'icomb.IComb.class', 750, 685, 1, time(), $USER->id, time(), 1)),
  60. // iVProg2 2.1.0
  61. array_combine(
  62. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  63. array('iVProg2', 'http://www.matematica.br/ivprog2', '2.1.0', 'Java', '{"en":"Visual Interactive Programming on the Internet","pt_br":"Programação visual interativa na Internet"}', 'ivp2', 'ilm/iVProg2/2.1.0/iVProg2.jar', 'usp.ime.line.ivprog.Ilm.class', 800, 700, 1, time(), $USER->id, time(), 1)),
  64. // iTangram2 0.4.6
  65. array_combine(
  66. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  67. array('iTangram2', 'http://www.matematica.br/itangram', '0.4.6', 'Java', '{"en":"interactive Tangram (by LInE)","pt_br":" Tangram interativo (do LInE)"}', 'itg2', 'ilm/iTangram2/0.4.6/iTangram2.jar', 'ilm.line.itangram2.Tangram', 800, 600, 1, time(), $USER->id, time(), 1)),
  68. // iHanoi 3.1.0
  69. array_combine(
  70. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  71. array('iHanoi', 'http://www.matematica.br/ihanoi', '3.1.0', 'Java', '{"en":"interactive Tower os Hanoi (by LInE)", "pt_br":"Torres de Hanói (do LInE)"}', 'ihn', 'ilm/iHanoi/3.1.0/iHanoi.jar', 'ihanoi.iHanoi', 730, 450, 1, time(), $USER->id, time(), 1)),
  72. // Risco 2
  73. array_combine(
  74. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  75. array('Risko', 'http://risko.pcc.usp.br/', '2.2.23', 'Java', '{"en":"Technical drawing with triangle and ruler","pt_br":"Desenho Geomẽtrico com esquadro"}', 'rsk', 'ilm/Risko/2.2.23/Risko.jar', 'RiskoApplet.class', 800, 600, 1, time(), $USER->id, time(), 0))
  76. );
  77. foreach ($records as $record) {
  78. // Verify if there is a previous iLM (an old version that must be kept)
  79. $iassign_ilm_parent = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'parent' => 0));
  80. $ilm_exists = false;
  81. if ($iassign_ilm_parent) {
  82. if ($iassign_ilm_parent->version != $record['version'])
  83. $record['parent'] = $iassign_ilm_parent->id;
  84. else
  85. $ilm_exists = true;
  86. }
  87. $file_jar = $record['file_jar'];
  88. if (!empty($file_jar)) {
  89. $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm'
  90. }
  91. } // foreach ($records as $record)
  92. // Add iAssign button to the Atto Editor
  93. $toolbar = get_config('editor_atto', 'toolbar');
  94. if (strpos($toolbar, 'iassign') === false && $toolbar && $toolbar != '') {
  95. $groups = explode("\n", $toolbar);
  96. // Try to put iassign in the html group.
  97. $found = false;
  98. foreach ($groups as $i => $group) {
  99. $parts = explode('=', $group);
  100. if (trim($parts[0]) == 'other') {
  101. $groups[$i] = 'other = ' . trim($parts[1]) . ', iassign';
  102. $found = true;
  103. }
  104. }
  105. // if the group is not found, create the other group and insert it there
  106. // Maybe unecessary as the other group is a standard, but if the user has changed it?
  107. if (!$found) {
  108. do {
  109. $last = array_pop($groups);
  110. } while (empty($last) && !empty($groups));
  111. $groups[] = 'other = iassign';
  112. $groups[] = $last;
  113. }
  114. // Update $toolbar and add to the config
  115. $toolbar = implode("\n", $groups);
  116. set_config('toolbar', $toolbar, 'editor_atto');
  117. } // if (strpos($toolbar, 'iassign') === false && $toolbar && $toolbar != '')
  118. // end Add
  119. // log event -----------------------------------------------------
  120. if (class_exists('plugin_manager'))
  121. $pluginman = plugin_manager::instance();
  122. else
  123. $pluginman = core_plugin_manager::instance();
  124. $plugins = $pluginman->get_plugins();
  125. iassign_log::add_log('install', 'version: ' . $plugins['mod']['iassign']->versiondb);
  126. // log event -----------------------------------------------------
  127. }
  128. // function xmldb_iassign_install()