ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
38 private $gui = null;
39 private $modes = array();
40 private $obj_id = 0;
41
46 public function __construct($a_parent_gui, $a_obj_id, $a_modes)
47 {
48 global $DIC;
49
50 $this->ctrl = $DIC->ctrl();
51 $this->gui = $a_parent_gui;
52 $this->modes = $a_modes;
53 $this->obj_id = $a_obj_id;
54 }
55
56
57
62 public function executeCommand()
63 {
65
66 $next_class = $ilCtrl->getNextClass($this);
67 $cmd = $ilCtrl->getCmd('editSettings');
68
69 switch ($next_class) {
70 default:
71 $this->$cmd();
72 break;
73 }
74 }
75
81 public static function initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
82 {
83 global $DIC;
84
85 $ilSetting = $DIC->settings();
86 $ilCtrl = $DIC->ctrl();
87 $lng = $DIC->language();
88
89 $lng->loadLanguageModule("obj");
90
91 // info tab
92 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
93 $info = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_info_tab'), self::INFO_TAB_VISIBILITY);
94 $info->setValue(1);
96 $a_obj_id,
97 self::INFO_TAB_VISIBILITY,
98 true
99 ));
100 //$info->setOptionTitle($lng->txt('obj_tool_setting_info_tab'));
101 $info->setInfo($lng->txt('obj_tool_setting_info_tab_info'));
102 $form->addItem($info);
103 }
104
105 // calendar
106 if (in_array(self::CALENDAR_VISIBILITY, $services)) {
107 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
108 if (ilCalendarSettings::_getInstance()->isEnabled()) {
109 // Container tools (calendar, news, ... activation)
110 $cal = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_calendar'), self::CALENDAR_VISIBILITY);
111 $cal->setValue(1);
112 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
113 $cal->setChecked(ilCalendarSettings::lookupCalendarActivated($a_obj_id));
114 //$cal->setOptionTitle($lng->txt('obj_tool_setting_calendar'));
115 $cal->setInfo($lng->txt('obj_tool_setting_calendar_info'));
116 $form->addItem($cal);
117 }
118 }
119
120 // news
121 if (in_array(self::USE_NEWS, $services)) {
122 $news = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_use_news'), self::USE_NEWS);
123 $news->setValue(1);
125 $a_obj_id,
126 self::USE_NEWS,
127 true
128 );
129 $news->setChecked($checked);
130 $info = $lng->txt('obj_tool_setting_use_news_info');
131 if ($checked) {
132 $info .= " <a href='" . $ilCtrl->getLinkTargetByClass("ilcontainernewssettingsgui", "") .
133 "'>ยป " . $lng->txt('obj_tool_setting_use_news_open_settings') . "</a>";
134 }
135 $news->setInfo($info);
136 $form->addItem($news);
137 }
138 if (in_array(self::NEWS_VISIBILITY, $services)) {
139 if ($ilSetting->get('block_activated_news')) {
140 // Container tools (calendar, news, ... activation)
141 $news = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_news'), self::NEWS_VISIBILITY);
142 $news->setValue(1);
143 $news->setChecked(ilContainer::_lookupContainerSetting(
144 $a_obj_id,
145 self::NEWS_VISIBILITY,
146 $ilSetting->get('block_activated_news', true)
147 ));
148 //$news->setOptionTitle($lng->txt('obj_tool_setting_news'));
149 $news->setInfo($lng->txt('obj_tool_setting_news_info'));
150 $form->addItem($news);
151
152 if (in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp'))) {
153 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
154
155 include_once 'Services/Membership/classes/class.ilMembershipNotifications.php';
157 }
158 }
159 }
160
161 // (local) custom metadata
162 if (in_array(self::CUSTOM_METADATA, $services)) {
163 $md = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_custom_metadata'), self::CUSTOM_METADATA);
164 $md->setInfo($lng->txt('obj_tool_setting_custom_metadata_info'));
165 $md->setValue(1);
167 $a_obj_id,
168 self::CUSTOM_METADATA,
169 false
170 ));
171 $form->addItem($md);
172 }
173
174 // tag cloud
175 if (in_array(self::TAG_CLOUD, $services)) {
176 $tags_active = new ilSetting("tags");
177 if ($tags_active->get("enable", false)) {
178 $tag = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_tag_cloud'), self::TAG_CLOUD);
179 $tag->setInfo($lng->txt('obj_tool_setting_tag_cloud_info'));
180 $tag->setValue(1);
182 $a_obj_id,
183 self::TAG_CLOUD,
184 false
185 ));
186 $form->addItem($tag);
187 }
188 }
189
190 // taxonomies
191 if (in_array(self::TAXONOMIES, $services)) {
192 $tax = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_taxonomies'), self::TAXONOMIES);
193 $tax->setValue(1);
195 $a_obj_id,
196 self::TAXONOMIES,
197 false
198 ));
199 $form->addItem($tax);
200 }
201
202 // auto rating
203 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
204 $lng->loadLanguageModule("rating");
205
206 // auto rating for new objects
207 $rate = new ilCheckboxInputGUI($lng->txt('rating_new_objects_auto'), self::AUTO_RATING_NEW_OBJECTS);
208 $rate->setValue(1);
209 //$rate->setOptionTitle($lng->txt('rating_new_objects_auto'));
210 $rate->setInfo($lng->txt('rating_new_objects_auto_info'));
211 $rate->setChecked(ilContainer::_lookupContainerSetting(
212 $a_obj_id,
213 self::AUTO_RATING_NEW_OBJECTS,
214 false
215 ));
216 $form->addItem($rate);
217 }
218
219 // badges
220 if (in_array(self::BADGES, $services)) {
221 include_once 'Services/Badge/classes/class.ilBadgeHandler.php';
222 if (ilBadgeHandler::getInstance()->isActive()) {
223 $bdg = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_badges'), self::BADGES);
224 $bdg->setInfo($lng->txt('obj_tool_setting_badges_info'));
225 $bdg->setValue(1);
227 $a_obj_id,
228 self::BADGES,
229 false
230 ));
231 $form->addItem($bdg);
232 }
233 }
234 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
235 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
236 ilObject::_lookupType($a_obj_id)
237 );
238 if (
239 $position_settings->isActive()
240 ) {
241 $lia = new ilCheckboxInputGUI(
242 $GLOBALS['DIC']->language()->txt('obj_orgunit_positions'),
243 self::ORGU_POSITION_ACCESS
244 );
245 $lia->setInfo($GLOBALS['DIC']->language()->txt('obj_orgunit_positions_info'));
246 $lia->setValue(1);
247 $lia->setChecked(
248 (bool) ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($a_obj_id)
249 );
250 if (!$position_settings->isChangeableForObject()) {
251 $lia->setDisabled(true);
252 }
253 $form->addItem($lia);
254 }
255 }
256
257 // skills
258 if (in_array(self::SKILLS, $services)) {
259 $skmg_set = new ilSetting("skmg");
260 if ($skmg_set->get("enable_skmg")) {
261 $skill = new ilCheckboxInputGUI($lng->txt('obj_tool_setting_skills'), self::SKILLS);
262 $skill->setInfo($lng->txt('obj_tool_setting_skills_info'));
263 $skill->setValue(1);
264 $skill->setChecked(ilContainer::_lookupContainerSetting(
265 $a_obj_id,
266 self::SKILLS,
267 false
268 ));
269 $form->addItem($skill);
270 }
271 }
272
273 return $form;
274 }
275
276
286 public static function updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
287 {
288 // info
289 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
290 include_once './Services/Container/classes/class.ilContainer.php';
291 ilContainer::_writeContainerSetting($a_obj_id, self::INFO_TAB_VISIBILITY, (int) $form->getInput(self::INFO_TAB_VISIBILITY));
292 }
293
294 // calendar
295 if (in_array(self::CALENDAR_VISIBILITY, $services)) {
296 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
297 if (ilCalendarSettings::_getInstance()->isEnabled()) {
298 include_once './Services/Container/classes/class.ilContainer.php';
299 ilContainer::_writeContainerSetting($a_obj_id, self::CALENDAR_VISIBILITY, (int) $form->getInput(self::CALENDAR_VISIBILITY));
300 }
301 }
302
303 // news
304 if (in_array(self::USE_NEWS, $services)) {
305 include_once './Services/Container/classes/class.ilContainer.php';
306 ilContainer::_writeContainerSetting($a_obj_id, self::USE_NEWS, (int) $form->getInput(self::USE_NEWS));
307 }
308 if (in_array(self::NEWS_VISIBILITY, $services)) {
309 include_once './Services/Container/classes/class.ilContainer.php';
310 ilContainer::_writeContainerSetting($a_obj_id, self::NEWS_VISIBILITY, (int) $form->getInput(self::NEWS_VISIBILITY));
311
312 if (in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp'))) {
313 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
314
315 include_once "Services/Membership/classes/class.ilMembershipNotifications.php";
317 }
318 }
319
320 // rating
321 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
322 include_once './Services/Container/classes/class.ilContainer.php';
323 ilContainer::_writeContainerSetting($a_obj_id, self::AUTO_RATING_NEW_OBJECTS, (int) $form->getInput(self::AUTO_RATING_NEW_OBJECTS));
324 }
325
326 // taxonomies
327 if (in_array(self::TAXONOMIES, $services)) {
328 include_once './Services/Container/classes/class.ilContainer.php';
329 ilContainer::_writeContainerSetting($a_obj_id, self::TAXONOMIES, (int) $form->getInput(self::TAXONOMIES));
330 }
331
332 // tag cloud
333 if (in_array(self::TAG_CLOUD, $services)) {
334 include_once './Services/Container/classes/class.ilContainer.php';
335 ilContainer::_writeContainerSetting($a_obj_id, self::TAG_CLOUD, (int) $form->getInput(self::TAG_CLOUD));
336 }
337
338 // (local) custom metadata
339 if (in_array(self::CUSTOM_METADATA, $services)) {
340 include_once './Services/Container/classes/class.ilContainer.php';
341 ilContainer::_writeContainerSetting($a_obj_id, self::CUSTOM_METADATA, (int) $form->getInput(self::CUSTOM_METADATA));
342 }
343
344 // badges
345 if (in_array(self::BADGES, $services)) {
346 include_once 'Services/Badge/classes/class.ilBadgeHandler.php';
347 if (ilBadgeHandler::getInstance()->isActive()) {
348 include_once './Services/Container/classes/class.ilContainer.php';
349 ilContainer::_writeContainerSetting($a_obj_id, self::BADGES, (int) $form->getInput(self::BADGES));
350 }
351 }
352
353 // extended user access
354 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
355 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
356 ilObject::_lookupType($a_obj_id)
357 );
358
359 if ($position_settings->isActive() && $position_settings->isChangeableForObject()) {
360 $orgu_object_settings = new ilOrgUnitObjectPositionSetting($a_obj_id);
361 $orgu_object_settings->setActive(
362 (int) $form->getInput(self::ORGU_POSITION_ACCESS)
363 );
364 $orgu_object_settings->update();
365 }
366 }
367
368 // skills
369 if (in_array(self::SKILLS, $services)) {
370 $skmg_set = new ilSetting("skmg");
371 if ($skmg_set->get("enable_skmg")) {
372 include_once './Services/Container/classes/class.ilContainer.php';
373 ilContainer::_writeContainerSetting($a_obj_id, self::SKILLS, (int) $form->getInput(self::SKILLS));
374 }
375 }
376
377 return true;
378 }
379
380
385 public function getModes()
386 {
387 return $this->modes;
388 }
389
394 public function getObjId()
395 {
396 return $this->obj_id;
397 }
398
399 protected function cancel()
400 {
402 $ilCtrl->returnToParent($this);
403 }
404
409 protected function editSettings(ilPropertyFormGUI $form = null)
410 {
411 global $DIC;
412
413 $tpl = $DIC->ui()->mainTemplate();
414
415 if (!$form instanceof ilPropertyFormGUI) {
416 $form = $this->initSettingsForm();
417 }
418 $tpl->setContent($form->getHTML());
419 }
420
421
425 protected function updateToolSettings()
426 {
427 global $DIC;
428
429 $lng = $DIC->language();
431
432 $form = $this->initSettingsForm();
433 if ($form->checkInput()) {
434 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
435 if (ilCalendarSettings::_getInstance()->isEnabled()) {
436 if ($this->isModeActive(self::CALENDAR_VISIBILITY)) {
437 ilContainer::_writeContainerSetting($this->getObjId(), 'show_calendar', (int) $form->getInput('calendar'));
438 }
439 }
440 ilUtil::sendSuccess($lng->txt('settings_saved'), true);
441 $ctrl->redirect($this);
442 }
443
444 ilUtil::sendFailure($lng->txt('err_check_input'));
445 $form->setValuesByPost();
446 $this->editSettings($form);
447 }
448
454 protected function isModeActive($a_mode)
455 {
456 return in_array($a_mode, $this->getModes());
457 }
458}
$tpl
Definition: ilias.php:10
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.
ILIAS Setting Class.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
$info
Definition: index.php:5
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
global $ilSetting
Definition: privfeed.php:17
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$lng