Commit e73abfd5 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review

Bug 1402485: Integrate the watchlist install stuff into the normal install process

Change-Id: I49cbd9196efca256bb0959e59dfc56aa2ba4e4e2
parent e330d3ed
......@@ -3140,7 +3140,60 @@ function xmldb_core_upgrade($oldversion=0) {
}
if ($oldversion < 2014032600) {
install_watchlist_notification();
set_config('watchlistnotification_delay', 20);
if (!table_exists(new XMLDBTable('watchlist_queue'))) {
$table = new XMLDBTable('watchlist_queue');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('block', XMLDB_TYPE_INTEGER, 10, null, false);
$table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('changed_on', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
$table->addKeyInfo('blockfk', XMLDB_KEY_FOREIGN, array('block'), 'block_instance', array('id'));
$table->addKeyInfo('usrfk', XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
create_table($table);
}
// new event type: delete blockinstance
$e = new stdClass();
$e->name = 'deleteblockinstance';
ensure_record_exists('event_type', $e, $e);
// install the core event subscriptions
$subs = array(
array(
'event' => 'blockinstancecommit',
'callfunction' => 'watchlist_record_changes',
),
array(
'event' => 'deleteblockinstance',
'callfunction' => 'watchlist_block_deleted',
),
array(
'event' => 'saveartefact',
'callfunction' => 'watchlist_record_changes',
),
array(
'event' => 'saveview',
'callfunction' => 'watchlist_record_changes',
),
);
foreach ($subs as $sub) {
ensure_record_exists('event_subscription', (object)$sub, (object)$sub);
}
// install the cronjobs...
$cron = new stdClass();
$cron->callfunction = 'watchlist_process_notifications';
$cron->minute = '*';
$cron->hour = '*';
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
ensure_record_exists('cron', $cron, $cron);
}
if ($oldversion < 2014032700) {
......
......@@ -821,11 +821,7 @@ function core_install_lastcoredata_defaults() {
// if we're installing, set up the block categories here and then poll the plugins.
// if we're upgrading this happens somewhere else. This is because of dependency issues around
// the order of installation stuff.
install_blocktype_extras();
// also install the new watchlist notification
install_watchlist_notification();
}
function core_install_firstcoredata_defaults() {
......@@ -858,6 +854,7 @@ function core_install_firstcoredata_defaults() {
set_config('dropdownmenu', 0);
// Set this to a random starting number to make minor version slightly harder to detect
set_config('cacheversion', rand(1000, 9999));
set_config('watchlistnotification_delay', 20);
// install the applications
$app = new StdClass;
......@@ -892,6 +889,7 @@ function core_install_firstcoredata_defaults() {
'saveview',
'deleteview',
'blockinstancecommit',
'deleteblockinstance',
'addfriend',
'removefriend',
'addfriendrequest',
......@@ -916,6 +914,22 @@ function core_install_firstcoredata_defaults() {
'event' => 'createuser',
'callfunction' => 'add_user_to_autoadd_groups',
),
array(
'event' => 'blockinstancecommit',
'callfunction' => 'watchlist_record_changes',
),
array(
'event' => 'deleteblockinstance',
'callfunction' => 'watchlist_block_deleted',
),
array(
'event' => 'saveartefact',
'callfunction' => 'watchlist_record_changes',
),
array(
'event' => 'saveview',
'callfunction' => 'watchlist_record_changes',
),
);
foreach ($subs as $sub) {
......@@ -973,6 +987,7 @@ function core_install_firstcoredata_defaults() {
'cron_institution_data_daily' => array('51', '23', '*', '*', '*'),
'check_imap_for_bounces' => array('*', '*', '*', '*', '*'),
'cron_event_log_expire' => array('7', '23', '*', '*', '*'),
'watchlist_process_notifications' => array('*', '*', '*', '*', '*'),
);
foreach ($cronjobs as $callfunction => $times) {
$cron = new StdClass;
......@@ -1524,65 +1539,6 @@ function site_warnings() {
return $warnings;
}
function install_watchlist_notification() {
if (!record_exists('config', 'field', 'watchlistnotification_delay')) {
set_config('watchlistnotification_delay', 20);
}
if (!table_exists(new XMLDBTable('watchlist_queue'))) {
$table = new XMLDBTable('watchlist_queue');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('block', XMLDB_TYPE_INTEGER, 10, null, false);
$table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('changed_on', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
$table->addKeyInfo('blockfk', XMLDB_KEY_FOREIGN, array('block'), 'block_instance', array('id'));
$table->addKeyInfo('usrfk', XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
create_table($table);
}
// new event type: delete blockinstance
$e = new StdClass;
$e->name = 'deleteblockinstance';
ensure_record_exists('event_type', $e, $e);
// install the core event subscriptions
$subs = array(
array(
'event' => 'blockinstancecommit',
'callfunction' => 'watchlist_record_changes',
),
array(
'event' => 'deleteblockinstance',
'callfunction' => 'watchlist_block_deleted',
),
array(
'event' => 'saveartefact',
'callfunction' => 'watchlist_record_changes',
),
array(
'event' => 'saveview',
'callfunction' => 'watchlist_record_changes',
),
);
foreach ($subs as $sub) {
ensure_record_exists('event_subscription', (object)$sub, (object)$sub);
}
// install the cronjobs...
$cron = new StdClass;
$cron->callfunction = 'watchlist_process_notifications';
$cron->minute = '*';
$cron->hour = '*';
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
ensure_record_exists('cron', $cron, $cron);
}
/**
* Increment the cache version number.
......
Markdown is supported
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