ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilTestPasswordChecker.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
12{
16 protected $rbacsystem;
17
21 protected $user;
22
26 protected $testOBJ;
27
29 {
30 $this->rbacsystem = $rbacsystem;
31 $this->user = $user;
32 $this->testOBJ = $testOBJ;
33
34 $this->initSession();
35 }
36
38 {
39 if( !$this->isTestPasswordEnabled() )
40 {
41 return false;
42 }
43
44 if( $this->isPrivilegedParticipant() )
45 {
46 return false;
47 }
48
49 if( $this->isUserEnteredPasswordCorrect() )
50 {
51 return false;
52 }
53
54 return true;
55 }
56
57 protected function isTestPasswordEnabled()
58 {
59 return strlen($this->testOBJ->getPassword());
60 }
61
62 protected function isPrivilegedParticipant()
63 {
64 return $this->rbacsystem->checkAccess('write', $this->testOBJ->getRefId());
65 }
66
68 {
69 return $this->getUserEnteredPassword() == $this->testOBJ->getPassword();
70 }
71
72 public function setUserEnteredPassword($enteredPassword)
73 {
74 $_SESSION[$this->buildSessionKey()] = $enteredPassword;
75 }
76
77 protected function getUserEnteredPassword()
78 {
79 return $_SESSION[$this->buildSessionKey()];
80 }
81
82 protected function initSession()
83 {
84 if( !isset($_SESSION[$this->buildSessionKey()]) )
85 {
86 $_SESSION[$this->buildSessionKey()] = null;
87 }
88 }
89
90 protected function buildSessionKey()
91 {
92 return 'tst_password_'.$this->testOBJ->getTestId();
93 }
94}
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
__construct(ilRbacSystem $rbacsystem, ilObjUser $user, ilObjTest $testOBJ)
setUserEnteredPassword($enteredPassword)
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']