[solved] online/offline/hidden indicator - how?


  -----  
Author Message

jerx
Member

Fri Aug 26, 2005 12:41 am   Post subject: [solved] online/offline/hidden indicator - how?
The contact list already has a similar feature, but I think it might be good to have the online/offline/hidden status listed as well.

I wasn' t able to do this on my own. I think I used the wrong code and modified the wrong files again.

These are the instructions for the memberlist:

Code:


#-----[ OPEN ]------------------------------------------
#
templates/subSilver/memberlist_body.tpl

#
#-----[ FIND ]------------------------------------------
#
     <th class="thTop" nowrap="nowrap">{L_JOINED}</th>
#
#-----[ AFTER, ADD ]------------------------------------------
#
     <th class="thTop" nowrap="nowrap">{L_ONLINE_STATUS}</th>
#
#-----[ FIND ]------------------------------------------
#
     <td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gensmall">{memberrow.JOINED}</span></td>
#
#-----[ AFTER, ADD ]------------------------------------------
#
     <td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gen">{memberrow.ONLINE_STATUS_IMG}</span></td>
#
#-----[ FIND ]------------------------------------------
#
     <td class="catBottom" colspan="8" height="28">&nbsp;</td>
#
#-----[ REPLACE WITH ]------------------------------------------
# or ADD +1 unit to 'colspan' if other Mods have been installed
#
     <td class="catBottom" colspan="9" height="28">&nbsp;</td>



#
#-----[ OPEN ]------------------------------------------
#
memberlist.php

