ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
ilContainerNewsSettingsGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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)
 
 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
 
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
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning News settings for containers

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

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

Constructor & Destructor Documentation

◆ __construct()

ilContainerNewsSettingsGUI::__construct ( ilObjectGUI  $a_parent_gui)

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

41 {
42 global $DIC;
43
44 $this->ctrl = $DIC->ctrl();
45 $this->lng = $DIC->language();
46 $this->lng->loadLanguageModule("news");
47 $this->tpl = $DIC["tpl"];
48 $this->setting = $DIC["ilSetting"];
49 $this->access = $DIC->access();
50 $this->tree = $DIC->repositoryTree();
51 $this->parent_gui = $a_parent_gui;
52 $this->object = $this->parent_gui->getObject();
53
54 $this->initDefaultOptions();
55 }
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 71 of file class.ilContainerNewsSettingsGUI.php.

71 : void
72 {
73 if ($this->access->checkAccess($perm, '', $this->object->getRefId())) {
74 return;
75 }
76
77 $this->tpl->setOnScreenMessage(
79 $this->lng->txt('msg_no_perm_read'),
80 true
81 );
82 $parent_ref_id = $this->tree->getParentId($this->object->getRefId());
83 $this->ctrl->redirectToURL($parent_ref_id > 0 ? ilLink::_getLink($parent_ref_id) : 'login.php?cmd=force_login');
84 }

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 57 of file class.ilContainerNewsSettingsGUI.php.

57 : void
58 {
59 $next_class = $this->ctrl->getNextClass($this);
60 $cmd = $this->ctrl->getCmd("show");
61
62 switch ($next_class) {
63 default:
64 if (in_array($cmd, ["show", "save"])) {
65 $this->checkPermission('write');
66 $this->$cmd();
67 }
68 }
69 }

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

+ Here is the call graph for this function:

◆ getCronNotifications()

ilContainerNewsSettingsGUI::getCronNotifications ( )

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

References $has_cron_notifications.

◆ getHideByDate()

ilContainerNewsSettingsGUI::getHideByDate ( )

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

281 : bool
282 {
284 }

References $has_hide_by_date.

◆ getNewsBlockForced()

ilContainerNewsSettingsGUI::getNewsBlockForced ( )

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

302 : bool
303 {
305 }

References $has_block_forced.

◆ getPublicNotification()

ilContainerNewsSettingsGUI::getPublicNotification ( )

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

References $has_public_notification.

◆ getTimeline()

ilContainerNewsSettingsGUI::getTimeline ( )

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

261 : bool
262 {
263 return $this->has_timeline;
264 }

References $has_timeline.

◆ initDefaultOptions()

ilContainerNewsSettingsGUI::initDefaultOptions ( )

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

