File indexing completed on 2025-01-19 05:21:20

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_OpenId
0018  * @subpackage Zend_OpenId_Provider
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * @see Zend_OpenId_Provider_User
0026  */
0027 // require_once "Zend/OpenId/Provider/User.php";
0028 
0029 /**
0030  * @see Zend_Session_Namespace
0031  */
0032 // require_once "Zend/Session/Namespace.php";
0033 
0034 /**
0035  * Class to get/store information about logged in user in Web Browser using
0036  * PHP session
0037  *
0038  * @category   Zend
0039  * @package    Zend_OpenId
0040  * @subpackage Zend_OpenId_Provider
0041  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0042  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0043  */
0044 class Zend_OpenId_Provider_User_Session extends Zend_OpenId_Provider_User
0045 {
0046     /**
0047      * Reference to an implementation of Zend_Session_Namespace object
0048      *
0049      * @var Zend_Session_Namespace $_session
0050      */
0051     private $_session = null;
0052 
0053     /**
0054      * Creates Zend_OpenId_Provider_User_Session object with given session
0055      * namespace or creates new session namespace named "openid"
0056      *
0057      * @param Zend_Session_Namespace $session
0058      */
0059     public function __construct(Zend_Session_Namespace $session = null)
0060     {
0061         if ($session === null) {
0062             $this->_session = new Zend_Session_Namespace("openid");
0063         } else {
0064             $this->_session = $session;
0065         }
0066     }
0067 
0068     /**
0069      * Stores information about logged in user in session data
0070      *
0071      * @param string $id user identity URL
0072      * @return bool
0073      */
0074     public function setLoggedInUser($id)
0075     {
0076         $this->_session->logged_in = $id;
0077         return true;
0078     }
0079 
0080     /**
0081      * Returns identity URL of logged in user or false
0082      *
0083      * @return mixed
0084      */
0085     public function getLoggedInUser()
0086     {
0087         if (isset($this->_session->logged_in)) {
0088             return $this->_session->logged_in;
0089         }
0090         return false;
0091     }
0092 
0093     /**
0094      * Performs logout. Clears information about logged in user.
0095      *
0096      * @return bool
0097      */
0098     public function delLoggedInUser()
0099     {
0100         unset($this->_session->logged_in);
0101         return true;
0102     }
0103 
0104 }