ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilContainerNewsSettingsGUI Class Reference

News settings for containers. More...

+ Collaboration diagram for ilContainerNewsSettingsGUI:

Public Member Functions

 __construct (ilObjectGUI $a_parent_gui)
 
 executeCommand ()
 
 show ()
 
 initForm ()
 
 save ()
 
 initDefaultOptions ()
 
 setTimeline (bool $a_value)
 
 getTimeline ()
 
 setCronNotifications (bool $a_value)
 
 getCronNotifications ()
 
 setHideByDate (bool $a_value)
 
 getHideByDate ()
 
 setPublicNotification (bool $a_value)
 
 getPublicNotification ()
 
 setNewsBlockForced (bool $a_value)
 
 setNewsBlockLabel (string $lang_key)
 
 setNewsBlockInfo (?string $lang_key)
 
 setPublicFeedInfo (string $lang_key)
 
 getNewsBlockForced ()
 

Protected Member Functions

 checkPermission (string $perm)
 

Protected Attributes

ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilSetting $setting
 
ilAccessHandler $access
 
ilTree $tree
 
ilObjectGUI $parent_gui
 
ilObject $object
 
ilSetting $news_settings
 
NewsPeriodInfo $period_info
 
UIRenderer $ui_renderer
 
UIFactory $ui_factory
 
bool $has_timeline = false
 
bool $has_cron_notifications = false
 
bool $has_hide_by_date = false
 
bool $has_public_notification = false
 
bool $has_block_forced = false
 
string $news_block_label = 'news_news_block'
 
string $news_block_info = 'obj_tool_setting_news_info'
 
string $public_feed_info = 'news_public_feed_info_container'
 

Detailed Description

News settings for containers.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 28 of file class.ilContainerNewsSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilContainerNewsSettingsGUI::__construct ( ilObjectGUI  $a_parent_gui)

Definition at line 51 of file class.ilContainerNewsSettingsGUI.php.