#
#-----[ FIND ]------------------------------------------
#
   'L_POSTS' => $lang['Posts'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
   // Start add - Online/Offline/Hidden Mod
   'L_ONLINE_STATUS' => $lang['Online_status'],
   // End add - Online/Offline/Hidden Mod
#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT username
#
#-----[ IN-LINE FIND ]------------------------------------------
#
user_avatar_type, user_allowavatar
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, user_allow_viewonline, user_session_time
#
#-----[ FIND ]------------------------------------------
#
      $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
#
#-----[ AFTER, ADD ]------------------------------------------
#
      // Start add - Online/Offline/Hidden Mod
      if ( $row['user_session_time'] >= (time()-$board_config['online_time']) )
      {
         if ( $row['user_allow_viewonline'] )
         {
            $online_status_img = '<a href="' . append_sid("viewonline.$phpEx") . '"><img src="' . $images['icon_online'] . '" alt="' . sprintf($lang['is_online'], $username) . '" title="' . sprintf($lang['is_online'], $username) . '" /></a>';
            $online_status = '<strong><a href="' . append_sid("viewonline.$phpEx") . '" title="' . sprintf($lang['is_online'], $username) . '"' . $online_color . '>' . $lang['Online'] . '</a></strong>';
         }
         else if ( $userdata['user_level'] == ADMIN || $userdata['user_id'] == $user_id )
         {
            $online_status_img = '<a href="' . append_sid("viewonline.$phpEx") . '"><img src="' . $images['icon_hidden'] . '" alt="' . sprintf($lang['is_hidden'], $username) . '" title="' . sprintf($lang['is_hidden'], $username) . '" /></a>';
            $online_status = '<strong><em><a href="' . append_sid("viewonline.$phpEx") . '" title="' . sprintf($lang['is_hidden'], $username) . '"' . $hidden_color . '>' . $lang['Hidden'] . '</a></em></strong>';
         }
         else
         {
            $online_status_img = '<img src="' . $images['icon_offline'] . '" alt="' . sprintf($lang['is_offline'], $username) . '" title="' . sprintf($lang['is_offline'], $username) . '" />';
            $online_status = '<span title="' . sprintf($lang['is_offline'], $username) . '"' . $offline_color . '><strong>' . $lang['Offline'] . '</strong></span>';
         }
      }
      else
      {
         $online_status_img = '<img src="' . $images['icon_offline'] . '" alt="' . sprintf($lang['is_offline'], $username) . '" title="' . sprintf($lang['is_offline'], $username) . '" />';
         $online_status = '<span title="' . sprintf($lang['is_offline'], $username) . '"' . $offline_color . '><strong>' . $lang['Offline'] . '</strong></span>';
      }
      // End add - Online/Offline/Hidden Mod
#
#-----[ FIND ]------------------------------------------
#
         'YIM' => $yim,
#
#-----[ AFTER, ADD ]------------------------------------------
#
         // Start add - Online/Offline/Hidden Mod
         'ONLINE_STATUS_IMG' => $online_status_img,
         'ONLINE_STATUS' => $online_status,
         // End add - Online/Offline/Hidden Mod


I did the following:
1. show.tpl

Code:


<th class="thTop" nowrap="nowrap">Status</th>
<td class="{list.list_row.ROW_CLASS}" align="center" valign="middle">{list.list_row.POSTER_ONLINE_STATUS}</td>

This seems to have only an effect on the "buddy of" listing. And even there the indicator doesn' t show up.

2. contactcp_show.php

Code:


   foreach($contact_list->$temp_type as $key=>$val)
   {
      $avatar_img = ($val['user_avatar'] && $val['user_avatar_type']==1 ? '<img src=images/avatars/' . $val['user_avatar'] . ' width="40" height="40">' :($val['user_avatar'] && $val['user_avatar_type']==2 ? '<img src=' . $val['user_avatar'] . ' width="40" height="40">' : ($val['user_avatar'] && $val['user_avatar_type']==3 ? '<img src=images/avatars/gallery/' . $val['user_avatar'] . ' width="40" height="40">' : false)));
      $profile_url = append_sid($temp_profile_url . $key);
      $s_checked = ( $val['alert'] ) ? 'checked="checked"' : '';
      $profile_img = '<a href="' . $profile_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
      $profile = '<a href="' . $profile_url . '">' . $lang['Read_profile'] . '</a>';

// Start add - Online/Offline/Hidden Mod
      if ( $val['user_session_time'] >= (time()-$board_config['online_time']) )
      {
         if ( $val['user_allow_viewonline'] )
         {
            $online_status_img = '<a href="' . append_sid("viewonline.$phpEx") . '"><img src="' . $images['icon_online'] . '" alt="' . sprintf($lang['is_online'], $username) . '" title="' . sprintf($lang['is_online'], $username) . '" /></a>';
            $online_status = '<strong><a href="' . append_sid("viewonline.$phpEx") . '" title="' . sprintf($lang['is_online'], $username) . '"' . $online_color . '>' . $lang['Online'] . '</a></strong>';
         }
         else if ( $userdata['user_level'] == ADMIN || $userdata['user_id'] == $user_id )
         {
            $online_status_img = '<a href="' . append_sid("viewonline.$phpEx") . '"><img src="' . $images['icon_hidden'] . '" alt="' . sprintf($lang['is_hidden'], $username) . '" title="' . sprintf($lang['is_hidden'], $username) . '" /></a>';
            $online_status = '<strong><em><a href="' . append_sid("viewonline.$phpEx") . '" title="' . sprintf($lang['is_hidden'], $username) . '"' . $hidden_color . '>' . $lang['Hidden'] . '</a></em></strong>';
         }
         else
         {
            $online_status_img = '<img src="' . $images['icon_offline'] . '" alt="' . sprintf($lang['is_offline'], $username) . '" title="' . sprintf($lang['is_offline'], $username) . '" />';
            $online_status = '<span title="' . sprintf($lang['is_offline'], $username) . '"' . $offline_color . '><strong>' . $lang['Offline'] . '</strong></span>';
         }
      }
      else
      {
         $online_status_img = '<img src="' . $images['icon_offline'] . '" alt="' . sprintf($lang['is_offline'], $username) . '" title="' . sprintf($lang['is_offline'], $username) . '" />';
         $online_status = '<span title="' . sprintf($lang['is_offline'], $username) . '"' . $offline_color . '><strong>' . $lang['Offline'] . '</strong></span>';
      }
// End add - Online/Offline/Hidden Mod

Code:


$template->assign_block_vars('list.list_row', array(
         'ROW_NUMBER' => $i + ( $start + 1 ),
         'ROW_COLOR' => '#' . $row_color,
         'ROW_CLASS' => $row_class,
         'AVATAR_IMG' => $avatar_img,
         // Start add - Online/Offline/Hidden Mod
         'ONLINE_STATUS_IMG' => $online_status_img,
         'ONLINE_STATUS' => $online_status,
         // End add - Online/Offline/Hidden Mod


3. class_contact.php

Code:


$sql = 'SELECT ' . $fields_sql . ', u.username, u.user_avatar, u.user_avatar_type, user_allow_viewonline, user_session_time FROM ' . CONTACT_TABLE . ' c, ' . USERS_TABLE . ' u WHERE u.user_id = ' . $field_check_sql;



Does anyone know what I have done wrong? Or is there an easier way to add the indicator, eg by using the alert code?

Last edited by jerx on Fri Aug 26, 2005 10:04 pm; edited 1 time in total
 

Thoul
Administrator

Fri Aug 26, 2005 6:20 pm   Post subject: re: online/offline/hidden indicator - how?
In show.tpl, change {list.list_row.POSTER_ONLINE_STATUS} to {list.list_row.ONLINE_STATUS}.

Quote:

This seems to have only an effect on the "buddy of" listing. And even there the indicator doesn' t show up.


The other pages use edit.tpl, so you'll need to make the same change to that file in order for them to show up.

All of the instances of $username in the code added to contactcp_show.php need to be changed to $val['username']. And also this line in that file:

Code:

         else if ( $userdata['user_level'] == ADMIN || $userdata['user_id'] == $user_id )


Could be changed to just:

Code:

         else if ( $userdata['user_level'] == ADMIN )


Other than that, it looks pretty good to me. Give these changes a try and let us know how it goes. Smile
 

jerx
Member

Fri Aug 26, 2005 10:02 pm   Post subject:
Once again: thank you so much, Thoul! It works like a charm.

Now the contact list has all the features I need and I stop bothering you with questions concerning it. But don' t feel relieved, there are many other mods you coded... Wink
 

WhirlyGirl
Member

Sat Jun 17, 2006 6:03 pm   Post subject:
Hi,

The code you have posted above looks like it could be an excellent and useful function. What would happen if you only want to show the online/offline status in the contact list (and not the member list)? I have tried using only the show.tpl code, but it doesn't work by it's self so I'm assuming there needs to be some more code for it to work correctly.

Many thanks,

WG
 

Page 1 of 1
Display posts from previous: