ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjForumAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 include_once("./Services/Object/classes/class.ilObjectGUI.php");
4 
17 {
23  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
24  {
25  $this->type = 'frma';
26  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
27 
28  $this->lng->loadLanguageModule('forum');
29  }
30 
37  public function executeCommand()
38  {
39  global $rbacsystem,$ilErr,$ilAccess;
40 
41  $next_class = $this->ctrl->getNextClass($this);
42  $cmd = $this->ctrl->getCmd();
43 
44  $this->prepareOutput();
45 
46 /* if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
47  {
48  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
49  }
50 */
51  switch($next_class)
52  {
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  $ret =& $this->ctrl->forwardCommand($perm_gui);
58  break;
59 
60  default:
61  if(!$cmd || $cmd == 'view')
62  {
63  $cmd = "editSettings";
64  }
65 
66  $this->$cmd();
67  break;
68  }
69  return true;
70  }
71 
78  public function getAdminTabs()
79  {
80  global $rbacsystem, $ilAccess;
81 
82  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
83  {
84  $this->tabs_gui->addTarget("settings",
85  $this->ctrl->getLinkTarget($this, "editSettings"),
86  array("editSettings", "view"));
87  }
88 
89  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
90  {
91  $this->tabs_gui->addTarget("perm_settings",
92  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
93  array(),'ilpermissiongui');
94  }
95  }
96 
97 
101  public function editSettings()
102  {
103  global $ilTabs;
104 
105  $this->tabs_gui->setTabActive('forum_edit_settings');
106  //$this->addSubTabs();
107  $ilTabs->activateSubTab("settings");
108  $this->initFormSettings();
109  return true;
110  }
111 
115  public function saveSettings()
116  {
117  global $ilCtrl, $ilSetting;
118 
119  $this->checkPermission("write");
120 
121  $frma_set = new ilSetting("frma");
122  $frma_set->set("forum_overview", ilUtil::stripSlashes($_POST["forum_overview"]));
123 
124  if(isset($_POST['anonymous_fora']))
125  $ilSetting->set('enable_anonymous_fora', 1);
126  else $ilSetting->set('enable_anonymous_fora', 0);
127 
128  if(isset($_POST['fora_statistics']))
129  $ilSetting->set('enable_fora_statistics', 1);
130  else $ilSetting->set('enable_fora_statistics', 0);
131 
132  $ilSetting->set('forum_notification', ilUtil::stripSlashes($_POST["forum_notification"]));
133 
134  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
135  $ilCtrl->redirect($this, "view");
136  }
137 
141  public function cancel()
142  {
143  global $ilCtrl;
144 
145  $ilCtrl->redirect($this, "view");
146  }
147 
153  protected function initFormSettings()
154  {
155  global $lng, $ilSetting;
156 
157  $this->tabs_gui->setTabActive('settings');
158  $frma_set = new ilSetting("frma");
159 
160  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
161  $form = new ilPropertyFormGUI();
162  $form->setFormAction($this->ctrl->getFormAction($this));
163  $form->setTitle($this->lng->txt('settings'));
164  $form->addCommandButton('saveSettings',$this->lng->txt('save'));
165  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
166 
167  // forum overview
168 
169  $frm_radio = new ilRadioGroupInputGUI($this->lng->txt('show_topics_overview'), 'forum_overview');
170  $frm_radio->addOption(new ilRadioOption($this->lng->txt('new').', '.$this->lng->txt('is_read').', '.$this->lng->txt('unread'), '0'));
171  $frm_radio->addOption(new ilRadioOption($this->lng->txt('is_read').', '.$this->lng->txt('unread'), '1'));
172  $frm_radio->setValue($frma_set->get('forum_overview'));
173  $frm_radio->setInfo($this->lng->txt('topics_overview_info'));
174  $form->addItem($frm_radio);
175 
176  $this->fora_statistics = (bool) $ilSetting->get('enable_fora_statistics',false);
177  $this->anonymous_fora = (bool) $ilSetting->get('enable_anonymous_fora',false);
178  $check = new ilCheckboxInputGui($this->lng->txt('enable_fora_statistics'), 'fora_statistics');
179  $check->setInfo($this->lng->txt('enable_fora_statistics_desc'));
180  $check->setChecked($this->fora_statistics);
181  $form->addItem($check);
182 
183  $check = new ilCheckboxInputGui($this->lng->txt('enable_anonymous_fora'), 'anonymous_fora');
184  $check->setInfo($this->lng->txt('enable_anonymous_fora_desc'));
185  $check->setChecked($this->anonymous_fora);
186  $form->addItem($check);
187 
188  $frm_sel = new ilSelectInputGUI($this->lng->txt('cron_forum_notification'), 'forum_notification');
189  $notification_options = array(
190  0 => $this->lng->txt('cron_forum_notification_never'),
191  1 => $this->lng->txt('cron_forum_notification_directly'),
192  2 => $this->lng->txt('cron_forum_notification_cron'));
193 
194  $frm_sel->setOptions($notification_options);
195  $frm_sel->setValue($ilSetting->get('forum_notification'));
196  $frm_sel->setInfo($this->lng->txt('cron_forum_notification_desc'));
197  $form->addItem($frm_sel);
198 
199  $this->tpl->setContent($form->getHTML());
200  }
201 }
202 ?>