Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cvsimport fixups -- cvshead had strayed from upstream

  • Loading branch information...
commit f3f7610c9013bd06ae0033e0143cc87e68c64bf3 1 parent b8806cc
Martin Langhoff authored
Showing with 1,548 additions and 25,184 deletions.
  1. +0 −185 admin/config.php
  2. +0 −660 admin/configvars.php
  3. +4 −0 admin/index.php
  4. +1 −1  admin/roles/assign.php
  5. +2 −2 admin/uploaduser.php
  6. +0 −70 admin/utfdbmigrate.html
  7. +0 −1,238 admin/utfdbmigrate.php
  8. +8 −0 admin/xmldb/actions/get_db_directories/get_db_directories.class.php
  9. +4 −4 backup/backuplib.php
  10. +0 −42 backup/db/migrate2utf8.php
  11. +0 −36 backup/db/migrate2utf8.xml
  12. +1 −1  blocks/admin/block_admin.php
  13. +0 −190 blocks/db/migrate2utf8.php
  14. +0 −31 blocks/db/migrate2utf8.xml
  15. +2 −2 blocks/online_users/block_online_users.php
  16. +0 −204 blocks/pagedemo.php
  17. +2 −2 blocks/quiz_results/block_quiz_results.php
  18. +0 −140 blocks/rss_client/db/migrate2utf8.php
  19. +0 −24 blocks/rss_client/db/migrate2utf8.xml
  20. +8 −7 blog/header.php
  21. +1 −1  blog/index.php
  22. +8 −1 blog/lib.php
  23. +2 −1  blog/rsslib.php
  24. +3 −3 calendar/event.php
  25. +7 −1 course/groups.php
  26. +3 −3 course/lib.php
  27. +0 −20 doc/COPYRIGHT.txt
  28. +0 −38 doc/contents.php
  29. +0 −131 doc/docstyles.css
  30. +0 −54 doc/index.php
  31. +0 −421 doc/install.html
  32. +0 −24 doc/top.php
  33. +0 −40 doc/view.php
  34. +0 −18 enrol/authorize/db/migrate2utf8.xml
  35. +182 −0 group/assign.php
  36. +73 −16 group/db/dbbasicgrouplib.php
  37. +3 −3 group/db/dbgroupinglib.php
  38. +20 −20 group/db/dbsetup.php
  39. +96 −0 group/db/install.xml
  40. +21 −21 group/db/mysql.sql
  41. +56 −50 group/db/postgres7.sql
  42. +223 −0 group/db/upgrade.php
  43. +208 −0 group/group.php
  44. +132 −0 group/grouping.php
  45. +0 −56 group/install.php
  46. +0 −199 group/install.sql
  47. +21 −0 group/lib.php
  48. +68 −15 group/lib/basicgrouplib.php
  49. +45 −15 group/lib/groupinglib.php
  50. +98 −83 group/lib/legacylib.php
  51. +80 −2 group/lib/utillib.php
  52. +8 −1 group/simpletest/test_basicgrouplib.php
  53. +1 −1  group/simpletest/test_groupinglib.php
  54. +11 −0 group/version.php
  55. +17 −3 lang/en_utf8/group.php
  56. +3 −0  lang/en_utf8/help/lesson/deleteattempts.html
  57. +14 −12 lib/accesslib.php
  58. +0 −1,787 lib/adodb/adodb-connection.inc.php
  59. +0 −316 lib/adodb/adodb-cryptsession.php
  60. +0 −919 lib/adodb/adodb-recordset.inc.php
  61. +0 −439 lib/adodb/adodb-session-clob.php
  62. +0 −398 lib/adodb/adodb-session.php
  63. +0 −43 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/Changelog
  64. +0 −8 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/INSTALL
  65. +0 −544 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/LICENSE
  66. +0 −36 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/README
  67. +0 −722 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/adodb-xmlschema.inc.php
  68. +0 −114 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/blank.html
  69. +0 −28 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/classtrees_xmlschema.html
  70. +0 −99 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/elementindex.html
  71. +0 −109 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/elementindex_xmlschema.html
  72. +0 −20 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/errors.html
  73. +0 −17 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/index.html
  74. +0 −38 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/li_xmlschema.html
  75. +0 −94 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/media/stylesheet.css
  76. +0 −25 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/packages.html
  77. +0 −111 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/xmlschema/_adodb-xmlschema_php.html
  78. +0 −235 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/xmlschema/adoSchema.html
  79. +0 −114 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/docs/xmlschema/package_xmlschema.html
  80. +0 −24 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/example.php
  81. +0 −27 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/example.xml
  82. +0 −31 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/xmlschema.dtd
  83. +0 −116 lib/adodb/adodb-xmlschema-0.0.1-snap20030511/xmlschema.html
  84. +3 −3 lib/adodb/adodb-xmlschema.inc.php
  85. +3 −3 lib/adodb/adodb-xmlschema03.inc.php
  86. +0 −64 lib/adodb/crypt.inc.php
  87. +0 −3,229 lib/adodb/docs-adodb.htm
  88. +0 −551 lib/adodb/docs-datadict.htm
  89. +0 −386 lib/adodb/docs-perf.htm
  90. +0 −213 lib/adodb/docs-session.htm
  91. +0 −413 lib/adodb/pear/Auth/Container/ADOdb.php
  92. +0 −20 lib/adodb/pear/readme.Auth.txt
  93. +0 −69 lib/adodb/readme.htm
  94. +0 −362 lib/adodb/tips_portable_sql.htm
  95. +0 −290 lib/adodb/tute.htm
  96. +12 −7 lib/datalib.php
  97. +3 −39 lib/db/install.xml
  98. +0 −2,308 lib/db/migrate2utf8.php
  99. +0 −563 lib/db/migrate2utf8.xml
  100. +0 −39 lib/db/mysql.sql
  101. +0 −26 lib/db/postgres7.sql
  102. +2 −2 lib/deprecatedlib.php
  103. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin_src.js
  104. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/plugins/fullscreen/editor_plugin_src.js
  105. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/themes/advanced/editor_template_src.js
  106. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/themes/simple/editor_template_src.js
  107. +4 −4 lib/editor/tinymce/jscripts/tiny_mce/tiny_mce_gzip.php
  108. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/tiny_mce_popup.js
  109. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/utils/form_utils.js
  110. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/utils/mclayer.js
  111. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/utils/mctabs.js
  112. +3 −3 lib/editor/tinymce/jscripts/tiny_mce/utils/validate.js
  113. +1 −1  lib/filelib.php
  114. +1 −1  lib/pear/HTML/QuickForm/Rule/Compare.php
  115. +1 −1  lib/soap/nusoap.php
  116. +0 −77 mod/assignment/db/migrate2utf8.php
  117. +0 −65 mod/assignment/db/migrate2utf8.xml
  118. +1 −1  mod/assignment/index.php
  119. +0 −78 mod/chat/db/migrate2utf8.php
  120. +0 −44 mod/chat/db/migrate2utf8.xml
  121. +1 −1  mod/chat/gui_header_js/index.php
  122. +1 −1  mod/chat/gui_sockets/index.php
  123. +0 −126 mod/choice/db/migrate2utf8.php
  124. +0 −28 mod/choice/db/migrate2utf8.xml
  125. +0 −521 mod/data/db/migrate2utf8.php
  126. +0 −189 mod/data/db/migrate2utf8.xml
  127. +1 −1  mod/data/index.php
  128. +0 −193 mod/exercise/db/migrate2utf8.php
  129. +0 −95 mod/exercise/db/migrate2utf8.xml
  130. +11 −11 mod/exercise/locallib.php
  131. +1 −1  mod/exercise/view.php
  132. +0 −78 mod/forum/db/migrate2utf8.php
  133. +0 −73 mod/forum/db/migrate2utf8.xml
  134. +1 −1  mod/forum/discuss.php
  135. +1 −1  mod/forum/view.php
  136. +0 −125 mod/glossary/db/migrate2utf8.php
  137. +0 −115 mod/glossary/db/migrate2utf8.xml
  138. +0 −213 mod/hotpot/db/migrate2utf8.php
  139. +0 −76 mod/hotpot/db/migrate2utf8.xml
  140. +6 −6 mod/hotpot/report.php
  141. +0 −77 mod/journal/db/migrate2utf8.php
  142. +0 −50 mod/journal/db/migrate2utf8.xml
  143. +2 −3 mod/journal/lib.php
  144. +1 −1  mod/journal/view.php
  145. +0 −77 mod/label/db/migrate2utf8.php
  146. +0 −18 mod/label/db/migrate2utf8.xml
  147. +0 −78 mod/lams/db/migrate2utf8.php
  148. +0 −18 mod/lams/db/migrate2utf8.xml
  149. +0 −304 mod/lesson/db/migrate2utf8.php
  150. +0 −77 mod/lesson/db/migrate2utf8.xml
  151. +1 −1  mod/lesson/mod_form.php
  152. +0 −934 mod/quiz/db/migrate2utf8.php
  153. +0 −255 mod/quiz/db/migrate2utf8.xml
  154. +2 −2 mod/quiz/lib.php
  155. +2 −6 mod/quiz/report/analysis/report.php
  156. +8 −9 mod/quiz/report/overview/report.php
  157. +0 −151 mod/resource/db/migrate2utf8.php
  158. +0 −31 mod/resource/db/migrate2utf8.xml
  159. +0 −802 mod/scorm/db/migrate2utf8.php
  160. +0 −132 mod/scorm/db/migrate2utf8.xml
  161. +0 −79 mod/survey/db/migrate2utf8.php
  162. +0 −78 mod/survey/db/migrate2utf8.xml
  163. +2 −2 mod/survey/lib.php
  164. +0 −157 mod/wiki/db/migrate2utf8.php
  165. +0 −126 mod/wiki/db/migrate2utf8.xml
  166. +3 −4 mod/wiki/lib.php
  167. +0 −315 mod/workshop/db/migrate2utf8.php
  168. +0 −141 mod/workshop/db/migrate2utf8.xml
  169. +5 −5 user/index.php
  170. +2 −2 user/tabs.php
  171. +3 −2 user/view.php
