Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_Sendfriend - DOC block update #749

Merged
merged 3 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/code/core/Mage/Sendfriend/Block/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getUserName()
return trim($name);
}

/* @var $session Mage_Customer_Model_Session */
/* @var Mage_Customer_Model_Session $session */
$session = Mage::getSingleton('customer/session');

if ($session->isLoggedIn()) {
Expand All @@ -68,7 +68,7 @@ public function getEmail()
return trim($email);
}

/* @var $session Mage_Customer_Model_Session */
/* @var Mage_Customer_Model_Session $session */
$session = Mage::getSingleton('customer/session');

if ($session->isLoggedIn()) {
Expand Down
40 changes: 25 additions & 15 deletions app/code/core/Mage/Sendfriend/Model/Sendfriend.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
*
* @method Mage_Sendfriend_Model_Resource_Sendfriend _getResource()
* @method Mage_Sendfriend_Model_Resource_Sendfriend getResource()
* @method Mage_Sendfriend_Model_Resource_Sendfriend_Collection getCollection()
*
* @method int getIp()
* @method Mage_Sendfriend_Model_Sendfriend setIp(int $value)
* @method $this setIp(int $value)
* @method int getTime()
* @method Mage_Sendfriend_Model_Sendfriend setTime(int $value)
* @method $this setTime(int $value)
*
* @category Mage
* @package Mage_Sendfriend
Expand Down Expand Up @@ -78,7 +80,7 @@ class Mage_Sendfriend_Model_Sendfriend extends Mage_Core_Model_Abstract
/**
* Last values for Cookie
*
* @var string
* @var array
*/
protected $_lastCookieValue = array();

Expand Down Expand Up @@ -108,20 +110,26 @@ protected function _getHelper()
* @return array
*/
public function toOptionArray()
{ return array();
{
return array();
}

/**
* @return $this
* @throws Mage_Core_Exception
* @throws Mage_Core_Model_Store_Exception
*/
public function send()
{
if ($this->isExceedLimit()){
if ($this->isExceedLimit()) {
Mage::throwException(Mage::helper('sendfriend')->__('You have exceeded limit of %d sends in an hour', $this->getMaxSendsToFriend()));
}

/* @var $translate Mage_Core_Model_Translate */
/* @var Mage_Core_Model_Translate $translate */
$translate = Mage::getSingleton('core/translate');
$translate->setTranslateInline(false);

/* @var $mailTemplate Mage_Core_Model_Email_Template */
/* @var Mage_Core_Model_Email_Template $mailTemplate */
$mailTemplate = Mage::getModel('core/email_template');

$message = nl2br(htmlspecialchars($this->getSender()->getMessage()));
Expand Down Expand Up @@ -150,8 +158,10 @@ public function send()
'message' => $message,
'sender_name' => $sender['name'],
'sender_email' => $sender['email'],
'product_image' => Mage::helper('catalog/image')->init($this->getProduct(),
'small_image')->resize(75),
'product_image' => Mage::helper('catalog/image')->init(
$this->getProduct(),
'small_image'
)->resize(75),
)
);
}
Expand All @@ -177,7 +187,7 @@ public function validate()
}