248 : void
249 {
250 $this->has_timeline = false;
251 $this->has_cron_notifications = false;
252 $this->has_hide_by_date = false;
253 $this->has_block_forced = false;
254 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initForm()

ilContainerNewsSettingsGUI::initForm ( )

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

93 {
94 $form = new ilPropertyFormGUI();
95 //from crs/grp/cat settings - additional feature - news
96
97 if ($this->setting->get('block_activated_news')) {
98 $news = new ilCheckboxInputGUI($this->lng->txt('news_news_block'), ilObjectServiceSettingsGUI::NEWS_VISIBILITY);
99 $news->setValue('1');
100 if ($this->has_block_forced) {
101 $news->setChecked(true);
102 $news->setDisabled(true);
103 } else {
104 $news->setChecked($this->object->getNewsBlockActivated());
105 }
106 $news->setInfo($this->lng->txt('obj_tool_setting_news_info'));
108 $form->addItem($news);
109 }
110
111 // Timeline (courses and groups)
112 if ($this->has_timeline) {
113 // timeline
114 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline"), "news_timeline");
115 $cb->setInfo($this->lng->txt("cont_news_timeline_info"));
116 $cb->setChecked($this->object->getNewsTimeline());
117 $form->addItem($cb);
118
119 // ...timeline: auto entries
120 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_auto_entries"), "news_timeline_auto_entries");
121 $cb2->setInfo($this->lng->txt("cont_news_timeline_auto_entries_info"));
122 $cb2->setChecked($this->object->getNewsTimelineAutoEntries());
123 $cb->addSubItem($cb2);
124
125 // ...timeline: landing page
126 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_landing_page"), "news_timeline_landing_page");
127 $cb2->setInfo($this->lng->txt("cont_news_timeline_landing_page_info"));
128 $cb2->setChecked($this->object->getNewsTimelineLandingPage());
129 $cb->addSubItem($cb2);
130 }
131
132 // Cron Notifications (courses and groups)
133 if ($this->has_cron_notifications && in_array(ilObject::_lookupType($this->object->getId()), ['crs', 'grp'])) {
134 $ref_ids = ilObject::_getAllReferences($this->object->getId());
135 $ref_id = array_pop($ref_ids);
137 }
138
139 $block_id = $this->ctrl->getContextObjId();
140
141 // Visibility by date
142 $hide_news_per_date = ilBlockSetting::_lookup(
144 "hide_news_per_date",
145 0,
146 $block_id
147 );
148 $hide_news_date = ilBlockSetting::_lookup(
150 "hide_news_date",
151 0,
152 $block_id
153 );
154
155 if ($hide_news_date != "") {
156 $hide_news_date = explode(" ", $hide_news_date);
157 }
158
159 // Hide news before a date (courses, groups and categories)
160 if ($this->has_hide_by_date) {
161 //Hide news per date
162 $hnpd = new ilCheckboxInputGUI(
163 $this->lng->txt("news_hide_news_per_date"),
164 "hide_news_per_date"
165 );
166 $hnpd->setInfo($this->lng->txt("news_hide_news_per_date_info"));
167 $hnpd->setChecked((bool) $hide_news_per_date);
168
169 $dt_prop = new ilDateTimeInputGUI($this->lng->txt("news_hide_news_date"), "hide_news_date");
170 $dt_prop->setRequired(true);
171 if (is_array($hide_news_date)) {
172 $dt_prop->setDate(new ilDateTime($hide_news_date[0] . ' ' . ($hide_news_date[1] ?? "12:00:00"), IL_CAL_DATETIME));
173 }
174
175 $dt_prop->setShowTime(true);
176
177 $hnpd->addSubItem($dt_prop);
178
179 $form->addItem($hnpd);
180 }
181
182 // public notifications (forums)
183 if ($this->has_public_notification) {
184 $public = ilBlockSetting::_lookup("news", "public_notifications", 0, $block_id);
185
186 $ch = new ilCheckboxInputGUI(
187 $this->lng->txt("news_notifications_public"),
188 "public_notifications"
189 );
190 $ch->setInfo($this->lng->txt("news_notifications_public_info"));
191 $ch->setChecked((bool) $public);
192 $form->addItem($ch);
193 }
194
195 $form->setTitle($this->lng->txt("cont_news_settings"));
196 $form->setFormAction($this->ctrl->getFormAction($this));
197 $form->addCommandButton("save", $this->lng->txt("save"));
198
199 return $form;
200 }
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)
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.
$ref_id
Definition: ltiauth.php:66

References ilNewsForContextBlockGUI\$block_type, $ref_id, 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 202 of file class.ilContainerNewsSettingsGUI.php.

