ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilContainerNewsSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $ctrl;
18
22 protected $tpl;
23
27 protected $lng;
28
32 protected $setting;
33
37 protected $parent_gui;
38
42 protected $object;
43
47 public function __construct(ilObjectGUI $a_parent_gui)
48 {
49 global $DIC;
50
51 $this->ctrl = $DIC->ctrl();
52 $this->lng = $DIC->language();
53 $this->tpl = $DIC["tpl"];
54 $this->setting = $DIC["ilSetting"];
55 $this->parent_gui = $a_parent_gui;
56 $this->object = $this->parent_gui->object;
57 }
58
62 public function executeCommand()
63 {
64 $next_class = $this->ctrl->getNextClass($this);
65 $cmd = $this->ctrl->getCmd("show");
66
67 switch ($next_class) {
68 default:
69 if (in_array($cmd, array("show", "save"))) {
70 $this->$cmd();
71 }
72 }
73 }
74
81 public function show()
82 {
83 $form = $this->initForm();
84 $this->tpl->setContent($form->getHTML());
85 }
86
90 public function initForm()
91 {
92 include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
93 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
95
96 if ($this->setting->get('block_activated_news')) {
97 // Container tools (calendar, news, ... activation)
98 $news = new ilCheckboxInputGUI($this->lng->txt('obj_tool_setting_news'), ilObjectServiceSettingsGUI::NEWS_VISIBILITY);
99 $news->setValue(1);
100 $news->setChecked($this->object->getNewsBlockActivated());
101 $news->setInfo($this->lng->txt('obj_tool_setting_news_info'));
102 $form->addItem($news);
103
104 if (in_array(ilObject::_lookupType($this->object->getId()), array('crs', 'grp'))) {
105 $ref_id = array_pop(ilObject::_getAllReferences($this->object->getId()));
106 include_once 'Services/Membership/classes/class.ilMembershipNotifications.php';
108 }
109 }
110
111 // timeline
112 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline"), "news_timeline");
113 $cb->setInfo($this->lng->txt("cont_news_timeline_info"));
114 $cb->setChecked($this->object->getNewsTimeline());
115 $form->addItem($cb);
116
117 // ...timeline: auto entries
118 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_auto_entries"), "news_timeline_auto_entries");
119 $cb2->setInfo($this->lng->txt("cont_news_timeline_auto_entries_info"));
120 $cb2->setChecked($this->object->getNewsTimelineAutoEntries());
121 $cb->addSubItem($cb2);
122
123 // ...timeline: landing page
124 $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_landing_page"), "news_timeline_landing_page");
125 $cb2->setInfo($this->lng->txt("cont_news_timeline_landing_page_info"));
126 $cb2->setChecked($this->object->getNewsTimelineLandingPage());
127 $cb->addSubItem($cb2);
128
129 // save and cancel commands
130 $form->addCommandButton("save", $this->lng->txt("save"));
131
132 $form->setTitle($this->lng->txt("cont_news_settings"));
133 $form->setFormAction($this->ctrl->getFormAction($this));
134
135 return $form;
136 }
137
141 public function save()
142 {
143 $form = $this->initForm();
144 if ($form->checkInput()) {
145 include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
146 $this->object->setNewsBlockActivated($form->getInput(ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
147 $this->object->setNewsTimeline($form->getInput("news_timeline"));
148 $this->object->setNewsTimelineAutoEntries($form->getInput("news_timeline_auto_entries"));
149 $this->object->setNewsTimelineLandingPage($form->getInput("news_timeline_landing_page"));
150
151
152 if ($this->setting->get('block_activated_news')) {
153 if (in_array(ilObject::_lookupType($this->object->getId()), array('crs', 'grp'))) {
154 $ref_id = array_pop(ilObject::_getAllReferences($this->object->getId()));
155
156 include_once "Services/Membership/classes/class.ilMembershipNotifications.php";
158 }
159 }
160
161 $this->object->update();
162 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
163 $this->ctrl->redirect($this, "");
164 } else {
165 $form->setValuesByPost();
166 $this->tpl->setContent($form->getHtml());
167 }
168 }
169}
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
__construct(ilObjectGUI $a_parent_gui)
Constructor.
static importFromForm($a_ref_id, ilPropertyFormGUI $a_form=null)
Import notification settings from form.
static addToSettingsForm($a_ref_id, ilPropertyFormGUI $a_form=null, ilFormPropertyGUI $a_input=null)
Add notification settings to form.
Class ilObjectGUI Basic methods of all Output classes.
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.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7