Source for file helper.php

Documentation is available at helper.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  mod_whosonline
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Helper for mod_whosonline
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  mod_whosonline
  17.  * @since       1.5
  18.  */
  19. {
  20.     /**
  21.      * Show online count
  22.      *
  23.      * @return  array  The number of Users and Guests online.
  24.      *
  25.      * @since   1.5.0
  26.      ***/
  27.     public static function getOnlineCount()
  28.     {
  29.         $db        JFactory::getDbo();
  30.  
  31.         // Calculate number of guests and users
  32.         $result    array();
  33.         $user_array  0;
  34.         $guest_array 0;
  35.         $query    $db->getQuery(true)
  36.             ->select('guest, client_id')
  37.             ->from('#__session')
  38.             ->where('client_id = 0');
  39.         $db->setQuery($query);
  40.         $sessions = (array) $db->loadObjectList();
  41.  
  42.         if (count($sessions))
  43.         {
  44.             foreach ($sessions as $session)
  45.             {
  46.                 // If guest increase guest count by 1
  47.                 if ($session->guest == 1)
  48.                 {
  49.                     $guest_array ++;
  50.                 }
  51.  
  52.                 // If member increase member count by 1
  53.                 if ($session->guest == 0)
  54.                 {
  55.                     $user_array ++;
  56.                 }
  57.             }
  58.         }
  59.  
  60.         $result['user']  $user_array;
  61.         $result['guest'$guest_array;
  62.  
  63.         return $result;
  64.     }
  65.  
  66.     /**
  67.      * Show online member names
  68.      *
  69.      * @param   mixed  $params  The parameters
  70.      *
  71.      * @return  array   (array) $db->loadObjectList()  The names of the online users.
  72.      *
  73.      * @since   1.5.0
  74.      ***/
  75.     public static function getOnlineUserNames($params)
  76.     {
  77.         $db        JFactory::getDbo();
  78.         $query    $db->getQuery(true)
  79.             ->select($db->quoteName(array('a.username''a.time''a.userid''a.client_id')))
  80.             ->from('#__session AS a')
  81.             ->where($db->quoteName('a.userid'' != 0')
  82.             ->where($db->quoteName('a.client_id'' = 0')
  83.             ->group($db->quoteName(array('a.username''a.time''a.userid''a.client_id')));
  84.         $user JFactory::getUser();
  85.  
  86.         if (!$user->authorise('core.admin'&& $params->get('filter_groups'0== 1)
  87.         {
  88.             $groups $user->getAuthorisedGroups();
  89.  
  90.             if (empty($groups))
  91.             {
  92.                 return array();
  93.             }
  94.  
  95.             $query->join('LEFT''#__user_usergroup_map AS m ON m.user_id = a.userid')
  96.                 ->join('LEFT''#__usergroups AS ug ON ug.id = m.group_id')
  97.                 ->where('ug.id in (' implode(','$groups')')
  98.                 ->where('ug.id <> 1');
  99.         }
  100.  
  101.         $db->setQuery($query);
  102.  
  103.         return (array) $db->loadObjectList();
  104.     }
  105. }

Documentation generated on Tue, 19 Nov 2013 15:04:21 +0100 by phpDocumentor 1.4.3