$email = $this->getSender()->getEmail();
if (empty($email) OR !Zend_Validate::is($email, 'EmailAddress')) {
if (empty($email) or !Zend_Validate::is($email, 'EmailAddress')) {
sreichel marked this conversation as resolved.
Show resolved Hide resolved
$errors[] = Mage::helper('sendfriend')->__('Invalid sender email.');
}

Expand Down Expand Up @@ -213,7 +223,7 @@ public function validate()
/**
* Set cookie instance
*
* @param Mage_Core_Model_Cookie $product
* @param Mage_Core_Model_Cookie $cookie
* @return $this
*/
public function setCookie($cookie)
Expand Down Expand Up @@ -289,9 +299,9 @@ public function getWebsiteId()
public function setRecipients($recipients)
{
// validate array
if (!is_array($recipients) OR !isset($recipients['email'])
OR !isset($recipients['name']) OR !is_array($recipients['email'])
OR !is_array($recipients['name'])) {
if (!is_array($recipients) or !isset($recipients['email'])
or !isset($recipients['name']) or !is_array($recipients['email'])
or !is_array($recipients['name'])) {
return $this;
}

Expand Down Expand Up @@ -520,7 +530,7 @@ protected function _sentCountByCookies($increment = false)
$oldTimes = explode(',', $oldTimes);
foreach ($oldTimes as $oldTime) {
$periodTime = $time - $this->_getHelper()->getPeriod();
if (is_numeric($oldTime) AND $oldTime >= $periodTime) {
if (is_numeric($oldTime) and $oldTime >= $periodTime) {
$newTimes[] = $oldTime;
}
}
Expand Down
18 changes: 7 additions & 11 deletions app/code/core/Mage/Sendfriend/controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function preDispatch()
{
parent::preDispatch();

/* @var $helper Mage_Sendfriend_Helper_Data */
/* @var Mage_Sendfriend_Helper_Data $helper */
$helper = Mage::helper('sendfriend');
/* @var $session Mage_Customer_Model_Session */
/* @var Mage_Customer_Model_Session $session */
$session = Mage::getSingleton('customer/session');

if (!$helper->isEnabled()) {
Expand All @@ -70,7 +70,7 @@ public function preDispatch()
/**
* Initialize Product Instance
*
* @return Mage_Catalog_Model_Product
* @return Mage_Catalog_Model_Product|false
*/
protected function _initProduct()
{
Expand Down Expand Up @@ -179,22 +179,18 @@ public function sendmailAction()
Mage::getSingleton('catalog/session')->addSuccess($this->__('The link to a friend was sent.'));
$this->_redirectSuccess($product->getProductUrl());
return;
}
else {
} else {
if (is_array($validate)) {
foreach ($validate as $errorMessage) {
Mage::getSingleton('catalog/session')->addError($errorMessage);
}
}
else {
} else {
Mage::getSingleton('catalog/session')->addError($this->__('There were some problems with the data.'));
}
}
}
catch (Mage_Core_Exception $e) {
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('catalog/session')->addError($e->getMessage());
}
catch (Exception $e) {
} catch (Exception $e) {
Mage::getSingleton('catalog/session')
->addException($e, $this->__('Some emails were not sent.'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

$installer = $this;
/* @var $installer Mage_Sendfriend_Model_Resource_Setup */
/* @var Mage_Sendfriend_Model_Resource_Setup $installer */

$installer->startSetup();

Expand All @@ -38,7 +38,7 @@
'primary' => true,
), 'Log ID')
->addColumn('ip', Varien_Db_Ddl_Table::TYPE_BIGINT, '20', array(
'unsigned' => true,
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Customer IP address')
Expand All @@ -48,7 +48,7 @@
'default' => '0',
), 'Log time')
->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
'unsigned' => true,
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Website ID')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

$installer = $this;
/* @var $installer Mage_Sendfriend_Model_Mysql4_Setup */
/* @var Mage_Sendfriend_Model_Mysql4_Setup $installer */

$installer->startSetup();

Expand All @@ -42,4 +42,3 @@
");

$installer->endSetup();

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

$installer = $this;
/* @var $installer Mage_Sendfriend_Model_Mysql4_Setup */
/* @var Mage_Sendfriend_Model_Mysql4_Setup $installer */

$installer->startSetup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,35 @@
*/


/* @var $installer Mage_Sendfriend_Model_Mysql4_Setup */
/* @var Mage_Sendfriend_Model_Mysql4_Setup $installer */
$installer = $this;

$installer->startSetup();
$installer->getConnection()->dropKey($installer->getTable('sendfriend/sendfriend'), 'ip');
$installer->getConnection()->dropKey($installer->getTable('sendfriend/sendfriend'), 'time');
$installer->getConnection()->modifyColumn($installer->getTable('sendfriend/sendfriend'),
'log_id', 'int(10) unsigned NOT NULL');
$installer->getConnection()->modifyColumn($installer->getTable('sendfriend/sendfriend'),
'ip', 'bigint(20) NOT NULL DEFAULT 0');
$installer->getConnection()->modifyColumn($installer->getTable('sendfriend/sendfriend'),
'time', 'int(10) unsigned NOT NULL');
$installer->getConnection()->addKey($installer->getTable('sendfriend/sendfriend'),
'IDX_REMOTE_ADDR', array('ip'));
$installer->getConnection()->addKey($installer->getTable('sendfriend/sendfriend'),
'IDX_LOG_TIME', array('time'));
$installer->getConnection()->modifyColumn(
$installer->getTable('sendfriend/sendfriend'),
'log_id',
'int(10) unsigned NOT NULL'
);
$installer->getConnection()->modifyColumn(
$installer->getTable('sendfriend/sendfriend'),
'ip',
'bigint(20) NOT NULL DEFAULT 0'
);
$installer->getConnection()->modifyColumn(
$installer->getTable('sendfriend/sendfriend'),
'time',
'int(10) unsigned NOT NULL'
);
$installer->getConnection()->addKey(
$installer->getTable('sendfriend/sendfriend'),
'IDX_REMOTE_ADDR',
array('ip')
);
$installer->getConnection()->addKey(
$installer->getTable('sendfriend/sendfriend'),
'IDX_LOG_TIME',
array('time')
);
$installer->endSetup();
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@
*/


/* @var $installer Mage_Sendfriend_Model_Mysql4_Setup */
/* @var Mage_Sendfriend_Model_Mysql4_Setup $installer */
$installer = $this;

$installer->startSetup();
$installer->getConnection()->modifyColumn($installer->getTable('sendfriend/sendfriend'),
'log_id', 'int(10) unsigned NOT NULL auto_increment');
$installer->getConnection()->addColumn($installer->getTable('sendfriend/sendfriend'),
'website_id', 'smallint(5) NOT NULL');
$installer->getConnection()->modifyColumn(
$installer->getTable('sendfriend/sendfriend'),
'log_id',
'int(10) unsigned NOT NULL auto_increment'
);
$installer->getConnection()->addColumn(
$installer->getTable('sendfriend/sendfriend'),
'website_id',
'smallint(5) NOT NULL'
);
$installer->endSetup();
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/* @var $installer Mage_Sendfriend_Model_Resource_Setup */
/* @var Mage_Sendfriend_Model_Resource_Setup $installer */
$installer = $this;
$installer->startSetup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/* @var $installer Mage_Sendfriend_Model_Resource_Setup */
/* @var Mage_Sendfriend_Model_Resource_Setup $installer */
$installer = $this;
$installer->startSetup();

Expand Down