Пример #1
0
 public function executeComponent()
 {
     try {
         /*
         			if (IsModuleInstalled("disk"))
         			{
         				\Bitrix\Disk\Internals\Diag::getInstance()
         //					->setExclusiveUserId(45)
         					->setEnableTimeTracker(true)
         					->setMemoryBehavior(\Bitrix\Disk\Internals\Diag::MEMORY_PRINT_DIFF)
         					->setSqlBehavior(\Bitrix\Disk\Internals\Diag::SQL_COUNT)
         					->collectDebugInfo($this->componentId, $this->getName());
         			}
         */
         $this->checkRequiredParams();
         $this->feed = new \Bitrix\Forum\Comments\Feed($this->arParams["FORUM_ID"], array("type" => $this->arParams["ENTITY_TYPE"], "id" => $this->arParams["ENTITY_ID"], "xml_id" => $this->arParams["ENTITY_XML_ID"]));
         $this->forum = $this->feed->getForum();
         if (array_key_exists("PERMISSION", $this->arParams)) {
             $this->feed->setPermission($this->arParams["PERMISSION"]);
         }
         if (array_key_exists("ALLOW_EDIT_OWN_MESSAGE", $this->arParams)) {
             $this->feed->setEditOwn($this->arParams["ALLOW_EDIT_OWN_MESSAGE"] == "ALL" || $this->arParams["ALLOW_EDIT_OWN_MESSAGE"] === "LAST");
         }
         $this->arParams["ALLOW_EDIT_OWN_MESSAGE"] = $this->feed->getEntity()->canEditOwn() ? "ALL" : "N";
         if (!$this->errorCollection->hasErrors() && $this->feed->canRead()) {
             $this->bindObjects();
             $this->prepareParams();
             foreach (GetModuleEvents('forum', 'OnCommentsInit', true) as $arEvent) {
                 ExecuteModuleEventEx($arEvent, array(&$this));
             }
             if (!$this->checkPreview() && $this->checkActions() === false) {
                 foreach (GetModuleEvents('forum', 'OnCommentError', true) as $arEvent) {
                     ExecuteModuleEventEx($arEvent, array(&$this));
                 }
             }
             ob_start();
             $this->__includeComponent();
             $output = ob_get_clean();
             foreach (GetModuleEvents('forum', 'OnCommentsDisplayTemplate', true) as $arEvent) {
                 ExecuteModuleEventEx($arEvent, array(&$output, $this->arParams, $this->arResult));
             }
             echo $output;
         } else {
             $this->showError();
         }
         if (IsModuleInstalled("disk")) {
             \Bitrix\Disk\Internals\Diag::getInstance()->logDebugInfo($this->componentId, $this->getName());
         }
     } catch (Exception $e) {
         $this->handleException($e);
     }
 }
Пример #2
0
 /**
  * Creates new
  * @param Feed $feed
  * @param $id
  * @return Comment
  */
 public static function create(Feed $feed)
 {
     $forum = $feed->getForum();
     return new Comment($forum["ID"], $feed->getEntity()->getFullId());
 }
Пример #3
0
 /**
  * Creates new
  * @param Feed $feed
  * @param $id
  * @return Comment
  */
 public static function create(Feed $feed)
 {
     $forum = $feed->getForum();
     $comment = new Comment($forum["ID"], $feed->getEntity()->getFullId());
     $comment->getEntity()->setPermission($feed->getEntity()->getPermission());
     return $comment;
 }