/**
  * Отправляет пользователю сообщение о добавлении его в друзья
  *
  * @param ModuleUser_EntityUser $oUserTo
  * @param ModuleUser_EntityUser $oUserFrom
  * @param string $sText
  */
 public function SendUserMarkImageNew(ModuleUser_EntityUser $oUserTo, ModuleUser_EntityUser $oUserFrom, $sText)
 {
     /**
      * Если в конфигураторе указан отложенный метод отправки,
      * то добавляем задание в массив. В противном случае,
      * сразу отсылаем на email
      */
     if (Config::Get('module.notify.delayed')) {
         $oNotifyTask = Engine::GetEntity('Notify_Task', array('user_mail' => $oUserTo->getMail(), 'user_login' => $oUserTo->getLogin(), 'notify_text' => $sText, 'notify_subject' => $this->Lang_Get('plugin.lsgallery.lsgallery_marked_subject'), 'date_created' => date("Y-m-d H:i:s"), 'notify_task_status' => self::NOTIFY_TASK_STATUS_NULL));
         if (Config::Get('module.notify.insert_single')) {
             $this->aTask[] = $oNotifyTask;
         } else {
             $this->oMapper->AddTask($oNotifyTask);
         }
     } else {
         /**
          * Отправляем мыло
          */
         $this->Mail_SetAdress($oUserTo->getMail(), $oUserTo->getLogin());
         $this->Mail_SetSubject($this->Lang_Get('plugin.lsgallery.lsgallery_marked_subject'));
         $this->Mail_SetBody($sText);
         $this->Mail_setHTML();
         $this->Mail_Send();
     }
 }
예제 #2
0
 /**
  * Авторизовывает юзера
  *
  * @param ModuleUser_EntityUser $oUser	Объект пользователя
  * @param bool $bRemember	Запоминать пользователя или нет
  * @param string $sKey	Ключ авторизации для куков
  * @return bool
  */
 public function Authorization(ModuleUser_EntityUser $oUser, $bRemember = true, $sKey = null)
 {
     if (!Config::Get('plugin.blacklist.check_authorization') || $oUser && $oUser->isAdministrator() || $oUser && !$this->PluginBlacklist_ModuleBlacklist_blackMail($oUser->getMail(), $oUser->getLogin())) {
         return parent::Authorization($oUser, $bRemember, $sKey);
     }
     $this->Message_AddErrorSingle($this->Lang_Get(Config::Get('plugin.blacklist.check_ip_exact') ? 'plugin.blacklist.user_in_exact_blacklist' : 'plugin.blacklist.user_in_blacklist'));
     return false;
 }
예제 #3
0
    protected function updateUserCat(ModuleUser_EntityUser $oUser)
    {
        $sql = 'UPDATE ' . Config::Get('db.table.user') . ' 
			SET 
				user_cat = ?
			WHERE
				user_id = ?d';
        if ($this->oDb->query($sql, $oUser->getCategory(), $oUser->getId()) !== null) {
            return true;
        }
        return false;
    }
예제 #4
0
 /**
  * Проверяет может ли пользователь создавать запись по времени
  */
 public function CanPostTestimonialTime(ModuleUser_EntityUser $oUser)
 {
     // Для администраторов ограничение по времени не действует
     if ($oUser->isAdministrator() or Config::Get('plugin.testimonials.acl.create.limit_time') == 0 or $oUser->getRating() >= Config::Get('plugin.testimonials.acl.create.limit_time_rating')) {
         return true;
     }
     /**
      * Проверяем, если топик опубликованный меньше чем acl.create.topic.limit_time секунд назад
      */
     $aTestimonials = $this->PluginTestimonials_Testimonials_GetTestimonialsItemsByFilter(array('#page' => array(1, 20), '#order' => array('id' => 'desc'), 'user_id' => $oUser->getId(), 'date_add >' => date("Y-m-d H:i:s", time() - Config::Get('plugin.testimonials.acl.create.limit_time'))));
     if (isset($aTestimonials['count']) and $aTestimonials['count'] > 0) {
         return false;
     }
     return true;
 }
예제 #5
0
 /**
  * Выводит список топиков
  *
  */
 protected function EventShowTopics()
 {
     /**
      * Меню
      */
     $this->sMenuSubItemSelect = $this->sCurrentEvent;
     /**
      * Передан ли номер страницы
      */
     $iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1;
     /**
      * Получаем список топиков
      */
     $aResult = E::ModuleTopic()->GetTopicsPersonalByUser($this->oUserCurrent->getId(), $this->sCurrentEvent == 'published' ? 1 : 0, $iPage, Config::Get('module.topic.per_page'));
     $aTopics = $aResult['collection'];
     /**
      * Формируем постраничность
      */
     $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), R::GetPath('content') . $this->sCurrentEvent);
     /**
      * Загружаем переменные в шаблон
      */
     E::ModuleViewer()->Assign('aPaging', $aPaging);
     E::ModuleViewer()->Assign('aTopics', $aTopics);
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('topic_menu_' . $this->sCurrentEvent));
 }
예제 #6
0
 /**
  * Отписка от блога или пользователя
  *
  */
 protected function EventUnsubscribe()
 {
     // * Устанавливаем формат Ajax ответа
     E::ModuleViewer()->SetResponseAjax('json');
     if (!F::GetRequest('id')) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'));
         return;
     }
     $sType = F::GetRequestStr('type');
     $iType = null;
     // * Определяем от чего отписываемся
     switch ($sType) {
         case 'blogs':
         case 'blog':
             $iType = ModuleUserfeed::SUBSCRIBE_TYPE_BLOG;
             break;
         case 'users':
         case 'user':
             $iType = ModuleUserfeed::SUBSCRIBE_TYPE_USER;
             break;
         default:
             E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'));
             return;
     }
     // * Отписываем пользователя
     E::ModuleUserfeed()->UnsubscribeUser($this->oUserCurrent->getId(), $iType, F::GetRequestStr('id'));
     E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('userfeed_subscribes_updated'), E::ModuleLang()->Get('attention'));
 }
 /**
  * Отписка от блога или пользователя
  *
  */
 protected function EventUnsubscribe()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     $this->Viewer_SetResponseAjax('json');
     if (!getRequest('id')) {
         $this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     $sType = getRequestStr('type');
     $iType = null;
     /**
      * Определяем от чего отписываемся
      */
     switch ($sType) {
         case 'blogs':
             $iType = ModuleUserfeed::SUBSCRIBE_TYPE_BLOG;
             break;
         case 'users':
             $iType = ModuleUserfeed::SUBSCRIBE_TYPE_USER;
             break;
         default:
             $this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
             return;
     }
     /**
      * Отписываем пользователя
      */
     $this->Userfeed_unsubscribeUser($this->oUserCurrent->getId(), $iType, getRequestStr('id'));
     $this->Message_AddNotice($this->Lang_Get('userfeed_subscribes_updated'), $this->Lang_Get('attention'));
 }
