ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
88 // info tab
89 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
90 $info = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_info_tab'), self::INFO_TAB_VISIBILITY);
91 $info->setValue(1);
93 $a_obj_id,
94 self::INFO_TAB_VISIBILITY,
95 true
96 ));
97 //$info->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_info_tab'));
98 $info->setInfo($GLOBALS['lng']->txt('obj_tool_setting_info_tab_info'));
99 $form->addItem($info);
100 }
101
102 // calendar
103 if (in_array(self::CALENDAR_VISIBILITY, $services)) {
104 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
105 if (ilCalendarSettings::_getInstance()->isEnabled()) {
106 // Container tools (calendar, news, ... activation)
107 $cal = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_calendar'), self::CALENDAR_VISIBILITY);
108 $cal->setValue(1);
109 include_once './Services/Calendar/classes/class.ilObjCalendarSettings.php';
110 $cal->setChecked(ilCalendarSettings::lookupCalendarActivated($a_obj_id));
111 //$cal->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_calendar'));
112 $cal->setInfo($GLOBALS['lng']->txt('obj_tool_setting_calendar_info'));
113 $form->addItem($cal);
114 }
115 }
116
117 // news
118 if (in_array(self::USE_NEWS, $services)) {
119 $news = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_use_news'), self::USE_NEWS);
120 $news->setValue(1);
122 $a_obj_id,
123 self::USE_NEWS,
124 true
125 );
126 $news->setChecked($checked);
127 $info = $GLOBALS['lng']->txt('obj_tool_setting_use_news_info');
128 if ($checked) {
129 $info.=" <a href='" . $ilCtrl->getLinkTargetByClass("ilcontainernewssettingsgui", "") .
130 "'>ยป " . $GLOBALS['lng']->txt('obj_tool_setting_use_news_open_settings') . "</a>";
131 }
132 $news->setInfo($info);
133 $form->addItem($news);
134 }
135 if (in_array(self::NEWS_VISIBILITY, $services)) {
136 if ($ilSetting->get('block_activated_news')) {
137 // Container tools (calendar, news, ... activation)
138 $news = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_news'), self::NEWS_VISIBILITY);
139 $news->setValue(1);
140 $news->setChecked(ilContainer::_lookupContainerSetting(
141 $a_obj_id,
142 self::NEWS_VISIBILITY,
143 $ilSetting->get('block_activated_news', true)
144 ));
145 //$news->setOptionTitle($GLOBALS['lng']->txt('obj_tool_setting_news'));
146 $news->setInfo($GLOBALS['lng']->txt('obj_tool_setting_news_info'));
147 $form->addItem($news);
148
149 if (in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp'))) {
150 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
151
152 include_once 'Services/Membership/classes/class.ilMembershipNotifications.php';
154 }
155 }
156 }
157
158 // (local) custom metadata
159 if (in_array(self::CUSTOM_METADATA, $services)) {
160 $md = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_custom_metadata'), self::CUSTOM_METADATA);
161 $md->setInfo($GLOBALS['lng']->txt('obj_tool_setting_custom_metadata_info'));
162 $md->setValue(1);
164 $a_obj_id,
165 self::CUSTOM_METADATA,
166 false
167 ));
168 $form->addItem($md);
169 }
170
171 // tag cloud
172 if (in_array(self::TAG_CLOUD, $services)) {
173 $tags_active = new ilSetting("tags");
174 if ($tags_active->get("enable", false)) {
175 $tag = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_tag_cloud'), self::TAG_CLOUD);
176 $tag->setInfo($GLOBALS['lng']->txt('obj_tool_setting_tag_cloud_info'));
177 $tag->setValue(1);
179 $a_obj_id,
180 self::TAG_CLOUD,
181 false
182 ));
183 $form->addItem($tag);
184 }
185 }
186
187 // taxonomies
188 if (in_array(self::TAXONOMIES, $services)) {
189 $tax = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_taxonomies'), self::TAXONOMIES);
190 $tax->setValue(1);
192 $a_obj_id,
193 self::TAXONOMIES,
194 false
195 ));
196 $form->addItem($tax);
197 }
198
199 // auto rating
200 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
201 $GLOBALS['lng']->loadLanguageModule("rating");
202
203 // auto rating for new objects
204 $rate = new ilCheckboxInputGUI($GLOBALS['lng']->txt('rating_new_objects_auto'), self::AUTO_RATING_NEW_OBJECTS);
205 $rate->setValue(1);
206 //$rate->setOptionTitle($GLOBALS['lng']->txt('rating_new_objects_auto'));
207 $rate->setInfo($GLOBALS['lng']->txt('rating_new_objects_auto_info'));
208 $rate->setChecked(ilContainer::_lookupContainerSetting(
209 $a_obj_id,
210 self::AUTO_RATING_NEW_OBJECTS,
211 false
212 ));
213 $form->addItem($rate);
214 }
215
216 // badges
217 if (in_array(self::BADGES, $services)) {
218 include_once 'Services/Badge/classes/class.ilBadgeHandler.php';
219 if (ilBadgeHandler::getInstance()->isActive()) {
220 $bdg = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_badges'), self::BADGES);
221 $bdg->setInfo($GLOBALS['lng']->txt('obj_tool_setting_badges_info'));
222 $bdg->setValue(1);
224 $a_obj_id,
225 self::BADGES,
226 false
227 ));
228 $form->addItem($bdg);
229 }
230 }
231 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
232 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
233 ilObject::_lookupType($a_obj_id)
234 );
235 if (
236 $position_settings->isActive()
237 ) {
238 $lia = new ilCheckboxInputGUI(
239 $GLOBALS['DIC']->language()->txt('obj_orgunit_positions'),
240 self::ORGU_POSITION_ACCESS
241 );
242 $lia->setInfo($GLOBALS['DIC']->language()->txt('obj_orgunit_positions_info'));
243 $lia->setValue(1);
244 $lia->setChecked(
245 (bool) ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($a_obj_id)
246 );
247 if (!$position_settings->isChangeableForObject()) {
248 $lia->setDisabled(true);
249 }
250 $form->addItem($lia);
251 }
252 }
253
254 // skills
255 if (in_array(self::SKILLS, $services)) {
256 $skmg_set = new ilSetting("skmg");
257 if ($skmg_set->get("enable_skmg")) {
258 $skill = new ilCheckboxInputGUI($GLOBALS['lng']->txt('obj_tool_setting_skills'), self::SKILLS);
259 $skill->setInfo($GLOBALS['lng']->txt('obj_tool_setting_skills_info'));
260 $skill->setValue(1);
261 $skill->setChecked(ilContainer::_lookupContainerSetting(
262 $a_obj_id,
263 self::SKILLS,
264 false
265 ));
266 $form->addItem($skill);
267 }
268 }
269
270 return $form;
271 }
272
273
283 public static function updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
284 {
285 // info
286 if (in_array(self::INFO_TAB_VISIBILITY, $services)) {
287 include_once './Services/Container/classes/class.ilContainer.php';
288 ilContainer::_writeContainerSetting($a_obj_id, self::INFO_TAB_VISIBILITY, (int) $form->getInput(self::INFO_TAB_VISIBILITY));
289 }
290
291 // calendar
292 if (in_array(self::CALENDAR_VISIBILITY, $services)) {
293 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
294 if (ilCalendarSettings::_getInstance()->isEnabled()) {
295 include_once './Services/Container/classes/class.ilContainer.php';
296 ilContainer::_writeContainerSetting($a_obj_id, self::CALENDAR_VISIBILITY, (int) $form->getInput(self::CALENDAR_VISIBILITY));
297 }
298 }
299
300 // news
301 if (in_array(self::USE_NEWS, $services)) {
302 include_once './Services/Container/classes/class.ilContainer.php';
303 ilContainer::_writeContainerSetting($a_obj_id, self::USE_NEWS, (int) $form->getInput(self::USE_NEWS));
304 }
305 if (in_array(self::NEWS_VISIBILITY, $services)) {
306 include_once './Services/Container/classes/class.ilContainer.php';
307 ilContainer::_writeContainerSetting($a_obj_id, self::NEWS_VISIBILITY, (int) $form->getInput(self::NEWS_VISIBILITY));
308
309 if (in_array(ilObject::_lookupType($a_obj_id), array('crs', 'grp'))) {
310 $ref_id = array_pop(ilObject::_getAllReferences($a_obj_id));
311
312 include_once "Services/Membership/classes/class.ilMembershipNotifications.php";
314 }
315 }
316
317 // rating
318 if (in_array(self::AUTO_RATING_NEW_OBJECTS, $services)) {
319 include_once './Services/Container/classes/class.ilContainer.php';
320 ilContainer::_writeContainerSetting($a_obj_id, self::AUTO_RATING_NEW_OBJECTS, (int) $form->getInput(self::AUTO_RATING_NEW_OBJECTS));
321 }
322
323 // taxonomies
324 if (in_array(self::TAXONOMIES, $services)) {
325 include_once './Services/Container/classes/class.ilContainer.php';
326 ilContainer::_writeContainerSetting($a_obj_id, self::TAXONOMIES, (int) $form->getInput(self::TAXONOMIES));
327 }
328
329 // tag cloud
330 if (in_array(self::TAG_CLOUD, $services)) {
331 include_once './Services/Container/classes/class.ilContainer.php';
332 ilContainer::_writeContainerSetting($a_obj_id, self::TAG_CLOUD, (int) $form->getInput(self::TAG_CLOUD));
333 }
334
335 // (local) custom metadata
336 if (in_array(self::CUSTOM_METADATA, $services)) {
337 include_once './Services/Container/classes/class.ilContainer.php';
338 ilContainer::_writeContainerSetting($a_obj_id, self::CUSTOM_METADATA, (int) $form->getInput(self::CUSTOM_METADATA));
339 }
340
341 // badges
342 if (in_array(self::BADGES, $services)) {
343 include_once 'Services/Badge/classes/class.ilBadgeHandler.php';
344 if (ilBadgeHandler::getInstance()->isActive()) {
345 include_once './Services/Container/classes/class.ilContainer.php';
346 ilContainer::_writeContainerSetting($a_obj_id, self::BADGES, (int) $form->getInput(self::BADGES));
347 }
348 }
349
350 // extended user access
351 if (in_array(self::ORGU_POSITION_ACCESS, $services)) {
352 $position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
353 ilObject::_lookupType($a_obj_id)
354 );
355
356 if ($position_settings->isActive() && $position_settings->isChangeableForObject()) {
357 $orgu_object_settings = new ilOrgUnitObjectPositionSetting($a_obj_id);
358 $orgu_object_settings->setActive(
359 (int) $form->getInput(self::ORGU_POSITION_ACCESS)
360 );
361 $orgu_object_settings->update();
362 }
363 }
364
365 // skills
366 if (in_array(self::SKILLS, $services)) {
367 $skmg_set = new ilSetting("skmg");
368 if ($skmg_set->get("enable_skmg")) {
369 include_once './Services/Container/classes/class.ilContainer.php';
370 ilContainer::_writeContainerSetting($a_obj_id, self::SKILLS, (int) $form->getInput(self::SKILLS));
371 }
372 }
373
374 return true;
375 }
376
377
382 public function getModes()
383 {
384 return $this->modes;
385 }
386
391 public function getObjId()
392 {
393 return $this->obj_id;
394 }
395
396 protected function cancel()
397 {
398 $GLOBALS['ilCtrl']->returnToParent($this);
399 }
400
405 protected function editSettings(ilPropertyFormGUI $form = null)
406 {
407 if (!$form instanceof ilPropertyFormGUI) {
408 $form = $this->initSettingsForm();
409 }
410 $GLOBALS['tpl']->setContent($form->getHTML());
411 }
412
413
417 protected function updateToolSettings()
418 {
419 $form = $this->initSettingsForm();
420 if ($form->checkInput()) {
421 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
422 if (ilCalendarSettings::_getInstance()->isEnabled()) {
423 if ($this->isModeActive(self::CALENDAR_VISIBILITY)) {
424 ilContainer::_writeContainerSetting($this->getObjId(), 'show_calendar', (int) $form->getInput('calendar'));
425 }
426 }
427 ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'), true);
428 $GLOBALS['ilCtrl']->redirect($this);
429 }
430
431 ilUtil::sendFailure($GLOBALS['lng']->txt('err_check_input'));
432 $form->setValuesByPost();
433 $this->editSettings($form);
434 }
435
441 protected function isModeActive($a_mode)
442 {
443 return in_array($a_mode, $this->getModes());
444 }
445}
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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
global $ilSetting
Definition: privfeed.php:17
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7