ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 Attributes

ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilSetting $setting
 
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 38 of file class.ilContainerNewsSettingsGUI.php.

39 {
40 global $DIC;
41
42 $this->ctrl = $DIC->ctrl();
43 $this->lng = $DIC->language();
44 $this->lng->loadLanguageModule("news");
45 $this->tpl = $DIC["tpl"];
46 $this->setting = $DIC["ilSetting"];
47 $this->parent_gui = $a_parent_gui;
48 $this->object = $this->parent_gui->getObject();
49
50 $this->initDefaultOptions();
51 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilContainerNewsSettingsGUI::executeCommand ( )

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

53 : void
54 {
55 $next_class = $this->ctrl->getNextClass($this);
56 $cmd = $this->ctrl->getCmd("show");
57
58 switch ($next_class) {
59 default:
60 if (in_array($cmd, ["show", "save"])) {
61 $this->$cmd();
62 }
63 }
64 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getCronNotifications()

ilContainerNewsSettingsGUI::getCronNotifications ( )

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

References $has_cron_notifications.

◆ getHideByDate()

ilContainerNewsSettingsGUI::getHideByDate ( )

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

261 : bool
262 {
264 }

References $has_hide_by_date.

◆ getNewsBlockForced()

ilContainerNewsSettingsGUI::getNewsBlockForced ( )

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

282 : bool
283 {
285 }

References $has_block_forced.

◆ getPublicNotification()

ilContainerNewsSettingsGUI::getPublicNotification ( )

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

References $has_public_notification.

◆ getTimeline()

ilContainerNewsSettingsGUI::getTimeline ( )

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

241 : bool
242 {
243 return $this->has_timeline;
244 }

References $has_timeline.

◆ initDefaultOptions()

ilContainerNewsSettingsGUI::initDefaultOptions ( )

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

228 : void
229 {
230 $this->has_timeline = false;
231 $this->has_cron_notifications = false;
232 $this->has_hide_by_date = false;
233 $this->has_block_forced = false;
234 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initForm()

ilContainerNewsSettingsGUI::initForm ( )

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

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

182 : void
183 {
184 $form = $this->initForm();
185 if ($form->checkInput()) {
186 //non container objects force this news block (forums etc.)
187 if (!$this->has_block_forced) {
188 $this->object->setNewsBlockActivated($form->getInput(ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
189 }
190 if ($this->has_timeline) {
191 $this->object->setNewsTimeline($form->getInput("news_timeline"));
192 $this->object->setNewsTimelineAutoEntries($form->getInput("news_timeline_auto_entries"));
193 $this->object->setNewsTimelineLandingPage($form->getInput("news_timeline_landing_page"));
194 }
195 if ($this->setting->get('block_activated_news')) {
196 //save contextblock settings
197 $context_block_settings = [
198 "public_feed" => $form->getInput("notifications_public_feed") ?? "",
199 "default_visibility" => $form->getInput("default_visibility"),
200 "hide_news_per_date" => $form->getInput("hide_news_per_date"),
201 "hide_news_date" => $form->getInput("hide_news_date")
202 ];
203 if ($this->has_public_notification) {
204 $context_block_settings["public_notifications"] =
205 $form->getInput('public_notifications');
206 }
207
208 ilNewsForContextBlockGUI::writeSettings($context_block_settings);
209
210 if (in_array(ilObject::_lookupType($this->object->getId()), ['crs', 'grp'])) {
211 $ref_ids = ilObject::_getAllReferences($this->object->getId());
212 $ref_id = array_pop($ref_ids);
213
215 }
216 }
217
218 $this->object->update();
219 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
220 $this->ctrl->redirect($this, "");
221 } else {
222 $form->setValuesByPost();
223 $this->tpl->setContent($form->getHTML());
224 }
225 }
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 246 of file class.ilContainerNewsSettingsGUI.php.

246 : void
247 {
248 $this->has_cron_notifications = $a_value;
249 }

◆ setHideByDate()

ilContainerNewsSettingsGUI::setHideByDate ( bool  $a_value)

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

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

◆ setNewsBlockForced()

ilContainerNewsSettingsGUI::setNewsBlockForced ( bool  $a_value)

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

277 : void
278 {
279 $this->has_block_forced = $a_value;
280 }

◆ setPublicNotification()

ilContainerNewsSettingsGUI::setPublicNotification ( bool  $a_value)

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

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

◆ setTimeline()

ilContainerNewsSettingsGUI::setTimeline ( bool  $a_value)

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

236 : void
237 {
238 $this->has_timeline = $a_value;
239 }

◆ show()

ilContainerNewsSettingsGUI::show ( )

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

66 : void
67 {
68 $form = $this->initForm();
69 $this->tpl->setContent($form->getHTML());
70 }

References initForm().

+ Here is the call graph for this function:

Field Documentation

◆ $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 36 of file class.ilContainerNewsSettingsGUI.php.

Referenced by getNewsBlockForced().

◆ $has_cron_notifications

bool ilContainerNewsSettingsGUI::$has_cron_notifications = false
protected

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

Referenced by getCronNotifications().

◆ $has_hide_by_date

bool ilContainerNewsSettingsGUI::$has_hide_by_date = false
protected

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

Referenced by getHideByDate().

◆ $has_public_notification

bool ilContainerNewsSettingsGUI::$has_public_notification = false
protected

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

Referenced by getPublicNotification().

◆ $has_timeline

bool ilContainerNewsSettingsGUI::$has_timeline = false
protected

Definition at line 32 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 31 of file class.ilContainerNewsSettingsGUI.php.

◆ $parent_gui

ilObjectGUI ilContainerNewsSettingsGUI::$parent_gui
protected

Definition at line 30 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.


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