예제 #8
0
 /**
  * Голосование админа
  */
 public function EventAjaxVote()
 {
     // * Устанавливаем формат ответа
     E::ModuleViewer()->SetResponseAjax('json');
     if (!E::IsAdmin()) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('need_authorization'), E::ModuleLang()->Get('error'));
         return;
     }
     $nUserId = $this->GetPost('idUser');
     if (!$nUserId || !($oUser = E::ModuleUser()->GetUserById($nUserId))) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_not_found'), E::ModuleLang()->Get('error'));
         return;
     }
     $nValue = $this->GetPost('value');
     $oUserVote = E::GetEntity('Vote');
     $oUserVote->setTargetId($oUser->getId());
     $oUserVote->setTargetType('user');
     $oUserVote->setVoterId($this->oUserCurrent->getId());
     $oUserVote->setDirection($nValue);
     $oUserVote->setDate(F::Now());
     $iVal = (double) E::ModuleRating()->VoteUser($this->oUserCurrent, $oUser, $nValue);
     $oUserVote->setValue($iVal);
     $oUser->setCountVote($oUser->getCountVote() + 1);
     if (E::ModuleVote()->AddVote($oUserVote) && E::ModuleUser()->Update($oUser)) {
         E::ModuleViewer()->AssignAjax('iRating', $oUser->getRating());
         E::ModuleViewer()->AssignAjax('iSkill', $oUser->getSkill());
         E::ModuleViewer()->AssignAjax('iCountVote', $oUser->getCountVote());
         E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('user_vote_ok'), E::ModuleLang()->Get('attention'));
     } else {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('action.admin.vote_error'), E::ModuleLang()->Get('error'));
     }
 }
예제 #9
0
 /**
  * Обработка завершения работу экшена
  */
 public function EventShutdown()
 {
     if (!E::User()) {
         return;
     }
     $iCountTalkFavourite = E::ModuleTalk()->GetCountTalksFavouriteByUserId($this->oUserCurrent->getId());
     E::ModuleViewer()->Assign('iCountTalkFavourite', $iCountTalkFavourite);
     $iUserId = E::UserId();
     // Get stats of various user publications topics, comments, images, etc. and stats of favourites
     $aProfileStats = E::ModuleUser()->GetUserProfileStats($iUserId);
     // Получим информацию об изображениях пользователя
     /** @var ModuleMresource_EntityMresourceCategory[] $aUserImagesInfo */
     $aUserImagesInfo = E::ModuleMresource()->GetAllImageCategoriesByUserId($iUserId);
     E::ModuleViewer()->Assign('oUserProfile', E::User());
     E::ModuleViewer()->Assign('aProfileStats', $aProfileStats);
     E::ModuleViewer()->Assign('aUserImagesInfo', $aUserImagesInfo);
     // Old style skin compatibility
     E::ModuleViewer()->Assign('iCountTopicUser', $aProfileStats['count_topics']);
     E::ModuleViewer()->Assign('iCountCommentUser', $aProfileStats['count_comments']);
     E::ModuleViewer()->Assign('iCountTopicFavourite', $aProfileStats['favourite_topics']);
     E::ModuleViewer()->Assign('iCountCommentFavourite', $aProfileStats['favourite_comments']);
     E::ModuleViewer()->Assign('iCountNoteUser', $aProfileStats['count_usernotes']);
     E::ModuleViewer()->Assign('iCountWallUser', $aProfileStats['count_wallrecords']);
     E::ModuleViewer()->Assign('iPhotoCount', $aProfileStats['count_images']);
     E::ModuleViewer()->Assign('iCountCreated', $aProfileStats['count_created']);
     E::ModuleViewer()->Assign('iCountFavourite', $aProfileStats['count_favourites']);
     E::ModuleViewer()->Assign('iCountFriendsUser', $aProfileStats['count_friends']);
     E::ModuleViewer()->Assign('sMenuSubItemSelect', $this->sMenuSubItemSelect);
     E::ModuleViewer()->Assign('sMenuSubItemSelect', $this->sMenuSubItemSelect);
     // * Передаем константы состояний участников разговора
     E::ModuleViewer()->Assign('TALK_USER_ACTIVE', ModuleTalk::TALK_USER_ACTIVE);
     E::ModuleViewer()->Assign('TALK_USER_DELETE_BY_SELF', ModuleTalk::TALK_USER_DELETE_BY_SELF);
     E::ModuleViewer()->Assign('TALK_USER_DELETE_BY_AUTHOR', ModuleTalk::TALK_USER_DELETE_BY_AUTHOR);
 }
