2009-05-10 10:50:39 +03:00
|
|
|
|
<?php
|
2014-10-08 08:20:29 +03:00
|
|
|
|
/*
|
|
|
|
|
* LiveStreet CMS
|
|
|
|
|
* Copyright © 2013 OOO "ЛС-СОФТ"
|
|
|
|
|
*
|
|
|
|
|
* ------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* Official site: www.livestreetcms.com
|
|
|
|
|
* Contact e-mail: office@livestreetcms.com
|
|
|
|
|
*
|
|
|
|
|
* GNU General Public License, version 2:
|
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
|
*
|
|
|
|
|
* ------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* @link http://www.livestreetcms.com
|
|
|
|
|
* @copyright 2013 OOO "ЛС-СОФТ"
|
|
|
|
|
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
*/
|
2008-09-21 09:36:57 +03:00
|
|
|
|
|
|
|
|
|
/**
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* Экшен обработки статистики юзеров, т.е. УРЛа вида /people/
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*
|
2014-10-08 08:20:29 +03:00
|
|
|
|
* @package application.actions
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* @since 1.0
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2014-10-08 11:49:34 +03:00
|
|
|
|
class ActionPeople extends Action
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Главное меню
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $sMenuHeadItemSelect = 'people';
|
|
|
|
|
/**
|
|
|
|
|
* Меню
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $sMenuItemSelect = 'all';
|
2012-04-16 17:40:14 +03:00
|
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Инициализация
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function Init()
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем title страницы
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user.users'));
|
|
|
|
|
}
|
2012-03-30 17:09:32 +03:00
|
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Регистрируем евенты
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function RegisterEvent()
|
|
|
|
|
{
|
|
|
|
|
$this->AddEventPreg('/^(index)?$/i', '/^(page([1-9]\d{0,5}))?$/i', '/^$/i', 'EventIndex');
|
|
|
|
|
$this->AddEventPreg('/^ajax-search$/i', 'EventAjaxSearch');
|
|
|
|
|
}
|
2012-04-16 17:40:14 +03:00
|
|
|
|
|
2012-03-30 17:09:32 +03:00
|
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**********************************************************************************
|
|
|
|
|
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
|
|
|
|
|
**********************************************************************************
|
|
|
|
|
*/
|
2012-04-13 20:37:50 +03:00
|
|
|
|
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Поиск пользователей по логину
|
|
|
|
|
*/
|
|
|
|
|
protected function EventAjaxSearch()
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
/**
|
|
|
|
|
* Формируем фильтр
|
|
|
|
|
*/
|
|
|
|
|
$aFilter = array(
|
|
|
|
|
'activate' => 1
|
|
|
|
|
);
|
|
|
|
|
$sOrderWay = in_array(getRequestStr('order'), array('desc', 'asc')) ? getRequestStr('order') : 'desc';
|
|
|
|
|
$sOrderField = in_array(getRequestStr('sort_by'), array(
|
2014-11-28 09:30:15 +02:00
|
|
|
|
'user_rating',
|
|
|
|
|
'user_date_register',
|
|
|
|
|
'user_login',
|
|
|
|
|
'user_profile_name'
|
|
|
|
|
)) ? getRequestStr('sort_by') : 'user_rating';
|
2014-10-08 11:49:34 +03:00
|
|
|
|
if (is_numeric(getRequestStr('pageNext')) and getRequestStr('pageNext') > 0) {
|
|
|
|
|
$iPage = getRequestStr('pageNext');
|
|
|
|
|
} else {
|
|
|
|
|
$iPage = 1;
|
|
|
|
|
}
|
|
|
|
|
/**
|
2014-10-30 19:52:20 +02:00
|
|
|
|
* Получаем из реквеста первые буквы для поиска пользователей по логину
|
2014-10-08 11:49:34 +03:00
|
|
|
|
*/
|
|
|
|
|
$sTitle = getRequest('sText');
|
|
|
|
|
if (is_string($sTitle) and mb_strlen($sTitle, 'utf-8')) {
|
|
|
|
|
$sTitle = str_replace(array('_', '%'), array('\_', '\%'), $sTitle);
|
|
|
|
|
} else {
|
|
|
|
|
$sTitle = '';
|
|
|
|
|
}
|
|
|
|
|
/**
|
2014-10-30 19:52:20 +02:00
|
|
|
|
* Как именно искать: совпадение в любой части логина, или только начало или конец логина
|
2014-10-08 11:49:34 +03:00
|
|
|
|
*/
|
|
|
|
|
if ($sTitle) {
|
|
|
|
|
if (getRequest('isPrefix')) {
|
|
|
|
|
$sTitle .= '%';
|
|
|
|
|
} elseif (getRequest('isPostfix')) {
|
|
|
|
|
$sTitle = '%' . $sTitle;
|
|
|
|
|
} else {
|
|
|
|
|
$sTitle = '%' . $sTitle . '%';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($sTitle) {
|
|
|
|
|
$aFilter['login'] = $sTitle;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Пол
|
|
|
|
|
*/
|
|
|
|
|
if (in_array(getRequestStr('sex'), array('man', 'woman', 'other'))) {
|
|
|
|
|
$aFilter['profile_sex'] = getRequestStr('sex');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Онлайн
|
|
|
|
|
* date_last
|
|
|
|
|
*/
|
|
|
|
|
if (getRequest('is_online')) {
|
|
|
|
|
$aFilter['date_last_more'] = date('Y-m-d H:i:s', time() - Config::Get('module.user.time_onlive'));
|
|
|
|
|
}
|
2014-11-28 09:30:15 +02:00
|
|
|
|
/**
|
|
|
|
|
* Geo привязка
|
|
|
|
|
*/
|
|
|
|
|
if (getRequestStr('city')) {
|
|
|
|
|
$aFilter['geo_city'] = getRequestStr('city');
|
|
|
|
|
} elseif (getRequestStr('region')) {
|
|
|
|
|
$aFilter['geo_region'] = getRequestStr('region');
|
|
|
|
|
} elseif (getRequestStr('country')) {
|
|
|
|
|
$aFilter['geo_country'] = getRequestStr('country');
|
|
|
|
|
}
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Ищем пользователей
|
|
|
|
|
*/
|
|
|
|
|
$aResult = $this->User_GetUsersByFilter($aFilter, array($sOrderField => $sOrderWay), $iPage,
|
|
|
|
|
Config::Get('module.user.per_page'));
|
|
|
|
|
$bHideMore = $iPage * Config::Get('module.user.per_page') >= $aResult['count'];
|
|
|
|
|
/**
|
|
|
|
|
* Формируем ответ
|
|
|
|
|
*/
|
|
|
|
|
$oViewer = $this->Viewer_GetLocalViewer();
|
2014-11-10 14:47:55 +02:00
|
|
|
|
$oViewer->Assign('users', $aResult['collection'], true);
|
2014-10-08 11:49:34 +03:00
|
|
|
|
$oViewer->Assign('oUserCurrent', $this->User_GetUserCurrent());
|
2014-11-10 14:47:55 +02:00
|
|
|
|
$oViewer->Assign('textEmpty', $this->Lang_Get('search.alerts.empty'), true);
|
2014-11-09 16:19:58 +02:00
|
|
|
|
$oViewer->Assign('useMore', true, true);
|
|
|
|
|
$oViewer->Assign('hideMore', $bHideMore, true);
|
|
|
|
|
$oViewer->Assign('searchCount', $aResult['count'], true);
|
2014-10-08 11:49:34 +03:00
|
|
|
|
$this->Viewer_AssignAjax('sText', $oViewer->Fetch("components/user/user-list.tpl"));
|
|
|
|
|
/**
|
|
|
|
|
* Для подгрузки
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_AssignAjax('count_loaded', count($aResult['collection']));
|
|
|
|
|
$this->Viewer_AssignAjax('pageNext', count($aResult['collection']) > 0 ? $iPage + 1 : $iPage);
|
|
|
|
|
$this->Viewer_AssignAjax('bHideMore', $bHideMore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Показываем юзеров
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventIndex()
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Получаем статистику
|
|
|
|
|
*/
|
|
|
|
|
$this->GetStats();
|
|
|
|
|
$aFilter = array(
|
|
|
|
|
'activate' => 1
|
|
|
|
|
);
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список юзеров
|
|
|
|
|
*/
|
|
|
|
|
$aResult = $this->User_GetUsersByFilter($aFilter, array('user_rating' => 'desc'), 1,
|
|
|
|
|
Config::Get('module.user.per_page'));
|
|
|
|
|
/**
|
|
|
|
|
* Получаем алфавитный указатель на список пользователей
|
|
|
|
|
*/
|
|
|
|
|
$aPrefixUser = $this->User_GetGroupPrefixUser(1);
|
2014-11-25 13:45:51 +02:00
|
|
|
|
/**
|
|
|
|
|
* Список используемых стран
|
|
|
|
|
*/
|
2014-11-28 09:30:15 +02:00
|
|
|
|
$aCountriesUsed = $this->Geo_GetCountriesUsedByTargetType('user');
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aUsers', $aResult['collection']);
|
|
|
|
|
$this->Viewer_Assign('iSearchCount', $aResult['count']);
|
|
|
|
|
$this->Viewer_Assign('aPrefixUser', $aPrefixUser);
|
2014-11-25 13:45:51 +02:00
|
|
|
|
$this->Viewer_Assign('aCountriesUsed', $aCountriesUsed);
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('index');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Получение статистики
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function GetStats()
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Статистика кто, где и т.п.
|
|
|
|
|
*/
|
|
|
|
|
$aStat = $this->User_GetStatUsers();
|
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aStat', $aStat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Выполняется при завершении работы экшена
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function EventShutdown()
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон необходимые переменные
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('sMenuHeadItemSelect', $this->sMenuHeadItemSelect);
|
|
|
|
|
$this->Viewer_Assign('sMenuItemSelect', $this->sMenuItemSelect);
|
|
|
|
|
}
|
2014-10-30 19:52:20 +02:00
|
|
|
|
}
|