ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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(ilObjPropertyFormGUI $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  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
105  $this->ctrl->redirect($this, "editSettings");
106  }
107  }
108 
109  $form->setValuesByPost();
110  $this->editSettings($form);
111  }
112 
113  protected function initFormSettings()
114  {
115  global $ilSetting;
116 
117  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
118  $form = new ilPropertyFormGUI();
119  $form->setFormAction($this->ctrl->getFormAction($this, "saveSettings"));
120  $form->setTitle($this->lng->txt("settings"));
121 
122  $this->addFieldsToForm($form);
123 
124  $this->lng->loadLanguageModule("mail");
125 
126  // member notification
127  $cn = new ilCheckboxInputGUI($this->lng->txt('mail_enable_'.$this->getParentObjType().'_member_notification'), 'mail_member_notification');
128  $cn->setInfo($this->lng->txt('mail_enable_'.$this->getParentObjType().'_member_notification_info'));
129  $cn->setChecked($ilSetting->get('mail_'.$this->getParentObjType().'_member_notification', true));
130  $form->addItem($cn);
131 
133  $this->getAdministrationFormId(),
134  $form,
135  $this
136  );
137 
138  $form->addCommandButton("saveSettings", $this->lng->txt("save"));
139  $form->addCommandButton("view", $this->lng->txt("cancel"));
140 
141  return $form;
142  }
143 
144  public function addToExternalSettingsForm($a_form_id)
145  {
146  global $ilSetting;
147 
148  switch($a_form_id)
149  {
151 
152  $this->lng->loadLanguageModule("mail");
153 
154  $fields = array('mail_enable_'.$this->getParentObjType().'_member_notification' => array($ilSetting->get('mail_'.$this->getParentObjType().'_member_notification', true), ilAdministrationSettingsFormHandler::VALUE_BOOL));
155 
156  return array(array("editSettings", $fields));
157  }
158  }
159 
160  protected function addFieldsToForm(ilPropertyFormGUI $a_form)
161  {
162 
163  }
164 
165  protected function save(ilPropertyFormGUI $a_form)
166  {
167  return true;
168  }
169 
170  abstract protected function getType();
171 
172  abstract protected function getParentObjType();
173 
174  abstract protected function getAdministrationFormId();
175 }
176 
177 ?>