Commit a1ff0952 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

added javascript update to the count of pending friends in the sideblock

added message about tagging as 'profile' to make artefacts go in the sideblock
parent 43bc2da4
......@@ -29,10 +29,25 @@ function sendMessage(id, link, tableRenderer) {
function approveFriend(id, tableRenderer) {
var pd = {'id': id, 'control': 1, 'filter': 0, 'type': 'accept'};
sendjsonrequest('index.json.php', pd, 'POST', function() { tableRenderer.doupdate(); });
decrementPendingFriends();
}
function disallowFriend(id, link) {
friendRequestWithMessage(id, link, 'disallow', friendslist);
decrementPendingFriends();
}
function decrementPendingFriends() {
var oldcount = parseInt($('pendingfriendscount').innerHTML);
var newcount = oldcount - 1;
var messagenode = $('pendingfriendsmessage');
if (newcount == 1) { // jump through hoops to change between plural and singular
messagenode.innerHTML = get_string('pendingfriend');
}
else {
messagenode.innerHTML = get_string('pendingfriends');
}
$('pendingfriendscount').innerHTML = newcount;
}
function sendFriendRequest(id, link) {
......
......@@ -69,7 +69,7 @@ $string['reason'] = 'Reason';
$string['select'] = 'Select';
$string['tags'] = 'Tags';
$string['tagsdesc'] = 'Enter comma separated tags for this item';
$string['tagsdesc'] = 'Enter comma separated tags for this item. Artefacts tagged with \'profile\' are displayed in the sidebar';
$string['selfsearch'] = 'Search My Portfolio';
$string['ssopeers'] = 'SSO Peers';
......@@ -85,11 +85,11 @@ $string['declinerequest'] = 'Decline request';
$string['strftimenotspecified'] = 'Not specified';
// profile sideblock strings
$string['invitedgroup'] = '1 group invited to';
$string['invitedgroups'] = '%s groups invited to';
$string['invitedgroup'] = 'group invited to';
$string['invitedgroups'] = 'groups invited to';
$string['logout'] = 'Logout';
$string['pendingfriend'] = '1 pending friend';
$string['pendingfriends'] = '%s pending friends';
$string['pendingfriend'] = 'pending friend';
$string['pendingfriends'] = 'pending friends';
// auth
$string['accessforbiddentoadminsection'] = 'You are forbidden from accessing the administration section';
......
......@@ -1664,28 +1664,13 @@ function profile_sideblock() {
$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'] = '<span class="unreadmessagecount">1</span> <span class="unreadmessages">' . get_string('unreadmessages') . '</span>';
}
else if ($unreadnotifications > 1) {
$data['unreadnotifications'] = '<span class="unreadmessagecount">' . $unreadnotifications . '</span> <span class="unreadmessages">' . get_string('unreadmessages') . '</span>';
}
$data['unreadnotifications'] = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
$data['unreadnotificationsmessage'] = $data['unreadnotifications'] == 1 ? get_string('unreadmessage') : 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['invitedgroups'] = $invitedgroups ? count($invitedgroups) : 0;
$data['invitedgroupsmessage'] = $data['invitedgroups'] == 1 ? get_string('invitedgroup') : get_string('invitedgroups');
$data['pendingfriends'] = count_records('usr_friend_request', 'owner', $USER->get('id'));
$data['pendingfriendsmessage'] = $data['pendingfriends'] == 1 ? get_string('pendingfriend') : get_string('pendingfriends');
$data['groups'] = get_owned_groups();
$data['views'] = get_records_sql_array(
'SELECT v.id, v.title
......
......@@ -385,7 +385,7 @@ EOF;
if($USER->is_logged_in()) {
$SIDEBLOCKS[] = array(
'name' => 'profile',
'weight' => -10,
'weight' => -20,
'data' => profile_sideblock()
);
}
......@@ -478,6 +478,10 @@ function jsstrings() {
'requestfriendship',
'cancel',
),
'mahara' => array(
'pendingfriend',
'pendingfriends',
),
),
'views' => array(
'view' => array(
......
<h3><a style="color:white" href="{$WWWROOT}user/view.php?id={$data.id}">{$data.id|display_name|escape}</a></h3>
<div class="fr"><a href="{$WWWROOT}user/view.php?id={$data.id}"><img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxsize=50&amp;id={$data.id}" alt=""></a></div>
<ul>
{if $data.unreadnotifications}<li><a href="{$WWWROOT}account/activity/"><span class="unreadmessagescontainer">{$data.unreadnotifications}</span></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}
{if $data.unreadnotifications}
<li>
<a href="{$WWWROOT}group/mygroups.php?filter=owned">{str tag="groupsiown" section="group"}:</a>
<ul>
{foreach from=$data.groups item=group}
<li><a href="{$WWWROOT}group/view.php?id={$group->id}">{$group->name|escape}</a></li>
{/foreach}
</ul>
<a href="{$WWWROOT}account/activity/">
<span class="unreadmessagescontainer"><span class="unreadmessagecount">{$data.unreadnotifications}</span> <span class="unreadmessages">{$data.unreadnotificationsmessage}</span></span>
</a>
</li>
{/if}
{if $data.invitedgroups}
<li>
<a href="{$WWWROOT}group/mygroups.php?filter=invited">
<span id="invitedgroupscount">{$data.invitedgroups}</span>
<span id="invitedgroupsmessage">{$data.invitedgroupsmessage}</span>
</a>
</li>
{/if}
{if $data.pendingfriends}
<li>
<a href="{$WWWROOT}user/">
<span id="pendingfriendscount">{$data.pendingfriends}</span>
<span id="pendingfriendsmessage">{$data.pendingfriendsmessage}</span>
</a>
</li>
{/if}
{if $data.views}
......
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