Example #1
0
function pleio_api_get_online_users()
{
    $query = sprintf("SELECT * FROM %susers_apisessions ORDER BY expires LIMIT 10", get_config("dbprefix"));
    $result = array();
    foreach (get_data($query) as $u) {
        if ($u->expires > time()) {
            $o = get_user_entity_as_row($u->user_guid);
            $o->expires = $u->expires;
            $o->expiresDate = date("d-m-Y H:i:s", $u->expires);
            $result[$u->user_guid] = $o;
        }
    }
    return $result;
}
 /**
  * Override the load function.
  * This function will ensure that all data is loaded (were possible), so
  * if only part of the ElggUser is loaded, it'll load the rest.
  * 
  * @param int $guid
  * @return true|false 
  */
 protected function load($guid)
 {
     // Test to see if we have the generic stuff
     if (!parent::load($guid)) {
         return false;
     }
     // Check the type
     if ($this->attributes['type'] != 'user') {
         throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));
     }
     // Load missing data
     $row = get_user_entity_as_row($guid);
     if ($row && !$this->isFullyLoaded()) {
         $this->attributes['tables_loaded']++;
     }
     // If $row isn't a cached copy then increment the counter
     // Now put these into the attributes array as core values
     $objarray = (array) $row;
     foreach ($objarray as $key => $value) {
         $this->attributes[$key] = $value;
     }
     return true;
 }
Example #3
0
 /**
  * Load the ElggUser data from the database
  *
  * @param mixed $guid ElggUser GUID or stdClass database row from entity table
  *
  * @return bool
  */
 protected function load($guid)
 {
     // Test to see if we have the generic stuff
     if (!parent::load($guid)) {
         return false;
     }
     // Only work with GUID from here
     if ($guid instanceof stdClass) {
         $guid = $guid->guid;
     }
     // Check the type
     if ($this->attributes['type'] != 'user') {
         $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class()));
         throw new InvalidClassException($msg);
     }
     // Load missing data
     $row = get_user_entity_as_row($guid);
     if ($row && !$this->isFullyLoaded()) {
         // If $row isn't a cached copy then increment the counter
         $this->attributes['tables_loaded']++;
     }
     // Now put these into the attributes array as core values
     $objarray = (array) $row;
     foreach ($objarray as $key => $value) {
         $this->attributes[$key] = $value;
     }
     // guid needs to be an int  http://trac.elgg.org/ticket/4111
     $this->attributes['guid'] = (int) $this->attributes['guid'];
     return true;
 }