/** * @return bool */ public function canEdit() { $userId = $this->getUser()->getId(); // admin is always able to edit\remove comments if (Loader::includeModule("tasks") && (\CTasksTools::isAdmin($userId) || \CTasksTools::IsPortalB24Admin($userId))) { return true; } // if you are not an admin, you must obey "tasks" module settings if (!static::checkEditOptionIsOn()) { return false; } // you are not allowed to view the task, so you can not edit messages either (even own) if (!$this->checkHasAccess()) { return false; } // in all other ways - depends on "forum" module settings return parent::canEdit(); }
protected function setEntity(array $id) { if (is_array($id) && ($id = array_change_key_case($id, CASE_LOWER)) && $id["id"] > 0) { switch (strtolower($id["type"])) { case 'tk': $result = array(TaskEntity::className(), 'tasks'); break; default: $result = array(Entity::className(), 'forum'); break; } $this->entity = new $result[0]($id, $this); } else { if ($id instanceof TaskEntity || $id instanceof Entity) { $this->entity = $id; } else { throw new ArgumentException(Loc::getMessage("FORUM_CM_WRONG_ENTITY"), self::ERROR_PARAMS_ENTITY_ID); } } return $this; }