ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAuthLoginPageEditorGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorSettings.php';
5
16{
20 protected $ctrl = null;
21 protected $lng = null;
22
23 private $ref_id = 0;
24 private $settings = null;
25
26
27
33 public function __construct($a_ref_id)
34 {
35 global $DIC;
36
37 $ilCtrl = $DIC['ilCtrl'];
38 $lng = $DIC['lng'];
39
40 $this->ctrl = $ilCtrl;
41 $this->lng = $lng;
42 $this->lng->loadLanguageModule('auth');
43 $this->ref_id = $a_ref_id;
44
46 }
47
52 public function getSettings()
53 {
54 return $this->settings;
55 }
56
60 public function getRefId()
61 {
62 return $this->ref_id;
63 }
64
68 public function executeCommand()
69 {
70 switch ($this->ctrl->getNextClass($this)) {
71 case 'illoginpagegui':
72 $GLOBALS['DIC']['ilTabs']->clearTargets();
73 $GLOBALS['DIC']['ilTabs']->setBackTarget(
74 $this->lng->txt('back'),
75 $this->ctrl->getLinkTarget($this, 'show'),
76 '_top'
77 );
78
79 if ($_GET["redirectSource"] != "ilinternallinkgui") {
80 $this->forwardToPageObject();
81 } else {
82 return '';
83 }
84 break;
85
86 default:
87 if (!$cmd = $this->ctrl->getCmd()) {
88 $cmd = 'show';
89 }
90 $this->$cmd();
91 break;
92 }
93 }
94
95
99 protected function forwardToPageObject()
100 {
101 global $DIC;
102
103 $lng = $DIC['lng'];
104 $tpl = $DIC['tpl'];
105
106 $key = (int) $_REQUEST['key'];
107 $this->ctrl->saveParameter($this, 'key', $key);
108
109 include_once("./Services/Authentication/classes/class.ilLoginPage.php");
110 include_once("./Services/Authentication/classes/class.ilLoginPageGUI.php");
111 include_once './Services/Style/Content/classes/class.ilObjStyleSheet.php';
112
113 $lng->loadLanguageModule("content");
114
115 if (!ilLoginPage::_exists('auth', $key)) {
116 // doesn't exist -> create new one
117 $new_page_object = new ilLoginPage();
118 $new_page_object->setParentId($key);
119 $new_page_object->setId($key);
120 $new_page_object->createFromXML();
121 }
122
125
126
127 $this->ctrl->setReturnByClass('illoginpagegui', "edit");
128 $page_gui = new ilLoginPageGUI($key);
129
130 $page_gui->setTemplateTargetVar("ADM_CONTENT");
131 $page_gui->setLinkXML($link_xml);
132 //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
133 //$page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
134 //$page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
135 //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
136 // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
137 $page_gui->setPresentationTitle("");
138 $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
139 $page_gui->setTemplateOutput(false);
140 //$page_gui->setLocator($contObjLocator);
141 $page_gui->setHeader("");
142
143 // style tab
144 //$page_gui->setTabHook($this, "addPageTabs");
145
146 if ($this->ctrl->getCmd() == 'editPage') {
147 $this->ctrl->setCmd('edit');
148 }
149 $html = $this->ctrl->forwardCommand($page_gui);
150
151 if ($html != "") {
152 $tpl->setContent($html);
153 }
154 }
155
160 protected function show()
161 {
162 $this->addEditorSwitch();
163
164 switch ($this->getSettings()->getMode()) {
166 return $this->showRichtextEditor();
167
169 return $this->showIliasEditor();
170 }
171 }
172
177 protected function addEditorSwitch()
178 {
179 global $DIC;
180
181 $ilToolbar = $DIC['ilToolbar'];
182
183 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
184 switch ($this->getSettings()->getMode()) {
186
187 $ilToolbar->addButton(
188 $this->lng->txt('login_page_switch_ipe'),
189 $this->ctrl->getLinkTarget($this, 'switchIPE')
190 );
191 break;
192
194
195 $ilToolbar->addButton(
196 $this->lng->txt('login_page_switch_rte'),
197 $this->ctrl->getLinkTarget($this, 'switchRTE')
198 );
199 break;
200 }
201 return;
202 }
203
207 protected function switchIPE()
208 {
210 $this->getSettings()->update();
211
212 ilUtil::sendSuccess($this->lng->txt('login_page_editor_switched'), true);
213 $this->ctrl->redirect($this, 'show');
214 }
215
219 protected function switchRTE()
220 {
222 $this->getSettings()->update();
223
224 ilUtil::sendSuccess($this->lng->txt('login_page_editor_switched'), true);
225 $this->ctrl->redirect($this, 'show');
226 }
227
231 protected function activate()
232 {
234 foreach ((array) $_POST['visible_languages'] as $lang_key) {
235 $settings->enableIliasEditor($lang_key, in_array($lang_key, (array) $_POST['languages']));
236 }
237 $settings->update();
238
239 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
240 $this->ctrl->redirect($this, 'show');
241 }
242
246 protected function showIliasEditor()
247 {
248 global $DIC;
249
250 $tpl = $DIC['tpl'];
251
252 include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorTableGUI.php';
253 $tbl = new ilAuthLoginPageEditorTableGUI($this, 'show');
254 $tbl->parse();
255
256 $tpl->setContent($tbl->getHTML());
257 }
258
266 protected function showRichtextEditor()
267 {
268 global $DIC;
269
270 $rbacsystem = $DIC['rbacsystem'];
271 $lng = $DIC['lng'];
272 $ilSetting = $DIC['ilSetting'];
273 $tpl = $DIC['tpl'];
274
275 if (!$rbacsystem->checkAccess("visible,read", $this->getRefId())) {
276 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
277 }
278 $lng->loadLanguageModule("meta");
279
280 $tpl->addBlockFile(
281 "ADM_CONTENT",
282 "adm_content",
283 "tpl.auth_login_messages.html",
284 "Services/Authentication"
285 );
286 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
287 $tpl->setVariable("TXT_HEADLINE", $this->lng->txt("login_information"));
288 $tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("login_information_desc"));
289 $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
290 $this->initLoginForm();
291 $tpl->setVariable('LOGIN_INFO', $this->form->getHTML());
292 }
293
300 protected function saveLoginInfo()
301 {
302 global $DIC;
303
304 $rbacsystem = $DIC['rbacsystem'];
305 $lng = $DIC['lng'];
306 $ilSetting = $DIC['ilSetting'];
307
308 if (!$rbacsystem->checkAccess("write", $this->getRefId())) {
309 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
310 }
311
312 $this->initLoginForm();
313 if ($this->form->checkInput()) {
314 if (is_array($_POST)) {
315 // @todo: Move settings ilAuthLoginPageSettings
316 $this->loginSettings = new ilSetting("login_settings");
317
318 foreach ($_POST as $key => $val) {
319 if (substr($key, 0, 14) == "login_message_") {
320 $this->loginSettings->set($key, $val);
321 }
322 }
323 }
324
325 if ($_POST['default_auth_mode']) {
326 $ilSetting->set('default_auth_mode', (int) $_POST['default_auth_mode']);
327 }
328
329 ilUtil::sendSuccess($this->lng->txt("login_information_settings_saved"), true);
330 }
331
332 $this->ctrl->redirect($this, 'show');
333 }
334
338 protected function initLoginForm()
339 {
340 global $DIC;
341
342 $rbacsystem = $DIC['rbacsystem'];
343 $lng = $DIC['lng'];
344 $ilSetting = $DIC['ilSetting'];
345
346 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
347 $this->form = new ilPropertyFormGUI();
348 $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveLoginInfo'));
349 $this->form->setTableWidth('80%');
350 $this->form->setTitle($this->lng->txt('login_information'));
351
352 $this->form->addCommandButton('saveLoginInfo', $this->lng->txt('save'));
353
354 include_once('Services/LDAP/classes/class.ilLDAPServer.php');
355 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
356 $rad_settings = ilRadiusSettings::_getInstance();
357 if ($ldap_id = ilLDAPServer::_getFirstActiveServer() or $rad_settings->isActive()) {
358 $select = new ilSelectInputGUI($this->lng->txt('default_auth_mode'), 'default_auth_mode');
359 $select->setValue($ilSetting->get('default_auth_mode', AUTH_LOCAL));
360 $select->setInfo($this->lng->txt('default_auth_mode_info'));
361 $options[AUTH_LOCAL] = $this->lng->txt('auth_local');
362 if ($ldap_id) {
363 $options[AUTH_LDAP] = $this->lng->txt('auth_ldap');
364 }
365 if ($rad_settings->isActive()) {
366 $options [AUTH_RADIUS] = $this->lng->txt('auth_radius');
367 }
368 $select->setOptions($options);
369 $this->form->addItem($select);
370 }
371
372 if (!is_object($this->loginSettings)) {
373 $this->loginSettings = new ilSetting("login_settings");
374 }
375
376 $login_settings = $this->loginSettings->getAll();
377 $languages = $lng->getInstalledLanguages();
378 $def_language = $lng->getDefaultLanguage();
379
380 foreach ($this->setDefLangFirst($def_language, $languages) as $lang_key) {
381 $add = "";
382 if ($lang_key == $def_language) {
383 $add = " (" . $lng->txt("default") . ")";
384 }
385
386 $textarea = new ilTextAreaInputGUI(
387 $lng->txt("meta_l_" . $lang_key) . $add,
388 'login_message_' . $lang_key
389 );
390 $textarea->setRows(10);
391 $textarea->setValue($login_settings["login_message_" . $lang_key]);
392 $textarea->setUseRte(true);
393 $textarea->setRteTagSet("extended");
394 $this->form->addItem($textarea);
395
396 unset($login_settings["login_message_" . $lang_key]);
397 }
398
399 foreach ($login_settings as $key => $message) {
400 $lang_key = substr($key, strrpos($key, "_") + 1, strlen($key) - strrpos($key, "_"));
401
402 $textarea = new ilTextAreaInputGUI(
403 $lng->txt("meta_l_" . $lang_key) . $add,
404 'login_message_' . $lang_key
405 );
406 $textarea->setRows(10);
407 $textarea->setValue($message);
408 $textarea->setUseRte(true);
409 $textarea->setRteTagSet("extended");
410 if (!in_array($lang_key, $languages)) {
411 $textarea->setAlert($lng->txt("not_installed"));
412 }
413 $this->form->addItem($textarea);
414 }
415 }
416
428 protected function setDefLangFirst($a_def_language, $a_languages)
429 {
430 if (is_array($a_languages) && $a_def_language != "") {
431 $languages = array();
432 $languages[] = $a_def_language;
433
434 foreach ($a_languages as $val) {
435 if (!in_array($val, $languages)) {
436 $languages[] = $val;
437 }
438 }
439
440 return $languages;
441 } else {
442 return array();
443 }
444 }
445}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const AUTH_LDAP
const AUTH_LOCAL
const AUTH_RADIUS
Login page editor settings GUI ILIAS page editor or richtext editor.
showIliasEditor()
Show ILIAS page editor summary.
addEditorSwitch()
Show editore switch @global ilToolbarGUI $ilToolbar.
showRichtextEditor()
Show richtext editor @global ilRbacSystem $rbacsystem @global ilLanguage $lng @global ilSetting $ilSe...
show()
Show current activated editor.
setDefLangFirst($a_def_language, $a_languages)
returns an array of all installed languages, default language at the first position
saveLoginInfo()
saves the login information data
forwardToPageObject()
Forward to page editor.
static _getFirstActiveServer()
Get first active server.
Login page GUI class.
Login page object.
static getSyntaxStylePath()
get syntax style path
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
This class represents a property form user interface.
static _getInstance()
singleton get instance
This class represents a selection list property in a property form.
ILIAS Setting Class.
This class represents a text area property in a property form.
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
global $ilSetting
Definition: privfeed.php:17
$ilErr
Definition: raiseError.php:18
settings()
Definition: settings.php:2
$message
Definition: xapiexit.php:14