ILIAS  release_7 Revision v7.30-3-g800a261c036
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 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
21 {
22 $this->type = $this->getType();
23
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
40 abstract protected function addChildContentsTo($form);
41
45 abstract protected function saveChildSettings($form);
46
51 abstract protected function getChildSettingsInfo($a_form_id);
52
53 public function executeCommand()
54 {
55 global $DIC;
56 $next_class = $this->ctrl->getNextClass($this);
57 $cmd = $this->ctrl->getCmd();
58
59 $this->prepareOutput();
60
61 if (!$DIC->rbac()->system()->checkAccess("visible,read", $this->object->getRefId())) {
62 $DIC['ilErr']->raiseError($this->lng->txt("no_permission"), $DIC['ilErr']->WARNING);
63 }
64
65 switch ($next_class) {
66 case 'ilpermissiongui':
67 $this->tabs_gui->setTabActive("perm_settings");
68 include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
69 $perm_gui = new ilPermissionGUI($this);
70 $this->ctrl->forwardCommand($perm_gui);
71 break;
72
73 case 'ilmemberexportsettingsgui':
74 $this->setSubTabs('settings', self::SUB_TAB_PRINT_VIEW);
75 include_once './Services/Membership/classes/Export/class.ilMemberExportSettingsGUI.php';
76 $settings_gui = new ilMemberExportSettingsGUI($this->getParentObjType());
77 $this->ctrl->forwardCommand($settings_gui);
78 break;
79
80 case 'iluseractionadmingui':
81 include_once("./Services/User/Actions/classes/class.ilUserActionAdminGUI.php");
82 include_once("./Services/User/Gallery/classes/class.ilGalleryUserActionContext.php");
83 $gui = new ilUserActionAdminGUI();
84 $gui->setActionContext(new ilGalleryUserActionContext());
85 $this->setSubTabs('settings', "actions");
86 $this->ctrl->forwardCommand($gui);
87 break;
88
89 default:
90 if (!$cmd || $cmd == "view") {
91 $cmd = "editSettings";
92 }
93 $this->$cmd();
94 break;
95 }
96 return true;
97 }
98
99 public function getAdminTabs()
100 {
101 global $DIC;
102
103 $rbacsystem = $DIC['rbacsystem'];
104
105 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
106 $this->tabs_gui->addTarget(
107 "settings",
108 $this->ctrl->getLinkTarget($this, "editSettings"),
109 array("editSettings", "view")
110 );
111 }
112
113 if ($rbacsystem->checkAccess("edit_permission", $this->object->getRefId())) {
114 $this->tabs_gui->addTarget(
115 "perm_settings",
116 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"),
117 array(),
118 "ilpermissiongui"
119 );
120 }
121 }
122
123 public function editSettings(ilPropertyFormGUI $a_form = null)
124 {
125 $this->setSubTabs('settings', self::SUB_TAB_GENERAL_SETTINGS);
126 $this->tabs_gui->setTabActive('settings');
127
128 if (!$a_form) {
129 $a_form = $this->initFormSettings();
130 }
131 $this->tpl->setContent($a_form->getHTML());
132 return true;
133 }
134
135 public function saveSettings()
136 {
137 $this->checkPermission("write");
138
139 $form = $this->initFormSettings();
140 if ($form->checkInput()) {
141 if ($this->save($form)) {
142 $this->settings->set(
143 'mail_' . $this->getParentObjType() . '_member_notification',
144 (int) $form->getInput('mail_member_notification')
145 );
146
147 $this->settings->set(
148 'mail_' . $this->getParentObjType() . '_admin_notification',
149 (int) $form->getInput('mail_admin_notification')
150 );
151
152 $this->saveChildSettings($form);
153
154 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
155 $this->ctrl->redirect($this, "editSettings");
156 }
157 }
158
159 $form->setValuesByPost();
160 $this->editSettings($form);
161 }
162
163 protected function initFormSettings()
164 {
165 global $DIC;
166
167
168 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
169 $form = new ilPropertyFormGUI();
170 $form->setFormAction($this->ctrl->getFormAction($this, "saveSettings"));
171 $form->setTitle($this->lng->txt("settings"));
172
173 $this->addFieldsToForm($form);
174
175 $this->lng->loadLanguageModule("mail");
176
177
180 $form,
181 $this
182 );
183
184 $sec = new ilFormSectionHeaderGUI();
185 $sec->setTitle($this->lng->txt('mail_notification_membership_section'));
186 $form->addItem($sec);
187
188 // member notification
189 $cn = new ilCheckboxInputGUI($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification'), 'mail_member_notification');
190 $cn->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification_info'));
191 $cn->setChecked($this->settings->get('mail_' . $this->getParentObjType() . '_member_notification', true));
192 $form->addItem($cn);
193
194 // default admin membership notification
195 $an = new ilCheckboxInputGUI($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification'), 'mail_admin_notification');
196 $an->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification_info'));
197 $an->setChecked($this->settings->get('mail_' . $this->getParentObjType() . '_admin_notification', true));
198 $form->addItem($an);
199
200 if ($this->access->checkAccess("write", "", $this->object->getRefId())) {
201 $form->addCommandButton("saveSettings", $this->lng->txt("save"));
202 $form->addCommandButton("view", $this->lng->txt("cancel"));
203 }
204
205 return $this->addChildContentsTo($form);
206 }
207
208 public function addToExternalSettingsForm($a_form_id)
209 {
210 switch ($a_form_id) {
212
213 $this->lng->loadLanguageModule("mail");
214
215 $fields = array(
216 'mail_enable_' . $this->getParentObjType() . '_member_notification' => array($this->settings->get('mail_' . $this->getParentObjType() . '_member_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL),
217 'mail_enable_' . $this->getParentObjType() . '_admin_notification' => array($this->settings->get('mail_' . $this->getParentObjType() . '_admin_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL)
218 );
219
220 return array(array("editSettings", $fields));
221 }
222 return $this->getChildSettingsInfo($a_form_id);
223 }
224
225 protected function addFieldsToForm(ilPropertyFormGUI $a_form)
226 {
227 }
228
229 protected function save(ilPropertyFormGUI $a_form)
230 {
231 return true;
232 }
233
239 protected function setSubTabs($a_main_tab, $a_active_tab)
240 {
241 if ($a_main_tab == 'settings') {
242 $GLOBALS['DIC']['ilTabs']->addSubTab(
243 self::SUB_TAB_GENERAL_SETTINGS,
244 $GLOBALS['DIC']['lng']->txt('mem_settings_tab_' . self::SUB_TAB_GENERAL_SETTINGS),
245 $GLOBALS['DIC']['ilCtrl']->getLinkTarget($this, 'editSettings')
246 );
247 $GLOBALS['DIC']['ilTabs']->addSubTab(
248 self::SUB_TAB_PRINT_VIEW,
249 $GLOBALS['DIC']['lng']->txt('mem_settings_tab_' . self::SUB_TAB_PRINT_VIEW),
250 $GLOBALS['DIC']['ilCtrl']->getLinkTargetByClass('ilMemberExportSettingsGUI', 'printViewSettings')
251 );
252 $GLOBALS['DIC']['ilTabs']->addSubTab(
253 "actions",
254 $GLOBALS['DIC']['lng']->txt("mmbr_gallery_user_actions"),
255 $GLOBALS['DIC']['ilCtrl']->getLinkTargetByClass("iluseractionadmingui")
256 );
257
258 $GLOBALS['DIC']['ilTabs']->activateTab($a_main_tab);
259 $GLOBALS['DIC']['ilTabs']->activateSubTab($a_active_tab);
260 }
261 }
262}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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.
Gallery context for user actions.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
getAdminTabs()
administration tabs show only permissions and trash folder
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.
User action administration GUI class.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
settings()
Definition: settings.php:2