Merge branch 'MDL-32119' of git://github.com/srynot4sale/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 9 Jul 2012 04:01:54 +0000 (16:01 +1200)
committerSam Hemelryk <sam@moodle.com>
Mon, 9 Jul 2012 04:02:49 +0000 (16:02 +1200)
Conflicts:
lib/db/upgrade.php
version.php

1  2 
backup/moodle2/backup_stepslib.php
backup/moodle2/restore_stepslib.php
lib/db/install.xml
lib/db/upgrade.php
version.php

Simple merge
Simple merge
          <INDEX NAME="userid" UNIQUE="false" FIELDS="userid" NEXT="course"/>
          <INDEX NAME="course" UNIQUE="false" FIELDS="course" PREVIOUS="userid" NEXT="criteriaid"/>
          <INDEX NAME="criteriaid" UNIQUE="false" FIELDS="criteriaid" PREVIOUS="course" NEXT="timecompleted"/>
 -        <INDEX NAME="timecompleted" UNIQUE="false" FIELDS="timecompleted" PREVIOUS="criteriaid"/>
 +        <INDEX NAME="timecompleted" UNIQUE="false" FIELDS="timecompleted" PREVIOUS="criteriaid" NEXT="useridcoursecriteriaid"/>
 +        <INDEX NAME="useridcoursecriteriaid" UNIQUE="true" FIELDS="userid, course, criteriaid" PREVIOUS="timecompleted"/>
        </INDEXES>
      </TABLE>
-     <TABLE NAME="course_completion_notify" COMMENT="Course completion notification emails" PREVIOUS="course_completion_crit_compl" NEXT="course_completions">
-       <FIELDS>
-         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="course"/>
-         <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="role"/>
-         <FIELD NAME="role" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="ID of the role to receive this notification message when a course has been completed" PREVIOUS="course" NEXT="message"/>
-         <FIELD NAME="message" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="HTML formatted message to be sent" PREVIOUS="role" NEXT="timesent"/>
-         <FIELD NAME="timesent" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="message"/>
-       </FIELDS>
-       <KEYS>
-         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
-       </KEYS>
-       <INDEXES>
-         <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
-       </INDEXES>
-     </TABLE>
-     <TABLE NAME="course_completions" COMMENT="Course completion records" PREVIOUS="course_completion_notify" NEXT="enrol">
+     <TABLE NAME="course_completions" COMMENT="Course completion records" PREVIOUS="course_completion_crit_compl" NEXT="enrol">
        <FIELDS>
          <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="userid"/>
          <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="course"/>
@@@ -843,111 -660,31 +843,164 @@@ function xmldb_main_upgrade($oldversion
              $dbman->drop_field($table, $field);
          }
  
