ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $ilCtrl,$lng;
36
37 $this->ctrl = $ilCtrl;
38 $this->lng = $lng;
39 $this->lng->loadLanguageModule('auth');
40 $this->ref_id = $a_ref_id;
41
43 }
44
49 public function getSettings()
50 {
51 return $this->settings;
52 }
53
57 public function getRefId()
58 {
59 return $this->ref_id;
60 }
61
65 public function executeCommand()
66 {
67 switch($this->ctrl->getNextClass($this))
68 {
69 case 'illoginpagegui':
70 $GLOBALS['ilTabs']->clearTargets();
71 $GLOBALS['ilTabs']->setBackTarget(
72 $this->lng->txt('back'),
73 $this->ctrl->getLinkTarget($this,'show'),
74 '_top'
75 );
76
77 if ($_GET["redirectSource"] != "ilinternallinkgui")
78 {
79 $this->forwardToPageObject();
80 }
81 else
82 {
83 return '';
84 }
85 break;
86
87 default:
88 if(!$cmd = $this->ctrl->getCmd())
89 {
90 $cmd = 'show';
91 }
92 $this->$cmd();
93 break;
94 }
95 }
96
97
101 protected function forwardToPageObject()
102 {
103 global $lng,$tpl;
104
105 $key = (int) $_REQUEST['key'];
106 $this->ctrl->saveParameter($this,'key',$key);
107
108 include_once("./Services/Authentication/classes/class.ilLoginPage.php");
109 include_once("./Services/Authentication/classes/class.ilLoginPageGUI.php");
110 include_once './Services/Style/Content/classes/class.ilObjStyleSheet.php';
111
112 $lng->loadLanguageModule("content");
113
114 if (!ilLoginPage::_exists('auth',$key))
115 {
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 $html = $this->ctrl->forwardCommand($page_gui);
152
153 $tpl->setContent($html);
154 }
155
160 protected function show()
161 {
162 $this->addEditorSwitch();
163
164 switch($this->getSettings()->getMode())
165 {
167 return $this->showRichtextEditor();
168
170 return $this->showIliasEditor();
171 }
172 }
173
178 protected function addEditorSwitch()
179 {
180 global $ilToolbar;
181
182 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
183 switch($this->getSettings()->getMode())
184 {
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 {
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 $tpl;
250
251 include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorTableGUI.php';
252 $tbl = new ilAuthLoginPageEditorTableGUI($this,'show');
253 $tbl->parse();
254
255 $tpl->setContent($tbl->getHTML());
256 }
257
265 protected function showRichtextEditor()
266 {
267 global $rbacsystem, $lng,$ilSetting,$tpl;
268
269 if(!$rbacsystem->checkAccess("visible,read", $this->getRefId()))
270 {
271 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
272 }
273 $lng->loadLanguageModule("meta");
274
275 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.auth_login_messages.html",
276 "Services/Authentication");
277 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
278 $tpl->setVariable("TXT_HEADLINE", $this->lng->txt("login_information"));
279 $tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("login_information_desc"));
280 $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
281 $this->initLoginForm();
282 $tpl->setVariable('LOGIN_INFO',$this->form->getHTML());
283 }
284
291 protected function saveLoginInfo()
292 {
293 global $rbacsystem, $lng,$ilSetting;
294
295 if(!$rbacsystem->checkAccess("write",$this->getRefId()))
296 {
297 $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
298 }
299
300 $this->initLoginForm();
301 if ($this->form->checkInput())
302 {
303 if (is_array($_POST))
304 {
305 // @todo: Move settings ilAuthLoginPageSettings
306 $this->loginSettings = new ilSetting("login_settings");
307
308 foreach ($_POST as $key => $val)
309 {
310 if (substr($key, 0, 14) == "login_message_")
311 {
312 $this->loginSettings->set($key, $val);
313 }
314 }
315 }
316
317 if($_POST['default_auth_mode'])
318 {
319 $ilSetting->set('default_auth_mode',(int) $_POST['default_auth_mode']);
320 }
321
322 ilUtil::sendSuccess($this->lng->txt("login_information_settings_saved"),true);
323 }
324
325 $this->ctrl->redirect($this,'show');
326 }
327
331 protected function initLoginForm()
332 {
333 global $rbacsystem, $lng,$ilSetting;
334
335 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
336 $this->form = new ilPropertyFormGUI();
337 $this->form->setFormAction($this->ctrl->getFormAction($this,'saveLoginInfo'));
338 $this->form->setTableWidth('80%');
339 $this->form->setTitle($this->lng->txt('login_information'));
340
341 $this->form->addCommandButton('saveLoginInfo',$this->lng->txt('save'));
342
343 include_once('Services/LDAP/classes/class.ilLDAPServer.php');
344 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
345 $rad_settings = ilRadiusSettings::_getInstance();
346 if($ldap_id = ilLDAPServer::_getFirstActiveServer() or $rad_settings->isActive())
347 {
348 $select = new ilSelectInputGUI($this->lng->txt('default_auth_mode'),'default_auth_mode');
349 $select->setValue($ilSetting->get('default_auth_mode',AUTH_LOCAL));
350 $select->setInfo($this->lng->txt('default_auth_mode_info'));
351 $options[AUTH_LOCAL] = $this->lng->txt('auth_local');
352 if($ldap_id)
353 {
354 $options[AUTH_LDAP] = $this->lng->txt('auth_ldap');
355 }
356 if($rad_settings->isActive())
357 {
358 $options [AUTH_RADIUS] = $this->lng->txt('auth_radius');
359 }
360 $select->setOptions($options);
361 $this->form->addItem($select);
362 }
363
364 if (!is_object($this->loginSettings))
365 {
366 $this->loginSettings = new ilSetting("login_settings");
367 }
368
369 $login_settings = $this->loginSettings->getAll();
370 $languages = $lng->getInstalledLanguages();
371 $def_language = $lng->getDefaultLanguage();
372
373 foreach ($this->setDefLangFirst($def_language, $languages) as $lang_key)
374 {
375 $add = "";
376 if ($lang_key == $def_language)
377 {
378 $add = " (".$lng->txt("default").")";
379 }
380
381 $textarea = new ilTextAreaInputGUI($lng->txt("meta_l_".$lang_key).$add,
382 'login_message_'.$lang_key);
383 $textarea->setRows(10);
384 $textarea->setValue($login_settings["login_message_".$lang_key]);
385 $textarea->setUseRte(true);
386 $textarea->setRteTagSet("extended");
387 $this->form->addItem($textarea);
388
389 unset($login_settings["login_message_".$lang_key]);
390 }
391
392 foreach ($login_settings as $key => $message)
393 {
394 $lang_key = substr($key, strrpos($key, "_") + 1, strlen($key) - strrpos($key, "_"));
395
396 $textarea = new ilTextAreaInputGUI($lng->txt("meta_l_".$lang_key).$add,
397 'login_message_'.$lang_key);
398 $textarea->setRows(10);
399 $textarea->setValue($message);
400 $textarea->setUseRte(true);
401 $textarea->setRteTagSet("extended");
402 if(!in_array($lang_key,$languages))
403 {
404 $textarea->setAlert($lng->txt("not_installed"));
405 }
406 $this->form->addItem($textarea);
407 }
408 }
409
421 protected function setDefLangFirst($a_def_language, $a_languages)
422 {
423 if (is_array($a_languages) && $a_def_language != "")
424 {
425 $languages = array();
426 $languages[] = $a_def_language;
427
428 foreach ($a_languages as $val)
429 {
430 if (!in_array($val, $languages))
431 {
432 $languages[] = $val;
433 }
434 }
435
436 return $languages;
437 }
438 else
439 {
440 return array();
441 }
442 }
443}
444?>
global $tpl
Definition: ilias.php:8
$_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)
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.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$languages
Definition: cssgen2.php:34
$html
Definition: example_001.php:87
$tbl
Definition: example_048.php:81
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35
settings()
Definition: settings.php:2
if(!is_array($argv)) $options