ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 const AUTO_RATING_NEW_OBJECTS = 'cont_auto_rate_new_obj';
19 const INFO_TAB_VISIBILITY = 'cont_show_info_tab';
20 const TAXONOMIES = 'cont_taxonomies';
21 const TAG_CLOUD = 'cont_tag_cloud';
22
23 private $gui = null;
24 private $modes = array();
25 private $obj_id = 0;
26
31 public function __construct($a_parent_gui, $a_obj_id, $a_modes)
32 {
33 $this->gui = $a_parent_gui;
34 $this->modes = $a_modes;
35 $this->obj_id = $a_obj_id;
36 }
37
38
39
44 public function executeCommand()
45 {
46 global $ilCtrl;
47
48 $next_class = $ilCtrl->getNextClass($this);
49 $cmd = $ilCtrl->getCmd('editSettings');
50
51 switch($next_class)
52 {
53 default:
54 $this->$cmd();
55 break;
56 }
57 }
58
64 public static function initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
65 {
66 global $ilSetting;
67
68 // info tab
69 if(in_array(self::INFO_TAB_VISIBILITY, $services))
70 {
71 $info = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_info_tab'), self::INFO_TAB_VISIBILITY);
72 $info->setValue(1);
74 $a_obj_id,
75 self::INFO_TAB_VISIBILITY,
76 true
77 ));
78 //$info->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_info_tab'));
79 $info->setInfo($GLOBALS['lng']->txt('obj_tool_setting_info_tab_info'));
80 $form->addItem($info);
81 }
82
83 // calendar
84 if(in_array(self::CALENDAR_VISIBILITY, $services))
85 {
86 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
87 if(ilCalendarSettings::_getInstance()->isEnabled())
88 {
89 // Container tools (calendar, news, ... activation)
90 $cal = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_calendar'), self::CALENDAR_VISIBILITY);
91 $cal->setValue(1);
92 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
93 $cal->setChecked(ilCalendarSettings::lookupCalendarActivated($a_obj_id));
94 //$cal->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_calendar'));
95 $cal->setInfo($GLOBALS['lng']->txt('obj_tool_setting_calendar_info'));
96 $form->addItem($cal);
97 }
98 }
99
100 // news
101 if(in_array(self::NEWS_VISIBILITY, $services))
102 {
103 if($ilSetting->get('block_activated_news'))
104 {
105 // Container tools (calendar, news, ... activation)
106 $news = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_news'), self::NEWS_VISIBILITY);
107 $news->setValue(1);
108 $news->setChecked(ilContainer::_lookupContainerSetting(
109 $a_obj_id,
110 self::NEWS_VISIBILITY,
111 $ilSetting->get('block_activated_news',true)
112 ));
113 //$news->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_news'));
114 $news->setInfo($GLOBALS['lng']->txt('obj_tool_setting_news_info'));
115 $form->addItem($news);
116 }
117 }
118
119 // tag cloud
120 if(in_array(self::TAG_CLOUD, $services))
121 {
122 $tags_active = new ilSetting("tags");
123 if($tags_active->get("enable", false))
124 {
125 $tag = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_tag_cloud'), self::TAG_CLOUD);
126 $tag->setInfo($GLOBALS['lng']->txt('obj_tool_setting_tag_cloud_info'));
127 $tag->setValue(1);
129 $a_obj_id,
130 self::TAG_CLOUD,
131 false
132 ));
133 $form->addItem($tag);
134 }
135 }
136
137 // taxonomies
138 if(in_array(self::TAXONOMIES, $services))
139 {
140 $tax = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_taxonomies'), self::TAXONOMIES);
141 $tax->setValue(1);
143 $a_obj_id,
144 self::TAXONOMIES,
145 false
146 ));
147 $form->addItem($tax);
148 }
149
150 // auto rating
151 if(in_array(self::AUTO_RATING_NEW_OBJECTS, $services))
152 {
153 $GLOBALS['lng']->loadLanguageModule("rating");
154
155 // auto rating for new objects
156 $rate = new ilCheckboxInputGUI($GLOBALS['lng']->txt('rating_new_objects_auto'), self::AUTO_RATING_NEW_OBJECTS);
157 $rate->setValue(1);
158 //$rate->setOptionTitle($GLOBALS['lng']->txt('rating_new_objects_auto'));
159 $rate->setInfo($GLOBALS['lng']->txt('rating_new_objects_auto_info'));
160 $rate->setChecked(ilContainer::_lookupContainerSetting(
161 $a_obj_id,
162 self::AUTO_RATING_NEW_OBJECTS,
163 false
164 ));
165 $form->addItem($rate);
166 }
167
168 return $form;
169 }
170
177 public static function updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
178 {
179 // info
180 if(in_array(self::INFO_TAB_VISIBILITY, $services))
181 {
182 include_once './Services/Container/classes/class.ilContainer.php';
183 ilContainer::_writeContainerSetting($a_obj_id,self::INFO_TAB_VISIBILITY,(int) $form->getInput(self::INFO_TAB_VISIBILITY));
184 }
185
186 // calendar
187 if(in_array(self::CALENDAR_VISIBILITY, $services))
188 {
189 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
190 if(ilCalendarSettings::_getInstance()->isEnabled())
191 {
192 include_once './Services/Container/classes/class.ilContainer.php';
193 ilContainer::_writeContainerSetting($a_obj_id,self::CALENDAR_VISIBILITY,(int) $form->getInput(self::CALENDAR_VISIBILITY));
194 }
195 }
196
197 // news
198 if(in_array(self::NEWS_VISIBILITY, $services))
199 {
200 include_once './Services/Container/classes/class.ilContainer.php';
201 ilContainer::_writeContainerSetting($a_obj_id,self::NEWS_VISIBILITY,(int) $form->getInput(self::NEWS_VISIBILITY));
202 }
203
204 // rating
205 if(in_array(self::AUTO_RATING_NEW_OBJECTS, $services))
206 {
207 include_once './Services/Container/classes/class.ilContainer.php';
208 ilContainer::_writeContainerSetting($a_obj_id,self::AUTO_RATING_NEW_OBJECTS,(int) $form->getInput(self::AUTO_RATING_NEW_OBJECTS));
209 }
210
211 // taxonomies
212 if(in_array(self::TAXONOMIES, $services))
213 {
214 include_once './Services/Container/classes/class.ilContainer.php';
215 ilContainer::_writeContainerSetting($a_obj_id,self::TAXONOMIES,(int) $form->getInput(self::TAXONOMIES));
216 }
217
218 // tag cloud
219 if(in_array(self::TAG_CLOUD, $services))
220 {
221 include_once './Services/Container/classes/class.ilContainer.php';
222 ilContainer::_writeContainerSetting($a_obj_id,self::TAG_CLOUD,(int) $form->getInput(self::TAG_CLOUD));
223 }
224
225 return true;
226 }
227
228
233 public function getModes()
234 {
235 return $this->modes;
236 }
237
242 public function getObjId()
243 {
244 return $this->obj_id;
245 }
246
247 protected function cancel()
248 {
249 $GLOBALS['ilCtrl']->returnToParent($this);
250 }
251
256 protected function editSettings(ilPropertyFormGUI $form = null)
257 {
258 if(!$form instanceof ilPropertyFormGUI)
259 {
260 $form = $this->initSettingsForm();
261 }
262 $GLOBALS['tpl']->setContent($form->getHTML());
263 }
264
265
269 protected function updateToolSettings()
270 {
271 $form = $this->initSettingsForm();
272 if($form->checkInput())
273 {
274 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
275 if(ilCalendarSettings::_getInstance()->isEnabled())
276 {
277 if($this->isModeActive(self::CALENDAR_VISIBILITY))
278 {
279 ilContainer::_writeContainerSetting($this->getObjId(),'show_calendar',(int) $form->getInput('calendar'));
280 }
281 }
282 ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'),true);
283 $GLOBALS['ilCtrl']->redirect($this);
284 }
285
286 ilUtil::sendFailure($GLOBALS['lng']->txt('err_check_input'));
287 $form->setValuesByPost();
288 $this->editSettings($form);
289 }
290
296 protected function isModeActive($a_mode)
297 {
298 return in_array($a_mode, $this->getModes());
299 }
300
301}
302?>
static _getInstance()
get singleton instance
static lookupCalendarActivated($a_obj_id)
This class represents a checkbox property in a property form.
_lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
_writeContainerSetting($a_id, $a_keyword, $a_value)
GUI class for service settings (calendar, notes, comments)
__construct($a_parent_gui, $a_obj_id, $a_modes)
Constructor.
static initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Init service settings form.
editSettings(ilPropertyFormGUI $form=null)
Edit tool settings (calendar, news, comments, ...)
static updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Update service settings.
isModeActive($a_mode)
Check if specific mode is active.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
ILIAS Setting Class.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$GLOBALS['ct_recipient']
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35