ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilContainerNewsSettingsGUI Class Reference

News settings for containers. More...

+ Collaboration diagram for ilContainerNewsSettingsGUI:

Public Member Functions

 __construct (ilObjectGUI $a_parent_gui)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 show ()
 Show. More...
 
 initForm ()
 Init settings form. More...
 
 save ()
 Save settings form. More...
 
 initDefaultOptions ()
 Set all possible news options as false;. More...
 
 setTimeline (bool $a_value)
 Set if the container has timeline or not. More...
 
 getTimeline ()
 Get if the container has timeline or not. More...
 
 setCronNotifications (bool $a_value)
 Set if the container has a configurable cron job to send notifications. More...
 
 getCronNotifications ()
 Get if the container has a configurable cron job to send notifications. More...
 
 setHideByDate (bool $a_value)
 Set if the container can hide news created before a date. More...
 
 getHideByDate ()
 Get if the container can hide news created before a date. More...
 
 setPublicNotification (bool $a_value)
 Set if this repository object has public notifications. More...
 
 getPublicNotification ()
 Get if this repository object has public notifications available. More...
 
 setNewsBlockForced (bool $a_value)
 Set if the News block is forced. More...
 
 getNewsBlockForced ()
 Get if the repository object has the news block forced. More...
 

Protected Attributes

 $ctrl
 
 $tpl
 
 $lng
 
 $setting
 
 $parent_gui
 
 $object
 
 $has_timeline
 
 $has_cron_notifications
 
 $has_hide_by_date
 
 $has_public_notification
 
 $has_block_forced
 

Detailed Description

News settings for containers.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilContainerNewsSettingsGUI::__construct ( ilObjectGUI  $a_parent_gui)

Constructor.

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

73 {
74 global $DIC;
75
76 $this->ctrl = $DIC->ctrl();
77 $this->lng = $DIC->language();
78 $this->lng->loadLanguageModule("news");
79 $this->tpl = $DIC["tpl"];
80 $this->setting = $DIC["ilSetting"];
81 $this->parent_gui = $a_parent_gui;
82 $this->object = $this->parent_gui->object;
83
84 $this->initDefaultOptions();
85 }
initDefaultOptions()
Set all possible news options as false;.
$DIC
Definition: xapitoken.php:46

References $DIC, and initDefaultOptions().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilContainerNewsSettingsGUI::executeCommand ( )

Execute command.

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

91 {
92 $next_class = $this->ctrl->getNextClass($this);
93 $cmd = $this->ctrl->getCmd("show");
94
95 switch ($next_class) {
96 default:
97 if (in_array($cmd, array("show", "save"))) {
98 $this->$cmd();
99 }
100 }
101 }

◆ getCronNotifications()

ilContainerNewsSettingsGUI::getCronNotifications ( )

Get if the container has a configurable cron job to send notifications.

Returns
mixed

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

321 : bool
322 {
323 return $this->getCronNotifications();
324 }
getCronNotifications()
Get if the container has a configurable cron job to send notifications.

References getCronNotifications().

Referenced by getCronNotifications().

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

◆ getHideByDate()

ilContainerNewsSettingsGUI::getHideByDate ( )

Get if the container can hide news created before a date.

Returns
bool

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

References $has_hide_by_date.

◆ getNewsBlockForced()

ilContainerNewsSettingsGUI::getNewsBlockForced ( )

Get if the repository object has the news block forced.

Returns
bool

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

References $has_block_forced.

◆ getPublicNotification()

ilContainerNewsSettingsGUI::getPublicNotification ( )

Get if this repository object has public notifications available.

Returns
bool

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

References $has_public_notification.

◆ getTimeline()

ilContainerNewsSettingsGUI::getTimeline ( )

Get if the container has timeline or not.

Returns
bool

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

References $has_timeline.

◆ initDefaultOptions()

ilContainerNewsSettingsGUI::initDefaultOptions ( )

Set all possible news options as false;.

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

