ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
123 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
124 $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
125 $tpl->setCurrentBlock("SyntaxStyle");
126 $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
127 $tpl->parseCurrentBlock();
128
129
130 $this->ctrl->setReturnByClass('illoginpagegui', "edit");
131 $page_gui = new ilLoginPageGUI($key);
132
133 $page_gui->setTemplateTargetVar("ADM_CONTENT");
134 $page_gui->setLinkXML($link_xml);
135 //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
136 //$page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
137 //$page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
138 //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
139 // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
140 $page_gui->setPresentationTitle("");
141 $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
142 $page_gui->setTemplateOutput(false);
143 //$page_gui->setLocator($contObjLocator);
144 $page_gui->setHeader("");
145
146 // style tab
147 //$page_gui->setTabHook($this, "addPageTabs");
148
149 if ($this->ctrl->getCmd() == 'editPage') {
150 $this->ctrl->setCmd('edit');
151 }
152 $html = $this->ctrl->forwardCommand($page_gui);
153
154 $tpl->setContent($html);
155 }
156
161 protected function show()
162 {
163 $this->addEditorSwitch();
164
165 switch ($this->getSettings()->getMode()) {
167 return $this->showRichtextEditor();
168
170 return $this->showIliasEditor();
171 }
172 }
173
178 protected function addEditorSwitch()
179 {
180 global $DIC;
181
182 $ilToolbar = $DIC['ilToolbar'];
183
184 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
185 switch ($this->getSettings()->getMode()) {
187
188 $ilToolbar->addButton(
189 $this->lng->txt('login_page_switch_ipe'),
190 $this->ctrl->getLinkTarget($this, 'switchIPE')
191 );
192 break;
193
195
196 $ilToolbar->addButton(
197 $this->lng->txt('login_page_switch_rte'),
198 $this->ctrl->getLinkTarget($this, 'switchRTE')
199 );
200 break;
201 }
202 return;
203 }
204
208 protected function switchIPE()
209 {
211 $this->getSettings()->update();
212
213 ilUtil::sendSuccess($this->lng->txt('login_page_editor_switched'), true);
214 $this->ctrl->redirect($this, 'show');
215 }
216
220 protected function switchRTE()
221 {
223 $this->getSettings()->update();
224
225 ilUtil::sendSuccess($this->lng->txt('login_page_editor_switched'), true);
226 $this->ctrl->redirect($this, 'show');
227 }
228
232 protected function activate()
233 {
235 foreach ((array) $_POST['visible_languages'] as $lang_key) {
236 $settings->enableIliasEditor($lang_key, in_array($lang_key, (array) $_POST['languages']));
237 }
238 $settings->update();
239
240 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
241 $this->ctrl->redirect($this, 'show');
242 }
243
247 protected function showIliasEditor()
248 {
249 global $DIC;
250
251 $tpl = $DIC['tpl'];
252
253 include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorTableGUI.php';
254 $tbl = new ilAuthLoginPageEditorTableGUI($this, 'show');
255 $tbl->parse();
256
257 $tpl->setContent($tbl->getHTML());
258 }
259
267 protected function showRichtextEditor()
268 {
269 global $DIC;
270
271 $rbacsystem = $DIC['rbacsystem'];
272 $lng = $DIC['lng'];
273 $ilSetting = $DIC['ilSetting'];
274 $tpl = $DIC['tpl'];
275
276 if (!$rbacsystem->checkAccess("visible,read", $this->getRefId())) {
277 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
278 }
279 $lng->loadLanguageModule("meta");
280
281 $tpl->addBlockFile(
282 "ADM_CONTENT",
283 "adm_content",
284 "tpl.auth_login_messages.html",
285 "Services/Authentication"
286 );
287 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
288 $tpl->setVariable("TXT_HEADLINE", $this->lng->txt("login_information"));
289 $tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("login_information_desc"));
290 $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
291 $this->initLoginForm();
292 $tpl->setVariable('LOGIN_INFO', $this->form->getHTML());
293 }
294
301 protected function saveLoginInfo()
302 {
303 global $DIC;
304
305 $rbacsystem = $DIC['rbacsystem'];
306 $lng = $DIC['lng'];
307 $ilSetting = $DIC['ilSetting'];
308
309 if (!$rbacsystem->checkAccess("write", $this->getRefId())) {
310 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
311 }
312
313 $this->initLoginForm();
314 if ($this->form->checkInput()) {
315 if (is_array($_POST)) {
316 // @todo: Move settings ilAuthLoginPageSettings
317 $this->loginSettings = new ilSetting("login_settings");
318
319 foreach ($_POST as $key => $val) {
320 if (substr($key, 0, 14) == "login_message_") {
321 $this->loginSettings->set($key, $val);
322 }
323 }
324 }
325
326 if ($_POST['default_auth_mode']) {
327 $ilSetting->set('default_auth_mode', (int) $_POST['default_auth_mode']);
328 }
329
330 ilUtil::sendSuccess($this->lng->txt("login_information_settings_saved"), true);
331 }
332
333 $this->ctrl->redirect($this, 'show');
334 }
335
339 protected function initLoginForm()
340 {
341 global $DIC;
342
343 $rbacsystem = $DIC['rbacsystem'];
344 $lng = $DIC['lng'];
345 $ilSetting = $DIC['ilSetting'];
346
347 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
348 $this->form = new ilPropertyFormGUI();
349 $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveLoginInfo'));
350 $this->form->setTableWidth('80%');
351 $this->form->setTitle($this->lng->txt('login_information'));
352
353 $this->form->addCommandButton('saveLoginInfo', $this->lng->txt('save'));
354
355 include_once('Services/LDAP/classes/class.ilLDAPServer.php');
356 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
357 $rad_settings = ilRadiusSettings::_getInstance();
358 if ($ldap_id = ilLDAPServer::_getFirstActiveServer() or $rad_settings->isActive()) {
359 $select = new ilSelectInputGUI($this->lng->txt('default_auth_mode'), 'default_auth_mode');
360 $select->setValue($ilSetting->get('default_auth_mode', AUTH_LOCAL));
361 $select->setInfo($this->lng->txt('default_auth_mode_info'));
362 $options[AUTH_LOCAL] = $this->lng->txt('auth_local');
363 if ($ldap_id) {
364 $options[AUTH_LDAP] = $this->lng->txt('auth_ldap');
365 }
366 if ($rad_settings->isActive()) {
367 $options [AUTH_RADIUS] = $this->lng->txt('auth_radius');
368 }
369 $select->setOptions($options);
370 $this->form->addItem($select);
371 }
372
373 if (!is_object($this->loginSettings)) {
374 $this->loginSettings = new ilSetting("login_settings");
375 }
376
377 $login_settings = $this->loginSettings->getAll();
378 $languages = $lng->getInstalledLanguages();
379 $def_language = $lng->getDefaultLanguage();
380
381 foreach ($this->setDefLangFirst($def_language, $languages) as $lang_key) {
382 $add = "";
383 if ($lang_key == $def_language) {
384 $add = " (" . $lng->txt("default") . ")";
385 }
386
387 $textarea = new ilTextAreaInputGUI(
388 $lng->txt("meta_l_" . $lang_key) . $add,
389 'login_message_' . $lang_key
390 );
391 $textarea->setRows(10);
392 $textarea->setValue($login_settings["login_message_" . $lang_key]);
393 $textarea->setUseRte(true);
394 $textarea->setRteTagSet("extended");
395 $this->form->addItem($textarea);
396
397 unset($login_settings["login_message_" . $lang_key]);
398 }
399
400 foreach ($login_settings as $key => $message) {
401 $lang_key = substr($key, strrpos($key, "_") + 1, strlen($key) - strrpos($key, "_"));
402
403 $textarea = new ilTextAreaInputGUI(
404 $lng->txt("meta_l_" . $lang_key) . $add,
405 'login_message_' . $lang_key
406 );
407 $textarea->setRows(10);
408 $textarea->setValue($message);
409 $textarea->setUseRte(true);
410 $textarea->setRteTagSet("extended");
411 if (!in_array($lang_key, $languages)) {
412 $textarea->setAlert($lng->txt("not_installed"));
413 }
414 $this->form->addItem($textarea);
415 }
416 }
417
429 protected function setDefLangFirst($a_def_language, $a_languages)
430 {
431 if (is_array($a_languages) && $a_def_language != "") {
432 $languages = array();
433 $languages[] = $a_def_language;
434
435 foreach ($a_languages as $val) {
436 if (!in_array($val, $languages)) {
437 $languages[] = $val;
438 }
439 }
440
441 return $languages;
442 } else {
443 return array();
444 }
445 }
446}
$tpl
Definition: ilias.php:10
$_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)
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.
$key
Definition: croninfo.php:18
$languages
Definition: cssgen2.php:34
$html
Definition: example_001.php:87
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
catch(Exception $e) $message
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
global $ilSetting
Definition: privfeed.php:17
$ilErr
Definition: raiseError.php:18
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2