/**
  * @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;
 }
示例#2
0
 /**
  * Инициализация
  *
  */
 public function Init()
 {
     // * Проверяем авторизован ли юзер
     if (!E::ModuleUser()->IsAuthorization() && R::GetActionEvent() !== 'go' && R::GetActionEvent() !== 'photo') {
         return parent::EventNotFound();
     }
     $this->oUserCurrent = E::ModuleUser()->GetUserCurrent();
     // * Устанавливаем дефолтный эвент
     $this->SetDefaultEvent('add');
     // * Загружаем в шаблон JS текстовки
     E::ModuleLang()->AddLangJs(array('topic_photoset_photo_delete', 'topic_photoset_mark_as_preview', 'topic_photoset_photo_delete_confirm', 'topic_photoset_is_preview', 'topic_photoset_upload_choose'));
     $this->aBlogTypes = $this->_getAllowBlogTypes();
 }
 /**
  * Инициализация
  *
  */
 public function Init()
 {
     //  Проверяем аторизован ли юзер
     if (E::ModuleUser()->IsAuthorization()) {
         E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('registration_is_authorization'), E::ModuleLang()->Get('attention'));
         return R::Action('error');
     }
     //  Если включены инвайты то перенаправляем на страницу регистрации по инвайтам
     if (!E::ModuleUser()->IsAuthorization() && Config::Get('general.reg.invite') && !in_array(R::GetActionEvent(), array('invite', 'activate', 'confirm')) && !$this->CheckInviteRegister()) {
         return R::Action('registration', 'invite');
     }
     $this->SetDefaultEvent('index');
     //  Устанавливаем title страницы
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('registration'));
 }
示例#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;
 }
示例#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;
     }
 }
示例#6
0
 /**
  * Обработка основного события
  *
  */
 public function EventIndex()
 {
     $sEvent = R::GetActionEvent();
     if ((!$sEvent || $sEvent == 'index') && F::GetRequestStr('q', null, 'get')) {
         $sEvent = 'topics';
     }
     if ($sEvent == 'comments') {
         return $this->EventComments();
     } elseif ($sEvent == 'blogs') {
         return $this->EventBlogs();
     } elseif ($sEvent == 'topics') {
         return $this->EventTopics();
     } else {
         $this->SetTemplateAction('index');
     }
 }
示例#7
0
 protected function CheckFieldsField($oContentType = null)
 {
     E::ModuleSecurity()->ValidateSendForm();
     $bOk = true;
     if (!F::CheckVal(F::GetRequest('field_name', null, 'post'), 'text', 2, 100)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.contenttypes_field_name_error'), E::ModuleLang()->Get('error'));
         $bOk = false;
     }
     if (!F::CheckVal(F::GetRequest('field_description', null, 'post'), 'text', 2, 200)) {
         E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.contenttypes_field_description_error'), E::ModuleLang()->Get('error'));
         $bOk = false;
     }
     if (R::GetActionEvent() == 'fieldadd') {
         if ($oContentType == 'photoset' && (F::GetRequest('field_type', null, 'post') == 'photoset' || $oContentType->isPhotosetEnable())) {
             E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'));
             $bOk = false;
         }
         if (!in_array(F::GetRequest('field_type', null, 'post'), E::ModuleTopic()->GetAvailableFieldTypes())) {
             E::ModuleMessage()->AddError(E::ModuleLang()->Get('action.admin.contenttypes_field_type_error'), E::ModuleLang()->Get('error'));
             $bOk = false;
         }
     }
     // * Выполнение хуков
     E::ModuleHook()->Run('check_admin_content_fields', array('bOk' => &$bOk));
     return $bOk;
 }
