/**
  * Получение токена в админке
  */
 protected function EventGetAccessToken()
 {
     if (!LS::Adm()) {
         return parent::EventNotFound();
     }
     $this->SetTemplateAction('access_token');
 }
Example #2
0
 public static function getInstance()
 {
     if (isset(self::$oInstance) && self::$oInstance instanceof self) {
         return self::$oInstance;
     } else {
         self::$oInstance = new self();
         return self::$oInstance;
     }
 }
Example #3
0
 /**
  * Добавляем чекбокс для публикации в группу
  */
 public function AddCheckBox($aA)
 {
     if (LS::Adm()) {
         if ($iTopicId = Router::GetParam(0)) {
             $oTopic = $this->Topic_GetTopicById($iTopicId);
             if ($oTopic) {
                 $this->Viewer_Assign('sVkPostId', $oTopic->getExtraValue('vk_post_id'));
             }
         }
         return $this->Viewer_Fetch(Plugin::GetTemplatePath(__CLASS__) . 'field.checkbox.tpl');
     }
     return null;
 }
 public function Exec()
 {
     /**
      * Получаем список форумов, открытых для пользователя
      */
     $aForumsId = $this->PluginForum_Forum_GetOpenForumsUser(LS::CurUsr(), true);
     /**
      * Получаем последние топики
      */
     if ($aForumsId) {
         $aLastTopics = $this->PluginForum_Forum_GetTopicItemsAll(array('#where' => array('forum_id IN (?a)' => array($aForumsId)), '#order' => array('last_post_id' => 'desc'), '#page' => array(1, Config::Get('block.stream.row'))));
         if (!empty($aLastTopics['collection'])) {
             $this->Viewer_Assign('aLastTopics', $aLastTopics['collection']);
         }
     }
 }
Example #5
0
 /**
  * Выполняет загрузку необходимый(возможно даже системный :)) переменных в шалон
  *
  */
 public function VarAssign()
 {
     /**
      * Загружаем весь $_REQUEST, предварительно обработав его функцией func_htmlspecialchars()
      */
     $aRequest = $_REQUEST;
     func_htmlspecialchars($aRequest);
     $this->Assign("_aRequest", $aRequest);
     /**
      * Параметры стандартной сессии
      */
     $this->Assign("_sPhpSessionName", session_name());
     $this->Assign("_sPhpSessionId", session_id());
     /** 
      * Short Engine aliases
      */
     $this->Assign("LS", LS::getInstance());
     /** 
      * Загружаем объект доступа к конфигурации 
      */
     $this->Assign("oConfig", Config::getInstance());
     /**
      * Загружаем роутинг с учетом правил rewrite
      */
     $aRouter = array();
     $aPages = Config::Get('router.page');
     if (!$aPages or !is_array($aPages)) {
         throw new Exception('Router rules is underfined.');
     }
     foreach ($aPages as $sPage => $aAction) {
         $aRouter[$sPage] = Router::GetPath($sPage);
     }
     $this->Assign("aRouter", $aRouter);
     /**
      * Загружаем в шаблон блоки
      */
     $this->Assign("aBlocks", $this->aBlocks);
     /**
      * Загружаем HTML заголовки
      */
     $this->Assign("sHtmlTitle", htmlspecialchars($this->sHtmlTitle));
     $this->Assign("sHtmlKeywords", htmlspecialchars($this->sHtmlKeywords));
     $this->Assign("sHtmlDescription", htmlspecialchars($this->sHtmlDescription));
     $this->Assign("aHtmlHeadFiles", $this->aHtmlHeadFiles);
     $this->Assign("aHtmlRssAlternate", $this->aHtmlRssAlternate);
     /**
      * Загружаем список активных плагинов
      */
     $aPlugins = $this->oEngine->GetPlugins();
     $this->Assign("aPluginActive", array_fill_keys(array_keys($aPlugins), true));
     /**
      * Загружаем пути до шаблонов плагинов
      */
     $aTemplateWebPathPlugin = array();
     $aTemplatePathPlugin = array();
     foreach ($aPlugins as $k => $oPlugin) {
         $aTemplateWebPathPlugin[$k] = Plugin::GetTemplateWebPath(get_class($oPlugin));
         $aTemplatePathPlugin[$k] = Plugin::GetTemplatePath(get_class($oPlugin));
     }
     $this->Assign("aTemplateWebPathPlugin", $aTemplateWebPathPlugin);
     $this->Assign("aTemplatePathPlugin", $aTemplatePathPlugin);
 }
