From f0a06c4e595f42aa8a9498a03803c279eae6dc16 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 13 Jan 2012 18:40:35 +0100 Subject: [PATCH] Adding online/offline icons --- main/css/base.css | 17 +++++++++++++ main/css/offline.png | Bin 0 -> 840 bytes main/css/online.png | Bin 0 -> 1069 bytes main/inc/lib/javascript/chat/js/chat.js | 4 +-- main/inc/lib/online.inc.php | 15 ++++++------ main/inc/lib/social.lib.php | 31 ++++++++++++++---------- main/social/profile.php | 25 +++++++++++++------ main/social/search.php | 12 ++++++--- whoisonline.php | 1 - 9 files changed, 72 insertions(+), 33 deletions(-) create mode 100644 main/css/offline.png create mode 100644 main/css/online.png mode change 100755 => 100644 main/social/search.php mode change 100755 => 100644 whoisonline.php diff --git a/main/css/base.css b/main/css/base.css index ff0d6787ae..eda7d13fd9 100644 --- a/main/css/base.css +++ b/main/css/base.css @@ -4180,3 +4180,20 @@ a:active{ .skills-skills ul.holder { margin-bottom: 8px; } + + +.offline_user { + display: block; + height: 20px; + width: 20px; + position:absolute; + background: url("offline.png") no-repeat scroll right center transparent; +} + +.online_user { + display: block; + height: 20px; + width: 20px; + position:absolute; + background: url("online.png") no-repeat scroll right center transparent; +} \ No newline at end of file diff --git a/main/css/offline.png b/main/css/offline.png new file mode 100644 index 0000000000000000000000000000000000000000..2c324efe5f9e2757ad08390d34a66dee4875c853 GIT binary patch literal 840 zcmV-O1GoH%P)4Tx0C?K1kv~gYVHC!H?+ubA#^q8vUhoeYV!0R!4RtXYLLkUBWJrQTlbf4s zN_z8hbF~fl5gY<8>SEL{;Lz$M=q$PjLaPWuKR`k1B62&tEm^8v`oMwTd6sjYb3prC zld`P=AH2XX<}yaPQZ=Gqi82BJHM=Y4EUUniy1zsKTuj%bY=61><`}*F&-wFrg_G~) zTb@_UFITD{bU=3%Cjh;!coxt<1~LF)0lK|ZYk+6~NxxLgg6IQrSMdOd*A?#r@fF(* zKpX?6*JyblegJP8PS*x40l2pG1JL@wM7dHm)M}jpq{kt$HuUNnaCihSPlw*bHjKT6 zgY%(xw}1e|i;HeEH3NW%Wnttd4DTi(x(<*1Fnrhv!^d5ST*L8ud)Z(4eHWpn;9tGU zrh4@QP;>vzDn9@w>|H`>6$)ptxdl^A7+VA@2BkDw>h+&ew*p|aTg+t)%kMN>ZHND? z!1)vaWIM9wx7?+`n3J;YB#pdhze*Z2rkUm!mvVAcuNkB@00002VoOIv0RM-N%)bBt z010qNS#tmY3ljhU3ljkVnw%H_000McNliru+6)*EI}K)Y(;xr<0X<1XK~yNuWsto~ z!eJ1{Klk%z7$LeiNmHApMN3;a1`XQU)+7W$|3Pb`&=|Ey1uYc~DM1j_&}tZ%n+Zul zB80v8JkK@wg4G?|@O?Y(gnktw@l-Gynw4?$^j`F@(sjtQ2~YqoRw|VTt!Y)O`lwaC zZ{O?!Y|M@-(9 zawQMqoX>HJI1EM&21`J~&o9fl(l&w+CK8><%qQ2w3*rl+u3104Jicp6M_WIwh?J=F Sq5sThNM literal 0 HcmV?d00001 diff --git a/main/css/online.png b/main/css/online.png new file mode 100644 index 0000000000000000000000000000000000000000..6b7c57af03bea47f25f665b26a12e5982fe151a4 GIT binary patch literal 1069 zcmV+|1k(G7P)4Tx0C?K1kv~gYVHC!H?+ubA#^q8vUhoeYV!0R!4RtXYLLkUBWJrQTlbf4s zN_z8hbF~fl5gY<8>SEL{;Lz$M=q$PjLaPWuKR`k1B62&tEm^8v`oMwTd6sjYb3prC zld`P=AH2XX<}yaPQZ=Gqi82BJHM=Y4EUUniy1zsKTuj%bY=61><`}*F&-wFrg_G~) zTb@_UFITD{bU=3%Cjh;!coxt<1~LF)0lK|ZYk+6~NxxLgg6IQrSMdOd*A?#r@fF(* zKpX?6*JyblegJP8PS*x40l2pG1JL@wM7dHm)M}jpq{kt$HuUNnaCihSPlw*bHjKT6 zgY%(xw}1e|i;HeEH3NW%Wnttd4DTi(x(<*1Fnrhv!^d5ST*L8ud)Z(4eHWpn;9tGU zrh4@QP;>vzDn9@w>|H`>6$)ptxdl^A7+VA@2BkDw>h+&ew*p|aTg+t)%kMN>ZHND? z!1)vaWIM9wx7?+`n3J;YB#pdhze*Z2rkUm!mvVAcuNkB@00006VoOIv0RI600RN!9 zr;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru+64s;01jZSky0v<_3K~y-) zjZ-^JR6!Iyci!x>gr7$I5EnxHC9nvInAjOAV<$ulq_>d5Xiv03V`pI~)XG8%8bhKH zEHo5G(a_LZXutrA!6k(Ky*G1@#lr;=kdxfZOy-_5_srZ8Y{UJ@)`pW!$2x5iy){*- zE(ohb@8;LmixUZJ-}Prc&jG-l(Ia>?unYl!;kT_Ay7V2-zjXJtwlogIxOSTep!5I$ zfq(?cp<7#BD~??|GkpU9ZjT;~1pr{=V`d<8qUl9w%Gd)8jFIfm^{)drXWH=|P5|KP zr_SD%mV+rLY=~ggpUaIghq%* zw-HgCvn7O)|6v2clse6+@&Fm1Yqk`@ot-e1Fp|%^#{vL%Up0?-a?t;2B5w1%4XWVb zI-6C`j>`7XczV{6XSsJL(ks#2n3U|V@bZJcg~= '".$current_date."' AND u.user_id = $user_id LIMIT 1 "; + $query = " SELECT login_user_id,login_date FROM ".$track_online_table ." track INNER JOIN ".$table_user ." u ON (u.user_id=track.login_user_id) + WHERE track.access_url_id = $access_url_id AND + DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."' AND + u.user_id = $user_id + LIMIT 1 "; $result = Database::query($query); if (Database::num_rows($result)) { diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index b3beb21007..1de6339551 100644 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -558,10 +558,10 @@ class SocialManager extends UserManager { * */ public static function show_social_menu($show = '', $group_id = 0, $user_id = 0, $show_full_profile = false) { - - if (empty($user_id)) { + if (empty($user_id)) { $user_id = api_get_user_id(); - } + } + $user_info = api_get_user_info($user_id, true); $show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups'); $show_messages = array('messages', 'messages_inbox', 'messages_outbox', 'messages_compose'); @@ -678,8 +678,6 @@ class SocialManager extends UserManager { echo '
  • '.Display::return_icon('briefcase.png',get_lang('MyFiles'),array('hspace'=>'6'),16).''.get_lang('MyFiles').'
  • '; } - $user_info = api_get_user_info($user_id); - // My friend profile $html_actions = ''; @@ -702,8 +700,10 @@ class SocialManager extends UserManager { //@todo check if user is online to show the chat link if (api_get_setting('allow_global_chat') == 'true') { if ($user_id != api_get_user_id()) { - $user_name = $user_info['complete_name']; - echo Display::tag('li', Display::url(Display::return_icon('chat.gif').get_lang('Chat'), 'javascript:void(0);', array('onclick' => "javascript:chatWith('".$user_id."', '".Security::remove_XSS($user_name)."')"))); + $user_name = $user_info['complete_name']; + $options = array('onclick' => "javascript:chatWith('".$user_id."', '".Security::remove_XSS($user_name)."', '".$user_info['user_is_online']."')"); + $chat_icon = $user_info['user_is_online'] ? Display::return_icon('online.png', get_lang('Online')) : Display::return_icon('offline.png', get_lang('Offline')); + echo Display::tag('li', Display::url($chat_icon.'  '.get_lang('Chat'), 'javascript:void(0);', $options)); } } echo ''; @@ -802,14 +802,16 @@ class SocialManager extends UserManager { $image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true); // reduce image - $name = api_get_person_name($user_info['firstName'], $user_info['lastName']); + $name = $user_info['complete_name']; if ($image_array['file'] == 'unknown.jpg' || !file_exists($image_array['dir'].$image_array['file'])) { - $friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg'; - $table_row[] = ''; - } else { - $friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL); + $friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg'; + $status_icon = Display::span('', array('class' => 'online_user')); + //$img = $status_icon.$img; + $table_row[] = ''.$status_icon.''; + } else { + $friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL); $img = ''.$name.''; @@ -821,7 +823,10 @@ class SocialManager extends UserManager { //A really tiny image if ($friends_profile['original_height'] < 50 || $friends_profile['original_height']< 50) { $clip = ''; - } + } + //$status_icon = Display::span($status_icon, array('class' => 'online_user')); + //$img = $status_icon.$img; + $table_row[] = Display::url(Display::div(Display::div($img, array('class'=>$clip)), array('class'=>'clip-wrapper')) , $url); } diff --git a/main/social/profile.php b/main/social/profile.php index 4dda174ac0..2f75c34ab9 100644 --- a/main/social/profile.php +++ b/main/social/profile.php @@ -393,13 +393,27 @@ if ($show_full_profile) { if (isset($friends[$k])) { $friend = $friends[$k]; $name_user = api_get_person_name($friend['firstName'], $friend['lastName']); - $friend_html.='
    '; + $user_info = api_get_user_info($friend['friend_user_id'], true); + + + if ($user_info['user_is_online']) { + $status_icon = Display::div('', array('class' => 'online_user')); + } else { + $status_icon = Display::div('', array('class' => 'offline_user')); + } + + $friend_html.= '
    '; + $friend_html.= $status_icon.'
    '; // the height = 92 must be the sqme in the image_friend_network span style in default.css $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_MEDIUM , 'width="85" height="90" '); + - $friend_html.=''; - $friend_html.=''; + $friend_html.= ''; + + + + $friend_html.= ''; $friend_html.= '
    '; $friend_html.= '
    '.$name_user.'
    '; $friend_html.= '
    '; @@ -640,9 +654,6 @@ if ($show_full_profile) { } echo '
    '; // close social-box-main1 } - -//echo '
    '; echo ''; echo ''; - -Display :: display_footer(); +Display :: display_footer(); \ No newline at end of file diff --git a/main/social/search.php b/main/social/search.php old mode 100755 new mode 100644 index a62a193f12..fea1a08351 --- a/main/social/search.php +++ b/main/social/search.php @@ -22,7 +22,6 @@ $this_section = SECTION_SOCIAL; $tool_name = get_lang('Search'); $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('Social')); - $query_vars = array(); $query = isset($_GET['q']) ? $_GET['q'] : null; @@ -52,6 +51,7 @@ echo '
    '; if (is_array($users) && count($users)> 0) { echo '

    '.get_lang('Users').'

    '; foreach($users as $user) { + $user_info = api_get_user_info($user['user_id'], true); $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id']; if (empty($user['picture_uri'])) { @@ -66,8 +66,14 @@ echo '
    '; $clip = 'clip_horizontal'; } $img = Display::url(Display::div(Display::div($img, array('class'=>$clip)), array('class'=>'clip-wrapper')) , $url); - } - + } + if ($user_info['user_is_online']) { + $status_icon = Display::span('', array('class' => 'online_user')); + } else { + $status_icon = Display::span('', array('class' => 'offline_user')); + } + $img = $status_icon.$img; + $user['firstname'] = Display::url($user['firstname'], $url); $user['lastname'] = Display::url($user['lastname'], $url); $user['tag'] = isset($user['tag']) ? $user['tag'] : null; diff --git a/whoisonline.php b/whoisonline.php old mode 100755 new mode 100644 index 76fb62a056..e67f564bdb --- a/whoisonline.php +++ b/whoisonline.php @@ -16,7 +16,6 @@ if (!isset($_GET['cidReq'])) { require_once './main/inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; - //social tab $this_section = SECTION_SOCIAL; // table definitions