ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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  case 'illoginpagegui':
69  $GLOBALS['ilTabs']->clearTargets();
70  $GLOBALS['ilTabs']->setBackTarget(
71  $this->lng->txt('back'),
72  $this->ctrl->getLinkTarget($this, 'show'),
73  '_top'
74  );
75 
76  if ($_GET["redirectSource"] != "ilinternallinkgui") {
77  $this->forwardToPageObject();
78  } else {
79  return '';
80  }
81  break;
82 
83  default:
84  if (!$cmd = $this->ctrl->getCmd()) {
85  $cmd = 'show';
86  }
87  $this->$cmd();
88  break;
89  }
90  }
91 
92 
96  protected function forwardToPageObject()
97  {
98  global $lng,$tpl;
99 
100  $key = (int) $_REQUEST['key'];
101  $this->ctrl->saveParameter($this, 'key', $key);
102 
103  include_once("./Services/Authentication/classes/class.ilLoginPage.php");
104  include_once("./Services/Authentication/classes/class.ilLoginPageGUI.php");
105  include_once './Services/Style/Content/classes/class.ilObjStyleSheet.php';
106 
107  $lng->loadLanguageModule("content");
108 
109  if (!ilLoginPage::_exists('auth', $key)) {
110  // doesn't exist -> create new one
111  $new_page_object = new ilLoginPage();
112  $new_page_object->setParentId($key);
113  $new_page_object->setId($key);
114  $new_page_object->createFromXML();
115  }
116 
117  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
118  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
119  $tpl->setCurrentBlock("SyntaxStyle");
120  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
121  $tpl->parseCurrentBlock();
122 
123 
124  $this->ctrl->setReturnByClass('illoginpagegui', "edit");
125  $page_gui = new ilLoginPageGUI($key);
126 
127  $page_gui->setTemplateTargetVar("ADM_CONTENT");
128  $page_gui->setLinkXML($link_xml);
129  //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
130  //$page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
131  //$page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
132  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
133  // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
134  $page_gui->setPresentationTitle("");
135  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
136  $page_gui->setTemplateOutput(false);
137  //$page_gui->setLocator($contObjLocator);
138  $page_gui->setHeader("");
139 
140  // style tab
141  //$page_gui->setTabHook($this, "addPageTabs");
142 
143  if ($this->ctrl->getCmd() == 'editPage') {
144  $this->ctrl->setCmd('edit');
145  }
146  $html = $this->ctrl->forwardCommand($page_gui);
147 
148  $tpl->setContent($html);
149  }
150 
155  protected function show()
156  {
157  $this->addEditorSwitch();
158 
159  switch ($this->getSettings()->getMode()) {
161  return $this->showRichtextEditor();
162 
164  return $this->showIliasEditor();
165  }
166  }
167 
172  protected function addEditorSwitch()
173  {
174  global $ilToolbar;
175 
176  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
177  switch ($this->getSettings()->getMode()) {
179 
180  $ilToolbar->addButton(
181  $this->lng->txt('login_page_switch_ipe'),
182  $this->ctrl->getLinkTarget($this, 'switchIPE')
183  );
184  break;
185 
187 
188  $ilToolbar->addButton(
189  $this->lng->txt('login_page_switch_rte'),
190  $this->ctrl->getLinkTarget($this, 'switchRTE')
191  );
192  break;
193  }
194  return;
195  }
196 
200  protected function switchIPE()
201  {
203  $this->getSettings()->update();
204 
205  ilUtil::sendSuccess($this->lng->txt('login_page_editor_switched'), true);
206  $this->ctrl->redirect($this, 'show');
207  }
208 
212  protected function switchRTE()
213  {
215  $this->getSettings()->update();
216 
217  ilUtil::sendSuccess($this->lng->txt('login_page_editor_switched'), true);
218  $this->ctrl->redirect($this, 'show');
219  }
220 
224  protected function activate()
225  {
227  foreach ((array) $_POST['visible_languages'] as $lang_key) {
228  $settings->enableIliasEditor($lang_key, in_array($lang_key, (array) $_POST['languages']));
229  }
230  $settings->update();
231 
232  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
233  $this->ctrl->redirect($this, 'show');
234  }
235 
239  protected function showIliasEditor()
240  {
241  global $tpl;
242 
243  include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorTableGUI.php';
244  $tbl = new ilAuthLoginPageEditorTableGUI($this, 'show');
245  $tbl->parse();
246 
247  $tpl->setContent($tbl->getHTML());
248  }
249 
257  protected function showRichtextEditor()
258  {
259  global $rbacsystem, $lng,$ilSetting,$tpl;
260 
261  if (!$rbacsystem->checkAccess("visible,read", $this->getRefId())) {
262  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
263  }
264  $lng->loadLanguageModule("meta");
265 
266  $tpl->addBlockFile(
267  "ADM_CONTENT",
268  "adm_content",
269  "tpl.auth_login_messages.html",
270  "Services/Authentication"
271  );
272  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
273  $tpl->setVariable("TXT_HEADLINE", $this->lng->txt("login_information"));
274  $tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("login_information_desc"));
275  $tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
276  $this->initLoginForm();
277  $tpl->setVariable('LOGIN_INFO', $this->form->getHTML());
278  }
279 
286  protected function saveLoginInfo()
287  {
288  global $rbacsystem, $lng,$ilSetting;
289 
290  if (!$rbacsystem->checkAccess("write", $this->getRefId())) {
291  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
292  }
293 
294  $this->initLoginForm();
295  if ($this->form->checkInput()) {
296  if (is_array($_POST)) {
297  // @todo: Move settings ilAuthLoginPageSettings
298  $this->loginSettings = new ilSetting("login_settings");
299 
300  foreach ($_POST as $key => $val) {
301  if (substr($key, 0, 14) == "login_message_") {
302  $this->loginSettings->set($key, $val);
303  }
304  }
305  }
306 
307  if ($_POST['default_auth_mode']) {
308  $ilSetting->set('default_auth_mode', (int) $_POST['default_auth_mode']);
309  }
310 
311  ilUtil::sendSuccess($this->lng->txt("login_information_settings_saved"), true);
312  }
313 
314  $this->ctrl->redirect($this, 'show');
315  }
316 
320  protected function initLoginForm()
321  {
322  global $rbacsystem, $lng,$ilSetting;
323 
324  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
325  $this->form = new ilPropertyFormGUI();
326  $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveLoginInfo'));
327  $this->form->setTableWidth('80%');
328  $this->form->setTitle($this->lng->txt('login_information'));
329 
330  $this->form->addCommandButton('saveLoginInfo', $this->lng->txt('save'));
331 
332  include_once('Services/LDAP/classes/class.ilLDAPServer.php');
333  include_once('Services/Radius/classes/class.ilRadiusSettings.php');
334  $rad_settings = ilRadiusSettings::_getInstance();
335  if ($ldap_id = ilLDAPServer::_getFirstActiveServer() or $rad_settings->isActive()) {
336  $select = new ilSelectInputGUI($this->lng->txt('default_auth_mode'), 'default_auth_mode');
337  $select->setValue($ilSetting->get('default_auth_mode', AUTH_LOCAL));
338  $select->setInfo($this->lng->txt('default_auth_mode_info'));
339  $options[AUTH_LOCAL] = $this->lng->txt('auth_local');
340  if ($ldap_id) {
341  $options[AUTH_LDAP] = $this->lng->txt('auth_ldap');
342  }
343  if ($rad_settings->isActive()) {
344  $options [AUTH_RADIUS] = $this->lng->txt('auth_radius');
345  }
346  $select->setOptions($options);
347  $this->form->addItem($select);
348  }
349 
350  if (!is_object($this->loginSettings)) {
351  $this->loginSettings = new ilSetting("login_settings");
352  }
353 
354  $login_settings = $this->loginSettings->getAll();
355  $languages = $lng->getInstalledLanguages();
356  $def_language = $lng->getDefaultLanguage();
357 
358  foreach ($this->setDefLangFirst($def_language, $languages) as $lang_key) {
359  $add = "";
360  if ($lang_key == $def_language) {
361  $add = " (" . $lng->txt("default") . ")";
362  }
363 
364  $textarea = new ilTextAreaInputGUI(
365  $lng->txt("meta_l_" . $lang_key) . $add,
366  'login_message_' . $lang_key
367  );
368  $textarea->setRows(10);
369  $textarea->setValue($login_settings["login_message_" . $lang_key]);
370  $textarea->setUseRte(true);
371  $textarea->setRteTagSet("extended");
372  $this->form->addItem($textarea);
373 
374  unset($login_settings["login_message_" . $lang_key]);
375  }
376 
377  foreach ($login_settings as $key => $message) {
378  $lang_key = substr($key, strrpos($key, "_") + 1, strlen($key) - strrpos($key, "_"));
379 
380  $textarea = new ilTextAreaInputGUI(
381  $lng->txt("meta_l_" . $lang_key) . $add,
382  'login_message_' . $lang_key
383  );
384  $textarea->setRows(10);
385  $textarea->setValue($message);
386  $textarea->setUseRte(true);
387  $textarea->setRteTagSet("extended");
388  if (!in_array($lang_key, $languages)) {
389  $textarea->setAlert($lng->txt("not_installed"));
390  }
391  $this->form->addItem($textarea);
392  }
393  }
394 
406  protected function setDefLangFirst($a_def_language, $a_languages)
407  {
408  if (is_array($a_languages) && $a_def_language != "") {
409  $languages = array();
410  $languages[] = $a_def_language;
411 
412  foreach ($a_languages as $val) {
413  if (!in_array($val, $languages)) {
414  $languages[] = $val;
415  }
416  }
417 
418  return $languages;
419  } else {
420  return array();
421  }
422  }
423 }
Login page editor settings GUI ILIAS page editor or richtext editor.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static _getFirstActiveServer()
Get first active server.
global $ilErr
Definition: raiseError.php:16
Login page GUI class.
setDefLangFirst($a_def_language, $a_languages)
returns an array of all installed languages, default language at the first position ...
This class represents a selection list property in a property form.
forwardToPageObject()
Forward to page editor.
This class represents a property form user interface.
$_GET["client_id"]
$tbl
Definition: example_048.php:81
$tpl
Definition: ilias.php:10
const AUTH_LDAP
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
executeCommand()
ilCtrl execute command
global $ilCtrl
Definition: ilias.php:18
catch(Exception $e) $message
setValue($a_value)
Set Value.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static _getInstance()
singleton get instance
static getSyntaxStylePath()
get syntax style path
const AUTH_LOCAL
static getContentStylePath($a_style_id, $add_random=true)
get content style path
showIliasEditor()
Show ILIAS page editor summary.
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
Login page object.
showRichtextEditor()
Show richtext editor ilRbacSystem $rbacsystem ilLanguage $lng ilSetting $ilSetting.
global $ilSetting
Definition: privfeed.php:17
saveLoginInfo()
saves the login information data
This class represents a text area property in a property form.
show()
Show current activated editor.
static getInstance()
Get singelton instance.
$key
Definition: croninfo.php:18
$_POST["username"]
$html
Definition: example_001.php:87
addEditorSwitch()
Show editore switch ilToolbarGUI $ilToolbar.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
const AUTH_RADIUS