ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 // unfortunately the following constants are not stored
17 // in a non-GUI class, other classes are currently directly
18 // accessing these, see ilObjectDataSet (changes should be
19 // made there accordingly)
20
21 const CALENDAR_VISIBILITY = 'cont_show_calendar';
22 const NEWS_VISIBILITY = 'cont_show_news';
23 const AUTO_RATING_NEW_OBJECTS = 'cont_auto_rate_new_obj';
24 const INFO_TAB_VISIBILITY = 'cont_show_info_tab';
25 const TAXONOMIES = 'cont_taxonomies';
26 const TAG_CLOUD = 'cont_tag_cloud';
27 const CUSTOM_METADATA = 'cont_custom_md';
28
29 private $gui = null;
30 private $modes = array();
31 private $obj_id = 0;
32
37 public function __construct($a_parent_gui, $a_obj_id, $a_modes)
38 {
39 $this->gui = $a_parent_gui;
40 $this->modes = $a_modes;
41 $this->obj_id = $a_obj_id;
42 }
43
44
45
50 public function executeCommand()
51 {
52 global $ilCtrl;
53
54 $next_class = $ilCtrl->getNextClass($this);
55 $cmd = $ilCtrl->getCmd('editSettings');
56
57 switch($next_class)
58 {
59 default:
60 $this->$cmd();
61 break;
62 }
63 }
64
70 public static function initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
71 {
72 global $ilSetting;
73
74 // info tab
75 if(in_array(self::INFO_TAB_VISIBILITY, $services))
76 {
77 $info = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_info_tab'), self::INFO_TAB_VISIBILITY);
78 $info->setValue(1);
80 $a_obj_id,
81 self::INFO_TAB_VISIBILITY,
82 true
83 ));
84 //$info->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_info_tab'));
85 $info->setInfo($GLOBALS['lng']->txt('obj_tool_setting_info_tab_info'));
86 $form->addItem($info);
87 }
88
89 // calendar
90 if(in_array(self::CALENDAR_VISIBILITY, $services))
91 {
92 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
93 if(ilCalendarSettings::_getInstance()->isEnabled())
94 {
95 // Container tools (calendar, news, ... activation)
96 $cal = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_calendar'), self::CALENDAR_VISIBILITY);
97 $cal->setValue(1);
98 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
99 $cal->setChecked(ilCalendarSettings::lookupCalendarActivated($a_obj_id));
100 //$cal->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_calendar'));
101 $cal->setInfo($GLOBALS['lng']->txt('obj_tool_setting_calendar_info'));
102 $form->addItem($cal);
103 }
104 }
105
106 // news
107 if(in_array(self::NEWS_VISIBILITY, $services))
108 {
109 if($ilSetting->get('block_activated_news'))
110 {
111 // Container tools (calendar, news, ... activation)
112 $news = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_news'), self::NEWS_VISIBILITY);
113 $news->setValue(1);
114 $news->setChecked(ilContainer::_lookupContainerSetting(
115 $a_obj_id,
116 self::NEWS_VISIBILITY,
117 $ilSetting->get('block_activated_news',true)
118 ));
119 //$news->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_news'));
120 $news->setInfo($GLOBALS['lng']->txt('obj_tool_setting_news_info'));
121 $form->addItem($news);
122
123 if(in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp')))
124 {
125 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
126
127 include_once 'Services/Membership/classes/class.ilMembershipNotifications.php';
129 }
130 }
131 }
132
133 // (local) custom metadata
134 if(in_array(self::CUSTOM_METADATA, $services))
135 {
136 $md = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_custom_metadata'), self::CUSTOM_METADATA);
137 $md->setInfo($GLOBALS['lng']->txt('obj_tool_setting_custom_metadata_info'));
138 $md->setValue(1);
140 $a_obj_id,
141 self::CUSTOM_METADATA,
142 false
143 ));
144 $form->addItem($md);
145 }
146
147 // tag cloud
148 if(in_array(self::TAG_CLOUD, $services))
149 {
150 $tags_active = new ilSetting("tags");
151 if($tags_active->get("enable", false))
152 {
153 $tag = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_tag_cloud'), self::TAG_CLOUD);
154 $tag->setInfo($GLOBALS['lng']->txt('obj_tool_setting_tag_cloud_info'));
155 $tag->setValue(1);
157 $a_obj_id,
158 self::TAG_CLOUD,
159 false
160 ));
161 $form->addItem($tag);
162 }
163 }
164
165 // taxonomies
166 if(in_array(self::TAXONOMIES, $services))
167 {
168 $tax = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_taxonomies'), self::TAXONOMIES);
169 $tax->setValue(1);
171 $a_obj_id,
172 self::TAXONOMIES,
173 false
174 ));
175 $form->addItem($tax);
176 }
177
178 // auto rating
179 if(in_array(self::AUTO_RATING_NEW_OBJECTS, $services))
180 {
181 $GLOBALS['lng']->loadLanguageModule("rating");
182
183 // auto rating for new objects
184 $rate = new ilCheckboxInputGUI($GLOBALS['lng']->txt('rating_new_objects_auto'), self::AUTO_RATING_NEW_OBJECTS);
185 $rate->setValue(1);
186 //$rate->setOptionTitle($GLOBALS['lng']->txt('rating_new_objects_auto'));
187 $rate->setInfo($GLOBALS['lng']->txt('rating_new_objects_auto_info'));
188 $rate->setChecked(ilContainer::_lookupContainerSetting(
189 $a_obj_id,
190 self::AUTO_RATING_NEW_OBJECTS,
191 false
192 ));
193 $form->addItem($rate);
194 }
195
196 return $form;
197 }
198
205 public static function updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
206 {
207 // info
208 if(in_array(self::INFO_TAB_VISIBILITY, $services))
209 {
210 include_once './Services/Container/classes/class.ilContainer.php';
211 ilContainer::_writeContainerSetting($a_obj_id,self::INFO_TAB_VISIBILITY,(int) $form->getInput(self::INFO_TAB_VISIBILITY));
212 }
213
214 // calendar
215 if(in_array(self::CALENDAR_VISIBILITY, $services))
216 {
217 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
218 if(ilCalendarSettings::_getInstance()->isEnabled())
219 {
220 include_once './Services/Container/classes/class.ilContainer.php';
221 ilContainer::_writeContainerSetting($a_obj_id,self::CALENDAR_VISIBILITY,(int) $form->getInput(self::CALENDAR_VISIBILITY));
222 }
223 }
224
225 // news
226 if(in_array(self::NEWS_VISIBILITY, $services))
227 {
228 include_once './Services/Container/classes/class.ilContainer.php';
229 ilContainer::_writeContainerSetting($a_obj_id,self::NEWS_VISIBILITY,(int) $form->getInput(self::NEWS_VISIBILITY));
230
231 if(in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp')))
232 {
233 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
234
235 include_once "Services/Membership/classes/class.ilMembershipNotifications.php";
237 }
238 }
239
240 // rating
241 if(in_array(self::AUTO_RATING_NEW_OBJECTS, $services))
242 {
243 include_once './Services/Container/classes/class.ilContainer.php';
244 ilContainer::_writeContainerSetting($a_obj_id,self::AUTO_RATING_NEW_OBJECTS,(int) $form->getInput(self::AUTO_RATING_NEW_OBJECTS));
245 }
246
247 // taxonomies
248 if(in_array(self::TAXONOMIES, $services))
249 {
250 include_once './Services/Container/classes/class.ilContainer.php';
251 ilContainer::_writeContainerSetting($a_obj_id,self::TAXONOMIES,(int) $form->getInput(self::TAXONOMIES));
252 }
253
254 // tag cloud
255 if(in_array(self::TAG_CLOUD, $services))
256 {
257 include_once './Services/Container/classes/class.ilContainer.php';
258 ilContainer::_writeContainerSetting($a_obj_id,self::TAG_CLOUD,(int) $form->getInput(self::TAG_CLOUD));
259 }
260
261 // (local) custom metadata
262 if(in_array(self::CUSTOM_METADATA, $services))
263 {
264 include_once './Services/Container/classes/class.ilContainer.php';
265 ilContainer::_writeContainerSetting($a_obj_id,self::CUSTOM_METADATA,(int) $form->getInput(self::CUSTOM_METADATA));
266 }
267
268 return true;
269 }
270
271
276 public function getModes()
277 {
278 return $this->modes;
279 }
280
285 public function getObjId()
286 {
287 return $this->obj_id;
288 }
289
290 protected function cancel()
291 {
292 $GLOBALS['ilCtrl']->returnToParent($this);
293 }
294
299 protected function editSettings(ilPropertyFormGUI $form = null)
300 {
301 if(!$form instanceof ilPropertyFormGUI)
302 {
303 $form = $this->initSettingsForm();
304 }
305 $GLOBALS['tpl']->setContent($form->getHTML());
306 }
307
308
312 protected function updateToolSettings()
313 {
314 $form = $this->initSettingsForm();
315 if($form->checkInput())
316 {
317 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
318 if(ilCalendarSettings::_getInstance()->isEnabled())
319 {
320 if($this->isModeActive(self::CALENDAR_VISIBILITY))
321 {
322 ilContainer::_writeContainerSetting($this->getObjId(),'show_calendar',(int) $form->getInput('calendar'));
323 }
324 }
325 ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'),true);
326 $GLOBALS['ilCtrl']->redirect($this);
327 }
328
329 ilUtil::sendFailure($GLOBALS['lng']->txt('err_check_input'));
330 $form->setValuesByPost();
331 $this->editSettings($form);
332 }
333
339 protected function isModeActive($a_mode)
340 {
341 return in_array($a_mode, $this->getModes());
342 }
343
344}
345?>
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)
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.
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.
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.
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.
$info
Definition: example_052.php:80
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39