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_Sendfriend_Block_Send
  • Mage_Sendfriend_Model_Mysql4_Sendfriend
  • Mage_Sendfriend_Model_Mysql4_Sendfriend_Collection
  • Mage_Sendfriend_Model_Mysql4_Setup
  • Mage_Sendfriend_Model_Observer
  • Mage_Sendfriend_Model_Resource_Sendfriend
  • Mage_Sendfriend_Model_Resource_Sendfriend_Collection
  • Mage_Sendfriend_Model_Resource_Setup
  • Mage_Sendfriend_Model_Sendfriend
  • 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_Sendfriend
 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:  * SendFriend Log Resource Model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Sendfriend
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Sendfriend_Model_Resource_Sendfriend extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * Initialize connection and table
 39:      *
 40:      */
 41:     protected function _construct()
 42:     {
 43:         $this->_init('sendfriend/sendfriend', 'log_id');
 44:     }
 45: 
 46:     /**
 47:      * Retrieve Sended Emails By Ip
 48:      *
 49:      * @param Mage_Sendfriend_Model_Sendfriend $object
 50:      * @param int $ip
 51:      * @param int $startTime
 52:      * @param int $websiteId
 53:      * @return int
 54:      */
 55:     public function getSendCount($object, $ip, $startTime, $websiteId = null)
 56:     {
 57:         $adapter = $this->_getReadAdapter();
 58:         $select = $adapter->select()
 59:             ->from($this->getMainTable(), array('count' => new Zend_Db_Expr('count(*)')))
 60:             ->where('ip=:ip
 61:                 AND  time>=:time
 62:                 AND  website_id=:website_id');
 63:         $bind = array(
 64:             'ip'      => $ip,
 65:             'time'    => $startTime,
 66:             'website_id' => (int)$websiteId,
 67:         );
 68: 
 69:         $row = $adapter->fetchRow($select, $bind);
 70:         return $row['count'];
 71:     }
 72: 
 73:     /**
 74:      * Add sended email by ip item
 75:      *
 76:      * @param int $ip
 77:      * @param int $startTime
 78:      * @param int $websiteId
 79:      * @return Mage_Sendfriend_Model_Resource_Sendfriend
 80:      */
 81:     public function addSendItem($ip, $startTime, $websiteId)
 82:     {
 83:         $this->_getWriteAdapter()->insert(
 84:             $this->getMainTable(),
 85:             array(
 86:                 'ip'         => $ip,
 87:                 'time'       => $startTime,
 88:                 'website_id' => $websiteId
 89:              )
 90:         );
 91:         return $this;
 92:     }
 93: 
 94:     /**
 95:      * Delete Old logs
 96:      *
 97:      * @param int $time
 98:      * @return Mage_Sendfriend_Model_Resource_Sendfriend
 99:      */
100:     public function deleteLogsBefore($time)
101:     {
102:         $cond = $this->_getWriteAdapter()->quoteInto('time<?', $time);
103:         $this->_getWriteAdapter()->delete($this->getMainTable(), $cond);
104: 
105:         return $this;
106:     }
107: }
108: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0