コード例 #1
0
 public function get_authorizations()
 {
     require_once PATH_TO_ROOT . '/' . $this->get_module_id() . '/pages_defines.php';
     $page_authorizations = unserialize($this->get_page_authorizations());
     $authorizations = new CommentsAuthorizations();
     if (!empty($page_authorizations)) {
         $authorizations->set_authorized_access_module(AppContext::get_current_user()->check_auth($page_authorizations, READ_PAGE));
     } else {
         $authorizations->set_authorized_access_module(AppContext::get_current_user()->check_auth(PagesConfig::load()->get_authorizations(), READ_PAGE));
     }
     return $authorizations;
 }
コード例 #2
0
    private function build_view($request)
    {
        $template = new FileTemplate('framework/content/comments/comments_list.tpl');
        $page = $request->get_getint('page', 1);
        $id_module = $this->module === null ? null : $this->module->get_id();
        $pagination = $this->get_pagination($page);
        $this->tpl->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display()));
        $result = PersistenceContext::get_querier()->select('
			SELECT comments.*, comments.timestamp AS comment_timestamp, comments.id AS id_comment,
			topic.*,
			member.user_id, member.display_name, member.level, member.groups,
			ext_field.user_avatar
			FROM ' . DB_TABLE_COMMENTS . ' comments
			LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' topic ON comments.id_topic = topic.id_topic
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = comments.user_id
			LEFT JOIN ' . DB_TABLE_MEMBER_EXTENDED_FIELDS . ' ext_field ON ext_field.user_id = comments.user_id
			' . $this->build_where_request() . '
			ORDER BY comments.timestamp DESC
			LIMIT :number_items_per_page OFFSET :display_from', array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
        $user_accounts_config = UserAccountsConfig::load();
        $comments_authorizations = new CommentsAuthorizations();
        $number_comment = 0;
        while ($row = $result->fetch()) {
            $id = $row['id_comment'];
            $path = $row['path'];
            //Avatar
            $user_avatar = !empty($row['user_avatar']) ? Url::to_rel($row['user_avatar']) : ($user_accounts_config->is_default_avatar_enabled() ? Url::to_rel('/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name()) : '');
            $timestamp = new Date($row['comment_timestamp'], Timezone::SERVER_TIMEZONE);
            $group_color = User::get_group_color($row['groups'], $row['level']);
            $template->assign_block_vars('comments', array('C_MODERATOR' => $comments_authorizations->is_authorized_moderation(), 'C_VISITOR' => empty($row['login']), 'C_VIEW_TOPIC' => true, 'C_GROUP_COLOR' => !empty($group_color), 'C_AVATAR' => $row['user_avatar'] || $user_accounts_config->is_default_avatar_enabled(), 'U_TOPIC' => Url::to_rel($path), 'U_EDIT' => CommentsUrlBuilder::edit($path, $id)->rel(), 'U_DELETE' => CommentsUrlBuilder::delete($path, $id)->rel(), 'U_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_AVATAR' => $user_avatar, 'ID_COMMENT' => $id, 'DATE' => $timestamp->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'DATE_ISO8601' => $timestamp->format(Date::FORMAT_ISO8601), 'MESSAGE' => FormatingHelper::second_parse($row['message']), 'USER_ID' => $row['user_id'], 'PSEUDO' => empty($row['login']) ? $row['pseudo'] : $row['login'], 'LEVEL_CLASS' => UserService::get_level_class($row['level']), 'GROUP_COLOR' => $group_color, 'L_LEVEL' => UserService::get_level_lang($row['level'] !== null ? $row['level'] : '-1')));
            $template->put_all(array('MODULE_ID' => $row['module_id'], 'ID_IN_MODULE' => $row['id_in_module'], 'L_VIEW_TOPIC' => $this->lang['view-topic']));
            $number_comment++;
        }
        $result->dispose();
        $this->tpl->put('C_NO_COMMENT', $number_comment == 0);
        $comments_tpl = new FileTemplate('framework/content/comments/comments.tpl');
        $comments_tpl->put_all(array('COMMENTS_LIST' => $template, 'MODULE_ID' => $row['module_id'], 'ID_IN_MODULE' => $row['id_in_module']));
        return $comments_tpl;
    }
コード例 #3
0
 public function get_authorizations()
 {
     $authorizations = new CommentsAuthorizations();
     $authorizations->set_authorized_access_module(WebAuthorizationsService::check_authorizations($this->get_weblink()->get_id_category())->read());
     return $authorizations;
 }
コード例 #4
0
 /**
  * @method Get comments authorizations
  */
 public function get_authorizations()
 {
     $authorizations = new CommentsAuthorizations();
     $authorizations->set_authorized_access_module(BugtrackerAuthorizationsService::check_authorizations()->read());
     return $authorizations;
 }
コード例 #5
0
 public function get_authorizations()
 {
     $authorizations = new CommentsAuthorizations();
     $authorizations->set_authorized_access_module(CalendarAuthorizationsService::check_authorizations($this->get_event()->get_content()->get_category_id())->read());
     return $authorizations;
 }
コード例 #6
0
 public function get_authorizations()
 {
     $authorizations = new CommentsAuthorizations();
     $authorizations->set_authorized_access_module(true);
     return $authorizations;
 }