/** * Обрабатывает ссылку на конкретный комментарий, определят к какому топику он относится и перенаправляет на него * Актуально при использовании постраничности комментариев */ protected function EventShowComment() { $iCommentId = $this->sCurrentEvent; /** * Проверяем к чему относится комментарий */ if (!($oComment = $this->Comment_GetCommentById($iCommentId))) { return parent::EventNotFound(); } if ($oComment->getTargetType() != 'topic' or !($oTopic = $oComment->getTarget())) { return parent::EventNotFound(); } /** * Определяем необходимую страницу для отображения комментария */ if (!Config::Get('module.comment.use_nested') or !Config::Get('module.comment.nested_per_page')) { Router::Location($oTopic->getUrl() . '#comment' . $oComment->getId()); } $iPage = $this->Comment_GetPageCommentByTargetId($oComment->getTargetId(), $oComment->getTargetType(), $oComment); if ($iPage == 1) { Router::Location($oTopic->getUrl() . '#comment' . $oComment->getId()); } else { Router::Location($oTopic->getUrl() . "?cmtpage={$iPage}#comment" . $oComment->getId()); } exit; }
public function Init() { if (!$this->User_IsAuthorization() or !($oUserCurrent = $this->User_GetUserCurrent()) or !$oUserCurrent->isAdministrator()) { return parent::EventNotFound(); } $this->oUserCurrent = $oUserCurrent; }
/** * Инициализация * */ public function Init() { // * Доступ только у авторизованных пользователей $this->oUserCurrent = E::ModuleUser()->GetUserCurrent(); if (!$this->oUserCurrent) { parent::EventNotFound(); } $this->SetDefaultEvent('index'); E::ModuleViewer()->Assign('sMenuItemSelect', 'feed'); }
public function EventDownloadFile() { $this->SetTemplate(false); $sTopicId = $this->GetParam(0); $sFieldId = $this->GetParam(1); E::ModuleSecurity()->ValidateSendForm(); if (!($oTopic = E::ModuleTopic()->GetTopicById($sTopicId))) { return parent::EventNotFound(); } if (!($this->oType = E::ModuleTopic()->GetContentType($oTopic->getType()))) { return parent::EventNotFound(); } if (!($oField = E::ModuleTopic()->GetContentFieldById($sFieldId))) { return parent::EventNotFound(); } if ($oField->getContentId() != $this->oType->getContentId()) { return parent::EventNotFound(); } //получаем объект файла $oFile = $oTopic->getFieldFile($oField->getFieldId()); //получаем объект поля топика, содержащий данные о файле $oValue = $oTopic->getField($oField->getFieldId()); if ($oFile && $oValue) { if (preg_match("/^(http:\\/\\/)/i", $oFile->getFileUrl())) { $sFullPath = $oFile->getFileUrl(); R::Location($sFullPath); } else { $sFullPath = Config::Get('path.root.dir') . $oFile->getFileUrl(); } $sFilename = $oFile->getFileName(); /* * Обновляем данные */ $aFileObj = array(); $aFileObj['file_name'] = $oFile->getFileName(); $aFileObj['file_url'] = $oFile->getFileUrl(); $aFileObj['file_size'] = $oFile->getFileSize(); $aFileObj['file_extension'] = $oFile->getFileExtension(); $aFileObj['file_downloads'] = $oFile->getFileDownloads() + 1; $sText = serialize($aFileObj); $oValue->setValue($sText); $oValue->setValueSource($sText); //сохраняем E::ModuleTopic()->UpdateContentFieldValue($oValue); /* * Отдаем файл */ header('Content-type: ' . $oFile->getFileExtension()); header('Content-Disposition: attachment; filename="' . $sFilename . '"'); F::File_PrintChunked($sFullPath); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('content_download_file_error')); return R::Action('error'); } }
/** * Инициализация * * @return string */ public function Init() { /** * Если нет прав доступа - перекидываем на 404 страницу */ if (!$this->User_IsAuthorization() or !($oUserCurrent = $this->User_GetUserCurrent()) or !$oUserCurrent->isAdministrator()) { return parent::EventNotFound(); } $this->SetDefaultEvent('index'); $this->oUserCurrent = $oUserCurrent; }
/** * Инициализация * */ public function Init() { /** * Доступ только у авторизованных пользователей */ $this->oUserCurrent = $this->User_getUserCurrent(); if (!$this->oUserCurrent) { parent::EventNotFound(); } $this->Viewer_Assign('sMenuItemSelect', 'feed'); }
/** * Инициализация * */ public function Init() { /** * Лента доступна только для авторизованных */ $this->oUserCurrent = $this->User_getUserCurrent(); if (!$this->oUserCurrent) { parent::EventNotFound(); } $this->SetDefaultEvent('index'); $this->Viewer_Assign('aStreamEventTypes', $this->Stream_getEventTypes()); $this->Viewer_Assign('sMenuItemSelect', 'stream'); /** * Загружаем в шаблон JS текстовки */ $this->Lang_AddLangJs(array('stream_subscribes_already_subscribed', 'error')); }
protected function EventReceptiondeskCategoryIndex() { if (!($oCategory = $this->PluginReceptiondesk_Category_GetCategoryByUrl($this->GetParamEventMatch(0, 0)))) { return parent::EventNotFound(); } $iPage = $this->GetParamEventMatch(1, 2) ? $this->GetParamEventMatch(1, 2) : 1; if ($iPage == 1) { $this->Viewer_SetHtmlCanonical(Router::GetPath('receptiondesk')); } $aResult = $this->PluginReceptiondesk_Question_GetQuestionList($iPage, Config::Get('plugin.receptiondesk.receptiondesk_question_per_page'), 1, $oCategory->getId()); $aPaging = $this->Viewer_MakePaging($aResult['count'], $iPage, Config::Get('plugin.receptiondesk.receptiondesk_question_per_page'), Config::Get('pagination.pages.count'), Router::GetPath('receptiondesk') . $oCategory->getUrl() . '/'); $this->Viewer_Assign('oCurrentCategory', $oCategory); $this->Viewer_Assign('aQuestionList', $aResult['collection']); $this->Viewer_Assign('aPaging', $aPaging); if (Config::Get('plugin.receptiondesk.receptiondesk_create_popup')) { $this->Viewer_Assign('bPopup', true); } $this->SetTemplateAction('index'); }
/** * Выводит список топиков * */ 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 EventWhois() { /** * Получаем логин из УРЛа */ $sUserLogin = $this->sCurrentEvent; /** * Проверяем есть ли такой юзер */ if (!($this->oUserProfile = $this->User_GetUserByLogin($sUserLogin))) { return parent::EventNotFound(); } /** * Получаем список друзей */ $aUsersFriend = $this->User_GetUsersFriend($this->oUserProfile->getId()); if (Config::Get('general.reg.invite')) { /** * Получаем список тех кого пригласил юзер */ $aUsersInvite = $this->User_GetUsersInvite($this->oUserProfile->getId()); $this->Viewer_Assign('aUsersInvite', $aUsersInvite); /** * Получаем того юзера, кто пригласил текущего */ $oUserInviteFrom = $this->User_GetUserInviteFrom($this->oUserProfile->getId()); $this->Viewer_Assign('oUserInviteFrom', $oUserInviteFrom); } /** * Получаем список юзеров блога */ $aBlogUsers = $this->Blog_GetBlogUsersByUserId($this->oUserProfile->getId(), ModuleBlog::BLOG_USER_ROLE_USER); $aBlogModerators = $this->Blog_GetBlogUsersByUserId($this->oUserProfile->getId(), ModuleBlog::BLOG_USER_ROLE_MODERATOR); $aBlogAdministrators = $this->Blog_GetBlogUsersByUserId($this->oUserProfile->getId(), ModuleBlog::BLOG_USER_ROLE_ADMINISTRATOR); /** * Получаем список блогов которые создал юзер */ $aBlogsOwner = $this->Blog_GetBlogsByOwnerId($this->oUserProfile->getId()); /** * Вызов хуков */ $this->Hook_Run('profile_whois_show', array("oUserProfile" => $this->oUserProfile)); /** * Загружаем переменные в шаблон */ $this->Viewer_Assign('aBlogUsers', $aBlogUsers); $this->Viewer_Assign('aBlogModerators', $aBlogModerators); $this->Viewer_Assign('aBlogAdministrators', $aBlogAdministrators); $this->Viewer_Assign('aBlogsOwner', $aBlogsOwner); $this->Viewer_Assign('aUsersFriend', $aUsersFriend); $this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile') . ' ' . $this->oUserProfile->getLogin()); $this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_whois')); /** * Устанавливаем шаблон вывода */ $this->SetTemplateAction('whois'); }
/** * Чтение письма */ protected function EventRead() { $this->sMenuSubItemSelect = 'read'; // * Получаем номер сообщения из УРЛ и проверяем существует ли оно $sTalkId = $this->GetParam(0); if (!($oTalk = E::ModuleTalk()->GetTalkById($sTalkId))) { return parent::EventNotFound(); } // * Пользователь есть в переписке? if (!($oTalkUser = E::ModuleTalk()->GetTalkUser($oTalk->getId(), $this->oUserCurrent->getId()))) { return parent::EventNotFound(); } // * Пользователь активен в переписке? if ($oTalkUser->getUserActive() != ModuleTalk::TALK_USER_ACTIVE) { return parent::EventNotFound(); } // * Обрабатываем добавление коммента if (isset($_REQUEST['submit_comment'])) { $this->SubmitComment(); } // * Достаём комменты к сообщению $aReturn = E::ModuleComment()->GetCommentsByTargetId($oTalk, 'talk'); $iMaxIdComment = $aReturn['iMaxIdComment']; $aComments = $aReturn['comments']; // * Помечаем дату последнего просмотра $oTalkUser->setDateLast(F::Now()); $oTalkUser->setCommentIdLast($iMaxIdComment); $oTalkUser->setCommentCountNew(0); E::ModuleTalk()->UpdateTalkUser($oTalkUser); E::ModuleViewer()->AddHtmlTitle($oTalk->getTitle()); E::ModuleViewer()->Assign('oTalk', $oTalk); E::ModuleViewer()->Assign('aComments', $aComments); E::ModuleViewer()->Assign('iMaxIdComment', $iMaxIdComment); /* * Подсчитываем нужно ли отображать комментарии. * Комментарии не отображаются, если у вестки только один читатель * и ранее созданных комментариев нет. */ if (count($aComments) == 0) { $iActiveSpeakers = 0; foreach ((array) $oTalk->getTalkUsers() as $oTalkUser) { if ($oTalkUser->getUserId() != $this->oUserCurrent->getId() && $oTalkUser->getUserActive() == ModuleTalk::TALK_USER_ACTIVE) { $iActiveSpeakers++; break; } } if ($iActiveSpeakers == 0) { E::ModuleViewer()->Assign('bNoComments', true); } } E::ModuleViewer()->Assign('bAllowToComment', true); $this->SetTemplateAction('message'); }
/** * Показывает юзеров по городу * */ protected function EventCity() { if (!($oCity = $this->User_GetCityByName(urldecode($this->getParam(0))))) { return parent::EventNotFound(); } /** * Получаем статистику */ $this->GetStats(); /** * Передан ли номер страницы */ $iPage = $this->GetParamEventMatch(1, 2) ? $this->GetParamEventMatch(1, 2) : 1; /** * Получаем список юзеров */ $aResult = $this->User_GetUsersByCity($oCity->getName(), $iPage, Config::Get('module.user.per_page')); $aUsersCity = $aResult['collection']; /** * Формируем постраничность */ $aPaging = $this->Viewer_MakePaging($aResult['count'], $iPage, Config::Get('module.user.per_page'), 4, Router::GetPath('people') . $this->sCurrentEvent . '/' . $oCity->getName()); /** * Загружаем переменные в шаблон */ if ($aUsersCity) { $this->Viewer_Assign('aPaging', $aPaging); } $this->Viewer_Assign('oCity', $oCity); $this->Viewer_Assign('aUsersCity', $aUsersCity); }
/** * Показ и обработка формы приглаешний * */ protected function EventInvite() { /** * Только при активном режиме инвайтов */ if (!Config::Get('general.reg.invite')) { return parent::EventNotFound(); } $this->sMenuItemSelect = 'invite'; $this->sMenuSubItemSelect = ''; E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('settings_menu_invite')); /** * Если отправили форму */ if (isPost('submit_invite')) { E::ModuleSecurity()->ValidateSendForm(); $bError = false; /** * Есть права на отправку инфайтов? */ if (!E::ModuleACL()->CanSendInvite($this->oUserCurrent) && !$this->oUserCurrent->isAdministrator()) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('settings_invite_available_no'), E::ModuleLang()->Get('error')); $bError = true; } /** * Емайл корректен? */ if (!F::CheckVal(F::GetRequestStr('invite_mail'), 'mail')) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('settings_invite_mail_error'), E::ModuleLang()->Get('error')); $bError = true; } /** * Запускаем выполнение хуков */ E::ModuleHook()->Run('settings_invate_send_before', array('oUser' => $this->oUserCurrent)); /** * Если нет ошибок, то отправляем инвайт */ if (!$bError) { $oInvite = E::ModuleUser()->GenerateInvite($this->oUserCurrent); E::ModuleNotify()->SendInvite($this->oUserCurrent, F::GetRequestStr('invite_mail'), $oInvite); E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('settings_invite_submit_ok')); E::ModuleHook()->Run('settings_invate_send_after', array('oUser' => $this->oUserCurrent)); } } E::ModuleViewer()->Assign('iCountInviteAvailable', E::ModuleUser()->GetCountInviteAvailable($this->oUserCurrent)); E::ModuleViewer()->Assign('iCountInviteUsed', E::ModuleUser()->GetCountInviteUsed($this->oUserCurrent->getId())); }
/** * Редактирование ссылки * * @return unknown */ protected function EventEdit() { /** * Меню */ $this->sMenuSubItemSelect = ''; $this->sMenuItemSelect = 'question'; /** * Получаем номер топика из УРЛ и проверяем существует ли он */ $sTopicId = $this->GetParam(0); if (!($oTopic = $this->Topic_GetTopicById($sTopicId))) { return parent::EventNotFound(); } /** * Проверяем тип топика */ if ($oTopic->getType() != 'question') { return parent::EventNotFound(); } /** * Если права на редактирование */ if (!$this->ACL_IsAllowEditTopic($oTopic, $this->oUserCurrent)) { return parent::EventNotFound(); } /** * Вызов хуков */ $this->Hook_Run('topic_edit_show', array('oTopic' => $oTopic)); /** * Загружаем переменные в шаблон */ $this->Viewer_Assign('aBlogsAllow', $this->Blog_GetBlogsAllowByUser($this->oUserCurrent)); $this->Viewer_Assign('bEditDisabled', $oTopic->getQuestionCountVote() == 0 ? false : true); $this->Viewer_AddHtmlTitle($this->Lang_Get('topic_question_title_edit')); /** * Устанавливаем шаблон вывода */ $this->SetTemplateAction('add'); /** * Проверяем отправлена ли форма с данными(хотяб одна кнопка) */ if (isset($_REQUEST['submit_topic_publish']) or isset($_REQUEST['submit_topic_save'])) { /** * Обрабатываем отправку формы */ return $this->SubmitEdit($oTopic); } else { /** * Заполняем поля формы для редактирования * Только перед отправкой формы! */ $_REQUEST['topic_title'] = $oTopic->getTitle(); $_REQUEST['topic_text'] = $oTopic->getTextSource(); $_REQUEST['topic_tags'] = $oTopic->getTags(); $_REQUEST['blog_id'] = $oTopic->getBlogId(); $_REQUEST['topic_id'] = $oTopic->getId(); $_REQUEST['topic_publish_index'] = $oTopic->getPublishIndex(); $_REQUEST['topic_forbid_comment'] = $oTopic->getForbidComment(); $_REQUEST['answer'] = array(); $aAnswers = $oTopic->getQuestionAnswers(); foreach ($aAnswers as $aAnswer) { $_REQUEST['answer'][] = $aAnswer['text']; } } }
/** * Добавление топика * */ protected function EventAdd() { $sTopicType = $this->GetParam(0); $iBlogId = (int) getRequest('blog_id'); if (!($oTopicType = $this->Topic_GetTopicType($sTopicType))) { return parent::EventNotFound(); } /** * Проверяем права на создание топика */ if (!$this->ACL_CanAddTopic($this->oUserCurrent, $oTopicType)) { $this->Message_AddErrorSingle($this->Rbac_GetMsgLast()); return Router::Action('error'); } $this->sMenuSubItemSelect = $sTopicType; /** * Получаем доступные блоги по типам */ $aBlogs = array(); $aBlogs['open'] = $this->Blog_GetBlogsByType('open'); /** * Убираем из списка блоги в которые не доступен постинг */ foreach ($aBlogs['open'] as $k => $oBlogOpen) { if (!$this->ACL_IsAllowBlog($oBlogOpen, $this->oUserCurrent)) { unset($aBlogs['open'][$k]); } } if ($this->oUserCurrent->isAdministrator()) { $aBlogs['close'] = $this->Blog_GetBlogsByType('close'); } else { $aBlogs['close'] = $this->Blog_GetBlogsByTypeAndUserId('close', $this->oUserCurrent->getId()); } /** * Вызов хуков */ $this->Hook_Run('topic_add_show', array('aBlogs' => &$aBlogs)); /** * Проверяем на отсутствие блогов */ $bSkipBlogs = true; foreach ($aBlogs as $aBlogsType) { if ($aBlogsType) { $bSkipBlogs = false; } } /** * Загружаем переменные в шаблон */ $this->Viewer_Assign('topicType', $oTopicType); $this->Viewer_Assign('blogsAllow', $aBlogs); $this->Viewer_Assign('skipBlogs', $bSkipBlogs); $this->Viewer_Assign('blogId', $iBlogId); $this->Viewer_AddHtmlTitle($this->Lang_Get('topic.add.title.add')); $this->SetTemplateAction('add'); }
/** * Выводит список комментариев которые написал юзер * */ protected function EventComments() { /** * Получаем логин из УРЛа */ $sUserLogin = $this->sCurrentEvent; /** * Проверяем есть ли такой юзер */ if (!($this->oUserProfile = $this->User_GetUserByLogin($sUserLogin))) { return parent::EventNotFound(); } /** * Передан ли номер страницы */ $iPage = $this->GetParamEventMatch(1, 2) ? $this->GetParamEventMatch(1, 2) : 1; /** * Получаем список комментов */ $aResult = $this->Comment_GetCommentsByUserId($this->oUserProfile->getId(), 'topic', $iPage, Config::Get('module.comment.per_page')); $aComments = $aResult['collection']; /** * Формируем постраничность */ $aPaging = $this->Viewer_MakePaging($aResult['count'], $iPage, Config::Get('module.comment.per_page'), 4, Router::GetPath('my') . $this->oUserProfile->getLogin() . '/comment'); /** * Загружаем переменные в шаблон */ $this->Viewer_Assign('aPaging', $aPaging); $this->Viewer_Assign('aComments', $aComments); $this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_publication') . ' ' . $this->oUserProfile->getLogin()); $this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_publication_comment')); /** * Устанавливаем шаблон вывода */ $this->SetTemplateAction('comment'); }
/** * Переход по ссылке с подсчетом количества переходов * */ protected function EventGo() { // * Получаем номер топика из УРЛ и проверяем существует ли он $iTopicId = intval($this->GetParam(0)); if (!$iTopicId || !($oTopic = E::ModuleTopic()->GetTopicById($iTopicId)) || !$oTopic->getPublish()) { return parent::EventNotFound(); } // * проверяем есть ли ссылка на источник if (!$oTopic->getSourceLink()) { return parent::EventNotFound(); } // * увелививаем число переходов по ссылке $oTopic->setSourceLinkCountJump($oTopic->getSourceLinkCountJump() + 1); E::ModuleTopic()->UpdateTopic($oTopic); // * собственно сам переход по ссылке R::Location($oTopic->getSourceLink()); }
/** * Показывает юзеров по городу * */ protected function EventCity() { $this->sMenuItemSelect = 'city'; // Город существует? if (!($oCity = E::ModuleGeo()->GetCityById($this->getParam(0)))) { return parent::EventNotFound(); } // Получаем статистику $this->GetStats(); // Передан ли номер страницы $iPage = $this->GetParamEventMatch(1, 2) ? $this->GetParamEventMatch(1, 2) : 1; // Получаем список юзеров $aResult = E::ModuleGeo()->GetTargets(array('city_id' => $oCity->getId(), 'target_type' => 'user'), $iPage, Config::Get('module.user.per_page')); $aUsersId = array(); foreach ($aResult['collection'] as $oTarget) { $aUsersId[] = $oTarget->getTargetId(); } $aUsersCity = E::ModuleUser()->GetUsersAdditionalData($aUsersId); // Формируем постраничность $aPaging = E::ModuleViewer()->MakePaging($aResult['count'], $iPage, Config::Get('module.user.per_page'), Config::Get('pagination.pages.count'), R::GetPath('people') . $this->sCurrentEvent . '/' . $oCity->getId()); // Загружаем переменные в шаблон if ($aUsersCity) { E::ModuleViewer()->Assign('aPaging', $aPaging); } E::ModuleViewer()->Assign('oCity', $oCity); E::ModuleViewer()->Assign('aUsersCity', $aUsersCity); }
/** * Удаление топика * */ protected function EventDelete() { $this->Security_ValidateSendForm(); /** * Получаем номер топика из УРЛ и проверяем существует ли он */ $sTopicId = $this->GetParam(0); if (!($oTopic = $this->Topic_GetTopicById($sTopicId))) { return parent::EventNotFound(); } /** * проверяем есть ли право на удаление топика */ if (!$this->ACL_IsAllowDeleteTopic($oTopic, $this->oUserCurrent)) { return parent::EventNotFound(); } /** * Удаляем топик */ $this->Hook_Run('topic_delete_before', array('oTopic' => $oTopic)); $this->Topic_DeleteTopic($oTopic); $this->Hook_Run('topic_delete_after', array('oTopic' => $oTopic)); /** * Перенаправляем на страницу со списком топиков из блога этого топика */ Router::Location($oTopic->getBlog()->getUrlFull()); }
/** * Обработка подтверждения нового емайла при смене старого */ public function EventChangemailConfirmTo() { if (!($oChangemail = $this->User_GetUserChangemailByCodeTo($this->GetParamEventMatch(1, 0)))) { return parent::EventNotFound(); } if (!$oChangemail->getConfirmFrom() or $oChangemail->getConfirmTo() or strtotime($oChangemail->getDateExpired()) < time()) { return parent::EventNotFound(); } $oChangemail->setConfirmTo(1); $oChangemail->setDateUsed(date("Y-m-d H:i:s")); $this->User_UpdateUserChangemail($oChangemail); $oUser = $this->User_GetUserById($oChangemail->getUserId()); $oUser->setMail($oChangemail->getMailTo()); $this->User_Update($oUser); $this->Viewer_Assign('oAceUserProfile', $this->PluginAceadminpanel_Admin_GetUserByLogin($this->oUserProfile->getLogin())); $this->Viewer_Assign('sText', $this->Lang_Get('settings_profile_mail_change_ok', array('mail' => htmlspecialchars($oChangemail->getMailTo())))); $this->SetTemplateAction('changemail_confirm'); }
/** * Выводит список комментариев которые написал юзер * Перенаправляет на профиль пользователя * */ 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); }
protected function EventDeleteField() { $this->sMainMenuItem = 'settings'; E::ModuleSecurity()->ValidateSendForm(); $iContentFieldId = intval($this->GetParam(0)); if (!$iContentFieldId) { return parent::EventNotFound(); } $oField = E::ModuleTopic()->GetContentFieldById($iContentFieldId); if ($oField) { $oContentType = E::ModuleTopic()->GetContentTypeById($oField->getContentId()); } else { $oContentType = null; } if (E::ModuleTopic()->DeleteField($iContentFieldId)) { E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('action.admin.contenttypes_success_fielddelete'), null, true); if ($oContentType) { R::Location('admin/settings-contenttypes/edit/' . $oContentType->getContentId() . '/'); } else { R::Location('admin/settings-contenttypes/'); } } return false; }
/** * Вывод RSS топиков из персонального блога или всех персональных */ protected function RssPersonalBlog() { $this->sUserLogin = $this->GetParam(0); if (!$this->sUserLogin) { /** * RSS-лента всех записей из персональных блогов */ $aResult = $this->Topic_GetTopicsPersonal(1, Config::Get('module.topic.per_page') * 2); } elseif (!($oUser = $this->User_GetUserByLogin($this->sUserLogin))) { return parent::EventNotFound(); } else { /** * RSS-лента записей персонального блога указанного пользователя */ $aResult = $this->Topic_GetTopicsPersonalByUser($oUser->getId(), 1, 1, Config::Get('module.topic.per_page') * 2); } $aTopics = $aResult['collection']; /** * Формируем данные канала RSS */ $aChannel['title'] = Config::Get('view.name'); $aChannel['link'] = Config::Get('path.root.web'); $aChannel['description'] = $this->sUserLogin ? Config::Get('path.root.web') . ' / ' . $oUser->getLogin() . ' / RSS channel' : 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 */ $topics = array(); foreach ($aTopics as $oTopic) { $item['title'] = $oTopic->getTitle(); $item['guid'] = $oTopic->getUrl(); $item['link'] = $oTopic->getUrl(); $item['description'] = $this->getTopicText($oTopic); $item['pubDate'] = $oTopic->getDateAdd(); $item['author'] = $oTopic->getUser()->getLogin(); $item['category'] = htmlspecialchars($oTopic->getTags()); $topics[] = $item; } /** * Формируем ответ */ $this->InitRss(); $this->Viewer_Assign('aChannel', $aChannel); $this->Viewer_Assign('aItems', $topics); $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()); } }
/** * Показ и обработка формы приглаешний * * @return unknown */ protected function EventInvite() { if (!Config::Get('general.reg.invite')) { return parent::EventNotFound(); } $this->sMenuItemSelect = 'invite'; $this->sMenuSubItemSelect = ''; $this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_invite')); if (isPost('submit_invite')) { $this->Security_ValidateSendForm(); $bError = false; if (!$this->ACL_CanSendInvite($this->oUserCurrent) and !$this->oUserCurrent->isAdministrator()) { $this->Message_AddError($this->Lang_Get('settings_invite_available_no'), $this->Lang_Get('error')); $bError = true; } if (!func_check(getRequest('invite_mail'), 'mail')) { $this->Message_AddError($this->Lang_Get('settings_invite_mail_error'), $this->Lang_Get('error')); $bError = true; } if (!$bError) { $oInvite = $this->User_GenerateInvite($this->oUserCurrent); $this->Notify_SendInvite($this->oUserCurrent, getRequest('invite_mail'), $oInvite); $this->Message_AddNoticeSingle($this->Lang_Get('settings_invite_submit_ok')); } } $this->Viewer_Assign('iCountInviteAvailable', $this->User_GetCountInviteAvailable($this->oUserCurrent)); $this->Viewer_Assign('iCountInviteUsed', $this->User_GetCountInviteUsed($this->oUserCurrent->getId())); }
/** * Обработка кода приглашения при включеном режиме инвайтов * */ protected function EventInvite() { if (!Config::Get('general.reg.invite')) { return parent::EventNotFound(); } // Обработка отправки формы с кодом приглашения if (F::isPost('submit_invite')) { // проверяем код приглашения на валидность if ($this->CheckInviteRegister()) { $sInviteCode = $this->GetInviteRegister(); } else { $sInviteCode = trim(F::GetRequestStr('invite_code')); } $oInvite = E::ModuleUser()->GetInviteByCode($sInviteCode); if ($oInvite) { if (!$this->CheckInviteRegister()) { E::ModuleSession()->Set('invite_code', $oInvite->getCode()); } return R::Action('registration'); } else { E::ModuleMessage()->AddError(E::ModuleLang()->Get('registration_invite_code_error'), E::ModuleLang()->Get('error')); } } }
/** * Чтение письма * TODO: Пагинация для комментов не передается */ protected function EventRead() { $this->sMenuSubItemSelect = 'read'; /** * Получаем номер сообщения из УРЛ и проверяем существует ли оно */ $sTalkId = $this->GetParam(0); if (!($oTalk = $this->Talk_GetTalkById($sTalkId))) { return parent::EventNotFound(); } /** * Пользователь есть в переписке? */ if (!($oTalkUser = $this->Talk_GetTalkUser($oTalk->getId(), $this->oUserCurrent->getId()))) { return parent::EventNotFound(); } /** * Пользователь активен в переписке? */ if ($oTalkUser->getUserActive() != ModuleTalk::TALK_USER_ACTIVE) { return parent::EventNotFound(); } /** * Достаём комменты к сообщению */ $aReturn = $this->Comment_GetCommentsByTargetId($oTalk->getId(), 'talk'); $iMaxIdComment = $aReturn['iMaxIdComment']; $aComments = $aReturn['comments']; /** * Помечаем дату последнего просмотра */ $oTalkUser->setDateLast(date("Y-m-d H:i:s")); $oTalkUser->setCommentIdLast($iMaxIdComment); $oTalkUser->setCommentCountNew(0); $this->Talk_UpdateTalkUser($oTalkUser); $this->Viewer_AddHtmlTitle($oTalk->getTitle()); $this->Viewer_Assign('talk', $oTalk); $this->Viewer_Assign('comments', $aComments); $this->Viewer_Assign('lastCommentId', $iMaxIdComment); /** * Подсчитываем нужно ли отображать комментарии. * Комментарии не отображаются, если у вестки только один читатель * и ранее созданных комментариев нет. */ if (count($aComments) == 0) { $iActiveSpeakers = 0; foreach ((array) $oTalk->getTalkUsers() as $oTalkUser) { if ($oTalkUser->getUserId() != $this->oUserCurrent->getId() && $oTalkUser->getUserActive() == ModuleTalk::TALK_USER_ACTIVE) { $iActiveSpeakers++; break; } } if ($iActiveSpeakers == 0) { $this->Viewer_Assign('bNoComments', true); } } $this->SetTemplateAction('talk'); }
/** * Редактирование топика-ссылки * */ protected function EventEdit() { /** * Проверяем авторизован ли юзер */ if (!$this->User_IsAuthorization()) { $this->Message_AddErrorSingle($this->Lang_Get('not_access'), $this->Lang_Get('error')); return Router::Action('error'); } /** * Получаем номер топика из УРЛ и проверяем существует ли он */ $sTopicId = $this->GetParam(0); if (!($oTopic = $this->Topic_GetTopicById($sTopicId))) { return parent::EventNotFound(); } /** * Проверяем тип топика */ if ($oTopic->getType() != 'link') { return parent::EventNotFound(); } /** * Если права на редактирование */ if (!$this->ACL_IsAllowEditTopic($oTopic, $this->oUserCurrent)) { return parent::EventNotFound(); } /** * Вызов хуков */ $this->Hook_Run('topic_edit_show', array('oTopic' => $oTopic)); /** * Загружаем переменные в шаблон */ $this->Viewer_Assign('aBlogsAllow', $this->Blog_GetBlogsAllowByUser($this->oUserCurrent)); $this->Viewer_AddHtmlTitle($this->Lang_Get('topic_link_title_edit')); /** * Устанавливаем шаблон вывода */ $this->SetTemplateAction('add'); /** * Проверяем отправлена ли форма с данными(хотяб одна кнопка) */ if (isset($_REQUEST['submit_topic_publish']) or isset($_REQUEST['submit_topic_save'])) { /** * Обрабатываем отправку формы */ return $this->SubmitEdit($oTopic); } else { /** * Заполняем поля формы для редактирования * Только перед отправкой формы! */ $_REQUEST['topic_title'] = $oTopic->getTitle(); $_REQUEST['topic_link_url'] = $oTopic->getLinkUrl(); $_REQUEST['topic_text'] = $oTopic->getTextSource(); $_REQUEST['topic_tags'] = $oTopic->getTags(); $_REQUEST['blog_id'] = $oTopic->getBlogId(); $_REQUEST['topic_id'] = $oTopic->getId(); $_REQUEST['topic_publish_index'] = $oTopic->getPublishIndex(); $_REQUEST['topic_forbid_comment'] = $oTopic->getForbidComment(); } }
/** * Удаление блога * * @return bool */ protected function EventDeleteBlog() { $this->Security_ValidateSendForm(); /** * Проверяем передан ли в УРЛе номер блога */ $sBlogId = $this->GetParam(0); if (!($oBlog = $this->Blog_GetBlogById($sBlogId))) { return parent::EventNotFound(); } /** * Проверям авторизован ли пользователь */ if (!$this->User_IsAuthorization()) { $this->Message_AddErrorSingle($this->Lang_Get('not_access'), $this->Lang_Get('error')); return Router::Action('error'); } /** * проверяем есть ли право на удаление топика */ if (!($bAccess = $this->ACL_IsAllowDeleteBlog($oBlog, $this->oUserCurrent))) { return parent::EventNotFound(); } $aTopics = $this->Topic_GetTopicsByBlogId($sBlogId); switch ($bAccess) { case ModuleACL::CAN_DELETE_BLOG_EMPTY_ONLY: if (is_array($aTopics) and count($aTopics)) { $this->Message_AddErrorSingle($this->Lang_Get('blog_admin_delete_not_empty'), $this->Lang_Get('error'), true); Router::Location($oBlog()->getUrlFull()); } break; case ModuleACL::CAN_DELETE_BLOG_WITH_TOPICS: /** * Если указан идентификатор блога для перемещения, * то делаем попытку переместить топики. * * (-1) - выбран пункт меню "удалить топики". */ if ($sBlogIdNew = getRequest('topic_move_to') and $sBlogIdNew != -1 and is_array($aTopics) and count($aTopics)) { if (!($oBlogNew = $this->Blog_GetBlogById($sBlogIdNew))) { $this->Message_AddErrorSingle($this->Lang_Get('blog_admin_delete_move_error'), $this->Lang_Get('error'), true); Router::Location($oBlog()->getUrlFull()); } /** * Если выбранный блог является персональным, возвращаем ошибку */ if ($oBlogNew->getType() == 'personal') { $this->Message_AddErrorSingle($this->Lang_Get('blog_admin_delete_move_personal'), $this->Lang_Get('error'), true); Router::Location($oBlog()->getUrlFull()); } /** * Перемещаем топики */ $this->Topic_MoveTopics($sBlogId, $sBlogIdNew); } break; default: return parent::EventNotFound(); } /** * Удаляяем блог и перенаправляем пользователя к списку блогов */ $this->Hook_Run('blog_delete_before', array('sBlogId' => $sBlogId)); if ($this->Blog_DeleteBlog($sBlogId)) { $this->Hook_Run('blog_delete_after', array('sBlogId' => $sBlogId)); $this->Message_AddNoticeSingle($this->Lang_Get('blog_admin_delete_success'), $this->Lang_Get('attention'), true); Router::Location(Router::GetPath('blogs')); } else { Router::Location($oBlog()->getUrlFull()); } }
/** * Отписка от пользователя * */ 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')); }