public function __construct(CommentsTopic $comments_topic) { $this->module_id = $comments_topic->get_module_id(); $this->id_in_module = $comments_topic->get_id_in_module(); $this->topic_identifier = $comments_topic->get_topic_identifier(); $this->topic_path = $comments_topic->get_path(); $this->comments_topic = $comments_topic; $this->user = AppContext::get_current_user(); $this->lang = LangLoader::get('main'); $this->common_lang = LangLoader::get('common'); $this->comments_lang = LangLoader::get('comments-common'); $this->comments_configuration = CommentsConfig::load(); }
/** * @desc This function display the comments * @param class CommentsTopic $topic * @return Template is a template object */ public static function display(CommentsTopic $topic) { $module_id = $topic->get_module_id(); $id_in_module = $topic->get_id_in_module(); $topic_identifier = $topic->get_topic_identifier(); $authorizations = $topic->get_authorizations(); if (!$authorizations->is_authorized_read()) { self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comments.not-authorized.read'], MessageHelper::NOTICE)); } else { $edit_comment_id = AppContext::get_request()->get_getint('edit_comment', 0); $delete_comment_id = AppContext::get_request()->get_getint('delete_comment', 0); try { $lock = AppContext::get_request()->get_getbool('lock'); if ($authorizations->is_authorized_moderation()) { if ($lock) { if (!CommentsTopicDAO::topic_exists($module_id, $id_in_module, $topic_identifier)) { CommentsTopicDAO::create_topic($module_id, $id_in_module, $topic_identifier, $topic->get_path()); } CommentsManager::lock_topic($module_id, $id_in_module, $topic_identifier); } else { CommentsManager::unlock_topic($module_id, $id_in_module, $topic_identifier); } } AppContext::get_response()->redirect($topic->get_path()); } catch (UnexistingHTTPParameterException $e) { } if (!empty($delete_comment_id)) { self::verificate_authorized_edit_or_delete_comment($authorizations, $delete_comment_id); CommentsManager::delete_comment($delete_comment_id); AppContext::get_response()->redirect($topic->get_path()); } elseif (!empty($edit_comment_id)) { self::verificate_authorized_edit_or_delete_comment($authorizations, $edit_comment_id); $edit_comment_form = EditCommentBuildForm::create($edit_comment_id, $topic->get_path()); self::$template->put_all(array('C_DISPLAY_FORM' => true, 'COMMENT_FORM' => $edit_comment_form->display())); } else { if ($authorizations->is_authorized_post() && $authorizations->is_authorized_access_module()) { $comments_topic_locked = CommentsManager::comment_topic_locked($module_id, $id_in_module, $topic_identifier); $user_read_only = self::$user->get_delay_readonly(); if (!$authorizations->is_authorized_moderation() && $comments_topic_locked) { self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comment.locked'], MessageHelper::NOTICE)); } elseif (!empty($user_read_only) && $user_read_only > time()) { self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comments.user.read-only'], MessageHelper::NOTICE)); } else { $add_comment_form = AddCommentBuildForm::create($topic); self::$template->put_all(array('C_DISPLAY_FORM' => true, 'COMMENT_FORM' => $add_comment_form->display())); } } else { self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comments.not-authorized.post'], MessageHelper::NOTICE)); } } $number_comments_display = $topic->get_number_comments_display(); $number_comments = self::$comments_cache->get_count_comments_by_module($module_id, $id_in_module, $topic_identifier); self::$template->put_all(array('COMMENTS_LIST' => self::display_comments($module_id, $id_in_module, $topic_identifier, $number_comments_display, $authorizations), 'MODULE_ID' => $module_id, 'ID_IN_MODULE' => $id_in_module, 'TOPIC_IDENTIFIER' => $topic_identifier, 'C_DISPLAY_VIEW_ALL_COMMENTS' => $number_comments > $number_comments_display, 'C_MODERATE' => $authorizations->is_authorized_moderation(), 'C_IS_LOCKED' => CommentsManager::comment_topic_locked($module_id, $id_in_module, $topic_identifier), 'U_LOCK' => CommentsUrlBuilder::lock_and_unlock($topic->get_path(), true)->rel(), 'U_UNLOCK' => CommentsUrlBuilder::lock_and_unlock($topic->get_path(), false)->rel())); } return self::$template; }
public function __construct(WebLink $weblink = null) { parent::__construct('web'); $this->weblink = $weblink; }
public function __construct() { parent::__construct('bugtracker'); }
public function __construct() { parent::__construct('pages'); }
public function __construct() { parent::__construct('media'); }
public function __construct() { parent::__construct('user', self::TOPIC_IDENTIFIER); }
public function __construct(CalendarEvent $event = null) { parent::__construct('calendar'); $this->event = $event; }
public function __construct(News $news = null) { parent::__construct('news'); $this->news = $news; }
public function __construct() { parent::__construct('wiki'); }
public function __construct(Article $article = null) { parent::__construct('articles'); $this->article = $article; }
public function __construct(DownloadFile $downloadfile = null) { parent::__construct('download'); $this->downloadfile = $downloadfile; }
public function __construct() { parent::__construct('sandbox'); }
public function __construct() { parent::__construct('gallery'); }