Example #6
0
 /**
  * Формируем права доступа
  *
  * @param	object	$oForum
  * @return	object
  */
 public function BuildPerms($oForum, $bNoModers = false)
 {
     $oUser = $this->User_GetUserCurrent();
     $oParent = $oForum->getParentId() ? $this->BuildPerms($oForum->getParent(), true) : null;
     /**
      * Права модератора
      */
     if (!$bNoModers) {
         $sId = $oUser ? $oUser->getId() : 0;
         $oModerator = $this->PluginForum_Forum_GetModeratorByUserIdAndForumId($sId, $oForum->getId());
         $oForum->setIsModerator(LS::Adm() || $oModerator);
         $oForum->setModViewIP(LS::Adm() || $oModerator && $oModerator->getViewIp());
         $oForum->setModDeletePost(LS::Adm() || $oModerator && $oModerator->getAllowDeletePost());
         $oForum->setModDeleteTopic(LS::Adm() || $oModerator && $oModerator->getAllowDeleteTopic());
         $oForum->setModMovePost(LS::Adm() || $oModerator && $oModerator->getAllowMovePost());
         $oForum->setModMoveTopic(LS::Adm() || $oModerator && $oModerator->getAllowMoveTopic());
         $oForum->setModOpencloseTopic(LS::Adm() || $oModerator && $oModerator->getAllowOpencloseTopic());
         $oForum->setModPinTopic(LS::Adm() || $oModerator && $oModerator->getAllowPinTopic());
     }
     $aPermissions = unserialize(stripslashes($oForum->getPermissions()));
     $oForum->setAllowShow(forum_check_perms($aPermissions['show_perms'], $oUser, true));
     $oForum->setAllowRead(forum_check_perms($aPermissions['read_perms'], $oUser, true));
     $oForum->setAllowReply(forum_check_perms($aPermissions['reply_perms'], $oUser));
     $oForum->setAllowStart(forum_check_perms($aPermissions['start_perms'], $oUser));
     /**
      * Авторизован ли текущий пользователь в данном форуме, при условии что форум запоролен
      */
     $oForum->setAutorization($this->isForumAuthorization($oForum));
     /**
      * Если у нас нет прав для просмотра родителя данного форума, запрещаем просмотр
      */
     if ($oParent && !$oParent->getAllowShow()) {
         $oForum->setAllowShow($oParent->getAllowShow());
     }
     return $oForum;
 }
