public function getUrlPath() { $sResult = $this->getProp('_page_url_path'); if (!$sResult) { $sResult = F::File_LocalUrl(R::GetPath('page') . '/' . $this->getUrlFull()); $this->setProp('_page_url_path', $sResult); } return $sResult; }
/** * @param ModuleMenu_EntityMenu $oMenu */ protected function _addMenuItem($oMenu) { // Создадим элемент меню $oMenuItem = E::ModuleMenu()->CreateMenuItem('plugin.sandbox.topics', array('text' => array('{{plugin.sandbox.menu_text}}', 'hook:new_sandbox_count' => array('red')), 'link' => R::GetPath('index/sandbox'), 'active' => array('topic_kind' => array('sandbox')), 'options' => array('class' => '', 'link_title' => '{{plugin.sandbox.menu_text}}'))); // Добавим в меню $oMenu->AddItem($oMenuItem); // Сохраним E::ModuleMenu()->SaveMenu($oMenu); }
/** * Ajax авторизация */ protected function EventAjaxLogin() { // Устанавливаем формат Ajax ответа E::ModuleViewer()->SetResponseAjax('json'); // Проверяем передачу логина пароля через POST $sUserLogin = trim($this->GetPost('login')); $sUserPassword = $this->GetPost('password'); $bRemember = $this->GetPost('remember', false) ? true : false; $sUrlRedirect = F::GetRequestStr('return-path'); if (!$sUserLogin || !trim($sUserPassword)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_login_bad')); return; } $iError = null; // Seek user by mail or by login $aUserAuthData = array('login' => $sUserLogin, 'email' => $sUserLogin, 'password' => $sUserPassword, 'error' => &$iError); /** @var ModuleUser_EntityUser $oUser */ $oUser = E::ModuleUser()->GetUserAuthorization($aUserAuthData); if ($oUser) { if ($iError) { switch ($iError) { case ModuleUser::USER_AUTH_ERR_NOT_ACTIVATED: $sErrorMessage = E::ModuleLang()->Get('user_not_activated', array('reactivation_path' => R::GetPath('login') . 'reactivation')); break; case ModuleUser::USER_AUTH_ERR_IP_BANNED: $sErrorMessage = E::ModuleLang()->Get('user_ip_banned'); break; case ModuleUser::USER_AUTH_ERR_BANNED_DATE: $sErrorMessage = E::ModuleLang()->Get('user_banned_before', array('date' => $oUser->GetBanLine())); break; case ModuleUser::USER_AUTH_ERR_BANNED_UNLIM: $sErrorMessage = E::ModuleLang()->Get('user_banned_unlim'); break; default: $sErrorMessage = E::ModuleLang()->Get('user_login_bad'); } E::ModuleMessage()->AddErrorSingle($sErrorMessage); return; } else { // Авторизуем E::ModuleUser()->Authorization($oUser, $bRemember); // Определяем редирект //$sUrl = Config::Get('module.user.redirect_after_login'); if (!$sUrlRedirect) { $sUrlRedirect = C::Get('path.root.url'); } E::ModuleViewer()->AssignAjax('sUrlRedirect', $sUrlRedirect); return; } } E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_login_bad')); }
/** * Ajax авторизация */ protected function EventAjaxLogin() { // Устанавливаем формат Ajax ответа E::ModuleViewer()->SetResponseAjax('json'); // Проверяем передачу логина пароля через POST $sUserLogin = trim($this->GetPost('login')); $sUserPassword = $this->GetPost('password'); if (!$sUserLogin || !trim($sUserPassword)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_login_bad')); return; } // Seek user by mail or by login /** @var ModuleUser_EntityUser $oUser */ if ($oUser = E::ModuleUser()->GetUserByMailOrLogin($sUserLogin)) { // Не забанен ли юзер if ($oUser->IsBanned()) { if ($oUser->IsBannedByIp()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_ip_banned')); return; } elseif ($oUser->GetBanLine()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_banned_before', array('date' => $oUser->GetBanLine()))); return; } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_banned_unlim')); return; } } // Check password if (E::ModuleUser()->CheckPassword($oUser, $sUserPassword)) { if (!$oUser->getActivate()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_not_activated', array('reactivation_path' => R::GetPath('login') . 'reactivation'))); return; } $bRemember = F::GetRequest('remember', false) ? true : false; // Авторизуем E::ModuleUser()->Authorization($oUser, $bRemember); // Определяем редирект //$sUrl = Config::Get('module.user.redirect_after_login'); $sUrl = Config::Get('path.root.url'); if (F::GetRequestStr('return-path')) { $sUrl = F::GetRequestStr('return-path'); } E::ModuleViewer()->AssignAjax('sUrlRedirect', $sUrl ? $sUrl : Config::Get('path.root.url')); return; } } E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_login_bad')); }
/** * Плагин для смарти * Позволяет получать данные о роутах * * @param array $aParams * @param Smarty $oSmarty * * @return string */ function smarty_function_router($aParams, &$oSmarty) { if (empty($aParams['page'])) { trigger_error("Router: missing 'page' parametr", E_USER_WARNING); return ''; } if (!($sPath = R::GetPath($aParams['page']))) { trigger_error("Router: unknown 'page' given", E_USER_WARNING); return ''; } // * Возвращаем полный адрес к указаному Action $sReturn = isset($aParams['extend']) ? $sPath . $aParams['extend'] . "/" : $sPath; if (!empty($aParams['assign'])) { $oSmarty->assign($aParams['assign'], $sReturn); return ''; } return $sReturn; }
public function EventSandbox() { // * Меню $this->sMenuSubItemSelect = 'sandbox'; // * Передан ли номер страницы $iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1; // * Получаем список топиков $aResult = E::ModuleTopic()->GetTopicsNewAll($iPage, Config::Get('module.topic.per_page')); $aTopics = $aResult['collection']; // * Вызов хуков E::ModuleHook()->Run('topics_list_show', array('aTopics' => $aTopics)); // * Формируем постраничность $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), R::GetPath('index/sandbox')); E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('plugin.sandbox.menu_text') . ($iPage > 1 ? ' (' . $iPage . ')' : '')); // * Загружаем переменные в шаблон E::ModuleViewer()->Assign('aTopics', $aTopics); E::ModuleViewer()->Assign('aPaging', $aPaging); // * Устанавливаем шаблон вывода $this->SetTemplateAction('index'); }
/** * Выводим список комментариев * */ protected function EventComments() { // * Передан ли номер страницы $iPage = $this->GetEventMatch(2) ? $this->GetEventMatch(2) : 1; // * Исключаем из выборки идентификаторы закрытых блогов (target_parent_id) $aCloseBlogs = $this->oUserCurrent ? E::ModuleBlog()->GetInaccessibleBlogsByUser($this->oUserCurrent) : E::ModuleBlog()->GetInaccessibleBlogsByUser(); // * Получаем список комментов $aResult = E::ModuleComment()->GetCommentsAll('topic', $iPage, Config::Get('module.comment.per_page'), array(), $aCloseBlogs); $aComments = $aResult['collection']; // * Формируем постраничность $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.comment.per_page'), Config::Get('pagination.pages.count'), R::GetPath('comments')); // * Загружаем переменные в шаблон E::ModuleViewer()->Assign('aPaging', $aPaging); E::ModuleViewer()->Assign('aComments', $aComments); // * Устанавливаем title страницы E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('comments_all')); E::ModuleViewer()->SetHtmlRssAlternate(R::GetPath('rss') . 'allcomments/', E::ModuleLang()->Get('comments_all')); // * Устанавливаем шаблон вывода $this->SetTemplateAction('index'); }
/** * Отписка от подписки */ protected function EventUnsubscribe() { /** * Получаем подписку по ключу */ $oSubscribe = E::ModuleSubscribe()->GetSubscribeByKey($this->getParam(0)); if ($oSubscribe && $oSubscribe->getStatus() == 1) { /** * Отписываем пользователя */ $oSubscribe->setStatus(0); $oSubscribe->setDateRemove(F::Now()); E::ModuleSubscribe()->UpdateSubscribe($oSubscribe); E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('subscribe_change_ok'), null, true); } /** * Получаем URL для редиректа */ if (!($sUrl = E::ModuleSubscribe()->GetUrlTarget($oSubscribe->getTargetType(), $oSubscribe->getTargetId()))) { $sUrl = R::GetPath('index'); } R::Location($sUrl); }
/** * Отображение топиков * */ protected function EventTags() { // * Gets tag from URL $sTag = F::UrlDecode(R::Url('event'), true); // * Check page number $iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1; // * Gets topics list $aResult = E::ModuleTopic()->GetTopicsByTag($sTag, $iPage, Config::Get('module.topic.per_page')); $aTopics = $aResult['collection']; // * Calls hooks E::ModuleHook()->Run('topics_list_show', array('aTopics' => $aTopics)); // * Makes pages $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), R::GetPath('tag') . htmlspecialchars($sTag)); // * Loads variables to template E::ModuleViewer()->Assign('aPaging', $aPaging); E::ModuleViewer()->Assign('aTopics', $aTopics); E::ModuleViewer()->Assign('sTag', $sTag); E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('tag_title')); E::ModuleViewer()->AddHtmlTitle($sTag); E::ModuleViewer()->SetHtmlRssAlternate(R::GetPath('rss') . 'tag/' . $sTag . '/', $sTag); // * Sets template for display $this->SetTemplateAction('index'); }
/** * Удаление блога * */ protected function EventDeleteBlog() { E::ModuleSecurity()->ValidateSendForm(); // * Проверяем передан ли в УРЛе номер блога $nBlogId = intval($this->GetParam(0)); if (!$nBlogId || !($oBlog = E::ModuleBlog()->GetBlogById($nBlogId))) { return parent::EventNotFound(); } $this->oCurrentBlog = $oBlog; // * Проверям авторизован ли пользователь if (!E::ModuleUser()->IsAuthorization()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('not_access'), E::ModuleLang()->Get('error')); return R::Action('error'); } // * проверяем есть ли право на удаление блога if (!($nAccess = E::ModuleACL()->IsAllowDeleteBlog($oBlog, $this->oUserCurrent))) { return parent::EventNotFound(); } $aTopics = E::ModuleTopic()->GetTopicsByBlogId($nBlogId); switch ($nAccess) { case ModuleACL::CAN_DELETE_BLOG_EMPTY_ONLY: if (is_array($aTopics) && count($aTopics)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('blog_admin_delete_not_empty'), E::ModuleLang()->Get('error'), true); R::Location($oBlog->getUrlFull()); } break; case ModuleACL::CAN_DELETE_BLOG_WITH_TOPICS: /* * Если указан идентификатор блога для перемещения, * то делаем попытку переместить топики. * * (-1) - выбран пункт меню "удалить топики". */ $nNewBlogId = intval(F::GetRequestStr('topic_move_to')); if ($nNewBlogId > 0 && is_array($aTopics) && count($aTopics)) { if (!($oBlogNew = E::ModuleBlog()->GetBlogById($nNewBlogId))) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('blog_admin_delete_move_error'), E::ModuleLang()->Get('error'), true); R::Location($oBlog->getUrlFull()); } // * Если выбранный блог является персональным, возвращаем ошибку if ($oBlogNew->getType() == 'personal') { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('blog_admin_delete_move_personal'), E::ModuleLang()->Get('error'), true); R::Location($oBlog->getUrlFull()); } // * Перемещаем топики E::ModuleTopic()->MoveTopics($nBlogId, $nNewBlogId); } break; default: return parent::EventNotFound(); } // * Удаляяем блог и перенаправляем пользователя к списку блогов E::ModuleHook()->Run('blog_delete_before', array('sBlogId' => $nBlogId)); if ($this->_deleteBlog($oBlog)) { E::ModuleHook()->Run('blog_delete_after', array('sBlogId' => $nBlogId)); E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('blog_admin_delete_success'), E::ModuleLang()->Get('attention'), true); R::Location(R::GetPath('blogs')); } else { R::Location($oBlog->getUrlFull()); } }
/** * Обработка добавления в друзья * * @param ModuleUser_EntityUser $oUser * @param string $sUserText * @param ModuleUser_EntityUser $oFriend * * @return bool */ protected function SubmitAddFriend($oUser, $sUserText, $oFriend = null) { /** * Ограничения на добавления в друзья, т.к. приглашение отправляется в личку, то и ограничиваем по ней */ if (!E::ModuleACL()->CanSendTalkTime($this->oUserCurrent)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_friend_add_time_limit'), E::ModuleLang()->Get('error')); return false; } /** * Обрабатываем текст заявки */ $sUserText = E::ModuleText()->Parse($sUserText); /** * Создаем связь с другом */ /** @var ModuleUser_EntityFriend $oFriendNew */ $oFriendNew = E::GetEntity('User_Friend'); $oFriendNew->setUserTo($oUser->getId()); $oFriendNew->setUserFrom($this->oUserCurrent->getId()); // Добавляем заявку в друзья $oFriendNew->setStatusFrom(ModuleUser::USER_FRIEND_OFFER); $oFriendNew->setStatusTo(ModuleUser::USER_FRIEND_NULL); $bStateError = $oFriend ? !E::ModuleUser()->UpdateFriend($oFriendNew) : !E::ModuleUser()->AddFriend($oFriendNew); if (!$bStateError) { E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('user_friend_offer_send'), E::ModuleLang()->Get('attention')); $sTitle = E::ModuleLang()->Get('user_friend_offer_title', array('login' => $this->oUserCurrent->getLogin(), 'friend' => $oUser->getLogin())); F::IncludeLib('XXTEA/encrypt.php'); $sCode = $this->oUserCurrent->getId() . '_' . $oUser->getId(); $sCode = rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('module.talk.encrypt')))); $aPath = array('accept' => R::GetPath('profile') . 'friendoffer/accept/?code=' . $sCode, 'reject' => R::GetPath('profile') . 'friendoffer/reject/?code=' . $sCode); $sText = E::ModuleLang()->Get('user_friend_offer_text', array('login' => $this->oUserCurrent->getLogin(), 'accept_path' => $aPath['accept'], 'reject_path' => $aPath['reject'], 'user_text' => $sUserText)); $oTalk = E::ModuleTalk()->SendTalk($sTitle, $sText, $this->oUserCurrent, array($oUser), false, false); /** * Отправляем пользователю заявку */ E::ModuleNotify()->SendUserFriendNew($oUser, $this->oUserCurrent, $sUserText, R::GetPath('talk') . 'read/' . $oTalk->getId() . '/'); /** * Удаляем отправляющего юзера из переписки */ E::ModuleTalk()->DeleteTalkUserByArray($oTalk->getId(), $this->oUserCurrent->getId()); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error')); } /** * Подписываем запрашивающего дружбу на */ E::ModuleStream()->SubscribeUser($this->oUserCurrent->getId(), $oUser->getId()); $oViewerLocal = $this->GetViewerLocal(); $oViewerLocal->Assign('oUserFriend', $oFriendNew); E::ModuleViewer()->AssignAjax('sToggleText', $oViewerLocal->Fetch('actions/profile/action.profile.friend_item.tpl')); }
/** * Возвращает URL до профиля пользователя * * @param string|null $sUrlMask - еcли передан параметр, то формирует URL по этой маске * @param bool $bFullUrl - возвращать полный путь (или относительный, если false) * * @return string */ public function getProfileUrl($sUrlMask = null, $bFullUrl = true) { $sKey = '-url-' . ($sUrlMask ? $sUrlMask : '') . ($bFullUrl ? '-1' : '-0'); $sUrl = $this->getProp($sKey); if (!is_null($sUrl)) { return $sUrl; } if (!$sUrlMask) { $sUrlMask = R::GetUserUrlMask(); } if (!$sUrlMask) { // формирование URL по умолчанию $sUrl = R::GetPath('profile/' . $this->getLogin()); $this->setProp($sKey, $sUrl); return $sUrl; } $aReplace = array('%user_id%' => $this->GetId(), '%login%' => $this->GetLogin()); $sUrl = strtr($sUrlMask, $aReplace); if (strpos($sUrl, '/')) { list($sAction, $sPath) = explode('/', $sUrl, 2); $sUrl = R::GetPath($sAction) . $sPath; } else { $sUrl = F::File_RootUrl() . $sUrl; } if (substr($sUrl, -1) !== '/') { $sUrl .= '/'; } $this->setProp($sKey, $sUrl); return $sUrl; }
/** * @return string */ public function getLink() { $sLink = R::GetPath('tag') . F::UrlEncode($this->getText(), true) . '/'; return $sLink; }
protected function _eventBanlistIps($nPage) { $this->SetTemplateAction('users/banlist_ips'); // Получаем список забаненных ip-адресов $aResult = E::ModuleAdmin()->GetIpsBanList($nPage, Config::Get('admin.items_per_page')); // Формируем постраничность $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $nPage, Config::Get('admin.items_per_page'), 4, R::GetPath('admin') . 'banlist/ips/'); E::ModuleViewer()->Assign('aPaging', $aPaging); E::ModuleViewer()->Assign('aIpsList', $aResult['collection']); }
/** * Страница создания письма */ protected function EventAdd() { $this->sMenuSubItemSelect = 'add'; E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('talk_menu_inbox_create')); // * Получаем список друзей $aUsersFriend = E::ModuleUser()->GetUsersFriend($this->oUserCurrent->getId()); if ($aUsersFriend['collection']) { E::ModuleViewer()->Assign('aUsersFriend', $aUsersFriend['collection']); } // * Проверяем отправлена ли форма с данными if (!F::isPost('submit_talk_add')) { return false; } // * Проверка корректности полей формы if (!$this->checkTalkFields()) { return false; } // * Проверяем разрешено ли отправлять инбокс по времени if (!E::ModuleACL()->CanSendTalkTime($this->oUserCurrent)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('talk_time_limit'), E::ModuleLang()->Get('error')); return false; } // * Отправляем письмо if ($oTalk = E::ModuleTalk()->SendTalk(E::ModuleText()->Parser(strip_tags(F::GetRequestStr('talk_title'))), E::ModuleText()->Parser(F::GetRequestStr('talk_text')), $this->oUserCurrent, $this->aUsersId)) { E::ModuleMresource()->CheckTargetTextForImages('talk', $oTalk->getId(), $oTalk->getText()); R::Location(R::GetPath('talk') . 'read/' . $oTalk->getId() . '/'); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error')); return R::Action('error'); } }
/** * Возвращает полный URL до страницы редактировани топика * * @return string */ public function getUrlEdit() { return R::GetPath('content') . 'edit/' . $this->getId() . '/'; }
/** * Вывод интересных на главную * */ protected function EventIndex() { E::ModuleViewer()->SetHtmlRssAlternate(R::GetPath('rss') . 'index/', Config::Get('view.name')); /** * Меню */ $this->sTopicFilter = $this->sMenuSubItemSelect = 'good'; /** * Передан ли номер страницы */ $iPage = $this->GetEventMatch(2) ? $this->GetEventMatch(2) : 1; /** * Устанавливаем основной URL для поисковиков */ if ($iPage == 1) { E::ModuleViewer()->SetHtmlCanonical(trim(Config::Get('path.root.url'), '/') . '/'); } /** * Получаем список топиков */ $aResult = E::ModuleTopic()->GetTopicsGood($iPage, Config::Get('module.topic.per_page')); $aTopics = $aResult['collection']; /** * Вызов хуков */ E::ModuleHook()->Run('topics_list_show', array('aTopics' => $aTopics)); /** * Формируем постраничность */ $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), R::GetPath('index')); /** * Загружаем переменные в шаблон */ E::ModuleViewer()->Assign('aTopics', $aTopics); E::ModuleViewer()->Assign('aPaging', $aPaging); /** * Устанавливаем шаблон вывода */ $this->SetTemplateAction('index'); }
/** * Create and show rss channel * * @param $aItems */ protected function _showRssItems($aItems) { $aParts = explode('/', trim(R::Url('path'), '/'), 2); if (isset($aParts[1])) { $sLink = R::GetPath('/' . $aParts[1]); } else { $sLink = R::GetPath('/'); } if ($sQuery = R::Url('query')) { $sLink .= '?' . $sQuery; } $aRssChannelData = array('title' => E::ModuleViewer()->GetHtmlTitle(), 'description' => E::ModuleViewer()->GetHtmlDescription(), 'link' => $sLink, 'language' => C::Get('lang.current'), 'managing_editor' => C::Get('general.rss_editor_mail'), 'web_master' => C::Get('general.rss_editor_mail'), 'generator' => 'Alto CMS v.' . ALTO_VERSION); /** @var ModuleRss_EntityRssChannel $oRssChannel */ $oRssChannel = E::GetEntity('ModuleRss_EntityRssChannel', $aRssChannelData); /** @var ModuleRss_EntityRss $oRss */ $oRss = E::GetEntity('Rss'); if ($aItems) { // Adds items into RSS channel foreach ($aItems as $oItem) { if ($oItem) { $oRssChannel->AddItem($oItem->CreateRssItem()); } } } $oRss->AddChannel($oRssChannel); $this->_displayRss($oRss); }
/** * @param array $aUserAuthData * * @return ModuleUser_EntityUser */ protected function _userLogin($aUserAuthData) { // Seek user by mail or by login /** @var ModuleUser_EntityUser $oUser */ $oUser = E::ModuleUser()->GetUserAuthorization($aUserAuthData); if ($oUser) { if ($this->iResponseError) { switch ($this->iResponseError) { case ModuleUser::USER_AUTH_ERR_NOT_ACTIVATED: $this->sResponseMessage = E::ModuleLang()->Get('user_not_activated', array('reactivation_path' => R::GetPath('login') . 'reactivation')); break; case ModuleUser::USER_AUTH_ERR_IP_BANNED: $this->sResponseMessage = E::ModuleLang()->Get('user_ip_banned'); break; case ModuleUser::USER_AUTH_ERR_BANNED_DATE: $this->sResponseMessage = E::ModuleLang()->Get('user_banned_before', array('date' => $oUser->GetBanLine())); break; case ModuleUser::USER_AUTH_ERR_BANNED_UNLIM: $this->sResponseMessage = E::ModuleLang()->Get('user_banned_unlim'); break; default: $this->sResponseMessage = E::ModuleLang()->Get('user_login_bad'); } } else { // Авторизуем E::ModuleUser()->Authorization($oUser, true); } } else { $this->sResponseMessage = E::ModuleLang()->Get('user_login_bad'); } return $oUser; }
/** * Получает URL цели * * @param string $sTargetType * @param int $iTargetId * * @return string */ public function GetTargetUrl($sTargetType, $iTargetId) { if (mb_strpos($sTargetType, 'single-image-uploader') === 0 || $sTargetType == 'photoset' || $sTargetType == 'topic') { /** @var ModuleTopic_EntityTopic $oTopic */ if (!($oTopic = E::ModuleTopic()->GetTopicById($iTargetId))) { return ''; } return $oTopic->getUrl(); } if ($sTargetType == 'profile_avatar') { return R::GetPath('settings'); } if ($sTargetType == 'profile_photo') { return R::GetPath('settings'); } if ($sTargetType == 'blog_avatar') { /** @var ModuleBlog_EntityBlog $oBlog */ $oBlog = E::ModuleBlog()->GetBlogById($iTargetId); if ($oBlog) { return $oBlog->getUrlFull(); } return ''; } return ''; }
/** * Выводит список топиков * */ protected function EventShowTopics() { /** * Меню */ $this->sMenuSubItemSelect = $this->sCurrentEvent; /* * Получаем тип контента */ if (!($this->oType = E::ModuleTopic()->GetContentType($this->sCurrentEvent))) { return parent::EventNotFound(); } /** * Устанавливаем title страницы */ E::ModuleViewer()->AddHtmlTitle($this->oType->getContentTitleDecl()); /** * Передан ли номер страницы */ $iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1; /** * Получаем список топиков */ $aResult = E::ModuleTopic()->GetTopicsByType($iPage, Config::Get('module.topic.per_page'), $this->oType->getContentUrl()); $aTopics = $aResult['collection']; /** * Формируем постраничность */ $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.topic.per_page'), Config::Get('pagination.pages.count'), R::GetPath('filter') . $this->sCurrentEvent); /** * Загружаем переменные в шаблон */ E::ModuleViewer()->Assign('aPaging', $aPaging); E::ModuleViewer()->Assign('aTopics', $aTopics); $this->SetTemplateAction('index'); }
/** * Отображение списка персональных блогов */ protected function EventShowBlogsPersonal() { // * По какому полю сортировать $sOrder = F::GetRequestStr('order', 'blog_title'); // * В каком направлении сортировать $sOrderWay = F::GetRequestStr('order_way', 'desc'); // * Фильтр поиска блогов $aFilter = array('include_type' => 'personal'); // * Передан ли номер страницы $iPage = preg_match('/^\\d+$/i', $this->GetParamEventMatch(0, 2)) ? $this->GetParamEventMatch(0, 2) : 1; // * Получаем список блогов $aResult = E::ModuleBlog()->GetBlogsByFilter($aFilter, array($sOrder => $sOrderWay), $iPage, Config::Get('module.blog.per_page')); $aBlogs = $aResult['collection']; // * Формируем постраничность $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.blog.per_page'), Config::Get('pagination.pages.count'), R::GetPath('blogs') . 'personal/', array('order' => $sOrder, 'order_way' => $sOrderWay)); // * Загружаем переменные в шаблон E::ModuleViewer()->Assign('aPaging', $aPaging); E::ModuleViewer()->Assign('aBlogs', $aBlogs); E::ModuleViewer()->Assign('sBlogOrder', htmlspecialchars($sOrder)); E::ModuleViewer()->Assign('sBlogOrderWay', htmlspecialchars($sOrderWay)); E::ModuleViewer()->Assign('sBlogOrderWayNext', $sOrderWay == 'desc' ? 'asc' : 'desc'); E::ModuleViewer()->Assign('sShow', 'personal'); E::ModuleViewer()->Assign('sBlogsRootPage', R::GetPath('blogs') . 'personal/'); // * Устанавливаем title страницы E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('blog_menu_all_list')); // * Устанавливаем шаблон вывода $this->SetTemplateAction('index'); }
/** * @return string */ public function GetSettings() { $sResult = $this->getProp('settings'); if (is_null($sResult)) { $sResult = preg_replace('/{([^}]+)}/', R::GetPath('$1'), $this->oXml->settings); $this->setProp('settings', $sResult); } return $sResult; }
/** * Выводит список топиков * */ 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)); }
/** * Показываем юзеров * */ protected function EventIndex() { // Получаем статистику $this->GetStats(); // По какому полю сортировать $sOrder = 'user_rating'; if (F::GetRequest('order')) { $sOrder = F::GetRequestStr('order'); } // В каком направлении сортировать $sOrderWay = 'desc'; if (F::GetRequest('order_way')) { $sOrderWay = F::GetRequestStr('order_way'); } $aFilter = array('activate' => 1); // Передан ли номер страницы $iPage = $this->GetParamEventMatch(0, 2) ? $this->GetParamEventMatch(0, 2) : 1; // Получаем список юзеров $aResult = E::ModuleUser()->GetUsersByFilter($aFilter, array($sOrder => $sOrderWay), $iPage, Config::Get('module.user.per_page')); $aUsers = $aResult['collection']; // Формируем постраничность $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.user.per_page'), Config::Get('pagination.pages.count'), R::GetPath('people') . 'index', array('order' => $sOrder, 'order_way' => $sOrderWay)); // Получаем алфавитный указатель на список пользователей $aPrefixUser = E::ModuleUser()->GetGroupPrefixUser(1); // Загружаем переменные в шаблон E::ModuleViewer()->Assign('aPaging', $aPaging); E::ModuleViewer()->Assign('aUsersRating', $aUsers); E::ModuleViewer()->Assign('aPrefixUser', $aPrefixUser); E::ModuleViewer()->Assign("sUsersOrder", htmlspecialchars($sOrder)); E::ModuleViewer()->Assign("sUsersOrderWay", htmlspecialchars($sOrderWay)); E::ModuleViewer()->Assign("sUsersOrderWayNext", htmlspecialchars($sOrderWay == 'desc' ? 'asc' : 'desc')); // Устанавливаем шаблон вывода $this->SetTemplateAction('index'); }
/** * Returns link to the blog * * @return string */ public function getLink() { if ($this->getType() == 'personal') { return $this->getOwner()->getProfileUrl() . 'created/topics/'; } else { return R::GetPath('blog/' . $this->getUrl()); } }
/** * Обработка Ajax регистрации */ protected function EventAjaxRegistration() { // * Устанавливаем формат Ajax ответа E::ModuleViewer()->SetResponseAjax('json'); E::ModuleSecurity()->ValidateSendForm(); // * Создаем объект пользователя и устанавливаем сценарий валидации /** @var ModuleUser_EntityUser $oUser */ $oUser = E::GetEntity('ModuleUser_EntityUser'); $oUser->_setValidateScenario('registration'); // * Заполняем поля (данные) $oUser->setLogin($this->GetPost('login')); $oUser->setMail($this->GetPost('mail')); $oUser->setPassword($this->GetPost('password')); $oUser->setPasswordConfirm($this->GetPost('password_confirm')); $oUser->setCaptcha($this->GetPost('captcha')); $oUser->setDateRegister(F::Now()); $oUser->setIpRegister(F::GetUserIp()); // * Если используется активация, то генерим код активации if (Config::Get('general.reg.activation')) { $oUser->setActivate(0); $oUser->setActivationKey(F::RandomStr()); } else { $oUser->setActivate(1); $oUser->setActivationKey(null); } E::ModuleHook()->Run('registration_validate_before', array('oUser' => $oUser)); // * Запускаем валидацию if ($oUser->_Validate()) { // Сбросим капчу // issue#342. E::ModuleSession()->Drop(E::ModuleCaptcha()->GetKeyName()); E::ModuleHook()->Run('registration_validate_after', array('oUser' => $oUser)); $oUser->setPassword($oUser->getPassword(), true); if ($this->_addUser($oUser)) { E::ModuleHook()->Run('registration_after', array('oUser' => $oUser)); // * Подписываем пользователя на дефолтные события в ленте активности E::ModuleStream()->SwitchUserEventDefaultTypes($oUser->getId()); // * Если юзер зарегистрировался по приглашению то обновляем инвайт if (Config::Get('general.reg.invite') && ($oInvite = E::ModuleUser()->GetInviteByCode($this->GetInviteRegister()))) { $oInvite->setUserToId($oUser->getId()); $oInvite->setDateUsed(F::Now()); $oInvite->setUsed(1); E::ModuleUser()->UpdateInvite($oInvite); } // * Если стоит регистрация с активацией то проводим её if (Config::Get('general.reg.activation')) { // * Отправляем на мыло письмо о подтверждении регистрации E::ModuleNotify()->SendRegistrationActivate($oUser, F::GetRequestStr('password')); E::ModuleViewer()->AssignAjax('sUrlRedirect', R::GetPath('registration') . 'confirm/'); } else { E::ModuleNotify()->SendRegistration($oUser, F::GetRequestStr('password')); $oUser = E::ModuleUser()->GetUserById($oUser->getId()); // * Сразу авторизуем E::ModuleUser()->Authorization($oUser, false); $this->DropInviteRegister(); // * Определяем URL для редиректа после авторизации $sUrl = Config::Get('module.user.redirect_after_registration'); if (F::GetRequestStr('return-path')) { $sUrl = F::GetRequestStr('return-path'); } E::ModuleViewer()->AssignAjax('sUrlRedirect', $sUrl ? $sUrl : Config::Get('path.root.url')); E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('registration_ok')); } } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error')); return; } } else { // * Получаем ошибки E::ModuleViewer()->AssignAjax('aErrors', $oUser->_getValidateErrors()); } }
/** * Выполняет загрузку необходимых (возможно даже системных :)) переменных в шаблонизатор */ public function VarAssign() { // * Загружаем весь $_REQUEST, предварительно обработав его функцией F::HtmlSpecialChars() $aRequest = $_REQUEST; F::HtmlSpecialChars($aRequest); $this->Assign('_aRequest', $aRequest); // * Параметры стандартной сессии // TODO: Убрать! Не должно этого быть на страницах сайта $this->Assign('_sPhpSessionName', session_name()); $this->Assign('_sPhpSessionId', session_id()); // * Загружаем роутинг с учетом правил rewrite $aRouter = array(); $aPages = Config::Get('router.page'); if (!$aPages || !is_array($aPages)) { throw new Exception('Router rules is underfined.'); } foreach ($aPages as $sPage => $aAction) { $aRouter[$sPage] = R::GetPath($sPage); } $this->Assign('aRouter', $aRouter); // * Загружаем виджеты $this->Assign('aWidgets', $this->GetWidgets()); // * Загружаем HTML заголовки $this->Assign('sHtmlTitle', $this->GetHtmlTitle()); $this->Assign('sHtmlKeywords', $this->GetHtmlKeywords()); $this->Assign('sHtmlDescription', $this->GetHtmlDescription()); $this->Assign('aHtmlHeadFiles', $this->aHtmlHeadFiles); $this->Assign('aHtmlRssAlternate', $this->aHtmlRssAlternate); $this->Assign('sHtmlCanonical', $this->sHtmlCanonical); $this->Assign('aHtmlHeadTags', $this->aHtmlHeadTags); $this->Assign('aJsAssets', E::ModuleViewerAsset()->GetPreparedAssetLinks()); // * Загружаем список активных плагинов $aPlugins = E::GetActivePlugins(); $this->Assign('aPluginActive', array_fill_keys(array_keys($aPlugins), true)); // * Загружаем пути до шаблонов плагинов $aPluginsTemplateUrl = array(); $aPluginsTemplateDir = array(); /** @var Plugin $oPlugin */ foreach ($aPlugins as $sPlugin => $oPlugin) { $sDir = Plugin::GetTemplateDir(get_class($oPlugin)); if ($sDir) { $this->oSmarty->addTemplateDir(array($sDir . 'tpls/', $sDir), $oPlugin->GetName(false)); $aPluginsTemplateDir[$sPlugin] = $sDir; $aPluginsTemplateUrl[$sPlugin] = Plugin::GetTemplateUrl(get_class($oPlugin)); } } if (E::ActivePlugin('ls')) { // LS-compatible // $this->Assign('aTemplateWebPathPlugin', $aPluginsTemplateUrl); $this->Assign('aTemplatePathPlugin', $aPluginsTemplateDir); } $sSkinTheme = $this->GetConfigTheme(); if (!$sSkinTheme) { $sSkinTheme = 'default'; } // Проверка существования темы if ($this->CheckTheme($sSkinTheme)) { $this->oSmarty->compile_id = $sSkinTheme; } $this->Assign('sSkinTheme', $sSkinTheme); }
public function getLink() { return R::GetPath('tag') . F::UrlEncode($this->getText()) . '/'; }