예제 #10
0
 /**
  * Обработка завершения работу экшена
  */
 public function EventShutdown()
 {
     if (!$this->oUserCurrent) {
         return;
     }
     $iCountTalkFavourite = $this->Talk_GetCountTalksFavouriteByUserId($this->oUserCurrent->getId());
     $this->Viewer_Assign('iCountTalkFavourite', $iCountTalkFavourite);
     $iCountTopicFavourite = $this->Topic_GetCountTopicsFavouriteByUserId($this->oUserCurrent->getId());
     $iCountTopicUser = $this->Topic_GetCountTopicsPersonalByUser($this->oUserCurrent->getId(), 1);
     $iCountCommentUser = $this->Comment_GetCountCommentsByUserId($this->oUserCurrent->getId(), 'topic');
     $iCountCommentFavourite = $this->Comment_GetCountCommentsFavouriteByUserId($this->oUserCurrent->getId());
     $iCountNoteUser = $this->User_GetCountUserNotesByUserId($this->oUserCurrent->getId());
     $this->Viewer_Assign('oUserProfile', $this->oUserCurrent);
     $this->Viewer_Assign('iCountWallUser', $this->Wall_GetCountWall(array('wall_user_id' => $this->oUserCurrent->getId(), 'pid' => null)));
     /**
      * Общее число публикация и избранного
      */
     $this->Viewer_Assign('iCountCreated', $iCountNoteUser + $iCountTopicUser + $iCountCommentUser);
     $this->Viewer_Assign('iCountFavourite', $iCountCommentFavourite + $iCountTopicFavourite);
     $this->Viewer_Assign('iCountFriendsUser', $this->User_GetCountUsersFriend($this->oUserCurrent->getId()));
     $this->Viewer_Assign('sMenuProfileItemSelect', $this->sMenuProfileItemSelect);
     $this->Viewer_Assign('sMenuSubItemSelect', $this->sMenuSubItemSelect);
     /**
      * Передаем во вьевер константы состояний участников разговора
      */
     $this->Viewer_Assign('TALK_USER_ACTIVE', ModuleTalk::TALK_USER_ACTIVE);
     $this->Viewer_Assign('TALK_USER_DELETE_BY_SELF', ModuleTalk::TALK_USER_DELETE_BY_SELF);
     $this->Viewer_Assign('TALK_USER_DELETE_BY_AUTHOR', ModuleTalk::TALK_USER_DELETE_BY_AUTHOR);
 }
예제 #11
0
 /**
  * Отписка от пользователя
  */
 protected function EventAjaxRemoveUser()
 {
     $iUserId = (int) getRequestStr('user_id');
     /**
      * Устанавливаем формат Ajax ответа
      */
     $this->Viewer_SetResponseAjax('json');
     /**
      * Пользователь авторизован?
      */
     if (!$this->oUserCurrent) {
         return $this->EventErrorDebug();
     }
     /**
      * Пользователь с таким ID существует?
      */
     if (!$this->User_GetUserById($iUserId)) {
         return $this->EventErrorDebug();
     }
     /**
      * Отписываем
      */
     $this->Stream_unsubscribeUser($this->oUserCurrent->getId(), $iUserId);
     $this->Message_AddNotice($this->Lang_Get('common.success.remove'), $this->Lang_Get('common.attention'));
 }
 /**
  * Получение новых комментариев
  *
  */
 protected function AjaxResponseComment()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     $this->Viewer_SetResponseAjax('json');
     /**
      * Пользователь авторизован?
      */
     if (!$this->oUserCurrent) {
         $this->oUserCurrent = $this->User_GetUserById(0);
     }
     /**
      * Топик существует?
      */
     $idTopic = getRequest('idTarget', null, 'post');
     if (!($oTopic = $this->Topic_GetTopicById($idTopic))) {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     $idCommentLast = getRequest('idCommentLast', null, 'post');
     $selfIdComment = getRequest('selfIdComment', null, 'post');
     $aComments = array();
     /**
      * Если используется постраничность, возвращаем только добавленный комментарий
      */
     if (getRequest('bUsePaging', null, 'post') and $selfIdComment) {
         if ($oComment = $this->Comment_GetCommentById($selfIdComment) and $oComment->getTargetId() == $oTopic->getId() and $oComment->getTargetType() == 'topic') {
             $oViewerLocal = $this->Viewer_GetLocalViewer();
             $oViewerLocal->Assign('oUserCurrent', $this->oUserCurrent);
             $oViewerLocal->Assign('bOneComment', true);
             $oViewerLocal->Assign('oComment', $oComment);
             $sText = $oViewerLocal->Fetch($this->Comment_GetTemplateCommentByTarget($oTopic->getId(), 'topic'));
             $aCmt = array();
             $aCmt[] = array('html' => $sText, 'obj' => $oComment);
         } else {
             $aCmt = array();
         }
         $aReturn['comments'] = $aCmt;
         $aReturn['iMaxIdComment'] = $selfIdComment;
     } else {
         $aReturn = $this->Comment_GetCommentsNewByTargetId($oTopic->getId(), 'topic', $idCommentLast);
     }
     $iMaxIdComment = $aReturn['iMaxIdComment'];
     $oTopicRead = Engine::GetEntity('Topic_TopicRead');
     $oTopicRead->setTopicId($oTopic->getId());
     $oTopicRead->setUserId($this->oUserCurrent->getId());
     $oTopicRead->setCommentCountLast($oTopic->getCountComment());
     $oTopicRead->setCommentIdLast($iMaxIdComment);
     $oTopicRead->setDateRead(date("Y-m-d H:i:s"));
     $this->Topic_SetTopicRead($oTopicRead);
     $aCmts = $aReturn['comments'];
     if ($aCmts and is_array($aCmts)) {
         foreach ($aCmts as $aCmt) {
             $aComments[] = array('html' => $aCmt['html'], 'idParent' => $aCmt['obj']->getPid(), 'id' => $aCmt['obj']->getId());
         }
     }
     $this->Viewer_AssignAjax('iMaxIdComment', $iMaxIdComment);
     $this->Viewer_AssignAjax('aComments', $aComments);
 }