示例#8
0
 /**
  * Запускает евент на выполнение
  * Если текущий евент не определен то  запускается тот которые определен по умолчанию (default event)
  *
  * @return mixed
  */
 public function ExecEvent()
 {
     if ($this->GetDefaultEvent() == 'index' && method_exists($this, 'EventIndex')) {
         $this->AddEvent('index', 'EventIndex');
     }
     $this->sCurrentEvent = R::GetActionEvent();
     if ($this->sCurrentEvent == null) {
         $this->sCurrentEvent = $this->GetDefaultEvent();
         R::SetActionEvent($this->sCurrentEvent);
     }
     $this->aCurrentEventHandler = $this->_getEventHandler();
     if ($this->aCurrentEventHandler !== false) {
         $this->sCurrentEventName = $this->aCurrentEventHandler['name'];
         if ($this->Access(R::GetActionEvent())) {
             $sMethod = $this->aCurrentEventHandler['method'];
             $sHook = 'action_event_' . strtolower($this->sCurrentAction);
             E::ModuleHook()->Run($sHook . '_before', array('event' => $this->sCurrentEvent, 'params' => $this->GetParams()));
             $xResult = $this->{$sMethod}();
             E::ModuleHook()->Run($sHook . '_after', array('event' => $this->sCurrentEvent, 'params' => $this->GetParams()));
             return $xResult;
         } else {
             return $this->AccessDenied(R::GetActionEvent());
             //return null;
         }
     }
     return $this->EventNotFound();
 }
示例#9
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;
 }
示例#10
0
 /**
  * Обработка основного события
  *
  */
 public function EventIndex()
 {
     $sEvent = R::GetActionEvent();
     if ($sEvent == 'comments') {
         return $this->EventComments();
     } elseif ($sEvent == 'blogs') {
         return $this->EventBlogs();
     } elseif ($sEvent == 'topics') {
         return $this->EventTopics();
     } else {
         $this->SetTemplateAction('index');
     }
 }
示例#11
0
 /**
  * Запускает евент на выполнение
  * Если текущий евент не определен то  запускается тот которые определен по умолчанию(default event)
  *
  * @return mixed
  */
 public function ExecEvent()
 {
     if ($this->GetDefaultEvent() == 'index' && method_exists($this, 'EventIndex')) {
         $this->AddEvent('index', 'EventIndex');
     }
     $this->sCurrentEvent = R::GetActionEvent();
     if ($this->sCurrentEvent == null) {
         $this->sCurrentEvent = $this->GetDefaultEvent();
         R::SetActionEvent($this->sCurrentEvent);
     }
     foreach ($this->aRegisterEvent as $aEvent) {
         if (preg_match($aEvent['preg'], $this->sCurrentEvent, $aMatch)) {
             $this->aParamsEventMatch['event'] = $aMatch;
             $this->aParamsEventMatch['params'] = array();
             foreach ($aEvent['params_preg'] as $iKey => $sParamPreg) {
                 if (preg_match($sParamPreg, $this->GetParam($iKey, ''), $aMatch)) {
                     $this->aParamsEventMatch['params'][$iKey] = $aMatch;
                 } else {
                     continue 2;
                 }
             }
             $this->sCurrentEventName = $aEvent['name'];
             $sMethod = $aEvent['method'];
             $sHook = 'action_event_' . strtolower($this->sCurrentAction);
             E::ModuleHook()->Run($sHook . '_before', array('event' => $this->sCurrentEvent, 'params' => $this->GetParams()));
             //$result = call_user_func_array(array($this, $aEvent['method']), array());
             $xResult = $this->{$sMethod}();
             E::ModuleHook()->Run($sHook . '_after', array('event' => $this->sCurrentEvent, 'params' => $this->GetParams()));
             return $xResult;
         }
     }
     return $this->EventNotFound();
 }
示例#12
0
 public function Init()
 {
     parent::Init();
     $sRequestMethod = $this->_getRequestMethod();
     $sResource = R::GetActionEvent();
     $aUriParams = R::GetParams();
     if ($aUriParams) {
         $sUri = $sResource . '/' . join('/', $aUriParams);
     } else {
         $sUri = $sResource;
     }
     if (isset($this->aResources[$sRequestMethod][$sResource][$sUri])) {
         $this->bRestApi = true;
     }
 }