ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjNotificationAdminGUI.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 require_once "./classes/class.ilObjectGUI.php";
5 require_once "./Services/Notifications/classes/class.ilObjNotificationAdmin.php";
6 require_once "./Services/Notifications/classes/class.ilObjNotificationAdminAccess.php";
7 
20 {
25  function __construct($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true) {
26  $this->type = "nota";
27  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
28  $this->lng->loadLanguageModule('notification');
29  }
30 
31  function _forwards()
32  {
33  return array();
34  }
35 
36  function executeCommand()
37  {
38  global $ilAccess, $ilNavigationHistory, $ilCtrl, $ilUser, $ilTabs;
39 
40  $next_class = $this->ctrl->getNextClass($this);
41  $cmd = $this->ctrl->getCmd();
42 
43  $this->prepareOutput();
44 
45  switch ($next_class)
46  {
47  case 'ilpermissiongui':
48  //$ilTabs->activateTab("id_permissions");
49  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
50  $perm_gui =& new ilPermissionGUI($this);
51  $ret =& $this->ctrl->forwardCommand($perm_gui);
52  break;
53 
54  default:
55  $this->__initSubTabs();
56  $ilTabs->activateTab("view");
57 
58  if (empty($cmd) || $cmd == 'view') {
59  $cmd = 'showTypes';
60  }
61 
62  $cmd .= "Object";
63  $this->$cmd();
64  break;
65  }
66  }
67 
73  static function saveObject2($params = array()) {
74  global $objDefinition, $ilUser;
75 
76  // create and insert file in grp_tree
77  require_once 'Services/Notifications/classes/class.ilObjNotificationAdmin.php';
78  $fileObj = new ilObjNotificationAdmin();
79  $fileObj->setTitle('notification admin');
80  $fileObj->create();
81  $fileObj->createReference();
82  $fileObj->putInTree(SYSTEM_FOLDER_ID);
83  //$fileObj->setPermissions($params['ref_id']);
84  // upload file to filesystem
85  }
86 
87  function setTabs() {
88  global $ilAccess, $ilTabs, $lng;
89 
90  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
91 
92  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
93  {
94  $ilTabs->addTab("id_info",
95  $lng->txt("info_short"),
96  $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilinfoscreengui"), "showSummary"));
97  }
98 
99  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
100  {
101  $ilTabs->addTab("id_permissions",
102  $lng->txt("perm_settings"),
103  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
104  }
105  }
106 
107  // init sub tabs
108  function __initSubTabs() {
109  global $ilTabs, $ilSetting, $ilCtrl;
110 
111  $ilTabs->addSubTabTarget("notification_general", $this->ctrl->getLinkTargetByClass('ilObjNotificationAdminGUI', "showGeneralSettings"));
112  //$ilTabs->addSubTabTarget("notification_admin_channels", $this->ctrl->getLinkTargetByClass('ilObjNotificationAdminGUI', "showChannels"));
113  $ilTabs->addSubTabTarget("notification_admin_types", $this->ctrl->getLinkTargetByClass('ilObjNotificationAdminGUI', "showTypes"));
114  $ilTabs->addSubTabTarget("notification_admin_matrix", $this->ctrl->getLinkTargetByClass('ilObjNotificationAdminGUI', "showConfigMatrix"));
115  }
116 
117  function addLocatorItems()
118  {
119  global $ilLocator;
120 
121  if (is_object($this->object)) {
122  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
123  }
124  }
125 
126  function showGeneralSettingsObject($form = null) {
127  require_once 'Services/Notifications/classes/class.ilNotificationAdminSettingsForm.php';
128 
129  if ($form == null) {
131  $settings = new ilSetting('notifications');
132 
136  $form->setValuesByArray(array_merge($settings->getAll(), $form->restored_values));
137  }
138 
139  $form->setFormAction($this->ctrl->getFormAction($this, 'saveGeneralSettings'));
140  $form->addCommandButton('saveGeneralSettings', 'save');
141  $form->addCommandButton('showGeneralSettings', 'cancel');
142 
143  $this->tpl->setContent($form->getHtml());
144  }
145 
147  require_once 'Services/Notifications/classes/class.ilNotificationAdminSettingsForm.php';
148  #require_once 'Services/Administration/classes/class.ilSetting.php';
149 
150  $settings = new ilSetting('notifications');
151 
153  $form->setValuesByPost();
154  if (!$form->checkInput()) {
155  $this->showGeneralSettingsObject($form);
156  }
157  else {
161  $values = $form->store_values;//array('enable_osd', 'osd_polling_intervall', 'enable_mail');
162 
163  foreach($values as $v) {
164  $settings->set($v, $_POST[$v]);
165  }
166 
167  foreach($_REQUEST['notifications'] as $type => $value) {
169  }
170 
171  $this->showGeneralSettingsObject();
172  }
173 
174  }
175 
176  public function showTypesObject() {
177  global $ilTabs;
178 
179  $ilTabs->activateSubTab('notification_admin_types');
180 
181  require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
182  require_once 'Services/Notifications/classes/class.ilNotificationAdminSettingsForm.php';
183 
185  $form->setFormAction($this->ctrl->getFormAction($this, 'showTypes'));
186  $form->addCommandButton('saveTypes', $this->lng->txt('save'));
187  $form->addCommandButton('showTypes', $this->lng->txt('cancel'));
188  $this->tpl->setContent($form->getHtml());
189 
190  }
191 
192  public function showChannelsObject() {
193  global $ilTabs;
194 
195  $ilTabs->activateSubTab('notification_admin_channels');
196 
197  require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
198  require_once 'Services/Notifications/classes/class.ilNotificationAdminSettingsForm.php';
199 
201  $form->setFormAction($this->ctrl->getFormAction($this, 'showChannels'));
202  $form->addCommandButton('saveChannels', $this->lng->txt('save'));
203  $form->addCommandButton('showChannels', $this->lng->txt('cancel'));
204  $this->tpl->setContent($form->getHtml());
205 
206  }
207 
208  public function saveTypesObject() {
209  require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
210  foreach($_REQUEST['notifications'] as $type => $value) {
212  }
213  $this->showTypesObject();
214  }
215 
216  public function saveChannelsObject() {
217  require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
218  foreach($_REQUEST['notifications'] as $type => $value) {
220  }
221  $this->showChannelsObject();
222  }
223 
224  public function showConfigMatrixObject() {
225  global $ilTabs;
226 
227  $ilTabs->activateSubTab('notification_admin_matrix');
228 
229  require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
230  require_once 'Services/Notifications/classes/class.ilNotificationSettingsTable.php';
231 
232  global $ilCtrl, $lng;
233 
235 
236  $table = new ilNotificationSettingsTable($this, 'a title', ilNotificationDatabaseHandler::getAvailableChannels(), $userdata, true);
237  $table->setFormAction($ilCtrl->getFormAction($this, 'saveConfigMatrix'));
239  $table->setDescription($lng->txt('notification_admin_matrix_settings_table_desc'));
240  $table->addCommandButton('saveConfigMatrix', $lng->txt('save'));
241  $table->addCommandButton('showConfigMatrix', $lng->txt('cancel'));
242 
243  $this->tpl->setContent($table->getHtml());
244  }
245 
246  private function saveConfigMatrixObject() {
247  global $ilUser, $ilCtrl;
248  require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
249 
250  ilNotificationDatabaseHandler::setUserConfig(-1, $_REQUEST['notification'] ? $_REQUEST['notification'] : array());
251  $this->showConfigMatrixObject();
252  }
253 } // END class.ilObjFileGUI
254 ?>