/** * Обработка отправки формы при редактировании страницы * * @param unknown_type $oPageEdit */ protected function EventPagesEditSubmit($oPageEdit) { $this->Security_ValidateSendForm(); // * Проверяем корректность полей if (!$this->EventPagesCheckFields()) { return; } if ($oPageEdit->getId() == getRequest('page_pid')) { $this->_messageError($this->Lang_Get('system_error'), 'page:edit'); return; } // * Обновляем свойства страницы $oPageEdit->setAutoBr(getRequest('page_auto_br') ? 1 : 0); $oPageEdit->setActive(getRequest('page_active') ? 1 : 0); $oPageEdit->setMain(getRequest('page_main') ? 1 : 0); $oPageEdit->setDateEdit(date("Y-m-d H:i:s")); if (getRequest('page_pid') == 0) { $oPageEdit->setUrlFull(getRequest('page_url')); $oPageEdit->setPid(null); } else { $oPageEdit->setPid(getRequest('page_pid')); $oPageParent = $this->PluginPage_Page_GetPageById(getRequest('page_pid')); $oPageEdit->setUrlFull($oPageParent->getUrlFull() . '/' . getRequest('page_url')); } $oPageEdit->setSeoDescription(getRequest('page_seo_description')); $oPageEdit->setSeoKeywords(getRequest('page_seo_keywords')); $oPageEdit->setText(getRequest('page_text')); $oPageEdit->setTitle(getRequest('page_title')); $oPageEdit->setUrl(getRequest('page_url')); $oPageEdit->setSort(intval(getRequest('page_sort'))); $oPageEdit->setOtherUrl(getRequest('page_other_url')); // * Обновляем страницу if ($this->PluginPage_Page_UpdatePage($oPageEdit)) { $this->PluginPage_Page_RebuildUrlFull($oPageEdit); $this->_messageNotice($this->Lang_Get('page_edit_submit_save_ok'), 'page:edit'); $this->SetParam(0, null); $this->SetParam(1, null); } else { $this->_messageError($this->Lang_Get('system_error'), 'page:edit'); } }
/** * Обработка редактирования топика * * @param unknown_type $oTopic * @return unknown */ protected function SubmitEdit($oTopic) { /** * Проверка корректности полей формы */ if (!$this->checkTopicFields()) { return false; } /** * Определяем в какой блог делаем запись */ $iBlogId = getRequest('blog_id'); if ($iBlogId == 0) { $oBlog = $this->Blog_GetPersonalBlogByUserId($oTopic->getUserId()); } else { $oBlog = $this->Blog_GetBlogById($iBlogId); } /** * Если блог не определен выдаем предупреждение */ if (!$oBlog) { $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_unknown'), $this->Lang_Get('error')); return false; } /** * Проверяем права на постинг в блог */ if (!$this->ACL_IsAllowBlog($oBlog, $this->oUserCurrent)) { $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'), $this->Lang_Get('error')); return false; } /** * Проверяем разрешено ли постить топик по времени */ if (isPost('submit_topic_publish') and !$oTopic->getPublishDraft() and !$this->ACL_CanPostTopicTime($this->oUserCurrent)) { $this->Message_AddErrorSingle($this->Lang_Get('topic_time_limit'), $this->Lang_Get('error')); return; } /** * Сохраняем старое значение идентификатора блога */ $sBlogIdOld = $oTopic->getBlogId(); /** * Теперь можно смело редактировать топик */ $oTopic->setBlogId($oBlog->getId()); $oTopic->setTitle(getRequest('topic_title')); $oTopic->setText(htmlspecialchars(getRequest('topic_text'))); $oTopic->setTextShort(htmlspecialchars(getRequest('topic_text'))); $oTopic->setTextSource(getRequest('topic_text')); $oTopic->setLinkUrl(getRequest('topic_link_url')); $oTopic->setTags(getRequest('topic_tags')); $oTopic->setUserIp(func_getIp()); $oTopic->setTextHash(md5($oTopic->getType() . $oTopic->getText() . $oTopic->getLinkUrl())); /** * Проверяем топик на уникальность */ if ($oTopicEquivalent = $this->Topic_GetTopicUnique($this->oUserCurrent->getId(), $oTopic->getTextHash())) { if ($oTopicEquivalent->getId() != $oTopic->getId()) { $this->Message_AddErrorSingle($this->Lang_Get('topic_create_text_error_unique'), $this->Lang_Get('error')); return false; } } /** * Публикуем или сохраняем в черновиках */ $bSendNotify = false; if (isset($_REQUEST['submit_topic_publish'])) { $oTopic->setPublish(1); if ($oTopic->getPublishDraft() == 0) { $oTopic->setPublishDraft(1); $oTopic->setDateAdd(date("Y-m-d H:i:s")); $bSendNotify = true; } } else { $oTopic->setPublish(0); } /** * Принудительный вывод на главную */ if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) { if (getRequest('topic_publish_index')) { $oTopic->setPublishIndex(1); } else { $oTopic->setPublishIndex(0); } } /** * Запрет на комментарии к топику */ $oTopic->setForbidComment(0); if (getRequest('topic_forbid_comment')) { $oTopic->setForbidComment(1); } $this->Hook_Run('topic_edit_before', array('oTopic' => $oTopic, 'oBlog' => $oBlog)); /** * Сохраняем топик */ if ($this->Topic_UpdateTopic($oTopic)) { $this->Hook_Run('topic_edit_after', array('oTopic' => $oTopic, 'oBlog' => $oBlog, 'bSendNotify' => &$bSendNotify)); /** * Обновляем данные в комментариях, если топик был перенесен в новый блог */ if ($sBlogIdOld != $oTopic->getBlogId()) { $this->Comment_UpdateTargetParentByTargetId($oTopic->getBlogId(), 'topic', $oTopic->getId()); $this->Comment_UpdateTargetParentByTargetIdOnline($oTopic->getBlogId(), 'topic', $oTopic->getId()); } /** * Обновляем количество топиков в блоге */ if ($sBlogIdOld != $oTopic->getBlogId()) { $this->Blog_RecalculateCountTopicByBlogId($sBlogIdOld); } $this->Blog_RecalculateCountTopicByBlogId($oTopic->getBlogId()); /** * Добавляем событие в ленту */ $this->Stream_write($oTopic->getUserId(), 'add_topic', $oTopic->getId(), $oTopic->getPublish() && $oBlog->getType() != 'close'); /** * Рассылаем о новом топике подписчикам блога */ if ($bSendNotify) { $this->Topic_SendNotifyTopicNew($oBlog, $oTopic, $this->oUserCurrent); } if (!$oTopic->getPublish() and !$this->oUserCurrent->isAdministrator() and $this->oUserCurrent->getId() != $oTopic->getUserId()) { Router::Location($oBlog->getUrlFull()); } Router::Location($oTopic->getUrl()); } else { $this->Message_AddErrorSingle($this->Lang_Get('system_error')); return Router::Action('error'); } }
/** * Обработка отправки формы при редактировании страницы * * @param unknown_type $oPageEdit */ protected function SubmitEditPage($oPageEdit) { /** * Проверяем корректность полей */ if (!$this->CheckPageFields()) { return; } if ($oPageEdit->getId() == getRequest('page_pid')) { $this->Message_AddError($this->Lang_Get('system_error')); return; } /** * Обновляем свойства страницы */ $oPageEdit->setActive(getRequest('page_active') ? 1 : 0); $oPageEdit->setAutoBr(getRequest('page_auto_br') ? 1 : 0); $oPageEdit->setMain(getRequest('page_main') ? 1 : 0); $oPageEdit->setDateEdit(date("Y-m-d H:i:s")); if (getRequest('page_pid') == 0) { $oPageEdit->setUrlFull(getRequest('page_url')); $oPageEdit->setPid(null); } else { $oPageEdit->setPid(getRequest('page_pid')); $oPageParent = $this->PluginPage_Page_GetPageById(getRequest('page_pid')); $oPageEdit->setUrlFull($oPageParent->getUrlFull() . '/' . getRequest('page_url')); } $oPageEdit->setSeoDescription(getRequest('page_seo_description')); $oPageEdit->setSeoKeywords(getRequest('page_seo_keywords')); $oPageEdit->setText(getRequest('page_text')); $oPageEdit->setTitle(getRequest('page_title')); $oPageEdit->setUrl(getRequest('page_url')); $oPageEdit->setSort(getRequest('page_sort')); /** * Обновляем страницу */ if ($this->PluginPage_Page_UpdatePage($oPageEdit)) { $this->PluginPage_Page_RebuildUrlFull($oPageEdit); $this->Message_AddNotice($this->Lang_Get('plugin.page.edit_submit_save_ok')); $this->SetParam(0, null); $this->SetParam(1, null); } else { $this->Message_AddError($this->Lang_Get('system_error')); } }
/** * Обработка отправки формы при редактировании форума * * @param unknown_type $oForum */ protected function submitEditForum($oForum = null) { $sNewType = isPost('f_type') ? getRequestStr('f_type') : 'forum'; /** * Обновляем свойства форума */ $oForum->setTitle(forum_parse_title(getRequestStr('forum_title'))); $oForum->setUrl(preg_replace("/\\s+/", '_', trim(getRequestStr('forum_url', '')))); if ($sNewType == 'category') { $oForum->setCanPost(1); } else { $oForum->setDescription(getRequestStr('forum_description')); $oForum->setParentId(getRequestStr('forum_parent')); $oForum->setType(getRequestStr('forum_type')); $oForum->setCanPost((int) getRequest('forum_sub_can_post', 0, 'post') === 1); $oForum->setQuickReply((int) getRequest('forum_quick_reply', 0, 'post') === 1); $oForum->setPassword(getRequestStr('forum_password')); $oForum->setSort(getRequestStr('forum_sort')); $oForum->setRedirectUrl(getRequestStr('forum_redirect_url')); if (isPost('forum_redirect_url')) { $oForum->setRedirectOn((int) getRequest('forum_redirect_on', 0, 'post') === 1); } $oForum->setLimitRatingTopic((double) getRequest('forum_limit_rating_topic')); /** * Опции */ if (isPost('forum_display_subforum_list')) { $oForum->setOptionsValue('display_subforum_list', (int) getRequest('forum_display_subforum_list', 0, 'post') === 1); } if (isPost('forum_display_on_index')) { $oForum->setOptionsValue('display_on_index', (int) getRequest('forum_display_on_index', 0, 'post') === 1); } if (isPost('forum_topics_per_page')) { $oForum->setOptionsValue('topics_per_page', getRequestStr('forum_topics_per_page')); } if (isPost('forum_posts_per_page')) { $oForum->setOptionsValue('posts_per_page', getRequestStr('forum_posts_per_page')); } /** * Копируем права доступа */ if (getRequest('forum_perms')) { if ($oCopyForum = $this->PluginForum_Forum_GetForumById(getRequestStr('forum_perms'))) { $oForum->setPermissions($oCopyForum->getPermissions()); } } /** * Загружаем иконку */ if (isset($_FILES['forum_icon']) && is_uploaded_file($_FILES['forum_icon']['tmp_name'])) { if ($sPath = $this->PluginForum_Forum_UploadIcon($_FILES['forum_icon'], $oForum)) { $oForum->setIcon($sPath); } else { $this->Message_AddError($this->Lang_Get('plugin.forum.create_icon_error'), $this->Lang_Get('error')); return false; } } /** * Удаляем иконку */ if (isset($_REQUEST['forum_icon_delete'])) { $this->PluginForum_Forum_DeleteIcon($oForum); $oForum->setIcon(null); } } /** * Проверяем корректность полей */ if (!$this->checkForumFields($oForum)) { return; } /** * Вызов хуков */ $this->Hook_Run('forum_edit_before', array('oForum' => $oForum)); /** * Сохраняем форум */ if ($this->PluginForum_Forum_SaveForum($oForum)) { $this->Hook_Run('forum_edit_after', array('oForum' => $oForum)); $this->Message_AddNotice($this->Lang_Get('plugin.forum.edit_ok'), null, 1); } else { $this->Message_AddError($this->Lang_Get('system_error'), null, 1); } if (isPost('submit_forum_save_next_perms')) { Router::Location(Router::GetPath('forum') . "admin/forums/perms/{$oForum->getId()}"); } else { Router::Location(Router::GetPath('forum') . 'admin/forums/'); } }