From d74638e08943cdaeb354d3cbbccc9052c2993bbc Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 14 Oct 2024 06:07:16 +0200 Subject: [PATCH 1/8] removed files from app/code/core --- app/code/core/Mage/Sendfriend/Block/Send.php | 187 ------ app/code/core/Mage/Sendfriend/Helper/Data.php | 124 ---- .../Sendfriend/Model/Mysql4/Sendfriend.php | 25 - .../Model/Mysql4/Sendfriend/Collection.php | 25 - .../Mage/Sendfriend/Model/Mysql4/Setup.php | 25 - .../core/Mage/Sendfriend/Model/Observer.php | 34 - .../Sendfriend/Model/Resource/Sendfriend.php | 93 --- .../Model/Resource/Sendfriend/Collection.php | 32 - .../Mage/Sendfriend/Model/Resource/Setup.php | 24 - .../core/Mage/Sendfriend/Model/Sendfriend.php | 584 ------------------ .../controllers/ProductController.php | 193 ------ app/code/core/Mage/Sendfriend/etc/config.xml | 128 ---- app/code/core/Mage/Sendfriend/etc/system.xml | 92 --- .../sql/sendfriend_setup/install-1.6.0.0.php | 48 -- .../sendfriend_setup/mysql4-install-0.7.0.php | 32 - .../mysql4-upgrade-0.7.1-0.7.2.php | 25 - .../mysql4-upgrade-0.7.2-0.7.3.php | 47 -- .../mysql4-upgrade-0.7.3-0.7.4.php | 31 - .../mysql4-upgrade-1.5.9.9-1.6.0.0.php | 92 --- .../mysql4-upgrade-1.6.0.0-1.6.0.1.php | 34 - 20 files changed, 1875 deletions(-) delete mode 100644 app/code/core/Mage/Sendfriend/Block/Send.php delete mode 100644 app/code/core/Mage/Sendfriend/Helper/Data.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Mysql4/Sendfriend.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Mysql4/Sendfriend/Collection.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Mysql4/Setup.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Observer.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Resource/Setup.php delete mode 100644 app/code/core/Mage/Sendfriend/Model/Sendfriend.php delete mode 100644 app/code/core/Mage/Sendfriend/controllers/ProductController.php delete mode 100644 app/code/core/Mage/Sendfriend/etc/config.xml delete mode 100644 app/code/core/Mage/Sendfriend/etc/system.xml delete mode 100644 app/code/core/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php delete mode 100644 app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-install-0.7.0.php delete mode 100644 app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.1-0.7.2.php delete mode 100644 app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.2-0.7.3.php delete mode 100644 app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.3-0.7.4.php delete mode 100644 app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php delete mode 100644 app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php diff --git a/app/code/core/Mage/Sendfriend/Block/Send.php b/app/code/core/Mage/Sendfriend/Block/Send.php deleted file mode 100644 index 8f3ccdc0406..00000000000 --- a/app/code/core/Mage/Sendfriend/Block/Send.php +++ /dev/null @@ -1,187 +0,0 @@ -getFormData()->getData('sender/name'); - if (!empty($name)) { - return trim($name); - } - - /** @var Mage_Customer_Model_Session $session */ - $session = Mage::getSingleton('customer/session'); - - if ($session->isLoggedIn()) { - return $session->getCustomer()->getName(); - } - - return ''; - } - - /** - * Retrieve sender email address - * - * @return string - */ - public function getEmail() - { - $email = $this->getFormData()->getData('sender/email'); - if (!empty($email)) { - return trim($email); - } - - /** @var Mage_Customer_Model_Session $session */ - $session = Mage::getSingleton('customer/session'); - - if ($session->isLoggedIn()) { - return $session->getCustomer()->getEmail(); - } - - return ''; - } - - /** - * Retrieve Message text - * - * @return string - */ - public function getMessage() - { - return $this->getFormData()->getData('sender/message'); - } - - /** - * Retrieve Form data or empty Varien_Object - * - * @return Varien_Object - */ - public function getFormData() - { - $data = $this->getData('form_data'); - if (!$data instanceof Varien_Object) { - $formData = Mage::getSingleton('catalog/session')->getFormData(true); - $data = new Varien_Object(); - if ($formData) { - $data->addData($formData); - } - $this->setData('form_data', $data); - } - - return $data; - } - - /** - * Set Form data array - * - * @param array $data - * @return $this - */ - public function setFormData($data) - { - if (is_array($data)) { - $this->setData('form_data', new Varien_Object($data)); - } - - return $this; - } - - /** - * Retrieve Current Product Id - * - * @return int - */ - public function getProductId() - { - return $this->getRequest()->getParam('id', null); - } - - /** - * Retrieve current category id for product - * - * @return int - */ - public function getCategoryId() - { - return $this->getRequest()->getParam('cat_id', null); - } - - /** - * Retrieve Max Recipients - * - * @return int - */ - public function getMaxRecipients() - { - return Mage::helper('sendfriend')->getMaxRecipients(); - } - - /** - * Retrieve count of recipients - * - * @return int - */ - public function getRecipientsCount() - { - $recipientsEmail = $this->getFormData()->getData('recipients/email'); - return (is_array($recipientsEmail)) ? count($recipientsEmail) : 0; - } - - /** - * Retrieve Send URL for Form Action - * - * @return string - */ - public function getSendUrl() - { - return Mage::getUrl('*/*/sendmail', [ - 'id' => $this->getProductId(), - 'cat_id' => $this->getCategoryId(), - '_secure' => $this->_isSecure() - ]); - } - - /** - * Return send friend model - * - * @return Mage_Sendfriend_Model_Sendfriend - */ - protected function _getSendfriendModel() - { - return Mage::registry('send_to_friend_model'); - } - - /** - * Check if user is allowed to send - * - * @return bool - */ - public function canSend() - { - return !$this->_getSendfriendModel()->isExceedLimit(); - } -} diff --git a/app/code/core/Mage/Sendfriend/Helper/Data.php b/app/code/core/Mage/Sendfriend/Helper/Data.php deleted file mode 100644 index df5ae0fca4b..00000000000 --- a/app/code/core/Mage/Sendfriend/Helper/Data.php +++ /dev/null @@ -1,124 +0,0 @@ -register(); - return $this; - } -} diff --git a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php b/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php deleted file mode 100644 index 5c0e7834175..00000000000 --- a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend.php +++ /dev/null @@ -1,93 +0,0 @@ -_init('sendfriend/sendfriend', 'log_id'); - } - - /** - * Retrieve Sended Emails By Ip - * - * @param Mage_Sendfriend_Model_Sendfriend $object - * @param int $ip - * @param int $startTime - * @param int $websiteId - * @return int - */ - public function getSendCount($object, $ip, $startTime, $websiteId = null) - { - $adapter = $this->_getReadAdapter(); - $select = $adapter->select() - ->from($this->getMainTable(), ['count' => new Zend_Db_Expr('count(*)')]) - ->where('ip=:ip - AND time>=:time - AND website_id=:website_id'); - $bind = [ - 'ip' => $ip, - 'time' => $startTime, - 'website_id' => (int)$websiteId, - ]; - - $row = $adapter->fetchRow($select, $bind); - return $row['count']; - } - - /** - * Add sended email by ip item - * - * @param int $ip - * @param int $startTime - * @param int $websiteId - * @return $this - */ - public function addSendItem($ip, $startTime, $websiteId) - { - $this->_getWriteAdapter()->insert( - $this->getMainTable(), - [ - 'ip' => $ip, - 'time' => $startTime, - 'website_id' => $websiteId - ] - ); - return $this; - } - - /** - * Delete Old logs - * - * @param int $time - * @return $this - */ - public function deleteLogsBefore($time) - { - $cond = $this->_getWriteAdapter()->quoteInto('time_getWriteAdapter()->delete($this->getMainTable(), $cond); - - return $this; - } -} diff --git a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php b/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php deleted file mode 100644 index ab99d4a502c..00000000000 --- a/app/code/core/Mage/Sendfriend/Model/Resource/Sendfriend/Collection.php +++ /dev/null @@ -1,32 +0,0 @@ -_init('sendfriend/sendfriend'); - } -} diff --git a/app/code/core/Mage/Sendfriend/Model/Resource/Setup.php b/app/code/core/Mage/Sendfriend/Model/Resource/Setup.php deleted file mode 100644 index 385321ebf83..00000000000 --- a/app/code/core/Mage/Sendfriend/Model/Resource/Setup.php +++ /dev/null @@ -1,24 +0,0 @@ -_init('sendfriend/sendfriend'); - } - - /** - * Retrieve Data Helper - * - * @return Mage_Sendfriend_Helper_Data - */ - protected function _getHelper() - { - return Mage::helper('sendfriend'); - } - - /** - * Retrieve Option Array - * - * @deprecated It Is a not Source model - * @return array - */ - public function toOptionArray() - { - return []; - } - - /** - * @return $this - * @throws Mage_Core_Exception - * @throws Mage_Core_Model_Store_Exception - */ - public function send() - { - if ($this->isExceedLimit()) { - Mage::throwException(Mage::helper('sendfriend')->__('You have exceeded limit of %d sends in an hour', $this->getMaxSendsToFriend())); - } - - /** @var Mage_Core_Model_Translate $translate */ - $translate = Mage::getSingleton('core/translate'); - $translate->setTranslateInline(false); - - /** @var Mage_Core_Model_Email_Template $mailTemplate */ - $mailTemplate = Mage::getModel('core/email_template'); - - $message = nl2br(htmlspecialchars($this->getSender()->getMessage())); - $sender = [ - 'name' => $this->_getHelper()->escapeHtml($this->getSender()->getName()), - 'email' => $this->_getHelper()->escapeHtml($this->getSender()->getEmail()) - ]; - - $mailTemplate->setDesignConfig([ - 'area' => 'frontend', - 'store' => Mage::app()->getStore()->getId() - ]); - - foreach ($this->getRecipients()->getEmails() as $k => $email) { - $name = $this->getRecipients()->getNames($k); - $mailTemplate->sendTransactional( - $this->getTemplate(), - $sender, - $email, - $name, - [ - 'name' => $name, - 'email' => $email, - 'product_name' => $this->getProduct()->getName(), - 'product_url' => $this->getProduct()->getUrlInStore(), - 'message' => $message, - 'sender_name' => $sender['name'], - 'sender_email' => $sender['email'], - 'product_image' => Mage::helper('catalog/image')->init( - $this->getProduct(), - 'small_image' - )->resize(75), - ] - ); - } - - $translate->setTranslateInline(true); - $this->_incrementSentCount(); - - return $this; - } - - /** - * Validate Form data - * - * @return bool|array - */ - public function validate() - { - $errors = []; - - $name = $this->getSender()->getName(); - if (empty($name)) { - $errors[] = Mage::helper('sendfriend')->__('The sender name cannot be empty.'); - } - - $email = $this->getSender()->getEmail(); - if (empty($email) || !Zend_Validate::is($email, 'EmailAddress')) { - $errors[] = Mage::helper('sendfriend')->__('Invalid sender email.'); - } - - $message = $this->getSender()->getMessage(); - if (empty($message)) { - $errors[] = Mage::helper('sendfriend')->__('The message cannot be empty.'); - } - - if (!$this->getRecipients()->getEmails()) { - $errors[] = Mage::helper('sendfriend')->__('At least one recipient must be specified.'); - } - - // validate recipients email addresses - foreach ($this->getRecipients()->getEmails() as $email) { - if (!Zend_Validate::is($email, 'EmailAddress')) { - $errors[] = Mage::helper('sendfriend')->__('An invalid email address for recipient was entered.'); - break; - } - } - - $maxRecipients = $this->getMaxRecipients(); - if (count($this->getRecipients()->getEmails()) > $maxRecipients) { - $errors[] = Mage::helper('sendfriend')->__('No more than %d emails can be sent at a time.', $this->getMaxRecipients()); - } - - if (empty($errors)) { - return true; - } - - return $errors; - } - - /** - * Set cookie instance - * - * @param Mage_Core_Model_Cookie $cookie - * @return $this - */ - public function setCookie($cookie) - { - return $this->setData('_cookie', $cookie); - } - - /** - * Retrieve Cookie instance - * - * @throws Mage_Core_Exception - * @return Mage_Core_Model_Cookie - */ - public function getCookie() - { - $cookie = $this->_getData('_cookie'); - if (!$cookie instanceof Mage_Core_Model_Cookie) { - Mage::throwException(Mage::helper('sendfriend')->__('Please define a correct Cookie instance.')); - } - return $cookie; - } - - /** - * Set Visitor Remote Address - * - * @param string|false $ipAddr the IP address on Long Format - * @return $this - */ - public function setRemoteAddr($ipAddr) - { - $this->setData('_remote_addr', $ipAddr); - return $this; - } - - /** - * Retrieve Visitor Remote Address - * - * @return int - */ - public function getRemoteAddr() - { - return $this->_getData('_remote_addr'); - } - - /** - * Set Website Id - * - * @param int|string|null $id - website id - * @return $this - */ - public function setWebsiteId($id) - { - $this->setData('_website_id', $id); - return $this; - } - - /** - * Retrieve Website Id - * - * @return int - */ - public function getWebsiteId() - { - return $this->_getData('_website_id'); - } - - /** - * Set Recipients - * - * @param array $recipients - * @return $this - */ - public function setRecipients($recipients) - { - // validate array - if (!is_array($recipients) || !isset($recipients['email']) - || !isset($recipients['name']) || !is_array($recipients['email']) - || !is_array($recipients['name']) - ) { - return $this; - } - - $emails = []; - $names = []; - foreach ($recipients['email'] as $k => $email) { - if (!isset($emails[$email]) && isset($recipients['name'][$k])) { - $emails[$email] = true; - $names[] = $recipients['name'][$k]; - } - } - - if ($emails) { - $emails = array_keys($emails); - } - - return $this->setData('_recipients', new Varien_Object([ - 'emails' => $emails, - 'names' => $names - ])); - } - - /** - * Retrieve Recipients object - * - * @return Varien_Object - */ - public function getRecipients() - { - $recipients = $this->_getData('_recipients'); - if (!$recipients instanceof Varien_Object) { - $recipients = new Varien_Object([ - 'emails' => [], - 'names' => [] - ]); - $this->setData('_recipients', $recipients); - } - return $recipients; - } - - /** - * Set product instance - * - * @param Mage_Catalog_Model_Product $product - * @return $this - */ - public function setProduct($product) - { - return $this->setData('_product', $product); - } - - /** - * Retrieve Product instance - * - * @throws Mage_Core_Exception - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - $product = $this->_getData('_product'); - if (!$product instanceof Mage_Catalog_Model_Product) { - Mage::throwException(Mage::helper('sendfriend')->__('Please define a correct Product instance.')); - } - return $product; - } - - /** - * Set Sender Information array - * - * @param array $sender - * @return $this - */ - public function setSender($sender) - { - if (!is_array($sender)) { - Mage::helper('sendfriend')->__('Invalid Sender Information'); - } - - return $this->setData('_sender', new Varien_Object($sender)); - } - - /** - * Retrieve Sender Information Object - * - * @throws Mage_Core_Exception - * @return Varien_Object - */ - public function getSender() - { - $sender = $this->_getData('_sender'); - if (!$sender instanceof Varien_Object) { - Mage::throwException(Mage::helper('sendfriend')->__('Please define the correct Sender information.')); - } - return $sender; - } - - /** - * @deprecated after 1.3.2.4 - * For get count sent letters use Mage_Sendfriend_Model_Sendfriend::getSentCount - * or Mage_Sendfriend_Model_Sendfriend::isExceedLimit - * - * @param int $ip - * @param int $startTime - * @return int - */ - public function getSendCount($ip = null, $startTime = null) - { - if (is_null($ip)) { - $ip = $this->getRemoteAddr(); - } - if (is_null($startTime)) { - $startTime = time() - $this->_getHelper()->getPeriod(); - } - - return $this->_getResource()->getSendCount($this, $ip, $startTime); - } - - /** - * Get max allowed uses of "Send to Friend" function per hour - * - * @return int - */ - public function getMaxSendsToFriend() - { - return $this->_getHelper()->getMaxEmailPerPeriod(); - } - - /** - * Get current Email "Send to friend" template - * - * @return string - */ - public function getTemplate() - { - return $this->_getHelper()->getEmailTemplate(); - } - - /** - * Get max allowed recipients for "Send to a Friend" function - * - * @return int - */ - public function getMaxRecipients() - { - return $this->_getHelper()->getMaxRecipients(); - } - - /** - * Check if user is allowed to email product to a friend - * - * @return bool - */ - public function canEmailToFriend() - { - return $this->_getHelper()->isEnabled(); - } - - /** - * Check if user is exceed limit - * - * @return bool - */ - public function isExceedLimit() - { - return $this->getSentCount() >= $this->getMaxSendsToFriend(); - } - - /** - * Return count of sent in last period - * - * @param bool $useCache - flag, is allow to use value of attribute of model if it is processed last time - * @return int - */ - public function getSentCount($useCache = true) - { - if ($useCache && !is_null($this->_sentCount)) { - return $this->_sentCount; - } - - switch ($this->_getHelper()->getLimitBy()) { - case Mage_Sendfriend_Helper_Data::CHECK_COOKIE: - return $this->_sentCount = $this->_sentCountByCookies(false); - case Mage_Sendfriend_Helper_Data::CHECK_IP: - return $this->_sentCount = $this->_sentCountByIp(false); - default: - return 0; - } - } - - /** - * Increase count of sent - * - * @return int - */ - protected function _incrementSentCount() - { - switch ($this->_getHelper()->getLimitBy()) { - case Mage_Sendfriend_Helper_Data::CHECK_COOKIE: - return $this->_sentCount = $this->_sentCountByCookies(true); - case Mage_Sendfriend_Helper_Data::CHECK_IP: - return $this->_sentCount = $this->_sentCountByIp(true); - default: - return 0; - } - } - - /** - * Return count of sent in last period by cookie - * - * @param bool $increment - flag, increase count before return value - * @return int - */ - protected function _sentCountByCookies($increment = false) - { - $cookie = $this->_getHelper()->getCookieName(); - $time = time(); - $newTimes = []; - - $oldTimes = $this->_lastCookieValue[$cookie] ?? $this->getCookie()->get($cookie); - - if ($oldTimes) { - $oldTimes = explode(',', $oldTimes); - foreach ($oldTimes as $oldTime) { - $periodTime = $time - $this->_getHelper()->getPeriod(); - if (is_numeric($oldTime) && $oldTime >= $periodTime) { - $newTimes[] = $oldTime; - } - } - } - - if ($increment) { - $newTimes[] = $time; - $newValue = implode(',', $newTimes); - $this->getCookie()->set($cookie, $newValue); - $this->_lastCookieValue[$cookie] = $newValue; - } - - return count($newTimes); - } - /** - * Return count of sent in last period by IP address - * - * @param bool $increment - flag, increase count before return value - * @return int - */ - protected function _sentCountByIp($increment = false) - { - $time = time(); - $period = $this->_getHelper()->getPeriod(); - $websiteId = $this->getWebsiteId(); - - if ($increment) { - // delete expired logs - $this->_getResource()->deleteLogsBefore($time - $period); - // add new item - $this->_getResource()->addSendItem($this->getRemoteAddr(), $time, $websiteId); - } - - return $this->_getResource()->getSendCount($this, $this->getRemoteAddr(), time() - $period, $websiteId); - } - /** - * Register self in global register with name send_to_friend_model - * - * @return $this - */ - public function register() - { - if (!Mage::registry('send_to_friend_model')) { - Mage::register('send_to_friend_model', $this); - } - return $this; - } - - /** - * @deprecated after 1.3.2.4 - * use Mage_Sendfriend_Model_Sendfriend::_sentCountByCookies - * - * @return int - */ - protected function _amountByCookies() - { - return $this->_sentCountByCookies(true); - } - - /** - * @deprecated after 1.3.2.4 - * use Mage_Sendfriend_Model_Sendfriend::_sentCountByIp - * - * @return int - */ - protected function _amountByIp() - { - return $this->_sentCountByIp(true); - } -} diff --git a/app/code/core/Mage/Sendfriend/controllers/ProductController.php b/app/code/core/Mage/Sendfriend/controllers/ProductController.php deleted file mode 100644 index 09fb1248a52..00000000000 --- a/app/code/core/Mage/Sendfriend/controllers/ProductController.php +++ /dev/null @@ -1,193 +0,0 @@ -isEnabled()) { - $this->norouteAction(); - return $this; - } - - if (!$helper->isAllowForGuest() && !$session->authenticate($this)) { - $this->setFlag('', self::FLAG_NO_DISPATCH, true); - if ($this->getRequest()->getActionName() == 'sendemail') { - $session->setBeforeAuthUrl(Mage::getUrl('*/*/send', [ - '_current' => true - ])); - Mage::getSingleton('catalog/session') - ->setSendfriendFormData($this->getRequest()->getPost()); - } - } - - return $this; - } - - /** - * Initialize Product Instance - * - * @return Mage_Catalog_Model_Product|false - */ - protected function _initProduct() - { - $productId = (int)$this->getRequest()->getParam('id'); - if (!$productId) { - return false; - } - $product = Mage::getModel('catalog/product') - ->load($productId); - if (!$product->getId() || !$product->isVisibleInCatalog()) { - return false; - } - - Mage::register('product', $product); - return $product; - } - - /** - * Initialize send friend model - * - * @return Mage_Sendfriend_Model_Sendfriend - */ - protected function _initSendToFriendModel() - { - $model = Mage::getModel('sendfriend/sendfriend'); - $model->setRemoteAddr(Mage::helper('core/http')->getRemoteAddr(true)); - $model->setCookie(Mage::app()->getCookie()); - $model->setWebsiteId(Mage::app()->getStore()->getWebsiteId()); - - Mage::register('send_to_friend_model', $model); - - return $model; - } - - /** - * Show Send to a Friend Form - * - * @return void - */ - public function sendAction() - { - $product = $this->_initProduct(); - $model = $this->_initSendToFriendModel(); - - if (!$product) { - $this->_forward('noRoute'); - return; - } - - if ($model->getMaxSendsToFriend() && $model->isExceedLimit()) { - Mage::getSingleton('catalog/session')->addNotice( - $this->__('The messages cannot be sent more than %d times in an hour', $model->getMaxSendsToFriend()) - ); - } - - $this->loadLayout(); - $this->_initLayoutMessages('catalog/session'); - - Mage::dispatchEvent('sendfriend_product', ['product' => $product]); - $data = Mage::getSingleton('catalog/session')->getSendfriendFormData(); - if ($data) { - Mage::getSingleton('catalog/session')->setSendfriendFormData(true); - $block = $this->getLayout()->getBlock('sendfriend.send'); - if ($block) { - $block->setFormData($data); - } - } - - $this->renderLayout(); - } - - /** - * Send Email Post Action - * - * @return $this|void - */ - public function sendmailAction() - { - if (!$this->_validateFormKey()) { - return $this->_redirect('*/*/send', ['_current' => true]); - } - - $product = $this->_initProduct(); - $model = $this->_initSendToFriendModel(); - $data = $this->getRequest()->getPost(); - - if (!$product || !$data) { - $this->_forward('noRoute'); - return; - } - - $categoryId = $this->getRequest()->getParam('cat_id', null); - if ($categoryId) { - $category = Mage::getModel('catalog/category') - ->load($categoryId); - $product->setCategory($category); - Mage::register('current_category', $category); - } - - $model->setSender($this->getRequest()->getPost('sender')); - $model->setRecipients($this->getRequest()->getPost('recipients')); - $model->setProduct($product); - - try { - $validate = $model->validate(); - if ($validate === true) { - $model->send(); - Mage::getSingleton('catalog/session')->addSuccess($this->__('The link to a friend was sent.')); - $this->_redirectSuccess($product->getProductUrl()); - return; - } else { - if (is_array($validate)) { - foreach ($validate as $errorMessage) { - Mage::getSingleton('catalog/session')->addError($errorMessage); - } - } else { - Mage::getSingleton('catalog/session')->addError($this->__('There were some problems with the data.')); - } - } - } catch (Mage_Core_Exception $e) { - Mage::getSingleton('catalog/session')->addError($e->getMessage()); - } catch (Exception $e) { - Mage::getSingleton('catalog/session') - ->addException($e, $this->__('Some emails were not sent.')); - } - - // save form data - Mage::getSingleton('catalog/session')->setSendfriendFormData($data); - - $this->_redirectError(Mage::getUrl('*/*/send', ['_current' => true])); - } -} diff --git a/app/code/core/Mage/Sendfriend/etc/config.xml b/app/code/core/Mage/Sendfriend/etc/config.xml deleted file mode 100644 index 84e160884fc..00000000000 --- a/app/code/core/Mage/Sendfriend/etc/config.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - 1.6.0.1 - - - - - - Mage_Sendfriend_Model - sendfriend_resource - - - Mage_Sendfriend_Model_Resource - sendfriend_mysql4 - sendfriend_mysql4 - - - sendfriend_log
-
-
-
-
- - - - Mage_Sendfriend - Mage_Sendfriend_Model_Resource_Setup - - - - - - Mage_Sendfriend_Block - - - - - Mage_Sendfriend_Helper - - - -
- - - - - - Mage_Sendfriend.csv - - - - - - - - - - - sendfriend/observer - register - - - - - - - standard - - Mage_Sendfriend - sendfriend - - - - - - - sendfriend.xml - - - - - - - - Mage_Sendfriend.csv - - - - - - - - - 0 - - 0 - 5 - 5 - 0 - - - -
diff --git a/app/code/core/Mage/Sendfriend/etc/system.xml b/app/code/core/Mage/Sendfriend/etc/system.xml deleted file mode 100644 index dc748326d8d..00000000000 --- a/app/code/core/Mage/Sendfriend/etc/system.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - catalog - 120 - 1 - 1 - 1 - - - - 1 - 1 - 1 - 1 - - - - select - adminhtml/system_config_source_yesno - 1 - 1 - 1 - 1 - Warning! This functionality is vulnerable and can be abused to distribute spam.]]> - - - - - select - adminhtml/system_config_source_yesno - 3 - 1 - 1 - 1 - - - - 4 - 1 - 1 - 1 - validate-digits - - - - 5 - 1 - 1 - 1 - validate-digits - - - - select - adminhtml/system_config_source_checktype - 6 - 1 - 1 - 1 - - - - - - - diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php b/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php deleted file mode 100644 index b0a1847b9ad..00000000000 --- a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/install-1.6.0.0.php +++ /dev/null @@ -1,48 +0,0 @@ -startSetup(); - -$table = $installer->getConnection() - ->newTable($installer->getTable('sendfriend/sendfriend')) - ->addColumn('log_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Log ID') - ->addColumn('ip', Varien_Db_Ddl_Table::TYPE_BIGINT, '20', [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Customer IP address') - ->addColumn('time', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Log time') - ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Website ID') - ->addIndex($installer->getIdxName('sendfriend/sendfriend', 'ip'), 'ip') - ->addIndex($installer->getIdxName('sendfriend/sendfriend', 'time'), 'time') - ->setComment('Send to friend function log storage table'); -$installer->getConnection()->createTable($table); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-install-0.7.0.php deleted file mode 100644 index 39f18c81319..00000000000 --- a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-install-0.7.0.php +++ /dev/null @@ -1,32 +0,0 @@ -startSetup(); - -$installer->run(" --- DROP TABLE IF EXISTS {$this->getTable('sendfriend_log')}; -CREATE TABLE {$this->getTable('sendfriend_log')} ( - `log_id` int(11) NOT NULL auto_increment, - `ip` int(11) NOT NULL default '0', - `time` int(11) NOT NULL default '0', - PRIMARY KEY (`log_id`), - KEY `ip` (`ip`), - KEY `time` (`time`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Send to friend function log storage table'; -"); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.1-0.7.2.php b/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.1-0.7.2.php deleted file mode 100644 index 55b24088bb3..00000000000 --- a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.1-0.7.2.php +++ /dev/null @@ -1,25 +0,0 @@ -startSetup(); - -$installer->run(" -ALTER TABLE `{$this->getTable('sendfriend/sendfriend')}` - MODIFY COLUMN `ip` int (11) unsigned DEFAULT '0' NOT NULL; -"); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.2-0.7.3.php b/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.2-0.7.3.php deleted file mode 100644 index 530a12ba888..00000000000 --- a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.2-0.7.3.php +++ /dev/null @@ -1,47 +0,0 @@ -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', - ['ip'] -); -$installer->getConnection()->addKey( - $installer->getTable('sendfriend/sendfriend'), - 'IDX_LOG_TIME', - ['time'] -); -$installer->endSetup(); diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.3-0.7.4.php b/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.3-0.7.4.php deleted file mode 100644 index ec1db9189c2..00000000000 --- a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-0.7.3-0.7.4.php +++ /dev/null @@ -1,31 +0,0 @@ -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->endSetup(); diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php b/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php deleted file mode 100644 index 7fdecdaeef2..00000000000 --- a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +++ /dev/null @@ -1,92 +0,0 @@ -startSetup(); - -/** - * Drop indexes - */ -$installer->getConnection()->dropIndex( - $installer->getTable('sendfriend/sendfriend'), - 'IDX_REMOTE_ADDR' -); - -$installer->getConnection()->dropIndex( - $installer->getTable('sendfriend/sendfriend'), - 'IDX_LOG_TIME' -); - -/** - * Change columns - */ -$tables = [ - $installer->getTable('sendfriend/sendfriend') => [ - 'columns' => [ - 'log_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'comment' => 'Log ID' - ], - 'ip' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT, - 'length' => 20, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Customer IP address' - ], - 'time' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Log time' - ], - 'website_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Website ID' - ] - ], - 'comment' => 'Send to friend function log storage table', - 'engine' => 'InnoDB' - ] -]; - -$installer->getConnection()->modifyTables($tables); - -/** - * Add indexes - */ -$installer->getConnection()->addIndex( - $installer->getTable('sendfriend/sendfriend'), - $installer->getIdxName('sendfriend/sendfriend', ['ip']), - ['ip'] -); - -$installer->getConnection()->addIndex( - $installer->getTable('sendfriend/sendfriend'), - $installer->getIdxName('sendfriend/sendfriend', ['time']), - ['time'] -); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php b/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php deleted file mode 100644 index cfe4bbc13aa..00000000000 --- a/app/code/core/Mage/Sendfriend/sql/sendfriend_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php +++ /dev/null @@ -1,34 +0,0 @@ -startSetup(); - -$installer->getConnection()->changeColumn( - $installer->getTable('sendfriend/sendfriend'), - 'ip', - 'ip', - 'varbinary(16)' -); - -$installer->getConnection()->update( - $installer->getTable('sendfriend/sendfriend'), - [ - 'ip' => new Zend_Db_Expr('UNHEX(HEX(CAST(ip as UNSIGNED INT)))') - ] -); - -$installer->endSetup(); From 1e44bea517b5e69fb6ea22239e1560f354c81228 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 14 Oct 2024 06:08:23 +0200 Subject: [PATCH 2/8] removed files from app/locale --- app/locale/en_US/Mage_Sendfriend.csv | 38 ---------------------------- 1 file changed, 38 deletions(-) delete mode 100644 app/locale/en_US/Mage_Sendfriend.csv diff --git a/app/locale/en_US/Mage_Sendfriend.csv b/app/locale/en_US/Mage_Sendfriend.csv deleted file mode 100644 index a3ec96de500..00000000000 --- a/app/locale/en_US/Mage_Sendfriend.csv +++ /dev/null @@ -1,38 +0,0 @@ -"Add Recipient","Add Recipient" -"Allow for Guests","Allow for Guests" -"An invalid email address for recipient was entered.","An invalid email address for recipient was entered." -"At least one recipient must be specified.","At least one recipient must be specified." -"Back","Back" -"Catalog Product Email to a Friend","Catalog Product Email to a Friend" -"Email Address","Email Address" -"Email Address:","Email Address:" -"Email Templates","Email Templates" -"Email to a Friend","Email to a Friend" -"Email:","Email:" -"Enabled","Enabled" -"Invalid Sender Information","Invalid Sender Information" -"Invalid sender email.","Invalid sender email." -"Limit Sending By","Limit Sending By" -"Max Products Sent in 1 Hour","Max Products Sent in 1 Hour" -"Max Recipients","Max Recipients" -"Maximum %d email addresses allowed.","Maximum %d email addresses allowed." -"Message:","Message:" -"Name","Name" -"Name:","Name:" -"No more than %d emails can be sent at a time.","No more than %d emails can be sent at a time." -"Please define a correct Cookie instance.","Please define a correct Cookie instance." -"Please define a correct Product instance.","Please define a correct Product instance." -"Please define the correct Sender information.","Please define the correct Sender information." -"Recipient:","Recipient:" -"Remove Email","Remove Email" -"Select Email Template","Select Email Template" -"Send Email","Send Email" -"Send product to a friend","Send product to a friend" -"Sender:","Sender:" -"Some emails were not sent.","Some emails were not sent." -"The link to a friend was sent.","The link to a friend was sent." -"The message cannot be empty.","The message cannot be empty." -"The messages cannot be sent more than %d times in an hour","The messages cannot be sent more than %d times in an hour" -"The sender name cannot be empty.","The sender name cannot be empty." -"There were some problems with the data.","There were some problems with the data." -"You have exceeded limit of %d sends in an hour","You have exceeded limit of %d sends in an hour" From e032d9368ea5c454dc6132559df8ce18467005c5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 14 Oct 2024 06:08:55 +0200 Subject: [PATCH 3/8] removed files from app/etc/modules --- app/etc/modules/Mage_Sendfriend.xml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 app/etc/modules/Mage_Sendfriend.xml diff --git a/app/etc/modules/Mage_Sendfriend.xml b/app/etc/modules/Mage_Sendfriend.xml deleted file mode 100644 index 7f1f12bab74..00000000000 --- a/app/etc/modules/Mage_Sendfriend.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - true - core - - - - - - From 7475b2967d8c828f44af9ddf4f609dd9b3b3e1e0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 14 Oct 2024 06:13:55 +0200 Subject: [PATCH 4/8] removed files from app/design/frontend/base --- .../base/default/layout/sendfriend.xml | 31 ---- .../default/template/sendfriend/send.phtml | 132 ------------------ 2 files changed, 163 deletions(-) delete mode 100644 app/design/frontend/base/default/layout/sendfriend.xml delete mode 100644 app/design/frontend/base/default/template/sendfriend/send.phtml diff --git a/app/design/frontend/base/default/layout/sendfriend.xml b/app/design/frontend/base/default/layout/sendfriend.xml deleted file mode 100644 index 31b06679017..00000000000 --- a/app/design/frontend/base/default/layout/sendfriend.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/app/design/frontend/base/default/template/sendfriend/send.phtml b/app/design/frontend/base/default/template/sendfriend/send.phtml deleted file mode 100644 index a759107f19a..00000000000 --- a/app/design/frontend/base/default/template/sendfriend/send.phtml +++ /dev/null @@ -1,132 +0,0 @@ - - - -
- getMessagesBlock()->toHtml() ?> -
-

__('Email to a Friend') ?>

-
-
-
- getBlockHtml('formkey')?> -

__('Sender:') ?>

-
    -
  • -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
  • -
  • - -
    - -
    -
  • -
-
-
-

__('Recipient:') ?>

-
    -
  • -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
  • -
-
-
- - - - getMaxRecipients()): ?> -

- -

- -
-
- -
From f9b1fac3c5d81c960eac1fa734f73e698c9b2515 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 14 Oct 2024 06:15:53 +0200 Subject: [PATCH 5/8] removed files from app/design/frontend/rwd --- .../default/template/sendfriend/send.phtml | 198 ------------------ 1 file changed, 198 deletions(-) delete mode 100644 app/design/frontend/rwd/default/template/sendfriend/send.phtml diff --git a/app/design/frontend/rwd/default/template/sendfriend/send.phtml b/app/design/frontend/rwd/default/template/sendfriend/send.phtml deleted file mode 100644 index 461e9f6ea0f..00000000000 --- a/app/design/frontend/rwd/default/template/sendfriend/send.phtml +++ /dev/null @@ -1,198 +0,0 @@ - -getRecipientsCount(); ?> - - -
- getMessagesBlock()->toHtml() ?> -
-

__('Email to a Friend') ?>

-
-
-
- getBlockHtml('formkey')?> -

__('Sender:') ?>

-
    -
  • -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
  • -
  • - -
    - -
    -
  • -
-
-
-

__('Recipient:') ?>

-
    -
  • -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
  • - - - -
  • -

    - - __('Remove Email'); ?> - -

    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
  • - - - getChildHtml('sendfriend.send.form.additional.info'); ?> -
-
-
- - - - getMaxRecipients()): ?> -

