ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTarget($this, 'showConfigurationForm'), array('', 'view', 'showConfigurationForm', 'saveConfigurationForm'), __CLASS__);
41 }
42
43 if ($this->checkPermissionBool('edit_permission')) {
44 $this->tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), 'perm'), array('perm', 'info', 'owner'), 'ilpermissiongui');
45 }
46 }
47
51 public function executeCommand()
52 {
53 $next_class = $this->ctrl->getNextClass($this);
54 $cmd = $this->ctrl->getCmd();
55 $this->prepareOutput();
56
57 switch ($next_class) {
58 case 'ilpermissiongui':
59 require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
60 $perm_gui = new ilPermissionGUI($this);
61 $this->ctrl->forwardCommand($perm_gui);
62 break;
63
64 default:
65 if ($cmd == '' || $cmd == 'view') {
66 $cmd = 'showConfigurationForm';
67 }
68 $this->$cmd();
69 break;
70 }
71 }
72
76 protected function getConfigurationForm()
77 {
78 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
80 $form->setTitle($this->lng->txt('settings'));
81 $form->setFormAction($this->ctrl->getFormAction($this, 'saveConfigurationForm'));
82
83 $enabled = new ilCheckboxInputGUI($this->lng->txt('buddy_enable'), 'enable');
84 $enabled->setValue(1);
85 $enabled->setInfo($this->lng->txt('buddy_enable_info'));
86 $enabled->setDisabled(!$this->checkPermissionBool('write'));
87
88 $notification = new ilCheckboxInputGUI($this->lng->txt('buddy_use_osd'), 'use_osd');
89 $notification->setValue(1);
90 $notification->setInfo($this->lng->txt('buddy_use_osd_info'));
91 $notification->setDisabled(!$this->checkPermissionBool('write'));
92 $enabled->addSubItem($notification);
93
94 $form->addItem($enabled);
95
96 if ($this->checkPermissionBool('write')) {
97 $form->addCommandButton('saveConfigurationForm', $this->lng->txt('save'));
98 }
99
100 return $form;
101 }
102
107 {
108 $this->checkPermission('read');
109
110 if (!($form instanceof ilPropertyFormGUI)) {
111 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
113
114 $form = $this->getConfigurationForm();
115 $form->setValuesByArray(array(
116 'enable' => (bool) ilBuddySystem::getInstance()->getSetting('enabled', 0),
117 'use_osd' => isset($cfg['buddysystem_request']) && array_search('osd', $cfg['buddysystem_request']) !== false
118 ));
119 }
120
121 $this->tpl->setContent($form->getHTML());
122 }
123
127 protected function saveConfigurationForm()
128 {
129 $this->checkPermission('write');
130
131 $form = $this->getConfigurationForm();
132 if (!$form->checkInput()) {
133 $form->setValuesByPost();
135 return;
136 }
137
138 ilBuddySystem::getInstance()->setSetting('enabled', (bool) $form->getInput('enable') ? 1 : 0);
139
140 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
142
143 $new_cfg = array();
144 foreach ($cfg as $type => $channels) {
145 $new_cfg[$type] = array();
146 foreach ($channels as $channel) {
147 $new_cfg[$type][$channel] = true;
148 }
149 }
150
151 if (!isset($new_cfg['buddysystem_request']) || !is_array($new_cfg['buddysystem_request'])) {
152 $new_cfg['buddysystem_request'] = array();
153 }
154
155 if ((bool) $form->getInput('use_osd') && !array_key_exists('osd', $new_cfg['buddysystem_request'])) {
156 $new_cfg['buddysystem_request']['osd'] = true;
157 } elseif (!(bool) $form->getInput('use_osd') && array_key_exists('osd', $new_cfg['buddysystem_request'])) {
158 $new_cfg['buddysystem_request']['osd'] = false;
159 }
160
162
163 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
164 $this->ctrl->redirect($this);
165 }
166}
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.
$type
if(isset($_POST['submit'])) $form
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg