ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  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  function executeCommand()
63  {
64  $next_class = $this->ctrl->getNextClass($this);
65  $cmd = $this->ctrl->getCmd("show");
66 
67  switch ($next_class)
68  {
69  default:
70  if (in_array($cmd, array("show", "save")))
71  {
72  $this->$cmd();
73  }
74  }
75  }
76 
83  function show()
84  {
85  $form = $this->initForm();
86  $this->tpl->setContent($form->getHTML());
87  }
88 
92  public function initForm()
93  {
94  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
95  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
96  $form = new ilPropertyFormGUI();
97 
98  if($this->setting->get('block_activated_news'))
99  {
100  // Container tools (calendar, news, ... activation)
101  $news = new ilCheckboxInputGUI($this->lng->txt('obj_tool_setting_news'), ilObjectServiceSettingsGUI::NEWS_VISIBILITY);
102  $news->setValue(1);
103  $news->setChecked($this->object->getNewsBlockActivated());
104  $news->setInfo($this->lng->txt('obj_tool_setting_news_info'));
105  $form->addItem($news);
106 
107  if (in_array(ilObject::_lookupType($this->object->getId()), array('crs', 'grp')))
108  {
109  $ref_id = array_pop(ilObject::_getAllReferences($this->object->getId()));
110  include_once 'Services/Membership/classes/class.ilMembershipNotifications.php';
112  }
113  }
114 
115  // timeline
116  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline"), "news_timeline");
117  $cb->setInfo($this->lng->txt("cont_news_timeline_info"));
118  $cb->setChecked($this->object->getNewsTimeline());
119  $form->addItem($cb);
120 
121  // ...timeline: auto entries
122  $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_auto_entries"), "news_timeline_auto_entries");
123  $cb2->setInfo($this->lng->txt("cont_news_timeline_auto_entries_info"));
124  $cb2->setChecked($this->object->getNewsTimelineAutoEntries());
125  $cb->addSubItem($cb2);
126 
127  // ...timeline: landing page
128  $cb2 = new ilCheckboxInputGUI($this->lng->txt("cont_news_timeline_landing_page"), "news_timeline_landing_page");
129  $cb2->setInfo($this->lng->txt("cont_news_timeline_landing_page_info"));
130  $cb2->setChecked($this->object->getNewsTimelineLandingPage());
131  $cb->addSubItem($cb2);
132 
133  // save and cancel commands
134  $form->addCommandButton("save", $this->lng->txt("save"));
135 
136  $form->setTitle($this->lng->txt("cont_news_settings"));
137  $form->setFormAction($this->ctrl->getFormAction($this));
138 
139  return $form;
140  }
141 
145  public function save()
146  {
147  $form = $this->initForm();
148  if ($form->checkInput())
149  {
150  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
151  $this->object->setNewsBlockActivated($form->getInput(ilObjectServiceSettingsGUI::NEWS_VISIBILITY));
152  $this->object->setNewsTimeline($form->getInput("news_timeline"));
153  $this->object->setNewsTimelineAutoEntries($form->getInput("news_timeline_auto_entries"));
154  $this->object->setNewsTimelineLandingPage($form->getInput("news_timeline_landing_page"));
155 
156 
157  if($this->setting->get('block_activated_news'))
158  {
159  if (in_array(ilObject::_lookupType($this->object->getId()), array('crs', 'grp')))
160  {
161  $ref_id = array_pop(ilObject::_getAllReferences($this->object->getId()));
162 
163  include_once "Services/Membership/classes/class.ilMembershipNotifications.php";
165  }
166  }
167 
168  $this->object->update();
169  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
170  $this->ctrl->redirect($this, "");
171  }
172  else
173  {
174  $form->setValuesByPost();
175  $this->tpl->setContent($form->getHtml());
176  }
177  }
178 
179 }
180 
181 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents a property form user interface.
$cmd
Definition: sahs_server.php:35
This class represents a checkbox property in a property form.
static _getAllReferences($a_id)
get all reference ids of object
setInfo($a_info)
Set Information Text.
__construct(ilObjectGUI $a_parent_gui)
Constructor.
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.
setValue($a_value)
Set Value.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39
Create new PHPExcel object
obj_idprivate
global $DIC
static importFromForm($a_ref_id, ilPropertyFormGUI $a_form=null)
Import notification settings from form.