Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Persistent_Block_Form_Remember
  • Mage_Persistent_Block_Header_Additional
  • Mage_Persistent_Helper_Data
  • Mage_Persistent_Helper_Session
  • Mage_Persistent_IndexController
  • Mage_Persistent_Model_Observer
  • Mage_Persistent_Model_Observer_Session
  • Mage_Persistent_Model_Persistent_Config
  • Mage_Persistent_Model_Resource_Session
  • Mage_Persistent_Model_Session
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Persistent
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Persistent Session Resource Model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Persistent
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Persistent_Model_Resource_Session extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * Use is object new method for object saving
 39:      *
 40:      * @var boolean
 41:      */
 42:     protected $_useIsObjectNew = true;
 43: 
 44:     /**
 45:      * Initialize connection and define main table and primary key
 46:      */
 47:     protected function _construct()
 48:     {
 49:         $this->_init('persistent/session', 'persistent_id');
 50:     }
 51: 
 52:     /**
 53:      * Add expiration date filter to select
 54:      *
 55:      * @param string $field
 56:      * @param mixed $value
 57:      * @param Mage_Persistent_Model_Session $object
 58:      * @return Zend_Db_Select
 59:      */
 60:     protected function _getLoadSelect($field, $value, $object)
 61:     {
 62:         $select = parent::_getLoadSelect($field, $value, $object);
 63:         if (!$object->getLoadExpired()) {
 64:             $tableName = $this->getMainTable();
 65:             $select->join(array('customer' => $this->getTable('customer/entity')),
 66:                 'customer.entity_id = ' . $tableName . '.customer_id'
 67:             )->where($tableName . '.updated_at >= ?', $object->getExpiredBefore());
 68:         }
 69: 
 70:         return $select;
 71:     }
 72: 
 73:     /**
 74:      * Delete customer persistent session by customer id
 75:      *
 76:      * @param int $customerId
 77:      * @return Mage_Persistent_Model_Resource_Session
 78:      */
 79:     public function deleteByCustomerId($customerId)
 80:     {
 81:         $this->_getWriteAdapter()->delete($this->getMainTable(), array('customer_id = ?' => $customerId));
 82:         return $this;
 83:     }
 84: 
 85:     /**
 86:      * Check if such session key allowed (not exists)
 87:      *
 88:      * @param string $key
 89:      * @return bool
 90:      */
 91:     public function isKeyAllowed($key)
 92:     {
 93:         $sameSession = Mage::getModel('persistent/session')->setLoadExpired();
 94:         $sameSession->loadByCookieKey($key);
 95:         return !$sameSession->getId();
 96:     }
 97: 
 98:     /**
 99:      * Delete expired persistent sessions
100:      *
101:      * @param  $websiteId
102:      * @param  $expiredBefore
103:      * @return Mage_Persistent_Model_Resource_Session
104:      */
105:     public function deleteExpired($websiteId, $expiredBefore)
106:     {
107:         $this->_getWriteAdapter()->delete(
108:             $this->getMainTable(),
109:             array(
110:                 'website_id = ?' => $websiteId,
111:                 'updated_at < ?' => $expiredBefore,
112:             )
113:         );
114:         return $this;
115:     }
116: }
117: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0