/** * Возвращает родстер (список контактов) пользователя. * * @param stdClass $attr - список параметров * string type : all - вернуть всех пользователей, active - вернуть только "активных". * Обязательные параметр. @see self::ACTIVE_CONTACT * integer online: 1 - возвращать только пользователей находящихся на сайте, 0 - всех * * @return array - массив с пользователями */ protected function _ceContacts($attr) { global $session; $messages = new messages(); if (is_emp($this->_uid)) { $sbr = new sbr_emp($this->_uid); } else { $sbr = new sbr_frl($this->_uid); } $rows = array_merge($messages->GetContacts($this->_uid), $sbr->getContacts()); $uids = array(); $res = array(); foreach ($rows as $row) { if (in_array($row['uid'], $uids) || $row['login'] == 'admin') { continue; } $uids[] = $row['uid']; if ($attr->type == 'active' && (isset($row['my_last_post']) || isset($row['his_last_post']))) { $last = max(strtotime($row['my_last_post']), strtotime($row['his_last_post'])); if ($last + self::ACTIVE_CONTACT < time()) { continue; } } $session->view_online_status($row['login']); $row['online'] = $session->is_active; if (!empty($attr->online) && !$row['online']) { continue; } $res[] = array('uid' => $row['uid'], 'name' => $row['uname'] ? iconv('CP1251', 'UTF-8', $row['uname'] . ' ' . $row['usurname']) : $row['login'], 'login' => $row['login'], 'online' => (int) $row['online'], 'avatar' => $row['photo'] ? WDCPREFIX . '/users/' . $row['login'] . '/foto/sm_' . $row['photo'] : '', 'emp' => (int) is_emp($row['role']), 'pro' => (int) ($row['is_pro'] == 't')); } return $res; }