コード例 #1
0
ファイル: Topic.class.php プロジェクト: AlexSSN/altocms
 /**
  * Обновляет топик
  *
  * @param ModuleTopic_EntityContentType $oContentType    Объект типа контента
  *
  * @return bool
  */
 public function DeleteContentType($oContentType)
 {
     $aFilter = array('topic_type' => $oContentType->getContentUrl());
     $iCount = $this->GetCountTopicsByFilter($aFilter);
     if (!$iCount && $this->oMapper->DeleteContentType($oContentType->getId())) {
         //чистим зависимые кеши
         E::ModuleCache()->CleanByTags(array('content_new', 'content_update', 'topic_update'));
         E::ModuleCache()->Delete("content_type_{$oContentType->getId()}");
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * Добавление топика
  *
  * @return mixed
  */
 protected function EventAdd()
 {
     // * Устанавливаем шаблон вывода
     $this->SetTemplateAction('add');
     E::ModuleViewer()->Assign('sMode', 'add');
     // * Вызов хуков
     E::ModuleHook()->Run('topic_add_show');
     // * Получаем тип контента
     if (!($this->oContentType = E::ModuleTopic()->GetContentTypeByUrl($this->sCurrentEvent))) {
         if (!($this->oContentType = E::ModuleTopic()->GetContentTypeDefault())) {
             return parent::EventNotFound();
         }
     }
     E::ModuleViewer()->Assign('oContentType', $this->oContentType);
     $this->sMenuSubItemSelect = $this->oContentType->getContentUrl();
     // * Если тип контента не доступен текущему юзеру
     if (!$this->oContentType->isAccessible()) {
         return parent::EventNotFound();
     }
     $aBlogFilter = array('user' => $this->oUserCurrent, 'content_type' => $this->oContentType);
     $aBlogsAllow = $this->_getAllowBlogs($aBlogFilter);
     // Такой тип контента не разрешен для пользователя ни в одном из типов блогов
     if (!$aBlogsAllow) {
         return parent::EventNotFound();
     }
     // Проверим можно ли писать в персональный блог такой тип контента
     /** @var ModuleBlog_EntityBlog $oAllowedBlog */
     $this->bPersonalBlogEnabled = FALSE;
     foreach ($aBlogsAllow as $oAllowedBlog) {
         // Нашли среди разрешенных персональный блог
         if ($oAllowedBlog->getType() == 'personal') {
             if (!$oAllowedBlog->getBlogType()->getContentTypes()) {
                 // типы контента не определены, значит, разрешен любой
                 $this->bPersonalBlogEnabled = TRUE;
             } else {
                 foreach ($oAllowedBlog->getBlogType()->getContentTypes() as $oContentType) {
                     if ($oContentType->getId() == $this->oContentType->getId()) {
                         $this->bPersonalBlogEnabled = TRUE;
                         break;
                     }
                 }
             }
             break;
         }
     }
     // * Загружаем переменные в шаблон
     E::ModuleViewer()->Assign('bPersonalBlog', $this->bPersonalBlogEnabled);
     E::ModuleViewer()->Assign('aBlogsAllow', $aBlogsAllow);
     E::ModuleViewer()->Assign('bEditDisabled', false);
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('topic_topic_create') . ' ' . mb_strtolower($this->oContentType->getContentTitle(), 'UTF-8'));
     if (!is_numeric(F::GetRequest('topic_id'))) {
         $_REQUEST['topic_id'] = '';
     }
     $_REQUEST['topic_show_photoset'] = 1;
     // * Если нет временного ключа для нового топика, то генерируем; если есть, то загружаем фото по этому ключу
     if ($sTargetTmp = E::ModuleSession()->GetCookie('ls_photoset_target_tmp')) {
         E::ModuleSession()->SetCookie('ls_photoset_target_tmp', $sTargetTmp, 'P1D', false);
         E::ModuleViewer()->Assign('aPhotos', E::ModuleTopic()->GetPhotosByTargetTmp($sTargetTmp));
     } else {
         E::ModuleSession()->SetCookie('ls_photoset_target_tmp', F::RandomStr(), 'P1D', false);
     }
     // Если POST-запрос, то обрабатываем отправку формы
     if ($this->IsPost()) {
         return $this->SubmitAdd();
     }
     return null;
 }