ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
22  protected $rbacsystem;
23 
27  protected $error;
28 
32  protected $tabs;
33 
34 
38  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
39  {
40  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
41  global $DIC;
42 
43  $this->rbacsystem = $DIC->rbac()->system();
44  $this->error = $DIC["ilErr"];
45  $this->access = $DIC->access();
46  $this->lng = $DIC->language();
47  $this->ctrl = $DIC->ctrl();
48  $this->tabs = $DIC->tabs();
49  $this->toolbar = $DIC->toolbar();
50  $this->tpl = $DIC["tpl"];
51  }
52 
53 
60  public function getType()
61  {
62  return "wiks";
63  }
64 
65 
72  public function executeCommand()
73  {
76  $ilAccess = $this->access;
77  $lng = $this->lng;
78 
79  $lng->loadLanguageModule("wiki");
80 
81  $next_class = $this->ctrl->getNextClass($this);
82  $cmd = $this->ctrl->getCmd();
83 
84  $this->prepareOutput();
85 
86  if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
87  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
88  }
89 
90  switch ($next_class) {
91  case 'ilpermissiongui':
92  $this->tabs_gui->setTabActive('perm_settings');
93  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
94  $perm_gui = new ilPermissionGUI($this);
95  $ret = $this->ctrl->forwardCommand($perm_gui);
96  break;
97 
98  default:
99  if (!$cmd || $cmd == 'view') {
100  $cmd = "editSettings";
101  }
102 
103  $this->$cmd();
104  break;
105  }
106  return true;
107  }
108 
112  protected function editSettings(ilPropertyFormGUI $form = null)
113  {
115  $lng = $this->lng;
116  $ilTabs = $this->tabs;
117  $ilToolbar = $this->toolbar;
118  $tpl = $this->tpl;
119 
120  $ilTabs->activateTab("settings");
121 
122  if ($this->checkPermissionBool("read")) {
123  if (!$form) {
124  $form = $this->initForm();
126  }
127  $tpl->setContent($form->getHTML());
128  }
129  }
130 
135  {
136  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
137 
138  $form->setValuesByArray(array(
139  'activate_captcha_anonym' => ilCaptchaUtil::isActiveForWiki()
140  ));
141  }
142 
147  public function initForm($a_mode = "edit")
148  {
149  $lng = $this->lng;
151 
152  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
153  $form = new ilPropertyFormGUI();
154 
155  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
156  $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
157  $cap->setInfo($this->lng->txt('adm_captcha_anonymous_wiki'));
158  $cap->setValue(1);
160  $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
161  }
162  $form->addItem($cap);
163 
164  if ($this->checkPermissionBool("write")) {
165  $form->addCommandButton("saveSettings", $lng->txt("save"));
166  }
167 
168  $form->setTitle($lng->txt("settings"));
169  $form->setFormAction($ilCtrl->getFormAction($this));
170 
171  return $form;
172  }
173 
177  protected function saveSettings()
178  {
183  $lng = $this->lng;
185 
186  if (!$this->checkPermissionBool("write")) {
187  $this->editSettings();
188  return;
189  }
190 
191  $form = $this->initForm();
192  if (!$form->checkInput()) {
193  $form->setValuesByPost();
194  $this->editSettings($form);
195  return;
196  }
197 
198  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
199  ilCaptchaUtil::setActiveForWiki((bool) $form->getInput('activate_captcha_anonym'));
200 
201  ilUtil::sendSuccess($lng->txt('msg_obj_modified'), true);
202  $ilCtrl->redirect($this, 'editSettings');
203  }
204 
208  public function getAdminTabs()
209  {
210  if ($this->checkPermissionBool("visible,read")) {
211  $this->tabs_gui->addTab(
212  "settings",
213  $this->lng->txt("settings"),
214  $this->ctrl->getLinkTarget($this, "editSettings")
215  );
216  }
217 
218  if ($this->checkPermissionBool("edit_permission")) {
219  $this->tabs_gui->addTab(
220  "perm_settings",
221  $this->lng->txt("perm_settings"),
222  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
223  );
224  }
225  }
226 
231  public function addToExternalSettingsForm($a_form_id)
232  {
233  switch ($a_form_id) {
235  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
236  $fields = array(
237  'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForWiki(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
238  );
239 
240  return array('obj_wiks' => array('editSettings', $fields));
241  }
242  }
243 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getAdminTabs()
administration tabs show only permissions and trash folder
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.
global $DIC
Definition: saml.php:7
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.
if(isset($_POST['submit'])) $form
editSettings(ilPropertyFormGUI $form=null)
Wiki settings gui class.
Create styles array
The data for the language used.
$ret
Definition: parser.php:6
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
populateWithCurrentSettings(ilPropertyFormGUI $form)
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.