ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTestPasswordProtectionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
14{
15 const CMD_SHOW_PASSWORD_FORM = 'showPasswordForm';
16 const CMD_SAVE_ENTERED_PASSWORD = 'saveEnteredPassword';
17 const CMD_BACK_TO_INFO_SCREEN = 'backToInfoScreen';
18
22 protected $ctrl;
23
27 protected $tpl;
28
32 protected $lng;
33
37 protected $parentGUI;
38
43
48
53
55 {
56 $this->ctrl = $ctrl;
57 $this->tpl = $tpl;
58 $this->lng = $lng;
59 $this->parentGUI = $parentGUI;
60 $this->passwordChecker = $passwordChecker;
61 }
62
63 public function executeCommand()
64 {
65 $this->ctrl->saveParameter($this, 'nextCommand');
66 $nextCommand = explode('::', $_GET['nextCommand']);
67 $this->setNextCommandClass($nextCommand[0]);
68 $this->setNextCommandCmd($nextCommand[1]);
69
70 $this->ctrl->saveParameter($this->parentGUI, 'lock');
71
72 switch($this->ctrl->getNextClass())
73 {
74 default:
75
76 $cmd = $this->ctrl->getCmd().'Cmd';
77 $this->$cmd();
78 }
79 }
80
81 protected function buildPasswordMsg()
82 {
83 if( !$this->passwordChecker->wrongUserEnteredPasswordExist() )
84 {
85 return '';
86 }
87
88 return $this->tpl->getMessageHTML(
89 $this->lng->txt('tst_password_entered_wrong_password'), 'failure'
90 );
91 }
92
96 protected function buildPasswordForm()
97 {
98 $form = new ilPropertyFormGUI();
99 $form->setTitle($this->lng->txt("tst_password_form"));
100 $form->setDescription($this->lng->txt("tst_password_introduction"));
101
102 $form->setFormAction($this->ctrl->getFormAction($this));
103 $form->addCommandButton(self::CMD_SAVE_ENTERED_PASSWORD, $this->lng->txt("submit"));
104 $form->addCommandButton(self::CMD_BACK_TO_INFO_SCREEN, $this->lng->txt("cancel"));
105
106 $inp = new ilPasswordInputGUI($this->lng->txt("tst_password"), 'password');
107 $inp->setRequired(true);
108 $inp->setRetype(false);
109 $form->addItem($inp);
110 return $form;
111 }
112
113 private function showPasswordFormCmd()
114 {
115 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
116 require_once 'Services/Form/classes/class.ilPasswordInputGUI.php';
117
118 $msg = $this->buildPasswordMsg();
119 $form = $this->buildPasswordForm();
120
121 $this->tpl->setVariable(
122 $this->parentGUI->getContentBlockName(), $msg.$this->ctrl->getHTML($form)
123 );
124 }
125
126 private function saveEnteredPasswordCmd()
127 {
128 $this->passwordChecker->setUserEnteredPassword($_POST["password"]);
129
130 if( !$this->passwordChecker->isUserEnteredPasswordCorrect() )
131 {
132 $this->passwordChecker->logWrongEnteredPassword();
133 }
134
135 $this->ctrl->redirectByClass($this->getNextCommandClass(), $this->getNextCommandCmd());
136 }
137
138 private function backToInfoScreenCmd()
139 {
140 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
141 }
142
144 {
145 $this->nextCommandClass = $nextCommandClass;
146 }
147
148 private function getNextCommandClass()
149 {
151 }
152
154 {
155 $this->nextCommandCmd = $nextCommandCmd;
156 }
157
158 private function getNextCommandCmd()
159 {
161 }
162}
$_GET["client_id"]
This class provides processing control methods.
language handling
This class represents a password property in a property form.
This class represents a property form user interface.
special template class to simplify handling of ITX/PEAR
__construct(ilCtrl $ctrl, ilTemplate $tpl, ilLanguage $lng, ilTestPlayerAbstractGUI $parentGUI, ilTestPasswordChecker $passwordChecker)
Output class for assessment test execution.
$_POST['username']
Definition: cron.php:12
$cmd
Definition: sahs_server.php:35