202 : void
203 {
204 $form = $this->initForm();
205 if ($form->checkInput()) {
206 //non container objects force this news block (forums etc.)
207 if (!$this->has_block_forced) {
208 $this->object->setNewsBlockActivated($form->getInput(ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
209 }
210 if ($this->has_timeline) {
211 $this->object->setNewsTimeline($form->getInput("news_timeline"));
212 $this->object->setNewsTimelineAutoEntries($form->getInput("news_timeline_auto_entries"));
213 $this->object->setNewsTimelineLandingPage($form->getInput("news_timeline_landing_page"));
214 }
215 if ($this->setting->get('block_activated_news')) {
216 //save contextblock settings
217 $context_block_settings = [
218 "public_feed" => $form->getInput("notifications_public_feed") ?? "",
219 "default_visibility" => $form->getInput("default_visibility"),
220 "hide_news_per_date" => $form->getInput("hide_news_per_date"),
221 "hide_news_date" => $form->getInput("hide_news_date")
222 ];
223 if ($this->has_public_notification) {
224 $context_block_settings["public_notifications"] =
225 $form->getInput('public_notifications');
226 }
227
228 ilNewsForContextBlockGUI::writeSettings($context_block_settings);
229
230 if (in_array(ilObject::_lookupType($this->object->getId()), ['crs', 'grp'])) {
231 $ref_ids = ilObject::_getAllReferences($this->object->getId());
232 $ref_id = array_pop($ref_ids);
233
235 }
236 }
237
238 $this->object->update();
239 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
240 $this->ctrl->redirect($this, "");
241 } else {
242 $form->setValuesByPost();
243 $this->tpl->setContent($form->getHTML());
244 }
245 }
static importFromForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null)

References $ref_id, ilObject\_getAllReferences(), ilObject\_lookupType(), ILIAS\Repository\ctrl(), 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 266 of file class.ilContainerNewsSettingsGUI.php.

266 : void
267 {
268 $this->has_cron_notifications = $a_value;
269 }

◆ setHideByDate()

ilContainerNewsSettingsGUI::setHideByDate ( bool  $a_value)

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

276 : void
277 {
278 $this->has_hide_by_date = $a_value;
279 }

◆ setNewsBlockForced()

ilContainerNewsSettingsGUI::setNewsBlockForced ( bool  $a_value)

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

297 : void
298 {
299 $this->has_block_forced = $a_value;
300 }

◆ setPublicNotification()

ilContainerNewsSettingsGUI::setPublicNotification ( bool  $a_value)

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

286 : void
287 {
288 $this->has_public_notification = $a_value;
289 }

◆ setTimeline()

ilContainerNewsSettingsGUI::setTimeline ( bool  $a_value)

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

256 : void
257 {
258 $this->has_timeline = $a_value;
259 }

◆ show()

ilContainerNewsSettingsGUI::show ( )

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

86 : void
87 {
88 $form = $this->initForm();
89 $this->tpl->setContent($form->getHTML());
90 }

References initForm().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilContainerNewsSettingsGUI::$access
protected

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

◆ $ctrl

ilCtrl ilContainerNewsSettingsGUI::$ctrl
protected

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

◆ $has_block_forced

bool ilContainerNewsSettingsGUI::$has_block_forced = false
protected

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

Referenced by getNewsBlockForced().

◆ $has_cron_notifications

bool ilContainerNewsSettingsGUI::$has_cron_notifications = false
protected

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

Referenced by getCronNotifications().

◆ $has_hide_by_date

bool ilContainerNewsSettingsGUI::$has_hide_by_date = false
protected

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

Referenced by getHideByDate().

◆ $has_public_notification

bool ilContainerNewsSettingsGUI::$has_public_notification = false
protected

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

Referenced by getPublicNotification().

◆ $has_timeline

bool ilContainerNewsSettingsGUI::$has_timeline = false
protected

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

Referenced by getTimeline().

◆ $lng

ilLanguage ilContainerNewsSettingsGUI::$lng
protected

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

◆ $object

ilObject ilContainerNewsSettingsGUI::$object
protected

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

◆ $parent_gui

ilObjectGUI ilContainerNewsSettingsGUI::$parent_gui
protected

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

◆ $setting

ilSetting ilContainerNewsSettingsGUI::$setting
protected

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

◆ $tpl

ilGlobalTemplateInterface ilContainerNewsSettingsGUI::$tpl
protected

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

◆ $tree

ilTree ilContainerNewsSettingsGUI::$tree
protected

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


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