Advertisement
Guest User

Untitled

a guest
May 8th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1. <?php if (!defined('APPLICATION')) exit();
  2. /**
  3.  * Renders a list of users who are taking part in a particular discussion.
  4.  */
  5. class WhosOnlineModule extends Gdn_Module {
  6.  
  7.    protected $_OnlineUsers;
  8.  
  9.    public function __construct(&$Sender = '') {
  10.       parent::__construct($Sender);
  11.    }
  12.  
  13.    public function GetData($Invisible = FALSE) {
  14.       $SQL = Gdn::SQL();
  15.      // $this->_OnlineUsers = $SQL
  16.      // insert or update entry into table
  17.      $Session = Gdn::Session();
  18.  
  19.  
  20.      if($Session->UserID && !$Invisible)
  21.         $SQL->Replace('Whosonline', array('UserID' => $Session->UserID, 'Timestamp' => time()), array('UserID' => $Session->UserID));
  22.  
  23.  
  24.      $Frequency = Gdn::Config('WhosOnline.Frequency', 4) * 2;
  25.      $History = time() - $Frequency;
  26.  
  27.      $this->_OnlineUsers = $SQL
  28.         ->Select('u.UserID, u.Photo, u.Email, u.Name, w.Timestamp')
  29.         ->From('Whosonline w')
  30.         ->Join('User u', 'w.UserID = u.UserID')
  31.         ->Where('w.Timestamp >=', $History)
  32.         ->OrderBy('u.Name')
  33.         ->Get();
  34.  
  35.    }
  36.  
  37.    public function AssetTarget() {
  38.       //return 'Foot';
  39.       return 'Panel';
  40.    }
  41.  
  42.    public function ToString() {
  43.       $String = '';
  44.       $Session = Gdn::Session();
  45.       ob_start();
  46.       ?>
  47. <div id="WhosOnline">
  48.       <div class="Header"><h4><?php echo T("Who's Online"); ?> (<?php echo $this->_OnlineUsers->NumRows(); ?>)</h4></div>
  49.         <div class="Box">
  50.             <div class="PhotoGridSmall">
  51.                 <?php
  52.                 if ($this->_OnlineUsers->NumRows() > 0) {
  53.                     foreach($this->_OnlineUsers->Result() as $User) {
  54.                         echo UserPhoto(UserBuilder($User),(isset($User->Invisible) ? 'Invisible' : 'ProfilePhotoMedium'));
  55.                         //echo Gdn_Format::Date($User->Timestamp);
  56.                     }
  57.                 }
  58.                 ?>
  59.             </div>
  60.         </div>
  61. </div>
  62.       <!--<div id="WhosOnline" class="Box">
  63.          <h4><?php echo Gdn::Translate("Who's Online"); ?> (<?php echo $this->_OnlineUsers->NumRows(); ?>)</h4>
  64.          <ul class="PanelInfo">
  65.             <?php
  66.             if($this->_OnlineUsers->NumRows() > 0) {
  67.                foreach($this->_OnlineUsers->Result() as $User) {
  68.                   ?>
  69.                   <li>
  70.                      <strong>
  71.                         <?php echo UserAnchor($User); ?>
  72.                      </strong>
  73.                      <?php echo Gdn_Format::Date($User->Timestamp); ?>
  74.                   </li>
  75.                   <?php
  76.                }
  77.             }
  78.             ?>
  79.          </ul>
  80.       </div>-->
  81.       <?php
  82.       $String = ob_get_contents();
  83.       @ob_end_clean();
  84.       return $String;
  85.    }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement