online indication on profile sidebar

This commit is contained in:
friendica 2014-01-28 17:07:25 -08:00
parent 3dfd38021f
commit cc11535e34
4 changed files with 33 additions and 2 deletions

View File

@ -544,6 +544,9 @@ function profile_load(&$a, $nickname, $profile = '') {
}
$a->profile = $r[0];
$online = get_online_status($nickname);
$a->profile['online_status'] = $online['result'];
$a->profile_uid = $r[0]['profile_uid'];
$a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname();
@ -678,13 +681,15 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
$gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
$marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
$profile['online'] = (($profile['online_status'] === 'online') ? t('Online Now') : False);
logger('online: ' . $profile['online']);
if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) {
$block = true;
}
if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
$location = $pdesc = $gender = $marital = $homepage = False;
$location = $pdesc = $gender = $marital = $homepage = $online = False;
}
$firstname = ((strpos($profile['name'],' '))
@ -1144,3 +1149,24 @@ function is_foreigner($s) {
function is_member($s) {
return((is_foreigner($s)) ? false : true);
}
function get_online_status($nick) {
$ret = array('result' => false);
$r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1",
dbesc(argv(1))
);
if($r) {
$hide = get_pconfig($r[0]['channel_id'],'system','hide_online_status');
if($hide)
return $ret;
$x = q("select cp_status from chatpresence where cp_xchan = '%s' and cp_room = 0 limit 1",
dbesc($r[0]['channel_hash'])
);
if($x)
$ret['result'] = $x[0]['cp_status'];
}
return $ret;
}

View File

@ -50,4 +50,5 @@ $(document).ready(function() {
$('.icon-check').addClass('');
$('.icon-globe').addClass('');
$('.icon-circle-blank').addClass('');
$('.icon-circle').addClass('');
});

View File

@ -2446,3 +2446,7 @@ img.mail-list-sender-photo {
.abook-self {
background-color: #ffdddd;
}
.online-now {
color: red;
cursor: pointer;
}

View File

@ -16,7 +16,7 @@
</div>
{{/if}}
<div class="fn label">{{$profile.name}}</div>
<div class="fn label">{{$profile.name}}{{if $profile.online}} <i class="icon-asterisk online-now" title="{{$profile.online}}"></i>{{/if}}</div>
{{if $pdesc}}<div class="title">{{$profile.pdesc}}</div>{{/if}}
<div id="profile-photo-wrapper"><img class="photo" width="175" height="175" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}"></div>