ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
4include_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 {
75 $ilAccess = $this->access;
77
78 $lng->loadLanguageModule("wiki");
79
80 $next_class = $this->ctrl->getNextClass($this);
81 $cmd = $this->ctrl->getCmd();
82
83 $this->prepareOutput();
84
85 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
86 $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
87 }
88
89 switch ($next_class) {
90 case 'ilpermissiongui':
91 $this->tabs_gui->setTabActive('perm_settings');
92 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
93 $perm_gui = new ilPermissionGUI($this);
94 $ret = $this->ctrl->forwardCommand($perm_gui);
95 break;
96
97 default:
98 if (!$cmd || $cmd == 'view') {
99 $cmd = "editSettings";
100 }
101
102 $this->$cmd();
103 break;
104 }
105 return true;
106 }
107
111 protected function editSettings(ilPropertyFormGUI $form = null)
112 {
115 $ilTabs = $this->tabs;
116 $ilToolbar = $this->toolbar;
118
119 $ilTabs->activateTab("settings");
120
121 if ($this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
122 if (!$form) {
123 $form = $this->initForm();
124 $this->populateWithCurrentSettings($form);
125 }
126 $tpl->setContent($form->getHTML());
127 }
128 }
129
134 {
135 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
136
137 $form->setValuesByArray(array(
138 'activate_captcha_anonym' => ilCaptchaUtil::isActiveForWiki()
139 ));
140 }
141
146 public function initForm($a_mode = "edit")
147 {
150
151 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
152 $form = new ilPropertyFormGUI();
153
154 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
155 $cap = new ilCheckboxInputGUI($this->lng->txt('adm_captcha_anonymous_short'), 'activate_captcha_anonym');
156 $cap->setInfo($this->lng->txt('adm_captcha_anonymous_wiki'));
157 $cap->setValue(1);
159 $cap->setAlert(ilCaptchaUtil::getPreconditionsMessage());
160 }
161 $form->addItem($cap);
162
163 if ($this->checkPermissionBool("write")) {
164 $form->addCommandButton("saveSettings", $lng->txt("save"));
165 }
166
167 $form->setTitle($lng->txt("settings"));
168 $form->setFormAction($ilCtrl->getFormAction($this));
169
170 return $form;
171 }
172
176 protected function saveSettings()
177 {
184
185 if (!$this->checkPermissionBool("write")) {
186 $this->editSettings();
187 return;
188 }
189
190 $form = $this->initForm();
191 if (!$form->checkInput()) {
192 $form->setValuesByPost();
193 $this->editSettings($form);
194 return;
195 }
196
197 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
198 ilCaptchaUtil::setActiveForWiki((bool) $form->getInput('activate_captcha_anonym'));
199
200 ilUtil::sendSuccess($lng->txt('msg_obj_modified'), true);
201 $ilCtrl->redirect($this, 'editSettings');
202 }
203
207 public function getAdminTabs()
208 {
209 if ($this->checkPermissionBool("visible,read")) {
210 $this->tabs_gui->addTab(
211 "settings",
212 $this->lng->txt("settings"),
213 $this->ctrl->getLinkTarget($this, "editSettings")
214 );
215 }
216
217 if ($this->checkPermissionBool("edit_permission")) {
218 $this->tabs_gui->addTab(
219 "perm_settings",
220 $this->lng->txt("perm_settings"),
221 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
222 );
223 }
224 }
225
230 public function addToExternalSettingsForm($a_form_id)
231 {
232 switch ($a_form_id) {
234 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
235 $fields = array(
236 'adm_captcha_anonymous_short' => array(ilCaptchaUtil::isActiveForWiki(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
237 );
238
239 return array('obj_wiks' => array('editSettings', $fields));
240 }
241 }
242}
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
static checkFreetype()
Check whether captcha support is active.
This class represents a checkbox property in a property form.
Wiki settings gui class.
getAdminTabs()
administration tabs show only permissions and trash folder
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
populateWithCurrentSettings(ilPropertyFormGUI $form)
editSettings(ilPropertyFormGUI $form=null)
New implementation of ilObjectGUI.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46