Public Member Functions | |
toOptionArray () | |
send () | |
canSend () | |
setIp ($ip) | |
setRecipients ($recipients) | |
setProduct ($product) | |
setSender ($sender) | |
getSendCount ($ip, $startTime) | |
getMaxSendsToFriend () | |
getTemplate () | |
getMaxRecipients () | |
canEmailToFriend () | |
Protected Member Functions | |
_construct () | |
Protected Attributes | |
$_names = array() | |
$_emails = array() | |
$_sender = array() | |
$_ip = 0 | |
$_product = null | |
$_period = 3600 | |
$_cookieName = 'stf' |
Definition at line 27 of file Sendfriend.php.
_construct | ( | ) | [protected] |
Enter description here...
Reimplemented from Varien_Object.
Definition at line 39 of file Sendfriend.php.
00040 { 00041 $this->_init('catalog/sendfriend'); 00042 }
canEmailToFriend | ( | ) |
Check if user is allowed to email product to a friend
Definition at line 188 of file Sendfriend.php.
00189 { 00190 if (!Mage::getStoreConfig('sendfriend/email/enabled')) { 00191 return false; 00192 } 00193 if (!Mage::getStoreConfig('sendfriend/email/allow_guest') 00194 && !Mage::getSingleton('customer/session')->isLoggedIn()) { 00195 return false; 00196 } 00197 return true; 00198 }
canSend | ( | ) |
Definition at line 86 of file Sendfriend.php.
00087 { 00088 if (!$this->canEmailToFriend()) { 00089 Mage::throwException( 00090 Mage::helper('catalog')->__('You cannot email this product to a friend') 00091 ); 00092 } 00093 00094 if ($this->_getSendToFriendCheckType()) { 00095 $amount = $this->_amountByCookies(); 00096 } else { 00097 $amount = $this->_amountByIp(); 00098 } 00099 00100 if ($amount >= $this->getMaxSendsToFriend()){ 00101 Mage::throwException( 00102 Mage::helper('catalog')->__('You have exceeded limit of %d sends in an hour', $this->getMaxSendsToFriend()) 00103 ); 00104 } 00105 00106 $maxRecipients = $this->getMaxRecipients(); 00107 if (count($this->_emails) > $maxRecipients) { 00108 Mage::throwException( 00109 Mage::helper('catalog')->__('You cannot send more than %d emails at a time', $this->getMaxRecipients()) 00110 ); 00111 } 00112 00113 if (count($this->_emails) < 1) { 00114 Mage::throwException( 00115 Mage::helper('catalog')->__('You have to specify at least one recipient') 00116 ); 00117 } 00118 00119 if (!$this->getTemplate()){ 00120 Mage::throwException( 00121 Mage::helper('catalog')->__('Email template is not specified by administrator') 00122 ); 00123 } 00124 00125 return true; 00126 }
getMaxRecipients | ( | ) |
Get max allowed recipients for "Send to a Friend" function
Definition at line 178 of file Sendfriend.php.
00179 { 00180 return max(0, (int) Mage::getStoreConfig('sendfriend/email/max_recipients')); 00181 }
getMaxSendsToFriend | ( | ) |
Get max allowed uses of "Send to Friend" function per hour
Definition at line 158 of file Sendfriend.php.
00159 { 00160 return max(0, (int) Mage::getStoreConfig('sendfriend/email/max_per_hour')); 00161 }
getSendCount | ( | $ | ip, | |
$ | startTime | |||
) |
Definition at line 147 of file Sendfriend.php.
00148 { 00149 $count = $this->_getResource()->getSendCount($this, $ip, $startTime); 00150 return $count; 00151 }
getTemplate | ( | ) |
Get current "Send to friend" template
Definition at line 168 of file Sendfriend.php.
00169 { 00170 return Mage::getStoreConfig('sendfriend/email/template'); 00171 }
send | ( | ) |
Definition at line 57 of file Sendfriend.php.
00058 { 00059 $errors = array(); 00060 00061 $this->_emailModel = Mage::getModel('core/email_template'); 00062 00063 $this->_emailModel->load($this->getTemplate()); 00064 if (!$this->_emailModel->getId()) { 00065 Mage::throwException( 00066 Mage::helper('catalog')->__('Invalid transactional email code') 00067 ); 00068 } 00069 00070 $this->_emailModel->setSenderName(strip_tags($this->_sender['name'])); 00071 $this->_emailModel->setSenderEmail(strip_tags($this->_sender['email'])); 00072 00073 foreach ($this->_emails as $k=>$email) { 00074 if (!$this->_sendOne($email, $this->_names[$k])) { 00075 $errors[] = $email; 00076 } 00077 } 00078 00079 if (count($errors)) { 00080 Mage::throwException( 00081 Mage::helper('catalog')->__('Email to %s was not sent', implode(', ', $errors)) 00082 ); 00083 } 00084 }
setIp | ( | $ | ip | ) |
setProduct | ( | $ | product | ) |
setRecipients | ( | $ | recipients | ) |
Definition at line 133 of file Sendfriend.php.
00134 { 00135 $this->_emails = array_unique($recipients['email']); 00136 $this->_names = $recipients['name']; 00137 }
setSender | ( | $ | sender | ) |
toOptionArray | ( | ) |
Definition at line 44 of file Sendfriend.php.
00045 { 00046 if(!$collection = Mage::registry('config_system_email_template')) { 00047 $collection = Mage::getResourceModel('core/email_template_collection') 00048 ->load(); 00049 00050 Mage::register('config_system_email_template', $collection); 00051 } 00052 $options = $collection->toOptionArray(); 00053 array_unshift($options, array('value'=>'', 'label'=>'')); 00054 return $options; 00055 }
$_cookieName = 'stf' [protected] |
Definition at line 37 of file Sendfriend.php.
$_emails = array() [protected] |
Definition at line 30 of file Sendfriend.php.
$_ip = 0 [protected] |
Definition at line 32 of file Sendfriend.php.
$_names = array() [protected] |
Definition at line 29 of file Sendfriend.php.
$_period = 3600 [protected] |
Definition at line 35 of file Sendfriend.php.
$_product = null [protected] |
Definition at line 33 of file Sendfriend.php.
$_sender = array() [protected] |
Definition at line 31 of file Sendfriend.php.