52 {
53 global $DIC;
54
55 $this->ctrl = $DIC->ctrl();
56 $this->lng = $DIC->language();
57 $this->lng->loadLanguageModule("news");
58 $this->tpl = $DIC["tpl"];
59 $this->setting = $DIC["ilSetting"];
60 $this->access = $DIC->access();
61 $this->tree = $DIC->repositoryTree();
62 $this->parent_gui = $a_parent_gui;
63 $this->object = $this->parent_gui->getObject();
64 $this->news_settings = new ilSetting('news');
65 $this->period_info = new NewsPeriodInfo($this->lng, $this->news_settings);
66 $this->ui_renderer = $DIC->ui()->renderer();
67 $this->ui_factory = $DIC->ui()->factory();
68
69 $this->initDefaultOptions();
70 }
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilObjectGUI\getObject(), initDefaultOptions(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkPermission()

ilContainerNewsSettingsGUI::checkPermission ( string  $perm)
protected

Definition at line 86 of file class.ilContainerNewsSettingsGUI.php.

86 : void
87 {
88 if ($this->access->checkAccess($perm, '', $this->object->getRefId())) {
89 return;
90 }
91
92 $this->tpl->setOnScreenMessage(
94 $this->lng->txt('msg_no_perm_read'),
95 true
96 );
97 $parent_ref_id = $this->tree->getParentId($this->object->getRefId());
98 $this->ctrl->redirectToURL($parent_ref_id > 0 ? ilLink::_getLink($parent_ref_id) : 'login.php?cmd=force_login');
99 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_FAILURE, and ILIAS\Repository\object().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilContainerNewsSettingsGUI::executeCommand ( )

Definition at line 72 of file class.ilContainerNewsSettingsGUI.php.

72 : void
73 {
74 $next_class = $this->ctrl->getNextClass($this);
75 $cmd = $this->ctrl->getCmd("show");
76
77 switch ($next_class) {
78 default:
79 if (in_array($cmd, ["show", "save"])) {
80 $this->checkPermission('write');
81 $this->$cmd();
82 }
83 }
84 }

References checkPermission(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getCronNotifications()

ilContainerNewsSettingsGUI::getCronNotifications ( )

Definition at line 353 of file class.ilContainerNewsSettingsGUI.php.

References $has_cron_notifications.

◆ getHideByDate()

ilContainerNewsSettingsGUI::getHideByDate ( )

Definition at line 363 of file class.ilContainerNewsSettingsGUI.php.

363 : bool
364 {
366 }

References $has_hide_by_date.

◆ getNewsBlockForced()

ilContainerNewsSettingsGUI::getNewsBlockForced ( )

Definition at line 399 of file class.ilContainerNewsSettingsGUI.php.

399 : bool
400 {
402 }

References $has_block_forced.

◆ getPublicNotification()

ilContainerNewsSettingsGUI::getPublicNotification ( )

Definition at line 373 of file class.ilContainerNewsSettingsGUI.php.

References $has_public_notification.

◆ getTimeline()

ilContainerNewsSettingsGUI::getTimeline ( )

Definition at line 343 of file class.ilContainerNewsSettingsGUI.php.

343 : bool
344 {
345 return $this->has_timeline;
346 }

References $has_timeline.

◆ initDefaultOptions()

ilContainerNewsSettingsGUI::initDefaultOptions ( )

Definition at line 330 of file class.ilContainerNewsSettingsGUI.php.

330 : void
331 {
332 $this->has_timeline = false;
333 $this->has_cron_notifications = false;
334 $this->has_hide_by_date = false;
335 $this->has_block_forced = false;
336 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initForm()

ilContainerNewsSettingsGUI::initForm ( )

Definition at line 107 of file class.ilContainerNewsSettingsGUI.php.

108 {
109 $form = new ilPropertyFormGUI();
110 //from crs/grp/cat settings - additional feature - news
111
112 if ($this->setting->get('block_activated_news')) {
113 $news = new ilCheckboxInputGUI(
114 $this->lng->txt($this->news_block_label),
116 );
117 $news->setValue('1');
118 if ($this->has_block_forced) {
119 $news->setChecked(true);
120 $news->setDisabled(true);
121 } else {
122 $news->setChecked($this->object->getNewsBlockActivated());
123 }
124 if ($this->news_block_info !== null) {
125 $news->setInfo($this->lng->txt($this->news_block_info));
126 }
127 ilNewsForContextBlockGUI::addToSettingsForm($news, $this->public_feed_info);
128 $form->addItem($news);
129 }
130
131 // Timeline (courses and groups)
132 if ($this->has_timeline) {
133 // timeline
134 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline"), "news_timeline");
135 $cb->setInfo($this->lng->txt("cont_news_timeline_info"));
136 $cb->setChecked($this->object->getNewsTimeline());
137 $form->addItem($cb);
138
139 // ...timeline: auto entries
140 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_auto_entries"), "news_timeline_auto_entries");
141 $cb2->setInfo($this->lng->txt("cont_news_timeline_auto_entries_info"));
142 $cb2->setChecked($this->object->getNewsTimelineAutoEntries());
143 $cb->addSubItem($cb2);
144
145 // ...timeline: landing page
146 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_landing_page"), "news_timeline_landing_page");
147 $cb2->setInfo($this->lng->txt("cont_news_timeline_landing_page_info"));
148 $cb2->setChecked($this->object->getNewsTimelineLandingPage());
149 $cb->addSubItem($cb2);
150 }
151
152 // Cron Notifications (courses and groups)
153 if ($this->has_cron_notifications && in_array(ilObject::_lookupType($this->object->getId()), ['crs', 'grp'])) {
154 $ref_ids = ilObject::_getAllReferences($this->object->getId());
155 $ref_id = array_pop($ref_ids);
157 }
158
159 $block_id = $this->ctrl->getContextObjId();
160
161 $hide_news_per_date = ilBlockSetting::_lookup(
163 "hide_news_per_date",
164 0,
165 $block_id
166 );
167 $hide_news_date = ilBlockSetting::_lookup(
169 "hide_news_date",
170 0,
171 $block_id
172 );
173 $hide_news_mode = ilBlockSetting::_lookup(
175 "hide_news_mode",
176 0,
177 $block_id
178 ) ?? ((is_string($hide_news_date) && $hide_news_date !== "") ? "per_date" : "global");
179 $news_co_period = ilBlockSetting::_lookup(
181 "news_co_period",
182 0,
183 $block_id
184 ) ?? "";
185
186 if (is_string($hide_news_date) && $hide_news_date !== "") {
187 $hide_news_date = explode(" ", $hide_news_date);
188 }
189
190 // Hide news: none, per date, or by period (courses, groups and categories)
191 if ($this->has_hide_by_date) {
192 $radio = new ilRadioGroupInputGUI($this->lng->txt("news_hide_news_mode"), "hide_news_mode");
193 $radio->setInfo(
194 $this->ui_renderer->render(
195 $this->ui_factory->messageBox()->info(
196 $this->period_info->getPeriodInfo()
197 )
198 )
199 );
200 $radio->setValue($hide_news_mode);
201
202 $opt_global = new ilRadioOption($this->lng->txt("news_hide_news_global"), "global");
203 $radio->addOption($opt_global);
204
205 $opt_none = new ilRadioOption($this->lng->txt("news_hide_news_none"), "none");
206 $radio->addOption($opt_none);
207
208 $opt_per_date = new ilRadioOption($this->lng->txt("news_hide_news_per_date"), "per_date");
209 $dt_prop = new ilDateTimeInputGUI($this->lng->txt("news_hide_news_date"), "hide_news_date");
210 $dt_prop->setRequired(true);
211 if (isset($hide_news_date[0], $hide_news_date[1])) {
212 $dt_prop->setDate(new ilDateTime($hide_news_date[0] . " " . $hide_news_date[1], IL_CAL_DATETIME));
213 }
214 $dt_prop->setShowTime(true);
215 $opt_per_date->addSubItem($dt_prop);
216 $radio->addOption($opt_per_date);
217
218 $opt_by_period = new ilRadioOption($this->lng->txt("news_hide_news_by_period"), "by_period");
219 $per_sel = new ilSelectInputGUI($this->lng->txt("news_co_period"), "news_co_period");
220 $per_sel->setRequired(true);
221 $per_sel->setInfo($this->lng->txt("news_co_period_info"));
222 $per_sel->setOptions([
223 7 => "1 {$this->lng->txt("week")}",
224 30 => "1 {$this->lng->txt("month")}",
225 366 => "1 {$this->lng->txt("year")}"
226 ]);
227 $per_sel->setValue($news_co_period);
228 $opt_by_period->addSubItem($per_sel);
229 $radio->addOption($opt_by_period);
230
231 $form->addItem($radio);
232 }
233
234 // public notifications (forums)
235 if ($this->has_public_notification) {
236 $public = ilBlockSetting::_lookup("news", "public_notifications", 0, $block_id);
237
238 $ch = new ilCheckboxInputGUI(
239 $this->lng->txt("news_notifications_public"),
240 "public_notifications"
241 );
242 $ch->setInfo($this->lng->txt("news_notifications_public_info"));
243 $ch->setChecked((bool) $public);
244 $form->addItem($ch);
245 }
246
247 $form->setTitle($this->lng->txt("cont_news_settings"));
248 $form->setFormAction($this->ctrl->getFormAction($this));
249 $form->addCommandButton("save", $this->lng->txt("save"));
250
251 return $form;
252 }
const IL_CAL_DATETIME
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
This class represents a checkbox property in a property form.
This class represents a date/time property in a property form.
@classDescription Date and time handling
static addToSettingsForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null, ?ilFormPropertyGUI $a_input=null)
Add notification settings to form.
static addToSettingsForm(ilFormPropertyGUI $a_input, string $public_feed_info)
Add inputs to the container news settings form to configure also the contextBlock options.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.

References ilNewsForContextBlockGUI\$block_type, ilObject\_getAllReferences(), ilBlockSetting\_lookup(), ilObject\_lookupType(), ilNewsForContextBlockGUI\addToSettingsForm(), ilMembershipNotifications\addToSettingsForm(), ILIAS\Repository\ctrl(), IL_CAL_DATETIME, ILIAS\Repository\lng(), ilObjectServiceSettingsGUI\NEWS_VISIBILITY, and ILIAS\Repository\object().

Referenced by save(), and show().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilContainerNewsSettingsGUI::save ( )

Definition at line 254 of file class.ilContainerNewsSettingsGUI.php.

254 : void
255 {
256 $form = $this->initForm();
257 if ($form->checkInput()) {
258 //non container objects force this news block (forums etc.)
259 if (!$this->has_block_forced) {
260 $this->object->setNewsBlockActivated($form->getInput(ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
261 }
262 if ($this->has_timeline) {
263 $this->object->setNewsTimeline($form->getInput("news_timeline"));
264 $this->object->setNewsTimelineAutoEntries($form->getInput("news_timeline_auto_entries"));
265 $this->object->setNewsTimelineLandingPage($form->getInput("news_timeline_landing_page"));
266 }
267 if ($this->setting->get('block_activated_news')) {
268 //save contextblock settings
269 $context_block_settings = [
270 "public_feed" => $form->getInput("notifications_public_feed") ?? "",
271 "default_visibility" => $form->getInput("default_visibility")
272 ];
273 if ($this->has_public_notification) {
274 $context_block_settings["public_notifications"] =
275 $form->getInput('public_notifications');
276 }
277
278 if ($this->has_hide_by_date) {
279 $context_block_settings["hide_news_mode"] = $form->getInput("hide_news_mode");
280 switch ($context_block_settings["hide_news_mode"]) {
281 case "per_date":
282 $hd = $form->getItemByPostVar("hide_news_date");
283 if ($hd instanceof ilDateTimeInputGUI) {
284 $hide_date = $hd->getDate();
285 if (!$hide_date instanceof ilDateTime) {
286 $hd->setAlert($this->lng->txt("msg_input_is_required"));
287 $form->setValuesByPost();
288 $this->tpl->setContent($form->getHTML());
289 return;
290 }
291 $context_block_settings["hide_news_per_date"] = "1";
292 $context_block_settings["hide_news_date"] = $hide_date->get(IL_CAL_DATETIME);
293 }
294 $context_block_settings["news_co_period"] = "";
295 break;
296 case "by_period":
297 $context_block_settings["hide_news_per_date"] = "0";
298 $context_block_settings["hide_news_date"] = "";
299 $context_block_settings["news_co_period"] = $form->getInput("news_co_period");
300 break;
301 case "global":
302 default:
303 $context_block_settings["hide_news_per_date"] = "0";
304 $context_block_settings["hide_news_date"] = "";
305 $context_block_settings["news_co_period"] = "";
306 break;
307 }
308 }
309
310 ilNewsForContextBlockGUI::writeSettings($context_block_settings);
311
312 if (in_array(ilObject::_lookupType($this->object->getId()), ['crs', 'grp'])) {
313 $ref_ids = ilObject::_getAllReferences($this->object->getId());
314 $ref_id = array_pop($ref_ids);
315
317 }
318 }
319
320 $this->object->update();
321 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
322 $this->ctrl->redirect($this, "");
323 } else {
324 $form->setValuesByPost();
325 $this->tpl->setContent($form->getHTML());
326 }
327 }
static importFromForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null)

References ilObject\_getAllReferences(), ilObject\_lookupType(), ILIAS\Repository\ctrl(), IL_CAL_DATETIME, ilMembershipNotifications\importFromForm(), initForm(), ILIAS\Repository\lng(), ilObjectServiceSettingsGUI\NEWS_VISIBILITY, ILIAS\Repository\object(), and ilNewsForContextBlockGUI\writeSettings().

+ Here is the call graph for this function:

◆ setCronNotifications()

ilContainerNewsSettingsGUI::setCronNotifications ( bool  $a_value)

Definition at line 348 of file class.ilContainerNewsSettingsGUI.php.

348 : void
349 {
350 $this->has_cron_notifications = $a_value;
351 }

◆ setHideByDate()

ilContainerNewsSettingsGUI::setHideByDate ( bool  $a_value)

Definition at line 358 of file class.ilContainerNewsSettingsGUI.php.

358 : void
359 {
360 $this->has_hide_by_date = $a_value;
361 }

◆ setNewsBlockForced()

ilContainerNewsSettingsGUI::setNewsBlockForced ( bool  $a_value)

Definition at line 379 of file class.ilContainerNewsSettingsGUI.php.

379 : void
380 {
381 $this->has_block_forced = $a_value;
382 }

◆ setNewsBlockInfo()

ilContainerNewsSettingsGUI::setNewsBlockInfo ( ?string  $lang_key)

Definition at line 389 of file class.ilContainerNewsSettingsGUI.php.

389 : void
390 {
391 $this->news_block_info = $lang_key;
392 }

◆ setNewsBlockLabel()

ilContainerNewsSettingsGUI::setNewsBlockLabel ( string  $lang_key)

Definition at line 384 of file class.ilContainerNewsSettingsGUI.php.

384 : void
385 {
386 $this->news_block_label = $lang_key;
387 }

◆ setPublicFeedInfo()

ilContainerNewsSettingsGUI::setPublicFeedInfo ( string  $lang_key)

Definition at line 394 of file class.ilContainerNewsSettingsGUI.php.

394 : void
395 {
396 $this->public_feed_info = $lang_key;
397 }

◆ setPublicNotification()

ilContainerNewsSettingsGUI::setPublicNotification ( bool  $a_value)

Definition at line 368 of file class.ilContainerNewsSettingsGUI.php.

368 : void
369 {
370 $this->has_public_notification = $a_value;
371 }

◆ setTimeline()

ilContainerNewsSettingsGUI::setTimeline ( bool  $a_value)

Definition at line 338 of file class.ilContainerNewsSettingsGUI.php.

338 : void
339 {
340 $this->has_timeline = $a_value;
341 }

◆ show()

ilContainerNewsSettingsGUI::show ( )

Definition at line 101 of file class.ilContainerNewsSettingsGUI.php.

101 : void
102 {
103 $form = $this->initForm();
104 $this->tpl->setContent($form->getHTML());
105 }

References initForm().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilContainerNewsSettingsGUI::$access
protected

Definition at line 34 of file class.ilContainerNewsSettingsGUI.php.

◆ $ctrl

ilCtrl ilContainerNewsSettingsGUI::$ctrl
protected

Definition at line 30 of file class.ilContainerNewsSettingsGUI.php.

◆ $has_block_forced

bool ilContainerNewsSettingsGUI::$has_block_forced = false
protected

Definition at line 46 of file class.ilContainerNewsSettingsGUI.php.

Referenced by getNewsBlockForced().

◆ $has_cron_notifications

bool ilContainerNewsSettingsGUI::$has_cron_notifications = false
protected

Definition at line 43 of file class.ilContainerNewsSettingsGUI.php.

Referenced by getCronNotifications().

◆ $has_hide_by_date

bool ilContainerNewsSettingsGUI::$has_hide_by_date = false
protected

Definition at line 44 of file class.ilContainerNewsSettingsGUI.php.

Referenced by getHideByDate().

◆ $has_public_notification

bool ilContainerNewsSettingsGUI::$has_public_notification = false
protected

Definition at line 45 of file class.ilContainerNewsSettingsGUI.php.

Referenced by getPublicNotification().

◆ $has_timeline

bool ilContainerNewsSettingsGUI::$has_timeline = false
protected

Definition at line 42 of file class.ilContainerNewsSettingsGUI.php.

Referenced by getTimeline().

◆ $lng

ilLanguage ilContainerNewsSettingsGUI::$lng
protected

Definition at line 32 of file class.ilContainerNewsSettingsGUI.php.

◆ $news_block_info

string ilContainerNewsSettingsGUI::$news_block_info = 'obj_tool_setting_news_info'
protected

Definition at line 48 of file class.ilContainerNewsSettingsGUI.php.

◆ $news_block_label

string ilContainerNewsSettingsGUI::$news_block_label = 'news_news_block'
protected

Definition at line 47 of file class.ilContainerNewsSettingsGUI.php.

◆ $news_settings

ilSetting ilContainerNewsSettingsGUI::$news_settings
protected

Definition at line 38 of file class.ilContainerNewsSettingsGUI.php.

◆ $object

ilObject ilContainerNewsSettingsGUI::$object
protected

Definition at line 37 of file class.ilContainerNewsSettingsGUI.php.

◆ $parent_gui

ilObjectGUI ilContainerNewsSettingsGUI::$parent_gui
protected

Definition at line 36 of file class.ilContainerNewsSettingsGUI.php.

◆ $period_info

NewsPeriodInfo ilContainerNewsSettingsGUI::$period_info
protected

Definition at line 39 of file class.ilContainerNewsSettingsGUI.php.

◆ $public_feed_info

string ilContainerNewsSettingsGUI::$public_feed_info = 'news_public_feed_info_container'
protected

Definition at line 49 of file class.ilContainerNewsSettingsGUI.php.

◆ $setting

ilSetting ilContainerNewsSettingsGUI::$setting
protected

Definition at line 33 of file class.ilContainerNewsSettingsGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilContainerNewsSettingsGUI::$tpl
protected

Definition at line 31 of file class.ilContainerNewsSettingsGUI.php.

◆ $tree

ilTree ilContainerNewsSettingsGUI::$tree
protected

Definition at line 35 of file class.ilContainerNewsSettingsGUI.php.

◆ $ui_factory

UIFactory ilContainerNewsSettingsGUI::$ui_factory
protected

Definition at line 41 of file class.ilContainerNewsSettingsGUI.php.

◆ $ui_renderer

UIRenderer ilContainerNewsSettingsGUI::$ui_renderer
protected

Definition at line 40 of file class.ilContainerNewsSettingsGUI.php.


The documentation for this class was generated from the following file: