Commit 0763c530 authored by Penny Leach's avatar Penny Leach
Browse files

added adminmessages to activity preferences for admins (as per test

script)
parent d51db4c9
...@@ -32,12 +32,23 @@ require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php'); ...@@ -32,12 +32,23 @@ require(dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php');
require_once('pieforms/pieform.php'); require_once('pieforms/pieform.php');
$activitytypes = get_records_array('activity_type', 'admin', 0); $activitytypes = get_records_array('activity_type', 'admin', 0);
if ($USER->get('admin')) {
$admintypes = get_records_array('activity_type', 'admin', 1);
$activitytypes[] = (object)array('name' => 'adminmessages');
}
$notifications = plugins_installed('notification'); $notifications = plugins_installed('notification');
$elements = array(); $elements = array();
foreach ($activitytypes as $type) { foreach ($activitytypes as $type) {
if (!$dv = $USER->get_activity_preference($type->name)) { if ($type->name == 'adminmessages') {
$dv = $USER->get_activity_preference('contactus');
}
else {
$dv = $USER->get_activity_preference($type->name);
}
if (empty($dv)) {
$dv = 'internal'; $dv = 'internal';
} }
$elements[$type->name] = array( $elements[$type->name] = array(
...@@ -76,12 +87,20 @@ $smarty->assign('form', pieform($prefsform)); ...@@ -76,12 +87,20 @@ $smarty->assign('form', pieform($prefsform));
$smarty->display('account/activity/preferences/index.tpl'); $smarty->display('account/activity/preferences/index.tpl');
function activityprefs_submit($values) { function activityprefs_submit($values) {
global $activitytypes, $USER; global $activitytypes, $admintypes, $USER;
$userid = $USER->get('id'); $userid = $USER->get('id');
foreach ($activitytypes as $type) { foreach ($activitytypes as $type) {
if ($type->name == 'adminmessages') {
continue;
}
$USER->set_activity_preference($type->name, $values[$type->name]); $USER->set_activity_preference($type->name, $values[$type->name]);
} }
if ($USER->get('admin')) {
foreach ($admintypes as $type) {
$USER->set_activity_preference($type->name, $values['adminmessages']);
}
}
json_reply(false, get_string('prefssaved', 'account')); json_reply(false, get_string('prefssaved', 'account'));
exit; exit;
} }
......
...@@ -35,6 +35,7 @@ $string['typecontactus'] = 'Contact us'; ...@@ -35,6 +35,7 @@ $string['typecontactus'] = 'Contact us';
$string['typeobjectionable'] = 'Objectionable content'; $string['typeobjectionable'] = 'Objectionable content';
$string['typevirusrepeat'] = 'Virus flat repeat'; $string['typevirusrepeat'] = 'Virus flat repeat';
$string['typevirusrelease'] = 'Virus flag release'; $string['typevirusrelease'] = 'Virus flag release';
$string['typeadminmessages'] = 'Administration messages';
$string['type'] = 'Activity type'; $string['type'] = 'Activity type';
$string['attime'] = 'at'; $string['attime'] = 'at';
......
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