/**
  * @return array
  */
 public function GetTopicsFilter()
 {
     $aFilter = parent::GetTopicsFilter();
     if (R::GetAction() == 'index' && R::GetActionEvent() == 'sandbox') {
         $aFilter['topic_status'] = TOPIC_STATUS_SANDBOX;
     } elseif (!(R::GetAction() == 'content' && R::GetActionEvent() == 'drafts')) {
         $aFilter['topic_status_not'] = TOPIC_STATUS_SANDBOX;
     }
     return $aFilter;
 }
Example #2
0
 /**
  * Обработка хука инициализации экшенов
  */
 public function InitAction()
 {
     // * Проверяем наличие директории install
     if (is_dir(rtrim(Config::Get('path.root.dir'), '/') . '/install') && (!isset($_SERVER['HTTP_APP_ENV']) || $_SERVER['HTTP_APP_ENV'] != 'test')) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('install_directory_exists'));
         R::Action('error');
     }
     // * Проверка на закрытый режим
     $oUserCurrent = E::ModuleUser()->GetUserCurrent();
     if (!$oUserCurrent && Config::Get('general.close.mode')) {
         $aEnabledActions = F::Str2Array(Config::Get('general.close.actions'));
         if (!in_array(R::GetAction(), $aEnabledActions)) {
             return R::Action('login');
         }
     }
     return null;
 }
Example #3
0
 /**
  * Обновляет топик
  *
  * @param ModuleTopic_EntityTopic $oTopic    Объект топика
  *
  * @return bool
  */
 public function UpdateTopic($oTopic)
 {
     // * Получаем топик ДО изменения
     $oTopicOld = $this->GetTopicById($oTopic->getId());
     $oTopic->setDateEdit(F::Now());
     if ($this->oMapper->UpdateTopic($oTopic)) {
         // * Если топик изменил видимость (publish) или локацию (BlogId) или список тегов
         if ($oTopicOld && ($oTopic->getPublish() != $oTopicOld->getPublish() || $oTopic->getBlogId() != $oTopicOld->getBlogId() || $oTopic->getTags() != $oTopicOld->getTags())) {
             // * Обновляем теги
             $this->DeleteTopicTagsByTopicId($oTopic->getId());
             if ($oTopic->getPublish() && $oTopic->getTags()) {
                 $aTags = explode(',', $oTopic->getTags());
                 foreach ($aTags as $sTag) {
                     /** @var ModuleTopic_EntityTopicTag $oTag */
                     $oTag = E::GetEntity('Topic_TopicTag');
                     $oTag->setTopicId($oTopic->getId());
                     $oTag->setUserId($oTopic->getUserId());
                     $oTag->setBlogId($oTopic->getBlogId());
                     $oTag->setText($sTag);
                     $this->AddTopicTag($oTag);
                 }
             }
         }
         if ($oTopicOld && $oTopic->getPublish() != $oTopicOld->getPublish()) {
             // * Обновляем избранное
             $this->SetFavouriteTopicPublish($oTopic->getId(), $oTopic->getPublish());
             // * Удаляем комментарий топика из прямого эфира
             if ($oTopic->getPublish() == 0) {
                 E::ModuleComment()->DeleteCommentOnlineByTargetId($oTopic->getId(), 'topic');
             }
             // * Изменяем видимость комментов
             E::ModuleComment()->SetCommentsPublish($oTopic->getId(), 'topic', $oTopic->getPublish());
         }
         if (R::GetAction() == 'content') {
             $this->processTopicFields($oTopic, 'update');
         }
         $this->UpdateMresources($oTopic);
         // чистим зависимые кеши
         E::ModuleCache()->CleanByTags(array('topic_update', "topic_update_user_{$oTopic->getUserId()}"));
         E::ModuleCache()->Delete("topic_{$oTopic->getId()}");
         return true;
     }
     return false;
 }
Example #4
0
 /**
  * Вызывается по строке "topic_kind"
  * @param $sTopicType
  * @internal param $iParam
  * @internal param $sParamData
  * @return bool
  */
 public function TopicKind($sTopicType)
 {
     if (R::GetAction() != 'index') {
         return false;
     }
     if (is_null(R::GetActionEvent())) {
         return 'good' == $sTopicType;
     }
     return R::GetActionEvent() == $sTopicType;
 }
Example #5
0
 /**
  * Обрабатываем процесс разлогинивания
  *
  */
 protected function EventExit()
 {
     E::ModuleSecurity()->ValidateSendForm();
     E::ModuleUser()->Logout();
     $iShowTime = Config::Val('module.user.logout.show_exit', 3);
     $sRedirect = Config::Get('module.user.logout.redirect');
     if (!$sRedirect) {
         if (isset($_SERVER['HTTP_REFERER']) && F::File_IsLocalUrl($_SERVER['HTTP_REFERER'])) {
             $sRedirect = $_SERVER['HTTP_REFERER'];
         }
     }
     /**
      * issue #104, {@see https://github.com/altocms/altocms/issues/104}
      * Установим в lgp (last_good_page) хэш имени страницы с постфиксом "logout". Такая
      * кука будет означать, что на этой странице пользователь вышел с сайта. Время 60 -
      * заранее достаточное время, что бы произошел редирект на страницу HTTP_REFERER. Если
      * же эта страница выпадет в 404 то в экшене ActionError уйдем на главную, поскольку
      * эта страница недоступна стала после выхода с сайта, а до этого была вполне ничего.
      */
     if ($iShowTime) {
         $sUrl = F::RealUrl($sRedirect);
         $sReferrer = Config::Get('path.root.web') . R::GetAction() . "/" . R::GetActionEvent() . '/?security_key=' . F::GetRequest('security_key', '');
         E::ModuleSession()->SetCookie('lgp', md5($sReferrer . 'logout'), 60);
         E::ModuleViewer()->SetHtmlHeadTag('meta', array('http-equiv' => 'Refresh', 'Content' => $iShowTime . '; url=' . $sUrl));
     } elseif ($sRedirect) {
         // Если установлена пользовтаельская страница выхода, то считаем,
         // что она без ошибки и смело не нее редиректим, в других случаях
         // возможна 404
         if (!Config::Get('module.user.logout.redirect')) {
             E::ModuleSession()->SetCookie('lgp', md5(F::RealUrl($sRedirect) . 'logout'), 60);
         }
         R::Location($sRedirect);
         exit;
     } else {
         // E::ModuleViewer()->Assign('bRefreshToHome', true);
         // Время показа страницы выхода не задано, поэтому просто редирект
         R::Location(Config::Get('path.root.web'));
         exit;
     }
 }
Example #6
0
 protected function _saveMode($nParam = 0, $sData)
 {
     $sKey = R::GetAction() . '.' . R::GetActionEvent() . '.' . $nParam;
     E::ModuleSession()->Set($sKey, $sData);
 }
Example #7
0
 /**
  * Вызывается по строке "topic_kind"
  *
  * @param $sTopicType
  *
  * @internal param $iParam
  * @internal param $sParamData
  *
  * @return bool
  */
 public function TopicKind($sTopicType)
 {
     $sViewTopicFilter = E::ModuleViewer()->getTemplateVars('sTopicFilter');
     if ($sViewTopicFilter && $sViewTopicFilter == $sTopicType) {
         return true;
     }
     if (R::GetAction() != 'index') {
         return false;
     }
     if (is_null(R::GetActionEvent())) {
         return 'good' == $sTopicType;
     }
     return R::GetActionEvent() == $sTopicType;
 }