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');
     }
 }
 /**
  * Обработка отправки формы при редактировании форума
  *
  * @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/');
     }
 }