ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectServiceSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
15 {
16  const CALENDAR_VISIBILITY = 'cont_show_calendar';
17  const NEWS_VISIBILITY = 'cont_show_news';
18 
19  private $gui = null;
20  private $modes = array();
21  private $obj_id = 0;
22 
27  public function __construct($a_parent_gui, $a_obj_id, $a_modes)
28  {
29  $this->gui = $a_parent_gui;
30  $this->modes = $a_modes;
31  $this->obj_id = $a_obj_id;
32  }
33 
34 
35 
40  public function executeCommand()
41  {
42  global $ilCtrl;
43 
44  $next_class = $ilCtrl->getNextClass($this);
45  $cmd = $ilCtrl->getCmd('editSettings');
46 
47  switch($next_class)
48  {
49  default:
50  $this->$cmd();
51  break;
52  }
53  }
54 
60  public static function initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
61  {
62  global $ilSetting;
63 
64  if(in_array(self::CALENDAR_VISIBILITY, $services))
65  {
66  include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
67  if(ilCalendarSettings::_getInstance()->isEnabled())
68  {
69  // Container tools (calendar, news, ... activation)
70  $cal = new ilCheckboxInputGUI('', self::CALENDAR_VISIBILITY);
71  $cal->setValue(1);
72  include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
73  $cal->setChecked(ilCalendarSettings::lookupCalendarActivated($a_obj_id));
74  $cal->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_calendar'));
75  $form->addItem($cal);
76  }
77  }
78  if(in_array(self::NEWS_VISIBILITY, $services))
79  {
80  if($ilSetting->get('block_activated_news'))
81  {
82  // Container tools (calendar, news, ... activation)
83  $news = new ilCheckboxInputGUI('', self::NEWS_VISIBILITY);
84  $news->setValue(1);
85  $news->setChecked(ilContainer::_lookupContainerSetting(
86  $a_obj_id,
87  self::NEWS_VISIBILITY,
88  $ilSetting->get('block_activated_news',true)
89  ));
90  $news->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_news'));
91  $form->addItem($news);
92  }
93  }
94 
95  return $form;
96  }
97 
104  public static function updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
105  {
106  if(in_array(self::CALENDAR_VISIBILITY, $services))
107  {
108  include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
109  if(ilCalendarSettings::_getInstance()->isEnabled())
110  {
111  include_once './Services/Container/classes/class.ilContainer.php';
112  ilContainer::_writeContainerSetting($a_obj_id,self::CALENDAR_VISIBILITY,(int) $form->getInput(self::CALENDAR_VISIBILITY));
113  }
114  }
115  if(in_array(self::NEWS_VISIBILITY, $services))
116  {
117  include_once './Services/Container/classes/class.ilContainer.php';
118  ilContainer::_writeContainerSetting($a_obj_id,self::NEWS_VISIBILITY,(int) $form->getInput(self::NEWS_VISIBILITY));
119  }
120 
121  return true;
122  }
123 
124 
129  public function getModes()
130  {
131  return $this->modes;
132  }
133 
138  public function getObjId()
139  {
140  return $this->obj_id;
141  }
142 
143  protected function cancel()
144  {
145  $GLOBALS['ilCtrl']->returnToParent($this);
146  }
147 
152  protected function editSettings(ilPropertyFormGUI $form = null)
153  {
154  if(!$form instanceof ilPropertyFormGUI)
155  {
156  $form = $this->initSettingsForm();
157  }
158  $GLOBALS['tpl']->setContent($form->getHTML());
159  }
160 
161 
165  protected function updateToolSettings()
166  {
167  $form = $this->initSettingsForm();
168  if($form->checkInput())
169  {
170  include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
171  if(ilCalendarSettings::_getInstance()->isEnabled())
172  {
173  if($this->isModeActive(self::CALENDAR_VISIBILITY))
174  {
175  ilContainer::_writeContainerSetting($this->getObjId(),'show_calendar',(int) $form->getInput('calendar'));
176  }
177  }
178  ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'),true);
179  $GLOBALS['ilCtrl']->redirect($this);
180  }
181 
182  ilUtil::sendFailure($GLOBALS['lng']->txt('err_check_input'));
183  $form->setValuesByPost();
184  $this->editSettings($form);
185  }
186 
192  protected function isModeActive($a_mode)
193  {
194  return in_array($a_mode, $this->getModes());
195  }
196 
197 }
198 ?>