View
185 admin/config.php
@@ -1,185 +0,0 @@
-<?php // $Id$
- // config.php - allows admin to edit all configuration variables
-
- require_once('../config.php');
-
- $focus = '';
-
- if ($site = get_site()) { // If false then this is a new installation
- require_login();
- require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
- }
-
-/// This is to overcome the "insecure forms paradox"
- if (isset($secureforms) and $secureforms == 0) {
- $match = 'nomatch';
- } else {
- $match = '';
- }
-
-/// If data submitted, then process and store.
-
- if ($config = data_submitted($match)) {
-
- if (!empty($USER->id)) { // Additional identity check
- if (!confirm_sesskey()) {
- error(get_string('confirmsesskeybad', 'error'));
- }
- }
-
- validate_form($config, $err);
-
- if (count($err) == 0) {
- foreach ($config as $name => $value) {
- if ($name == "sessioncookie") {
- $value = eregi_replace("[^a-zA-Z0-9_]", "", $value);
- }
- if ($name == "defaultallowedmodules") {
- $value = implode(',',$value);
- }
- if ($name == 'hiddenuserfields') {
- if (in_array('none', $value)) {
- $value = '';
- } else {
- $value = implode(',',$value);
- }
- }
- if ($name == "locale") {
- $value = trim($value);
- }
- $conf = new object();
- $conf->name = $name;
- $conf->value = $value;
- if ($current = get_record('config', 'name', $name)) {
- $conf->id = $current->id;
- if (! update_record('config', $conf)) {
- error("Error: Could not update $name to $value");
- }
- } else {
- if (! insert_record('config', $conf)) {
- error("Error: could not add new variable $name !");
- }
- }
- }
- redirect('index.php');
- exit;
-
- } else {
- foreach ($err as $key => $value) {
- $focus = "form.$key";
- }
- }
- }
-
-/// Otherwise fill and print the form.
-
- if (empty($config)) {
- $config = $CFG;
- }
-
- $sesskey = !empty($USER->id) ? $USER->sesskey : '';
-
-
- $stradmin = get_string('administration');
- $strconfiguration = get_string('configuration');
- $strconfigvariables = get_string('configvariables', 'admin');
-
- if ($site) {
- print_header("$site->shortname: $strconfigvariables", $site->fullname,
- "<a href=\"index.php\">$stradmin</a> -> ".
- "<a href=\"configure.php\">$strconfiguration</a> -> $strconfigvariables", $focus);
- print_heading($strconfigvariables);
- } else {
- print_header();
- print_heading($strconfigvariables);
- print_simple_box(get_string('configintro', 'admin'), 'center', "50%");
- echo '<br />';
- }
-
-
-
-/// Get all the configuration fields and helptext
- require('configvars.php');
-
-/// Cycle through the sections to get the sectionnames
- $linktext = '';
- foreach($configvars as $sectionname=>$section) {
- if ($linktext !== '') {
- $linktext .= ' | ';
- }
- $linktext .= '<a href="#configsection'.$sectionname.'">'.get_string('configsection'.$sectionname, 'admin').'</a>';
- }
-
- echo "<center>$linktext</center>\n";
-
-
- echo '<form method="post" action="config.php" name="form">';
- echo '<center><input type="submit" value="'.get_string('savechanges').'" /></center>';
-
-/// Cycle through each section of the configuration
- foreach ($configvars as $sectionname=>$section) {
-
- print_heading('<a name="configsection'.$sectionname.'"></a>'.get_string('configsection'.$sectionname, 'admin'));
-
- $table = NULL;
- $table->data = array();
- foreach ($section as $configvariable=>$configobject) {
- $table->data[] = array ( $configvariable.': ',
- $configobject->field
- );
- if ($configobject->display_warning()) {
- $table->data[] = array ( '&nbsp;',
- '<span class="configwarning">'.$configobject->warning.'</span>'
- );
- }
- $table->data[] = array ( '&nbsp;',
- '<span class="confighelp">'.$configobject->help.'</span>'
- );
- $table->align = array ('right', 'left');
- }
- print_table($table);
-
- }
- echo '<center>';
- echo '<input type="hidden" name="sesskey" value="'.$sesskey.'" />';
- echo '<input type="submit" value="'.get_string('savechanges').'" />';
- echo '</center>';
-
- echo '</form>';
-
-
-
-
-
- /// Lock some options
-
- $httpsurl = str_replace('http://', 'https://', $CFG->wwwroot);
- if ($httpsurl != $CFG->wwwroot) {
- if (ini_get('allow_url_fopen')) {
- if ((($fh = @fopen($httpsurl, 'r')) == false) and ($config->loginhttps == 0)) {
- echo '<script type="text/javascript">'."\n";
- echo '<!--'."\n";
- echo "eval('document.form.loginhttps.disabled=true');\n";
- echo '-->'."\n";
- echo '</script>'."\n";
- }
- }
- }
-
-
- if ($site) {
- print_footer();
- }
-
- exit;
-
-/// Functions /////////////////////////////////////////////////////////////////
-
-function validate_form(&$form, &$err) {
-
- // Currently no checks are needed ...
-
- return true;
-}
-
-?>
View
660 admin/configvars.php
@@ -1,660 +0,0 @@
-<?php // $Id$
- // Shane Elliott
-defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
-
-/// Add new sitewide configuration variables to this file.
-
-
-/// $configvars is parsed by config.php
-/// It is an array of arrays of objects
-/// $configvars[sectionname][configvariablename] = configvar object
- $configvars = array();
-
-
-/// no, yes strings and menu options are used in a number of places
-/// so we define them here to save time on repeatedly calling
-/// get_string()
- $stryes = get_string('yes');
- $strno = get_string('no');
-
- $noyesoptions[0] = $strno;
- $noyesoptions[1] = $stryes;
-
-
-
-/// A class to hold the configurable information
-/// $field - the html code for the form field
-/// $help - help text for the field
-/// $warning - optional warning text to be displayed
-/// method display_warning() - a generic function that can be used in an extended class
-/// e.g. enablerssfeeds
-class configvar {
-
- var $field;
- var $help;
- var $warning;
-
- function configvar($help, $field, $warning='') {
- $this->help = $help;
- $this->field = $field;
- $this->warning = $warning;
- }
-
- function display_warning() {
- return false;
- }
-}
-
-
-
-
-
-////////////////////////////////////////////////////////////////////
-/// Miscellaneous config variables
-////////////////////////////////////////////////////////////////////
- $misc = array();
-
-
-/// maxeditingtime
- unset($options);
- $options[3600] = get_string('numminutes', '', 60);
- $options[2700] = get_string('numminutes', '', 45);
- $options[1800] = get_string('numminutes', '', 30);
- $options[900] = get_string('numminutes', '', 15);
- $options[300] = get_string('numminutes', '', 5);
- $options[60] = get_string('numminutes', '', 1);
-
- $misc['maxeditingtime'] = new configvar (get_string('configmaxeditingtime', 'admin'),
- choose_from_menu ($options, 'maxeditingtime', $config->maxeditingtime, '', '', '', true) );
-
-/// debug
- unset($options);
- $options[5] = $strno;
- $options[15] = $stryes;
-
- $misc['debug'] = new configvar (get_string('configdebug', 'admin'),
- choose_from_menu ($options, 'debug', $config->debug, '', '', '', true) );
-
- $misc['perfdebug'] = new configvar (get_string('configperfdebug', 'admin'),
- choose_from_menu ($options, 'perfdebug', $config->perfdebug, '', '', '', true) );
-
-/// enablerssfeeds
-class configvarrss extends configvar {
- function display_warning() {
- return (!function_exists('utf8_encode'));
- }
-}
-
- $misc['enablerssfeeds'] = new configvarrss (get_string('configenablerssfeeds', 'admin'),
- choose_from_menu ($noyesoptions, 'enablerssfeeds', $config->enablerssfeeds, '', '', '', true),
- '<font color="red"> You need to add XML support to your PHP installation.</font>' );
-
- $misc['mymoodleredirect'] = new configvar (get_string('configmymoodleredirect','admin'),
- choose_from_menu($noyesoptions,'mymoodleredirect',$config->mymoodleredirect,'','','',true));
-
- unset($options);
- $options[5] = get_string('worldblogs','blog');
- $options[4] = get_string('siteblogs','blog');
- $options[3] = get_string('courseblogs','blog');
- $options[2] = get_string('groupblogs','blog');
- $options[1] = get_string('personalblogs','blog');
- $options[0] = get_string('disableblogs','blog');
-
- $misc['bloglevel'] = new configvar (get_string('configbloglevel', 'admin'),
- choose_from_menu ($options, 'bloglevel', $config->bloglevel,'','','',true));
-
-////////////////////////////////////////////////////////////////////
-/// OPERATING SYSTEM config variables
-////////////////////////////////////////////////////////////////////
- $operatingsystem = array();
-
-/// gdversion
- unset($options);
- $options[0] = get_string('gdnot');
- $options[1] = get_string('gd1');
- $options[2] = get_string('gd2');
-
- $installed = check_gd_version();
-
- $operatingsystem['gdversion'] = new configvar (get_string('configgdversion', 'admin'),
- choose_from_menu ($options, 'gdversion', $installed, '', '', '', true) );
-
-/// dbsessions
- $operatingsystem['dbsessions'] = new configvar (get_string('configdbsessions', 'admin'),
- choose_from_menu ($noyesoptions, 'dbsessions', $config->dbsessions, '', '', '', true) );
-
-/// sessiontimeout
- unset($options);
- $options[14400] = get_string('numhours', '', 4);
- $options[10800] = get_string('numhours', '', 3);
- $options[7200] = get_string('numhours', '', 2);
- $options[5400] = get_string('numhours', '', '1.5');
- $options[3600] = get_string('numminutes', '', 60);
- $options[2700] = get_string('numminutes', '', 45);
- $options[1800] = get_string('numminutes', '', 30);
- $options[900] = get_string('numminutes', '', 15);
- $options[300] = get_string('numminutes', '', 5);
-
- $operatingsystem['sessiontimeout'] = new configvar (get_string('configsessiontimeout', 'admin'),
- choose_from_menu ($options, 'sessiontimeout', $config->sessiontimeout, '', '', '', true) );
-
-/// sessioncookie
- $operatingsystem['sessioncookie'] = new configvar (get_string('configsessioncookie', 'admin'),
- '<input name="sessioncookie" type="text" size="10" value="'.s($config->sessioncookie).'" alt="sessioncookie" />' );
- $operatingsystem['sessioncookiepath'] = new configvar (get_string('configsessioncookiepath', 'admin'),
- '<input name="sessioncookiepath" type="text" size="10" value="'.s($config->sessioncookiepath).'" alt="sessioncookiepath" />' );
-
-/// zip
- $operatingsystem['zip'] = new configvar (get_string('configzip', 'admin'),
- '<input name="zip" type="text" size="30" value="'.s($config->zip).'" alt="zip" />' );
-
-/// unzip
- $operatingsystem['unzip'] = new configvar (get_string('configunzip', 'admin'),
- '<input name="unzip" type="text" size="30" value="'.s($config->unzip).'" alt="unzip" />' );
-
- $operatingsystem['pathtodu'] = new configvar(get_string('configpathtodu', 'admin'),
- '<input name="pathtodu" type="text" size="30" value="'.s($config->pathtodu).'" alt="pathtodu" />');
-
-/// slasharguments
- unset($options);
- $options[0] = "file.php?file=/1/pic.jpg";
- $options[1] = "file.php/1/pic.jpg";
-
- $operatingsystem['slasharguments'] = new configvar (get_string('configslasharguments', 'admin'),
- choose_from_menu ($options, 'slasharguments', $config->slasharguments, '', '', '', true) );
-
-/// proxyhost
- $operatingsystem['proxyhost'] = new configvar (get_string('configproxyhost', 'admin'),
- '<input name="proxyhost" type="text" size="30" value="'.s($config->proxyhost).'" alt="proxyhost" />' );
-
-/// proxyport
- $operatingsystem['proxyport'] = new configvar ('',
- '<input name="proxyport" type="text" size="5" value="'.s($config->proxyport).'" alt="proxyport" />' );
-
-
-
-////////////////////////////////////////////////////////////////////
-/// PERMISSIONS config variables
-////////////////////////////////////////////////////////////////////
- $permissions = array();
-
-/// teacherassignteachers
- $permissions['teacherassignteachers'] = new configvar (get_string('configteacherassignteachers', 'admin'),
- choose_from_menu ($noyesoptions, 'teacherassignteachers', $config->teacherassignteachers, '', '', '', true) );
-
-/// allowunenroll
- $permissions['allowunenroll'] = new configvar (get_string('configallowunenroll', 'admin'),
- choose_from_menu ($noyesoptions, 'allowunenroll', $config->allowunenroll, '', '', '', true) );
-
-/// allusersaresitestudents
- $permissions['allusersaresitestudents'] = new configvar (get_string('configallusersaresitestudents', 'admin'),
- choose_from_menu ($noyesoptions, 'allusersaresitestudents', $config->allusersaresitestudents, '', '', '', true) );
-
-/// showsiteparticipantslist
- unset($options);
- $options[0] = get_string('siteteachers');
- $options[1] = get_string('allteachers');
- $options[2] = get_string('studentsandteachers');
-
- $permissions['showsiteparticipantslist'] = new configvar (get_string('configshowsiteparticipantslist', 'admin'),
- choose_from_menu ($options, 'showsiteparticipantslist', $config->showsiteparticipantslist, '', '', '', true) );
-
-/// forcelogin
- $permissions['forcelogin'] = new configvar (get_string('configforcelogin', 'admin'),
- choose_from_menu ($noyesoptions, 'forcelogin', $config->forcelogin, '', '', '', true) );
-
-/// forceloginforprofiles
- $permissions['forceloginforprofiles'] = new configvar (get_string('configforceloginforprofiles', 'admin'),
- choose_from_menu ($noyesoptions, 'forceloginforprofiles', $config->forceloginforprofiles, '', '', '', true) );
-
-/// opentogoogle
- $permissions['opentogoogle'] = new configvar (get_string('configopentogoogle', 'admin'),
- choose_from_menu ($noyesoptions, 'opentogoogle', $config->opentogoogle, '', '', '', true) );
-
-/// maxbytes
- $options = get_max_upload_sizes();
-
- $permissions['maxbytes'] = new configvar (get_string('configmaxbytes', 'admin'),
- choose_from_menu ($options, 'maxbytes', $config->maxbytes, '', '', 0, true) );
-
-/// messaging
- $permissions['messaging'] = new configvar (get_string('configmessaging', 'admin'),
- choose_from_menu ($noyesoptions, 'messaging', $config->messaging, '', '', '', true) );
-
-/// allowobjectembed
- $permissions['allowobjectembed'] = new configvar (get_string('configallowobjectembed', 'admin'),
- choose_from_menu ($noyesoptions, 'allowobjectembed', $config->allowobjectembed, '', '', '', true) );
-
-/// enabletrusttext
- $permissions['enabletrusttext'] = new configvar (get_string('configenabletrusttext', 'admin'),
- choose_from_menu ($noyesoptions, 'enabletrusttext', $config->enabletrusttext, '', '', '', true) );
-
- unset($options);
- $options['none'] = 'No courses';
- $options['all'] = 'All courses';
- $options['requested'] = 'Requested courses';
-
- $permissions['restrictmodulesfor'] = new configvar (get_string('configrestrictmodulesfor','admin'),
- ' <script language="JavaScript">
- function togglemodules(index) {
- if (index == 0) {
- document.getElementById(\'allowedmodules\').disabled=true;
- }
- else {
- document.getElementById(\'allowedmodules\').disabled=false;
- }
- }
- </script>'.
- choose_from_menu($options,'restrictmodulesfor',$config->restrictmodulesfor,'','togglemodules(this.selectedIndex);','',true) );
-
- $permissions['restrictbydefault'] = new configvar (get_string('configrestrictbydefault','admin'),
- choose_from_menu($noyesoptions, 'restrictbydefault',$config->restrictbydefault,'','','',true) );
-
- $allowstr = '<select name="defaultallowedmodules[]" id="allowedmodules" multiple="multiple" size="10"'.((empty($config->restrictmodulesfor)) ? "disabled=\"disabled\"" : "").'>';
-
- $allowedmodules = array();
- if (!empty($config->defaultallowedmodules)) {
- $allowedmodules = explode(',',$config->defaultallowedmodules);
- }
-
-// On a fresh install of Moodle, this could be empty; prevent a warning on the following loop.
- if (!$mods = get_records("modules")) {
- $mods = array();
- }
- $s = "selected=\"selected\"";
- $allowstr .= '<option value="0" '.((empty($allowedmodules)) ? $s : '').'>'.get_string('allownone').'</option>'."\n";
- foreach ($mods as $mod) {
- $selected = "";
- if (in_array($mod->id,$allowedmodules))
- $selected = $s;
- $allowstr .= '<option '.$selected.' value="'.$mod->id.'">'.$mod->name.'</option>'."\n";
- }
- $allowstr .= '</select>';
-
- $permissions['defaultallowedmodules'] = new configvar (get_string('configdefaultallowedmodules','admin'),$allowstr);
-
-
-/// course requests
- $reqcourse['enablecourserequests'] = new configvar (get_string('configenablecourserequests', 'admin'),
- choose_from_menu ($noyesoptions,'enablecourserequests',$config->enablecourserequests,'','','',true) );
-
-/// default category for course requests
- require_once($CFG->dirroot.'/course/lib.php');
- $reqcourse['defaultrequestedcategory'] = new configvar (get_string('configdefaultrequestedcategory', 'admin'),
- choose_from_menu (make_categories_options(), 'defaultrequestedcategory',$config->defaultrequestedcategory,'','','',true) );
-
- $reqcourse['requestedteachername'] = new configvar (get_string('configrequestedteachername','admin'),
- '<input type="text" name="requestedteachername" size="20" maxlength="100" value="'.s($config->requestedteachername).'" />');
-
- $reqcourse['requestedteachersname'] = new configvar (get_string('configrequestedteachersname','admin'),
- '<input type="text" name="requestedteachersname" size="20" maxlength="100" value="'.s($config->requestedteachersname).'" />');
-
- $reqcourse['requestedstudentname'] = new configvar (get_string('configrequestedstudentname','admin'),
- '<input type="text" name="requestedstudentname" size="20" maxlength="100" value="'.s($config->requestedstudentname).'" />');
-
- $reqcourse['requestedstudentsname'] = new configvar (get_string('configrequestedstudentsname','admin'),
- '<input type="text" name="requestedstudentsname" size="20" maxlength="100" value="'.s($config->requestedstudentsname).'" />');
-
-////////////////////////////////////////////////////////////////////
-/// INTERFACE config variables
-////////////////////////////////////////////////////////////////////
- $interface = array();
-
-/// language settings
- $interface['lang'] = new configvar ( get_string('configlang', 'admin'),
- choose_from_menu(get_list_of_languages(), 'lang', $config->lang, '', '', '', true) );
-
-/// language menu
- $interface['langmenu'] = new configvar ( get_string('configlangmenu', 'admin'),
- choose_from_menu($noyesoptions, 'langmenu', $config->langmenu, '', '', '', true) );
-
-/// language list
- $interface['langlist'] = new configvar ( get_string('configlanglist', 'admin'),
- '<input name="langlist" type="text" size="60" value="'.s($config->langlist).'" alt="langlist" />' );
-
-/// language menu
- $interface['langcache'] = new configvar ( get_string('configlangcache', 'admin'),
- choose_from_menu($noyesoptions, 'langcache', $config->langcache, '', '', '', true) );
-
-/// locale
- $interface['locale'] = new configvar ( get_string('configlocale', 'admin'),
- '<input name="locale" type="text" size="15" value="'.s($config->locale).'" alt="locale" />' );
-
-/// docroot
- $interface['docroot'] = new configvar ( get_string('configdocroot', 'admin'),
- '<input name="docroot" type="text" size="60" value="'.s($config->docroot).'" alt="docroot" />' );
-
-/// doctonewwindow
- $interface['doctonewwindow'] = new configvar ( get_string('configdoctonewwindow', 'admin'),
- choose_from_menu($noyesoptions, 'doctonewwindow', $config->doctonewwindow, '', '', '', true) );
-
-/// timezone
- $interface['timezone'] = new configvar ( get_string('configtimezone', 'admin'),
- choose_from_menu (get_list_of_timezones(), 'timezone', $config->timezone, get_string('serverlocaltime'), '', '99', true ) );
-
-/// country
- $interface['country'] = new configvar ( get_string('configcountry', 'admin'),
- choose_from_menu (get_list_of_countries(), 'country', $config->country, get_string('selectacountry'), '', 0, true) );
-
-/// framename
- if (empty($config->framename)) {
- $config->framename = "_top";
- }
-
- $interface['framename'] = new configvar (get_string('configframename', 'admin'),
- '<input name="framename" type="text" size="15" value="'.s($config->framename).'" alt="framename" />' );
-
-/// language list
- $interface['themelist'] = new configvar ( get_string('configthemelist', 'admin'),
- '<input name="themelist" type="text" size="60" value="'.s($config->themelist).'" alt="themelist" />' );
-
-/// user themes
- $interface['allowuserthemes'] = new configvar (get_string('configallowuserthemes', 'admin'),
- choose_from_menu ($noyesoptions, 'allowuserthemes', $config->allowuserthemes, '', '', '', true) );
-
-/// course themes
- $interface['allowcoursethemes'] = new configvar (get_string('configallowcoursethemes', 'admin'),
- choose_from_menu ($noyesoptions, 'allowcoursethemes', $config->allowcoursethemes, '', '', '', true) );
-
-/// allowuserblockhiding
- $interface['allowuserblockhiding'] = new configvar (get_string('configallowuserblockhiding', 'admin'),
- choose_from_menu ($noyesoptions, 'allowuserblockhiding', $config->allowuserblockhiding, '', '', '', true) );
-
-/// showblocksonmodpages
- $interface['showblocksonmodpages'] = new configvar (get_string('configshowblocksonmodpages', 'admin'),
- choose_from_menu ($noyesoptions, 'showblocksonmodpages', $config->showblocksonmodpages, '', '', '', true) );
-
-
-/// tabselectedtofront
- $interface['tabselectedtofront'] = new configvar (get_string('tabselectedtofront', 'admin'),
- choose_from_menu ($noyesoptions, 'tabselectedtofront', $config->tabselectedtofront, '', '', '', true) );
-
-
-
-////////////////////////////////////////////////////////////////////
-/// USER config variables
-////////////////////////////////////////////////////////////////////
- $user = array();
-
-/// sitepolicy
- $user['sitepolicy'] = new configvar (get_string('configsitepolicy', 'admin'),
- '<input type="text" name="sitepolicy" size="60" value="'.$config->sitepolicy.'" alt="sitepolicy" />' );
-
-
-/// fullnamedisplay
- unset($options);
- $options['language'] = get_string('language');
- $options['firstname lastname'] = get_string('firstname') . ' + ' . get_string('lastname');
- $options['lastname firstname'] = get_string('lastname') . ' + ' . get_string('firstname');
- $options['firstname'] = get_string('firstname');
-
- $user['fullnamedisplay'] = new configvar (get_string('configfullnamedisplay', 'admin'),
- choose_from_menu ($options, 'fullnamedisplay', $config->fullnamedisplay, '', '', '', true) );
-
-/// extendedusernamechars
- $user['extendedusernamechars'] = new configvar (get_string('configextendedusernamechars', 'admin'),
- choose_from_menu ($noyesoptions, 'extendedusernamechars', $config->extendedusernamechars, '', '', '', true) );
-
-/// autologinguests
- $user['autologinguests'] = new configvar (get_string('configautologinguests', 'admin'),
- choose_from_menu ($noyesoptions, 'autologinguests', $config->autologinguests, '', '', '', true) );
-
-/// hiddenuserfields
- $fields = array('none', 'description', 'city', 'country', 'webpage', 'icqnumber', 'skypeid', 'yahooid', 'aimid', 'msnid', 'lastaccess');
- if (empty($config->hiddenuserfields)) {
- $config->hiddenuserfields = 'none';
- }
- $configfields = array_flip(explode(',', $config->hiddenuserfields));
- $fieldoptions = '';
- foreach ($fields as $value) {
- $fieldoptions .= '<option value="'.$value.'"';
- if (isset($configfields[$value])) {
- $fieldoptions .= ' selected="selected"';
- }
- $fieldoptions .= '>'.get_string($value).'</option>';
- }
-
- $user['hiddenuserfields'] = new configvar (get_string('confighiddenuserfields', 'admin'),
- '<select id="menuhiddenuserfields" name="hiddenuserfields[]" size="10" multiple="multiple">'.$fieldoptions.'</select>' );
-
-
-
-
-////////////////////////////////////////////////////////////////////
-/// SECURITY config variables
-////////////////////////////////////////////////////////////////////
- $security = array();
-
-/// displayloginfailures
- unset($options);
- $options[''] = get_string('nobody');
- $options['admin'] = get_string('administrators');
- $options['teacher'] = get_string('administratorsandteachers');
- $options['everybody'] = get_string('everybody');
-
- $security['displayloginfailures'] = new configvar (get_string('configdisplayloginfailures', 'admin'),
- choose_from_menu($options, 'displayloginfailures', $config->displayloginfailures, '', '', '', true) );
-
-/// notifyloginfailures
- unset($options);
- $options[''] = get_string('nobody');
- $options['mainadmin'] = get_string('administrator');
- $options['alladmins'] = get_string('administratorsall');
-
- $security['notifyloginfailures'] = new configvar (get_string('confignotifyloginfailures', 'admin'),
- choose_from_menu($options, 'notifyloginfailures', $config->notifyloginfailures, '', '', '', true) );
-
-/// notifyloginthreshold
- unset($options);
- for ($i=1; $i<=100; $i++) {
- $options[$i] = "$i";
- }
-
- $security['notifyloginthreshold'] = new configvar (get_string('confignotifyloginthreshold', 'admin'),
- choose_from_menu($options, 'notifyloginthreshold', $config->notifyloginthreshold, '', '', '', true) );
-
-/// secureforms
- $security['secureforms'] = new configvar (get_string('configsecureforms', 'admin'),
- choose_from_menu ($noyesoptions, 'secureforms', $config->secureforms, '', '', '', true) );
-
-/// loginhttps
- $security['loginhttps'] = new configvar (get_string('configloginhttps', 'admin'),
- choose_from_menu ($noyesoptions, 'loginhttps', $config->loginhttps, '', '', '', true) );
-
-/// runclamonupload
- $security['runclamonupload'] = new configvar (get_string('configrunclamonupload', 'admin'),
- choose_from_menu($noyesoptions, 'runclamonupload', $config->runclamonupload, '', '', '', true) );
-
-/// pathtoclam
- $security['pathtoclam'] = new configvar (get_string('configpathtoclam', 'admin'),
- '<input type="text" name="pathtoclam" size="30" value="'.$config->pathtoclam.'" alt="pathtoclam" />' );
-
-/// quarantinedir
- $security['quarantinedir'] = new configvar (get_string('configquarantinedir', 'admin'),
- '<input type="text" name="quarantinedir" size="30" value="'.$config->quarantinedir.'" alt="quarantinedir" />' );
-
-/// clamfailureonupload
- unset($options);
- $options['donothing'] = get_string('configclamdonothing', 'admin');
- $options['actlikevirus'] = get_string('configclamactlikevirus', 'admin');
-
- $security['clamfailureonupload'] = new configvar (get_string('configclamfailureonupload', 'admin'),
- choose_from_menu($options, 'clamfailureonupload', $config->clamfailureonupload, '', '', '', true) );
-
-
-
-
-////////////////////////////////////////////////////////////////////
-/// MAINTENANCE config variables
-////////////////////////////////////////////////////////////////////
- $maintenance = array();
-
-/// longtimenosee
- unset($options);
- $options[0] = get_string('never');
- $options[1000] = get_string('numdays', '', 1000);
- $options[365] = get_string('numdays', '', 365);
- $options[180] = get_string('numdays', '', 180);
- $options[150] = get_string('numdays', '', 150);
- $options[120] = get_string('numdays', '', 120);
- $options[90] = get_string('numdays', '', 90);
- $options[60] = get_string('numdays', '', 60);
- $options[30] = get_string('numdays', '', 30);
- $options[21] = get_string('numdays', '', 21);
- $options[14] = get_string('numdays', '', 14);
- $options[7] = get_string('numdays', '', 7);
-
- $maintenance['longtimenosee'] = new configvar (get_string('configlongtimenosee', 'admin'),
- choose_from_menu ($options, 'longtimenosee', $config->longtimenosee, '', '', '', true) );
-
-/// deleteunconfirmed
- unset($options);
- $options[0] = get_string('never');
- $options[168] = get_string('numdays', '', 7);
- $options[144] = get_string('numdays', '', 6);
- $options[120] = get_string('numdays', '', 5);
- $options[96] = get_string('numdays', '', 4);
- $options[72] = get_string('numdays', '', 3);
- $options[48] = get_string('numdays', '', 2);
- $options[24] = get_string('numdays', '', 1);
- $options[12] = get_string('numhours', '', 12);
- $options[6] = get_string('numhours', '', 6);
- $options[1] = get_string('numhours', '', 1);
-
- $maintenance['deleteunconfirmed'] = new configvar (get_string('configdeleteunconfirmed', 'admin'),
- choose_from_menu ($options, 'deleteunconfirmed', $config->deleteunconfirmed, '', '', '', true) );
-
-/// loglifetime
- unset($options);
- $options[0] = get_string('neverdeletelogs');
- $options[1000] = get_string('numdays', '', 1000);
- $options[365] = get_string('numdays', '', 365);
- $options[180] = get_string('numdays', '', 180);
- $options[150] = get_string('numdays', '', 150);
- $options[120] = get_string('numdays', '', 120);
- $options[90] = get_string('numdays', '', 90);
- $options[60] = get_string('numdays', '', 60);
- $options[30] = get_string('numdays', '', 30);
-
- $maintenance['loglifetime'] = new configvar (get_string('configloglifetime', 'admin'),
- choose_from_menu ($options, 'loglifetime', $config->loglifetime, '', '', '', true) );
-
-
-////////////////////////////////////////////////////////////////////
-/// MAIL config variables
-////////////////////////////////////////////////////////////////////
- $mail = array();
-
-/// smtphosts
- $mail['smtphosts'] = new configvar (get_string('configsmtphosts', 'admin'),
- '<input name="smtphosts" type="text" size="30" value="'.s($config->smtphosts).'" alt="smtphosts" />' );
-
-/// smtpuser
- $mail['smtpuser'] = new configvar (get_string('configsmtpuser', 'admin'),
- '<input name="smtpuser" type="text" size="10" value="'.s($config->smtpuser).'" alt="smtpuser" />' );
-
-/// smtppass
- $mail['smtppass'] = new configvar ('',
- '<input name="smtppass" type="password" size="10" value="'.s($config->smtppass).'" alt="smtppass" />' );
-
-/// noreplyaddress
- $mail['noreplyaddress'] = new configvar (get_string('confignoreplyaddress', 'admin'),
- '<input name="noreplyaddress" type="text" size="30" value="'.s($config->noreplyaddress).'" alt="noreplyaddress" />' );
-
-/// digestmailtime
- $hours = array();
- for ($i=0; $i<=23; $i++) {
- $hours[$i] = sprintf("%02d",$i);
- }
-
- $mail['digestmailtime'] = new configvar (get_string('configdigestmailtime', 'admin'),
- choose_from_menu($hours, 'digestmailtime', $config->digestmailtime, '', '', 0, true) );
-
-/// allowemailaddresses
- $mail['allowemailaddresses'] = new configvar (get_string('configallowemailaddresses', 'admin'),
- '<input name="allowemailaddresses" type="text" size="60" value="'.s($config->allowemailaddresses).'" alt="allowemailaddresses" />' );
-
-/// denyemailaddresses
- $mail['denyemailaddresses'] = new configvar (get_string('configdenyemailaddresses', 'admin'),
- '<input name="denyemailaddresses" type="text" size="60" value="'.s($config->denyemailaddresses).'" alt="denyemailaddresses" />' );
-
- if (!empty($CFG->unicodedb)) { ///These options are only available if running under unicodedb
- /// sitemailcharset
- unset($options);
- unset($charsets);
- $charsets = get_list_of_charsets();
- $options['0'] = get_string('none');
- $options = array_merge($options, $charsets);
- $mail['sitemailcharset'] = new configvar (get_string('configsitemailcharset', 'admin'),
- choose_from_menu($options, 'sitemailcharset', $config->sitemailcharset, '', '', '', true));
-
- /// allowusermailcharset
- $mail['allowusermailcharset'] = new configvar (get_string('configallowusermailcharset', 'admin'),
- choose_from_menu($noyesoptions, 'allowusermailcharset', $config->allowusermailcharset, '', '', '', true));
- }
-
-/// enable stats
-if (empty($CFG->disablestatsprocessing)) {
- $stats['enablestats'] = new configvar (get_string('configenablestats','admin'),
- choose_from_menu($noyesoptions, 'enablestats', $config->enablestats, '', '', '', true) );
-
- unset($options);
- $options['none'] = get_string('none');
- $options[60*60*24*7] = get_string('numweeks','moodle',1);
- $options[60*60*24*14] = get_string('numweeks','moodle',2);
- $options[60*60*24*21] = get_string('numweeks','moodle',3);
- $options[60*60*24*28] = get_string('nummonths','moodle',1);
- $options[60*60*24*56] = get_string('nummonths','moodle',2);
- $options[60*60*24*84] = get_string('nummonths','moodle',3);
- $options[60*60*24*112] = get_string('nummonths','moodle',4);
- $options[60*60*24*140] = get_string('nummonths','moodle',5);
- $options[60*60*24*168] = get_string('nummonths','moodle',6);
- $options['all'] = get_string('all');
-
- $stats['statsfirstrun'] = new configvar (get_string('configstatsfirstrun','admin'),
- choose_from_menu($options,'statsfirstrun',$config->statsfirstrun,'','','',true) );
-
- unset($options);
- $options[0] = get_string('untilcomplete');
- $options[60*60] = '1 '.get_string('hour');
- $options[60*60*2] = '2 '.get_string('hours');
- $options[60*60*3] = '3 '.get_string('hours');
- $options[60*60*4] = '4 '.get_string('hours');
- $options[60*60*5] = '5 '.get_string('hours');
- $options[60*60*6] = '6 '.get_string('hours');
- $options[60*60*7] = '7 '.get_string('hours');
- $options[60*60*8] = '8 '.get_string('hours');
-
- if (empty($config->statsruntimestarthour)) {
- $config->statsruntimestarthour = 0;
- }
- if (empty($config->statsruntimestartminute)) {
- $config->statsruntimestartminute = 0;
- }
-
- $stats['statsmaxruntime'] = new configvar (get_string('configstatsmaxruntime','admin'),
- choose_from_menu($options,'statsmaxruntime',$config->statsmaxruntime,'','','',true) );
-
- $stats['statsruntimestart'] = new configvar (get_string('configstatsruntimestart','admin'),
- print_time_selector("statsruntimestarthour","statsruntimestartminute",make_timestamp(2000,1,1,$config->statsruntimestarthour,$config->statsruntimestartminute),5,true) );
-
- $stats['statsuserthreshold'] = new configvar (get_string('configstatsuserthreshold','admin'),
- '<input type="text" name="statsuserthreshold" size="4" value="'.$config->statsuserthreshold.'" />');
-}
-
-////////////////////////////////////////////////////////////////////
-
- $configvars['interface'] = $interface;
- $configvars['security'] = $security;
- $configvars['operatingsystem'] = $operatingsystem;
- $configvars['maintenance'] = $maintenance;
- $configvars['mail'] = $mail;
- $configvars['user'] = $user;
- $configvars['permissions'] = $permissions;
- $configvars['requestedcourse'] = $reqcourse;
- $configvars['misc'] = $misc;
-if (empty($CFG->disablestatsprocessing)) {
- $configvars['stats'] = $stats;
-}
-
-?>
View
4 admin/index.php
@@ -356,6 +356,10 @@
require_once("$CFG->dirroot/lib/locallib.php");
upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
+/// Check for new groups and upgrade if necessary. TODO:
+ require_once("$CFG->dirroot/group/db/upgrade.php");
+ upgrade_group_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
+
/// just make sure upgrade logging is properly terminated
upgrade_log_finish();
View
2  admin/roles/assign.php
@@ -224,7 +224,7 @@
/// In the .html file below we loop through these results and exclude any in $contextusers
echo '<div align="center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
- echo $strroletoassign.': ';
+ echo '<label for="jump">'.$strroletoassign.'</label>: ';
$assignableroles = array('0'=>get_string('listallroles', 'role').'...') + $assignableroles;
popup_form("$CFG->wwwroot/$CFG->admin/roles/assign.php?userid=$userid&amp;courseid=$courseid&amp;contextid=$contextid&amp;roleid=",
$assignableroles, 'switchrole', $roleid, '');
View
4 admin/uploaduser.php
@@ -304,8 +304,8 @@
if (!$course[$i]) {
notify(get_string('coursegroupunknown','error',$addgroup[$i]));
} else {
- if ($group = get_record("groups","courseid",$course[$i]->id,"name",$addgroup[$i])) {
- $groupid[$i] = $group->id;
+ if ($groupid = groups_get_group_by_name($course[$i]->id, $addgroup[$i])) { //TODO:check.
+ $groupid[$i] = $groupid;
} else {
notify(get_string('groupunknown','error',$addgroup[$i]));
}
View
70 admin/utfdbmigrate.html
@@ -1,70 +0,0 @@
-<?php
- if (!isset($form->dbhost)) {
- $form->dbhost = '';
- }
- if (!isset($form->dbname)) {
- $form->dbname = '';
- }
- if (!isset($form->dbuser)) {
- $form->dbuser = '';
- }
- if (!isset($form->dbpass)) {
- $form->dbpass = '';
- }
- if (!isset($form->dbcluster)) {
- $form->dbcluster = '';
- }
- if (!isset($form->pathtopgdump)) {
- $form->pathtopgdump = '';
- }
- if (!isset($form->pathtopsql)) {
- $form->pathtopsql = '';
- }
-?>
-<form name="migratefrom" action="utfdbmigrate.php" method="POST">
-<input name="migrate" type="hidden" value="1" />
-<input name="sesskey" type="hidden" value="<?php echo sesskey() ?>" />
-<?php if (isset($err["dbconnect"])) formerr($err["dbconnect"]); ?>
-<?php if (isset($err["pathtopgdump"])) formerr($err["pathtopgdump"]); ?>
-<?php if (isset($err["pathtopsql"])) formerr($err["pathtopsql"]); ?>
-<table cellpadding="9" cellspacing="0" width="500">
-<tr valign="top">
- <td align="right"><?php print_string("dbhost", "install") ?>:</td>
- <td><input type="text" name="dbhost" value="<?php p($form->dbhost) ?>" />
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><?php print_string("database", "install") ?>:</td>
- <td><input type="text" name="dbname" value="<?php p($form->dbname) ?>" />
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><?php print_string("user") ?>:</td>
- <td><input type="text" name="dbuser" value="<?php p($form->dbuser) ?>" />
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><?php print_string("password") ?>:</td>
- <td><input type="text" name="dbpass" value="<?php p($form->dbpass) ?>" />
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><?php print_string("pgcluster", "admin") ?>:</td>
- <td><input type="text" name="dbcluster" value="<?php p($form->dbcluster) ?>" />
- <td><?php print_string("pgclusterdescription", "admin") ?></td>
-</tr>
-<tr valign="top">
- <td align="right" nowrap="nowrap"><?php print_string("pathtopgdump","admin") ?>:</td>
- <td><input type="text" name="pathtopgdump" value="<?php p($form->pathtopgdump) ?>" />
- <td><?php print_string("pathtopgdumpdesc","admin"); ?></td>
-</tr>
-<tr valign="top">
- <td align="right" nowrap="nowrap"><?php print_string("pathtopsql","admin") ?>:</td>
- <td><input type="text" name="pathtopsql" value="<?php p($form->pathtopsql) ?>" />
- <td><?php print_string("pathtopsqldesc","admin"); ?></td>
-</tr>
-</table>
-<center>
-<input type="submit" value="<?php print_string('continue') ?>"/>
-&nbsp;<input type="button" value="<?php print_string('cancel') ?>" onclick="javascript:history.go(-1)" />
-</center>
View
1,238 admin/utfdbmigrate.php
@@ -1,1238 +0,0 @@
-<?php //$Id$
-
-///dummy field names are used to help adding and dropping indexes. There's only 1 case now, in scorm_scoes_track
-//testing
- require_once('../config.php');
- require_once($CFG->libdir.'/adminlib.php');
- require_once($CFG->libdir.'/environmentlib.php');
- require_once($CFG->dirroot.'/course/lib.php');
- require_once($CFG->libdir.'/ddllib.php'); //We are going to need DDL services here
- require_once($CFG->dirroot.'/backup/lib.php'); //We are going to need BACKUP services here
- define ('BACKUP_UNIQUE_CODE', '1100110011'); //One code in the past to store UTF8 temp indexes info
- require_login();
-
- // declare once
- global $enc;
-
- $customlang = array();
-
- $enc = array('af' => 'iso-8859-1', 'ar' => 'windows-1256', 'be' => 'windows-1251', 'bg' => 'windows-1251', 'bs' => 'windows-1250', 'ca' => 'iso-8859-1', 'cs' => 'iso-8859-2', 'da' => 'iso-8859-1', 'de' => 'iso-8859-1', 'de_du' => 'iso-8859-1', 'de_utf8' => 'utf-8', 'el' => 'windows-1253', 'en' => 'iso-8859-1', 'en_ja' => 'euc-jp', 'en_us' => 'iso-8859-1', 'en_utf8' => 'utf-8', 'es' => 'iso-8859-1', 'es_ar' => 'iso-8859-1', 'es_es' => 'iso-8859-1', 'es_mx' => 'iso-8859-1', 'et' => 'iso-8859-1', 'eu' => 'iso-8859-1', 'fa' => 'windows-1256', 'fa_utf8' => 'utf-8', 'fi' => 'iso-8859-1', 'fil' => 'iso-8859-15', 'fr' => 'iso-8859-1', 'fr_ca' => 'iso-8859-15', 'ga' => 'iso-8859-1', 'gl' => 'iso-8859-1', 'he' => 'ISO-8859-8-I', 'he_utf8' => 'utf-8', 'hi' => 'iso-8859-1', 'hr' => 'windows-1250', 'hr_utf8' => 'utf-8', 'hu' => 'iso-8859-2', 'id' => 'iso-8859-1', 'is' => 'iso-8859-1', 'it' => 'iso-8859-1', 'ja' => 'EUC-JP', 'ja_utf8' => 'UTF-8', 'ka_utf8' => 'UTF-8', 'km_utf8' => 'UTF-8', 'kn_utf8' => 'utf-8', 'ko' => 'EUC-KR', 'ko_utf8' => 'UTF-8', 'lt' => 'windows-1257', 'lv' => 'ISO-8859-4', 'mi_nt' => 'iso-8859-1', 'mi_tn_utf8' => 'utf-8', 'ms' => 'iso-8859-1', 'nl' => 'iso-8859-1', 'nn' => 'iso-8859-1', 'no' => 'iso-8859-1', 'no_gr' => 'iso-8859-1', 'pl' => 'iso-8859-2', 'pt' => 'iso-8859-1', 'pt_br' => 'iso-8859-1', 'ro' => 'iso-8859-2', 'ru' => 'windows-1251', 'sk' => 'iso-8859-2', 'sl' => 'iso-8859-2', 'sl_utf8' => 'utf-8', 'so' => 'iso-8859-1', 'sq' => 'iso-8859-1', 'sr_utf8' => 'utf-8', 'sv' => 'iso-8859-1', 'th' => 'TIS-620', 'th_utf8' => 'UTF-8', 'tl' => 'iso-8859-15', 'tl_utf8' => 'UTF-8', 'tr' => 'iso-8859-9', 'uk' => 'windows-1251', 'vi_utf8' => 'UTF-8', 'zh_cn' => 'GB18030', 'zh_cn_utf8' => 'UTF-8', 'zh_tw' => 'Big5', 'zh_tw_utf8' => 'UTF-8');
-
- /**************************************
- * Custom lang pack handling *
- **************************************/
-
- // scan list of langs, including customs packs
- $langs = get_list_of_languages();
-
- // foreach lang
- foreach ($langs as $lang => $lang1) {
-
- if (in_array($lang, array_keys($enc))) {
- // if already in array, ignore
- continue;
- }
-
- // if this lang has got a charset
-
- if ($result = get_string_from_file('thischarset',$CFG->dirroot.'/lang/'.$lang.'/moodle.php', "\$resultstring")) {
- eval($result);
- $enc[$lang] = $resultstring;
- } else if ($result = get_string_from_file('parentlanguage',$CFG->dirroot.'/lang/'.$lang.'/moodle.php',"\$resultstring")) {
- // else if there's a parent lang we can use
- eval($result);
- $enc[$lang] = $enc[$resultstring];
- } else {
- notify ('unknown lang pack detected '.$lang);
- }
-
- }
-
- /**************************************
- * End custom lang pack handling *
- **************************************/
-
- require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
-
- if (!$site = get_site()) {
- redirect('index.php');
- }
-
- if (!empty($CFG->unicodedb)) {
- error ('unicode db migration has already been performed!');
- }
-
- $migrate = optional_param('migrate', 0, PARAM_BOOL);
- $confirm = optional_param('confirm', 0, PARAM_BOOL);
-
- $textlib = textlib_get_instance();
-
- $stradministration = get_string('administration');
- $strdbmigrate = get_string('dbmigrate','admin');
-
- $filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html'; //maintenance file
-
- print_header("$site->shortname: $stradministration", "$site->fullname",
- '<a href="index.php">'. "$stradministration</a> -> $strdbmigrate");
-
- print_heading($strdbmigrate);
-
- if ($CFG->dbtype == 'postgres7') {
- $CFG->pagepath = 'admin/utfdbmigrate/postgresql';
- }
- //if $confirm
- if ($confirm && confirm_sesskey()) {
- //do the real migration of db
- print_simple_box_start('center','50%');
- print_string('importlangreminder','admin');
- print_simple_box_end();
- db_migrate2utf8();
- print_heading('db unicode migration has been completed!');
- if (!get_config('', 'migrate_maintmode')) { // already in maint mode
- unlink($filename); //no longer in maintenance mode
- }
- unset_config('migrate_maintmode');
- @require_logout();
- print_continue($CFG->wwwroot.'/'.$CFG->admin.'/langimport.php');
- }
-
- //else if $migrate
- else if ($migrate && confirm_sesskey()) {
- if ($CFG->dbtype == 'postgres7' && !is_postgres_utf8()) {
- $continue = false;
- if (($form = data_submitted()) && isset($form->dbhost)) {
- validate_form($form, $err);
-
- if (count($err) == 0) {
- $_SESSION['newpostgresdb'] = $form;
- $continue = true;
- }
- }
- } else {
- $continue = true;
- }
- if ($continue) {
- echo '<div align="center">';
- print_simple_box_start('center','50%');
- print_string('dbmigratewarning2','admin');
- print_simple_box_end();
- //put the site in maintenance mode
- check_dir_exists($CFG->dataroot.'/'.SITEID, true);
-
- if (file_exists($filename)) {
- set_config('migrate_maintmode', 1); // already in maintenance mode
- } else {
- if (touch($filename)) {
- $file = fopen($filename, 'w');
- fwrite($file, get_string('maintinprogress','admin'));
- fclose($file);
- } else {
- notify (get_string('maintfileopenerror','admin'));
- }
- }
- //print second confirmation box
- echo '<form name="migratefrom" action="utfdbmigrate.php" method="POST">';
- echo '<input name="confirm" type="hidden" value="1" />';
- echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
-
- $xmls = utf_get_xml();
- $sumrecords = 0; //this is the sum of all records of relavent tables.
- foreach ($xmls as $xml) { ///foreach xml file, we must get a list of tables
- $dbtables = $xml['DBMIGRATION']['#']['TABLES'][0]['#']['TABLE']; //real db tables
-
- foreach ($dbtables as $dbtable) {
- $dbtablename = $dbtable['@']['name'];
-
- if ($dbtablename=='adodb_logsql') {
- $prefix = '';
- } else {
- $prefix = $CFG->prefix;
- }
- $sumrecords += count_records_sql("SELECT COUNT(*) FROM {$prefix}$dbtablename");
- }
- }
- echo 'Total number of records in your database is <b>'.$sumrecords.'</b>';
- if ($sumrecords > 10000) {
- echo '<br />Number of Records to process before halting (Leave blank for no limit) <input name="maxrecords" type="text" value="" />';
- }
-
- //print the "i-know-what-lang-to-use" menu
-
- echo '<br />The whole site is in this encoding: (leave blank if you are not sure)';
- echo '<select name="globallang"><option value="">I am not sure</option>';
- foreach ($enc as $lang => $encoding) {
- echo '<option value="'.$encoding.'">'.$lang.'</option>';
- }
- echo '</select>';
-
- echo '<p /><input type="submit" value="'.get_string('continue').'"/>';
- echo '<input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
- echo '</form>';
- echo '</div>';
-
- } else {
- echo '<div align="center">';
- print_simple_box_start('center','50%');
- print_string('dbmigratepostgres','admin');
- print_simple_box_end();
-
- print_simple_box_start("center", "");
- include("utfdbmigrate.html");
- print_simple_box_end();
- }
- }
-
- else { //else, print welcome to migrate page message
- echo '<div align="center">';
- print_simple_box_start('center','50%');
- print_string('dbmigratewarning','admin');
- print_simple_box_end();
-
- /*************************************
- * Eloy's environement checking code *
- *************************************/
-
- $current_version = $CFG->release;
-
- /// Gather and show results
- $status = check_moodle_environment($current_version, $environment_results);
-
- //end of env checking
-
- /// We only allow to continue if environmental checks have been passed ok
- if ($status) {
- echo '<form name="migratefrom" action="utfdbmigrate.php" method="POST">';
- echo '<input name="migrate" type="hidden" value="1" />';
- echo '<input name="sesskey" type="hidden" value="'.sesskey().'" />';
- echo '<input type="submit" value="'.get_string('continue').'"/>';
- echo '&nbsp;<input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1)" />';
- echo '</form>';
- echo '</div>';
- }
- }
-
- print_footer();
-
-
-function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
- //pointing to the num of records to process would be
- //useful. And it won't break anything, because the
- //crash system will continue the next time it was
- //executed. Also, the function could return:
- //0 = Some sort of error
- //1 = Finished completelly!
- //2 = Finished limit records
- //(using constants, of course ;-))
- //Then, all those errors, should be converted to
- //mtrace() and return 0. (showing the current
- //table/field/recordid)
-
- global $db, $CFG, $dbtablename, $fieldname, $record, $processedrecords;
- $debug = debugging();
-
- if ($CFG->dbtype == 'mysql') {
- check_and_create_backup_dir(BACKUP_UNIQUE_CODE); //Create the backup temp dir
- }
-
- ignore_user_abort(false); // see bug report 5352. This should kill this thread as soon as user aborts.
-
- @set_time_limit(0);
- @ob_implicit_flush(true);
- @ob_end_flush();
-
- $maxrecords = optional_param('maxrecords', 0, PARAM_INT);
- $globallang = optional_param('globallang', '', PARAM_FILE);
- $processedrecords = 0;
-
- $ignoretables = array(); //list of tables to ignore, optional
-
- //one gigantic array to hold all db table information read from all the migrate2utf8.xml file.
- require_once($CFG->dirroot.'/lib/xmlize.php');
- $xmls = utf_get_xml(1);
- $tablestoconvert = 0; // total number of tables to convert
- foreach ($xmls as $xml) { ///foreach xml file, we must get a list of tables
- $dbtables = $xml['DBMIGRATION']['#']['TABLES'][0]['#']['TABLE']; //real db tables
- foreach ($dbtables as $dbtable) {
- $tablestoconvert++;
- }
- }
- // progress bar handling
- // first let's find out how many tables there are
-
- $done = 0;
- print_progress($done, $tablestoconvert, 5, 1);
-
-
- $textlib = textlib_get_instance(); //only 1 reference
-
- //if unicodedb is set, migration is complete. die here;
- if (!$crash = get_record('config','name','dbmigration')) {
- //Duplicate the database if not unicode for postgres7
- if ($CFG->dbtype == 'postgres7' && !is_postgres_utf8() && !is_postgres_setup()) {
- echo '<script>';
- echo 'document.getElementById("text").innerHTML = "Copying data to the UTF8 database for processing...";'."\n";
- echo '</script>';
-
- if ($_SESSION['newpostgresdb']->dbcluster) {
- $cluster = ' --cluster ' . $_SESSION['newpostgresdb']->dbcluster;
- } else {
- $cluster = '';
- }
- $pgdump = 'pg_dump';
- if (!empty($_SESSION['newpostgresdb']->pathtopgdump)) {
- $pgdump = $_SESSION['newpostgresdb']->pathtopgdump;
- }
- $psql = 'psql';
- if (!empty($_SESSION['newpostgresdb']->pathtopsql)) {
- $pgsql = $_SESSION['newpostgresdb']->pathtopsql;
- }
-
- $cmd = "PGPASSWORD={$CFG->dbpass} PGCLIENTENCODING='UNICODE' PGDATABASE={$CFG->dbname} $pgdump -Fp -O -x -U {$CFG->dbuser}$cluster";
- if ($CFG->dbhost) {
- $host = split(":", $CFG->dbhost);
- if ($host[0]) $cmd .= " -h {$host[0]}";
- if (isset($host[1])) $cmd .= " -p {$host[1]}";
- }
- $cmds[] = $cmd;
- $cmds[] = 'grep -v "COMMENT ON SCHEMA"';
- $cmds[] = 'iconv -f UTF-8 -t UTF-8 -c';
- $cmd = "PGPASSWORD={$_SESSION['newpostgresdb']->dbpass} PGDATABASE={$_SESSION['newpostgresdb']->dbname} $psql -q -U {$_SESSION['newpostgresdb']->dbuser} -v ON_ERROR_STOP=1$cluster";
- if ($_SESSION['newpostgresdb']->dbhost) {
- $host = split(":", $_SESSION['newpostgresdb']->dbhost);
- if ($host[0]) $cmd .= " -h {$host[0]}";
- if (isset($host[1])) $cmd .= " -p {$host[1]}";
- }
- $cmds[] = $cmd;
- foreach ($cmds as $key => $cmd) {
- $files[] = tempnam($CFG->dataroot, 'utf8_');
- $cmd = $cmd . ($key?" < {$files[$key-1]}":'') . " 2>&1 > {$files[$key]}";
- if (stripos(PHP_OS, 'darwin') !== false && stripos($cmd,'iconv') !== false) {
- // I know this looks DREADFULLY hackish, but the iconv in mac os x seems to have a return code of 1 for warnings
- // and I cannot figure out why, it's a very different version of iconv to most *nix versions, even seems to be a
- // different gnu project.
- // If someone can figure out a better way to do this, FEEL FREE :)
- // - Penny
- $cmd .= ' || true';
- }
- exec($cmd, $output, $return_var);
- if ($key) {
- unlink($files[$key-1]);
- }
- if ($return_var) { // we are dead!
- unlink($files[$key]);
- echo '<br />';
- print_simple_box_start('center','50%');
- print_string('dbmigrationdupfailed','admin',htmlspecialchars(implode("\n", $output)));
- print_simple_box_end();
- print_footer();
- exit;
- }
- }
- unlink(array_pop($files));
- }
-
- $migrationconfig = new object;
- $migrationconfig->name = 'dbmigration';
- $migrationconfig->value = '-1';
- insert_record('config',$migrationconfig); //process initiated
-
- //langs used, to help make recommendations on what lang packs to install
- $langsused = new object;
- $langsused->name = 'langsused';
- $langsused->value = '';
- insert_record('config',$langsused);
-
- } else {
-
- $crashdata = explode('##',$crash->value);
- $crash->table = $crashdata[0];
- $crash->field = $crashdata[1];
- $crash->record = $crashdata[2];
-
- notify("Resuming migration from: $crash->table / .$crash->field, Record: $crash->record");
- }
-
- /************************************************************************
- * Now we got all our tables in order *
- ************************************************************************/
-
- foreach ($xmls as $xml) { ///foreach xml file, we must get a list of tables
- $dir = $xml['DBMIGRATION']['@']['type'];
- $dbtables = $xml['DBMIGRATION']['#']['TABLES'][0]['#']['TABLE']; //real db tables
-
- foreach ($dbtables as $dbtable) {
-
- $done++;
- print_progress($done, $tablestoconvert, 5, 1);
-
- $dbtablename = $dbtable['@']['name'];
-
- // exception handling for adodb_logsql
- // see bug 5003
- if ($dbtablename == 'adodb_logsql') {
- $prefix = '';
- } else {
- $prefix = $CFG->prefix;
- }
-
- if ($crash && ($dbtablename != $crash->table)) { //resuming from crash
- $done++; // need to update progress bar
- continue;
- }
-
- if ($debug) {
- print_heading("<br><b>Processsing db table ".$dbtablename.'...</b>');
- }
-
- /* Insted of relying in the indexes defined for the table in utfmigrate.xml
- files, we are going to use the MetaIndexes() DB call in order to detect
- all the table indexes. Once fetched, they are saved in backup tables for
- safe storage and they are dropped from the table.
- At the end of the table, we'll fetch them from backup tables and all them
- will be recreated again.
- This will ensure that no index in lost in the UTF8 migration process and
- they will be exactly the same for each server (custom indexes...)
- Also this will leave free to keep the utfmigrate.xml files in sync for
- all the existing indexes and we only have to maintain fields in such
- files
- */
-
- /// Calculate all the indexes of the table
- if ($CFG->dbtype == 'mysql' && $allindexes = $db->MetaIndexes($prefix.$dbtablename)) {
- /// Send them to backup_ids table for temporal storage if crash
- backup_putid(BACKUP_UNIQUE_CODE, $prefix.$dbtablename, 1, 1, $allindexes);
- /// Drop all the indexes
- $sqlarr = array();
- foreach ($allindexes as $onekey => $oneindex) {
- $sqlarr[] = 'ALTER TABLE '.$prefix.$dbtablename.' DROP INDEX '.$onekey;
- }
- execute_sql_arr($sqlarr, true, $debug);
- }
-
- /**********************************************************
- * This is the by pass structure. It allows us to process *
- * tables on row basis instead of column/field basis *
- * It relies on a single function in migrate2utf8.php *
- **********************************************************/
-
- /// first, check to see if there's a function for the whole table. By pass point (1)
- if (file_exists($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php')) {
- require_once($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php');
- // this is a function to process table on role basis, e.g. user table in moodorg
- $tablefunction = 'migrate2utf8_'.$dbtablename;
- }
- if ($CFG->dbtype=='mysql' && function_exists($tablefunction)) {
- $tablefunction($dbtable['#']['FIELDS'][0]['#']['FIELD'], $crash, $debug, $maxrecords, $done, $tablestoconvert); // execute it.
- } else {
-
- /******************************************************
- * No function for converting whole table, we proceed *
- ******************************************************/
-
- if (!empty($dbtable['#']) && ($fields = $dbtable['#']['FIELDS'][0]['#']['FIELD']) and (!in_array($dbtablename, $ignoretables))) {
-
- $colnames = array();
- $coltypes = array(); //array to hold all column types for the table
- $collengths = array(); //array to hold all column lengths for the table
- $defaults = array(); //array to hold defaults, if any
- //reset holders
- $addindexarray = array();
- $adduniqueindexarray = array();
- $addprimaryarray = array();
-
- foreach ($fields as $field){
-
- //if in crash state, and field name is not the same as crash field name
-
- $fieldname = isset($field['@']['name'])?$field['@']['name']:"";
- $method = isset($field['@']['method'])?$field['@']['method']:"";
- $type = isset($field['@']['type'])?$field['@']['type']:"";
- $length = isset($field['@']['length'])?$field['@']['length']:"";
-
- if ($crash && ($crash->field != $fieldname)) {
- continue;
- }
-
- $dropindex = isset($field['@']['dropindex'])?$field['@']['dropindex']:"";
- $addindex = isset($field['@']['addindex'])?$field['@']['addindex']:"";
- $adduniqueindex = isset($field['@']['adduniqueindex'])?$field['@']['adduniqueindex']:"";
-
- $dropprimary = isset($field['@']['dropprimary'])?$field['@']['dropprimary']:"";
- $addprimary = isset($field['@']['addprimary'])?$field['@']['addprimary']:"";
- $default = isset($field['@']['default'])?"'".$field['@']['default']."'":"''";
-
- if ($fieldname != 'dummy') {
- $colnames[] = $fieldname;
- $coltypes[] = $type;
- $collengths[]= $length;
- }
-
- if ($debug) {
- echo "<br>--><b>processing db field ".$fieldname.'</b>';
- echo "<br>---><b>method ".$method.'</b>';
- }
-
-
- if ($CFG->dbtype == 'mysql') {
-
- /* Drop the index, because with index on, you can't change it to longblob
-
- NOTE: We aren't going to drop individual indexes anymore, because we have
- dropped them at the begining of the table iteration, saving them to
- backup temp tables. At the end of the table iteration we are going
- to rebuild them back
-
- if ($dropindex){ //drop index if index is varchar, text etc type
- $SQL = 'ALTER TABLE '.$prefix.$dbtablename.' DROP INDEX '.$dropindex.';';
- $SQL1 = 'ALTER TABLE '.$prefix.$dbtablename.' DROP INDEX '.$CFG->prefix.$dropindex.';'; // see bug 5205
- if ($debug) {
- $db->debug=999;
- }
-
- execute_sql($SQL, false); // see bug 5205
- execute_sql($SQL1, false); // see bug 5205
-
- if ($debug) {
- $db->debug=0;
- }
- } else */
- if ($dropprimary) { // drop primary key
- $SQL = 'ALTER TABLE '.$prefix.$dbtablename.' DROP PRIMARY KEY;';
- if ($debug) {
- $db->debug=999;
- }
- execute_sql($SQL, $debug);
- if ($debug) {
- $db->debug=0;
- }
- }
-
- /* Previously to change the field to LONGBLOB, we are going to
- use Meta info to fetch the NULL/NOT NULL status of the field.
- Then, when converting back the field to its final UTF8 status
- we'll apply such status (and default)
- This has been added on 1.7 because we are in the process of
- converting some fields to NULL and the assumption of all the
- CHAR/TEXT fields being always NOT NULL isn't valid anymore!
- Note that this code will leave remaining NOT NULL fiels
- unmodified at all, folowing the old approach
- */
- if(($cols = $db->MetaColumns($prefix.$dbtablename)) && $fieldname != 'dummy') {
- $cols = array_change_key_case($cols, CASE_LOWER); ///lowercase col names
- $notnull = 'NOT NULL'; ///Old default
- if ($col = $cols[strtolower($fieldname)]) {
- /// If the column was null before UTF-8 migration, save it
- if (!$col->not_null) {
- $notnull = 'NULL';
- /// And, if the column had an empty string as default, make it NULL now
- if ($default == "''") {
- $default = 'NULL';
- }
- }
- }
- }
-
- /* Change to longblob, serves 2 purposes:
- 1. column loses encoding, so when we finally change it to unicode,
- mysql does not do a double convertion
- 2. longblobs puts no limit (ok, not really but it's large enough)
- to handle most of the problems such as in bug 5194
- */
-
- $SQL = 'ALTER TABLE '.$prefix.$dbtablename;
- $SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' LONGBLOB';
-
- /*
- if ($length > 0) {
- $SQL.='('.$length.') ';
- }
- $SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';';
- */
- if ($debug) {
- $db->debug=999;
- }
- if ($fieldname != 'dummy') {
- execute_sql($SQL, $debug);
- }
- if ($debug) {
- $db->debug=0;
- }
-
- }
-
- $patterns[]='/RECORDID/'; //for preg_replace
- $patterns[]='/\{\$CFG\-\>prefix\}/i'; //same here
-
- if ($method == 'PLAIN_SQL_UPDATE') {
- $sqldetectuser = $field['#']['SQL_DETECT_USER'][0]['#'];
- $sqldetectcourse = $field['#']['SQL_DETECT_COURSE'][0]['#'];
- }
- else if ($method == 'PHP_FUNCTION') {
- $phpfunction = 'migrate2utf8_'.$dbtablename.'_'.$fieldname;
- }
-
- ///get the total number of records for this field
-
- // could not use count_records because it addes prefix to adodb_logsql
- $totalrecords = count_records_sql("select count(*) from {$prefix}$dbtablename");
- $counter = 0;
- $recordsetsize = 50;
-
- if ($crash) { //if resuming from crash
- //find the number of records with id smaller than the crash id
- $indexSQL = 'SELECT COUNT(*) FROM '.$prefix.$dbtablename.' WHERE id < '.$crash->record;
- $counter = count_records_sql($indexSQL);
- }
-
- if ($debug) {
- echo "<br>Total number of records is ..".$totalrecords;
- echo "<br/>Counter is $counter";
- }
-
-
- /**************************
- * converting each record *
- **************************/
- while(($counter < $totalrecords) and ($fieldname !='dummy') and ($method!='NO_CONV')) { //while there is still something
- $SQL = 'SELECT * FROM '.$prefix.$dbtablename.' ORDER BY id ASC';
- if ($records = get_records_sql($SQL, $counter, $recordsetsize)) {
- foreach ($records as $record) {
-
- //if we are up this far, either no crash, or crash with same table, field name.
- if ($crash){
- if ($crash->record != $record->id) { //might set to < just in case record is deleted
- continue;
- } else {
- $crash = 0;
- }
- }
-
- $migrationconfig = get_record('config','name','dbmigration');
- $migrationconfig->name = 'dbmigration';
- $migrationconfig->value = $dbtablename.'##'.$fieldname.'##'.$record->id;
- update_record('config',$migrationconfig);
-
- $replacements = array(); //manual refresh
- $replacements[] = $record->id;
- $replacements[] = $prefix;
-
- if (!empty($record->{$fieldname})) { //only update if not empty
- switch ($method){
- case 'PLAIN_SQL_UPDATE': //use the 2 statements to update
-
- if ($debug) {
- $db->debug=999;
- }
-
- //if global lang is set, we just use that
-
- if ($globallang) {
- $fromenc = $globallang;
- } else {
- $userid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectuser));
- $courseid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectcourse));
-
- $sitelang = $CFG->lang;
- $courselang = get_course_lang(isset($courseid->course)?$courseid->course:1);
- $userlang = get_user_lang(isset($userid->userid)?$userid->userid:1);
-
- $fromenc = get_original_encoding($sitelang, $courselang, $userlang);
- }
-
- //only update if non utf8
- if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
- $result = utfconvert($record->{$fieldname}, $fromenc);
- $newrecord = new object;
- $newrecord->id = $record->id;
- $newrecord->{$fieldname} = $result;
- migrate2utf8_update_record($dbtablename,$newrecord);
- }
- if ($debug) {
- $db->debug=0;
- }
- break;
-
- case 'PHP_FUNCTION': //use the default php function to execute
- if ($debug) {
- $db->debug=999;
- }
- require_once($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php');
- $phpfunction($record->id);
- if ($debug) {
- $db->debug=0;
- }
- break;
-
- default: //no_conv, don't do anything ;-)
- break;
- }
- }
- $counter++;
- if ($maxrecords) {
- if ($processedrecords == $maxrecords) {
- notify($maxrecords.' records processed. Migration Process halted');
- print_continue('utfdbmigrate.php?confirm=1&amp;maxrecords='.$maxrecords.'&amp;sesskey='.sesskey());
- print_footer();
- die();
- }
- }
-
- $processedrecords++;
- //print some output once in a while
- if (($processedrecords) % 1000 == 0) {
- print_progress($done, $tablestoconvert, 5, 1,
- 'Processing: '.$dbtablename.'/'.$fieldname.' ');
- }
- }
- }else {
- if ($debug) {
- notify('no records found!');
- }
- }
- } //close the while loop
-
- /********************