ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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{
19 protected $ctrl;
20
21 // unfortunately the following constants are not stored
22 // in a non-GUI class, other classes are currently directly
23 // accessing these, see ilObjectDataSet (changes should be
24 // made there accordingly)
25
26 const CALENDAR_VISIBILITY = 'cont_show_calendar';
27 const NEWS_VISIBILITY = 'cont_show_news';
28 const USE_NEWS = 'cont_use_news';
29 const AUTO_RATING_NEW_OBJECTS = 'cont_auto_rate_new_obj';
30 const INFO_TAB_VISIBILITY = 'cont_show_info_tab';
31 const TAXONOMIES = 'cont_taxonomies';
32 const TAG_CLOUD = 'cont_tag_cloud';
33 const CUSTOM_METADATA = 'cont_custom_md';
34 const BADGES = 'cont_badges';
35 const ORGU_POSITION_ACCESS = 'obj_orgunit_positions';
36 const SKILLS = 'cont_skills';
37 const FILTER = 'filter';
38 const BOOKING = 'cont_bookings';
39
40 private $gui = null;
41 private $modes = array();
42 private $obj_id = 0;
43
48 public function __construct($a_parent_gui, $a_obj_id, $a_modes)
49 {
50 global $DIC;
51
52 $this->ctrl = $DIC->ctrl();
53 $this->gui = $a_parent_gui;
54 $this->modes = $a_modes;
55 $this->obj_id = $a_obj_id;
56 }
57
58
59
64 public function executeCommand()
65 {
67
68 $next_class = $ilCtrl->getNextClass($this);
69 $cmd = $ilCtrl->getCmd('editSettings');
70
71 switch ($next_class) {
72 default:
73 $this->$cmd();
74 break;
75 }
76 }
77
83 public static function initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
84 {
85 global $DIC;
86
87 $ilSetting = $DIC->settings();
88 $ilCtrl = $DIC->ctrl();
89 $lng = $DIC->language();
90
91 $lng->loadLanguageModule("obj");
92
93 // info tab
94 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
95 $info = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_info_tab'), self::INFO_TAB_VISIBILITY);
96 $info->setValue(1);
98 $a_obj_id,
99 self::INFO_TAB_VISIBILITY,
100 true
101 ));
102 //$info->setOptionTitle($lng->txt('obj_tool_setting_info_tab'));
103 $info->setInfo($lng->txt('obj_tool_setting_info_tab_info'));
104 $form->addItem($info);
105 }
106
107 // calendar
108 if (in_array(self::CALENDAR_VISIBILITY, $services)) {
109 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
110 if (ilCalendarSettings::_getInstance()->isEnabled()) {
111 // Container tools (calendar, news, ... activation)
112 $cal = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_calendar'), self::CALENDAR_VISIBILITY);
113 $cal->setValue(1);
114 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
115 $cal->setChecked(ilCalendarSettings::lookupCalendarActivated($a_obj_id));
116 //$cal->setOptionTitle($lng->txt('obj_tool_setting_calendar'));
117 $cal->setInfo($lng->txt('obj_tool_setting_calendar_info'));
118 $form->addItem($cal);
119 }
120 }
121
122 // news
123 if (in_array(self::USE_NEWS, $services)) {
124 $news = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_use_news'), self::USE_NEWS);
125 $news->setValue(1);
127 $a_obj_id,
128 self::USE_NEWS,
129 true
130 );
131 $news->setChecked($checked);
132 $info = $lng->txt('obj_tool_setting_use_news_info');
133 if ($checked) {
134 $info .= " <a href='" . $ilCtrl->getLinkTargetByClass("ilcontainernewssettingsgui", "") .
135 "'>ยป " . $lng->txt('obj_tool_setting_use_news_open_settings') . "</a>";
136 }
137 $news->setInfo($info);
138 $form->addItem($news);
139 }
140 if (in_array(self::NEWS_VISIBILITY, $services)) {
141 if ($ilSetting->get('block_activated_news')) {
142 // Container tools (calendar, news, ... activation)
143 $news = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_news'), self::NEWS_VISIBILITY);
144 $news->setValue(1);
145 $news->setChecked(ilContainer::_lookupContainerSetting(
146 $a_obj_id,
147 self::NEWS_VISIBILITY,
148 $ilSetting->get('block_activated_news', true)
149 ));
150 //$news->setOptionTitle($lng->txt('obj_tool_setting_news'));
151 $news->setInfo($lng->txt('obj_tool_setting_news_info'));
152 $form->addItem($news);
153
154 if (in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp'))) {
155 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
156
157 include_once 'Services/Membership/classes/class.ilMembershipNotifications.php';
159 }
160 }
161 }
162
163 // (local) custom metadata
164 if (in_array(self::CUSTOM_METADATA, $services)) {
165 $md = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_custom_metadata'), self::CUSTOM_METADATA);
166 $md->setInfo($lng->txt('obj_tool_setting_custom_metadata_info'));
167 $md->setValue(1);
169 $a_obj_id,
170 self::CUSTOM_METADATA,
171 false
172 ));
173 $form->addItem($md);
174 }
175
176 // tag cloud
177 if (in_array(self::TAG_CLOUD, $services)) {
178 $tags_active = new ilSetting("tags");
179 if ($tags_active->get("enable", false)) {
180 $tag = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_tag_cloud'), self::TAG_CLOUD);
181 $tag->setInfo($lng->txt('obj_tool_setting_tag_cloud_info'));
182 $tag->setValue(1);
184 $a_obj_id,
185 self::TAG_CLOUD,
186 false
187 ));
188 $form->addItem($tag);
189 }
190 }
191
192 // taxonomies
193 if (in_array(self::TAXONOMIES, $services)) {
194 $tax = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_taxonomies'), self::TAXONOMIES);
195 $tax->setValue(1);
197 $a_obj_id,
198 self::TAXONOMIES,
199 false
200 ));
201 $form->addItem($tax);
202 }
203
204 // auto rating
205 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
206 $lng->loadLanguageModule("rating");
207
208 // auto rating for new objects
209 $rate = new ilCheckboxInputGUI($lng->txt('rating_new_objects_auto'), self::AUTO_RATING_NEW_OBJECTS);
210 $rate->setValue(1);
211 //$rate->setOptionTitle($lng->txt('rating_new_objects_auto'));
212 $rate->setInfo($lng->txt('rating_new_objects_auto_info'));
213 $rate->setChecked(ilContainer::_lookupContainerSetting(
214 $a_obj_id,
215 self::AUTO_RATING_NEW_OBJECTS,
216 false
217 ));
218 $form->addItem($rate);
219 }
220
221 // badges
222 if (in_array(self::BADGES, $services)) {
223 include_once 'Services/Badge/classes/class.ilBadgeHandler.php';
224 if (ilBadgeHandler::getInstance()->isActive()) {
225 $bdg = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_badges'), self::BADGES);
226 $bdg->setInfo($lng->txt('obj_tool_setting_badges_info'));
227 $bdg->setValue(1);
229 $a_obj_id,
230 self::BADGES,
231 false
232 ));
233 $form->addItem($bdg);
234 }
235 }
236 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
237 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
238 ilObject::_lookupType($a_obj_id)
239 );
240 if (
241 $position_settings->isActive()
242 ) {
243 $lia = new ilCheckboxInputGUI(
244 $GLOBALS['DIC']->language()->txt('obj_orgunit_positions'),
245 self::ORGU_POSITION_ACCESS
246 );
247 $lia->setInfo($GLOBALS['DIC']->language()->txt('obj_orgunit_positions_info'));
248 $lia->setValue(1);
249 $lia->setChecked(
250 (bool) ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($a_obj_id)
251 );
252 if (!$position_settings->isChangeableForObject()) {
253 $lia->setDisabled(true);
254 }
255 $form->addItem($lia);
256 }
257 }
258
259 // skills
260 if (in_array(self::SKILLS, $services)) {
261 $skmg_set = new ilSetting("skmg");
262 if ($skmg_set->get("enable_skmg")) {
263 $skill = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_skills'), self::SKILLS);
264 $skill->setInfo($lng->txt('obj_tool_setting_skills_info'));
265 $skill->setValue(1);
266 $skill->setChecked(ilContainer::_lookupContainerSetting(
267 $a_obj_id,
268 self::SKILLS,
269 false
270 ));
271 $form->addItem($skill);
272 }
273 }
274
275 // filter
276 if (in_array(self::FILTER, $services)) {
277 $filter = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_filter'), self::FILTER);
278 $filter->setInfo($lng->txt('obj_tool_setting_filter_info'));
279 $filter->setValue(1);
280 $filter->setChecked(ilContainer::_lookupContainerSetting(
281 $a_obj_id,
282 self::FILTER,
283 false
284 ));
285 $form->addItem($filter);
286
287 $filter_show_empty = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_filter_empty'), "filter_show_empty");
288 $filter_show_empty->setInfo($lng->txt('obj_tool_setting_filter_empty_info'));
289 $filter_show_empty->setValue(1);
290 $filter_show_empty->setChecked(ilContainer::_lookupContainerSetting(
291 $a_obj_id,
292 "filter_show_empty",
293 false
294 ));
295 $filter->addSubItem($filter_show_empty);
296 }
297 // booking tool
298 if (in_array(self::BOOKING, $services)) {
299 $book = new ilCheckboxInputGUI($lng->txt('obj_tool_booking'), self::BOOKING);
300 $book->setInfo($lng->txt('obj_tool_booking_info'));
301 $book->setValue(1);
302 $book->setChecked(ilContainer::_lookupContainerSetting(
303 $a_obj_id,
304 self::BOOKING,
305 false
306 ));
307 $form->addItem($book);
308 }
309
310 return $form;
311 }
312
313
323 public static function updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
324 {
325 // info
326 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
327 include_once './Services/Container/classes/class.ilContainer.php';
328 ilContainer::_writeContainerSetting($a_obj_id, self::INFO_TAB_VISIBILITY, (int) $form->getInput(self::INFO_TAB_VISIBILITY));
329 }
330
331 // calendar
332 if (in_array(self::CALENDAR_VISIBILITY, $services)) {
333 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
334 if (ilCalendarSettings::_getInstance()->isEnabled()) {
335 include_once './Services/Container/classes/class.ilContainer.php';
336 ilContainer::_writeContainerSetting($a_obj_id, self::CALENDAR_VISIBILITY, (int) $form->getInput(self::CALENDAR_VISIBILITY));
337 }
338 }
339
340 // news
341 if (in_array(self::USE_NEWS, $services)) {
342 include_once './Services/Container/classes/class.ilContainer.php';
343 ilContainer::_writeContainerSetting($a_obj_id, self::USE_NEWS, (int) $form->getInput(self::USE_NEWS));
344 }
345 if (in_array(self::NEWS_VISIBILITY, $services)) {
346 include_once './Services/Container/classes/class.ilContainer.php';
347 ilContainer::_writeContainerSetting($a_obj_id, self::NEWS_VISIBILITY, (int) $form->getInput(self::NEWS_VISIBILITY));
348
349 if (in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp'))) {
350 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
351
352 include_once "Services/Membership/classes/class.ilMembershipNotifications.php";
354 }
355 }
356
357 // rating
358 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
359 include_once './Services/Container/classes/class.ilContainer.php';
360 ilContainer::_writeContainerSetting($a_obj_id, self::AUTO_RATING_NEW_OBJECTS, (int) $form->getInput(self::AUTO_RATING_NEW_OBJECTS));
361 }
362
363 // taxonomies
364 if (in_array(self::TAXONOMIES, $services)) {
365 include_once './Services/Container/classes/class.ilContainer.php';
366 ilContainer::_writeContainerSetting($a_obj_id, self::TAXONOMIES, (int) $form->getInput(self::TAXONOMIES));
367 }
368
369 // tag cloud
370 if (in_array(self::TAG_CLOUD, $services)) {
371 include_once './Services/Container/classes/class.ilContainer.php';
372 ilContainer::_writeContainerSetting($a_obj_id, self::TAG_CLOUD, (int) $form->getInput(self::TAG_CLOUD));
373 }
374
375 // (local) custom metadata
376 if (in_array(self::CUSTOM_METADATA, $services)) {
377 include_once './Services/Container/classes/class.ilContainer.php';
378 ilContainer::_writeContainerSetting($a_obj_id, self::CUSTOM_METADATA, (int) $form->getInput(self::CUSTOM_METADATA));
379 }
380
381 // badges
382 if (in_array(self::BADGES, $services)) {
383 include_once 'Services/Badge/classes/class.ilBadgeHandler.php';
384 if (ilBadgeHandler::getInstance()->isActive()) {
385 include_once './Services/Container/classes/class.ilContainer.php';
386 ilContainer::_writeContainerSetting($a_obj_id, self::BADGES, (int) $form->getInput(self::BADGES));
387 }
388 }
389
390 // booking
391 if (in_array(self::BOOKING, $services)) {
392 include_once './Services/Container/classes/class.ilContainer.php';
393 ilContainer::_writeContainerSetting($a_obj_id, self::BOOKING, (int) $form->getInput(self::BOOKING));
394 }
395
396 // extended user access
397 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
398 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
399 ilObject::_lookupType($a_obj_id)
400 );
401
402 if ($position_settings->isActive() && $position_settings->isChangeableForObject()) {
403 $orgu_object_settings = new ilOrgUnitObjectPositionSetting($a_obj_id);
404 $orgu_object_settings->setActive(
405 (int) $form->getInput(self::ORGU_POSITION_ACCESS)
406 );
407 $orgu_object_settings->update();
408 }
409 }
410
411 // skills
412 if (in_array(self::SKILLS, $services)) {
413 $skmg_set = new ilSetting("skmg");
414 if ($skmg_set->get("enable_skmg")) {
415 include_once './Services/Container/classes/class.ilContainer.php';
416 ilContainer::_writeContainerSetting($a_obj_id, self::SKILLS, (int) $form->getInput(self::SKILLS));
417 }
418 }
419
420 // filter
421 if (in_array(self::FILTER, $services)) {
422 include_once './Services/Container/classes/class.ilContainer.php';
423 ilContainer::_writeContainerSetting($a_obj_id, self::FILTER, (int) $form->getInput(self::FILTER));
424 ilContainer::_writeContainerSetting($a_obj_id, "filter_show_empty", (int) $form->getInput("filter_show_empty"));
425 }
426
427 return true;
428 }
429
430
435 public function getModes()
436 {
437 return $this->modes;
438 }
439
444 public function getObjId()
445 {
446 return $this->obj_id;
447 }
448
449 protected function cancel()
450 {
452 $ilCtrl->returnToParent($this);
453 }
454
459 protected function editSettings(ilPropertyFormGUI $form = null)
460 {
461 global $DIC;
462
463 $tpl = $DIC->ui()->mainTemplate();
464
465 if (!$form instanceof ilPropertyFormGUI) {
466 $form = $this->initSettingsForm();
467 }
468 $tpl->setContent($form->getHTML());
469 }
470
471
475 protected function updateToolSettings()
476 {
477 global $DIC;
478
479 $lng = $DIC->language();
481
482 $form = $this->initSettingsForm();
483 if ($form->checkInput()) {
484 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
485 if (ilCalendarSettings::_getInstance()->isEnabled()) {
486 if ($this->isModeActive(self::CALENDAR_VISIBILITY)) {
487 ilContainer::_writeContainerSetting($this->getObjId(), 'show_calendar', (int) $form->getInput('calendar'));
488 }
489 }
490 ilUtil::sendSuccess($lng->txt('settings_saved'), true);
491 $ctrl->redirect($this);
492 }
493
494 ilUtil::sendFailure($lng->txt('err_check_input'));
495 $form->setValuesByPost();
496 $this->editSettings($form);
497 }
498
504 protected function isModeActive($a_mode)
505 {
506 return in_array($a_mode, $this->getModes());
507 }
508}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
static getInstance()
Constructor.
static _getInstance()
get singleton instance
static lookupCalendarActivated($a_obj_id)
This class represents a checkbox property in a property form.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
static _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
Stores object activation status of orgunit position settings.
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 sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
language()
Definition: language.php:2
global $ilSetting
Definition: privfeed.php:17
$lng
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$DIC
Definition: xapitoken.php:46