Example #7
0
 public function VarAssign()
 {
     parent::VarAssign();
     // В Alto CMS по умолчанию используется Smarty-переменная $aWidgets
     $this->Assign('aBlocks', $this->GetBlocks(true));
     // В Smarty 3.x рекомендуется использовать статический класс Config
     $this->Assign('oConfig', Config::getInstance());
     // * Short Engine aliases
     $this->Assign('LS', LS::getInstance());
 }
 /**
  * Выполняет загрузку необходимых (возможно даже системных :)) переменных в шаблон
  *
  */
 public function VarAssign()
 {
     /**
      * Загружаем весь $_REQUEST, предварительно обработав его функцией func_htmlspecialchars()
      */
     $aRequest = $_REQUEST;
     func_htmlspecialchars($aRequest);
     $this->Assign("_aRequest", $aRequest);
     /**
      * Параметры стандартной сессии
      */
     $this->Assign("_sPhpSessionName", session_name());
     $this->Assign("_sPhpSessionId", session_id());
     /**
      * Short Engine aliases
      */
     $this->Assign("LS", LS::getInstance());
     /**
      * Загружаем объект доступа к конфигурации
      */
     $this->Assign("oConfig", Config::getInstance());
     /**
      * Загружаем роутинг с учетом правил rewrite
      */
     $aRouter = array();
     if ($aPages = Config::Get('router.page')) {
         foreach ($aPages as $sPage => $aAction) {
             $aRouter[$sPage] = Router::GetPath($sPage);
         }
     }
     $this->Assign("aRouter", $aRouter);
     /**
      * Загружаем в шаблон блоки
      */
     $this->Assign("aBlocks", $this->aBlocks);
     /**
      * Загружаем в шаблон JS переменные
      */
     $this->Assign("aVarsJs", $this->aVarsJs);
     /**
      * Загружаем HTML заголовки
      */
     $this->Assign("sHtmlTitle", htmlspecialchars($this->GetHtmlTitle(Config::Get('view.title_sort_reverse'))));
     $this->Assign("sHtmlKeywords", htmlspecialchars($this->sHtmlKeywords));
     $this->Assign("sHtmlDescription", htmlspecialchars($this->sHtmlDescription));
     $this->Assign("aHtmlHeadFiles", $this->aHtmlHeadFiles);
     $this->Assign("aHtmlRssAlternate", $this->aHtmlRssAlternate);
     $this->Assign("sHtmlCanonical", func_urlspecialchars($this->sHtmlCanonical));
     $this->Assign("sHtmlRobots", $this->sHtmlRobots);
     /**
      * Загружаем список активных плагинов
      */
     $aPlugins = Engine::getInstance()->GetPlugins();
     $this->Assign("aPluginActive", array_fill_keys(array_keys($aPlugins), true));
     /**
      * Загружаем пути до шаблонов плагинов
      */
     $aTemplateWebPathPlugin = array();
     $aTemplatePathPlugin = array();
     foreach ($aPlugins as $k => $oPlugin) {
         $aTemplateWebPathPlugin[$k] = Plugin::GetTemplateWebPath(get_class($oPlugin));
         $aTemplatePathPlugin[$k] = Plugin::GetTemplatePath(get_class($oPlugin));
     }
     $this->Assign("aTemplateWebPathPlugin", $aTemplateWebPathPlugin);
     $this->Assign("aTemplatePathPlugin", $aTemplatePathPlugin);
     /**
      * Загружаем security-ключ
      */
     $this->Assign("LIVESTREET_SECURITY_KEY", $this->Security_GetSecurityKey());
 }
 /**
  * Админка
  */
 public function EventAdmin()
 {
     if (!LS::Adm()) {
         return parent::EventNotFound();
     }
     $this->sMenuItemSelect = 'admin';
     $this->_addTitle($this->Lang_Get('plugin.forum.acp'));
     /**
      * Подключаем CSS
      */
     $this->Viewer_AppendStyle(Plugin::GetTemplatePath(__CLASS__) . 'css/admin.css');
     /**
      * Подключаем JS
      */
     $this->Viewer_AppendScript(Plugin::GetWebPath(__CLASS__) . 'templates/framework/js/forum.admin.js');
     $sCategory = $this->GetParam(0);
     $sAction = $this->GetParam(1);
     /**
      * Раздел админки
      */
     switch ($sCategory) {
         /**
          * Управление форумами
          */
         case 'forums':
             /**
              * Раздел
              */
             switch ($sAction) {
                 /**
                  * Новый форум
                  */
                 case 'new':
                     $this->_adminForumForm('new');
                     break;
                     /**
                      * Редактирование форума
                      */
                 /**
                  * Редактирование форума
                  */
                 case 'edit':
                     $this->_adminForumForm('edit');
                     break;
                     /**
                      * Удаление форума
                      */
                 /**
                  * Удаление форума
                  */
                 case 'delete':
                     $this->_adminForumDelete();
                     break;
                     /**
                      * Изменение сортировки
                      */
                 /**
                  * Изменение сортировки
                  */
                 case 'sort':
                     $this->_adminForumSort();
                     break;
                     /**
                      * Права доступа
                      */
                 /**
                  * Права доступа
                  */
                 case 'perms':
                     $this->_adminForumPerms();
                     break;
                     /**
                      * Пересчет счетчиков
                      */
                 /**
                  * Пересчет счетчиков
                  */
                 case 'refresh':
                     $this->_adminForumRefresh();
                     break;
                     /**
                      * Список форумов
                      */
                 /**
                  * Список форумов
                  */
                 case null:
                     $this->_adminForums();
                     break;
                 default:
                     return parent::EventNotFound();
             }
             $this->sMenuSubItemSelect = 'forums';
             break;
             /**
              * Пользователи
              */
         /**
          * Пользователи
          */
         case 'users':
             $this->_adminUsers();
             break;
             /**
              * Права доступа
              */
         /**
          * Права доступа
          */
         case 'perms':
             $this->_adminPerms();
             break;
             /**
              * Файлы
              */
         /**
          * Файлы
          */
         case 'files':
             $this->_adminFiles();
             break;
             /**
              * Главная
              */
         /**
          * Главная
          */
         case null:
             $this->_adminMain();
             break;
         default:
             return parent::EventNotFound();
     }
 }
 /**
  * Вывод RSS последних записей с форума
  */
 protected function RssForumStream()
 {
     /**
      * Получаем список форумов
      */
     $aForumsId = $this->PluginForum_Forum_GetOpenForumsUser(LS::CurUsr(), true);
     /**
      * Получаем последние топики
      */
     $aResult = $this->PluginForum_Forum_GetTopicItemsAll(array('#where' => array('forum_id IN (?a)' => array($aForumsId)), '#order' => array('last_post_id' => 'desc'), '#page' => array(1, 30)));
     $aTopics = $aResult['collection'];
     /**
      * Формируем данные канала RSS
      */
     $aChannel['title'] = Config::Get('view.name');
     $aChannel['link'] = Config::Get('path.root.web');
     $aChannel['description'] = Config::Get('path.root.web') . ' / RSS channel';
     $aChannel['language'] = 'ru';
     $aChannel['managingEditor'] = Config::Get('general.rss_editor_mail');
     $aChannel['generator'] = Config::Get('path.root.web');
     /**
      * Формируем записи RSS
      */
     $aItems = array();
     foreach ($aTopics as $oTopic) {
         /**
          * Relation data
          */
         $oPost = $oTopic->getPost();
         $oUser = $oPost->getUser();
         /**
          * Build record
          */
         $aItem = array('title' => 'Latest topics: ' . $oTopic->getTitle(), 'guid' => $oTopic->getUrlFull() . '#post-' . $oPost->getId(), 'link' => $oTopic->getUrlFull() . '#post-' . $oPost->getId(), 'description' => $this->getPostText($oPost), 'pubDate' => $oPost->getDateAdd(), 'category' => 'topics');
         if ($oUser) {
             $aItem['author'] = $oUser->getLogin();
         } else {
             $aItem['author'] = $this->Lang_Get('plugin.forum.guest_prefix') . $oPost->getGuestName();
         }
         $aItems[] = $aItem;
     }
     /**
      * Формируем ответ
      */
     $this->InitRss();
     $this->Viewer_Assign('aChannel', $aChannel);
     $this->Viewer_Assign('aItems', $aItems);
     $this->SetTemplateAction('index');
 }