/** * Имплементация метода, создающего сообщение * * @return DiscussionMsg созданное сообщение */ public final function saveMessageImpl($threadId, $parentId, $text, $theme, $templateId, $templateData, PsUser $author) { $threadId = $this->validateThreadId($threadId); $unique = $this->SETTINGS->getUnique(); check_condition($templateId === null || is_integer($templateId), "Код шаблона [{$templateId}] должен быть целочисленным"); check_condition($templateId === null || $this->SETTINGS->isTemplatable(), "Дискуссия [{$unique}] не работает с шаблонными сообщениями"); /* @var $parent DiscussionMsg */ $parent = is_numeric($parentId) ? $this->getMsgById($parentId) : null; $checkThreadId = $parent ? $this->validateThreadId($parent->getThreadId()) : $threadId; check_condition($threadId === $checkThreadId, "Не совпадают коды тредов: [{$threadId}]!=[{$checkThreadId}]"); if ($parent) { check_condition(!$parent->isDeleted(), 'Родительское сообщение удалено.'); check_condition(!$parent->isMaxDeepLevel(), 'Достигнут максимальный уровень вложенности.'); } $this->assertCanSaveDiscussionMsg($author, $parent, $threadId); $idUserTo = $parent ? $parent->getUser()->getId() : AuthManager::validateUserIdOrNull($this->getIdUserTo4Root($author, $threadId)); $userTo = is_integer($idUserTo) ? PsUser::inst($idUserTo, true) : null; return $this->BEAN->saveMsg($threadId, $text, $theme, $templateId, $templateData, $author, $userTo, $parent); }
public function isTemplated() { return $this->SETTINGS->isTemplatable() && is_numeric($this->id_template); }