- -

- -
-
- -
From 377e50a51b3e2325e9506b3fa2b816662d3c5e63 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 14 Oct 2024 06:48:43 +0200 Subject: [PATCH 6/8] Updated README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bee054d0ed0..a7f82e6fa3c 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,8 @@ Most important changes will be listed here, all other changes since `19.4.0` can - `Mage_Compiler` - `Mage_GoogleBase` - `Mage_PageCache` ([#2258](https://github.com/OpenMage/magento-lts/pull/2258)) - - `Mage_Poll` ([#3098](https://github.com/OpenMage/magento-lts/pull/3098)) + - `Mage_Poll` ([#3098](https://github.com/OpenMage/magento-lts/pull/3098)) + - `Mage_Sendfriend` ([#4274](https://github.com/OpenMage/magento-lts/pull/4274)) - `Mage_Xmlconnect` - `Phoenix_Moneybookers` @@ -217,6 +218,7 @@ _If you rely on those modules you can reinstall them with composer:_ - `Mage_Backup`: `composer require openmage/module-mage-backup` - `Mage_PageCache`: `composer require openmage/module-mage-pagecache` - `Mage_Poll`: `composer require openmage/module-mage-poll` +- `Mage_Sendfriend`: `composer require openmage/module-mage-sendfriend` - `Legacy frontend themes`: `composer require openmage/legacy-frontend-themes` ### Between OpenMage 19.x and 20.x From 08c60116f52e6e75d55f96f975e244c7bf0e095c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 14 Oct 2024 23:46:28 +0200 Subject: [PATCH 7/8] removed orphaned references --- .../Model/System/Config/Source/Checktype.php | 42 ------------------- .../core/Mage/Adminhtml/etc/adminhtml.xml | 4 -- app/code/core/Mage/Sendfriend/etc/system.xml | 0 3 files changed, 46 deletions(-) delete mode 100644 app/code/core/Mage/Adminhtml/Model/System/Config/Source/Checktype.php delete mode 100644 app/code/core/Mage/Sendfriend/etc/system.xml diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Checktype.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Checktype.php deleted file mode 100644 index f49a012dde8..00000000000 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Checktype.php +++ /dev/null @@ -1,42 +0,0 @@ - Mage_Sendfriend_Helper_Data::CHECK_IP, - 'label' => Mage::helper('adminhtml')->__('IP Address') - ], - [ - 'value' => Mage_Sendfriend_Helper_Data::CHECK_COOKIE, - 'label' => Mage::helper('adminhtml')->__('Cookie (unsafe)') - ], - ]; - } -} diff --git a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml b/app/code/core/Mage/Adminhtml/etc/adminhtml.xml index 759cdd93c41..ea3ddbf0f67 100644 --- a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml +++ b/app/code/core/Mage/Adminhtml/etc/adminhtml.xml @@ -197,10 +197,6 @@ Currency Setup 120 - - Email to a Friend - 140 - Admin 100 diff --git a/app/code/core/Mage/Sendfriend/etc/system.xml b/app/code/core/Mage/Sendfriend/etc/system.xml deleted file mode 100644 index e69de29bb2d..00000000000 From 9701de1ea114f37d3f3310dbcc036f783f1ebb4f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 15 Oct 2024 00:12:23 +0200 Subject: [PATCH 8/8] removed orphaned references --- .../Model/Resource/Eav/Mysql4/Sendfriend.php | 25 ------------------- .../Eav/Mysql4/Sendfriend/Collection.php | 25 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Sendfriend.php delete mode 100644 app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Sendfriend/Collection.php diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Sendfriend.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Sendfriend.php deleted file mode 100644 index 69cae45e20b..00000000000 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Sendfriend.php +++ /dev/null @@ -1,25 +0,0 @@ -