283 {
284 $this->has_timeline = false;
285 $this->has_cron_notifications = false;
286 $this->has_hide_by_date = false;
287 $this->has_block_forced = false;
288 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initForm()

ilContainerNewsSettingsGUI::initForm ( )

Init settings form.

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

119 {
120 $form = new ilPropertyFormGUI();
121 //from crs/grp/cat settings - additional feature - news
122
123 if ($this->setting->get('block_activated_news')) {
124 $news = new ilCheckboxInputGUI($this->lng->txt('news_news_block'), ilObjectServiceSettingsGUI::NEWS_VISIBILITY);
125 $news->setValue(1);
126 if ($this->has_block_forced) {
127 $news->setChecked(true);
128 $news->setDisabled(true);
129 } else {
130 $news->setChecked($this->object->getNewsBlockActivated());
131 }
132 $news->setInfo($this->lng->txt('obj_tool_setting_news_info'));
134 $form->addItem($news);
135 }
136
137 // Timeline (courses and groups)
138 if ($this->has_timeline) {
139 // timeline
140 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline"), "news_timeline");
141 $cb->setInfo($this->lng->txt("cont_news_timeline_info"));
142 $cb->setChecked($this->object->getNewsTimeline());
143 $form->addItem($cb);
144
145 // ...timeline: auto entries
146 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_auto_entries"), "news_timeline_auto_entries");
147 $cb2->setInfo($this->lng->txt("cont_news_timeline_auto_entries_info"));
148 $cb2->setChecked($this->object->getNewsTimelineAutoEntries());
149 $cb->addSubItem($cb2);
150
151 // ...timeline: landing page
152 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_landing_page"), "news_timeline_landing_page");
153 $cb2->setInfo($this->lng->txt("cont_news_timeline_landing_page_info"));
154 $cb2->setChecked($this->object->getNewsTimelineLandingPage());
155 $cb->addSubItem($cb2);
156 }
157
158 // Cron Notifications (courses and groups)
159 if ($this->has_cron_notifications) {
160 if (in_array(ilObject::_lookupType($this->object->getId()), array('crs', 'grp'))) {
161 $ref_id = array_pop(ilObject::_getAllReferences($this->object->getId()));
162 include_once 'Services/Membership/classes/class.ilMembershipNotifications.php';
164 }
165 }
166
167 $block_id = $this->ctrl->getContextObjId();
168
169 // Visibility by date
170 $hide_news_per_date = ilBlockSetting::_lookup(
172 "hide_news_per_date",
173 0,
174 $block_id
175 );
176 $hide_news_date = ilBlockSetting::_lookup(
178 "hide_news_date",
179 0,
180 $block_id
181 );
182
183 if ($hide_news_date != "") {
184 $hide_news_date = explode(" ", $hide_news_date);
185 }
186
187 // Hide news before a date (courses, groups and categories)
188 if ($this->has_hide_by_date) {
189 //Hide news per date
190 $hnpd = new ilCheckboxInputGUI(
191 $this->lng->txt("news_hide_news_per_date"),
192 "hide_news_per_date"
193 );
194 $hnpd->setInfo($this->lng->txt("news_hide_news_per_date_info"));
195 $hnpd->setChecked($hide_news_per_date);
196
197 $dt_prop = new ilDateTimeInputGUI($this->lng->txt("news_hide_news_date"), "hide_news_date");
198 $dt_prop->setRequired(true);
199
200 if ($hide_news_date != "") {
201 $dt_prop->setDate(new ilDateTime($hide_news_date[0] . ' ' . $hide_news_date[1], IL_CAL_DATETIME));
202 }
203
204 $dt_prop->setShowTime(true);
205
206 $hnpd->addSubItem($dt_prop);
207
208 $form->addItem($hnpd);
209 }
210
211 // public notifications (forums)
212 if ($this->has_public_notification) {
213 $public = ilBlockSetting::_lookup("news", "public_notifications", 0, $block_id);
214
215 $ch = new ilCheckboxInputGUI(
216 $this->lng->txt("news_notifications_public"),
217 "public_notifications"
218 );
219 $ch->setInfo($this->lng->txt("news_notifications_public_info"));
220 $ch->setChecked($public);
221 $form->addItem($ch);
222 }
223
224 $form->setTitle($this->lng->txt("cont_news_settings"));
225 $form->setFormAction($this->ctrl->getFormAction($this));
226 $form->addCommandButton("save", $this->lng->txt("save"));
227
228 return $form;
229 }
const IL_CAL_DATETIME
static _lookup($a_type, $a_setting, $a_user=0, $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($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 _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.

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

Referenced by save(), and show().

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

◆ save()

ilContainerNewsSettingsGUI::save ( )

Save settings form.

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

235 {
236 $form = $this->initForm();
237 if ($form->checkInput()) {
238 include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
239 //non container objects force this news block (forums etc.)
240 if (!$this->has_block_forced) {
241 $this->object->setNewsBlockActivated($form->getInput(ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
242 }
243 if ($this->has_timeline) {
244 $this->object->setNewsTimeline($form->getInput("news_timeline"));
245 $this->object->setNewsTimelineAutoEntries($form->getInput("news_timeline_auto_entries"));
246 $this->object->setNewsTimelineLandingPage($form->getInput("news_timeline_landing_page"));
247 }
248 if ($this->setting->get('block_activated_news')) {
249 //save contextblock settings
250 $context_block_settings = array(
251 "public_feed" => $_POST["notifications_public_feed"],
252 "default_visibility" => $_POST["default_visibility"],
253 "hide_news_per_date" => $_POST["hide_news_per_date"],
254 "hide_news_date" => $_POST["hide_news_date"]
255 );
256 if ($this->has_public_notification) {
257 $context_block_settings["public_notifications"] = $_POST['public_notifications'];
258 }
259
260 ilNewsForContextBlockGUI::writeSettings($context_block_settings);
261
262 if (in_array(ilObject::_lookupType($this->object->getId()), array('crs', 'grp'))) {
263 $ref_id = array_pop(ilObject::_getAllReferences($this->object->getId()));
264
265 include_once "Services/Membership/classes/class.ilMembershipNotifications.php";
267 }
268 }
269
270 $this->object->update();
271 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
272 $this->ctrl->redirect($this, "");
273 } else {
274 $form->setValuesByPost();
275 $this->tpl->setContent($form->getHtml());
276 }
277 }
$_POST["username"]
static importFromForm($a_ref_id, ilPropertyFormGUI $a_form=null)
Import notification settings from form.

References $_POST, ilObject\_getAllReferences(), ilObject\_lookupType(), ilMembershipNotifications\importFromForm(), initForm(), ilObjectServiceSettingsGUI\NEWS_VISIBILITY, and ilNewsForContextBlockGUI\writeSettings().

+ Here is the call graph for this function:

◆ setCronNotifications()

ilContainerNewsSettingsGUI::setCronNotifications ( bool  $a_value)

Set if the container has a configurable cron job to send notifications.

Parameters
bool$a_value

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

313 {
314 $this->has_cron_notifications = $a_value;
315 }

◆ setHideByDate()

ilContainerNewsSettingsGUI::setHideByDate ( bool  $a_value)

Set if the container can hide news created before a date.

Parameters
bool$a_value

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

331 {
332 $this->has_hide_by_date = $a_value;
333 }

◆ setNewsBlockForced()

ilContainerNewsSettingsGUI::setNewsBlockForced ( bool  $a_value)

Set if the News block is forced.

Parameters
bool$a_value

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

367 {
368 $this->has_block_forced = $a_value;
369 }

◆ setPublicNotification()

ilContainerNewsSettingsGUI::setPublicNotification ( bool  $a_value)

Set if this repository object has public notifications.

Parameters
bool$a_value

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

349 {
350 $this->has_public_notification = $a_value;
351 }

◆ setTimeline()

ilContainerNewsSettingsGUI::setTimeline ( bool  $a_value)

Set if the container has timeline or not.

Parameters
bool$a_value

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

295 {
296 $this->has_timeline = $a_value;
297 }

◆ show()

ilContainerNewsSettingsGUI::show ( )

Show.

Parameters

return

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

110 {
111 $form = $this->initForm();
112 $this->tpl->setContent($form->getHTML());
113 }

References initForm().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilContainerNewsSettingsGUI::$ctrl
protected

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

◆ $has_block_forced

ilContainerNewsSettingsGUI::$has_block_forced
protected

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

Referenced by getNewsBlockForced().

◆ $has_cron_notifications

ilContainerNewsSettingsGUI::$has_cron_notifications
protected

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

◆ $has_hide_by_date

ilContainerNewsSettingsGUI::$has_hide_by_date
protected

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

Referenced by getHideByDate().

◆ $has_public_notification

ilContainerNewsSettingsGUI::$has_public_notification
protected

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

Referenced by getPublicNotification().

◆ $has_timeline

ilContainerNewsSettingsGUI::$has_timeline
protected

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

Referenced by getTimeline().

◆ $lng

ilContainerNewsSettingsGUI::$lng
protected

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

◆ $object

ilContainerNewsSettingsGUI::$object
protected

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

◆ $parent_gui

ilContainerNewsSettingsGUI::$parent_gui
protected

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

◆ $setting

ilContainerNewsSettingsGUI::$setting
protected

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

◆ $tpl

ilContainerNewsSettingsGUI::$tpl
protected

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


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