Commit 327aaf3f authored by Nigel McNie's avatar Nigel McNie
Browse files

[UPSTREAM] Remove the rather sadistic "No friends" message on users' profile pages

Instead, put controls in its place.
parent 77d1589a
......@@ -49,6 +49,7 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
}
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
$userid = $instance->get_view()->get('owner');
$smarty = smarty_core();
$records = get_records_sql_array('SELECT usr1, usr2 FROM {usr_friend}
......@@ -93,6 +94,46 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
}
$smarty->assign('friends', $friends);
$smarty->assign('friendsmessage', $friendsmessage);
// If the user has no friends, try and display something useful, such
// as a 'request friendship' button
$loggedinid = $USER->get('id');
$is_friend = is_friend($userid, $loggedinid);
if ($is_friend) {
$relationship = 'existingfriend';
}
else if (record_exists('usr_friend_request', 'requester', $loggedinid, 'owner', $userid)) {
$relationship = 'requestedfriendship';
}
else {
$relationship = 'none';
$friendscontrol = get_account_preference($userid, 'friendscontrol');
if ($friendscontrol == 'auto') {
$newfriendform = pieform(array(
'name' => 'myfriends_addfriend',
'successcallback' => 'addfriend_submit',
'autofocus' => false,
'renderer' => 'div',
'elements' => array(
'add' => array(
'type' => 'submit',
'value' => get_string('addtomyfriends', 'group')
),
'id' => array(
'type' => 'hidden',
'value' => $userid
)
)
));
$smarty->assign('newfriendform', $newfriendform);
}
$smarty->assign('friendscontrol', $friendscontrol);
}
$smarty->assign('relationship', $relationship);
$smarty->assign_by_ref('USER', $USER);
$smarty->assign('USERID', $userid);
return $smarty->fetch('blocktype:myfriends:myfriends.tpl');
}
......
......@@ -15,6 +15,17 @@
{/foreach}
</table>
{else}
{str tag='nofriends' section='group'}
{if $USERID == $USER->get('id')}
<div class="message">Try <a href="{$WWWROOT}user/find.php">searching for friends</a>!</div>
{else}
{if $relationship == 'none' && $friendscontrol == 'auto'}
<div class="message">{$newfriendform}</div>
{elseif $relationship == 'none' && $friendscontrol == 'auth'}
<div class="message"><a href="{$WWWROOT}user/requestfriendship.php?id={$USERID}&amp;returnto=view" class="btn-request">{str tag='requestfriendship' section='group'}</a></div>
{elseif $relationship == 'requestedfriendship'}
<div class="message">{str tag=friendshiprequested section=group}</div>
{/if}
{* Case not covered here: friendscontrol disallows new users. The block will appear empty. *}
{/if}
{/if}
</div>
......@@ -244,7 +244,6 @@ $string['cantmessageuser'] = 'You cannot send this user a message';
$string['requestedfriendship'] = 'requested friendship';
$string['notinanygroups'] = 'Not in any groups';
$string['numberoffriends'] = 'Friends (%s of %s)';
$string['nofriends'] = 'No friends :(';
$string['addusertogroup'] = 'Add to ';
$string['inviteusertojoingroup'] = 'Invite to ';
$string['invitemembertogroup'] = 'Invite %s to join \'%s\'';
......
......@@ -1214,10 +1214,15 @@ fieldset.collapsed legend a {
font-size: 11px;
}
#userview .user-icon input#addfriend_add {
input#addfriend_add,
input#myfriends_addfriend_add {
background: transparent url(../images/icon-add.gif) no-repeat left;
border: 0;
color: #7f9d16;
color: #3092ce;
margin: 0;
}
input#myfriends_addfriend_add {
font-weight: bold;
}
#userview .user-icon #invite,
#userview .user-icon #addmember {
......@@ -1241,7 +1246,7 @@ fieldset.collapsed legend a {
color: #7f9d16;
height: 16px;
}
#userview #btn-request {
.btn-request {
background: transparent url(../images/icon-add.gif) no-repeat left;
padding: 4px 12px;
}
......
......@@ -18,7 +18,7 @@
{$newfriendform}
{elseif $relationship == 'none' && $friendscontrol == 'auth'}
<br>
<a href="{$WWWROOT}user/requestfriendship.php?id={$USERID}&amp;returnto=view" id="btn-request">{str tag='requestfriendship' section='group'}</a>
<a href="{$WWWROOT}user/requestfriendship.php?id={$USERID}&amp;returnto=view" class="btn-request">{str tag='requestfriendship' section='group'}</a>
{/if}
{if $invitedlist}<div>{str tag=groupinvitesfrom section=group}{$invitedlist}</div>{/if}
{if $inviteform}
......
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