Esempio n. 1
0
 /**
  * Обработка отправки формы при редактировании страницы
  *
  * @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 $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');
     }
 }
Esempio n. 3
0
 /**
  * Обработка редактирования топика
  *
  * @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');
     }
 }