Commit f8fcaae4 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files
parents 376cb5d0 2046f3d8
......@@ -34,36 +34,40 @@ require_once('pieforms/pieform.php');
$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');
$activitytypes = array_merge($activitytypes , $admintypes);
}
$notifications = plugins_installed('notification');
$elements = array();
$options = array();
foreach ($notifications as $n) {
$options[$n->name] = get_string('name', 'notification.' . $n->name);
}
foreach ($activitytypes as $type) {
if ($type->name == 'adminmessages') {
$dv = $USER->get_activity_preference('contactus');
}
else {
$dv = $USER->get_activity_preference($type->name);
}
$dv = $USER->get_activity_preference($type->name);
if (empty($dv)) {
$dv = 'internal';
if (!empty($type->admin)) {
$dv = 'none';
} else {
$dv = 'internal';
}
}
$elements[$type->name] = array(
'defaultvalue' => $dv,
'type' => 'select',
'title' => get_string('type' . $type->name, 'activity'),
'options' => array(),
'options' => $options,
'rules' => array(
'required' => true
)
);
foreach ($notifications as $n) {
$elements[$type->name]['options'][$n->name] = get_string('name', 'notification.' . $n->name);
if (!empty($type->admin)) {
$elements[$type->name]['rules']['required'] = false;
$elements[$type->name]['options']['none'] = get_string('none');
}
}
$elements['submit'] = array(
......@@ -92,14 +96,11 @@ function activityprefs_submit(Pieform $form, $values) {
$userid = $USER->get('id');
foreach ($activitytypes as $type) {
if ($type->name == 'adminmessages') {
continue;
}
$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']);
if ($values[$type->name] == none) {
$USER->set_activity_preference($type->name, null);
}
else {
$USER->set_activity_preference($type->name, $values[$type->name]);
}
}
$form->json_reply(PIEFORM_OK, get_string('prefssaved', 'account'));
......
......@@ -71,6 +71,10 @@ function adminusers_submit(Pieform $form, $values) {
execute_sql('UPDATE ' . $table . '
SET admin = 1
WHERE id IN (' . join(',', $values['users']) . ')');
execute_sql('DELETE FROM ' . get_config('prefix') . 'usr_activity_preference
WHERE activity IN (SELECT name FROM ' . get_config('dbprefix') . 'activity_type
WHERE admin = 1 )
AND usr NOT IN (' . join(',', $values['users']) . ')');
db_commit();
$SESSION->add_ok_msg(get_string('adminusersupdated', 'admin'));
redirect('/admin/users/admins.php');
......
......@@ -41,90 +41,30 @@ $sql = 'SELECT u.*, a.activity, a.method
WHERE u.admin = ?';
$admins = get_records_sql_array($sql, array(1));
$types = get_column('activity_type', 'name', 'admin', 1);
$types = array_flip($types);
foreach (array_keys($types) as $k) {
$types[$k] = get_string('type' . $k, 'activity');
}
$users = array();
foreach ($admins as $u) {
if (!array_key_exists($u->id, $users)) {
$users[$u->id] = array('user' => $u,
'methods' => array());
foreach (array_keys($types) as $key) {
$users[$u->id]['methods'][$key] = '';
}
}
$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',
'jsform' => true,
'plugintype' => 'core',
'pluginname' => 'admin',
'renderer' => 'multicolumntable',
'elements' => array()
);
// build up the header
$form['elements']['headerprofileicon'] = array(
'title' => ' ',
'type' => 'html',
'class' => 'header',
'value' => get_string('profileicon')
);
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) {
$form['elements']['profileicon-' . $id] = array(
'key' => $id,
'type' => 'html',
'title' => full_name($user['user']),
'value' => '<img src="' . get_config('wwwroot') . 'thumb.php?type=profileicon&size=40x40&id=' . $id . '" alt="">'
);
foreach ($types as $type) {
$form['elements']['admin-' . $id . '-' . $type->name] = array(
'key' => $id,
'title' => full_name($user['user']),
'type' => 'select',
'options' => $options,
'defaultvalue' => ((array_key_exists($type->name, $user['methods']))
? $user['methods'][$type->name]
: 'none'),
);
if (!empty($u->method)) {
$users[$u->id]['methods'][$u->activity] = get_string('name', 'notification.' . $u->method);
}
}
$form['elements']['submit'] = array(
'type' => 'submit',
'value' =>get_string('save')
);
$smarty = smarty();
$smarty->assign('form', pieform($form));
$smarty->assign('users', $users);
$smarty->assign('types', $types);
$smarty->display('admin/users/notifications.tpl');
function adminnotifications_submit(Pieform $form, $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);
}
$form->json_reply(PIEFORM_OK, get_string('notificationssaved', 'admin'));
}
?>
......@@ -874,6 +874,14 @@ class ArtefactTypeImage extends ArtefactTypeFile {
else {
$height = $this->get('height');
}
if ((isset($options['width']) || isset($options['height'])) && isset($options['viewid'])) {
$url = get_config('wwwroot') . 'view/view.php?artefact=' . $this->get('id')
. '&view=' . $options['viewid'];
if (isset($options['path'])) {
$url .= '&path=' . $options['path'];
}
$smarty->assign('url', $url);
}
$smarty->assign('height', $height ? $height : '');
return $smarty->fetch('artefact:file:image_renderfull.tpl');
}
......
{if isset($url)}
<a href="{$url}">
{/if}
<img src="{$src}" width="{$width}" height="{$height}" alt="{$title}">
{if isset($url)}
</a>
{/if}
......@@ -46,7 +46,7 @@ var communitylist = new TableRenderer(
if (r.requestcount == 0) {
return TD(null);
}
return TD(null, A({'href': '{$editurl}' + r.id + '#pending'}, r.requestcount));
return TD(null, A({'href': '{$viewurl}' + r.id + '&pending=1#members'}, r.requestcount));
},
function (r) {
return TD(null, A({'href': '{$editurl}' + r.id}, '{$editstr}'));
......
......@@ -33,6 +33,7 @@ require_once('community.php');
$id = param_integer('id');
$joincontrol = param_alpha('joincontrol', null);
$pending = param_integer('pending', 0);
if (!$community = get_record('community', 'id', $id)) {
throw new CommunityNotFoundException("Couldn't find community with id $id");
......@@ -232,8 +233,8 @@ EOF;
$javascript .= <<<EOF
]
);
memberlist.type = 'members';
memberlist.id = $id;
memberlist.type='members';
memberlist.pending = 0;
memberlist.statevars.push('type');
memberlist.statevars.push('pending');
......@@ -242,8 +243,18 @@ memberlist.updateOnLoad();
addLoadEvent(function () { hideElement($('pendingreasonheader')); });
function switchPending() {
var pending = $('pendingselect').options[$('pendingselect').selectedIndex].value;
function switchPending(force) {
if (force) {
pending = force;
var theOption = filter(
function (o) { if ( o.value == pending ) return true; return false; },
$('pendingselect').options
);
theOption[0].selected = true;
}
else {
var pending = $('pendingselect').options[$('pendingselect').selectedIndex].value;
}
if (pending == 0) {
hideElement($('pendingreasonheader'));
}
......@@ -311,6 +322,11 @@ function joinRequestControl() {
EOF;
if (!empty($pending) && $canupdate && $request) {
$javascript .= <<<EOF
addLoadEvent(function () { switchPending(1) });
EOF;
}
$smarty = smarty(array('tablerenderer'));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('member', $membership);
......
......@@ -74,7 +74,7 @@ $string['adminusersdescription'] = 'Assign Site Administrator access rights';
$string['institutions'] = 'Institutions';
$string['institutionsdescription'] = 'Install and manage installed institutions';
$string['adminnotifications'] = 'Admin Notifications';
$string['adminnotificationsdescription'] = 'Configure how administrators receive system notifications';
$string['adminnotificationsdescription'] = 'Overview of how administrators receive system notifications';
$string['uploadcsv'] = 'Add Users by CSV';
$string['uploadcsvdescription'] = 'Upload a CSV file containing new users';
$string['usersearch'] = 'User Search';
......
......@@ -43,7 +43,7 @@ $string['errorprocessingform'] = 'There was an error with submitting this form.
$string['no'] = 'No';
$string['yes'] = 'Yes';
$string['none'] = 'none';
$string['none'] = 'None';
$string['nextpage'] = 'Next page';
$string['prevpage'] = 'Previous page';
......@@ -499,8 +499,9 @@ $string['requestedfriendlistmessage'] = '%s has requested that you add them as a
.' You can either do this from the link below, or from your friends list page';
$string['requestedfriendlistmessagereason'] = '%s has requested that you add them as a friend.'
. ' You can either do this from the link below, or from your friends list page'
. ' Their reason was:<br>';
. ' You can either do this from the link below, or from your friends list page.'
. ' Their reason was:
';
$string['removefromfriendslist'] = 'Remove from friends';
$string['confirmremovefriend'] = 'Are you sure you want to remove this user from your friends list?';
......
......@@ -421,8 +421,14 @@ SELECT DISTINCT u.*, p.method, ?||wa.view AS url
if ($user->method != 'internal') {
$method = $user->method;
safe_require('notification', $method, 'lib.php', 'require_once');
call_static_method(generate_class_name('notification', $method), 'notify_user', $user, $userdata);
$user->markasread = true; // if we're doing something else, don't generate unread internal ones.
try {
call_static_method(generate_class_name('notification', $method), 'notify_user', $user, $userdata);
$user->markasread = true; // if we're doing something else, don't generate unread internal ones.
}
catch (Exception $e) {
$user->markasread = false; // if we fail (eg email falls over), don't mark it as read...
// @todo penny notify them that their notification type failed....
}
}
// always do internal
call_static_method('PluginNotificationInternal', 'notify_user', $user, $userdata);
......
......@@ -367,7 +367,7 @@ function template_render($template, $mode, $data=array(), $view_id=null) {
'format' => isset($t['format']) ? $t['format'] : null,
'options' => $options,
);
if ( isset($data[$t['id']]) ) {
$format = FORMAT_ARTEFACT_LISTSELF;
......
......@@ -128,7 +128,7 @@ function set_activity_preference($userid, $activity, $method) {
}
catch (Exception $e) {
throw new InvalidArgumentException("Failed to insert activity preference "
." $methodfor $activity for user $userid");
." $method for $activity for user $userid");
}
}
}
......
......@@ -280,10 +280,8 @@ class View {
$data = array();
foreach ($artefacts as $artefact) {
$data[$artefact->block] = array(
'id' => $artefact->id,
'format' => $artefact->format
);
$data[$artefact->block]['format'] = $artefact->format;
$data[$artefact->block]['id'][] = $artefact->id;
}
foreach ($contents as $content) {
$data[$content->block] = array(
......
......@@ -1064,11 +1064,13 @@ function main_nav() {
'link' => $wwwroot . 'contacts/',
'section' => 'mahara',
),
/*
array(
'name' => 'myaddressbook',
'link' => $wwwroot . 'contacts/addressbook/',
'section' => 'mahara',
),
*/
array(
'name' => 'mycommunities',
'link' => $wwwroot . 'contacts/communities/',
......
......@@ -2,8 +2,25 @@
{include file="columnfullstart.tpl"}
<h2>{str tag='adminnotifications' section='admin'}</h2>
<table>
<tr>
<th>&nbsp;</th>
<th>{str tag='profileicon'}</th>
{foreach from=$types item='type'}
<th>{$type}</th>
{/foreach}
</tr>
{foreach from=$users item='user' key='userid'}
<tr>
<td>{display_name user=$user.user}</td>
<td><img src="{$WWWROOT}thumb.php?type=profileicon&size=40x40&id={$userid}" alt="profile icon"/></td>
{foreach from=$types key='type' item='name'}
<td>{if $user.methods.$type}{$user.methods.$type}{else}{str tag='none'}{/if}</td>
{/foreach}
</tr>
{/foreach}
{$form}
</table>
{include file="columnfullend.tpl"}
{include file="footer.tpl"}
......@@ -42,6 +42,7 @@
</table>
</div>
<div class="communitymembers">
<a name="members"></a>
<h5>{str tag='members'}</h5>
{if $canupdate && $request}
<form>
......
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