|
1 <?php |
|
2 |
|
3 /** |
|
4 * Zend Framework |
|
5 * |
|
6 * LICENSE |
|
7 * |
|
8 * This source file is subject to the new BSD license that is bundled |
|
9 * with this package in the file LICENSE.txt. |
|
10 * It is also available through the world-wide-web at this URL: |
|
11 * http://framework.zend.com/license/new-bsd |
|
12 * If you did not receive a copy of the license and are unable to |
|
13 * obtain it through the world-wide-web, please send an email |
|
14 * to license@zend.com so we can send you a copy immediately. |
|
15 * |
|
16 * @category Zend |
|
17 * @package Zend_OpenId |
|
18 * @subpackage Zend_OpenId_Provider |
|
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
21 * @version $Id: Session.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
22 */ |
|
23 |
|
24 /** |
|
25 * @see Zend_OpenId_Provider_User |
|
26 */ |
|
27 require_once "Zend/OpenId/Provider/User.php"; |
|
28 |
|
29 /** |
|
30 * @see Zend_Session_Namespace |
|
31 */ |
|
32 require_once "Zend/Session/Namespace.php"; |
|
33 |
|
34 /** |
|
35 * Class to get/store information about logged in user in Web Browser using |
|
36 * PHP session |
|
37 * |
|
38 * @category Zend |
|
39 * @package Zend_OpenId |
|
40 * @subpackage Zend_OpenId_Provider |
|
41 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
42 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
43 */ |
|
44 class Zend_OpenId_Provider_User_Session extends Zend_OpenId_Provider_User |
|
45 { |
|
46 /** |
|
47 * Reference to an implementation of Zend_Session_Namespace object |
|
48 * |
|
49 * @var Zend_Session_Namespace $_session |
|
50 */ |
|
51 private $_session = null; |
|
52 |
|
53 /** |
|
54 * Creates Zend_OpenId_Provider_User_Session object with given session |
|
55 * namespace or creates new session namespace named "openid" |
|
56 * |
|
57 * @param Zend_Session_Namespace $session |
|
58 */ |
|
59 public function __construct(Zend_Session_Namespace $session = null) |
|
60 { |
|
61 if ($session === null) { |
|
62 $this->_session = new Zend_Session_Namespace("openid"); |
|
63 } else { |
|
64 $this->_session = $session; |
|
65 } |
|
66 } |
|
67 |
|
68 /** |
|
69 * Stores information about logged in user in session data |
|
70 * |
|
71 * @param string $id user identity URL |
|
72 * @return bool |
|
73 */ |
|
74 public function setLoggedInUser($id) |
|
75 { |
|
76 $this->_session->logged_in = $id; |
|
77 return true; |
|
78 } |
|
79 |
|
80 /** |
|
81 * Returns identity URL of logged in user or false |
|
82 * |
|
83 * @return mixed |
|
84 */ |
|
85 public function getLoggedInUser() |
|
86 { |
|
87 if (isset($this->_session->logged_in)) { |
|
88 return $this->_session->logged_in; |
|
89 } |
|
90 return false; |
|
91 } |
|
92 |
|
93 /** |
|
94 * Performs logout. Clears information about logged in user. |
|
95 * |
|
96 * @return bool |
|
97 */ |
|
98 public function delLoggedInUser() |
|
99 { |
|
100 unset($this->_session->logged_in); |
|
101 return true; |
|
102 } |
|
103 |
|
104 } |