Merge branch 'MDL-60361-master' of git://github.com/andrewnicols/moodle

This commit is contained in:
Jake Dallimore 2017-11-06 09:29:46 +08:00
commit eb354bdefa
14 changed files with 713 additions and 176 deletions

View file

@ -79,11 +79,17 @@ class calendar_subscription_created extends base
* @return \moodle_url
*/
public function get_url() {
if (($this->other['courseid'] == SITEID) || ($this->other['courseid'] == 0)) {
return new \moodle_url('calendar/managesubscriptions.php');
} else {
return new \moodle_url('calendar/managesubscriptions.php', array('course' => $this->other['courseid']));
$params = [];
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
$params['course'] = $this->other['courseid'];
if ($this->other['eventtype'] == 'group' && isset($this->other['groupid'])) {
$params['group'] = $this->other['groupid'];
}
}
if ($this->other['eventtype'] == 'category' && isset($this->other['categoryid'])) {
$params['category'] = $this->other['categoryid'];
}
return new \moodle_url('/calendar/managesubscriptions.php', $params);
}
/**
@ -103,8 +109,16 @@ class calendar_subscription_created extends base
if (!isset($this->other['eventtype'])) {
throw new \coding_exception('The \'eventtype\' value must be set in other.');
}
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
}
if ($this->other['eventtype'] == 'group' && !isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
if ($this->other['eventtype'] == 'category' && !isset($this->other['categoryid'])) {
throw new \coding_exception('The \'categoryid\' value must be set in other.');
}
}

View file

@ -78,11 +78,26 @@ class calendar_subscription_deleted extends base
* @return \moodle_url
*/
public function get_url() {
if (($this->other['courseid'] == SITEID) || ($this->other['courseid'] == 0)) {
return new \moodle_url('calendar/managesubscriptions.php');
$params = [];
if (isset($this->other['eventtype'])) {
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
$params['course'] = $this->other['courseid'];
if ($this->other['eventtype'] == 'group' && isset($this->other['groupid'])) {
$params['group'] = $this->other['groupid'];
}
}
if ($this->other['eventtype'] == 'category' && isset($this->other['categoryid'])) {
$params['category'] = $this->other['categoryid'];
}
} else {
return new \moodle_url('calendar/managesubscriptions.php', array('course' => $this->other['courseid']));
// This is a legacy event.
// Prior to specification of the eventtype there were only two params.
if (($this->other['courseid'] != SITEID) && ($this->other['courseid'] != 0)) {
$params['course'] = $this->other['courseid'];
}
}
return new \moodle_url('/calendar/managesubscriptions.php', $params);
}
/**
@ -99,8 +114,19 @@ class calendar_subscription_deleted extends base
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
if (!isset($this->other['eventtype'])) {
throw new \coding_exception('The \'eventtype\' value must be set in other.');
}
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
}
if ($this->other['eventtype'] == 'group' && !isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
if ($this->other['eventtype'] == 'category' && !isset($this->other['categoryid'])) {
throw new \coding_exception('The \'categoryid\' value must be set in other.');
}
}

View file

@ -79,11 +79,17 @@ class calendar_subscription_updated extends base
* @return \moodle_url
*/
public function get_url() {
if (($this->other['courseid'] == SITEID) || ($this->other['courseid'] == 0)) {
return new \moodle_url('calendar/managesubscriptions.php');
} else {
return new \moodle_url('calendar/managesubscriptions.php', array('course' => $this->other['courseid']));
$params = [];
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
$params['course'] = $this->other['courseid'];
if ($this->other['eventtype'] == 'group' && isset($this->other['groupid'])) {
$params['group'] = $this->other['groupid'];
}
}
if ($this->other['eventtype'] == 'category' && isset($this->other['categoryid'])) {
$params['category'] = $this->other['categoryid'];
}
return new \moodle_url('/calendar/managesubscriptions.php', $params);
}
/**
@ -103,8 +109,16 @@ class calendar_subscription_updated extends base
if (!isset($this->other['eventtype'])) {
throw new \coding_exception('The \'eventtype\' value must be set in other.');
}
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
}
if ($this->other['eventtype'] == 'group' && !isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
if ($this->other['eventtype'] == 'category' && !isset($this->other['categoryid'])) {
throw new \coding_exception('The \'categoryid\' value must be set in other.');
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20170929" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20171026" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@ -2858,6 +2858,7 @@
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="categoryid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>

View file

@ -2793,5 +2793,20 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2017102100.01);
}
if ($oldversion < 2017110300.01) {
// Define field categoryid to be added to event_subscriptions.
$table = new xmldb_table('event_subscriptions');
$field = new xmldb_field('categoryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'url');
// Conditionally launch add field categoryid.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2017110300.01);
}
return true;
}