ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjContactAdministrationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Object/classes/class.ilObject2GUI.php';
5require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
6
14{
20 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
21 {
22 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
23 $this->lng->loadLanguageModule('buddysystem');
24 }
25
29 public function getType()
30 {
31 return 'cadm';
32 }
33
37 public function getAdminTabs()
38 {
39 if($this->checkPermissionBool('read'))
40 {
41 $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTarget($this, 'showConfigurationForm'), array('', 'view', 'showConfigurationForm', 'saveConfigurationForm'), __CLASS__);
42 }
43
44 if($this->checkPermissionBool('edit_permission'))
45 {
46 $this->tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), 'perm'), array('perm', 'info', 'owner'), 'ilpermissiongui');
47 }
48 }
49
53 public function executeCommand()
54 {
55 $next_class = $this->ctrl->getNextClass($this);
56 $cmd = $this->ctrl->getCmd();
57 $this->prepareOutput();
58
59 switch($next_class)
60 {
61 case 'ilpermissiongui':
62 require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
63 $perm_gui = new ilPermissionGUI($this);
64 $this->ctrl->forwardCommand($perm_gui);
65 break;
66
67 default:
68 if($cmd == '' || $cmd == 'view')
69 {
70 $cmd = 'showConfigurationForm';
71 }
72 $this->$cmd();
73 break;
74 }
75 }
76
80 protected function getConfigurationForm()
81 {
82 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
83 $form = new ilPropertyFormGUI();
84 $form->setTitle($this->lng->txt('settings'));
85 $form->setFormAction($this->ctrl->getFormAction($this, 'saveConfigurationForm'));
86
87 $enabled = new ilCheckboxInputGUI($this->lng->txt('buddy_enable'), 'enable');
88 $enabled->setValue(1);
89 $enabled->setInfo($this->lng->txt('buddy_enable_info'));
90 $enabled->setDisabled(!$this->checkPermissionBool('write'));
91
92 $notification = new ilCheckboxInputGUI($this->lng->txt('buddy_use_osd'), 'use_osd');
93 $notification->setValue(1);
94 $notification->setInfo($this->lng->txt('buddy_use_osd_info'));
95 $notification->setDisabled(!$this->checkPermissionBool('write'));
96 $enabled->addSubItem($notification);
97
98 $form->addItem($enabled);
99
100 $form->addCommandButton('saveConfigurationForm', $this->lng->txt('save'));
101
102 return $form;
103 }
104
108 protected function showConfigurationForm(ilPropertyFormGUI $form = null)
109 {
110 $this->checkPermission('read');
111
112 if(!($form instanceof ilPropertyFormGUI))
113 {
114 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
116
117 $form = $this->getConfigurationForm();
118 $form->setValuesByArray(array(
119 'enable' => (bool)ilBuddySystem::getInstance()->getSetting('enabled', 0),
120 'use_osd' => isset($cfg['buddysystem_request']) && array_search('osd', $cfg['buddysystem_request']) !== false
121 ));
122 }
123
124 $this->tpl->setContent($form->getHTML());
125 }
126
130 protected function saveConfigurationForm()
131 {
132 $this->checkPermission('write');
133
134 $form = $this->getConfigurationForm();
135 if(!$form->checkInput())
136 {
137 $form->setValuesByPost();
138 $this->showConfigurationForm($form);
139 return;
140 }
141
142 ilBuddySystem::getInstance()->setSetting('enabled', (bool)$form->getInput('enable') ? 1 : 0);
143
144 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
146
147 $new_cfg = array();
148 foreach($cfg as $type => $channels)
149 {
150 $new_cfg[$type] = array();
151 foreach($channels as $channel)
152 {
153 $new_cfg[$type][$channel] = true;
154 }
155 }
156
157 if(!isset($new_cfg['buddysystem_request']) || !is_array($new_cfg['buddysystem_request']))
158 {
159 $new_cfg['buddysystem_request'] = array();
160 }
161
162 if((bool)$form->getInput('use_osd') && !array_key_exists('osd', $new_cfg['buddysystem_request']))
163 {
164 $new_cfg['buddysystem_request']['osd'] = true;
165 }
166 else if(!(bool)$form->getInput('use_osd') && array_key_exists('osd', $new_cfg['buddysystem_request']))
167 {
168 $new_cfg['buddysystem_request']['osd'] = false;
169 }
170
172
173 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
174 $this->ctrl->redirect($this);
175 }
176}
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
static setUserConfig($userid, array $configArray)
Sets the configuration for all given configurations.
Class ilObjContactAdministrationGUI.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
getType()
{Functions that must be overwritten.}
showConfigurationForm(ilPropertyFormGUI $form=null)
getAdminTabs()
{administration tabs show only permissions and trash folder}
New implementation of ilObjectGUI.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$cmd
Definition: sahs_server.php:35