Commit 2bf6a0d8 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

created new profile sideblock

appears on every page with a sidebar when logged in
contains unread messages, pending friends, groups invited to, groups owned, views tagged with 'profile'
parent 2660f1b1
......@@ -84,6 +84,12 @@ $string['declinerequest'] = 'Decline request';
$string['strftimenotspecified'] = 'Not specified';
// profile sideblock strings
$string['invitedgroup'] = '1 group invited to';
$string['invitedgroups'] = '%s groups invited to';
$string['pendingfriend'] = '1 pending friend';
$string['pendingfriends'] = '%s pending friends';
// auth
$string['accessforbiddentoadminsection'] = 'You are forbidden from accessing the administration section';
$string['accountdeleted'] = 'Sorry, your account has been deletd';
......
......@@ -1657,4 +1657,45 @@ function str_shorten($str, $maxlen) {
return $str;
}
function profile_sideblock() {
global $USER;
safe_require('notification', 'internal');
require_once('group.php');
$data = array(
'id' => $USER->get('id'),
);
$unreadnotifications = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
if ($unreadnotifications == 1) {
$data['unreadnotifications'] = '1 ' . get_string('unreadmessages');
}
else if ($unreadnotifications > 1) {
$data['unreadnotifications'] = $unreadnotifications . ' ' . get_string('unreadmessages');
}
$invitedgroups = get_invited_groups();
$invitedgroups = $invitedgroups ? count($invitedgroups) : 0;
if ($invitedgroups && $invitedgroups == 1) {
$data['invitedgroups'] = get_string('invitedgroup', 'mahara', 1);
}
else if ($invitedgroups > 1) {
$data['invitedgroups'] = get_string('invitedgroups', 'mahara', $invitedgroups);
}
$pendingfriends = count_records('usr_friend_request', 'owner', $USER->get('id'));
if ($pendingfriends == 1) {
$data['pendingfriends'] = get_string('pendingfriend');
}
else if ($pendingfriends > 1) {
$data['pendingfriends'] = get_string('pendingfriends', 'mahara', $pendingfriends);
}
$data['groups'] = get_owned_groups();
$data['views'] = get_records_sql_array(
'SELECT v.id, v.title
FROM {view} v
INNER JOIN {view_tag} vt ON (vt.tag = ? AND vt.view = v.id)
WHERE v.owner = ?
ORDER BY v.title',
array('profile', $USER->get('id'))
);
return $data;
}
?>
......@@ -378,7 +378,15 @@ EOF;
'data' => array(),
);
}
if($USER->is_logged_in()) {
$SIDEBLOCKS[] = array(
'name' => 'profile',
'weight' => -10,
'data' => profile_sideblock()
);
}
if (!$USER->is_logged_in()) {
$SIDEBLOCKS[] = array(
'name' => 'login',
......
<h3><a href="{$WWWROOT}user/view.php?id={$data.id}">{$data.id|display_name|escape}</a></h3>
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxsize=50&amp;id={$data.id}" alt="">
<ul style="color:black">
{if $data.unreadnotifications}<li><a href="{$WWWROOT}account/activity/">{$data.unreadnotifications}</a></li>{/if}
{if $data.invitedgroups}<li><a href="{$WWWROOT}group/mygroups.php?filter=invited">{$data.invitedgroups}</a></li>{/if}
{if $data.pendingfriends}<li><a href="{$WWWROOT}user/?filter=2">{$data.pendingfriends}</a></li>{/if}
{if $data.groups}
<li>
<a href="{$WWWROOT}/group/mygroups.php?filter=owned">{str tag="groupsiown"}:</a>
<ul>
{foreach from=$data.groups item=group}
<li><a href="{$WWWROOT}group/view.php?id={$group->id}">{$group->name}</a></li>
{/foreach}
</ul>
</li>
{/if}
{if $data.views}
<li>
<a href="{$WWWROOT}view/">{str tag="myviews"}:</a>
<ul>
{foreach from=$data.views item=view}
<li><a href="{$WWWROOT}view/view.php?id={$view->id}">{$view->title}</a></li>
{/foreach}
</ul>
</li>
{/if}
</ul>
\ No newline at end of file
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