예제 #13
0
 /**
  * Vote for image
  * 
  * @param ModuleUser_EntityUser $oUser
  * @param PluginLsgallery_ModuleImage_EntityImage $oImage
  * @param int $iValue
  * @return int
  */
 public function VoteImage(ModuleUser_EntityUser $oUser, PluginLsgallery_ModuleImage_EntityImage $oImage, $iValue)
 {
     $skill = $oUser->getSkill();
     $iDeltaRating = $iValue;
     if ($skill >= 100 and $skill < 250) {
         $iDeltaRating = $iValue * 2;
     } elseif ($skill >= 250 and $skill < 400) {
         $iDeltaRating = $iValue * 3;
     } elseif ($skill >= 400) {
         $iDeltaRating = $iValue * 4;
     }
     $oImage->setRating($oImage->getRating() + $iDeltaRating);
     /**
      * Начисляем силу и рейтинг автору топика, используя логарифмическое распределение
      */
     $iMinSize = 0.1;
     $iMaxSize = 8;
     $iSizeRange = $iMaxSize - $iMinSize;
     $iMinCount = log(0 + 1);
     $iMaxCount = log(500 + 1);
     $iCountRange = $iMaxCount - $iMinCount;
     if ($iCountRange == 0) {
         $iCountRange = 1;
     }
     if ($skill > 50 and $skill < 200) {
         $skill_new = $skill / 70;
     } elseif ($skill >= 200) {
         $skill_new = $skill / 10;
     } else {
         $skill_new = $skill / 100;
     }
     $iDelta = $iMinSize + (log($skill_new + 1) - $iMinCount) * ($iSizeRange / $iCountRange);
     /**
      * Сохраняем силу и рейтинг
      */
     $oUserImage = $this->User_GetUserById($oImage->getUserId());
     $iSkillNew = $oUserImage->getSkill() + $iValue * $iDelta;
     $iSkillNew = $iSkillNew < 0 ? 0 : $iSkillNew;
     $oUserImage->setSkill($iSkillNew);
     $oUserImage->setRating($oUserImage->getRating() + $iValue * $iDelta / 2.73);
     $this->User_Update($oUserImage);
     return $iDeltaRating;
 }
 /**
  * Изменение состояния подписки
  */
 protected function EventAjaxSubscribeToggle()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     $this->Viewer_SetResponseAjax('json');
     /**
      * Получаем емайл подписки и проверяем его на валидность
      */
     $sMail = getRequestStr('mail');
     if ($this->oUserCurrent) {
         $sMail = $this->oUserCurrent->getMail();
     }
     if (!func_check($sMail, 'mail')) {
         $this->Message_AddError($this->Lang_Get('registration_mail_error'), $this->Lang_Get('error'));
         return;
     }
     /**
      * Получаем тип объекта подписки
      */
     $sTargetType = getRequestStr('target_type');
     if (!$this->Subscribe_IsAllowTargetType($sTargetType)) {
         $this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     $sTargetId = getRequestStr('target_id') ? getRequestStr('target_id') : null;
     $iValue = getRequest('value') ? 1 : 0;
     $oSubscribe = null;
     /**
      * Есть ли доступ к подписке гостям?
      */
     if (!$this->oUserCurrent and !$this->Subscribe_IsAllowTargetForGuest($sTargetType)) {
         $this->Message_AddError($this->Lang_Get('need_authorization'), $this->Lang_Get('error'));
         return;
     }
     /**
      * Проверка объекта подписки
      */
     if (!$this->Subscribe_CheckTarget($sTargetType, $sTargetId, $iValue)) {
         $this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     /**
      * Если подписка еще не существовала, то создаем её
      */
     if ($oSubscribe = $this->Subscribe_AddSubscribeSimple($sTargetType, $sTargetId, $sMail)) {
         $oSubscribe->setStatus($iValue);
         $this->Subscribe_UpdateSubscribe($oSubscribe);
         $this->Message_AddNotice($this->Lang_Get('subscribe_change_ok'), $this->Lang_Get('attention'));
         return;
     }
     $this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
     return;
 }
예제 #15
0
 /**
  * Возвращает список media с учетов прав доступа текущего пользователя
  * В методе происходит проверка на права:
  * 1. разрешаем объекты, которые создал пользователь
  * 2. разрешаем объекты, которые связаны таргетом, к которому у пользователя есть доступ на редактирование
  * @param array $aId
  *
  * @return array
  */
 public function GetAllowMediaItemsById($aId)
 {
     $aIdItems = array();
     foreach ((array) $aId as $iId) {
         $aIdItems[] = (int) $iId;
     }
     $aIdItemsAll = $aIdItems;
     if (is_array($aIdItems) and count($aIdItems)) {
         $iUserId = $this->oUserCurrent ? $this->oUserCurrent->getId() : null;
         $aMediaItems = $this->Media_GetMediaItemsByFilter(array('#where' => array('id in (?a) AND ( user_id is null OR user_id = ?d )' => array($aIdItems, $iUserId)), '#index-from-primary'));
         /**
          * Смотрим что осталось
          */
         if (!is_null($iUserId) and $aIdItems = array_diff($aIdItems, array_keys($aMediaItems))) {
             $aMediaAllowIds = array();
             $aTargetMediaGroup = $this->GetTargetItemsByFilter(array('media_id in' => $aIdItems, '#with' => 'media', '#index-group' => 'media_id'));
             $_this = $this;
             foreach ($aTargetMediaGroup as $iMediaId => $aTargetMedia) {
                 /**
                  * Проверяем каждый таргет
                  */
                 foreach ($aTargetMedia as $oTargetMedia) {
                     if ($this->Cache_Remember("media_check_target_{$oTargetMedia->getTargetType()}_{$oTargetMedia->getTargetId()}", function () use($_this, $oTargetMedia, $iUserId) {
                         if ($oTargetMedia->getTargetId()) {
                             return $_this->CheckTarget($oTargetMedia->getTargetType(), $oTargetMedia->getTargetId(), ModuleMedia::TYPE_CHECK_ALLOW_ADD);
                         }
                         if ($oMedia = $oTargetMedia->getMedia() and $oMedia->getUserId() == $iUserId) {
                             return true;
                         }
                         return false;
                     }, false, array(), 'life', true)) {
                         $aMediaAllowIds[] = $oTargetMedia->getMediaId();
                         break;
                     }
                 }
             }
             if ($aMediaAllowIds) {
                 $aMediaItems = $aMediaItems + $this->GetMediaItemsByFilter(array('id in' => $aMediaAllowIds, '#index-from-primary'));
             }
         }
         /**
          * Нужно отсортировать по первоначальному массиву $aIdItems
          */
         $aReturn = array();
         foreach ($aIdItemsAll as $iId) {
             if (isset($aMediaItems[$iId])) {
                 $aReturn[$iId] = $aMediaItems[$iId];
             }
         }
         return $aReturn;
     }
     return array();
 }
 /**
  * Инициализация
  *
  * @return null
  */
 public function Init()
 {
     /**
      * Проверяем авторизован ли юзер
      */
     if (!$this->User_IsAuthorization()) {
         $this->Message_AddErrorSingle($this->Lang_Get('not_access'));
         return Router::Action('error');
     }
     /**
      * Получаем текущего юзера
      */
     $this->oUserCurrent = $this->User_GetUserCurrent();
     /**
      * Проверяем является ли юзер администратором
      */
     if (!$this->oUserCurrent->isAdministrator()) {
         $this->Message_AddErrorSingle($this->Lang_Get('not_access'));
         return Router::Action('error');
     }
     $this->SetDefaultEvent('report');
 }
예제 #17
0
 /**
  * Расчет рейтинга и силы при гоосовании за пост на форуме
  *
  * @param ModuleUser_EntityUser $oUser	Объект пользователя, который голосует
  * @param PluginForum_ModuleForum_EntityPost $oPost	Объект поста
  * @param int $iValue
  * @return int
  */
 public function VoteForumPost(ModuleUser_EntityUser $oUser, PluginForum_ModuleForum_EntityPost $oPost, $iValue)
 {
     /**
      * Устанавливаем рейтинг поста
      */
     $iDeltaRating = $iValue;
     $oPost->setRating($oPost->getRating() + $iDeltaRating);
     /**
      * Начисляем силу и рейтинг автору топика, используя логарифмическое распределение
      */
     $iMinSize = 0.1;
     $iMaxSize = 8;
     $iSizeRange = $iMaxSize - $iMinSize;
     $iMinCount = log(0 + 1);
     $iMaxCount = log(500 + 1);
     $iCountRange = $iMaxCount - $iMinCount;
     if ($iCountRange == 0) {
         $iCountRange = 1;
     }
     $skill = $oUser->getSkill();
     if ($skill > 50 and $skill < 200) {
         $skill_new = $skill / 70;
     } elseif ($skill >= 200) {
         $skill_new = $skill / 10;
     } else {
         $skill_new = $skill / 100;
     }
     $iDelta = $iMinSize + (log($skill_new + 1) - $iMinCount) * ($iSizeRange / $iCountRange);
     /**
      * Сохраняем силу и рейтинг
      */
     $oUser = $this->User_GetUserById($oPost->getUserId());
     $iSkillNew = $oUser->getSkill() + $iValue * $iDelta;
     $iSkillNew = $iSkillNew < 0 ? 0 : $iSkillNew;
     $oUser->setSkill($iSkillNew);
     $oUser->setRating($oUser->getRating() + $iValue * $iDelta / 2.73);
     $this->User_Update($oUser);
     return $iDeltaRating;
 }
 /**
  * Получение новых комментариев
  *
  */
 protected function AjaxResponseComment()
 {
     $this->Viewer_SetResponseAjax('json');
     if (!$this->oUserCurrent) {
         $this->Message_AddErrorSingle($this->Lang_Get('need_authorization'), $this->Lang_Get('error'));
         return;
     }
     $idImage = getRequest('idTarget', null, 'post');
     if (!($oImage = $this->PluginLsgallery_Image_GetImageById($idImage))) {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     $idCommentLast = getRequest('idCommentLast', null, 'post');
     $selfIdComment = getRequest('selfIdComment', null, 'post');
     $aComments = array();
     if (getRequest('bUsePaging', null, 'post') && $selfIdComment) {
         $oComment = $this->Comment_GetCommentById($selfIdComment);
         if ($oComment && $oComment->getTargetId() == $oImage->getId() && $oComment->getTargetType() == 'image') {
             $oViewerLocal = $this->Viewer_GetLocalViewer();
             $oViewerLocal->Assign('oUserCurrent', $this->oUserCurrent);
             $oViewerLocal->Assign('bOneComment', true);
             $oViewerLocal->Assign('oComment', $oComment);
             $sText = $oViewerLocal->Fetch("comment.tpl");
             $aCmt = array();
             $aCmt[] = array('html' => $sText, 'obj' => $oComment);
         } else {
             $aCmt = array();
         }
         $aReturn['comments'] = $aCmt;
         $aReturn['iMaxIdComment'] = $selfIdComment;
     } else {
         $aReturn = $this->Comment_GetCommentsNewByTargetId($oImage->getId(), 'image', $idCommentLast);
     }
     $iMaxIdComment = $aReturn['iMaxIdComment'];
     $oImageRead = Engine::GetEntity('PluginLsgallery_ModuleImage_EntityImageRead');
     $oImageRead->setImageId($oImage->getId());
     $oImageRead->setUserId($this->oUserCurrent->getId());
     $oImageRead->setCommentCountLast($oImage->getCountComment());
     $oImageRead->setCommentIdLast($iMaxIdComment);
     $oImageRead->setDateRead();
     $this->PluginLsgallery_Image_SetImageRead($oImageRead);
     $aCmts = $aReturn['comments'];
     if ($aCmts and is_array($aCmts)) {
         foreach ($aCmts as $aCmt) {
             $aComments[] = array('html' => $aCmt['html'], 'idParent' => $aCmt['obj']->getPid(), 'id' => $aCmt['obj']->getId());
         }
     }
     $this->Viewer_AssignAjax('iMaxIdComment', $iMaxIdComment);
     $this->Viewer_AssignAjax('aComments', $aComments);
 }
예제 #19
0
 /**
  * Проверка объекта подписки с типом "topic_new_comment"
  * Название метода формируется автоматически
  *
  * @param int $iTargetId    ID владельца
  * @param int $iStatus      Статус
  *
  * @return bool
  */
 public function CheckTargetTopicNewComment($iTargetId, $iStatus)
 {
     if ($oTopic = E::ModuleTopic()->GetTopicById($iTargetId)) {
         /**
          * Топик может быть в закрытом блоге, поэтому необходимо разрешить подписку только если пользователь в нем состоит
          * Отписываться разрешаем с любого топика
          */
         if ($iStatus == 1 && $oTopic->getBlog()->IsPrivate()) {
             if (!$this->oUserCurrent || !($oTopic->getBlog()->getOwnerId() == $this->oUserCurrent->getId() || E::ModuleBlog()->GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(), $this->oUserCurrent->getId()))) {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
예제 #20
0
 /**
  * Проверка объекта подписки с типом "topic_new_comment"
  * Название метода формируется автоматически
  *
  * @param int $iTargetId	ID владельца
  * @param int $iStatus	Статус
  * @return bool
  */
 public function CheckTargetTopicNewComment($iTargetId, $iStatus)
 {
     if ($oTopic = $this->Topic_GetTopicById($iTargetId)) {
         /**
          * Топик может быть в закрытом блоге, поэтому необходимо разрешить подписку только если пользователь в нем состоит, или является автором блога
          * Отписываться разрешаем с любого топика
          */
         if ($iStatus == 1 and $oTopic->getBlog()->getType() == 'close') {
             if (!$this->oUserCurrent or !($oTopic->getBlog()->getOwnerId() == $this->oUserCurrent->getId() or $this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(), $this->oUserCurrent->getId()))) {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
예제 #21
0
 /**
  * Выполняется при завершении работы экшена
  */
 public function EventShutdown()
 {
     if (!$this->oUserProfile) {
         return;
     }
     /**
      * Загружаем в шаблон необходимые переменные
      */
     $iCountTopicFavourite = E::ModuleTopic()->GetCountTopicsFavouriteByUserId($this->oUserProfile->getId());
     $iCountTopicUser = E::ModuleTopic()->GetCountTopicsPersonalByUser($this->oUserProfile->getId(), 1);
     $iCountCommentUser = E::ModuleComment()->GetCountCommentsByUserId($this->oUserProfile->getId(), 'topic');
     $iCountCommentFavourite = E::ModuleComment()->GetCountCommentsFavouriteByUserId($this->oUserProfile->getId());
     $iCountNoteUser = E::ModuleUser()->GetCountUserNotesByUserId($this->oUserProfile->getId());
     // Получим информацию об изображениях пользовтеля
     // И посчитаем общее количество картинок
     /** @var ModuleMresource_EntityMresourceCategory[] $aUserImagesInfo */
     $aUserImagesInfo = E::ModuleMresource()->GetAllImageCategoriesByUserId($this->oUserProfile->getId());
     $iPhotoCount = E::ModuleMresource()->GetCountImagesByUserId($this->oUserProfile->getId());
     E::ModuleViewer()->Assign('oUserProfile', $this->oUserProfile);
     E::ModuleViewer()->Assign('iCountTopicUser', $iCountTopicUser);
     E::ModuleViewer()->Assign('iCountCommentUser', $iCountCommentUser);
     E::ModuleViewer()->Assign('iCountTopicFavourite', $iCountTopicFavourite);
     E::ModuleViewer()->Assign('iCountCommentFavourite', $iCountCommentFavourite);
     E::ModuleViewer()->Assign('iCountNoteUser', $iCountNoteUser);
     E::ModuleViewer()->Assign('iCountWallUser', E::ModuleWall()->GetCountWall(array('wall_user_id' => $this->oUserProfile->getId(), 'pid' => null)));
     E::ModuleViewer()->Assign('oUserImagesInfo', $aUserImagesInfo);
     E::ModuleViewer()->Assign('iPhotoCount', $iPhotoCount);
     /**
      * Общее число публикаций и избранного
      */
     E::ModuleViewer()->Assign('iCountCreated', ($this->oUserCurrent && $this->oUserCurrent->getId() == $this->oUserProfile->getId() ? $iCountNoteUser : 0) + $iCountTopicUser + $iCountCommentUser + $iPhotoCount);
     E::ModuleViewer()->Assign('iCountFavourite', $iCountCommentFavourite + $iCountTopicFavourite);
     /**
      * Заметка текущего пользователя о юзере
      */
     if ($this->oUserCurrent) {
         E::ModuleViewer()->Assign('oUserNote', $this->oUserProfile->getUserNote());
     }
     E::ModuleViewer()->Assign('iCountFriendsUser', E::ModuleUser()->GetCountUsersFriend($this->oUserProfile->getId()));
     E::ModuleViewer()->Assign('sMenuSubItemSelect', $this->sMenuSubItemSelect);
     E::ModuleViewer()->Assign('sMenuHeadItemSelect', $this->sMenuHeadItemSelect);
     E::ModuleViewer()->Assign('USER_FRIEND_NULL', ModuleUser::USER_FRIEND_NULL);
     E::ModuleViewer()->Assign('USER_FRIEND_OFFER', ModuleUser::USER_FRIEND_OFFER);
     E::ModuleViewer()->Assign('USER_FRIEND_ACCEPT', ModuleUser::USER_FRIEND_ACCEPT);
     E::ModuleViewer()->Assign('USER_FRIEND_REJECT', ModuleUser::USER_FRIEND_REJECT);
     E::ModuleViewer()->Assign('USER_FRIEND_DELETE', ModuleUser::USER_FRIEND_DELETE);
 }
 /**
  * Выполняется при завершении работы экшена
  */
 public function EventShutdown()
 {
     if (!$this->oUserProfile) {
         return;
     }
     /**
      * Загружаем в шаблон необходимые переменные
      */
     $iCountTopicFavourite = $this->Topic_GetCountTopicsFavouriteByUserId($this->oUserProfile->getId());
     $iCountTopicUser = $this->Topic_GetCountTopicsPersonalByUser($this->oUserProfile->getId(), 1);
     $iCountCommentUser = $this->Comment_GetCountCommentsByUserId($this->oUserProfile->getId(), 'topic');
     $iCountCommentFavourite = $this->Comment_GetCountCommentsFavouriteByUserId($this->oUserProfile->getId());
     $iCountNoteUser = $this->User_GetCountUserNotesByUserId($this->oUserProfile->getId());
     $this->Viewer_Assign('oUserProfile', $this->oUserProfile);
     $this->Viewer_Assign('iCountTopicUser', $iCountTopicUser);
     $this->Viewer_Assign('iCountCommentUser', $iCountCommentUser);
     $this->Viewer_Assign('iCountTopicFavourite', $iCountTopicFavourite);
     $this->Viewer_Assign('iCountCommentFavourite', $iCountCommentFavourite);
     $this->Viewer_Assign('iCountNoteUser', $iCountNoteUser);
     $this->Viewer_Assign('iCountWallUser', $this->Wall_GetCountWall(array('wall_user_id' => $this->oUserProfile->getId(), 'pid' => null)));
     /**
      * Общее число публикация и избранного
      */
     $this->Viewer_Assign('iCountCreated', (($this->oUserCurrent and $this->oUserCurrent->getId() == $this->oUserProfile->getId()) ? $iCountNoteUser : 0) + $iCountTopicUser + $iCountCommentUser);
     $this->Viewer_Assign('iCountFavourite', $iCountCommentFavourite + $iCountTopicFavourite);
     /**
      * Заметка текущего пользователя о юзере
      */
     if ($this->oUserCurrent) {
         $this->Viewer_Assign('oUserNote', $this->oUserProfile->getUserNote());
     }
     $this->Viewer_Assign('iCountFriendsUser', $this->User_GetCountUsersFriend($this->oUserProfile->getId()));
     $this->Viewer_Assign('sMenuSubItemSelect', $this->sMenuSubItemSelect);
     $this->Viewer_Assign('sMenuHeadItemSelect', $this->sMenuHeadItemSelect);
     $this->Viewer_Assign('sMenuProfileItemSelect', $this->sMenuProfileItemSelect);
     $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);
 }
예제 #23
0
 /**
  * Изменение состояния подписки
  */
 protected function EventAjaxTrackToggle()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     E::ModuleViewer()->SetResponseAjax('json');
     if (!$this->oUserCurrent) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('need_authorization'), E::ModuleLang()->Get('error'));
         return;
     }
     /**
      * Получаем тип объекта подписки
      */
     $sTargetType = F::GetRequestStr('target_type');
     if (!E::ModuleSubscribe()->IsAllowTargetType($sTargetType)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'));
         return;
     }
     $sTargetId = F::GetRequestStr('target_id') ? F::GetRequestStr('target_id') : null;
     $iValue = F::GetRequest('value') ? 1 : 0;
     $oTrack = null;
     /**
      * Проверка объекта подписки
      */
     if (!E::ModuleSubscribe()->CheckTarget($sTargetType, $sTargetId, $iValue)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'));
         return;
     }
     /**
      * Если подписка еще не существовала, то создаем её
      */
     if ($oTrack = E::ModuleSubscribe()->AddTrackSimple($sTargetType, $sTargetId, $this->oUserCurrent->getId())) {
         $oTrack->setStatus($iValue);
         E::ModuleSubscribe()->UpdateTrack($oTrack);
         E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('subscribe_change_ok'), E::ModuleLang()->Get('attention'));
         return;
     }
     E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'));
     return;
 }
예제 #24
0
 /**
  * Выполняется при завершении работы экшена
  */
 public function EventShutdown()
 {
     if (!$this->oUserProfile) {
         return;
     }
     $iProfileUserId = $this->oUserProfile->getId();
     // Get stats of various user publications topics, comments, images, etc. and stats of favourites
     $aProfileStats = E::ModuleUser()->GetUserProfileStats($iProfileUserId);
     // Получим информацию об изображениях пользователя
     /** @var ModuleMresource_EntityMresourceCategory[] $aUserImagesInfo */
     //$aUserImagesInfo = E::ModuleMresource()->GetAllImageCategoriesByUserId($iProfileUserId);
     // * Загружаем в шаблон необходимые переменные
     E::ModuleViewer()->Assign('oUserProfile', $this->oUserProfile);
     E::ModuleViewer()->Assign('aProfileStats', $aProfileStats);
     // unused
     //E::ModuleViewer()->Assign('aUserImagesInfo', $aUserImagesInfo);
     // * Заметка текущего пользователя о юзере
     if (E::User()) {
         E::ModuleViewer()->Assign('oUserNote', $this->oUserProfile->getUserNote());
     }
     E::ModuleViewer()->Assign('sMenuSubItemSelect', $this->sMenuSubItemSelect);
     E::ModuleViewer()->Assign('sMenuHeadItemSelect', $this->sMenuHeadItemSelect);
     E::ModuleViewer()->Assign('USER_FRIEND_NULL', ModuleUser::USER_FRIEND_NULL);
     E::ModuleViewer()->Assign('USER_FRIEND_OFFER', ModuleUser::USER_FRIEND_OFFER);
     E::ModuleViewer()->Assign('USER_FRIEND_ACCEPT', ModuleUser::USER_FRIEND_ACCEPT);
     E::ModuleViewer()->Assign('USER_FRIEND_REJECT', ModuleUser::USER_FRIEND_REJECT);
     E::ModuleViewer()->Assign('USER_FRIEND_DELETE', ModuleUser::USER_FRIEND_DELETE);
     // Old style skin compatibility
     E::ModuleViewer()->Assign('iCountTopicUser', $aProfileStats['count_topics']);
     E::ModuleViewer()->Assign('iCountCommentUser', $aProfileStats['count_comments']);
     E::ModuleViewer()->Assign('iCountTopicFavourite', $aProfileStats['favourite_topics']);
     E::ModuleViewer()->Assign('iCountCommentFavourite', $aProfileStats['favourite_comments']);
     E::ModuleViewer()->Assign('iCountNoteUser', $aProfileStats['count_usernotes']);
     E::ModuleViewer()->Assign('iCountWallUser', $aProfileStats['count_wallrecords']);
     E::ModuleViewer()->Assign('iPhotoCount', $aProfileStats['count_images']);
     E::ModuleViewer()->Assign('iCountCreated', $aProfileStats['count_created']);
     E::ModuleViewer()->Assign('iCountFavourite', $aProfileStats['count_favourites']);
     E::ModuleViewer()->Assign('iCountFriendsUser', $aProfileStats['count_friends']);
 }
 /**
  * Выполняется при завершении работы экшена
  *
  */
 public function EventShutdown()
 {
     $iCountTopicFavourite = $this->Topic_GetCountTopicsFavouriteByUserId($this->oUserCurrent->getId());
     $iCountTopicUser = $this->Topic_GetCountTopicsPersonalByUser($this->oUserCurrent->getId(), 1);
     $iCountCommentUser = $this->Comment_GetCountCommentsByUserId($this->oUserCurrent->getId(), 'topic');
     $iCountCommentFavourite = $this->Comment_GetCountCommentsFavouriteByUserId($this->oUserCurrent->getId());
     $iCountNoteUser = $this->User_GetCountUserNotesByUserId($this->oUserCurrent->getId());
     $this->Viewer_Assign('oUserProfile', $this->oUserCurrent);
     $this->Viewer_Assign('iCountWallUser', $this->Wall_GetCountWall(array('wall_user_id' => $this->oUserCurrent->getId(), 'pid' => null)));
     /**
      * Общее число публикация и избранного
      */
     $this->Viewer_Assign('iCountCreated', $iCountNoteUser + $iCountTopicUser + $iCountCommentUser);
     $this->Viewer_Assign('iCountFavourite', $iCountCommentFavourite + $iCountTopicFavourite);
     $this->Viewer_Assign('iCountFriendsUser', $this->User_GetCountUsersFriend($this->oUserCurrent->getId()));
     /**
      * Загружаем в шаблон необходимые переменные
      */
     $this->Viewer_Assign('sMenuItemSelect', $this->sMenuItemSelect);
     $this->Viewer_Assign('sMenuSubItemSelect', $this->sMenuSubItemSelect);
     $this->Hook_Run('action_shutdown_settings');
 }
예제 #26
0
 /**
  * Выводит список комментариев которые написал юзер
  * Перенаправляет на профиль пользователя
  *
  */
 protected function EventComments()
 {
     /**
      * Получаем логин из УРЛа
      */
     $sUserLogin = $this->sCurrentEvent;
     /**
      * Проверяем есть ли такой юзер
      */
     if (!($this->oUserProfile = E::ModuleUser()->GetUserByLogin($sUserLogin))) {
         return parent::EventNotFound();
     }
     /**
      * Передан ли номер страницы
      */
     $iPage = $this->GetParamEventMatch(1, 2) ? $this->GetParamEventMatch(1, 2) : 1;
     /**
      * Выполняем редирект на новый URL, в новых версиях LS экшен "my" будет удален
      */
     $sPage = $iPage == 1 ? '' : "page{$iPage}/";
     R::Location($this->oUserProfile->getUserWebPath() . 'created/comments/' . $sPage);
 }
예제 #27
0
 /**
  * Добавление записи на стену
  */
 public function EventWallAdd()
 {
     $this->Viewer_SetResponseAjax('json');
     if (!$this->oUserCurrent) {
         return $this->EventErrorDebug();
     }
     if (!$this->WallCheckUserProfile()) {
         return $this->EventErrorDebug();
     }
     // Создаем запись
     $oWall = Engine::GetEntity('Wall');
     $oWall->_setValidateScenario('add');
     $oWall->setWallUserId($this->oUserProfile->getId());
     $oWall->setUserId($this->oUserCurrent->getId());
     $oWall->setText(getRequestStr('text'));
     $oWall->setPid(getRequestStr('pid'));
     $this->Hook_Run('wall_add_validate_before', array('oWall' => $oWall));
     if ($oWall->_Validate()) {
         // Экранируем текст и добавляем запись в БД
         $oWall->setText($this->Text_Parser($oWall->getText()));
         $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->Wall_SendNotifyWallNew($oWall, $this->oUserCurrent);
             }
             if ($oWallParent = $oWall->GetPidWall() and $oWallParent->getUserId() != $oWall->getUserId()) {
                 $this->Wall_SendNotifyWallReply($oWallParent, $oWall, $this->oUserCurrent);
             }
             // Добавляем событие в ленту
             $this->Stream_Write($oWall->getUserId(), 'add_wall', $oWall->getId());
         } else {
             $this->Message_AddError($this->Lang_Get('common.error.add'), $this->Lang_Get('common.error.error'));
         }
     } else {
         $this->Message_AddError($oWall->_getValidateError(), $this->Lang_Get('common.error.error'));
     }
 }
예제 #28
0
 /**
  * Возвращает список опросов для объекта
  *
  * @param string $sTargetType
  * @param string $sTargetId
  *
  * @return mixed
  */
 public function GetPollItemsByTarget($sTargetType, $sTargetId)
 {
     $aFilter = array('target_type' => $sTargetType, 'target_id' => $sTargetId, '#with' => array('answers'));
     if ($this->oUserCurrent) {
         $aFilter['#with']['vote_current'] = array('user_id' => $this->oUserCurrent->getId(), '#value-default' => false);
     } else {
         $_this = $this;
         $aFilter['#with']['vote_current'] = array('#value-default' => false, '#callback-filter' => function ($aPollItems, &$aRelationFilter) use($_this) {
             $aWhere = array();
             $aWhereBind = array();
             foreach ($aPollItems as $oPoll) {
                 /**
                  * Смотрим по IP
                  */
                 if ($oPoll->getIsGuestCheckIp()) {
                     $aWhere[] = ' ( t.poll_id = ?d and t.ip = ? ) ';
                     $aWhereBind[] = $oPoll->getId();
                     $aWhereBind[] = func_getIp();
                 }
                 /**
                  * Смотрим в куках
                  */
                 if ($sKey = $_this->Session_GetCookie($_this->GetCookieVoteName($oPoll->getId()))) {
                     $aWhere[] = ' ( t.poll_id = ?d and t.guest_key = ? ) ';
                     $aWhereBind[] = $oPoll->getId();
                     $aWhereBind[] = $sKey;
                 }
             }
             if ($aWhere) {
                 $aRelationFilter['#where'] = array(' ( ' . join(' or ', $aWhere) . ' ) ' => $aWhereBind);
             } else {
                 $aRelationFilter['#value-set'] = false;
             }
         });
     }
     $aPollItems = $this->Poll_GetPollItemsByFilter($aFilter);
     return $aPollItems;
 }
예제 #29
0
 /**
  * Отписка от пользователя
  *
  */
 protected function EventUnsubscribe()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     E::ModuleViewer()->SetResponseAjax('json');
     /**
      * Пользователь авторизован?
      */
     if (!$this->oUserCurrent) {
         parent::EventNotFound();
     }
     /**
      * Пользователь с таким ID существует?
      */
     if (!E::ModuleUser()->GetUserById(F::GetRequestStr('id'))) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'));
     }
     /**
      * Отписываем
      */
     E::ModuleStream()->UnsubscribeUser($this->oUserCurrent->getId(), F::GetRequestStr('id'));
     E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('stream_subscribes_updated'), E::ModuleLang()->Get('attention'));
 }
 /**
  * Отписка от пользователя
  *
  */
 protected function EventUnsubscribe()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     $this->Viewer_SetResponseAjax('json');
     /**
      * Пользователь авторизован?
      */
     if (!$this->oUserCurrent) {
         parent::EventNotFound();
     }
     /**
      * Пользователь с таким ID существует?
      */
     if (!$this->User_getUserById(getRequestStr('id'))) {
         $this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
     }
     /**
      * Отписываем
      */
     $this->Stream_unsubscribeUser($this->oUserCurrent->getId(), getRequestStr('id'));
     $this->Message_AddNotice($this->Lang_Get('stream_subscribes_updated'), $this->Lang_Get('attention'));
 }