ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
18  {
19  $this->type = $this->getType();
20  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
21 
22  $this->lng->loadLanguageModule("grp");
23  }
24 
25  public function executeCommand()
26  {
27  global $ilAccess, $ilErr;
28 
29  $next_class = $this->ctrl->getNextClass($this);
30  $cmd = $this->ctrl->getCmd();
31 
32  $this->prepareOutput();
33 
34  if(!$ilAccess->checkAccess("read", "", $this->object->getRefId()))
35  {
36  $ilErr->raiseError($this->lng->txt("no_permission"), $ilErr->WARNING);
37  }
38 
39  switch($next_class)
40  {
41  case 'ilpermissiongui':
42  $this->tabs_gui->setTabActive("perm_settings");
43  include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
44  $perm_gui = new ilPermissionGUI($this);
45  $this->ctrl->forwardCommand($perm_gui);
46  break;
47 
48  default:
49  if(!$cmd || $cmd == "view")
50  {
51  $cmd = "editSettings";
52  }
53  $this->$cmd();
54  break;
55  }
56  return true;
57  }
58 
59  public function getAdminTabs()
60  {
61  global $rbacsystem;
62 
63  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId()))
64  {
65  $this->tabs_gui->addTarget("settings",
66  $this->ctrl->getLinkTarget($this, "editSettings"),
67  array("editSettings", "view"));
68  }
69 
70  if ($rbacsystem->checkAccess("edit_permission", $this->object->getRefId()))
71  {
72  $this->tabs_gui->addTarget("perm_settings",
73  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"),
74  array(), "ilpermissiongui");
75  }
76  }
77 
78  public function editSettings(ilPropertyFormGUI $a_form = null)
79  {
80  $this->tabs_gui->setTabActive('settings');
81 
82  if(!$a_form)
83  {
84  $a_form = $this->initFormSettings();
85  }
86  $this->tpl->setContent($a_form->getHTML());
87  return true;
88  }
89 
90  public function saveSettings()
91  {
92  global $ilSetting;
93 
94  $this->checkPermission("write");
95 
96  $form = $this->initFormSettings();
97  if($form->checkInput())
98  {
99  if($this->save($form))
100  {
101  $ilSetting->set('mail_'.$this->getParentObjType().'_member_notification',
102  (int)$form->getInput('mail_member_notification'));
103 
104  $ilSetting->set('mail_'.$this->getParentObjType().'_admin_notification',
105  (int)$form->getInput('mail_admin_notification'));
106 
107  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
108  $this->ctrl->redirect($this, "editSettings");
109  }
110  }
111 
112  $form->setValuesByPost();
113  $this->editSettings($form);
114  }
115 
116  protected function initFormSettings()
117  {
118  global $ilSetting, $ilAccess;
119 
120  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
121  $form = new ilPropertyFormGUI();
122  $form->setFormAction($this->ctrl->getFormAction($this, "saveSettings"));
123  $form->setTitle($this->lng->txt("settings"));
124 
125  $this->addFieldsToForm($form);
126 
127  $this->lng->loadLanguageModule("mail");
128 
129 
131  $this->getAdministrationFormId(),
132  $form,
133  $this
134  );
135 
136  $sec = new ilFormSectionHeaderGUI();
137  $sec->setTitle($this->lng->txt('mail_notification_membership_section'));
138  $form->addItem($sec);
139 
140  // member notification
141  $cn = new ilCheckboxInputGUI($this->lng->txt('mail_enable_'.$this->getParentObjType().'_member_notification'), 'mail_member_notification');
142  $cn->setInfo($this->lng->txt('mail_enable_'.$this->getParentObjType().'_member_notification_info'));
143  $cn->setChecked($ilSetting->get('mail_'.$this->getParentObjType().'_member_notification', true));
144  $form->addItem($cn);
145 
146  // default admin membership notification
147  $an = new ilCheckboxInputGUI($this->lng->txt('mail_enable_'.$this->getParentObjType().'_admin_notification'), 'mail_admin_notification');
148  $an->setInfo($this->lng->txt('mail_enable_'.$this->getParentObjType().'_admin_notification_info'));
149  $an->setChecked($ilSetting->get('mail_'.$this->getParentObjType().'_admin_notification', true));
150  $form->addItem($an);
151 
152  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
153  {
154  $form->addCommandButton("saveSettings", $this->lng->txt("save"));
155  $form->addCommandButton("view", $this->lng->txt("cancel"));
156  }
157 
158  return $form;
159  }
160 
161  public function addToExternalSettingsForm($a_form_id)
162  {
163  global $ilSetting;
164 
165  switch($a_form_id)
166  {
168 
169  $this->lng->loadLanguageModule("mail");
170 
171  $fields = array(
172  'mail_enable_'.$this->getParentObjType().'_member_notification' => array($ilSetting->get('mail_'.$this->getParentObjType().'_member_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL),
173  'mail_enable_'.$this->getParentObjType().'_admin_notification' => array($ilSetting->get('mail_'.$this->getParentObjType().'_admin_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL)
174  );
175 
176  return array(array("editSettings", $fields));
177  }
178  }
179 
180  protected function addFieldsToForm(ilPropertyFormGUI $a_form)
181  {
182 
183  }
184 
185  protected function save(ilPropertyFormGUI $a_form)
186  {
187  return true;
188  }
189 
190  abstract protected function getType();
191 
192  abstract protected function getParentObjType();
193 
194  abstract protected function getAdministrationFormId();
195 }
196 
197 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents a property form user interface.
This class represents a section header in a property form.
$cmd
Definition: sahs_server.php:35
This class represents a checkbox property in a property form.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
setInfo($a_info)
Set Information Text.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput()
prepare output
global $ilSetting
Definition: privfeed.php:40
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.
editSettings(ilPropertyFormGUI $a_form=null)