Commit ca75ec4f authored by jun's avatar jun
Browse files

MDL-55956 db: Add priority column for event table

* New priority column in order to enable the rendering of a single,
relevant calendar event for a module that has user/group overrides.
* Insert refresh_mod_calendar_events_task record to task_adhoc
table to upgrade existing calendar events for mod plugins via cron
after upgrade process.
parent 37d0c7c7
......@@ -120,6 +120,11 @@ define('CALENDAR_SUBSCRIPTION_UPDATE', 1);
*/
define('CALENDAR_SUBSCRIPTION_REMOVE', 2);
/**
* CALENDAR_EVENT_USER_OVERRIDE_PRIORITY - Constant for the user override priority.
*/
define('CALENDAR_EVENT_USER_OVERRIDE_PRIORITY', 9999999);
/**
* Return the days of the week
*
......
......@@ -439,6 +439,7 @@
<FIELD NAME="sequence" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="subscriptionid" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The event_subscription id this event is associated with."/>
<FIELD NAME="priority" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The event's display priority. For multiple events with the same module name, instance and eventtype (e.g. for group overrides), the one with the higher priority will be displayed."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
......@@ -2555,5 +2555,29 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2017021400.00);
}
if ($oldversion < 2017030300.01) {
// Define field priority to be added to event.
$table = new xmldb_table('event');
$field = new xmldb_field('priority', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'subscriptionid');
// Conditionally launch add field priority.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Create adhoc task for upgrading of existing calendar events.
$record = new \stdClass();
$record->classname = "\\core\\task\\refresh_mod_calendar_events_task";
$record->component = 'core';
// Next run time based from nextruntime computation in \core\task\manager::queue_adhoc_task().
$nextruntime = time() - 1;
$record->nextruntime = $nextruntime;
$DB->insert_record('task_adhoc', $record);
// Main savepoint reached.
upgrade_main_savepoint(true, 2017030300.01);
}
return true;
}
......@@ -54,6 +54,7 @@ information provided here is intended especially for developers.
the submitted capability. The parameter 'fieldsexceptid' will now accept context fields which can be used for preloading.
* The caching option 'immutable' has been added to send_stored_file() and send_file().
* New adhoc task refresh_mod_calendar_events_task that updates existing calendar events of modules.
* New 'priority' column for the event table to determine which event to show in case of events with user and group overrides.
=== 3.2 ===
......
......@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2017030300.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017030300.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment