Online indicator for user profile page SE4 mod

Started on the old forum in October 2014 · view the original in the archive · old links redirect here

No replies · 94 views · started 12 years ago · 1 min read

GumSlone Administrator Principal · 1,690 posts #1

This mod shows a online indicator in users profile, next to the name of the user.

open: /application/modules/User/widgets/profile-status/Controller.php find and after:

// Get subject and check auth
    $subject = Engine_Api::_()->core()->getSubject('user');
    //if( !$subject->authorization()->isAllowed($viewer, 'view') ) {
    //  return $this->setNoRender();
    //}

add this code:

    $onlineTable = Engine_Api::_()->getDbtable('online', 'user');
    $onlineTableName = $onlineTable->info('name');
 
    $select = $onlineTable->select()
    ->from($onlineTableName, array('COUNT(*) AS count'))
      ->where($onlineTableName.'.user_id = ?', $subject->user_id)
      ->where($onlineTableName.'.active > ?', new Zend_Db_Expr('DATE_SUB(NOW(),INTERVAL 20 MINUTE)'))
      ;
      $_is_online = $select->query()->fetchColumn(0);
      $this->view->is_online = $_is_online;

save changes!

open: /application/modules/User/widgets/profile-status/index.tpl find and after: PHP:

<?php echo $this->subject()->getTitle() ?>

add this code:

<?php
    if($this->is_online==1) echo '<span style="width:10px;height:10px;background-color:#5cb85c;border: 1px solid #4cae4c;border-radius:5px;color:white;font-size:12px;vertical-align:middle;">'.$this->translate('online').'</span>'
    ?>

Done!

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close