ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMembershipAdministrationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/Object/classes/class.ilObjectGUI.php" ;
5include_once "./Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php" ;
6
16{
17 const SUB_TAB_GENERAL_SETTINGS = 'settings';
18 const SUB_TAB_PRINT_VIEW = 'print_view';
19
20
21 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
22 {
23 $this->type = $this->getType();
24 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
25
26 $this->lng->loadLanguageModule("grp");
27 $this->lng->loadLanguageModule('mem');
28 }
29
30 abstract protected function getType();
31
32 abstract protected function getParentObjType();
33
34 abstract protected function getAdministrationFormId();
35
36 public function executeCommand()
37 {
38 global $ilAccess, $ilErr;
39
40 $next_class = $this->ctrl->getNextClass($this);
41 $cmd = $this->ctrl->getCmd();
42
43 $this->prepareOutput();
44
45 if(!$ilAccess->checkAccess("read", "", $this->object->getRefId()))
46 {
47 $ilErr->raiseError($this->lng->txt("no_permission"), $ilErr->WARNING);
48 }
49
50 switch($next_class)
51 {
52 case 'ilpermissiongui':
53 $this->tabs_gui->setTabActive("perm_settings");
54 include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
55 $perm_gui = new ilPermissionGUI($this);
56 $this->ctrl->forwardCommand($perm_gui);
57 break;
58
59 case 'ilmemberexportsettingsgui':
60 $this->setSubTabs('settings', self::SUB_TAB_PRINT_VIEW);
61 include_once './Services/Membership/classes/Export/class.ilMemberExportSettingsGUI.php';
62 $settings_gui = new ilMemberExportSettingsGUI($this->getParentObjType());
63 $this->ctrl->forwardCommand($settings_gui);
64 break;
65
66 default:
67 if(!$cmd || $cmd == "view")
68 {
69 $cmd = "editSettings";
70 }
71 $this->$cmd();
72 break;
73 }
74 return true;
75 }
76
77 public function getAdminTabs()
78 {
79 global $rbacsystem;
80
81 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId()))
82 {
83 $this->tabs_gui->addTarget("settings",
84 $this->ctrl->getLinkTarget($this, "editSettings"),
85 array("editSettings", "view"));
86 }
87
88 if ($rbacsystem->checkAccess("edit_permission", $this->object->getRefId()))
89 {
90 $this->tabs_gui->addTarget("perm_settings",
91 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"),
92 array(), "ilpermissiongui");
93 }
94 }
95
96 public function editSettings(ilPropertyFormGUI $a_form = null)
97 {
98 $this->setSubTabs('settings', self::SUB_TAB_GENERAL_SETTINGS);
99 $this->tabs_gui->setTabActive('settings');
100
101 if(!$a_form)
102 {
103 $a_form = $this->initFormSettings();
104 }
105 $this->tpl->setContent($a_form->getHTML());
106 return true;
107 }
108
109 public function saveSettings()
110 {
111 global $ilSetting;
112
113 $this->checkPermission("write");
114
115 $form = $this->initFormSettings();
116 if($form->checkInput())
117 {
118 if($this->save($form))
119 {
120 $ilSetting->set('mail_'.$this->getParentObjType().'_member_notification',
121 (int)$form->getInput('mail_member_notification'));
122
123 $ilSetting->set('mail_'.$this->getParentObjType().'_admin_notification',
124 (int)$form->getInput('mail_admin_notification'));
125
126 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
127 $this->ctrl->redirect($this, "editSettings");
128 }
129 }
130
131 $form->setValuesByPost();
132 $this->editSettings($form);
133 }
134
135 protected function initFormSettings()
136 {
137 global $ilSetting, $ilAccess;
138
139 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
140 $form = new ilPropertyFormGUI();
141 $form->setFormAction($this->ctrl->getFormAction($this, "saveSettings"));
142 $form->setTitle($this->lng->txt("settings"));
143
144 $this->addFieldsToForm($form);
145
146 $this->lng->loadLanguageModule("mail");
147
148
150 $this->getAdministrationFormId(),
151 $form,
152 $this
153 );
154
155 $sec = new ilFormSectionHeaderGUI();
156 $sec->setTitle($this->lng->txt('mail_notification_membership_section'));
157 $form->addItem($sec);
158
159 // member notification
160 $cn = new ilCheckboxInputGUI($this->lng->txt('mail_enable_'.$this->getParentObjType().'_member_notification'), 'mail_member_notification');
161 $cn->setInfo($this->lng->txt('mail_enable_'.$this->getParentObjType().'_member_notification_info'));
162 $cn->setChecked($ilSetting->get('mail_'.$this->getParentObjType().'_member_notification', true));
163 $form->addItem($cn);
164
165 // default admin membership notification
166 $an = new ilCheckboxInputGUI($this->lng->txt('mail_enable_'.$this->getParentObjType().'_admin_notification'), 'mail_admin_notification');
167 $an->setInfo($this->lng->txt('mail_enable_'.$this->getParentObjType().'_admin_notification_info'));
168 $an->setChecked($ilSetting->get('mail_'.$this->getParentObjType().'_admin_notification', true));
169 $form->addItem($an);
170
171 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
172 {
173 $form->addCommandButton("saveSettings", $this->lng->txt("save"));
174 $form->addCommandButton("view", $this->lng->txt("cancel"));
175 }
176
177 return $form;
178 }
179
180 public function addToExternalSettingsForm($a_form_id)
181 {
182 global $ilSetting;
183
184 switch($a_form_id)
185 {
187
188 $this->lng->loadLanguageModule("mail");
189
190 $fields = array(
191 'mail_enable_'.$this->getParentObjType().'_member_notification' => array($ilSetting->get('mail_'.$this->getParentObjType().'_member_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL),
192 'mail_enable_'.$this->getParentObjType().'_admin_notification' => array($ilSetting->get('mail_'.$this->getParentObjType().'_admin_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL)
193 );
194
195 return array(array("editSettings", $fields));
196 }
197 }
198
199 protected function addFieldsToForm(ilPropertyFormGUI $a_form)
200 {
201
202 }
203
204 protected function save(ilPropertyFormGUI $a_form)
205 {
206 return true;
207 }
208
214 protected function setSubTabs($a_main_tab, $a_active_tab)
215 {
216 if($a_main_tab == 'settings')
217 {
218 $GLOBALS['ilTabs']->addSubTab(
219 self::SUB_TAB_GENERAL_SETTINGS,
220 $GLOBALS['lng']->txt('mem_settings_tab_'.self::SUB_TAB_GENERAL_SETTINGS),
221 $GLOBALS['ilCtrl']->getLinkTarget($this,'editSettings')
222 );
223 $GLOBALS['ilTabs']->addSubTab(
224 self::SUB_TAB_PRINT_VIEW,
225 $GLOBALS['lng']->txt('mem_settings_tab_'.self::SUB_TAB_PRINT_VIEW),
226 $GLOBALS['ilCtrl']->getLinkTargetByClass('ilMemberExportSettingsGUI', 'printViewSettings')
227 );
228
229 $GLOBALS['ilTabs']->activateTab($a_main_tab);
230 $GLOBALS['ilTabs']->activateSubTab($a_active_tab);
231 }
232 }
233
234
235}
236
237?>
An exception for terminatinating execution or to throw for unit testing.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
This class represents a checkbox property in a property form.
This class represents a section header in a property form.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
getAdminTabs()
administration tabs show only permissions and trash folder
editSettings(ilPropertyFormGUI $a_form=null)
setSubTabs($a_main_tab, $a_active_tab)
Set sub tabs.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilSetting
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35