ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
39 
40  $ilAccess = $DIC['ilAccess'];
41  $ilErr = $DIC['ilErr'];
42 
43  $next_class = $this->ctrl->getNextClass($this);
44  $cmd = $this->ctrl->getCmd();
45 
46  $this->prepareOutput();
47 
48  if (!$ilAccess->checkAccess("read", "", $this->object->getRefId())) {
49  $ilErr->raiseError($this->lng->txt("no_permission"), $ilErr->WARNING);
50  }
51 
52  switch ($next_class) {
53  case 'ilpermissiongui':
54  $this->tabs_gui->setTabActive("perm_settings");
55  include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
56  $perm_gui = new ilPermissionGUI($this);
57  $this->ctrl->forwardCommand($perm_gui);
58  break;
59 
60  case 'ilmemberexportsettingsgui':
61  $this->setSubTabs('settings', self::SUB_TAB_PRINT_VIEW);
62  include_once './Services/Membership/classes/Export/class.ilMemberExportSettingsGUI.php';
63  $settings_gui = new ilMemberExportSettingsGUI($this->getParentObjType());
64  $this->ctrl->forwardCommand($settings_gui);
65  break;
66 
67  case 'iluseractionadmingui':
68  include_once("./Services/User/Actions/classes/class.ilUserActionAdminGUI.php");
69  include_once("./Services/User/Gallery/classes/class.ilGalleryUserActionContext.php");
70  $gui = new ilUserActionAdminGUI();
71  $gui->setActionContext(new ilGalleryUserActionContext());
72  $this->setSubTabs('settings', "actions");
73  $this->ctrl->forwardCommand($gui);
74  break;
75 
76  default:
77  if (!$cmd || $cmd == "view") {
78  $cmd = "editSettings";
79  }
80  $this->$cmd();
81  break;
82  }
83  return true;
84  }
85 
86  public function getAdminTabs()
87  {
88  global $DIC;
89 
90  $rbacsystem = $DIC['rbacsystem'];
91 
92  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
93  $this->tabs_gui->addTarget(
94  "settings",
95  $this->ctrl->getLinkTarget($this, "editSettings"),
96  array("editSettings", "view")
97  );
98  }
99 
100  if ($rbacsystem->checkAccess("edit_permission", $this->object->getRefId())) {
101  $this->tabs_gui->addTarget(
102  "perm_settings",
103  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"),
104  array(),
105  "ilpermissiongui"
106  );
107  }
108  }
109 
110  public function editSettings(ilPropertyFormGUI $a_form = null)
111  {
112  $this->setSubTabs('settings', self::SUB_TAB_GENERAL_SETTINGS);
113  $this->tabs_gui->setTabActive('settings');
114 
115  if (!$a_form) {
116  $a_form = $this->initFormSettings();
117  }
118  $this->tpl->setContent($a_form->getHTML());
119  return true;
120  }
121 
122  public function saveSettings()
123  {
124  global $DIC;
125 
126  $ilSetting = $DIC['ilSetting'];
127 
128  $this->checkPermission("write");
129 
130  $form = $this->initFormSettings();
131  if ($form->checkInput()) {
132  if ($this->save($form)) {
133  $ilSetting->set(
134  'mail_' . $this->getParentObjType() . '_member_notification',
135  (int) $form->getInput('mail_member_notification')
136  );
137 
138  $ilSetting->set(
139  'mail_' . $this->getParentObjType() . '_admin_notification',
140  (int) $form->getInput('mail_admin_notification')
141  );
142 
143  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
144  $this->ctrl->redirect($this, "editSettings");
145  }
146  }
147 
148  $form->setValuesByPost();
149  $this->editSettings($form);
150  }
151 
152  protected function initFormSettings()
153  {
154  global $DIC;
155 
156  $ilSetting = $DIC['ilSetting'];
157  $ilAccess = $DIC['ilAccess'];
158 
159  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
160  $form = new ilPropertyFormGUI();
161  $form->setFormAction($this->ctrl->getFormAction($this, "saveSettings"));
162  $form->setTitle($this->lng->txt("settings"));
163 
164  $this->addFieldsToForm($form);
165 
166  $this->lng->loadLanguageModule("mail");
167 
168 
170  $this->getAdministrationFormId(),
171  $form,
172  $this
173  );
174 
175  $sec = new ilFormSectionHeaderGUI();
176  $sec->setTitle($this->lng->txt('mail_notification_membership_section'));
177  $form->addItem($sec);
178 
179  // member notification
180  $cn = new ilCheckboxInputGUI($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification'), 'mail_member_notification');
181  $cn->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_member_notification_info'));
182  $cn->setChecked($ilSetting->get('mail_' . $this->getParentObjType() . '_member_notification', true));
183  $form->addItem($cn);
184 
185  // default admin membership notification
186  $an = new ilCheckboxInputGUI($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification'), 'mail_admin_notification');
187  $an->setInfo($this->lng->txt('mail_enable_' . $this->getParentObjType() . '_admin_notification_info'));
188  $an->setChecked($ilSetting->get('mail_' . $this->getParentObjType() . '_admin_notification', true));
189  $form->addItem($an);
190 
191  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
192  $form->addCommandButton("saveSettings", $this->lng->txt("save"));
193  $form->addCommandButton("view", $this->lng->txt("cancel"));
194  }
195 
196  return $form;
197  }
198 
199  public function addToExternalSettingsForm($a_form_id)
200  {
201  global $DIC;
202 
203  $ilSetting = $DIC['ilSetting'];
204 
205  switch ($a_form_id) {
207 
208  $this->lng->loadLanguageModule("mail");
209 
210  $fields = array(
211  'mail_enable_' . $this->getParentObjType() . '_member_notification' => array($ilSetting->get('mail_' . $this->getParentObjType() . '_member_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL),
212  'mail_enable_' . $this->getParentObjType() . '_admin_notification' => array($ilSetting->get('mail_' . $this->getParentObjType() . '_admin_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL)
213  );
214 
215  return array(array("editSettings", $fields));
216  }
217  }
218 
219  protected function addFieldsToForm(ilPropertyFormGUI $a_form)
220  {
221  }
222 
223  protected function save(ilPropertyFormGUI $a_form)
224  {
225  return true;
226  }
227 
233  protected function setSubTabs($a_main_tab, $a_active_tab)
234  {
235  if ($a_main_tab == 'settings') {
236  $GLOBALS['DIC']['ilTabs']->addSubTab(
237  self::SUB_TAB_GENERAL_SETTINGS,
238  $GLOBALS['DIC']['lng']->txt('mem_settings_tab_' . self::SUB_TAB_GENERAL_SETTINGS),
239  $GLOBALS['DIC']['ilCtrl']->getLinkTarget($this, 'editSettings')
240  );
241  $GLOBALS['DIC']['ilTabs']->addSubTab(
242  self::SUB_TAB_PRINT_VIEW,
243  $GLOBALS['DIC']['lng']->txt('mem_settings_tab_' . self::SUB_TAB_PRINT_VIEW),
244  $GLOBALS['DIC']['ilCtrl']->getLinkTargetByClass('ilMemberExportSettingsGUI', 'printViewSettings')
245  );
246  $GLOBALS['DIC']['ilTabs']->addSubTab(
247  "actions",
248  $GLOBALS['DIC']['lng']->txt("mmbr_gallery_user_actions"),
249  $GLOBALS['DIC']['ilCtrl']->getLinkTargetByClass("iluseractionadmingui")
250  );
251 
252  $GLOBALS['DIC']['ilTabs']->activateTab($a_main_tab);
253  $GLOBALS['DIC']['ilTabs']->activateSubTab($a_active_tab);
254  }
255  }
256 }
setSubTabs($a_main_tab, $a_active_tab)
Set sub tabs.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
User action administration GUI class.
This class represents a section header in a property form.
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.
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.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.