ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilNewsForContextTableGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
29 protected int $perm_ref_id = 0;
31
32 public function __construct(
33 ilNewsItemGUI $a_parent_obj,
34 string $a_parent_cmd = "",
35 int $a_perm_ref_id = 0
36 ) {
37 global $DIC;
38
39 $this->ctrl = $DIC->ctrl();
40 $this->lng = $DIC->language();
41 $this->access = $DIC->access();
42 $ilCtrl = $DIC->ctrl();
43 $lng = $DIC->language();
44
45 parent::__construct($a_parent_obj, $a_parent_cmd);
46
47 $this->perm_ref_id = $a_perm_ref_id;
48 $this->news_access = new NewsAccess($this->perm_ref_id);
49
50 $this->addColumn("", "f", "1");
51 $this->addColumn($lng->txt("news_news_item_content"));
52 $this->addColumn($lng->txt("news_attached_to"));
53 $this->addColumn($lng->txt("access"));
54 $this->addColumn($lng->txt("author"));
55 $this->addColumn($lng->txt("created"));
56 $this->addColumn($lng->txt("last_update"));
57 $this->addColumn($lng->txt("actions"));
58 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
59 $this->setRowTemplate(
60 "tpl.table_row_news_for_context.html",
61 "components/ILIAS/News"
62 );
63 }
64
69 protected function fillRow(array $a_set): void
70 {
72 $ilCtrl = $this->ctrl;
73 $ilAccess = $this->access;
74
75 $news_set = new ilSetting("news");
76 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
77
78 // user
79 if ($a_set["user_id"] > 0) {
80 $this->tpl->setCurrentBlock("user_info");
81 $user_obj = new ilObjUser($a_set["user_id"]);
82 $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
83 $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
84 $this->tpl->parseCurrentBlock();
85 }
86
87 // access
88 if ($enable_internal_rss) {
89 $this->tpl->setCurrentBlock("access");
90 $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
91 if ($a_set["visibility"] === NEWS_PUBLIC ||
92 ((int) $a_set["priority"] === 0 &&
94 "news",
95 "public_notifications",
96 0,
97 $a_set["context_obj_id"]
98 ))) {
99 $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
100 } else {
101 $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
102 }
103 $this->tpl->parseCurrentBlock();
104 }
105
106 // last update
107 if ($a_set["creation_date"] !== $a_set["update_date"]) {
108 $this->tpl->setCurrentBlock("ni_update");
109 $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
110 $this->tpl->setVariable(
111 "VAL_LAST_UPDATE",
113 );
114 $this->tpl->parseCurrentBlock();
115 }
116
117 // creation date
118 $this->tpl->setVariable(
119 "VAL_CREATION_DATE",
120 ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME))
121 );
122 $this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
123
124 // title
125 $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
126
127 // content
128 if ($a_set["content"] != "") {
129 $this->tpl->setCurrentBlock("content");
130 $this->tpl->setVariable(
131 "VAL_CONTENT",
132 ilStr::shortenTextExtended($a_set["content"], 80, true, true)
133 );
134 $this->tpl->parseCurrentBlock();
135 }
136
137 $perm_ref_id = ($this->perm_ref_id > 0)
138 ? $this->perm_ref_id
139 : $a_set["ref_id"];
140
141 $news_item = new ilNewsItem($a_set["id"]);
142 if ($this->news_access->canEdit($news_item)) {
143 $this->tpl->setCurrentBlock("edit");
144 $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
145 $ilCtrl->setParameterByClass("ilnewsitemgui", "news_item_id", $a_set["id"]);
146 $this->tpl->setVariable(
147 "CMD_EDIT",
148 $ilCtrl->getLinkTargetByClass("ilnewsitemgui", "editNewsItem")
149 );
150 $this->tpl->parseCurrentBlock();
151 }
152
153 if ($this->news_access->canDelete($news_item)) {
154 $this->tpl->setCurrentBlock("cb");
155 $this->tpl->setVariable("VAL_ID", $a_set["id"]);
156 $this->tpl->parseCurrentBlock();
157 }
158
159 // context
160 $this->tpl->setVariable(
161 "CONTEXT",
162 $lng->txt("obj_" . $a_set["context_obj_type"]) . ":<br />" .
163 ilObject::_lookupTitle($a_set["context_obj_id"])
164 );
165 }
166}
const IL_CAL_DATETIME
const NEWS_PUBLIC
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
TableGUI class for table NewsForContext.
__construct(ilNewsItemGUI $a_parent_obj, string $a_parent_cmd="", int $a_perm_ref_id=0)
fillRow(array $a_set)
Standard Version of Fill Row.
User Interface for NewsItem entities.
A news item can be created by different sources.
User class.
static _lookupTitle(int $obj_id)
ILIAS Setting Class.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
ilLanguage $lng
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26