ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMembershipAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected const SUB_TAB_GENERAL_SETTINGS = 'settings';
29 protected const SUB_TAB_PRINT_VIEW = 'print_view';
30
31 public function __construct($a_data, int $a_id, bool $a_call_by_reference = true, bool $a_prepare_output = true)
32 {
33 $this->type = $this->getType();
34 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
35
36 $this->lng->loadLanguageModule("grp");
37 $this->lng->loadLanguageModule('mem');
38 }
39
40 abstract protected function getType(): string;
41
42 abstract protected function getParentObjType(): string;
43
44 abstract protected function getAdministrationFormId(): int;
45
46 abstract protected function addChildContentsTo(ilPropertyFormGUI $form): ilPropertyFormGUI;
47
48 abstract protected function saveChildSettings(ilPropertyFormGUI $form): void;
49
50 abstract protected function getChildSettingsInfo(int $a_form_id): array;
51
52 public function executeCommand(): void
53 {
54 $next_class = $this->ctrl->getNextClass($this);
55 $cmd = $this->ctrl->getCmd();
56
57 $this->prepareOutput();
58
59 if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
60 $this->error->raiseError($this->lng->txt("no_permission"), $this->error->WARNING);
61 }
62
63 switch ($next_class) {
64 case 'ilpermissiongui':
65 $this->tabs_gui->setTabActive("perm_settings");
66 $perm_gui = new ilPermissionGUI($this);
67 $this->ctrl->forwardCommand($perm_gui);
68 break;
69
70 case 'ilmemberexportsettingsgui':
71 $this->setSubTabs('settings', self::SUB_TAB_PRINT_VIEW);
72 $settings_gui = new ilMemberExportSettingsGUI($this->getParentObjType());
73 $this->ctrl->forwardCommand($settings_gui);
74 break;
75
76 case 'iluseractionadmingui':
77 $gui = new ilUserActionAdminGUI($this->object->getRefId());
78 $gui->setActionContext(new ilGalleryUserActionContext());
79 $this->setSubTabs('settings', "actions");
80 $this->ctrl->forwardCommand($gui);
81 break;
82
83 default:
84 if (!$cmd || $cmd === "view") {
85 $cmd = "editSettings";
86 }
87 $this->$cmd();
88 break;
89 }
90 }
91
92 public function getAdminTabs(): void
93 {
94 if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
95 $this->tabs_gui->addTarget(
96 "settings",
97 $this->ctrl->getLinkTarget($this, "editSettings"),
98 array("editSettings", "view")
99 );
100 }
101
102 if ($this->rbac_system->checkAccess("edit_permission", $this->object->getRefId())) {
103 $this->tabs_gui->addTarget(
104 "perm_settings",
105 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"),
106 array(),
107 "ilpermissiongui"
108 );
109 }
110 }
111
112 public function editSettings(?ilPropertyFormGUI $a_form = null): void
113 {
114 $this->setSubTabs('settings', self::SUB_TAB_GENERAL_SETTINGS);
115 $this->tabs_gui->setTabActive('settings');
116
117 if ($a_form === null) {
118 $a_form = $this->initFormSettings();
119 }
120 $this->tpl->setContent($a_form->getHTML());
121 }
122
123 public function saveSettings(): void
124 {
125 $this->checkPermission("write");
126 $form = $this->initFormSettings();
127 if ($form->checkInput()) {
128 if ($this->save($form)) {
129 $this->settings->set(
130 'mail_' . $this->getParentObjType() . '_member_notification',
131 (string) $form->getInput('mail_member_notification')
132 );
133
134 $this->settings->set(
135 'mail_' . $this->getParentObjType() . '_admin_notification',
136 (string) $form->getInput('mail_admin_notification')
137 );
138
139 $this->saveChildSettings($form);
140
141 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
142 $this->ctrl->redirect($this, "editSettings");
143 }
144 }
145 $form->setValuesByPost();
146 $this->editSettings($form);
147 }
148
150 {
151 $form = new ilPropertyFormGUI();
152 $form->setFormAction($this->ctrl->getFormAction($this, "saveSettings"));
153 $form->setTitle($this->lng->txt("settings"));
154
155 $this->addFieldsToForm($form);
156
157 $this->lng->loadLanguageModule("mail");
158
161 $form,
162 $this
163 );
164
165 $sec = new ilFormSectionHeaderGUI();
166 $sec->setTitle($this->lng->txt('mail_notification_membership_section'));
167 $form->addItem($sec);
168
169 // member notification
170 $cn = new ilCheckboxInputGUI(
171 $this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification'),
172 'mail_member_notification'
173 );
174 $cn->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification_info'));
175 $cn->setChecked((bool) $this->settings->get('mail_' . $this->getParentObjType() . '_member_notification', '1'));
176 $form->addItem($cn);
177
178 // default admin membership notification
179 $an = new ilCheckboxInputGUI(
180 $this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification'),
181 'mail_admin_notification'
182 );
183 $an->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification_info'));
184 $an->setChecked((bool) $this->settings->get('mail_' . $this->getParentObjType() . '_admin_notification', '1'));
185 $form->addItem($an);
186
187 if ($this->access->checkAccess("write", "", $this->object->getRefId())) {
188 $form->addCommandButton("saveSettings", $this->lng->txt("save"));
189 $form->addCommandButton("view", $this->lng->txt("cancel"));
190 }
191 return $this->addChildContentsTo($form);
192 }
193
194 public function addToExternalSettingsForm(int $a_form_id): array
195 {
196 switch ($a_form_id) {
198
199 $this->lng->loadLanguageModule("mail");
200
201 $fields = array(
202 'mail_enable_' . $this->getParentObjType() . '_member_notification' => array(
203 $this->settings->get('mail_' . $this->getParentObjType() . '_member_notification', '1'),
205 ),
206 'mail_enable_' . $this->getParentObjType() . '_admin_notification' => array(
207 $this->settings->get('mail_' . $this->getParentObjType() . '_admin_notification', '1'),
209 )
210 );
211 return [
212 [
213 "editSettings",
214 $fields
215 ]
216 ];
217 }
218 return $this->getChildSettingsInfo($a_form_id);
219 }
220
221 protected function addFieldsToForm(ilPropertyFormGUI $a_form): void
222 {
223 }
224
225 protected function save(ilPropertyFormGUI $a_form): bool
226 {
227 return true;
228 }
229
230 protected function setSubTabs(string $a_main_tab, string $a_active_tab): void
231 {
232 if ($a_main_tab === 'settings') {
233 $this->tabs_gui->addSubTab(
234 self::SUB_TAB_GENERAL_SETTINGS,
235 $this->lng->txt('mem_settings_tab_' . self::SUB_TAB_GENERAL_SETTINGS),
236 $this->ctrl->getLinkTarget($this, 'editSettings')
237 );
238 $this->tabs_gui->addSubTab(
239 self::SUB_TAB_PRINT_VIEW,
240 $this->lng->txt('mem_settings_tab_' . self::SUB_TAB_PRINT_VIEW),
241 $this->ctrl->getLinkTargetByClass('ilMemberExportSettingsGUI', 'printViewSettings')
242 );
243 $this->tabs_gui->addSubTab(
244 "actions",
245 $this->lng->txt("mmbr_gallery_user_actions"),
246 $this->ctrl->getLinkTargetByClass("iluseractionadmingui")
247 );
248
249 $this->tabs_gui->activateTab($a_main_tab);
250 $this->tabs_gui->activateSubTab($a_active_tab);
251 }
252 }
253}
error(string $a_errmsg)
static addFieldsToForm(int $a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
This class represents a checkbox property in a property form.
setFormAction(string $a_formaction)
This class represents a section header in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getChildSettingsInfo(int $a_form_id)
__construct($a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
getAdminTabs()
administration tabs show only permissions and trash folder
saveChildSettings(ilPropertyFormGUI $form)
addChildContentsTo(ilPropertyFormGUI $form)
editSettings(?ilPropertyFormGUI $a_form=null)
setSubTabs(string $a_main_tab, string $a_active_tab)
Class ilObjectGUI Basic methods of all Output classes.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
User action administration GUI class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc