ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilContainerNewsSettingsGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

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  }
+ Here is the call graph for this function:

◆ getCronNotifications()

ilContainerNewsSettingsGUI::getCronNotifications ( )

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

References $has_cron_notifications.

252  : bool
253  {
255  }

◆ getHideByDate()

ilContainerNewsSettingsGUI::getHideByDate ( )

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

References $has_hide_by_date.

262  : bool
263  {
265  }

◆ getNewsBlockForced()

ilContainerNewsSettingsGUI::getNewsBlockForced ( )

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

References $has_block_forced.

283  : bool
284  {
286  }

◆ getPublicNotification()

ilContainerNewsSettingsGUI::getPublicNotification ( )

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

References $has_public_notification.

272  : bool
273  {
275  }

◆ getTimeline()

ilContainerNewsSettingsGUI::getTimeline ( )

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

References $has_timeline.

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

◆ initDefaultOptions()

ilContainerNewsSettingsGUI::initDefaultOptions ( )

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

Referenced by __construct().

229  : void
230  {
231  $this->has_timeline = false;
232  $this->has_cron_notifications = false;
233  $this->has_hide_by_date = false;
234  $this->has_block_forced = false;
235  }
+ Here is the caller graph for this function:

◆ initForm()

ilContainerNewsSettingsGUI::initForm ( )

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

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

Referenced by save(), and show().

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);
116  ilMembershipNotifications::addToSettingsForm($ref_id, $form, null);
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 
152  if ($hide_news_date != "") {
153  $dt_prop->setDate(new ilDateTime($hide_news_date[0] . ' ' . $hide_news_date[1], IL_CAL_DATETIME));
154  }
155 
156  $dt_prop->setShowTime(true);
157 
158  $hnpd->addSubItem($dt_prop);
159 
160  $form->addItem($hnpd);
161  }
162 
163  // public notifications (forums)
164  if ($this->has_public_notification) {
165  $public = ilBlockSetting::_lookup("news", "public_notifications", 0, $block_id);
166 
167  $ch = new ilCheckboxInputGUI(
168  $this->lng->txt("news_notifications_public"),
169  "public_notifications"
170  );
171  $ch->setInfo($this->lng->txt("news_notifications_public_info"));
172  $ch->setChecked((bool) $public);
173  $form->addItem($ch);
174  }
175 
176  $form->setTitle($this->lng->txt("cont_news_settings"));
177  $form->setFormAction($this->ctrl->getFormAction($this));
178  $form->addCommandButton("save", $this->lng->txt("save"));
179 
180  return $form;
181  }
const IL_CAL_DATETIME
static _getAllReferences(int $id)
get all reference ids for object ID
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
setRequired(bool $a_required)
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 addToSettingsForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null, ?ilFormPropertyGUI $a_input=null)
Add notification settings to form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilContainerNewsSettingsGUI::save ( )

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

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().

183  : void
184  {
185  $form = $this->initForm();
186  if ($form->checkInput()) {
187  //non container objects force this news block (forums etc.)
188  if (!$this->has_block_forced) {
189  $this->object->setNewsBlockActivated($form->getInput(ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
190  }
191  if ($this->has_timeline) {
192  $this->object->setNewsTimeline($form->getInput("news_timeline"));
193  $this->object->setNewsTimelineAutoEntries($form->getInput("news_timeline_auto_entries"));
194  $this->object->setNewsTimelineLandingPage($form->getInput("news_timeline_landing_page"));
195  }
196  if ($this->setting->get('block_activated_news')) {
197  //save contextblock settings
198  $context_block_settings = [
199  "public_feed" => $form->getInput("notifications_public_feed") ?? "",
200  "default_visibility" => $form->getInput("default_visibility"),
201  "hide_news_per_date" => $form->getInput("hide_news_per_date"),
202  "hide_news_date" => $form->getInput("hide_news_date")
203  ];
204  if ($this->has_public_notification) {
205  $context_block_settings["public_notifications"] =
206  $form->getInput('public_notifications');
207  }
208 
209  ilNewsForContextBlockGUI::writeSettings($context_block_settings);
210 
211  if (in_array(ilObject::_lookupType($this->object->getId()), ['crs', 'grp'])) {
212  $ref_ids = ilObject::_getAllReferences($this->object->getId());
213  $ref_id = array_pop($ref_ids);
214 
216  }
217  }
218 
219  $this->object->update();
220  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
221  $this->ctrl->redirect($this, "");
222  } else {
223  $form->setValuesByPost();
224  $this->tpl->setContent($form->getHTML());
225  }
226  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
static importFromForm(int $a_ref_id, ?ilPropertyFormGUI $a_form=null)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ setCronNotifications()

ilContainerNewsSettingsGUI::setCronNotifications ( bool  $a_value)

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

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

◆ setHideByDate()

ilContainerNewsSettingsGUI::setHideByDate ( bool  $a_value)

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

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

◆ setNewsBlockForced()

ilContainerNewsSettingsGUI::setNewsBlockForced ( bool  $a_value)

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

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

◆ setPublicNotification()

ilContainerNewsSettingsGUI::setPublicNotification ( bool  $a_value)

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

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

◆ setTimeline()

ilContainerNewsSettingsGUI::setTimeline ( bool  $a_value)

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

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

◆ show()

ilContainerNewsSettingsGUI::show ( )

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

References initForm().

66  : void
67  {
68  $form = $this->initForm();
69  $this->tpl->setContent($form->getHTML());
70  }
+ 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: