ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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(ilTabsGUI $tabs_gui)
38 {
39 if($this->checkPermissionBool('read'))
40 {
41 $tabs_gui->addTarget('settings', $this->ctrl->getLinkTarget($this, 'showConfigurationForm'), array('', 'view', 'showConfigurationForm', 'saveConfigurationForm'), __CLASS__);
42 }
43
44 if($this->checkPermissionBool('edit_permission'))
45 {
46 $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->setInfo($this->lng->txt('buddy_enable_info'));
89 $enabled->setDisabled(!$this->checkPermissionBool('write'));
90 $form->addItem($enabled);
91
92 $form->addCommandButton('saveConfigurationForm', $this->lng->txt('save'));
93
94 return $form;
95 }
96
100 protected function showConfigurationForm(ilPropertyFormGUI $form = null)
101 {
102 $this->checkPermission('read');
103
104 if(!($form instanceof ilPropertyFormGUI))
105 {
106 $form = $this->getConfigurationForm();
107 $form->setValuesByArray(array(
108 'enable' => (bool)ilBuddySystem::getInstance()->getSetting('enabled', 0)
109 ));
110 }
111
112 $this->tpl->setContent($form->getHTML());
113 }
114
118 protected function saveConfigurationForm()
119 {
120 $this->checkPermission('write');
121
122 $form = $this->getConfigurationForm();
123 if(!$form->checkInput())
124 {
125 $form->setValuesByPost();
126 $this->showConfigurationForm($form);
127 return;
128 }
129
130 ilBuddySystem::getInstance()->setSetting('enabled', (bool)$form->getInput('enable') ? 1 : 0);
131
132 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
133 $this->ctrl->redirect($this);
134 }
135}
This class represents a checkbox property in a property form.
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)
New implementation of ilObjectGUI.
prepareOutput()
prepare output
checkPermission($a_perm, $a_cmd="")
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
Tabs GUI.
addTarget($a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$cmd
Definition: sahs_server.php:35