install.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. // iVProg 1.0.20190717 - HTML5 - 2020
  35. array_combine(
  36. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  37. array('iVProg', '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/iVProg/1.0.20190717/ivprog/', 'index.html', 800, 600, 1, time(), $USER->id, time(), 1)),
  38. // fractions 0.1.2017.11.22 - HTML5
  39. array_combine(
  40. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  41. array('iFractions', 'http://www.matematica.br/ifractions', '0.1.20200221', 'HTML5', '{"en":"Interactive Fractions game","pt_br":"Jogo interativa de frações"}', 'frc', 'ilm/iFractions/0.1.20200221/ifractions/', 'index.html', 1000, 600, 1, time(), $USER->id, time(), 1)),
  42. // iHanoi - 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('iHanoi', 'http://www.matematica.br/ihanoi', '0.1.20200115', 'HTML5', '{"en":"iHanoi","pt_br":"iHanoi"}', 'frc', 'ilm/iHanoi/0.1.20200115/ihanoi/', '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. );
  57. foreach ($records as $record) {
  58. // Verify if there is a previous iLM (an old version that must be kept)
  59. $iassign_ilm_parent = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'parent' => 0));
  60. $ilm_exists = false;
  61. if ($iassign_ilm_parent) {
  62. if ($iassign_ilm_parent->version != $record['version'])
  63. $record['parent'] = $iassign_ilm_parent->id;
  64. else
  65. $ilm_exists = true;
  66. }
  67. $file_jar = $record['file_jar'];
  68. if (!empty($file_jar)) {
  69. $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm'
  70. }
  71. } // foreach ($records as $record)
  72. // Add iAssign button to the Atto Editor
  73. $toolbar = get_config('editor_atto', 'toolbar');
  74. if (strpos($toolbar, 'iassign') === false && $toolbar && $toolbar != '') {
  75. $groups = explode("\n", $toolbar);
  76. // Try to put iassign in the html group.
  77. $found = false;
  78. foreach ($groups as $i => $group) {
  79. $parts = explode('=', $group);
  80. if (trim($parts[0]) == 'other') {
  81. $groups[$i] = 'other = ' . trim($parts[1]) . ', iassign';
  82. $found = true;
  83. }
  84. }
  85. // if the group is not found, create the other group and insert it there
  86. // Maybe unecessary as the other group is a standard, but if the user has changed it?
  87. if (!$found) {
  88. do {
  89. $last = array_pop($groups);
  90. } while (empty($last) && !empty($groups));
  91. $groups[] = 'other = iassign';
  92. $groups[] = $last;
  93. }
  94. // Update $toolbar and add to the config
  95. $toolbar = implode("\n", $groups);
  96. set_config('toolbar', $toolbar, 'editor_atto');
  97. } // if (strpos($toolbar, 'iassign') === false && $toolbar && $toolbar != '')
  98. // end Add
  99. // log event -----------------------------------------------------
  100. if (class_exists('plugin_manager'))
  101. $pluginman = plugin_manager::instance();
  102. else
  103. $pluginman = core_plugin_manager::instance();
  104. $plugins = $pluginman->get_plugins();
  105. iassign_log::add_log('install', 'version: ' . $plugins['mod']['iassign']->versiondb);
  106. // log event -----------------------------------------------------
  107. }
  108. // function xmldb_iassign_install()