diff --git a/application/classes/modules/topic/Topic.class.php b/application/classes/modules/topic/Topic.class.php index 0b8e009a..66fea925 100644 --- a/application/classes/modules/topic/Topic.class.php +++ b/application/classes/modules/topic/Topic.class.php @@ -30,7 +30,7 @@ class ModuleTopic extends Module const TOPIC_TYPE_STATE_ACTIVE = 1; const TOPIC_TYPE_STATE_NOT_ACTIVE = 0; - + /** * Объект маппера * diff --git a/application/classes/modules/topic/entity/Topic.entity.class.php b/application/classes/modules/topic/entity/Topic.entity.class.php index 548adc5b..43435d6b 100644 --- a/application/classes/modules/topic/entity/Topic.entity.class.php +++ b/application/classes/modules/topic/entity/Topic.entity.class.php @@ -143,7 +143,8 @@ class ModuleTopic_EntityTopic extends Entity public function ValidatePublishDateCheck($aValue, $aParams) { $oTopicType = $this->getTypeObject(); - if ($oTopicType and ($oTopicType->getParam('allow_deferred_all') or ($oTopicType->getParam('allow_deferred_admin') and $oUser = $this->getUserCreator() and $oUser->isAdministrator()))) { + $oUser = $this->getUserCreator(); + if ($oTopicType and $oTopicType->isAllowCreateDeferredTopic($oUser)) { if ((!$this->getId() or !$this->getPublishDraft()) and isset($aValue['date']) and is_string($aValue['date']) and isset($aValue['time']) and is_string($aValue['time'])) { $sDateFull = $aValue['date'] . ' ' . $aValue['time']; if ($this->Validate_Validate('date', $sDateFull, array('format' => 'dd.MM.yyyy HH:mm', 'allowEmpty' => true))) { diff --git a/application/classes/modules/topic/entity/TopicType.entity.class.php b/application/classes/modules/topic/entity/TopicType.entity.class.php index 04942470..1b1bf1c2 100644 --- a/application/classes/modules/topic/entity/TopicType.entity.class.php +++ b/application/classes/modules/topic/entity/TopicType.entity.class.php @@ -135,4 +135,12 @@ class ModuleTopic_EntityTopicType extends Entity { return 'topic_' . $this->getCode(); } + + public function isAllowCreateDeferredTopic($oUser) + { + if (!$oUser) { + return false; + } + return $this->getParam('allow_deferred_all') or ($this->getParam('allow_deferred_admin') and $oUser->isAdministrator()); + } } \ No newline at end of file diff --git a/application/frontend/components/topic/topic-add.tpl b/application/frontend/components/topic/topic-add.tpl index 0fc664a3..1d70b2ec 100644 --- a/application/frontend/components/topic/topic-add.tpl +++ b/application/frontend/components/topic/topic-add.tpl @@ -132,7 +132,7 @@ targetId = ( $topic ) ? $topic->getId() : ''} {/if} - {if $type->getParam('allow_deferred_all') or ($type->getParam('allow_deferred_admin') and $oUserCurrent->isAdministrator())} + {if $type->isAllowCreateDeferredTopic($oUserCurrent)} {if !$topic or !$topic->getPublishDraft() or ($topic->getDatePublish() and strtotime($topic->getDatePublish()) > time())} {$iDatePublish = null} {if $topic}