2011-06-06 14:58:19 +03:00
|
|
|
|
<?php
|
2011-07-31 19:52:50 +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
|
|
|
|
|
*
|
|
|
|
|
---------------------------------------------------------
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* Экшен обработки ленты активности
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* @package actions
|
|
|
|
|
* @since 1.0
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*/
|
|
|
|
|
class ActionStream extends Action {
|
|
|
|
|
/**
|
|
|
|
|
* Текущий пользователь
|
|
|
|
|
*
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* @var ModuleUser_EntityUser|null
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*/
|
2011-07-22 18:07:41 +03:00
|
|
|
|
protected $oUserCurrent;
|
2012-04-14 10:32:27 +03:00
|
|
|
|
/**
|
|
|
|
|
* Какое меню активно
|
|
|
|
|
*
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* @var string
|
2012-04-14 10:32:27 +03:00
|
|
|
|
*/
|
|
|
|
|
protected $sMenuItemSelect='user';
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Инициализация
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function Init() {
|
|
|
|
|
/**
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* Личная лента доступна только для авторизованных, для гостей показываем общую ленту
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*/
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->oUserCurrent = $this->User_getUserCurrent();
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if ($this->oUserCurrent) {
|
|
|
|
|
$this->SetDefaultEvent('user');
|
|
|
|
|
} else {
|
|
|
|
|
$this->SetDefaultEvent('all');
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
|
|
|
|
$this->Viewer_Assign('aStreamEventTypes', $this->Stream_getEventTypes());
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2012-04-14 10:32:27 +03:00
|
|
|
|
$this->Viewer_Assign('sMenuHeadItemSelect', 'stream');
|
2011-07-31 19:52:50 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон JS текстовки
|
|
|
|
|
*/
|
|
|
|
|
$this->Lang_AddLangJs(array(
|
2012-05-04 13:12:21 +03:00
|
|
|
|
'stream_subscribes_already_subscribed','error'
|
|
|
|
|
));
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Регистрация евентов
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function RegisterEvent() {
|
2012-04-14 10:32:27 +03:00
|
|
|
|
$this->AddEvent('user', 'EventUser');
|
|
|
|
|
$this->AddEvent('all', 'EventAll');
|
2014-02-07 12:26:28 +02:00
|
|
|
|
$this->AddEvent('subscribe', 'EventSubscribe'); // TODO: возможно нужно удалить
|
|
|
|
|
$this->AddEvent('ajaxadduser', 'EventAjaxAddUser');
|
|
|
|
|
$this->AddEvent('ajaxremoveuser', 'EventAjaxRemoveUser');
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->AddEvent('switchEventType', 'EventSwitchEventType');
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->AddEvent('get_more_custom', 'EventGetMore');
|
2012-03-19 23:10:06 +02:00
|
|
|
|
$this->AddEvent('get_more_user', 'EventGetMoreUser');
|
2012-04-14 10:32:27 +03:00
|
|
|
|
$this->AddEvent('get_more_all', 'EventGetMoreAll');
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
2012-04-14 10:32:27 +03:00
|
|
|
|
* Список событий в ленте активности пользователя
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*
|
|
|
|
|
*/
|
2012-04-14 10:32:27 +03:00
|
|
|
|
protected function EventUser() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if (!$this->oUserCurrent) {
|
2013-02-04 01:45:44 +02:00
|
|
|
|
return parent::EventNotFound();
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
2013-05-04 17:10:22 +03:00
|
|
|
|
$this->Viewer_AddBlock('right','activitySettings');
|
|
|
|
|
$this->Viewer_AddBlock('right','activityUsers');
|
2014-03-04 10:32:38 +02:00
|
|
|
|
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Читаем события
|
|
|
|
|
*/
|
2011-07-31 19:52:50 +03:00
|
|
|
|
$aEvents = $this->Stream_Read();
|
2012-04-14 20:48:18 +03:00
|
|
|
|
$this->Viewer_Assign('bDisableGetMoreButton', $this->Stream_GetCountByReaderId($this->oUserCurrent->getId()) < Config::Get('module.stream.count_default'));
|
2011-07-31 19:52:50 +03:00
|
|
|
|
$this->Viewer_Assign('aStreamEvents', $aEvents);
|
|
|
|
|
if (count($aEvents)) {
|
|
|
|
|
$oEvenLast=end($aEvents);
|
|
|
|
|
$this->Viewer_Assign('iStreamLastId', $oEvenLast->getId());
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_Assign('sDateLast', $oEvenLast->getDateAdded());
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-14 10:32:27 +03:00
|
|
|
|
/**
|
|
|
|
|
* Список событий в общей ленте активности сайта
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventAll() {
|
|
|
|
|
$this->sMenuItemSelect='all';
|
|
|
|
|
/**
|
|
|
|
|
* Читаем события
|
|
|
|
|
*/
|
|
|
|
|
$aEvents = $this->Stream_ReadAll();
|
2012-04-14 20:48:18 +03:00
|
|
|
|
$this->Viewer_Assign('bDisableGetMoreButton', $this->Stream_GetCountAll() < Config::Get('module.stream.count_default'));
|
2012-04-14 10:32:27 +03:00
|
|
|
|
$this->Viewer_Assign('aStreamEvents', $aEvents);
|
|
|
|
|
if (count($aEvents)) {
|
|
|
|
|
$oEvenLast=end($aEvents);
|
|
|
|
|
$this->Viewer_Assign('iStreamLastId', $oEvenLast->getId());
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_Assign('sDateLast', $oEvenLast->getDateAdded());
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Активаци/деактивация типа события
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventSwitchEventType() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if (!$this->oUserCurrent) {
|
2013-02-04 01:45:44 +02:00
|
|
|
|
return parent::EventNotFound();
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
2011-07-22 18:07:41 +03:00
|
|
|
|
if (!getRequest('type')) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Активируем/деактивируем тип
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$this->Stream_switchUserEventType($this->oUserCurrent->getId(), getRequestStr('type'));
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('stream_subscribes_updated'), $this->Lang_Get('attention'));
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Погрузка событий (замена постраничности)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventGetMore() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if (!$this->oUserCurrent) {
|
2013-02-04 01:45:44 +02:00
|
|
|
|
return parent::EventNotFound();
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Необходимо передать последний просмотренный ID событий
|
|
|
|
|
*/
|
2013-06-20 14:28:58 +03:00
|
|
|
|
$iFromId = getRequestStr('iLastId');
|
2011-07-22 18:07:41 +03:00
|
|
|
|
if (!$iFromId) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем события
|
|
|
|
|
*/
|
2011-07-31 19:52:50 +03:00
|
|
|
|
$aEvents = $this->Stream_Read(null, $iFromId);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$oViewer=$this->Viewer_GetLocalViewer();
|
2011-07-31 19:52:50 +03:00
|
|
|
|
$oViewer->Assign('aStreamEvents', $aEvents);
|
2013-06-20 14:28:58 +03:00
|
|
|
|
$oViewer->Assign('sDateLast', getRequestStr('sDateLast'));
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('iCountLoaded', count($aEvents));
|
|
|
|
|
|
2011-07-31 19:52:50 +03:00
|
|
|
|
if (count($aEvents)) {
|
|
|
|
|
$oEvenLast=end($aEvents);
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('iLastId', $oEvenLast->getId());
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Возвращаем данные в ajax ответе
|
|
|
|
|
*/
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sHtml', $oViewer->Fetch('actions/ActionStream/events.tpl'));
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
2012-04-14 10:32:27 +03:00
|
|
|
|
/**
|
|
|
|
|
* Погрузка событий для всего сайта
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventGetMoreAll() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-04-14 10:32:27 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
/**
|
|
|
|
|
* Необходимо передать последний просмотренный ID событий
|
|
|
|
|
*/
|
2013-06-20 14:28:58 +03:00
|
|
|
|
$iFromId = getRequestStr('iLastId');
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if (!$iFromId) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем события
|
|
|
|
|
*/
|
|
|
|
|
$aEvents = $this->Stream_ReadAll(null, $iFromId);
|
|
|
|
|
|
|
|
|
|
$oViewer=$this->Viewer_GetLocalViewer();
|
|
|
|
|
$oViewer->Assign('aStreamEvents', $aEvents);
|
2013-06-20 14:28:58 +03:00
|
|
|
|
$oViewer->Assign('sDateLast', getRequestStr('sDateLast'));
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('iCountLoaded', count($aEvents));
|
|
|
|
|
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if (count($aEvents)) {
|
|
|
|
|
$oEvenLast=end($aEvents);
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sDateLast', $oEvenLast->getDateAdded());
|
|
|
|
|
$this->Viewer_AssignAjax('iLastId', $oEvenLast->getId());
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Возвращаем данные в ajax ответе
|
|
|
|
|
*/
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sHtml', $oViewer->Fetch('actions/ActionStream/events.tpl'));
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
2012-03-19 23:10:06 +02:00
|
|
|
|
/**
|
2012-05-04 13:12:21 +03:00
|
|
|
|
* Подгрузка событий для пользователя
|
2012-03-19 23:10:06 +02:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventGetMoreUser() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-19 23:10:06 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
/**
|
|
|
|
|
* Необходимо передать последний просмотренный ID событий
|
|
|
|
|
*/
|
2013-06-20 14:28:58 +03:00
|
|
|
|
$iFromId = getRequestStr('iLastId');
|
2012-03-19 23:10:06 +02:00
|
|
|
|
if (!$iFromId) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-03-04 10:32:38 +02:00
|
|
|
|
if (!($oUser=$this->User_GetUserById(getRequestStr('iTargetId')))) {
|
2012-03-19 23:10:06 +02:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем события
|
|
|
|
|
*/
|
|
|
|
|
$aEvents = $this->Stream_ReadByUserId($oUser->getId(), null, $iFromId);
|
|
|
|
|
|
|
|
|
|
$oViewer=$this->Viewer_GetLocalViewer();
|
|
|
|
|
$oViewer->Assign('aStreamEvents', $aEvents);
|
2013-06-20 14:28:58 +03:00
|
|
|
|
$oViewer->Assign('sDateLast', getRequestStr('sDateLast'));
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('iCountLoaded', count($aEvents));
|
|
|
|
|
|
2012-03-19 23:10:06 +02:00
|
|
|
|
if (count($aEvents)) {
|
|
|
|
|
$oEvenLast=end($aEvents);
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sDateLast', $oEvenLast->getDateAdded());
|
|
|
|
|
$this->Viewer_AssignAjax('iLastId', $oEvenLast->getId());
|
2012-03-19 23:10:06 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Возвращаем данные в ajax ответе
|
|
|
|
|
*/
|
2014-03-04 10:32:38 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sHtml', $oViewer->Fetch('actions/ActionStream/events.tpl'));
|
2012-03-19 23:10:06 +02:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Подписка на пользователя по ID
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventSubscribe() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if (!$this->oUserCurrent) {
|
2013-02-04 01:45:44 +02:00
|
|
|
|
return parent::EventNotFound();
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Проверяем существование пользователя
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (!$this->User_getUserById(getRequestStr('id'))) {
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if ($this->oUserCurrent->getId() == getRequestStr('id')) {
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('stream_error_subscribe_to_yourself'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Подписываем на пользователя
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$this->Stream_subscribeUser($this->oUserCurrent->getId(), getRequestStr('id'));
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('stream_subscribes_updated'), $this->Lang_Get('attention'));
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Подписка на пользователя по логину
|
|
|
|
|
*
|
|
|
|
|
*/
|
2014-02-07 12:26:28 +02:00
|
|
|
|
protected function EventAjaxAddUser() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2014-02-07 12:26:28 +02:00
|
|
|
|
$sUsers=getRequestStr('sUserList',null,'post');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
2014-02-07 12:26:28 +02:00
|
|
|
|
* Если пользователь не авторизирован, возвращаем ошибку
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*/
|
2014-02-07 12:26:28 +02:00
|
|
|
|
if (!$this->User_IsAuthorization()) {
|
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('need_authorization'),$this->Lang_Get('error'));
|
2011-07-22 18:07:41 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
2014-02-07 12:26:28 +02:00
|
|
|
|
$aUsers=explode(',',$sUsers);
|
|
|
|
|
|
|
|
|
|
$aResult=array();
|
|
|
|
|
/**
|
|
|
|
|
* Обрабатываем добавление по каждому из переданных логинов
|
|
|
|
|
*/
|
|
|
|
|
foreach ($aUsers as $sUser) {
|
|
|
|
|
$sUser=trim($sUser);
|
|
|
|
|
if ($sUser=='') {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Если пользователь не найден или неактивен, возвращаем ошибку
|
|
|
|
|
*/
|
|
|
|
|
if ($oUser=$this->User_GetUserByLogin($sUser) and $oUser->getActivate()==1) {
|
|
|
|
|
$this->Stream_subscribeUser($this->oUserCurrent->getId(),$oUser->getId());
|
|
|
|
|
$oViewer = $this->Viewer_GetLocalViewer();
|
|
|
|
|
$oViewer->Assign('oUser', $oUser);
|
|
|
|
|
$oViewer->Assign('bUserListSmallShowActions', true);
|
|
|
|
|
|
|
|
|
|
$aResult[]=array(
|
|
|
|
|
'bStateError'=>false,
|
|
|
|
|
'sMsgTitle'=>$this->Lang_Get('attention'),
|
|
|
|
|
'sMsg'=>$this->Lang_Get('common.success.add',array('login'=>htmlspecialchars($sUser))),
|
|
|
|
|
'sUserId'=>$oUser->getId(),
|
|
|
|
|
'sUserLogin'=>htmlspecialchars($sUser),
|
|
|
|
|
'sUserWebPath'=>$oUser->getUserWebPath(),
|
|
|
|
|
'sUserAvatar48'=>$oUser->getProfileAvatarPath(48),
|
|
|
|
|
'sUserHtml'=>$oViewer->Fetch("user_list_small_item.tpl")
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$aResult[]=array(
|
|
|
|
|
'bStateError'=>true,
|
|
|
|
|
'sMsgTitle'=>$this->Lang_Get('error'),
|
|
|
|
|
'sMsg'=>$this->Lang_Get('user_not_found',array('login'=>htmlspecialchars($sUser))),
|
|
|
|
|
'sUserLogin'=>htmlspecialchars($sUser)
|
|
|
|
|
);
|
|
|
|
|
}
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
2014-02-07 12:26:28 +02:00
|
|
|
|
* Передаем во вьевер массив с результатами обработки по каждому пользователю
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*/
|
2014-02-07 12:26:28 +02:00
|
|
|
|
$this->Viewer_AssignAjax('aUsers',$aResult);
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Отписка от пользователя
|
|
|
|
|
*
|
|
|
|
|
*/
|
2014-02-07 12:26:28 +02:00
|
|
|
|
protected function EventAjaxRemoveUser() {
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-04-14 10:32:27 +03:00
|
|
|
|
if (!$this->oUserCurrent) {
|
2014-02-07 12:26:28 +02:00
|
|
|
|
return $this->EventErrorDebug();
|
2012-04-14 10:32:27 +03:00
|
|
|
|
}
|
2012-05-04 13:12:21 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь с таким ID существует?
|
|
|
|
|
*/
|
2014-02-07 12:26:28 +02:00
|
|
|
|
if (!$this->User_GetUserById(getRequestStr('iUserId'))) {
|
|
|
|
|
return $this->EventErrorDebug();
|
2011-07-22 18:07:41 +03:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Отписываем
|
|
|
|
|
*/
|
2014-02-07 12:46:33 +02:00
|
|
|
|
$this->Stream_unsubscribeUser($this->oUserCurrent->getId(), getRequestStr('iUserId'));
|
2011-07-22 18:07:41 +03:00
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('stream_subscribes_updated'), $this->Lang_Get('attention'));
|
|
|
|
|
}
|
2012-04-14 10:32:27 +03:00
|
|
|
|
/**
|
|
|
|
|
* Выполняется при завершении работы экшена
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function EventShutdown() {
|
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон необходимые переменные
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('sMenuItemSelect',$this->sMenuItemSelect);
|
|
|
|
|
}
|
2013-02-04 01:45:44 +02:00
|
|
|
|
}
|