Merge branch 'MDL-63658-master-2' of https://github.com/snake/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 18 Oct 2018 01:08:22 +0000 (09:08 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 18 Oct 2018 01:08:22 +0000 (09:08 +0800)
1  2 
lib/db/upgrade.php
version.php

@@@ -2508,30 -2524,42 +2508,67 @@@ function xmldb_main_upgrade($oldversion
          upgrade_main_savepoint(true, 2018092800.03);
      }
  
 -    if ($oldversion < 2018101600.01) {
 +    if ($oldversion < 2018101700.01) {
 +        if (empty($CFG->keepmessagingallusersenabled)) {
 +            // When it is not set, $CFG->messagingallusers should be disabled by default.
 +            // When $CFG->messagingallusers = false, the default user preference is MESSAGE_PRIVACY_COURSEMEMBER
 +            // (contacted by users sharing a course).
 +            set_config('messagingallusers', false);
 +        } else {
 +            // When $CFG->keepmessagingallusersenabled is set to true, $CFG->messagingallusers is set to true.
 +            set_config('messagingallusers', true);
 +
 +            // When $CFG->messagingallusers = true, the default user preference is MESSAGE_PRIVACY_SITE
 +            // (contacted by all users site). So we need to set existing values from 0 (MESSAGE_PRIVACY_COURSEMEMBER)
 +            // to 2 (MESSAGE_PRIVACY_SITE).
 +            $DB->set_field(
 +                'user_preferences',
 +                'value',
 +                \core_message\api::MESSAGE_PRIVACY_SITE,
 +                array('name' => 'message_blocknoncontacts', 'value' => 0)
 +            );
 +        }
 +
 +        // Main savepoint reached.
 +        upgrade_main_savepoint(true, 2018101700.01);
 +    }
 +
++    if ($oldversion < 2018101800.00) {
+         // Define table 'favourite' to be created.
+         $table = new xmldb_table('favourite');
+         // Adding fields to table 'favourite'.
+         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+         $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+         $table->add_field('itemtype', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+         $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+         $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+         $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+         $table->add_field('ordering', XMLDB_TYPE_INTEGER, 10, null, null, null, null);
+         $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+         $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+         // Adding keys to table 'favourite'.
+         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+         $table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
+         $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
+         // Conditionally launch create table for 'favourite'.
+         if (!$dbman->table_exists($table)) {
+             $dbman->create_table($table);
+         }
+         // Add composite index 'uniqueuserfavouriteitem' to the table 'favourite'.
+         $index = new xmldb_index('uniqueuserfavouriteitem', XMLDB_INDEX_UNIQUE,
+             ['component', 'itemtype', 'itemid', 'contextid', 'userid']);
+         if (!$dbman->index_exists($table, $index)) {
+             $dbman->add_index($table, $index);
+         }
+         // Main savepoint reached.
 -        upgrade_main_savepoint(true, 2018101600.01);
++        upgrade_main_savepoint(true, 2018101800.00);
+     }
      return true;
  }
diff --cc version.php
@@@ -29,7 -29,7 +29,7 @@@
  
  defined('MOODLE_INTERNAL') || die();
  
- $version  = 2018101700.01;              // YYYYMMDD      = weekly release date of this DEV branch.
 -$version  = 2018101600.01;              // YYYYMMDD      = weekly release date of this DEV branch.
++$version  = 2018101800.00;              // YYYYMMDD      = weekly release date of this DEV branch.
                                          //         RR    = release increments - 00 in DEV branches.
                                          //           .XX = incremental changes.