Commit 5d55b90c authored by Doris Tam's avatar Doris Tam Committed by Robert Lyon
Browse files

Bug 1866779: moving watchlist delay notification settings

Moving the watchlist delay notification setting from site options from admin settings
to plugin administration under blocktype.

- Moved strings to the blocktype.watchlist lang strings area.
- Removed a set_config call in upgrade.php and added a post_inst method
following other blocktype plugin  post install calls instead.

- Upgrade step to transfer over old site setting 'watchnotification_delay'
to plugin admin, updating the version number too
Change-Id: If388ddd083ceb8f46026fdc138f27ca8c8da5b04
parent 6fb84258
......@@ -203,13 +203,6 @@ $siteoptionform = array(
'help' => true,
'disabled' => in_array('generatesitemap', $OVERRIDDEN) || !get_config('allowpublicviews'),
),
'watchlistnotification_delay' => array(
'type' => 'text',
'title' => get_string('watchlistdelaytitle', 'admin'),
'description' => get_string('watchlistdelaydescription', 'admin'),
'defaultvalue' => get_config('watchlistnotification_delay'),
'disabled' => in_array('watchlistnotification_delay', $OVERRIDDEN),
),
),
),
'institutionsettings' => array(
......@@ -893,7 +886,7 @@ function siteoptions_submit(Pieform $form, $values) {
'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials', 'smtphosts', 'smtpport', 'smtpuser', 'smtppass', 'smtpsecure',
'noreplyaddress', 'homepageinfo', 'showprogressbar', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers',
'registerterms', 'licensemetadata', 'licenseallowcustom', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'owngroupsonly', 'wysiwyg',
'staffreports', 'staffstats', 'userscandisabledevicedetection', 'watchlistnotification_delay',
'staffreports', 'staffstats', 'userscandisabledevicedetection',
'masqueradingreasonrequired', 'masqueradingnotified', 'searchuserspublic',
'eventloglevel', 'eventlogexpiry', 'eventlogenhancedsearch', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs',
'defaultreviewselfdeletion'
......
<?php
/**
*
* @package mahara
* @subpackage blocktype-watchlist
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
defined('INTERNAL') || die();
function xmldb_blocktype_watchlist_upgrade($oldversion=0) {
if ($oldversion < 2020121000) {
$prevsetting = get_config('watchlistnotification_delay');
set_config_plugin('blocktype', 'watchlist', 'watchlistnotification_delay', (int)$prevsetting);
execute_sql("DELETE FROM {config} WHERE field = ?", array('watchlistnotification_delay'));
}
return true;
}
......@@ -39,3 +39,8 @@ $string['orderby'] = 'Order by';
$string['orderbydesc'] = 'Select to show pages in reverse chronological order or by page owner.';
$string['orderby.activity'] = 'Reverse chronological order';
$string['orderby.owner'] = 'Page owner';
$string['watchlistnotification'] = 'Watchlist notification';
$string['watchlistdelaytitle'] = 'Watchlist notification delay';
$string['watchlistdelaydescription'] = 'The delay in minutes between sending emails regarding watchlist changes.';
......@@ -186,6 +186,40 @@ class PluginBlocktypeWatchlist extends MaharaCoreBlocktype {
return true;
}
public static function has_config() {
return true;
}
public static function get_config_options() {
$elements = array();
$elements['watchlistnotification'] = array(
'type' => 'fieldset',
'legend' => get_string('watchlistnotification', 'blocktype.watchlist'),
'elements' => array(
'watchlistnotification_delay' => array(
'title' => get_string('watchlistdelaytitle', 'blocktype.watchlist'),
'type' => 'text',
'defaultvalue' => get_config_plugin('blocktype', 'watchlist', 'watchlistnotification_delay'),
'rules' => array( 'integer' => true, 'minvalue' => 0 ),
'description' => get_string('watchlistdelaydescription', 'blocktype.watchlist'),
)
),
);
return array(
'elements' => $elements,
);
}
public static function save_config_options(Pieform $form, $values) {
set_config_plugin('blocktype', 'watchlist', 'watchlistnotification_delay', (int)$values['watchlistnotification_delay']);
}
public static function postinst($prevversion) {
if ($prevversion == 0) {
set_config_plugin('blocktype', 'watchlist', 'watchlistnotification_delay', 20);
}
}
public static function get_instance_config_javascript(BlockInstance $instance) {
return array('js/configform.js');
}
......
......@@ -13,5 +13,5 @@
defined('INTERNAL') || die();
$config = new stdClass();
$config->version = 2016061400;
$config->release = '1.1.0';
$config->version = 2020121000;
$config->release = '1.1.1';
......@@ -547,8 +547,6 @@ $string['eventlogenhancedsearch'] = 'Event log reporting';
$string['eventlogenhancedsearchdescription1'] = 'This is required if you want to use the advanced analytics features in order to report over more activity on your site. You also need to enable Elasticsearch in the "Search Settings".';
$string['sitefilesaccess'] = 'Access to site files';
$string['sitefilesaccessdescription1'] = 'Allow registered people to access site files in subfolders. By default, only files in the top level directory are accessible to them.';
$string['watchlistdelaydescription'] = 'The delay in minutes between sending emails regarding watchlist changes.';
$string['watchlistdelaytitle'] = 'Watchlist notification delay';
$string['defaultmultipleblogs'] = 'Multiple journals';
$string['defaultmultipleblogsdescription1'] = 'Allow people to have multiple journals by default. They can override this on their account settings page.';
$string['defaultreviewsselfdeletion'] = 'Review accounts before self-deletion';
......
......@@ -901,7 +901,6 @@ 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();
......
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