-         if ($dbman->table_exists($table)) {
-             $dbman->drop_table($table);
 +        // Main savepoint reached
 +        upgrade_main_savepoint(true, 2012061800.01);
 +    }
 +
 +    if ($oldversion < 2012062000.00) {
 +        // Add field newcontextid to backup_files_template
 +        $table = new xmldb_table('backup_files_template');
 +        $field = new xmldb_field('newcontextid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'info');
 +
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
 +
 +        upgrade_main_savepoint(true, 2012062000.00);
 +    }
 +
 +    if ($oldversion < 2012062000.01) {
 +        // Add field newitemid to backup_files_template
 +        $table = new xmldb_table('backup_files_template');
 +        $field = new xmldb_field('newitemid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'newcontextid');
 +
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
 +
 +        upgrade_main_savepoint(true, 2012062000.01);
 +    }
 +
 +
 +    // Moodle v2.3.0 release upgrade line
 +    // Put any upgrade step following this
 +
 +
 +    if ($oldversion < 2012062500.02) {
 +        // Drop some old backup tables, not used anymore
 +
 +        // Define table backup_files to be dropped
 +        $table = new xmldb_table('backup_files');
 +
 +        // Conditionally launch drop table for backup_files
 +        if ($dbman->table_exists($table)) {
 +            $dbman->drop_table($table);
 +        }
 +
 +        // Define table backup_ids to be dropped
 +        $table = new xmldb_table('backup_ids');
 +
 +        // Conditionally launch drop table for backup_ids
+         // Conditionally launch drop field deleted from course_completion_crit_compl
+         if ($dbman->field_exists($table2, $field)) {
+             $dbman->drop_field($table2, $field);
          }
  
 -        if ($dbman->table_exists($table)) {
 -            $dbman->drop_table($table);
+         // Drop unused table "course_completion_notify"
+         $table = new xmldb_table('course_completion_notify');
+         // Conditionally launch drop table course_completion_notify
 +        // Main savepoint reached
 +        upgrade_main_savepoint(true, 2012062500.02);
 +    }
 +
 +    if ($oldversion < 2012062500.04) {
 +        // Define table course_modules_avail_fields to be created
 +        $table = new xmldb_table('course_modules_avail_fields');
 +
 +        // Adding fields to table course_modules_avail_fields
 +        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
 +        $table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
 +        $table->add_field('userfield', XMLDB_TYPE_CHAR, '50', null, null, null, null);
 +        $table->add_field('customfieldid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
 +        $table->add_field('operator', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
 +        $table->add_field('value', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
 +
 +        // Adding keys to table course_modules_avail_fields
 +        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
 +        $table->add_key('coursemoduleid', XMLDB_KEY_FOREIGN, array('coursemoduleid'), 'course_modules', array('id'));
 +
 +        // Conditionally launch create table for course_modules_avail_fields
 +        if (!$dbman->table_exists($table)) {
 +            $dbman->create_table($table);
          }
  
 -        // Drop "timenotified" field from course_completions
 +        // Main savepoint reached
 +        upgrade_main_savepoint(true, 2012062500.04);
 +    }
 +
 +    if ($oldversion < 2012062500.05) {
 +        // Define table course_sections_avail_fields to be created
 +        $table = new xmldb_table('course_sections_avail_fields');
 +
 +        // Adding fields to table course_sections_avail_fields
 +        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
 +        $table->add_field('coursesectionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
 +        $table->add_field('userfield', XMLDB_TYPE_CHAR, '50', null, null, null, null);
 +        $table->add_field('customfieldid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
 +        $table->add_field('operator', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
 +        $table->add_field('value', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
 +
 +        // Adding keys to table course_sections_avail_fields
 +        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
 +        $table->add_key('coursesectionid', XMLDB_KEY_FOREIGN, array('coursesectionid'), 'course_sections', array('id'));
 +
 +        // Conditionally launch create table for course_sections_avail_fields
 +        if (!$dbman->table_exists($table)) {
 +            $dbman->create_table($table);
 +        }
 +
 +        // Main savepoint reached
 +        upgrade_main_savepoint(true, 2012062500.05);
 +    }
 +
++    if ($oldversion < 2012062500.06) {
++
++        // Drop "deleted" fields
+         $table = new xmldb_table('course_completions');
+         $field = new xmldb_field('timenotified');
++        $field = new xmldb_field('deleted');
++
++        // Conditionally launch drop field deleted from course_completions
++        if ($dbman->field_exists($table, $field)) {
++        $dbman->drop_field($table, $field);
++        }
++        $field = new xmldb_field('timenotified');
+         // Conditionally launch drop field timenotified from course_completions
+         if ($dbman->field_exists($table, $field)) {
+             $dbman->drop_field($table, $field);
+         }
+         // Main savepoint reached
 -        upgrade_main_savepoint(true, 2012052500.05);
++        upgrade_main_savepoint(true, 2012062500.06);
+     }
++    if ($oldversion < 2012062500.07) {
++        $table = new xmldb_table('course_completion_crit_compl');
++        $field = new xmldb_field('deleted');
++
++        // Conditionally launch drop field deleted from course_completion_crit_compl
++        if ($dbman->field_exists($table, $field)) {
++            $dbman->drop_field($table, $field);
++        }
++        // Main savepoint reached
++        upgrade_main_savepoint(true, 2012062500.07);
++    }
++
++    if ($oldversion < 2012062500.08) {
++
++        // Drop unused table "course_completion_notify"
++        $table = new xmldb_table('course_completion_notify');
++
++        // Conditionally launch drop table course_completion_notify
++        if ($dbman->table_exists($table)) {
++            $dbman->drop_table($table);
++        }
++
++        // Main savepoint reached
++        upgrade_main_savepoint(true, 2012062500.08);
++     }
++
      return true;
  }
diff --cc version.php
@@@ -30,7 -30,7 +30,7 @@@
  defined('MOODLE_INTERNAL') || die();
  
  
- $version  = 2012062500.05;              // YYYYMMDD      = weekly release date of this DEV branch
 -$version  = 2012052500.05;              // YYYYMMDD      = weekly release date of this DEV branch
++$version  = 2012062500.08;              // YYYYMMDD      = weekly release date of this DEV branch
                                          //         RR    = release increments - 00 in DEV branches
                                          //           .XX = incremental changes