Commit 5224d28d authored by Nigel McNie's avatar Nigel McNie
Browse files

Show institutions a user is a member of on the Find Friends page and their profile page.

parent 6252c757
......@@ -73,6 +73,7 @@ $string['last'] = 'Last';
$string['lastpage'] = 'Last page';
$string['accept'] = 'Accept';
$string['memberofinstitutions'] = 'Member of %s';
$string['reject'] = 'Reject';
$string['sendrequest'] = 'Send request';
$string['reason'] = 'Reason';
......
......@@ -1022,6 +1022,7 @@ function get_users_data($userlist) {
}
$record->messages = ($record->messages == 'allow' || $record->friend && $record->messages == 'friends' || $USER->get('admin')) ? 1 : 0;
$record->institutions = get_institution_string_for_user($record->id);
}
if (!$data || !$views = get_views(array_keys($data), null, null)) {
......@@ -1116,6 +1117,26 @@ function get_users_data($userlist) {
return $ordereddata;
}
function get_institution_string_for_user($userid) {
static $institutions = null;
if (is_null($institutions)) {
$institutions = get_records_assoc('institution', '', '', '', 'name, displayname');
}
$user = new User;
$user->find_by_id($userid);
$userinstitutions = array();
foreach ($user->get('institutions') as $institution) {
$userinstitutions[] = $institutions[$institution->institution]->displayname;
}
if ($userinstitutions) {
return get_string('memberofinstitutions', 'mahara', join(', ', $userinstitutions));
}
return '';
}
function friends_control_sideblock($returnto='myfriends') {
global $USER;
$form = array(
......
{if $user->pending}
<td class="pending friendinfo">
<ul class="actionlist">
{if $user->institutions}<li>{$user->institutions|escape}</li>{/if}
<li>{$user->accept}</li>
<li>
<a href="{$WWWROOT}user/denyrequest.php?id={$user->id}&amp;returnto={$page}" id="btn-denyrequest">
......@@ -39,6 +40,7 @@
{elseif $user->friend}
<td class="friendinfo">
<ul class="actionlist">
{if $user->institutions}<li>{$user->institutions|escape}</li>{/if}
{if $user->messages}
<li>
<a href="{$WWWROOT}user/sendmessage.php?id={$user->id}&amp;returnto={$page}" id="btn-sendmessage">
......@@ -95,6 +97,7 @@
{elseif $user->requestedfriendship}
<td class="friendinfo">
<ul class="actionlist">
{if $user->institutions}<li>{$user->institutions|escape}</li>{/if}
{if $user->messages}
<li>
<a href="{$WWWROOT}user/sendmessage.php?id={$user->id}&amp;returnto={$page}" id="btn-sendmessage">
......@@ -123,6 +126,7 @@
{else}
<td class="friendinfo">
<ul class="actionlist">
{if $user->institutions}<li>{$user->institutions|escape}</li>{/if}
{if $user->messages}
<li>
<a href="{$WWWROOT}user/sendmessage.php?id={$user->id}&amp;returnto={$page}" id="btn-sendmessage">
......@@ -156,4 +160,4 @@
{/if}
</div>
</td>
{/if}
\ No newline at end of file
{/if}
......@@ -4,6 +4,7 @@
{include file="columnleftstart.tpl"}
<div id="userview">
<div class="user-icon right">
{$institutions}
{if !empty($loginas)}
<strong><a href="{$WWWROOT}admin/users/changeuser.php?id={$USERID}">{$loginas}</a></strong>
{/if}
......
......@@ -287,6 +287,7 @@ $smarty->assign('loginas', $loginas);
if (isset($introduction)) {
$smarty->assign('introduction', $introduction);
}
$smarty->assign('institutions', get_institution_string_for_user($userid));
$smarty->assign('canmessage', can_send_message($loggedinid, $userid));
$smarty->assign('NAME',$name);
$smarty->assign('USERID', $userid);
......
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