ILIAS  release_4-4 Revision
class.ilObjWikiSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObject2GUI.php");
5 
18 {
19 
26  function getType()
27  {
28  return "wiks";
29  }
30 
31 
38  public function executeCommand()
39  {
40  global $rbacsystem, $ilErr, $ilAccess, $lng;
41 
42  $lng->loadLanguageModule("wiki");
43 
44  $next_class = $this->ctrl->getNextClass($this);
45  $cmd = $this->ctrl->getCmd();
46 
47  $this->prepareOutput();
48 
49  if (!$ilAccess->checkAccess('read','',$this->object->getRefId()))
50  {
51  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
52  }
53 
54  switch($next_class)
55  {
56  case 'ilpermissiongui':
57  $this->tabs_gui->setTabActive('perm_settings');
58  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
59  $perm_gui =& new ilPermissionGUI($this);
60  $ret =& $this->ctrl->forwardCommand($perm_gui);
61  break;
62 
63  default:
64  if(!$cmd || $cmd == 'view')
65  {
66  $cmd = "editSettings";
67  }
68 
69  $this->$cmd();
70  break;
71  }
72  return true;
73  }
74 
78  protected function editSettings(ilPropertyFormGUI $form = null)
79  {
80  global $ilCtrl, $lng, $ilTabs, $ilToolbar, $tpl;
81 
82  $ilTabs->activateTab("settings");
83 
84  if ($this->checkPermissionBool("read"))
85  {
86  if(!$form)
87  {
88  $form = $this->initForm();
89  $this->populateWithCurrentSettings($form);
90  }
91  $tpl->setContent($form->getHTML());
92  }
93  }
94 
99  {
100  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
101 
102  $form->setValuesByArray(array(
103  'activate_captcha_anonym' => ilCaptchaUtil::isActiveForWiki()
104  ));
105  }
106 
111  public function initForm($a_mode = "edit")
112  {
113  global $lng, $ilCtrl;
114 
115  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
116  $form = new ilPropertyFormGUI();
117 
118  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
119  $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
120  $cap->setInfo($this->lng->txt('adm_captcha_anonymous_wiki'));
121  $cap->setValue(1);
123  {
124  $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
125  }
126  $form->addItem($cap);
127 
128  if ($this->checkPermissionBool("write"))
129  {
130  $form->addCommandButton("saveSettings", $lng->txt("save"));
131  }
132 
133  $form->setTitle($lng->txt("settings"));
134  $form->setFormAction($ilCtrl->getFormAction($this));
135 
136  return $form;
137  }
138 
142  protected function saveSettings()
143  {
148  global $lng, $ilCtrl;
149 
150  if(!$this->checkPermissionBool("write"))
151  {
152  $this->editSettings();
153  return;
154  }
155 
156  $form = $this->initForm();
157  if(!$form->checkInput())
158  {
159  $form->setValuesByPost();
160  $this->editSettings($form);
161  return;
162  }
163 
164  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
165  ilCaptchaUtil::setActiveForWiki((bool)$form->getInput('activate_captcha_anonym'));
166 
167  ilUtil::sendSuccess($lng->txt('msg_obj_modified'), true);
168  $ilCtrl->redirect($this, 'editSettings');
169  }
170 
174  function getAdminTabs($tabs_gui)
175  {
176  global $tree;
177 
178  if ($this->checkPermissionBool("visible,read"))
179  {
180  $tabs_gui->addTab("settings",
181  $this->lng->txt("settings"),
182  $this->ctrl->getLinkTarget($this, "editSettings"));
183 
184  }
185 
186  if ($this->checkPermissionBool("edit_permission"))
187  {
188  $tabs_gui->addTab("perm_settings",
189  $this->lng->txt("perm_settings"),
190  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
191  );
192  }
193  }
194 
199  public function addToExternalSettingsForm($a_form_id)
200  {
201  switch($a_form_id)
202  {
204  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
205  $fields = array(
206  'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForWiki(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
207  );
208 
209  return array('obj_wiks' => array('editSettings', $fields));
210  }
211  }
212 }
213 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents a property form user interface.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
setValuesByArray($a_values)
Set form values from an array.
$cmd
Definition: sahs_server.php:35
static checkFreetype()
Check whether captcha support is active.
This class represents a checkbox property in a property form.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
editSettings(ilPropertyFormGUI $form=null)
Wiki settings gui class.
getAdminTabs($tabs_gui)
administration tabs show only permissions and trash folder
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
populateWithCurrentSettings(ilPropertyFormGUI $form)