public function __get($param)
{
switch ($param) {
case 'name_support':
return $this->chat_nickname != '' ? trim($this->chat_nickname) : trim($this->name_official);
break;
case 'name_official':
$this->name_official = trim($this->name . ' ' . $this->surname);
$this->name_official = $this->name_official != '' ? $this->name_official : $this->chat_nickname;
return $this->name_official;
break;
case 'user_groups_id':
$userGroups = erLhcoreClassModelGroupUser::getList(array('filter' => array('user_id' => $this->id)));
$this->user_groups_id = array();
if (!empty($userGroups)) {
foreach ($userGroups as $userGroup) {
$this->user_groups_id[] = $userGroup->group_id;
}
}
return $this->user_groups_id;
break;
case 'lastactivity':
$db = ezcDbInstance::get();
$stmt = $db->prepare('SELECT last_activity FROM lh_userdep WHERE user_id = :user_id LIMIT 1');
$stmt->bindValue(':user_id', $this->id, PDO::PARAM_INT);
$stmt->execute();
$this->lastactivity = (int) $stmt->fetchColumn();
return $this->lastactivity;
break;
case 'has_photo':
return $this->filename != '';
break;
case 'photo_path':
$this->photo_path = ($this->filepath != '' ? erLhcoreClassSystem::instance()->wwwDir() : erLhcoreClassSystem::instance()->wwwImagesDir()) . '/' . $this->filepath . $this->filename;
return $this->photo_path;
break;
case 'file_path_server':
return $this->filepath . $this->filename;
break;
case 'lastactivity_front':
$this->lastactivity_front = '';
if ($this->lastactivity > 0) {
$this->lastactivity_front = date(erLhcoreClassModule::$dateDateHourFormat);
}
return $this->lastactivity_front;
break;
case 'lastactivity_ago':
$this->lastactivity_ago = '';
if ($this->lastactivity > 0) {
$periods = array("s.", "m.", "h.", "d.", "w.", "m.", "y.", "dec.");
$lengths = array("60", "60", "24", "7", "4.35", "12", "10");
$difference = time() - $this->lastactivity;
for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
$this->lastactivity_ago = "{$difference} {$periods[$j]}";
}
return $this->lastactivity_ago;
break;
default:
break;
}
}