2009-05-10 10:50:39 +03:00
|
|
|
|
<?php
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/*-------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* LiveStreet Engine Social Networking
|
|
|
|
|
* Copyright © 2008 Mzhelskiy Maxim
|
|
|
|
|
*
|
|
|
|
|
*--------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* Official site: www.livestreet.ru
|
|
|
|
|
* Contact e-mail: rus.engine@gmail.com
|
|
|
|
|
*
|
|
|
|
|
* GNU General Public License, version 2:
|
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
|
*
|
|
|
|
|
---------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* Экшен обработки статистики юзеров, т.е. УРЛа вида /people/
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* @package actions
|
|
|
|
|
* @since 1.0
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
|
|
|
|
class ActionPeople extends Action {
|
2012-04-13 20:37:50 +03:00
|
|
|
|
/**
|
|
|
|
|
* Главное меню
|
|
|
|
|
*
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* @var string
|
2012-04-13 20:37:50 +03:00
|
|
|
|
*/
|
|
|
|
|
protected $sMenuHeadItemSelect='people';
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Меню
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2012-04-20 13:36:07 +03:00
|
|
|
|
protected $sMenuItemSelect='all';
|
2012-04-16 17:40:14 +03:00
|
|
|
|
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Инициализация
|
|
|
|
|
*
|
|
|
|
|
*/
|
2010-02-06 02:09:44 +02:00
|
|
|
|
public function Init() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем title страницы
|
|
|
|
|
*/
|
2009-11-23 16:01:48 +02:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('people'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Регистрируем евенты
|
|
|
|
|
*
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
protected function RegisterEvent() {
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$this->AddEvent('online','EventOnline');
|
2009-06-13 00:54:04 +03:00
|
|
|
|
$this->AddEvent('new','EventNew');
|
2012-07-09 08:47:42 +03:00
|
|
|
|
$this->AddEventPreg('/^(index)?$/i','/^(page([1-9]\d{0,5}))?$/i','/^$/i','EventIndex');
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$this->AddEventPreg('/^ajax-search$/i','EventAjaxSearch');
|
|
|
|
|
|
2012-07-09 08:47:42 +03:00
|
|
|
|
$this->AddEventPreg('/^country$/i','/^\d+$/i','/^(page([1-9]\d{0,5}))?$/i','EventCountry');
|
|
|
|
|
$this->AddEventPreg('/^city$/i','/^\d+$/i','/^(page([1-9]\d{0,5}))?$/i','EventCity');
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
2012-04-16 17:40:14 +03:00
|
|
|
|
|
|
|
|
|
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**********************************************************************************
|
|
|
|
|
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
|
|
|
|
|
**********************************************************************************
|
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
|
|
|
|
|
/**
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* Поиск пользователей по логину
|
2012-03-30 17:09:32 +03:00
|
|
|
|
*/
|
|
|
|
|
protected function EventAjaxSearch() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем из реквеста первые быквы для поиска пользователей по логину
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$sTitle=getRequest('user_login');
|
|
|
|
|
if (is_string($sTitle) and mb_strlen($sTitle,'utf-8')) {
|
|
|
|
|
$sTitle=str_replace(array('_','%'),array('\_','\%'),$sTitle);
|
|
|
|
|
} else {
|
2014-01-28 11:29:59 +02:00
|
|
|
|
$this->Viewer_AssignAjax('bShowOriginal',true);
|
|
|
|
|
return;
|
2012-03-30 17:09:32 +03:00
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Как именно искать: совпадение в любой частилогина, или только начало или конец логина
|
|
|
|
|
*/
|
2012-04-06 12:30:02 +03:00
|
|
|
|
if (getRequest('isPrefix')) {
|
|
|
|
|
$sTitle.='%';
|
|
|
|
|
} elseif (getRequest('isPostfix')) {
|
|
|
|
|
$sTitle='%'.$sTitle;
|
|
|
|
|
} else {
|
|
|
|
|
$sTitle='%'.$sTitle.'%';
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Ищем пользователей
|
|
|
|
|
*/
|
2012-04-13 03:31:51 +03:00
|
|
|
|
$aResult=$this->User_GetUsersByFilter(array('activate' => 1,'login'=>$sTitle),array('user_rating'=>'desc'),1,50);
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Формируем ответ
|
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$oViewer=$this->Viewer_GetLocalViewer();
|
|
|
|
|
$oViewer->Assign('aUsersList',$aResult['collection']);
|
2012-05-11 17:10:47 +03:00
|
|
|
|
$oViewer->Assign('oUserCurrent',$this->User_GetUserCurrent());
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$oViewer->Assign('sUserListEmpty',$this->Lang_Get('user_search_empty'));
|
|
|
|
|
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("user_list.tpl"));
|
|
|
|
|
}
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Показывает юзеров по стране
|
|
|
|
|
*
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
protected function EventCountry() {
|
2012-06-29 15:40:01 +03:00
|
|
|
|
$this->sMenuItemSelect='country';
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Страна существует?
|
|
|
|
|
*/
|
2012-03-23 15:18:02 +02:00
|
|
|
|
if (!($oCountry=$this->Geo_GetCountryById($this->getParam(0)))) {
|
2009-04-07 17:59:43 +03:00
|
|
|
|
return parent::EventNotFound();
|
2009-01-24 00:46:27 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем статистику
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->GetStats();
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
2012-03-23 15:18:02 +02:00
|
|
|
|
* Получаем список вязей пользователей со страной
|
2012-04-16 17:40:14 +03:00
|
|
|
|
*/
|
2012-03-23 15:18:02 +02:00
|
|
|
|
$aResult=$this->Geo_GetTargets(array('country_id'=>$oCountry->getId(),'target_type'=>'user'),$iPage,Config::Get('module.user.per_page'));
|
|
|
|
|
$aUsersId=array();
|
|
|
|
|
foreach($aResult['collection'] as $oTarget) {
|
|
|
|
|
$aUsersId[]=$oTarget->getTargetId();
|
|
|
|
|
}
|
|
|
|
|
$aUsersCountry=$this->User_GetUsersAdditionalData($aUsersId);
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
2012-04-16 17:40:14 +03:00
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('people').$this->sCurrentEvent.'/'.$oCountry->getId());
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
if ($aUsersCountry) {
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
}
|
2009-01-24 00:46:27 +02:00
|
|
|
|
$this->Viewer_Assign('oCountry',$oCountry);
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->Viewer_Assign('aUsersCountry',$aUsersCountry);
|
2009-01-24 00:46:27 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Показывает юзеров по городу
|
|
|
|
|
*
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
protected function EventCity() {
|
2012-06-29 15:40:01 +03:00
|
|
|
|
$this->sMenuItemSelect='city';
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Город существует?
|
|
|
|
|
*/
|
2012-03-23 15:18:02 +02:00
|
|
|
|
if (!($oCity=$this->Geo_GetCityById($this->getParam(0)))) {
|
2009-04-07 17:59:43 +03:00
|
|
|
|
return parent::EventNotFound();
|
2009-01-24 00:46:27 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем статистику
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->GetStats();
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список юзеров
|
2012-03-23 15:18:02 +02:00
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->Geo_GetTargets(array('city_id'=>$oCity->getId(),'target_type'=>'user'),$iPage,Config::Get('module.user.per_page'));
|
|
|
|
|
$aUsersId=array();
|
|
|
|
|
foreach($aResult['collection'] as $oTarget) {
|
|
|
|
|
$aUsersId[]=$oTarget->getTargetId();
|
|
|
|
|
}
|
|
|
|
|
$aUsersCity=$this->User_GetUsersAdditionalData($aUsersId);
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
2012-04-16 17:40:14 +03:00
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('people').$this->sCurrentEvent.'/'.$oCity->getId());
|
2009-01-24 00:46:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
if ($aUsersCity) {
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
}
|
2009-01-24 00:46:27 +02:00
|
|
|
|
$this->Viewer_Assign('oCity',$oCity);
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->Viewer_Assign('aUsersCity',$aUsersCity);
|
2009-01-24 00:46:27 +02:00
|
|
|
|
}
|
2009-01-20 21:45:16 +02:00
|
|
|
|
/**
|
|
|
|
|
* Показываем последних на сайте
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventOnline() {
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuItemSelect='online';
|
2009-08-08 12:33:32 +03:00
|
|
|
|
/**
|
|
|
|
|
* Последние по визиту на сайт
|
|
|
|
|
*/
|
|
|
|
|
$aUsersLast=$this->User_GetUsersByDateLast(15);
|
|
|
|
|
$this->Viewer_Assign('aUsersLast',$aUsersLast);
|
2009-01-20 21:45:16 +02:00
|
|
|
|
/**
|
|
|
|
|
* Получаем статистику
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->GetStats();
|
2009-01-20 21:45:16 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Показываем новых на сайте
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventNew() {
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuItemSelect='new';
|
2009-08-08 12:33:32 +03:00
|
|
|
|
/**
|
|
|
|
|
* Последние по регистрации
|
|
|
|
|
*/
|
|
|
|
|
$aUsersRegister=$this->User_GetUsersByDateRegister(15);
|
|
|
|
|
$this->Viewer_Assign('aUsersRegister',$aUsersRegister);
|
2009-01-20 21:45:16 +02:00
|
|
|
|
/**
|
|
|
|
|
* Получаем статистику
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$this->GetStats();
|
2009-01-20 21:45:16 +02:00
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-30 17:09:32 +03:00
|
|
|
|
* Показываем юзеров
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*
|
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
protected function EventIndex() {
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем статистику
|
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$this->GetStats();
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-30 17:09:32 +03:00
|
|
|
|
* По какому полю сортировать
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$sOrder='user_rating';
|
|
|
|
|
if (getRequest('order')) {
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$sOrder=getRequestStr('order');
|
2012-03-30 17:09:32 +03:00
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-30 17:09:32 +03:00
|
|
|
|
* В каком направлении сортировать
|
|
|
|
|
*/
|
|
|
|
|
$sOrderWay='desc';
|
|
|
|
|
if (getRequest('order_way')) {
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$sOrderWay=getRequestStr('order_way');
|
2012-03-30 17:09:32 +03:00
|
|
|
|
}
|
|
|
|
|
$aFilter=array(
|
|
|
|
|
'activate' => 1
|
|
|
|
|
);
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-30 17:09:32 +03:00
|
|
|
|
* Передан ли номер страницы
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$iPage=$this->GetParamEventMatch(0,2) ? $this->GetParamEventMatch(0,2) : 1;
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-30 17:09:32 +03:00
|
|
|
|
* Получаем список юзеров
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$aResult=$this->User_GetUsersByFilter($aFilter,array($sOrder=>$sOrderWay),$iPage,Config::Get('module.user.per_page'));
|
|
|
|
|
$aUsers=$aResult['collection'];
|
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('people').'index',array('order'=>$sOrder,'order_way'=>$sOrderWay));
|
2012-04-06 12:30:02 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем алфавитный указатель на список пользователей
|
|
|
|
|
*/
|
|
|
|
|
$aPrefixUser=$this->User_GetGroupPrefixUser(1);
|
2012-03-30 17:09:32 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aUsersRating',$aUsers);
|
2012-04-06 12:30:02 +03:00
|
|
|
|
$this->Viewer_Assign('aPrefixUser',$aPrefixUser);
|
2012-03-30 17:09:32 +03:00
|
|
|
|
$this->Viewer_Assign("sUsersOrder",htmlspecialchars($sOrder));
|
|
|
|
|
$this->Viewer_Assign("sUsersOrderWay",htmlspecialchars($sOrderWay));
|
|
|
|
|
$this->Viewer_Assign("sUsersOrderWayNext",htmlspecialchars($sOrderWay=='desc' ? 'asc' : 'desc'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
2012-04-16 17:40:14 +03:00
|
|
|
|
*/
|
2008-09-21 09:36:57 +03:00
|
|
|
|
$this->SetTemplateAction('index');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получение статистики
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function GetStats() {
|
|
|
|
|
/**
|
|
|
|
|
* Статистика кто, где и т.п.
|
|
|
|
|
*/
|
2012-04-16 17:40:14 +03:00
|
|
|
|
$aStat=$this->User_GetStatUsers();
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aStat',$aStat);
|
2009-02-14 13:56:04 +02:00
|
|
|
|
}
|
2012-04-13 20:37:50 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Выполняется при завершении работы экшена
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function EventShutdown() {
|
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон необходимые переменные
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->Viewer_Assign('sMenuItemSelect',$this->sMenuItemSelect);
|
2012-04-13 20:37:50 +03:00
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
?>
|