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
|
|
|
|
* Экшен обработки профайла юзера, т.е. УРЛ вида /profile/login/
|
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 ActionProfile extends Action {
|
|
|
|
|
/**
|
|
|
|
|
* Объект юзера чей профиль мы смотрим
|
|
|
|
|
*
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* @var ModuleUser_EntityUser|null
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
|
|
|
|
protected $oUserProfile;
|
2012-06-03 06:16:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Главное меню
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $sMenuHeadItemSelect='people';
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Субменю
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2012-04-20 13:36:07 +03:00
|
|
|
|
protected $sMenuSubItemSelect='';
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Текущий пользователь
|
|
|
|
|
*
|
|
|
|
|
* @var ModuleUser_EntityUser|null
|
|
|
|
|
*/
|
2012-03-11 19:52:17 +02:00
|
|
|
|
protected $oUserCurrent;
|
|
|
|
|
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Инициализация
|
|
|
|
|
*/
|
2010-02-06 11:04:36 +02:00
|
|
|
|
public function Init() {
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$this->oUserCurrent=$this->User_GetUserCurrent();
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Регистрация евентов
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
protected function RegisterEvent() {
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$this->AddEvent('friendoffer','EventFriendOffer');
|
|
|
|
|
$this->AddEvent('ajaxfriendadd', 'EventAjaxFriendAdd');
|
2009-09-03 20:07:02 +03:00
|
|
|
|
$this->AddEvent('ajaxfrienddelete', 'EventAjaxFriendDelete');
|
2009-09-05 16:35:44 +03:00
|
|
|
|
$this->AddEvent('ajaxfriendaccept', 'EventAjaxFriendAccept');
|
2012-03-16 13:14:35 +02:00
|
|
|
|
$this->AddEvent('ajax-note-save', 'EventAjaxNoteSave');
|
|
|
|
|
$this->AddEvent('ajax-note-remove', 'EventAjaxNoteRemove');
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2010-08-21 13:14:13 +03:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^(whois)?$/i','EventWhois');
|
2012-03-19 12:02:07 +02:00
|
|
|
|
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^$/i','EventWall');
|
2012-03-12 13:40:26 +02:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^add$/i','EventWallAdd');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^load$/i','EventWallLoad');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^load-reply$/i','EventWallLoadReply');
|
2012-04-13 20:12:59 +03:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^remove$/i','EventWallRemove');
|
2012-03-19 12:02:07 +02:00
|
|
|
|
|
2012-07-09 08:47:42 +03:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^comments$/i','/^(page([1-9]\d{0,5}))?$/i','EventFavouriteComments');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^(page([1-9]\d{0,5}))?$/i','EventFavourite');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^topics/i','/^(page([1-9]\d{0,5}))?$/i','EventFavourite');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^topics/i','/^tag/i','/^.+/i','/^(page([1-9]\d{0,5}))?$/i','EventFavouriteTopicsTag');
|
2012-03-19 06:12:59 +02:00
|
|
|
|
|
2012-07-09 08:47:42 +03:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^created/i','/^notes/i','/^(page([1-9]\d{0,5}))?$/i','EventCreatedNotes');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^created/i','/^(page([1-9]\d{0,5}))?$/i','EventCreatedTopics');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^created/i','/^topics/i','/^(page([1-9]\d{0,5}))?$/i','EventCreatedTopics');
|
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^created/i','/^comments$/i','/^(page([1-9]\d{0,5}))?$/i','EventCreatedComments');
|
2012-03-19 12:02:07 +02:00
|
|
|
|
|
2012-07-09 08:47:42 +03:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^friends/i','/^(page([1-9]\d{0,5}))?$/i','EventFriends');
|
2012-03-19 23:10:06 +02:00
|
|
|
|
$this->AddEventPreg('/^.+$/i','/^stream/i','/^$/i','EventStream');
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**********************************************************************************
|
|
|
|
|
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
|
|
|
|
|
**********************************************************************************
|
|
|
|
|
*/
|
2012-04-29 20:11:53 +03:00
|
|
|
|
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-19 06:12:59 +02:00
|
|
|
|
* Проверка корректности профиля
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
protected function CheckUserProfile() {
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-19 06:12:59 +02:00
|
|
|
|
* Проверяем есть ли такой юзер
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if (!($this->oUserProfile=$this->User_GetUserByLogin($this->sCurrentEvent))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-03-19 23:10:06 +02:00
|
|
|
|
/**
|
|
|
|
|
* Чтение активности пользователя (stream)
|
|
|
|
|
*/
|
|
|
|
|
protected function EventStream() {
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Читаем события
|
|
|
|
|
*/
|
|
|
|
|
$aEvents = $this->Stream_ReadByUserId($this->oUserProfile->getId());
|
2012-04-13 16:30:29 +03:00
|
|
|
|
$this->Viewer_Assign('bDisableGetMoreButton', $this->Stream_GetCountByUserId($this->oUserProfile->getId()) < Config::Get('module.stream.count_default'));
|
2012-03-19 23:10:06 +02:00
|
|
|
|
$this->Viewer_Assign('aStreamEvents', $aEvents);
|
|
|
|
|
if (count($aEvents)) {
|
|
|
|
|
$oEvenLast=end($aEvents);
|
|
|
|
|
$this->Viewer_Assign('iStreamLastId', $oEvenLast->getId());
|
|
|
|
|
}
|
|
|
|
|
$this->SetTemplateAction('stream');
|
|
|
|
|
}
|
2012-03-19 12:02:07 +02:00
|
|
|
|
/**
|
|
|
|
|
* Список друзей пользователей
|
|
|
|
|
*/
|
|
|
|
|
protected function EventFriends() {
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
|
|
|
|
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список комментов
|
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->User_GetUsersFriend($this->oUserProfile->getId(),$iPage,Config::Get('module.user.per_page'));
|
|
|
|
|
$aFriends=$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'),$this->oUserProfile->getUserWebPath().'friends');
|
2012-03-19 12:02:07 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aFriends',$aFriends);
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_friends').' '.$this->oUserProfile->getLogin());
|
|
|
|
|
|
|
|
|
|
$this->SetTemplateAction('friends');
|
|
|
|
|
}
|
2012-03-19 06:12:59 +02:00
|
|
|
|
/**
|
|
|
|
|
* Список топиков пользователя
|
|
|
|
|
*/
|
|
|
|
|
protected function EventCreatedTopics() {
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuSubItemSelect='topics';
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2012-03-19 06:12:59 +02:00
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
|
|
|
|
if ($this->GetParamEventMatch(1,0)=='topics') {
|
|
|
|
|
$iPage=$this->GetParamEventMatch(2,2) ? $this->GetParamEventMatch(2,2) : 1;
|
|
|
|
|
} else {
|
|
|
|
|
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список топиков
|
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->Topic_GetTopicsPersonalByUser($this->oUserProfile->getId(),1,$iPage,Config::Get('module.topic.per_page'));
|
|
|
|
|
$aTopics=$aResult['collection'];
|
2012-06-10 11:33:03 +03:00
|
|
|
|
/**
|
|
|
|
|
* Вызов хуков
|
|
|
|
|
*/
|
|
|
|
|
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
|
2012-03-19 06:12:59 +02:00
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),$this->oUserProfile->getUserWebPath().'created/topics');
|
2012-03-19 06:12:59 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aTopics',$aTopics);
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_publication').' '.$this->oUserProfile->getLogin());
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_publication_blog'));
|
|
|
|
|
$this->Viewer_SetHtmlRssAlternate(Router::GetPath('rss').'personal_blog/'.$this->oUserProfile->getLogin().'/',$this->oUserProfile->getLogin());
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('created_topics');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Вывод комментариев пользователя
|
|
|
|
|
*/
|
|
|
|
|
protected function EventCreatedComments() {
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuSubItemSelect='comments';
|
2012-03-19 06:12:59 +02:00
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
|
|
|
|
$iPage=$this->GetParamEventMatch(2,2) ? $this->GetParamEventMatch(2,2) : 1;
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список комментов
|
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->Comment_GetCommentsByUserId($this->oUserProfile->getId(),'topic',$iPage,Config::Get('module.comment.per_page'));
|
|
|
|
|
$aComments=$aResult['collection'];
|
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.comment.per_page'),Config::Get('pagination.pages.count'),$this->oUserProfile->getUserWebPath().'created/comments');
|
2012-03-19 06:12:59 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aComments',$aComments);
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_publication').' '.$this->oUserProfile->getLogin());
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_publication_comment'));
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('created_comments');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Выводит список избранноего юзера
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventFavourite() {
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2008-09-21 09:36:57 +03:00
|
|
|
|
return parent::EventNotFound();
|
2011-06-06 14:58:19 +03:00
|
|
|
|
}
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuSubItemSelect='topics';
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if ($this->GetParamEventMatch(1,0)=='topics') {
|
|
|
|
|
$iPage=$this->GetParamEventMatch(2,2) ? $this->GetParamEventMatch(2,2) : 1;
|
|
|
|
|
} else {
|
|
|
|
|
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
|
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список избранных топиков
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->Topic_GetTopicsFavouriteByUserId($this->oUserProfile->getId(),$iPage,Config::Get('module.topic.per_page'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
$aTopics=$aResult['collection'];
|
2012-06-10 11:33:03 +03:00
|
|
|
|
/**
|
|
|
|
|
* Вызов хуков
|
|
|
|
|
*/
|
|
|
|
|
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),$this->oUserProfile->getUserWebPath().'favourites/topics');
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2008-09-21 09:36:57 +03:00
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aTopics',$aTopics);
|
2009-04-07 17:59:43 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
|
2012-03-27 13:45:52 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_favourites'));
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('favourite_topics');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Список топиков из избранного по тегу
|
|
|
|
|
*/
|
|
|
|
|
protected function EventFavouriteTopicsTag() {
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован и просматривает свой профиль?
|
|
|
|
|
*/
|
2012-03-27 13:45:52 +03:00
|
|
|
|
if (!$this->oUserCurrent or $this->oUserProfile->getId()!=$this->oUserCurrent->getId()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuSubItemSelect='topics';
|
2012-03-27 13:45:52 +03:00
|
|
|
|
$sTag=$this->GetParamEventMatch(3,0);
|
|
|
|
|
/*
|
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
|
|
|
|
$iPage=$this->GetParamEventMatch(4,2) ? $this->GetParamEventMatch(4,2) : 1;
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список избранных топиков
|
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->Favourite_GetTags(array('target_type'=>'topic','user_id'=>$this->oUserProfile->getId(),'text'=>$sTag),array('target_id'=>'desc'),$iPage,Config::Get('module.topic.per_page'));
|
|
|
|
|
$aTopicId=array();
|
|
|
|
|
foreach($aResult['collection'] as $oTag) {
|
|
|
|
|
$aTopicId[]=$oTag->getTargetId();
|
|
|
|
|
}
|
|
|
|
|
$aTopics=$this->Topic_GetTopicsAdditionalData($aTopicId);
|
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),$this->oUserProfile->getUserWebPath().'favourites/topics/tag/'.htmlspecialchars($sTag));
|
2012-03-27 13:45:52 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aTopics',$aTopics);
|
|
|
|
|
$this->Viewer_Assign('sFavouriteTag',htmlspecialchars($sTag));
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
|
2009-04-07 17:59:43 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_favourites'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
$this->SetTemplateAction('favourite_topics');
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
2009-08-22 00:01:09 +03:00
|
|
|
|
/**
|
|
|
|
|
* Выводит список избранноего юзера
|
|
|
|
|
*
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
protected function EventFavouriteComments() {
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2009-08-22 00:01:09 +03:00
|
|
|
|
return parent::EventNotFound();
|
2011-06-06 14:58:19 +03:00
|
|
|
|
}
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuSubItemSelect='comments';
|
2009-08-22 00:01:09 +03:00
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
|
|
|
|
$iPage=$this->GetParamEventMatch(2,2) ? $this->GetParamEventMatch(2,2) : 1;
|
2009-08-22 00:01:09 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список избранных комментариев
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->Comment_GetCommentsFavouriteByUserId($this->oUserProfile->getId(),$iPage,Config::Get('module.comment.per_page'));
|
2009-08-22 00:01:09 +03:00
|
|
|
|
$aComments=$aResult['collection'];
|
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.comment.per_page'),Config::Get('pagination.pages.count'),$this->oUserProfile->getUserWebPath().'favourites/comments');
|
2009-08-22 00:01:09 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2009-08-22 00:01:09 +03:00
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aComments',$aComments);
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_favourites_comments'));
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
$this->SetTemplateAction('favourite_comments');
|
2011-06-06 14:58:19 +03:00
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Показывает инфу профиля
|
|
|
|
|
*
|
|
|
|
|
*/
|
2009-03-01 13:59:53 +02:00
|
|
|
|
protected function EventWhois() {
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2009-03-01 13:59:53 +02:00
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-05-18 17:28:43 +03:00
|
|
|
|
$this->sMenuSubItemSelect='main';
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список друзей
|
|
|
|
|
*/
|
2012-03-19 12:02:07 +02:00
|
|
|
|
$aUsersFriend=$this->User_GetUsersFriend($this->oUserProfile->getId(),1,Config::Get('module.user.friend_on_profile'));
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если активен режим инвайтов, то прогружаем дополнительную информацию
|
|
|
|
|
*/
|
2009-08-20 10:43:06 +03:00
|
|
|
|
if (Config::Get('general.reg.invite')) {
|
2008-10-16 07:29:15 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список тех кого пригласил юзер
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$aUsersInvite=$this->User_GetUsersInvite($this->oUserProfile->getId());
|
2008-10-16 07:29:15 +03:00
|
|
|
|
$this->Viewer_Assign('aUsersInvite',$aUsersInvite);
|
|
|
|
|
/**
|
|
|
|
|
* Получаем того юзера, кто пригласил текущего
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$oUserInviteFrom=$this->User_GetUserInviteFrom($this->oUserProfile->getId());
|
2008-10-16 07:29:15 +03:00
|
|
|
|
$this->Viewer_Assign('oUserInviteFrom',$oUserInviteFrom);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2009-06-13 14:32:06 +03:00
|
|
|
|
* Получаем список юзеров блога
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2010-05-27 17:02:43 +03:00
|
|
|
|
$aBlogUsers=$this->Blog_GetBlogUsersByUserId($this->oUserProfile->getId(),ModuleBlog::BLOG_USER_ROLE_USER);
|
|
|
|
|
$aBlogModerators=$this->Blog_GetBlogUsersByUserId($this->oUserProfile->getId(),ModuleBlog::BLOG_USER_ROLE_MODERATOR);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$aBlogAdministrators=$this->Blog_GetBlogUsersByUserId($this->oUserProfile->getId(),ModuleBlog::BLOG_USER_ROLE_ADMINISTRATOR);
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список блогов которые создал юзер
|
|
|
|
|
*/
|
2009-05-09 20:53:25 +03:00
|
|
|
|
$aBlogsOwner=$this->Blog_GetBlogsByOwnerId($this->oUserProfile->getId());
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список контактов
|
|
|
|
|
*/
|
|
|
|
|
$aUserFields = $this->User_getUserFieldsValues($this->oUserProfile->getId());
|
2009-05-09 20:53:25 +03:00
|
|
|
|
/**
|
|
|
|
|
* Вызов хуков
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$this->Hook_Run('profile_whois_show',array("oUserProfile"=>$this->oUserProfile));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
2009-06-13 14:32:06 +03:00
|
|
|
|
$this->Viewer_Assign('aBlogUsers',$aBlogUsers);
|
|
|
|
|
$this->Viewer_Assign('aBlogModerators',$aBlogModerators);
|
|
|
|
|
$this->Viewer_Assign('aBlogAdministrators',$aBlogAdministrators);
|
2008-09-21 09:36:57 +03:00
|
|
|
|
$this->Viewer_Assign('aBlogsOwner',$aBlogsOwner);
|
2012-03-19 12:02:07 +02:00
|
|
|
|
$this->Viewer_Assign('aUsersFriend',$aUsersFriend['collection']);
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->Viewer_Assign('aUserFields',$aUserFields);
|
2009-04-07 17:59:43 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_whois'));
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$this->SetTemplateAction('whois');
|
|
|
|
|
}
|
2012-03-11 19:52:17 +02:00
|
|
|
|
/**
|
|
|
|
|
* Отображение стены пользователя
|
|
|
|
|
*/
|
|
|
|
|
public function EventWall() {
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2012-03-11 19:52:17 +02:00
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем записи стены
|
|
|
|
|
*/
|
|
|
|
|
$aWall=$this->Wall_GetWall(array('wall_user_id'=>$this->oUserProfile->getId(),'pid'=>null),array('id'=>'desc'),1,Config::Get('module.wall.per_page'));
|
|
|
|
|
$this->Viewer_Assign('aWall',$aWall['collection']);
|
|
|
|
|
$this->Viewer_Assign('iCountWall',$aWall['count']);
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('wall');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Добавление записи на стену
|
|
|
|
|
*/
|
|
|
|
|
public function EventWallAdd() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-03-11 19:52:17 +02:00
|
|
|
|
if (!$this->oUserCurrent) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2012-03-11 19:52:17 +02:00
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Создаем запись
|
|
|
|
|
*/
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$oWall=Engine::GetEntity('Wall');
|
2012-04-13 17:24:53 +03:00
|
|
|
|
$oWall->_setValidateScenario('add');
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$oWall->setWallUserId($this->oUserProfile->getId());
|
|
|
|
|
$oWall->setUserId($this->oUserCurrent->getId());
|
|
|
|
|
$oWall->setText(getRequest('sText'));
|
|
|
|
|
$oWall->setPid(getRequest('iPid'));
|
|
|
|
|
|
2012-04-13 15:07:59 +03:00
|
|
|
|
$this->Hook_Run('wall_add_validate_before', array('oWall'=>$oWall));
|
2012-03-11 19:52:17 +02:00
|
|
|
|
if ($oWall->_Validate()) {
|
|
|
|
|
/**
|
|
|
|
|
* Экранируем текст и добавляем запись в БД
|
|
|
|
|
*/
|
|
|
|
|
$oWall->setText($this->Text_Parser($oWall->getText()));
|
2012-04-13 15:07:59 +03:00
|
|
|
|
$this->Hook_Run('wall_add_before', array('oWall'=>$oWall));
|
|
|
|
|
if ($this->Wall_AddWall($oWall)) {
|
|
|
|
|
$this->Hook_Run('wall_add_after', array('oWall'=>$oWall));
|
|
|
|
|
/**
|
|
|
|
|
* Отправляем уведомления
|
|
|
|
|
*/
|
|
|
|
|
if ($oWall->getWallUserId()!=$oWall->getUserId()) {
|
|
|
|
|
$this->Notify_SendWallNew($oWall,$this->oUserCurrent);
|
|
|
|
|
}
|
|
|
|
|
if ($oWallParent=$oWall->GetPidWall() and $oWallParent->getUserId()!=$oWall->getUserId()) {
|
|
|
|
|
$this->Notify_SendWallReply($oWallParent,$oWall,$this->oUserCurrent);
|
|
|
|
|
}
|
2012-04-14 08:05:46 +03:00
|
|
|
|
/**
|
|
|
|
|
* Добавляем событие в ленту
|
|
|
|
|
*/
|
|
|
|
|
$this->Stream_Write($oWall->getUserId(), 'add_wall', $oWall->getId());
|
2012-04-13 15:07:59 +03:00
|
|
|
|
} else {
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('wall_add_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2012-03-24 07:11:48 +02:00
|
|
|
|
$this->Message_AddError($oWall->_getValidateError(),$this->Lang_Get('error'));
|
2012-03-11 19:52:17 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-13 20:12:59 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаление записи со стены
|
|
|
|
|
*/
|
|
|
|
|
public function EventWallRemove() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-04-13 20:12:59 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-04-13 20:12:59 +03:00
|
|
|
|
if (!$this->oUserCurrent) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем запись
|
|
|
|
|
*/
|
2012-04-13 20:12:59 +03:00
|
|
|
|
if (!($oWall=$this->Wall_GetWallById(getRequest('iId')))) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если разрешено удаление - удаляем
|
|
|
|
|
*/
|
2012-04-13 20:12:59 +03:00
|
|
|
|
if ($oWall->isAllowDelete()) {
|
|
|
|
|
$this->Wall_DeleteWall($oWall);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-03-11 19:52:17 +02:00
|
|
|
|
/**
|
|
|
|
|
* Ajax подгрузка сообщений стены
|
|
|
|
|
*/
|
|
|
|
|
public function EventWallLoad() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2012-03-11 19:52:17 +02:00
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Формируем фильтр для запроса к БД
|
|
|
|
|
*/
|
|
|
|
|
$aFilter=array(
|
|
|
|
|
'wall_user_id'=>$this->oUserProfile->getId(),
|
|
|
|
|
'pid'=>null
|
|
|
|
|
);
|
|
|
|
|
if (is_numeric(getRequest('iIdLess'))) {
|
|
|
|
|
$aFilter['id_less']=getRequest('iIdLess');
|
|
|
|
|
} elseif (is_numeric(getRequest('iIdMore'))) {
|
|
|
|
|
$aFilter['id_more']=getRequest('iIdMore');
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* Получаем сообщения и формируем ответ
|
2012-03-11 19:52:17 +02:00
|
|
|
|
*/
|
|
|
|
|
$aWall=$this->Wall_GetWall($aFilter,array('id'=>'desc'),1,Config::Get('module.wall.per_page'));
|
|
|
|
|
$this->Viewer_Assign('aWall',$aWall['collection']);
|
2012-04-09 17:33:10 +03:00
|
|
|
|
$this->Viewer_Assign('oUserCurrent',$this->oUserCurrent); // хак, т.к. к этому моменту текущий юзер не загружен в шаблон
|
2012-03-11 19:52:17 +02:00
|
|
|
|
$this->Viewer_AssignAjax('sText', $this->Viewer_Fetch('actions/ActionProfile/wall_items.tpl'));
|
|
|
|
|
$this->Viewer_AssignAjax('iCountWall',$aWall['count']);
|
|
|
|
|
$this->Viewer_AssignAjax('iCountWallReturn',count($aWall['collection']));
|
2012-03-12 13:40:26 +02:00
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Подгрузка ответов на стене к сообщению
|
|
|
|
|
*/
|
2012-03-12 13:40:26 +02:00
|
|
|
|
public function EventWallLoadReply() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-12 13:40:26 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-03-19 06:12:59 +02:00
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2012-03-12 13:40:26 +02:00
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
if (!($oWall=$this->Wall_GetWallById(getRequest('iPid'))) or $oWall->getPid()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Формируем фильтр для запроса к БД
|
|
|
|
|
*/
|
|
|
|
|
$aFilter=array(
|
|
|
|
|
'wall_user_id'=>$this->oUserProfile->getId(),
|
|
|
|
|
'pid'=>$oWall->getId()
|
|
|
|
|
);
|
|
|
|
|
if (is_numeric(getRequest('iIdLess'))) {
|
|
|
|
|
$aFilter['id_less']=getRequest('iIdLess');
|
|
|
|
|
} elseif (is_numeric(getRequest('iIdMore'))) {
|
|
|
|
|
$aFilter['id_more']=getRequest('iIdMore');
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('error'));
|
|
|
|
|
return;
|
2012-03-11 19:52:17 +02:00
|
|
|
|
}
|
2012-03-12 13:40:26 +02:00
|
|
|
|
/**
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* Получаем сообщения и формируем ответ
|
2012-05-11 05:20:05 +03:00
|
|
|
|
* Необходимо вернуть все ответы, но ставим "разумное" ограничение
|
2012-03-12 13:40:26 +02:00
|
|
|
|
*/
|
2012-05-11 05:20:05 +03:00
|
|
|
|
$aWall=$this->Wall_GetWall($aFilter,array('id'=>'asc'),1,300);
|
2012-03-12 13:40:26 +02:00
|
|
|
|
$this->Viewer_Assign('aReplyWall',$aWall['collection']);
|
|
|
|
|
$this->Viewer_AssignAjax('sText', $this->Viewer_Fetch('actions/ActionProfile/wall_items_reply.tpl'));
|
|
|
|
|
$this->Viewer_AssignAjax('iCountWall',$aWall['count']);
|
|
|
|
|
$this->Viewer_AssignAjax('iCountWallReturn',count($aWall['collection']));
|
2012-03-11 19:52:17 +02:00
|
|
|
|
}
|
2012-03-16 13:14:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* Сохраняет заметку о пользователе
|
|
|
|
|
*/
|
|
|
|
|
public function EventAjaxNoteSave() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-16 13:14:35 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Пользователь авторизован?
|
|
|
|
|
*/
|
2012-03-16 13:14:35 +02:00
|
|
|
|
if (!$this->oUserCurrent) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Создаем заметку и проводим валидацию
|
|
|
|
|
*/
|
|
|
|
|
$oNote=Engine::GetEntity('ModuleUser_EntityNote');
|
|
|
|
|
$oNote->setTargetUserId(getRequest('iUserId'));
|
|
|
|
|
$oNote->setUserId($this->oUserCurrent->getId());
|
2012-07-08 11:50:36 +03:00
|
|
|
|
$oNote->setText((string)getRequest('text'));
|
2012-03-16 13:14:35 +02:00
|
|
|
|
|
|
|
|
|
if ($oNote->_Validate()) {
|
|
|
|
|
/**
|
|
|
|
|
* Экранируем текст и добавляем запись в БД
|
|
|
|
|
*/
|
|
|
|
|
$oNote->setText(htmlspecialchars($oNote->getText()));
|
|
|
|
|
if ($this->User_SaveNote($oNote)) {
|
|
|
|
|
$this->Viewer_AssignAjax('sText',$oNote->getText());
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_note_save_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2012-03-24 07:11:48 +02:00
|
|
|
|
$this->Message_AddError($oNote->_getValidateError(),$this->Lang_Get('error'));
|
2012-03-16 13:14:35 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Удаляет заметку о пользователе
|
|
|
|
|
*/
|
|
|
|
|
public function EventAjaxNoteRemove() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2012-03-16 13:14:35 +02:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
if (!$this->oUserCurrent) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!($oUserTarget=$this->User_GetUserById(getRequest('iUserId')))) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
if (!($oNote=$this->User_GetUserNote($oUserTarget->getId(),$this->oUserCurrent->getId()))) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
$this->User_DeleteUserNoteById($oNote->getId());
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Список созданных заметок
|
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
public function EventCreatedNotes() {
|
|
|
|
|
if (!$this->CheckUserProfile()) {
|
2012-03-16 14:51:05 +02:00
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->sMenuSubItemSelect='notes';
|
2012-03-16 14:51:05 +02:00
|
|
|
|
/**
|
|
|
|
|
* Заметки может читать только сам пользователь
|
|
|
|
|
*/
|
|
|
|
|
if (!$this->oUserCurrent or $this->oUserCurrent->getId()!=$this->oUserProfile->getId()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
$iPage=$this->GetParamEventMatch(2,2) ? $this->GetParamEventMatch(2,2) : 1;
|
2012-03-16 14:51:05 +02:00
|
|
|
|
/**
|
|
|
|
|
* Получаем список заметок
|
|
|
|
|
*/
|
|
|
|
|
$aResult=$this->User_GetUserNotesByUserId($this->oUserProfile->getId(),$iPage,Config::Get('module.user.usernote_per_page'));
|
|
|
|
|
$aNotes=$aResult['collection'];
|
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
|
|
|
|
*/
|
2012-04-25 17:47:47 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.usernote_per_page'),Config::Get('pagination.pages.count'),$this->oUserProfile->getUserWebPath().'created/notes');
|
2012-03-16 14:51:05 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign('aNotes',$aNotes);
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_notes'));
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
2012-03-19 06:12:59 +02:00
|
|
|
|
$this->SetTemplateAction('created_notes');
|
2012-03-16 14:51:05 +02:00
|
|
|
|
}
|
2009-09-02 23:36:44 +03:00
|
|
|
|
/**
|
|
|
|
|
* Добавление пользователя в друзья, по отправленной заявке
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
public function EventFriendOffer() {
|
|
|
|
|
require_once Config::Get('path.root.engine').'/lib/external/XXTEA/encrypt.php';
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Из реквеста дешефруем ID польователя
|
|
|
|
|
*/
|
2012-07-08 11:50:36 +03:00
|
|
|
|
$sUserId=xxtea_decrypt(base64_decode(rawurldecode((string)getRequest('code'))), Config::Get('module.talk.encrypt'));
|
2010-04-03 23:38:00 +03:00
|
|
|
|
if (!$sUserId) {
|
|
|
|
|
return $this->EventNotFound();
|
|
|
|
|
}
|
2009-09-05 16:35:44 +03:00
|
|
|
|
list($sUserId,)=explode('_',$sUserId,2);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-02 23:36:44 +03:00
|
|
|
|
$sAction=$this->GetParam(0);
|
|
|
|
|
/**
|
|
|
|
|
* Получаем текущего пользователя
|
|
|
|
|
*/
|
|
|
|
|
if(!$this->User_IsAuthorization()) {
|
|
|
|
|
return $this->EventNotFound();
|
|
|
|
|
}
|
2009-09-26 03:51:20 +03:00
|
|
|
|
$this->oUserCurrent = $this->User_GetUserCurrent();
|
2009-09-02 23:36:44 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем объект пользователя приславшего заявку,
|
|
|
|
|
* если пользователь не найден, переводим в раздел сообщений (Talk) -
|
|
|
|
|
* так как пользователь мог перейти сюда либо из talk-сообщений,
|
|
|
|
|
* либо из e-mail письма-уведомления
|
|
|
|
|
*/
|
|
|
|
|
if(!$oUser=$this->User_GetUserById($sUserId)) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_not_found'),$this->Lang_Get('error'),true);
|
2009-09-09 20:49:00 +03:00
|
|
|
|
Router::Location(Router::GetPath('talk'));
|
2009-09-02 23:36:44 +03:00
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем связь дружбы из базы данных.
|
|
|
|
|
* Если связь не найдена либо статус отличен от OFFER,
|
|
|
|
|
* переходим в раздел Talk и возвращаем сообщение об ошибке
|
|
|
|
|
*/
|
2009-09-26 03:51:20 +03:00
|
|
|
|
$oFriend=$this->User_GetFriend($this->oUserCurrent->getId(),$oUser->getId(),0);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if(!$oFriend
|
2009-09-05 16:35:44 +03:00
|
|
|
|
|| !in_array(
|
2012-04-29 20:11:53 +03:00
|
|
|
|
$oFriend->getFriendStatus(),
|
|
|
|
|
array(
|
|
|
|
|
ModuleUser::USER_FRIEND_OFFER+ModuleUser::USER_FRIEND_NULL,
|
2009-09-05 16:35:44 +03:00
|
|
|
|
)
|
2012-04-29 20:11:53 +03:00
|
|
|
|
)
|
|
|
|
|
) {
|
2009-09-04 10:36:38 +03:00
|
|
|
|
$sMessage=($oFriend)
|
|
|
|
|
? $this->Lang_Get('user_friend_offer_already_done')
|
|
|
|
|
: $this->Lang_Get('user_friend_offer_not_found');
|
|
|
|
|
$this->Message_AddError($sMessage,$this->Lang_Get('error'),true);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-09 20:49:00 +03:00
|
|
|
|
Router::Location(Router::GetPath('talk'));
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return ;
|
|
|
|
|
}
|
2009-09-02 23:36:44 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем новый статус связи
|
|
|
|
|
*/
|
|
|
|
|
$oFriend->setStatusTo(
|
|
|
|
|
($sAction=='accept')
|
2010-05-27 17:02:43 +03:00
|
|
|
|
? ModuleUser::USER_FRIEND_ACCEPT
|
|
|
|
|
: ModuleUser::USER_FRIEND_REJECT
|
2009-09-02 23:36:44 +03:00
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-02 23:36:44 +03:00
|
|
|
|
if ($this->User_UpdateFriend($oFriend)) {
|
2009-09-04 10:36:38 +03:00
|
|
|
|
$sMessage=($sAction=='accept')
|
|
|
|
|
? $this->Lang_Get('user_friend_add_ok')
|
|
|
|
|
: $this->Lang_Get('user_friend_offer_reject');
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-04 10:36:38 +03:00
|
|
|
|
$this->Message_AddNoticeSingle($sMessage,$this->Lang_Get('attention'),true);
|
2009-09-26 03:51:20 +03:00
|
|
|
|
$this->NoticeFriendOffer($oUser,$sAction);
|
2009-09-02 23:36:44 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('system_error'),
|
|
|
|
|
$this->Lang_Get('error'),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
}
|
2009-09-09 20:49:00 +03:00
|
|
|
|
Router::Location(Router::GetPath('talk'));
|
2009-09-02 23:36:44 +03:00
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Подтверждение заявки на добавления в друзья
|
|
|
|
|
*/
|
2009-09-05 16:35:44 +03:00
|
|
|
|
public function EventAjaxFriendAccept() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2010-08-21 19:31:41 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2009-10-17 21:04:22 +03:00
|
|
|
|
$sUserId=getRequest('idUser',null,'post');
|
2009-09-05 16:35:44 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если пользователь не авторизирован, возвращаем ошибку
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2009-09-05 16:35:44 +03:00
|
|
|
|
if (!$this->User_IsAuthorization()) {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('need_authorization'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-05 16:35:44 +03:00
|
|
|
|
}
|
|
|
|
|
$this->oUserCurrent=$this->User_GetUserCurrent();
|
|
|
|
|
/**
|
|
|
|
|
* При попытке добавить в друзья себя, возвращаем ошибку
|
|
|
|
|
*/
|
|
|
|
|
if ($this->oUserCurrent->getId()==$sUserId) {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_add_self'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Если пользователь не найден, возвращаем ошибку
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if( !$oUser=$this->User_GetUserById($sUserId) ) {
|
2009-09-05 16:35:44 +03:00
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_not_found'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-05 16:35:44 +03:00
|
|
|
|
}
|
|
|
|
|
$this->oUserProfile=$oUser;
|
|
|
|
|
/**
|
|
|
|
|
* Получаем статус дружбы между пользователями
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$oFriend=$this->User_GetFriend($oUser->getId(),$this->oUserCurrent->getId());
|
2009-09-05 16:35:44 +03:00
|
|
|
|
/**
|
|
|
|
|
* При попытке потдвердить ранее отклоненную заявку,
|
|
|
|
|
* проверяем, чтобы изменяющий был принимающей стороной
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if($oFriend
|
|
|
|
|
&& ($oFriend->getStatusFrom()==ModuleUser::USER_FRIEND_OFFER||$oFriend->getStatusFrom()==ModuleUser::USER_FRIEND_ACCEPT)
|
|
|
|
|
&& ($oFriend->getStatusTo()==ModuleUser::USER_FRIEND_REJECT||$oFriend->getStatusTo()==ModuleUser::USER_FRIEND_NULL)
|
2009-09-06 17:09:27 +03:00
|
|
|
|
&& $oFriend->getUserTo()==$this->oUserCurrent->getId()) {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Меняем статус с отвергнутое, на акцептованное
|
|
|
|
|
*/
|
|
|
|
|
$oFriend->setStatusByUserId(ModuleUser::USER_FRIEND_ACCEPT,$this->oUserCurrent->getId());
|
|
|
|
|
if($this->User_UpdateFriend($oFriend)) {
|
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('user_friend_add_ok'),$this->Lang_Get('attention'));
|
|
|
|
|
$this->NoticeFriendOffer($oUser,'accept');
|
2009-09-05 16:35:44 +03:00
|
|
|
|
/**
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* Добавляем событие в ленту
|
2009-09-05 16:35:44 +03:00
|
|
|
|
*/
|
2012-04-29 20:11:53 +03:00
|
|
|
|
$this->Stream_write($oFriend->getUserFrom(), 'add_friend', $oFriend->getUserTo());
|
|
|
|
|
$this->Stream_write($oFriend->getUserTo(), 'add_friend', $oFriend->getUserFrom());
|
|
|
|
|
/**
|
|
|
|
|
* Добавляем пользователей к друг другу в ленту активности
|
|
|
|
|
*/
|
|
|
|
|
$this->Stream_subscribeUser($oFriend->getUserFrom(), $oFriend->getUserTo());
|
|
|
|
|
$this->Stream_subscribeUser($oFriend->getUserTo(), $oFriend->getUserFrom());
|
2012-03-24 11:01:23 +02:00
|
|
|
|
|
2012-04-29 20:11:53 +03:00
|
|
|
|
$oViewerLocal=$this->GetViewerLocal();
|
|
|
|
|
$oViewerLocal->Assign('oUserFriend',$oFriend);
|
|
|
|
|
$this->Viewer_AssignAjax('sToggleText',$oViewerLocal->Fetch("actions/ActionProfile/friend_item.tpl"));
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2012-04-29 20:11:53 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('system_error'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return;
|
2009-09-05 16:35:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('system_error'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-05 16:35:44 +03:00
|
|
|
|
}
|
2009-09-26 03:51:20 +03:00
|
|
|
|
/**
|
|
|
|
|
* Отправляет пользователю Talk уведомление о принятии или отклонении его заявки
|
|
|
|
|
*
|
2010-05-27 18:16:20 +03:00
|
|
|
|
* @param ModuleUser_EntityUser $oUser
|
2012-04-29 20:11:53 +03:00
|
|
|
|
* @param string $sAction
|
2009-09-26 03:51:20 +03:00
|
|
|
|
*/
|
|
|
|
|
protected function NoticeFriendOffer($oUser,$sAction) {
|
|
|
|
|
/**
|
|
|
|
|
* Проверяем допустимость действия
|
|
|
|
|
*/
|
|
|
|
|
if(!in_array($sAction,array('accept','reject'))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Проверяем настройки (нужно ли отправлять уведомление)
|
|
|
|
|
*/
|
|
|
|
|
if(!Config::Get("module.user.friend_notice.{$sAction}")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-26 03:51:20 +03:00
|
|
|
|
$sTitle=$this->Lang_Get("user_friend_{$sAction}_notice_title");
|
|
|
|
|
$sText=$this->Lang_Get(
|
|
|
|
|
"user_friend_{$sAction}_notice_text",
|
|
|
|
|
array(
|
|
|
|
|
'login'=>$this->oUserCurrent->getLogin(),
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$oTalk=$this->Talk_SendTalk($sTitle,$sText,$this->oUserCurrent,array($oUser),false,false);
|
|
|
|
|
$this->Talk_DeleteTalkUserByArray($oTalk->getId(),$this->oUserCurrent->getId());
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Обработка Ajax добавления в друзья
|
|
|
|
|
*/
|
2009-09-03 10:30:50 +03:00
|
|
|
|
public function EventAjaxFriendAdd() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2010-08-21 19:31:41 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$sUserId=getRequest('idUser');
|
|
|
|
|
$sUserText=getRequest('userText','');
|
|
|
|
|
/**
|
|
|
|
|
* Если пользователь не авторизирован, возвращаем ошибку
|
2009-09-22 00:08:00 +03:00
|
|
|
|
*/
|
2009-09-03 10:30:50 +03:00
|
|
|
|
if (!$this->User_IsAuthorization()) {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('need_authorization'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-03 10:30:50 +03:00
|
|
|
|
}
|
|
|
|
|
$this->oUserCurrent=$this->User_GetUserCurrent();
|
|
|
|
|
/**
|
|
|
|
|
* При попытке добавить в друзья себя, возвращаем ошибку
|
|
|
|
|
*/
|
|
|
|
|
if ($this->oUserCurrent->getId()==$sUserId) {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_add_self'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Если пользователь не найден, возвращаем ошибку
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if( !$oUser=$this->User_GetUserById($sUserId) ) {
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_not_found'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-03 10:30:50 +03:00
|
|
|
|
}
|
2009-09-04 02:40:56 +03:00
|
|
|
|
$this->oUserProfile=$oUser;
|
2009-09-03 10:30:50 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем статус дружбы между пользователями
|
|
|
|
|
*/
|
|
|
|
|
$oFriend=$this->User_GetFriend($oUser->getId(),$this->oUserCurrent->getId());
|
|
|
|
|
/**
|
|
|
|
|
* Если связи ранее не было в базе данных, добавляем новую
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if( !$oFriend ) {
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$this->SubmitAddFriend($oUser,$sUserText,$oFriend);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-03 10:30:50 +03:00
|
|
|
|
}
|
|
|
|
|
/**
|
2011-06-06 14:58:19 +03:00
|
|
|
|
* Если статус связи соответствует статусам отправленной и акцептованной заявки,
|
2009-09-03 10:30:50 +03:00
|
|
|
|
* то предупреждаем что этот пользователь уже является нашим другом
|
|
|
|
|
*/
|
2010-05-27 17:02:43 +03:00
|
|
|
|
if($oFriend->getFriendStatus()==ModuleUser::USER_FRIEND_OFFER + ModuleUser::USER_FRIEND_ACCEPT) {
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_already_exist'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
2011-06-06 14:58:19 +03:00
|
|
|
|
* Если пользователь ранее отклонил нашу заявку,
|
2009-09-03 10:30:50 +03:00
|
|
|
|
* возвращаем сообщение об ошибке
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if($oFriend->getUserFrom()==$this->oUserCurrent->getId()
|
2012-04-29 20:11:53 +03:00
|
|
|
|
&& $oFriend->getStatusTo()==ModuleUser::USER_FRIEND_REJECT ) {
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_offer_reject'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-03 10:30:50 +03:00
|
|
|
|
}
|
2009-09-04 02:40:56 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если дружба была удалена, то проверяем кто ее удалил
|
|
|
|
|
* и разрешаем восстановить только удалившему
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if($oFriend->getFriendStatus()>ModuleUser::USER_FRIEND_DELETE
|
2012-04-29 20:11:53 +03:00
|
|
|
|
&& $oFriend->getFriendStatus()<ModuleUser::USER_FRIEND_REJECT) {
|
2009-09-04 02:40:56 +03:00
|
|
|
|
/**
|
|
|
|
|
* Определяем статус связи текущего пользователя
|
|
|
|
|
*/
|
|
|
|
|
$iStatusCurrent = $oFriend->getStatusByUserId($this->oUserCurrent->getId());
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2010-05-27 17:02:43 +03:00
|
|
|
|
if($iStatusCurrent==ModuleUser::USER_FRIEND_DELETE) {
|
2009-09-04 02:40:56 +03:00
|
|
|
|
/**
|
2011-06-06 14:58:19 +03:00
|
|
|
|
* Меняем статус с удаленного, на акцептованное
|
2009-09-04 02:40:56 +03:00
|
|
|
|
*/
|
2010-05-27 17:02:43 +03:00
|
|
|
|
$oFriend->setStatusByUserId(ModuleUser::USER_FRIEND_ACCEPT,$this->oUserCurrent->getId());
|
2009-09-04 02:40:56 +03:00
|
|
|
|
if($this->User_UpdateFriend($oFriend)) {
|
2011-07-31 19:52:50 +03:00
|
|
|
|
/**
|
|
|
|
|
* Добавляем событие в ленту
|
|
|
|
|
*/
|
|
|
|
|
$this->Stream_write($oFriend->getUserFrom(), 'add_friend', $oFriend->getUserTo());
|
2012-04-29 20:11:53 +03:00
|
|
|
|
$this->Stream_write($oFriend->getUserTo(), 'add_friend', $oFriend->getUserFrom());
|
2009-09-04 02:40:56 +03:00
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('user_friend_add_ok'),$this->Lang_Get('attention'));
|
|
|
|
|
|
|
|
|
|
$oViewerLocal=$this->GetViewerLocal();
|
|
|
|
|
$oViewerLocal->Assign('oUserFriend',$oFriend);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$this->Viewer_AssignAjax('sToggleText',$oViewerLocal->Fetch("actions/ActionProfile/friend_item.tpl"));
|
|
|
|
|
|
2009-09-04 02:40:56 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('system_error'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_add_deleted'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-04 02:40:56 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-04 10:36:38 +03:00
|
|
|
|
/**
|
|
|
|
|
* Функция создает локальный объект вьювера для рендеринга html-объектов в ajax запросах
|
|
|
|
|
*
|
2010-05-27 17:02:43 +03:00
|
|
|
|
* @return ModuleViewer
|
2009-09-04 10:36:38 +03:00
|
|
|
|
*/
|
2009-09-04 02:40:56 +03:00
|
|
|
|
protected function GetViewerLocal() {
|
|
|
|
|
/**
|
|
|
|
|
* Получаем HTML код inject-объекта
|
|
|
|
|
*/
|
2009-12-14 22:25:30 +02:00
|
|
|
|
$oViewerLocal=$this->Viewer_GetLocalViewer();
|
2009-09-04 02:40:56 +03:00
|
|
|
|
$oViewerLocal->Assign('oUserCurrent',$this->oUserCurrent);
|
|
|
|
|
$oViewerLocal->Assign('oUserProfile',$this->oUserProfile);
|
|
|
|
|
|
2010-05-27 17:02:43 +03:00
|
|
|
|
$oViewerLocal->Assign('USER_FRIEND_NULL',ModuleUser::USER_FRIEND_NULL);
|
|
|
|
|
$oViewerLocal->Assign('USER_FRIEND_OFFER',ModuleUser::USER_FRIEND_OFFER);
|
|
|
|
|
$oViewerLocal->Assign('USER_FRIEND_ACCEPT',ModuleUser::USER_FRIEND_ACCEPT);
|
|
|
|
|
$oViewerLocal->Assign('USER_FRIEND_REJECT',ModuleUser::USER_FRIEND_REJECT);
|
|
|
|
|
$oViewerLocal->Assign('USER_FRIEND_DELETE',ModuleUser::USER_FRIEND_DELETE);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-04 02:40:56 +03:00
|
|
|
|
return $oViewerLocal;
|
2009-09-03 10:30:50 +03:00
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Обработка добавления в друзья
|
|
|
|
|
*
|
|
|
|
|
* @param $oUser
|
|
|
|
|
* @param $sUserText
|
|
|
|
|
* @param null $oFriend
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2009-09-03 10:30:50 +03:00
|
|
|
|
protected function SubmitAddFriend($oUser,$sUserText,$oFriend=null) {
|
2012-01-08 17:50:39 +02:00
|
|
|
|
/**
|
|
|
|
|
* Ограничения на добавления в друзья, т.к. приглашение отправляется в личку, то и ограничиваем по ней
|
|
|
|
|
*/
|
|
|
|
|
if (!$this->ACL_CanSendTalkTime($this->oUserCurrent)) {
|
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('user_friend_add_time_limit'),$this->Lang_Get('error'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Обрабатываем текст заявки
|
|
|
|
|
*/
|
2010-12-19 10:36:31 +02:00
|
|
|
|
$sUserText=$this->Text_Parser($sUserText);
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Создаем связь с другом
|
|
|
|
|
*/
|
2009-09-08 15:02:51 +03:00
|
|
|
|
$oFriendNew=Engine::GetEntity('User_Friend');
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$oFriendNew->setUserTo($oUser->getId());
|
|
|
|
|
$oFriendNew->setUserFrom($this->oUserCurrent->getId());
|
|
|
|
|
// Добавляем заявку в друзья
|
2010-05-27 17:02:43 +03:00
|
|
|
|
$oFriendNew->setStatusFrom(ModuleUser::USER_FRIEND_OFFER);
|
|
|
|
|
$oFriendNew->setStatusTo(ModuleUser::USER_FRIEND_NULL);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$bStateError=($oFriend)
|
|
|
|
|
? !$this->User_UpdateFriend($oFriendNew)
|
|
|
|
|
: !$this->User_AddFriend($oFriendNew);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-03 10:30:50 +03:00
|
|
|
|
if ( !$bStateError ) {
|
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('user_friend_offer_send'),$this->Lang_Get('attention'));
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$sTitle=$this->Lang_Get(
|
|
|
|
|
'user_friend_offer_title',
|
|
|
|
|
array(
|
|
|
|
|
'login'=>$this->oUserCurrent->getLogin(),
|
|
|
|
|
'friend'=>$oUser->getLogin()
|
|
|
|
|
)
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-04 22:01:21 +03:00
|
|
|
|
require_once Config::Get('path.root.engine').'/lib/external/XXTEA/encrypt.php';
|
2009-09-05 16:35:44 +03:00
|
|
|
|
$sCode=$this->oUserCurrent->getId().'_'.$oUser->getId();
|
2010-04-03 23:38:00 +03:00
|
|
|
|
$sCode=rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('module.talk.encrypt'))));
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-06 17:09:27 +03:00
|
|
|
|
$aPath=array(
|
|
|
|
|
'accept'=>Router::GetPath('profile').'friendoffer/accept/?code='.$sCode,
|
|
|
|
|
'reject'=>Router::GetPath('profile').'friendoffer/reject/?code='.$sCode
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
2009-09-03 10:30:50 +03:00
|
|
|
|
$sText=$this->Lang_Get(
|
|
|
|
|
'user_friend_offer_text',
|
|
|
|
|
array(
|
|
|
|
|
'login'=>$this->oUserCurrent->getLogin(),
|
2009-09-06 17:09:27 +03:00
|
|
|
|
'accept_path'=>$aPath['accept'],
|
|
|
|
|
'reject_path'=>$aPath['reject'],
|
2009-09-03 10:30:50 +03:00
|
|
|
|
'user_text'=>$sUserText
|
|
|
|
|
)
|
|
|
|
|
);
|
2009-09-04 17:57:34 +03:00
|
|
|
|
$oTalk=$this->Talk_SendTalk($sTitle,$sText,$this->oUserCurrent,array($oUser),false,false);
|
2009-09-06 17:09:27 +03:00
|
|
|
|
/**
|
|
|
|
|
* Отправляем пользователю заявку
|
|
|
|
|
*/
|
|
|
|
|
$this->Notify_SendUserFriendNew(
|
|
|
|
|
$oUser,$this->oUserCurrent,$sUserText,
|
|
|
|
|
Router::GetPath('talk').'read/'.$oTalk->getId().'/'
|
2011-06-06 14:58:19 +03:00
|
|
|
|
);
|
2009-09-04 17:57:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаляем отправляющего юзера из переписки
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2009-09-04 17:57:34 +03:00
|
|
|
|
$this->Talk_DeleteTalkUserByArray($oTalk->getId(),$this->oUserCurrent->getId());
|
2009-09-03 10:30:50 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
2011-06-06 14:58:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-04 02:40:56 +03:00
|
|
|
|
$oViewerLocal=$this->GetViewerLocal();
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$oViewerLocal->Assign('oUserFriend',$oFriendNew);
|
|
|
|
|
$this->Viewer_AssignAjax('sToggleText',$oViewerLocal->Fetch("actions/ActionProfile/friend_item.tpl"));
|
2009-09-03 10:30:50 +03:00
|
|
|
|
}
|
2009-09-03 20:07:02 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаление пользователя из друзей
|
|
|
|
|
*/
|
|
|
|
|
public function EventAjaxFriendDelete() {
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем формат Ajax ответа
|
|
|
|
|
*/
|
2010-08-21 19:31:41 +03:00
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2009-10-17 21:04:22 +03:00
|
|
|
|
$sUserId=getRequest('idUser',null,'post');
|
2009-09-03 20:07:02 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если пользователь не авторизирован, возвращаем ошибку
|
2011-06-06 14:58:19 +03:00
|
|
|
|
*/
|
2009-09-03 20:07:02 +03:00
|
|
|
|
if (!$this->User_IsAuthorization()) {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('need_authorization'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-03 20:07:02 +03:00
|
|
|
|
}
|
|
|
|
|
$this->oUserCurrent=$this->User_GetUserCurrent();
|
|
|
|
|
/**
|
|
|
|
|
* При попытке добавить в друзья себя, возвращаем ошибку
|
|
|
|
|
*/
|
|
|
|
|
if ($this->oUserCurrent->getId()==$sUserId) {
|
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_add_self'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Если пользователь не найден, возвращаем ошибку
|
|
|
|
|
*/
|
2011-06-06 14:58:19 +03:00
|
|
|
|
if( !$oUser=$this->User_GetUserById($sUserId) ) {
|
2009-09-03 20:07:02 +03:00
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_del_no'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2009-12-12 19:18:04 +02:00
|
|
|
|
return;
|
2009-09-03 20:07:02 +03:00
|
|
|
|
}
|
2009-12-12 19:18:04 +02:00
|
|
|
|
$this->oUserProfile=$oUser;
|
2009-09-03 20:07:02 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем статус дружбы между пользователями.
|
|
|
|
|
* Если статус не определен, или отличается от принятой заявки,
|
|
|
|
|
* возвращаем ошибку
|
|
|
|
|
*/
|
2009-12-12 19:18:04 +02:00
|
|
|
|
$oFriend=$this->User_GetFriend($oUser->getId(),$this->oUserCurrent->getId());
|
2010-05-27 17:02:43 +03:00
|
|
|
|
$aAllowedFriendStatus = array(ModuleUser::USER_FRIEND_ACCEPT+ModuleUser::USER_FRIEND_OFFER,ModuleUser::USER_FRIEND_ACCEPT+ModuleUser::USER_FRIEND_ACCEPT);
|
2009-12-12 19:18:04 +02:00
|
|
|
|
if(!$oFriend || !in_array($oFriend->getFriendStatus(),$aAllowedFriendStatus)) {
|
2009-09-03 20:07:02 +03:00
|
|
|
|
$this->Message_AddErrorSingle(
|
|
|
|
|
$this->Lang_Get('user_friend_del_no'),
|
|
|
|
|
$this->Lang_Get('error')
|
|
|
|
|
);
|
2009-12-12 19:18:04 +02:00
|
|
|
|
return;
|
2009-09-03 20:07:02 +03:00
|
|
|
|
}
|
2012-04-29 20:11:53 +03:00
|
|
|
|
/**
|
|
|
|
|
* Удаляем из друзей
|
|
|
|
|
*/
|
2009-09-03 20:07:02 +03:00
|
|
|
|
if( $this->User_DeleteFriend($oFriend) ) {
|
|
|
|
|
$this->Message_AddNoticeSingle($this->Lang_Get('user_friend_del_ok'),$this->Lang_Get('attention'));
|
2009-09-04 02:40:56 +03:00
|
|
|
|
|
|
|
|
|
$oViewerLocal=$this->GetViewerLocal();
|
|
|
|
|
$oViewerLocal->Assign('oUserFriend',$oFriend);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$this->Viewer_AssignAjax('sToggleText',$oViewerLocal->Fetch("actions/ActionProfile/friend_item.tpl"));
|
|
|
|
|
|
2009-09-26 03:51:20 +03:00
|
|
|
|
/**
|
|
|
|
|
* Отправляем пользователю сообщение об удалении дружеской связи
|
|
|
|
|
*/
|
|
|
|
|
if(Config::Get('module.user.friend_notice.delete')) {
|
|
|
|
|
$sText=$this->Lang_Get(
|
|
|
|
|
'user_friend_del_notice_text',
|
|
|
|
|
array(
|
|
|
|
|
'login'=>$this->oUserCurrent->getLogin(),
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$oTalk=$this->Talk_SendTalk(
|
|
|
|
|
$this->Lang_Get('user_friend_del_notice_title'),
|
|
|
|
|
$sText,$this->oUserCurrent,
|
|
|
|
|
array($oUser),false,false
|
|
|
|
|
);
|
2011-06-06 14:58:19 +03:00
|
|
|
|
$this->Talk_DeleteTalkUserByArray($oTalk->getId(),$this->oUserCurrent->getId());
|
2009-09-26 03:51:20 +03:00
|
|
|
|
}
|
2011-06-06 14:58:19 +03:00
|
|
|
|
return;
|
2009-09-03 20:07:02 +03:00
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-21 09:36:57 +03:00
|
|
|
|
/**
|
2009-03-01 13:59:53 +02:00
|
|
|
|
* Выполняется при завершении работы экшена
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2010-02-06 02:09:44 +02:00
|
|
|
|
public function EventShutdown() {
|
2009-03-01 13:59:53 +02:00
|
|
|
|
if (!$this->oUserProfile) {
|
|
|
|
|
return ;
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
/**
|
2009-03-01 13:59:53 +02:00
|
|
|
|
* Загружаем в шаблон необходимые переменные
|
2008-09-21 09:36:57 +03:00
|
|
|
|
*/
|
2009-03-01 13:59:53 +02:00
|
|
|
|
$iCountTopicFavourite=$this->Topic_GetCountTopicsFavouriteByUserId($this->oUserProfile->getId());
|
|
|
|
|
$iCountTopicUser=$this->Topic_GetCountTopicsPersonalByUser($this->oUserProfile->getId(),1);
|
2009-06-23 20:06:19 +03:00
|
|
|
|
$iCountCommentUser=$this->Comment_GetCountCommentsByUserId($this->oUserProfile->getId(),'topic');
|
2009-08-22 00:01:09 +03:00
|
|
|
|
$iCountCommentFavourite=$this->Comment_GetCountCommentsFavouriteByUserId($this->oUserProfile->getId());
|
2012-03-19 06:33:41 +02:00
|
|
|
|
$iCountNoteUser=$this->User_GetCountUserNotesByUserId($this->oUserProfile->getId());
|
2011-06-06 14:58:19 +03:00
|
|
|
|
|
|
|
|
|
$this->Viewer_Assign('oUserProfile',$this->oUserProfile);
|
|
|
|
|
$this->Viewer_Assign('iCountTopicUser',$iCountTopicUser);
|
|
|
|
|
$this->Viewer_Assign('iCountCommentUser',$iCountCommentUser);
|
2009-03-01 13:59:53 +02:00
|
|
|
|
$this->Viewer_Assign('iCountTopicFavourite',$iCountTopicFavourite);
|
2009-08-22 00:01:09 +03:00
|
|
|
|
$this->Viewer_Assign('iCountCommentFavourite',$iCountCommentFavourite);
|
2012-03-19 06:33:41 +02:00
|
|
|
|
$this->Viewer_Assign('iCountNoteUser',$iCountNoteUser);
|
2012-03-19 07:59:29 +02:00
|
|
|
|
$this->Viewer_Assign('iCountWallUser',$this->Wall_GetCountWall(array('wall_user_id'=>$this->oUserProfile->getId(),'pid'=>null)));
|
2012-03-19 06:33:41 +02:00
|
|
|
|
/**
|
|
|
|
|
* Общее число публикация и избранного
|
|
|
|
|
*/
|
2012-03-19 08:08:43 +02:00
|
|
|
|
$this->Viewer_Assign('iCountCreated',(($this->oUserCurrent and $this->oUserCurrent->getId()==$this->oUserProfile->getId()) ? $iCountNoteUser : 0) +$iCountTopicUser+$iCountCommentUser);
|
2012-03-19 06:33:41 +02:00
|
|
|
|
$this->Viewer_Assign('iCountFavourite',$iCountCommentFavourite+$iCountTopicFavourite);
|
2012-03-19 08:08:43 +02:00
|
|
|
|
/**
|
|
|
|
|
* Заметка текущего пользователя о юзере
|
|
|
|
|
*/
|
|
|
|
|
if ($this->oUserCurrent) {
|
|
|
|
|
$this->Viewer_Assign('oUserNote',$this->User_GetUserNote($this->oUserProfile->getId(),$this->oUserCurrent->getId()));
|
|
|
|
|
}
|
2012-03-19 12:02:07 +02:00
|
|
|
|
$this->Viewer_Assign('iCountFriendsUser',$this->User_GetCountUsersFriend($this->oUserProfile->getId()));
|
2012-03-19 06:33:41 +02:00
|
|
|
|
|
2012-04-20 13:36:07 +03:00
|
|
|
|
$this->Viewer_Assign('sMenuSubItemSelect',$this->sMenuSubItemSelect);
|
2012-06-03 06:16:57 +03:00
|
|
|
|
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
|
2010-05-27 17:02:43 +03:00
|
|
|
|
$this->Viewer_Assign('USER_FRIEND_NULL',ModuleUser::USER_FRIEND_NULL);
|
|
|
|
|
$this->Viewer_Assign('USER_FRIEND_OFFER',ModuleUser::USER_FRIEND_OFFER);
|
|
|
|
|
$this->Viewer_Assign('USER_FRIEND_ACCEPT',ModuleUser::USER_FRIEND_ACCEPT);
|
|
|
|
|
$this->Viewer_Assign('USER_FRIEND_REJECT',ModuleUser::USER_FRIEND_REJECT);
|
|
|
|
|
$this->Viewer_Assign('USER_FRIEND_DELETE',ModuleUser::USER_FRIEND_DELETE);
|
2008-09-21 09:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|