Example #1
0
 /**
  * addMessage() - Add a message to flash message
  *
  * @param  string $message
  * @return IfwPsn_Vendor_Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
  */
 public function addMessage($message, $namespace = null)
 {
     if (!is_string($namespace) || $namespace == '') {
         $namespace = $this->getNamespace();
     }
     if (self::$_messageAdded === false) {
         self::$_session->setExpirationHops(1, null, true);
     }
     if (!is_array(self::$_session->{$namespace})) {
         self::$_session->{$namespace} = array();
     }
     self::$_session->{$namespace}[] = $message;
     self::$_messageAdded = true;
     return $this;
 }
Example #2
0
 /**
  * Ifw Hack for using Zend_Session in WordPress context if session is already started
  * @param $started
  */
 public static function setStarted($started)
 {
     if ($started === true) {
         self::$_sessionStarted = true;
         parent::$_readable = true;
         parent::$_writable = true;
     }
 }
Example #3
0
 /**
  * __construct() - Returns an instance object bound to a particular, isolated section
  * of the session, identified by $namespace name (defaulting to 'Default').
  * The optional argument $singleInstance will prevent construction of additional
  * instance objects acting as accessors to this $namespace.
  *
  * @param string $namespace       - programmatic name of the requested namespace
  * @param bool $singleInstance    - prevent creation of additional accessor instance objects for this namespace
  * @return void
  */
 public function __construct($namespace = 'Default', $singleInstance = false)
 {
     if ($namespace === '') {
         /**
          * @see IfwPsn_Vendor_Zend_Session_Exception
          */
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
         throw new IfwPsn_Vendor_Zend_Session_Exception('Session namespace must be a non-empty string.');
     }
     if ($namespace[0] == "_") {
         /**
          * @see IfwPsn_Vendor_Zend_Session_Exception
          */
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
         throw new IfwPsn_Vendor_Zend_Session_Exception('Session namespace must not start with an underscore.');
     }
     if (preg_match('#(^[0-9])#i', $namespace[0])) {
         /**
          * @see IfwPsn_Vendor_Zend_Session_Exception
          */
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
         throw new IfwPsn_Vendor_Zend_Session_Exception('Session namespace must not start with a number.');
     }
     if (isset(self::$_singleInstances[$namespace])) {
         /**
          * @see IfwPsn_Vendor_Zend_Session_Exception
          */
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
         throw new IfwPsn_Vendor_Zend_Session_Exception("A session namespace object already exists for this namespace ('{$namespace}'), and no additional accessors (session namespace objects) for this namespace are permitted.");
     }
     if ($singleInstance === true) {
         self::$_singleInstances[$namespace] = true;
     }
     $this->_namespace = $namespace;
     // Process metadata specific only to this namespace.
     IfwPsn_Vendor_Zend_Session::start(true);
     // attempt auto-start (throws exception if strict option set)
     if (self::$_readable === false) {
         /**
          * @see IfwPsn_Vendor_Zend_Session_Exception
          */
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
         throw new IfwPsn_Vendor_Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG);
     }
     if (!isset($_SESSION['__ZF'])) {
         return;
         // no further processing needed
     }
     // do not allow write access to namespaces, after stop() or writeClose()
     if (parent::$_writable === true) {
         if (isset($_SESSION['__ZF'][$namespace])) {
             // Expire Namespace by Namespace Hop (ENNH)
             if (isset($_SESSION['__ZF'][$namespace]['ENNH'])) {
                 $_SESSION['__ZF'][$namespace]['ENNH']--;
                 if ($_SESSION['__ZF'][$namespace]['ENNH'] === 0) {
                     if (isset($_SESSION[$namespace])) {
                         self::$_expiringData[$namespace] = $_SESSION[$namespace];
                         unset($_SESSION[$namespace]);
                     }
                     unset($_SESSION['__ZF'][$namespace]);
                 }
             }
             // Expire Namespace Variables by Namespace Hop (ENVNH)
             if (isset($_SESSION['__ZF'][$namespace]['ENVNH'])) {
                 foreach ($_SESSION['__ZF'][$namespace]['ENVNH'] as $variable => $hops) {
                     $_SESSION['__ZF'][$namespace]['ENVNH'][$variable]--;
                     if ($_SESSION['__ZF'][$namespace]['ENVNH'][$variable] === 0) {
                         if (isset($_SESSION[$namespace][$variable])) {
                             self::$_expiringData[$namespace][$variable] = $_SESSION[$namespace][$variable];
                             unset($_SESSION[$namespace][$variable]);
                         }
                         unset($_SESSION['__ZF'][$namespace]['ENVNH'][$variable]);
                     }
                 }
                 if (empty($_SESSION['__ZF'][$namespace]['ENVNH'])) {
                     unset($_SESSION['__ZF'][$namespace]['ENVNH']);
                 }
             }
         }
         if (empty($_SESSION['__ZF'][$namespace])) {
             unset($_SESSION['__ZF'][$namespace]);
         }
         if (empty($_SESSION['__ZF'])) {
             unset($_SESSION['__ZF']);
         }
     }
 }
Example #4
0
 /**
  * exit(): Perform exit for redirector
  *
  * @return void
  */
 public function redirectAndExit()
 {
     if ($this->getCloseSessionOnExit()) {
         // Close session, if started
         if (class_exists('IfwPsn_Vendor_Zend_Session', false) && IfwPsn_Vendor_Zend_Session::isStarted()) {
             IfwPsn_Vendor_Zend_Session::writeClose();
         } elseif (isset($_SESSION)) {
             session_write_close();
         }
     }
     $this->getResponse()->sendHeaders();
     exit;
 }
Example #5
0
 /**
  * Defined by IfwPsn_Vendor_Zend_Application_Resource_Resource
  *
  * @return void
  */
 public function init()
 {
     $options = array_change_key_case($this->getOptions(), CASE_LOWER);
     if (isset($options['savehandler'])) {
         unset($options['savehandler']);
     }
     if (count($options) > 0) {
         IfwPsn_Vendor_Zend_Session::setOptions($options);
     }
     if ($this->_hasSaveHandler()) {
         IfwPsn_Vendor_Zend_Session::setSaveHandler($this->getSaveHandler());
     }
 }
Example #6
0
 /**
  * Destructor
  *
  * @return void
  */
 public function __destruct()
 {
     IfwPsn_Vendor_Zend_Session::writeClose();
 }