ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_once "./Services/Object/classes/class.ilObjectGUI.php" ;
5 include_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  $ilErr->raiseError($this->lng->txt("no_permission"), $ilErr->WARNING);
47  }
48 
49  switch ($next_class) {
50  case 'ilpermissiongui':
51  $this->tabs_gui->setTabActive("perm_settings");
52  include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
53  $perm_gui = new ilPermissionGUI($this);
54  $this->ctrl->forwardCommand($perm_gui);
55  break;
56 
57  case 'ilmemberexportsettingsgui':
58  $this->setSubTabs('settings', self::SUB_TAB_PRINT_VIEW);
59  include_once './Services/Membership/classes/Export/class.ilMemberExportSettingsGUI.php';
60  $settings_gui = new ilMemberExportSettingsGUI($this->getParentObjType());
61  $this->ctrl->forwardCommand($settings_gui);
62  break;
63 
64  case 'iluseractionadmingui':
65  include_once("./Services/User/Actions/classes/class.ilUserActionAdminGUI.php");
66  include_once("./Services/User/Gallery/classes/class.ilGalleryUserActionContext.php");
67  $gui = new ilUserActionAdminGUI();
68  $gui->setActionContext(new ilGalleryUserActionContext());
69  $this->setSubTabs('settings', "actions");
70  $this->ctrl->forwardCommand($gui);
71  break;
72 
73  default:
74  if (!$cmd || $cmd == "view") {
75  $cmd = "editSettings";
76  }
77  $this->$cmd();
78  break;
79  }
80  return true;
81  }
82 
83  public function getAdminTabs()
84  {
85  global $rbacsystem;
86 
87  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
88  $this->tabs_gui->addTarget(
89  "settings",
90  $this->ctrl->getLinkTarget($this, "editSettings"),
91  array("editSettings", "view")
92  );
93  }
94 
95  if ($rbacsystem->checkAccess("edit_permission", $this->object->getRefId())) {
96  $this->tabs_gui->addTarget(
97  "perm_settings",
98  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"),
99  array(),
100  "ilpermissiongui"
101  );
102  }
103  }
104 
105  public function editSettings(ilPropertyFormGUI $a_form = null)
106  {
107  $this->setSubTabs('settings', self::SUB_TAB_GENERAL_SETTINGS);
108  $this->tabs_gui->setTabActive('settings');
109 
110  if (!$a_form) {
111  $a_form = $this->initFormSettings();
112  }
113  $this->tpl->setContent($a_form->getHTML());
114  return true;
115  }
116 
117  public function saveSettings()
118  {
119  global $ilSetting;
120 
121  $this->checkPermission("write");
122 
123  $form = $this->initFormSettings();
124  if ($form->checkInput()) {
125  if ($this->save($form)) {
126  $ilSetting->set(
127  'mail_' . $this->getParentObjType() . '_member_notification',
128  (int) $form->getInput('mail_member_notification')
129  );
130 
131  $ilSetting->set(
132  'mail_' . $this->getParentObjType() . '_admin_notification',
133  (int) $form->getInput('mail_admin_notification')
134  );
135 
136  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
137  $this->ctrl->redirect($this, "editSettings");
138  }
139  }
140 
141  $form->setValuesByPost();
142  $this->editSettings($form);
143  }
144 
145  protected function initFormSettings()
146  {
147  global $ilSetting, $ilAccess;
148 
149  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
150  $form = new ilPropertyFormGUI();
151  $form->setFormAction($this->ctrl->getFormAction($this, "saveSettings"));
152  $form->setTitle($this->lng->txt("settings"));
153 
154  $this->addFieldsToForm($form);
155 
156  $this->lng->loadLanguageModule("mail");
157 
158 
160  $this->getAdministrationFormId(),
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($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification'), 'mail_member_notification');
171  $cn->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification_info'));
172  $cn->setChecked($ilSetting->get('mail_' . $this->getParentObjType() . '_member_notification', true));
173  $form->addItem($cn);
174 
175  // default admin membership notification
176  $an = new ilCheckboxInputGUI($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification'), 'mail_admin_notification');
177  $an->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification_info'));
178  $an->setChecked($ilSetting->get('mail_' . $this->getParentObjType() . '_admin_notification', true));
179  $form->addItem($an);
180 
181  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
182  $form->addCommandButton("saveSettings", $this->lng->txt("save"));
183  $form->addCommandButton("view", $this->lng->txt("cancel"));
184  }
185 
186  return $form;
187  }
188 
189  public function addToExternalSettingsForm($a_form_id)
190  {
191  global $ilSetting;
192 
193  switch ($a_form_id) {
195 
196  $this->lng->loadLanguageModule("mail");
197 
198  $fields = array(
199  'mail_enable_' . $this->getParentObjType() . '_member_notification' => array($ilSetting->get('mail_' . $this->getParentObjType() . '_member_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL),
200  'mail_enable_' . $this->getParentObjType() . '_admin_notification' => array($ilSetting->get('mail_' . $this->getParentObjType() . '_admin_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL)
201  );
202 
203  return array(array("editSettings", $fields));
204  }
205  }
206 
207  protected function addFieldsToForm(ilPropertyFormGUI $a_form)
208  {
209  }
210 
211  protected function save(ilPropertyFormGUI $a_form)
212  {
213  return true;
214  }
215 
221  protected function setSubTabs($a_main_tab, $a_active_tab)
222  {
223  if ($a_main_tab == 'settings') {
224  $GLOBALS['ilTabs']->addSubTab(
225  self::SUB_TAB_GENERAL_SETTINGS,
226  $GLOBALS['lng']->txt('mem_settings_tab_' . self::SUB_TAB_GENERAL_SETTINGS),
227  $GLOBALS['ilCtrl']->getLinkTarget($this, 'editSettings')
228  );
229  $GLOBALS['ilTabs']->addSubTab(
230  self::SUB_TAB_PRINT_VIEW,
231  $GLOBALS['lng']->txt('mem_settings_tab_' . self::SUB_TAB_PRINT_VIEW),
232  $GLOBALS['ilCtrl']->getLinkTargetByClass('ilMemberExportSettingsGUI', 'printViewSettings')
233  );
234  $GLOBALS['ilTabs']->addSubTab(
235  "actions",
236  $GLOBALS['lng']->txt("mmbr_gallery_user_actions"),
237  $GLOBALS['ilCtrl']->getLinkTargetByClass("iluseractionadmingui")
238  );
239 
240  $GLOBALS['ilTabs']->activateTab($a_main_tab);
241  $GLOBALS['ilTabs']->activateSubTab($a_active_tab);
242  }
243  }
244 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
setSubTabs($a_main_tab, $a_active_tab)
Set sub tabs.
This class represents a property form user interface.
User action administration GUI class.
This class represents a section header in a property form.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Gallery context for user actions.
This class represents a checkbox property in a property form.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
prepareOutput($a_show_subobjects=true)
prepare output
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
if(isset($_POST['submit'])) $form
Class ilObjectGUI Basic methods of all Output classes.
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
Membership Administration Settings.
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.