Commit b14692f7 authored by Penny Leach's avatar Penny Leach
Browse files

adminnotifications done. added some strings

parent 953f06d9
......@@ -30,7 +30,89 @@ define('MENUITEM', 'configusers');
define('SUBMENUITEM', 'adminnotifications');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
$prefix = get_config('dbprefix');
$sql = 'SELECT u.*, a.activity, a.method
FROM ' . $prefix . 'usr u
LEFT JOIN ' . $prefix . 'usr_activity_preference a ON a.usr = u.id
WHERE u.admin = ?';
$admins = get_records_sql_array($sql, array(1));
$users = array();
foreach ($admins as $u) {
if (!array_key_exists($u->id, $users)) {
$users[$u->id] = array('user' => $u,
'methods' => array());
}
$users[$u->id]['methods'][$u->activity] = $u->method;
}
$types = get_records_array('activity_type', 'admin', 1);
$methods = plugins_installed('notification');
$options = array('none' => ucfirst(get_string('none')));
foreach ($methods as $m) {
$options[$m->name] = get_string('name', 'notification.' . $m->name);
}
$form = array(
'name' => 'adminnotifications',
'method' => 'post',
'ajaxpost' => true,
'plugintype' => 'core',
'pluginname' => 'admin',
'renderer' => 'multicolumntable',
'elements' => array()
);
// build up the header
foreach ($types as $type) {
$form['elements']['header' . $type->name] = array(
'title' => ' ',
'type' => 'html',
'class' => 'header',
'value' => get_string('type' . $type->name, 'activity'),
);
}
foreach ($users as $id => $user) {
foreach ($types as $type) {
$form['elements']['admin-' . $id . '-' . $type->name] = array(
'title' => full_name($user['user']),
'type' => 'select',
'options' => $options,
'defaultvalue' => ((array_key_exists($type->name, $user['methods']))
? $user['methods'][$type->name]
: 'none'),
);
}
}
$form['elements']['submit'] = array(
'type' => 'submit',
'value' =>get_string('save')
);
$smarty = smarty();
$smarty->assign('form', pieform($form));
$smarty->display('admin/users/notifications.tpl');
function adminnotifications_submit($values) {
foreach ($values as $key => $value) {
if (!preg_match('/^admin\-(\d+)\-([a-z]+)$/', $key, $m)) {
continue;
}
if ($value == 'none') {
$value = null;
}
set_activity_preference($m[1], $m[2], $value);
}
json_reply(false, get_string('notificationssaved', 'admin'));
exit;
}
?>
......@@ -186,5 +186,5 @@ $string['institutionupdatedsuccessfully'] = 'Institution updated successfully';
$string['registrationallowed'] = 'Registration allowed?';
$string['registrationalloweddescription'] = 'Whether users can register for the system with this institution';
$string['notificationssaved'] = 'Notification settings saved';
?>
......@@ -38,6 +38,7 @@ $string['change'] = 'Change';
$string['no'] = 'no';
$string['yes'] = 'yes';
$string['none'] = 'none';
$string['nextpage'] = 'Next page';
$string['prevpage'] = 'Previous page';
......
......@@ -4,9 +4,9 @@
<div class="content">
<div class="box-cnrs"><span class="cnr-tl"><span class="cnr-tr"><span class="cnr-bl"><span class="cnr-br">
<div class="maincontent">
<h2>AdminNotifications</h2>
<h2>{str tag='adminnotifications' section='admin'}</h2>
<p>... not until stage three :)</p>
{$form}
</div>
</span></span></span></span></div>
......
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