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:  * Email to a Friend Block
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Sendfriend
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Sendfriend_Block_Send extends Mage_Core_Block_Template
 36: {
 37:     /**
 38:      * Retrieve username for form field
 39:      *
 40:      * @return string
 41:      */
 42:     public function getUserName()
 43:     {
 44:         $name = $this->getFormData()->getData('sender/name');
 45:         if (!empty($name)) {
 46:             return trim($name);
 47:         }
 48: 
 49:         /* @var $session Mage_Customer_Model_Session */
 50:         $session = Mage::getSingleton('customer/session');
 51: 
 52:         if ($session->isLoggedIn()) {
 53:             return $session->getCustomer()->getName();
 54:         }
 55: 
 56:         return '';
 57:     }
 58: 
 59:     /**
 60:      * Retrieve sender email address
 61:      *
 62:      * @return string
 63:      */
 64:     public function getEmail()
 65:     {
 66:         $email = $this->getFormData()->getData('sender/email');
 67:         if (!empty($email)) {
 68:             return trim($email);
 69:         }
 70: 
 71:         /* @var $session Mage_Customer_Model_Session */
 72:         $session = Mage::getSingleton('customer/session');
 73: 
 74:         if ($session->isLoggedIn()) {
 75:             return $session->getCustomer()->getEmail();
 76:         }
 77: 
 78:         return '';
 79:     }
 80: 
 81:     /**
 82:      * Retrieve Message text
 83:      *
 84:      * @return string
 85:      */
 86:     public function getMessage()
 87:     {
 88:         return $this->getFormData()->getData('sender/message');
 89:     }
 90: 
 91:     /**
 92:      * Retrieve Form data or empty Varien_Object
 93:      *
 94:      * @return Varien_Object
 95:      */
 96:     public function getFormData()
 97:     {
 98:         $data = $this->getData('form_data');
 99:         if (!$data instanceof Varien_Object) {
100:             $data = new Varien_Object();
101:             $this->setData('form_data', $data);
102:         }
103: 
104:         return $data;
105:     }
106: 
107:     /**
108:      * Set Form data array
109:      *
110:      * @param array $data
111:      * @return Mage_Sendfriend_Block_Send
112:      */
113:     public function setFormData($data)
114:     {
115:         if (is_array($data)) {
116:             $this->setData('form_data', new Varien_Object($data));
117:         }
118: 
119:         return $this;
120:     }
121: 
122:     /**
123:      * Retrieve Current Product Id
124:      *
125:      * @return int
126:      */
127:     public function getProductId()
128:     {
129:         return $this->getRequest()->getParam('id', null);
130:     }
131: 
132:     /**
133:      * Retrieve current category id for product
134:      *
135:      * @return int
136:      */
137:     public function getCategoryId()
138:     {
139:         return $this->getRequest()->getParam('cat_id', null);
140:     }
141: 
142:     /**
143:      * Retrieve Max Recipients
144:      *
145:      * @return int
146:      */
147:     public function getMaxRecipients()
148:     {
149:         return Mage::helper('sendfriend')->getMaxRecipients();
150:     }
151: 
152:     /**
153:      * Retrieve Send URL for Form Action
154:      *
155:      * @return string
156:      */
157:     public function getSendUrl()
158:     {
159:         return Mage::getUrl('*/*/sendmail', array(
160:             'id'     => $this->getProductId(),
161:             'cat_id' => $this->getCategoryId()
162:         ));
163:     }
164: 
165:     /**
166:      * Return send friend model
167:      *
168:      * @return Mage_Sendfriend_Model_Sendfriend
169:      */
170:     protected function _getSendfriendModel()
171:     {
172:         return Mage::registry('send_to_friend_model');
173:     }
174: 
175:     /**
176:      * Check if user is allowed to send
177:      *
178:      * @return boolean
179:      */
180:     public function canSend()
181:     {
182:         return !$this->_getSendfriendModel()->isExceedLimit();
183:     }
184: }
185: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0