From 0a542b38fe5256b725419d4659142632016ada0b Mon Sep 17 00:00:00 2001 From: Lee Saferite Date: Sun, 2 Aug 2009 20:54:41 -0400 Subject: [PATCH] Import Magento Release 1.3.2.2 --- app/Mage.php | 4 +- .../core/Mage/Admin/Model/Acl/Assert/Ip.php | 6 +- app/code/core/Mage/Admin/Model/User.php | 14 + .../core/Mage/Adminhtml/Block/Backup/Grid.php | 8 +- .../Block/Catalog/Category/Abstract.php | 18 + .../Block/Catalog/Category/Edit/Form.php | 18 - .../Adminhtml/Block/Catalog/Category/Tree.php | 13 - .../Product/Attribute/Edit/Tab/Main.php | 15 + .../Catalog/Product/Attribute/Set/Main.php | 6 + .../Product/Attribute/Set/Toolbar/Main.php | 6 + .../Product/Edit/Tab/Attributes/Create.php | 6 + .../Customer/Edit/Tab/View/Accordion.php | 172 ++--- .../Block/Customer/Edit/Tab/View/Cart.php | 2 + .../Block/Customer/Edit/Tab/View/Wishlist.php | 4 +- .../Block/Customer/Edit/Tab/Wishlist.php | 6 +- app/code/core/Mage/Adminhtml/Block/Denied.php | 37 + .../Block/Extensions/Custom/Edit/Tab/Grid.php | 46 +- .../Adminhtml/Block/Newsletter/Queue/Edit.php | 25 +- .../Template/Grid/Renderer/Action.php | 26 +- .../Adminhtml/Block/Notification/Window.php | 9 +- .../core/Mage/Adminhtml/Block/Report/Grid.php | 2 +- .../Block/Report/Product/Lowstock/Grid.php | 16 +- .../Adminhtml/Block/Sales/Items/Abstract.php | 41 +- .../Sales/Order/Creditmemo/Create/Items.php | 28 +- .../Sales/Order/Shipment/Create/Items.php | 26 - .../Order/View/Items/Renderer/Default.php | 3 + .../Block/Sales/Order/View/Tab/Info.php | 3 + .../Adminhtml/Block/System/Config/Form.php | 9 +- .../Block/System/Config/Form/Fieldset.php | 2 +- .../Block/System/Convert/Profile/Run.php | 3 +- .../core/Mage/Adminhtml/Block/Template.php | 11 + .../Block/Widget/Grid/Column/Filter/Price.php | 2 +- .../Grid/Column/Renderer/Ip.php} | 97 ++- .../Adminhtml/Model/Extension/Collection.php | 111 ++- .../Model/Extension/Collection/Abstract.php | 149 ---- .../Adminhtml/Model/Sales/Order/Create.php | 41 +- .../Mage/Adminhtml/Model/Session/Quote.php | 22 +- .../Catalog/Product/AttributeController.php | 4 + .../controllers/Catalog/ProductController.php | 4 + .../Newsletter/QueueController.php | 252 ++++--- .../Newsletter/TemplateController.php | 22 - .../controllers/Sales/OrderController.php | 2 +- .../controllers/Tax/RateController.php | 11 +- .../controllers/UrlrewriteController.php | 16 +- .../core/Mage/Api/Model/Acl/Assert/Ip.php | 2 +- app/code/core/Mage/Backup/Model/Backup.php | 4 +- .../core/Mage/Backup/Model/Fs/Collection.php | 205 +----- .../Mage/Bundle/Model/Mysql4/Price/Index.php | 15 +- .../Mage/Bundle/Model/Mysql4/Selection.php | 3 + .../Model/Sales/Order/Pdf/Items/Abstract.php | 52 +- .../Sales/Order/Pdf/Items/Creditmemo.php | 25 +- .../Model/Sales/Order/Pdf/Items/Invoice.php | 34 +- .../Model/Sales/Order/Pdf/Items/Shipment.php | 28 +- .../core/Mage/Catalog/Block/Layer/State.php | 2 +- .../Catalog/Block/Product/List/Toolbar.php | 46 +- app/code/core/Mage/Catalog/Model/Category.php | 11 + .../core/Mage/Catalog/Model/Category/Api.php | 37 +- .../Mage/Catalog/Model/Category/Api/V2.php | 29 +- .../Catalog/Model/Layer/Filter/Abstract.php | 10 + app/code/core/Mage/Catalog/Model/Product.php | 2 + .../Product/Attribute/Backend/Tierprice.php | 2 +- .../Model/Product/Attribute/Media/Api/V2.php | 6 +- .../core/Mage/Catalog/Model/Product/Image.php | 3 + .../Model/Product/Option/Type/Date.php | 2 +- .../Model/Resource/Eav/Mysql4/Category.php | 89 +++ .../Resource/Eav/Mysql4/Category/Flat.php | 63 +- .../Model/Resource/Eav/Mysql4/Product.php | 33 +- app/code/core/Mage/Catalog/etc/wsdl.xml | 1 + .../catalog_setup/mysql4-install-0.7.0.php | 2 - .../core/Mage/CatalogIndex/Model/Observer.php | 5 +- .../core/Mage/CatalogRule/Model/Observer.php | 6 +- .../core/Mage/CatalogSearch/Helper/Data.php | 2 + .../controllers/ResultController.php | 1 + app/code/core/Mage/Checkout/Model/Session.php | 4 +- .../controllers/OnepageController.php | 30 +- app/code/core/Mage/Compiler/Model/Process.php | 65 +- .../controllers/ProcessController.php | 2 +- .../Mage/Core/Controller/Front/Action.php | 2 +- .../Mage/Core/Controller/Request/Http.php | 101 ++- .../Mage/Core/Controller/Response/Http.php | 6 + .../Mage/Core/Controller/Varien/Action.php | 6 +- .../Mage/Core/Controller/Varien/Front.php | 36 +- app/code/core/Mage/Core/Helper/Data.php | 7 +- app/code/core/Mage/Core/Helper/Http.php | 198 ++++- app/code/core/Mage/Core/Helper/String.php | 11 + app/code/core/Mage/Core/Model/Abstract.php | 2 +- app/code/core/Mage/Core/Model/App.php | 51 +- .../Mage/Core/Model/Email/Template/Filter.php | 88 +++ .../Core/Model/Mysql4/Collection/Abstract.php | 12 + .../Core/Model/Session/Abstract/Varien.php | 4 +- app/code/core/Mage/Core/Model/Url.php | 8 +- app/code/core/Mage/Customer/Helper/Data.php | 27 +- app/code/core/Mage/Customer/Model/Address.php | 13 +- .../core/Mage/Customer/Model/Customer.php | 12 + .../Mage/Customer/Model/Entity/Address.php | 15 + .../Mage/Customer/Model/Entity/Customer.php | 22 + .../controllers/AccountController.php | 42 ++ app/code/core/Mage/Customer/etc/config.xml | 5 +- app/code/core/Mage/Customer/etc/system.xml | 21 +- .../mysql4-upgrade-0.8.10-0.8.11.php | 35 + .../core/Mage/Directory/Model/Currency.php | 25 +- .../Mage/Directory/Model/Mysql4/Currency.php | 38 +- app/code/core/Mage/Directory/etc/config.xml | 2 +- .../mysql4-upgrade-0.8.4-0.8.5.php | 39 + .../core/Mage/Downloadable/Model/Observer.php | 2 +- .../Model/Sales/Order/Pdf/Items/Abstract.php | 11 +- .../Sales/Order/Pdf/Items/Creditmemo.php | 169 +++-- .../Model/Sales/Order/Pdf/Items/Invoice.php | 134 ++-- .../core/Mage/Downloadable/etc/config.xml | 2 +- .../core/Mage/Eav/Model/Entity/Abstract.php | 19 +- .../Entity/Attribute/Backend/Abstract.php | 5 +- .../Mage/Eav/Model/Entity/Attribute/Set.php | 10 +- app/code/core/Mage/Eav/Model/Entity/Setup.php | 1 + app/code/core/Mage/Eav/Model/Entity/Type.php | 6 + .../Mage/Eav/Model/Mysql4/Entity/Store.php | 7 +- .../Mage/GiftMessage/Block/Message/Inline.php | 3 + .../GoogleBase/Block/Adminhtml/Types/Grid.php | 2 - .../core/Mage/GoogleBase/Model/Config.php | 11 + .../core/Mage/GoogleBase/Model/Service.php | 7 +- .../Mage/GoogleBase/Model/Service/Item.php | 17 +- .../Model/Source/Accounttype.php} | 33 +- .../controllers/ItemsController.php | 21 +- app/code/core/Mage/GoogleBase/etc/config.xml | 1 + app/code/core/Mage/GoogleBase/etc/system.xml | 11 +- .../core/Mage/Log/Model/Mysql4/Visitor.php | 26 +- .../Mysql4/Visitor/Online/Collection.php | 34 + app/code/core/Mage/Log/Model/Visitor.php | 24 +- app/code/core/Mage/Page/Model/Config.php | 240 +++--- .../core/Mage/Paygate/Model/Authorizenet.php | 3 +- app/code/core/Mage/Paypal/Model/Standard.php | 7 +- .../Paypal/controllers/ExpressController.php | 8 + app/code/core/Mage/PaypalUk/Model/Express.php | 3 +- .../controllers/ExpressController.php | 9 + app/code/core/Mage/PaypalUk/etc/config.xml | 4 +- app/code/core/Mage/Poll/Model/Poll.php | 4 +- .../Mage/Poll/controllers/VoteController.php | 2 +- .../ProductAlert/Block/Email/Abstract.php | 2 +- .../core/Mage/ProductAlert/Model/Email.php | 29 +- .../core/Mage/Rating/Model/Mysql4/Rating.php | 95 ++- .../Rating/Model/Mysql4/Rating/Option.php | 4 +- .../Mysql4/Product/Lowstock/Collection.php | 174 +++++ app/code/core/Mage/Reports/Model/Totals.php | 24 +- .../Review/Model/Mysql4/Review/Summary.php | 31 + app/code/core/Mage/Rule/Model/Rule.php | 4 +- .../Sales/Model/Mysql4/Sale/Collection.php | 8 + app/code/core/Mage/Sales/Model/Order/Api.php | 2 +- .../Mage/Sales/Model/Order/Pdf/Abstract.php | 2 +- .../Mage/Sales/Model/Order/Pdf/Invoice.php | 6 +- .../Sales/Model/Order/Pdf/Items/Abstract.php | 5 + .../Order/Pdf/Items/Creditmemo/Default.php | 102 +-- .../Model/Order/Pdf/Items/Invoice/Default.php | 48 +- .../Order/Pdf/Items/Shipment/Default.php | 24 +- .../core/Mage/Sales/Model/Order/Shipment.php | 1 + .../Model/Quote/Address/Total/Discount.php | 5 - app/code/core/Mage/Sales/Model/Quote/Item.php | 4 + .../Mage/Sales/Model/Quote/Item/Abstract.php | 20 + .../core/Mage/Sales/Model/Quote/Payment.php | 2 +- app/code/core/Mage/SalesRule/Model/Rule.php | 4 +- app/code/core/Mage/Sendfriend/etc/config.xml | 4 +- .../Mage/Shipping/Model/Carrier/Flatrate.php | 217 +++--- .../Sitemap/Model/Mysql4/Catalog/Category.php | 17 +- .../Sitemap/Model/Mysql4/Catalog/Product.php | 17 +- app/code/core/Mage/Sitemap/Model/Sitemap.php | 10 + .../core/Mage/Tag/Block/Product/Result.php | 3 +- .../Mage/Tag/Model/Mysql4/Tag/Relation.php | 45 +- app/code/core/Mage/Tag/Model/Tag/Relation.php | 41 +- .../Tag/controllers/CustomerController.php | 39 +- .../core/Mage/Tax/Model/Calculation/Rate.php | 13 + app/code/core/Mage/Tax/Model/Mysql4/Setup.php | 87 ++- .../tax_setup/mysql4-upgrade-0.7.6-0.7.7.php | 17 +- .../Mage/Usa/Model/Shipping/Carrier/Usps.php | 13 +- .../core/Mage/Wishlist/Model/Observer.php | 4 +- .../core/Mage/Wishlist/Model/Wishlist.php | 15 +- app/code/core/Mage/Wishlist/etc/system.xml | 2 +- .../default/default/layout/customer.xml | 4 +- .../adminhtml/default/default/layout/main.xml | 4 +- .../default/template/access_denied.phtml | 40 + .../creditmemo/create/items/renderer.phtml | 4 +- .../template/catalog/category/edit.phtml | 6 + .../template/catalog/category/edit/form.phtml | 13 +- .../catalog/product/attribute/set/main.phtml | 19 +- .../default/template/dashboard/index.phtml | 25 +- .../create/items/renderer/downloadable.phtml | 10 +- .../create/items/renderer/configurable.phtml | 10 +- .../create/items/renderer/default.phtml | 10 +- .../template/checkout/cart/shipping.phtml | 13 - .../default/template/email/order/items.phtml | 4 +- app/etc/local.xml.additional | 6 +- app/etc/local.xml.template | 6 +- app/etc/modules/Mage_All.xml | 30 +- app/locale/en_US/Mage_Adminhtml.csv | 58 +- app/locale/en_US/Mage_Api.csv | 19 +- app/locale/en_US/Mage_Backup.csv | 1 - app/locale/en_US/Mage_Catalog.csv | 24 +- app/locale/en_US/Mage_CatalogRule.csv | 2 +- app/locale/en_US/Mage_Checkout.csv | 1 - app/locale/en_US/Mage_Cms.csv | 3 + app/locale/en_US/Mage_Compiler.csv | 21 + app/locale/en_US/Mage_Core.csv | 15 +- app/locale/en_US/Mage_Customer.csv | 10 +- app/locale/en_US/Mage_GoogleBase.csv | 6 +- app/locale/en_US/Mage_Install.csv | 2 + app/locale/en_US/Mage_Newsletter.csv | 4 +- app/locale/en_US/Mage_Page.csv | 7 + app/locale/en_US/Mage_Paypal.csv | 8 +- app/locale/en_US/Mage_ProductAlert.csv | 1 + app/locale/en_US/Mage_Reports.csv | 5 +- app/locale/en_US/Mage_Sales.csv | 17 +- app/locale/en_US/Mage_SalesRule.csv | 2 +- app/locale/en_US/Mage_Sendfriend.csv | 1 + app/locale/en_US/Mage_Shipping.csv | 2 + app/locale/en_US/Mage_Tax.csv | 13 +- app/locale/en_US/Mage_Wishlist.csv | 2 + js/mage/adminhtml/rules.js | 2 +- js/mage/adminhtml/tools.js | 19 +- lib/Varien/Autoload.php | 2 +- lib/Varien/Data/Collection.php | 2 +- lib/Varien/Data/Collection/Db.php | 3 + lib/Varien/Data/Collection/Filesystem.php | 697 ++++++++++++++++++ lib/Varien/Data/Form/Element/Fieldset.php | 61 +- lib/Zend/Gdata/App.php | 2 +- skin/frontend/default/blue/js/opcheckout.js | 10 + .../frontend/default/default/js/opcheckout.js | 10 + 223 files changed, 4340 insertions(+), 1839 deletions(-) create mode 100644 app/code/core/Mage/Adminhtml/Block/Denied.php rename app/code/core/Mage/Adminhtml/Block/{Backup/Grid/Renderer/Type.php => Widget/Grid/Column/Renderer/Ip.php} (64%) delete mode 100644 app/code/core/Mage/Adminhtml/Model/Extension/Collection/Abstract.php create mode 100644 app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-0.8.10-0.8.11.php create mode 100644 app/code/core/Mage/Directory/sql/directory_setup/mysql4-upgrade-0.8.4-0.8.5.php rename app/code/core/Mage/{Adminhtml/Block/Backup/Grid/Filter/Type.php => GoogleBase/Model/Source/Accounttype.php} (57%) create mode 100644 app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php create mode 100644 app/design/adminhtml/default/default/template/access_denied.phtml create mode 100644 app/locale/en_US/Mage_Compiler.csv create mode 100644 lib/Varien/Data/Collection/Filesystem.php diff --git a/app/Mage.php b/app/Mage.php index 2baae144be..a60392aaf8 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -84,7 +84,7 @@ final class Mage { public static function getVersion() { - return '1.3.2.1'; + return '1.3.2.2'; } /** @@ -596,7 +596,7 @@ public static function logException(Exception $e) return; } $file = Mage::getStoreConfig('dev/log/exception_file'); - self::log("\n".$e->getTraceAsString(), Zend_Log::ERR, $file); + self::log("\n".(string)$e, Zend_Log::ERR, $file); } /** diff --git a/app/code/core/Mage/Admin/Model/Acl/Assert/Ip.php b/app/code/core/Mage/Admin/Model/Acl/Assert/Ip.php index 8692684196..a4fdd5b623 100644 --- a/app/code/core/Mage/Admin/Model/Acl/Assert/Ip.php +++ b/app/code/core/Mage/Admin/Model/Acl/Assert/Ip.php @@ -27,12 +27,12 @@ /** * IP assertion for admin acl - * + * * @category Mage * @package Mage_Admin * @author Magento Core Team */ -class Mage_Admin_Model_Acl_Assert_Ip implements Zend_Acl_Assert_Interface +class Mage_Admin_Model_Acl_Assert_Ip implements Zend_Acl_Assert_Interface { /** * Check whether ip is allowed @@ -46,7 +46,7 @@ class Mage_Admin_Model_Acl_Assert_Ip implements Zend_Acl_Assert_Interface public function assert(Mage_Admin_Model_Acl $acl, Mage_Admin_Model_Acl_Role $role = null, Mage_Admin_Model_Acl_Resource $resource = null, $privilege = null) { - return $this->_isCleanIP($_SERVER['REMOTE_ADDR']); + return $this->_isCleanIP(Mage::helper('core/http')->getRemoteAddr()); } protected function _isCleanIP($ip) diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php index a0b6e712bf..1c7d85ae06 100644 --- a/app/code/core/Mage/Admin/Model/User.php +++ b/app/code/core/Mage/Admin/Model/User.php @@ -44,6 +44,8 @@ class Mage_Admin_Model_User extends Mage_Core_Model_Abstract */ protected $_role; + protected $_hasAvailableResources = true; + /** * Varien constructor */ @@ -333,6 +335,18 @@ public function findFirstAvailableMenu($parent=null, $path='', $level=0) } } } + $this->_hasAvailableResources = false; + return '*/*/denied'; + } + + /** + * Check if user has available resources + * + * @return bool + */ + public function hasAvailableResources() + { + return $this->_hasAvailableResources; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php b/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php index a18c7214f6..a588c149cb 100644 --- a/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Backup/Grid.php @@ -60,8 +60,8 @@ protected function _prepareColumns() $this->addColumn('time', array( 'header' => Mage::helper('backup')->__('Time'), - 'index' => 'time_formated', - 'type' => 'datetime' + 'index' => 'date_object', + 'type' => 'datetime', )); $this->addColumn('size', array( @@ -74,8 +74,8 @@ protected function _prepareColumns() $this->addColumn('type', array( 'header' => Mage::helper('backup')->__('Type'), - 'filter' => 'adminhtml/backup_grid_filter_type', - 'renderer' => 'adminhtml/backup_grid_renderer_type', + 'type' => 'options', + 'options' => array('db' => Mage::helper('backup')->__('DB')), 'index' =>'type' )); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php index 47743cdb42..40e90c125f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Abstract.php @@ -181,4 +181,22 @@ public function getEditUrl() { return $this->getUrl("*/catalog_category/edit", array('_current'=>true, 'store'=>null, '_query'=>false, 'id'=>null, 'parent'=>null)); } + + /** + * Return ids of root categories as array + * + * @return array + */ + public function getRootIds() + { + $ids = $this->getData('root_ids'); + if (is_null($ids)) { + $ids = array(); + foreach (Mage::app()->getGroups() as $store) { + $ids[] = $store->getRootCategoryId(); + } + $this->setData('root_ids', $ids); + } + return $ids; + } } \ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php index d05621e789..008d765080 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php @@ -87,24 +87,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - /** - * Return array of root categories ids - * - * @return array - */ - public function getRootIds() - { - $ids = $this->getData('root_ids'); - if (is_null($ids)) { - $ids = array(); - foreach (Mage::app()->getStores() as $store) { - $ids[] = $store->getRootCategoryId(); - } - $this->setData('root_ids', $ids); - } - return $ids; - } - public function getStoreConfigurationUrl() { $storeId = (int) $this->getRequest()->getParam('store'); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php index 5a86d84027..24d482278f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php @@ -178,19 +178,6 @@ public function getTreeJson($parenNodeCategory=null) return $json; } - public function getRootIds() - { - $ids = $this->getData('root_ids'); - if (is_null($ids)) { - $ids = array(); - foreach (Mage::app()->getStores() as $store) { - $ids[] = $store->getRootCategoryId(); - } - $this->setData('root_ids', $ids); - } - return $ids; - } - /** * Get JSON of array of categories, that are breadcrumbs for specified category path * diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php index 2e780f4e62..06ea1114b2 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php @@ -53,6 +53,15 @@ protected function _prepareForm() 'url_key' => array( 'is_unique', ), + 'status' => array( + 'is_configurable' + ) + ); + + $rewriteAttributeValue = array( + 'status' => array( + 'is_configurable' => 0 + ) ); $fieldset = $form->addFieldset('base_fieldset', @@ -385,6 +394,12 @@ protected function _prepareForm() $form->addValues($model->getData()); + if ($model->getId() && isset($rewriteAttributeValue[$model->getAttributeCode()])) { + foreach ($rewriteAttributeValue[$model->getAttributeCode()] as $field => $value) { + $form->getElement($field)->setValue($value); + } + } + $form->getElement('apply_to')->setSize(5); if ($applyTo = $model->getApplyTo()) { diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php index 948ec0bd23..a754e0a7e9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php @@ -292,4 +292,10 @@ protected function _getSetData() { return Mage::getModel('eav/entity_attribute_set')->load( $this->_getSetId() ); } + + protected function _toHtml() + { + Mage::dispatchEvent('adminhtml_catalog_product_attribute_set_main_html_before', array('block' => $this)); + return parent::_toHtml(); + } } \ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php index 1fb503d4ec..d922fc6799 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php @@ -62,4 +62,10 @@ protected function _getHeader() { return Mage::helper('catalog')->__('Manage Attribute Sets'); } + + protected function _toHtml() + { + Mage::dispatchEvent('adminhtml_catalog_product_attribute_set_toolbar_main_html_before', array('block' => $this)); + return parent::_toHtml(); + } } \ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php index eb3c27244c..bb71e28d03 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php @@ -81,6 +81,12 @@ protected function _beforeToHtml() protected function _toHtml() { + $this->setCanShow(true); + Mage::dispatchEvent('adminhtml_catalog_product_edit_tab_attributes_create_html_before', array('block' => $this)); + if (!$this->getCanShow()) { + return ''; + } + $html = parent::_toHtml(); $html .= Mage::helper('adminhtml/js')->getScript( "var {$this->getJsObjectName()} = new Product.Attributes('{$this->getId()}');\n" diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php index 9767f599d3..ee6fd3de77 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Accordion.php @@ -1,84 +1,88 @@ - - */ -class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion extends Mage_Adminhtml_Block_Widget_Accordion -{ - protected function _prepareLayout() - { - $customer = Mage::registry('current_customer'); - - $this->setId('customerViewAccordion'); - - $this->addItem('lastOrders', array( - 'title' => Mage::helper('customer')->__('Recent Orders'), - 'ajax' => true, - 'content_url' => $this->getUrl('*/*/lastOrders', array('_current' => true)), - )); - - // add shopping cart block of each website - foreach (Mage::registry('current_customer')->getSharedWebsiteIds() as $websiteId) { - $website = Mage::app()->getWebsite($websiteId); - - // count cart items - $cartItemsCount = Mage::getModel('sales/quote') - ->setWebsite($website)->loadByCustomer($customer) - ->getItemsCollection(false)->getSize(); - // prepare title for cart - $title = Mage::helper('customer')->__('Shopping Cart - %d item(s)', $cartItemsCount); - if (count($customer->getSharedWebsiteIds()) > 1) { - $title = Mage::helper('customer')->__('Shopping Cart of %1$s - %2$d item(s)', - $website->getName(), $cartItemsCount - ); - } - - // add cart ajax accordion - $this->addItem('shopingCart' . $websiteId, array( - 'title' => $title, - 'ajax' => true, - 'content_url' => $this->getUrl('*/*/viewCart', array('_current' => true, 'website_id' => $websiteId)), - )); - } - - // count wishlist items - $wishlistCount = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer) - ->getProductCollection() - ->addStoreData() - ->getSize(); - // add wishlist ajax accordion - $this->addItem('wishlist', array( - 'title' => Mage::helper('customer')->__('Wishlist - %d item(s)', $wishlistCount), - 'ajax' => true, - 'content_url' => $this->getUrl('*/*/viewWishlist', array('_current' => true)), - )); - } -} + + */ +class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Accordion extends Mage_Adminhtml_Block_Widget_Accordion +{ + protected function _prepareLayout() + { + $customer = Mage::registry('current_customer'); + + $this->setId('customerViewAccordion'); + + $this->addItem('lastOrders', array( + 'title' => Mage::helper('customer')->__('Recent Orders'), + 'ajax' => true, + 'content_url' => $this->getUrl('*/*/lastOrders', array('_current' => true)), + )); + + // add shopping cart block of each website + foreach (Mage::registry('current_customer')->getSharedWebsiteIds() as $websiteId) { + $website = Mage::app()->getWebsite($websiteId); + + // count cart items + $cartItemsCount = Mage::getModel('sales/quote') + ->setWebsite($website)->loadByCustomer($customer) + ->getItemsCollection(false) + ->addFieldToFilter('parent_item_id', array('null' => true)) + ->getSize(); + // prepare title for cart + $title = Mage::helper('customer')->__('Shopping Cart - %d item(s)', $cartItemsCount); + if (count($customer->getSharedWebsiteIds()) > 1) { + $title = Mage::helper('customer')->__('Shopping Cart of %1$s - %2$d item(s)', + $website->getName(), $cartItemsCount + ); + } + + // add cart ajax accordion + $this->addItem('shopingCart' . $websiteId, array( + 'title' => $title, + 'ajax' => true, + 'content_url' => $this->getUrl('*/*/viewCart', array('_current' => true, 'website_id' => $websiteId)), + )); + } + + // count wishlist items + $wishlist = Mage::getModel('wishlist/wishlist'); + $wishlistCount = $wishlist->loadByCustomer($customer) + ->setSharedStoreIds($wishlist->getSharedStoreIds(false)) + ->getProductCollection() + ->addStoreData() + ->getSize(); + // add wishlist ajax accordion + $this->addItem('wishlist', array( + 'title' => Mage::helper('customer')->__('Wishlist - %d item(s)', $wishlistCount), + 'ajax' => true, + 'content_url' => $this->getUrl('*/*/viewWishlist', array('_current' => true)), + )); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php index ffc5f075c8..92512f5626 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Cart.php @@ -60,6 +60,8 @@ protected function _prepareCollection() else { $collection = new Varien_Data_Collection(); } + + $collection->addFieldToFilter('parent_item_id', array('null' => true)); $this->setCollection($collection); return parent::_prepareCollection(); diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php index 6cce1ddac8..84a6dd2e49 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Wishlist.php @@ -46,7 +46,9 @@ public function __construct() protected function _prepareCollection() { - $collection = Mage::getModel('wishlist/wishlist')->loadByCustomer(Mage::registry('current_customer')) + $wishlist = Mage::getModel('wishlist/wishlist'); + $collection = $wishlist->loadByCustomer(Mage::registry('current_customer')) + ->setSharedStoreIds($wishlist->getSharedStoreIds(false)) ->getProductCollection() ->addAttributeToSelect('name') ->addStoreData(); diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php index 4a51c36a6c..68d51d048f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php @@ -72,9 +72,9 @@ protected function _getCustomer() */ protected function _prepareCollection() { - $collection = Mage::getModel('wishlist/wishlist') - ->loadByCustomer($this->_getCustomer()) - ->setSharedStoreIds($this->_getCustomer()->getSharedStoreIds()) + $wishlist = Mage::getModel('wishlist/wishlist'); + $collection = $wishlist->loadByCustomer($this->_getCustomer()) + ->setSharedStoreIds($wishlist->getSharedStoreIds(false)) ->getProductCollection() ->addAttributeToSelect('name') ->addAttributeToSelect('price') diff --git a/app/code/core/Mage/Adminhtml/Block/Denied.php b/app/code/core/Mage/Adminhtml/Block/Denied.php new file mode 100644 index 0000000000..d489a29758 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Block/Denied.php @@ -0,0 +1,37 @@ +getUser(); + if ($user && $user->hasAvailableResources()) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Adminhtml/Block/Extensions/Custom/Edit/Tab/Grid.php b/app/code/core/Mage/Adminhtml/Block/Extensions/Custom/Edit/Tab/Grid.php index bea3007649..ada4be2d3a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Extensions/Custom/Edit/Tab/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Extensions/Custom/Edit/Tab/Grid.php @@ -33,40 +33,64 @@ */ class Mage_Adminhtml_Block_Extensions_Custom_Edit_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid { + /** + * Default collection limit + * + * @var int + */ protected $_defaultLimit = 200; + /** + * Initialize collection and grid + */ public function __construct() { parent::__construct(); $this->setId('extensions_custom_edit_grid'); $this->setUseAjax(true); + $this->setCollection(Mage::getModel('adminhtml/extension_collection')); } - protected function _prepareCollection() - { - // take a look at Mage_Adminhtml_Model_Extension_Collection_Abstract - $collection = Mage::getSingleton('adminhtml/extension_collection'); - $this->setCollection($collection); - return parent::_prepareCollection(); - } - + /** + * Prepare grid columns + * + * @return Mage_Adminhtml_Block_Extensions_Custom_Edit_Tab_Grid + */ protected function _prepareColumns() { $baseUrl = $this->getUrl(); - $this->addColumn('filename', array( - 'header' => Mage::helper('adminhtml')->__('Package'), - 'index' => 'filename', + $this->addColumn('folder', array( + 'header' => Mage::helper('adminhtml')->__('Folder'), + 'index' => 'folder', + 'width' => 100, + 'type' => 'options', + 'options' => $this->getCollection()->collectFolders() + )); + + $this->addColumn('package', array( + 'header' => Mage::helper('adminhtml')->__('Package'), + 'index' => 'package', )); return parent::_prepareColumns(); } + /** + * Self URL getter + * + * @return string + */ public function getCurrentUrl($params=array()) { return $this->getUrl('*/*/grid', array('_current'=>true)); } + /** + * Row URL getter + * + * @return string + */ public function getRowUrl($row) { return $this->getUrl('*/*/load') . '?id=' . urlencode($row->getFilenameId()); diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php index 07046a0d92..eac4bcf494 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php @@ -34,6 +34,19 @@ class Mage_Adminhtml_Block_Newsletter_Queue_Edit extends Mage_Adminhtml_Block_Template { + /** + * Check for template Id in request + * + */ + protected function _construct() + { + parent::_construct(); + $templateId = $this->getRequest()->getParam('template_id'); + if ($templateId) { + $this->setTemplateId($templateId); + } + } + /** * Retrieve current Newsletter Queue Object * @@ -57,7 +70,12 @@ protected function _beforeToHtml() { public function getSaveUrl() { - return $this->getUrl('*/*/save',array('id'=>$this->getRequest()->getParam('id'))); + if ($this->getTemplateId()) { + $params = array('template_id' => $this->getTemplateId()); + } else { + $params = array('id' => $this->getRequest()->getParam('id')); + } + return $this->getUrl('*/*/save', $params); } protected function _prepareLayout() @@ -93,8 +111,9 @@ protected function _prepareLayout() ->setData( array( 'label' => Mage::helper('newsletter')->__('Back'), - 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'", - 'class' => 'back' + 'onclick' => "window.location.href = '" . $this->getUrl(( + $this->getTemplateId() ? '*/newsletter_template/' : '*/*')) . "'", + 'class' => 'back' ) ) ); diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php index 1faba2142f..262eb2fbcf 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php @@ -36,23 +36,21 @@ class Mage_Adminhtml_Block_Newsletter_Template_Grid_Renderer_Action extends Mage { public function render(Varien_Object $row) { - $actions = array(); + if($row->isValidForSend()) { + $actions[] = array( + 'url' => $this->getUrl('*/newsletter_queue/edit', array('template_id' => $row->getId())), + 'caption' => Mage::helper('newsletter')->__('Queue Newsletter...') + ); + } - if($row->isValidForSend()) { - $actions[] = array( - 'url' => $this->getUrl('*/*/toqueue', array('id'=>$row->getId())), - 'caption' => Mage::helper('newsletter')->__('Queue Newsletter') - ); - } - - $actions[] = array( - 'url' => $this->getUrl('*/*/preview', array('id'=>$row->getId())), - 'popup' => true, - 'caption' => Mage::helper('newsletter')->__('Preview') - ); + $actions[] = array( + 'url' => $this->getUrl('*/*/preview', array('id'=>$row->getId())), + 'popup' => true, + 'caption' => Mage::helper('newsletter')->__('Preview') + ); $this->getColumn()->setActions($actions); - return parent::render($row); + return parent::render($row); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Window.php b/app/code/core/Mage/Adminhtml/Block/Notification/Window.php index 96d51f274a..343dca8623 100644 --- a/app/code/core/Mage/Adminhtml/Block/Notification/Window.php +++ b/app/code/core/Mage/Adminhtml/Block/Notification/Window.php @@ -79,6 +79,11 @@ protected function _construct() */ public function canShow() { + if (!Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) { + $this->_available = false; + return false; + } + if (!$this->isOutputEnabled('Mage_AdminNotification')) { $this->_available = false; return false; @@ -95,10 +100,6 @@ public function canShow() } if (is_null($this->_available)) { - if (!Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) { - $this->_available = false; - return false; - } $this->_available = $this->isShow(); } return $this->_available; diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php index 2b9ba3f398..58c0994de3 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php @@ -362,7 +362,7 @@ public function getReport($from, $to) if ($to == '') { $to = $this->getFilter('report_to'); } - $totalObj = new Mage_Reports_Model_Totals(); + $totalObj = Mage::getModel('reports/totals'); $this->setTotals($totalObj->countTotals($this, $from, $to)); $this->addGrandTotals($this->getTotals()); return $this->getCollection()->getReport($from, $to); diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php index fd3671fdce..e6fcd71ecf 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Product/Lowstock/Grid.php @@ -56,19 +56,13 @@ protected function _prepareCollection() $storeId = ''; } - $collection = Mage::getModel('catalog/product')->getCollection() + $collection = Mage::getResourceModel('reports/product_lowstock_collection') ->addAttributeToSelect('*') ->setStoreId($storeId) - ->addAttributeToFilter('type_id', array( - Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, - Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL - )) - ->joinField('qty', - 'cataloginventory/stock_item', - 'qty', - 'product_id=entity_id', - '{{table}}.stock_id=1', - 'left') + ->filterByIsQtyProductTypes() + ->joinInventoryItem('qty') + ->useManageStockFilter($storeId) + ->useNotifyStockQtyFilter($storeId) ->setOrder('qty', 'asc'); if( $storeId ) { diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php index 0f74c57b5d..df4d039a19 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php @@ -443,7 +443,7 @@ public function getInvoice() /** * CREDITMEMO */ - + public function canReturnToStock() { $canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT); if (Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT)) { @@ -452,6 +452,45 @@ public function canReturnToStock() { return false; } } + + /** + * Whether to show 'Return to stock' checkbox for item + * @param Mage_Sales_Model_Order_Creditmemo_Item $item + * @return bool + */ + public function canReturnItemToStock($item=null) { + $canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT); + if (!is_null($item)) { + if (!$item->hasCanReturnToStock()) { + $product = Mage::getModel('catalog/product')->load($item->getOrderItem()->getProductId()); + if ( $product->getId() && $product->getStockItem()->getManageStock() ) { + $item->setCanReturnToStock(true); + } + else { + $item->setCanReturnToStock(false); + } + } + $canReturnToStock = $item->getCanReturnToStock(); + } + return $canReturnToStock; + } + /** + * Whether to show 'Return to stock' column for item parent + * @param Mage_Sales_Model_Order_Creditmemo_Item $item + * @return bool + */ + public function canParentReturnToStock($item = null) + { + $canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT); + if (!is_null($item)) { + if ( $item->getCreditmemo()->getOrder()->hasCanReturnToStock() ) { + $canReturnToStock = $item->getCreditmemo()->getOrder()->getCanReturnToStock(); + } + } elseif ( $this->getOrder()->hasCanReturnToStock() ) { + $canReturnToStock = $this->getOrder()->getCanReturnToStock(); + } + return $canReturnToStock; + } /** * Return true if can ship partially diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php index c50e45035c..2a98e9b77c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create/Items.php @@ -34,6 +34,7 @@ class Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items extends Mage_Adminhtml_Block_Sales_Items_Abstract { + protected $_canReturnToStock; /** * Prepare child blocks * @@ -168,8 +169,8 @@ public function getUpdateUrl() )); } - public function canReturnToStock() { - + public function canReturnToStock() + { $canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT); if (Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT)) { return true; @@ -177,6 +178,29 @@ public function canReturnToStock() { return false; } } + + /** + * Whether to show 'Return to stock' column in creaditmemo grid + * @return bool + */ + public function canReturnItemsToStock() + { + if (is_null($this->_canReturnToStock)) { + if ($this->_canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT)) { + $canReturnToStock = false; + foreach ($this->getCreditmemo()->getAllItems() as $item) { + $product = Mage::getModel('catalog/product')->load($item->getOrderItem()->getProductId()); + if ( $product->getId() && $product->getStockItem()->getManageStock() ) { + $item->setCanReturnToStock($canReturnToStock = true); + } else { + $item->setCanReturnToStock(false); + } + } + $this->getCreditmemo()->getOrder()->setCanReturnToStock($this->_canReturnToStock = $canReturnToStock); + } + } + return $this->_canReturnToStock; + } public function canSendCreditmemoEmail() { diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php index 41afdf901f..033c647545 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php @@ -96,32 +96,6 @@ public function getUpdateUrl() return $this->getUrl('*/*/updateQty', array('order_id'=>$this->getShipment()->getOrderId())); } - public function canShipPartially() - { - $value = Mage::registry('current_shipment')->getOrder()->getCanShipPartially(); - if (!is_null($value) && !$value) { - return false; - } - return true; - } - - public function canShipPartiallyItem() - { - $value = Mage::registry('current_shipment')->getOrder()->getCanShipPartiallyItem(); - if (!is_null($value) && !$value) { - return false; - } - return true; - } - - public function isShipmentRegular() - { - if (!$this->canShipPartiallyItem() || !$this->canShipPartially()) { - return false; - } - return true; - } - public function canSendShipmentEmail() { return Mage::helper('sales')->canSendNewShipmentEmail($this->getOrder()->getStore()->getId()); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php index 7b370eded6..29725ce27d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php @@ -199,6 +199,9 @@ public function canDisplayContainer() */ public function canDisplayGiftmessage() { + if (!$this->getItem()->getOrder()->canInvoice()) { + return false; + } return $this->helper('giftmessage/message')->getIsMessagesAvailable( 'order_item', $this->getItem(), $this->getItem()->getOrder()->getStoreId() ); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php index 50da71ed9e..6e4a6646a7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php @@ -93,6 +93,9 @@ public function getItemsHtml() */ public function getGiftmessageHtml() { + if (!$this->getOrder()->canInvoice()) { + return ''; + } return $this->getChildHtml('order_giftmessage'); } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php index 8f1bc6b8c7..3551567ca3 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php @@ -206,7 +206,14 @@ public function initFields($fieldset, $group, $section, $fieldPrefix='', $labelP foreach ($group->fields as $elements) { $elements = (array)$elements; - usort($elements, array($this, '_sortForm')); + // sort either by sort_order or by child node values bypassing the sort_order + if ($group->sort_fields && $group->sort_fields->by) { + $fieldset->setSortElementsByAttribute((string)$group->sort_fields->by, + ($group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC) + ); + } else { + usort($elements, array($this, '_sortForm')); + } foreach ($elements as $e) { if (!$this->_canShowField($e)) { diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php index bf1a4f20c5..d95bfc3e63 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset.php @@ -47,7 +47,7 @@ public function render(Varien_Data_Form_Element_Abstract $element) { $html = $this->_getHeaderHtml($element); - foreach ($element->getElements() as $field) { + foreach ($element->getSortedElements() as $field) { $html.= $field->toHtml(); } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Run.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Run.php index e24317eb92..a478556d37 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Run.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Run.php @@ -29,7 +29,7 @@ * * @category Mage * @package Mage_Adminhtml - * @author Magento Core Team + * @author Magento Core Team */ class Mage_Adminhtml_Block_System_Convert_Profile_Run extends Mage_Adminhtml_Block_Abstract { @@ -43,6 +43,7 @@ protected function _toHtml() $profile = $this->getProfile(); echo ''; + echo ''; echo ''; $headBlock = $this->getLayout()->createBlock('page/html_head'); diff --git a/app/code/core/Mage/Adminhtml/Block/Template.php b/app/code/core/Mage/Adminhtml/Block/Template.php index d7ca2c6184..ddf6835b81 100644 --- a/app/code/core/Mage/Adminhtml/Block/Template.php +++ b/app/code/core/Mage/Adminhtml/Block/Template.php @@ -69,4 +69,15 @@ public function isOutputEnabled($moduleName = null) } return !Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName); } + + /** + * Prepare html output + * + * @return string + */ + protected function _toHtml() + { + Mage::dispatchEvent('adminhtml_block_html_before', array('block' => $this)); + return parent::_toHtml(); + } } diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php index 0fd1077793..236c4d3d37 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.php @@ -134,7 +134,7 @@ public function getCondition() protected function _getRate($from, $to) { - return Mage::getModel('directory/currency')->load($from)->getRate($to); + return Mage::getModel('directory/currency')->load($from)->getAnyRate($to); } public function prepareRates($displayCurrency) diff --git a/app/code/core/Mage/Adminhtml/Block/Backup/Grid/Renderer/Type.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php similarity index 64% rename from app/code/core/Mage/Adminhtml/Block/Backup/Grid/Renderer/Type.php rename to app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php index e35e289978..6667da446a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Backup/Grid/Renderer/Type.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php @@ -1,54 +1,43 @@ - - */ -class Mage_Adminhtml_Block_Backup_Grid_Renderer_Type extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract -{ - protected function _getOption($id) - { - $options = array( - 'db'=>Mage::helper('backup')->__('DB') - ); - - if(!isset($options[$id])) { - return ''; - } - return $options[$id]; - } - - public function render(Varien_Object $row) - { - return $this->_getOption($row->getData($this->getColumn()->getIndex())); - } - - -} \ No newline at end of file +getData($this->getColumn()->getIndex())); + } +} diff --git a/app/code/core/Mage/Adminhtml/Model/Extension/Collection.php b/app/code/core/Mage/Adminhtml/Model/Extension/Collection.php index 90bb753ffd..6376365452 100644 --- a/app/code/core/Mage/Adminhtml/Model/Extension/Collection.php +++ b/app/code/core/Mage/Adminhtml/Model/Extension/Collection.php @@ -28,83 +28,72 @@ * Extension packages files collection * */ -class Mage_Adminhtml_Model_Extension_Collection extends Mage_Adminhtml_Model_Extension_Collection_Abstract +class Mage_Adminhtml_Model_Extension_Collection extends Varien_Data_Collection_Filesystem { - public static $allowDirs = '/^[a-z0-9\.\-]+$/i'; - public static $allowFiles = '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i'; - public static $disallowFiles = '/^package\.xml$/i'; + /** + * Files and folders regexsp + * + * @var string + */ + protected $_allowedDirsMask = '/^[a-z0-9\.\-]+$/i'; + protected $_allowedFilesMask = '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i'; + protected $_disallowedFilesMask = '/^package\.xml$/i'; /** - * Get all packages identifiers + * Base dir where packages are located * + * @var string + */ + protected $_baseDir = ''; + + /** + * Set base dir + */ + public function __construct() + { + $this->_baseDir = Mage::getBaseDir('var') . DS . 'pear'; + $this->addTargetDir($this->_baseDir); + } + + /** + * Row generator + * + * @param string $filename * @return array */ - protected function _fetchPackages() + protected function _generateRow($filename) { - $baseDir = Mage::getBaseDir('var') . DS . 'pear'; - $files = array(); - $this->_collectRecursive($baseDir, $files); - $result = array(); - foreach ($files as $file) { - $file = preg_replace(array('/^' . preg_quote($baseDir . DS, '/') . '/', '/\.(xml|ser)$/'), '', $file); - $result[] = array( - 'filename' => $file, - 'filename_id' => $file - ); + $row = parent::_generateRow($filename); + $row['package'] = preg_replace('/\.(xml|ser)$/', '', str_replace($this->_baseDir . DS, '', $filename)); + $row['filename_id'] = $row['package']; + $folder = explode(DS, $row['package']); + array_pop($folder); + $row['folder'] = DS; + if (!empty($folder)) { + $row['folder'] = implode(DS, $folder) . DS; } - return $result; + return $row; } /** - * Get package files from directory recursively + * Get all folders as options array * - * @param string $dir - * @param array &$result - * @param bool $dirsFirst + * @return array */ - protected function _collectRecursive($dir, &$result, $dirsFirst = true) + public function collectFolders() { - $_result = glob($dir . DS . '*'); + $collectFiles = $this->_collectFiles; + $collectDirs = $this->_collectDirs; + $this->setCollectFiles(false)->setCollectDirs(true); - if (!is_array($_result)) { - return; + $this->_collectRecursive($this->_baseDir); + $result = array(DS => DS); + foreach ($this->_collectedDirs as $dir) { + $dir = str_replace($this->_baseDir . DS, '', $dir) . DS; + $result[$dir] = $dir; } - if (!$dirsFirst) { - // collect all the stuff recursively - foreach ($_result as $item) { - if (is_dir($item) && preg_match(self::$allowDirs, basename($item))) { - $this->_collectRecursive($item, $result, $dirsFirst); - } - elseif (is_file($item) - && preg_match(self::$allowFiles, basename($item)) - && !preg_match(self::$disallowFiles, basename($item))) { - $result[] = $item; - } - } - } - else { - // collect directories first - $dirs = array(); - $files = array(); - foreach ($_result as $item) { - if (is_dir($item) && preg_match(self::$allowDirs, basename($item))) { - $dirs[] = $item; - } - elseif (is_file($item) - && preg_match(self::$allowFiles, basename($item)) - && !preg_match(self::$disallowFiles, basename($item))) { - $files[] = $item; - } - } - // search directories recursively - foreach ($dirs as $item) { - $this->_collectRecursive($item, $result, $dirsFirst); - } - // add files - foreach ($files as $item) { - $result[] = $item; - } - } + $this->setCollectFiles($collectFiles)->setCollectDirs($collectDirs); + return $result; } } diff --git a/app/code/core/Mage/Adminhtml/Model/Extension/Collection/Abstract.php b/app/code/core/Mage/Adminhtml/Model/Extension/Collection/Abstract.php deleted file mode 100644 index d4f4ded586..0000000000 --- a/app/code/core/Mage/Adminhtml/Model/Extension/Collection/Abstract.php +++ /dev/null @@ -1,149 +0,0 @@ -isLoaded()) { - return $this; - } - - // fetch packages specific to source - $packages = $this->_fetchPackages(); - - // apply filters - if (!empty($this->_filters)) { - foreach ($packages as $i=>$pkg) { - if (!$this->validateRow($pkg)) { - unset($packages[$i]); - } - } - } - - // find totals - $this->_totalRecords = sizeof($packages); - $this->_setIsLoaded(); - - // sort packages - if (!empty($this->_orders)) { - usort($packages, array($this, 'sortPackages')); - } - - // pagination and add to collection - $from = ($this->getCurPage() - 1) * $this->getPageSize(); - $to = $from + $this->getPageSize() - 1; - - $cnt = 0; - foreach ($packages as $pkg) { - $cnt++; - if ($cnt<$from || $cnt>$to) { - continue; - } - $item = new $this->_itemObjectClass(); - $item->addData($pkg); - $this->addItem($item); - } - - return $this; - } - - abstract protected function _fetchPackages(); - - public function setOrder($field, $dir) - { - $this->_orders[] = array('field'=>$field, 'dir'=>$dir); - return $this; - } - - public function sortPackages($a, $b) - { - $field = $this->_orders[0]['field']; - $dir = $this->_orders[0]['dir']; - - $cmp = $a[$field] > $b[$field] ? 1 : ($a[$field] < $b[$field] ? -1 : 0); - - return ('asc'===$dir) ? $cmp : -$cmp; - } - - public function addFieldToFilter($field, $condition) - { - $this->_filters[$field] = $condition; - return $this; - } - - public function validateRow($row) - { - if (empty($this->_filters)) { - return true; - } - foreach ($this->_filters as $field=>$filter) { - if (!isset($row[$field])) { - return false; - } - if (isset($filter['eq'])) { - if ($filter['eq']!=$row[$field]) { - return false; - } - } - if (isset($filter['like'])) { - $query = preg_replace('#(^%|%$)#', '', $filter['like']); - if (strpos(strtolower($row[$field]), strtolower($query))===false) { - return false; - } - } - if ('version'===$field) { - if (isset($filter['from'])) { - if (!version_compare($filter['from'], $row[$field], '<=')) { - return false; - } - } - if (isset($filter['to'])) { - if (!version_compare($filter['to'], $row[$field], '>=')) { - return false; - } - } - } - } - return true; - } - - public function getAllIds() - { - $this->load(); - - $ids = array(); - foreach ($this->getIterator() as $item) { - $ids[] = $item->getId(); - } - return $ids; - } - -} diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php index 2b3692e666..aab7bd5e4c 100644 --- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php +++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php @@ -155,8 +155,16 @@ public function initFromOrder(Mage_Sales_Model_Order $order) $this->getSession()->setReordered($order->getId()); } + /** + * Check if we edit quest order + */ $this->getSession()->setCurrencyId($order->getOrderCurrencyCode()); - $this->getSession()->setCustomerId($order->getCustomerId()); + if ($order->getCustomerId()) { + $this->getSession()->setCustomerId($order->getCustomerId()); + } else { + $this->getSession()->setCustomerId(false); + } + $this->getSession()->setStoreId($order->getStoreId()); foreach ($order->getItemsCollection( @@ -1132,9 +1140,24 @@ protected function _validate() if (!$this->getQuote()->getShippingAddress()->getShippingMethod()) { $errors[] = Mage::helper('adminhtml')->__('Shipping method must be specified'); } + } - if (!$this->getQuote()->getPayment()->getMethod()) { - $errors[] = Mage::helper('adminhtml')->__('Payment method must be specified'); + if (!$this->getQuote()->getPayment()->getMethod()) { + $errors[] = Mage::helper('adminhtml')->__('Payment method must be specified'); + } else { + $method = $this->getQuote()->getPayment()->getMethodInstance(); + if (!$method) { + $errors[] = Mage::helper('adminhtml')->__('Payment method instance is not available'); + } else { + if (!$method->isAvailable($this->getQuote())) { + $errors[] = Mage::helper('adminhtml')->__('Payment method is not available'); + } else { + try { + $method->validate(); + } catch (Mage_Core_Exception $e) { + $errors[] = $e->getMessage(); + } + } } } @@ -1177,8 +1200,16 @@ protected function _putCustomerIntoQuote() ->setDefaultBilling($billingAddress->getId()) ->setDefaultShipping($shippingAddress->getId()); } - else { - $customer = $this->getSession()->getCustomer(); + elseif (($customer = $this->getSession()->getCustomer()) && $customer->getId() + && !$this->getSession()->getCustomer(true,true)->getId()) + { + $customer = clone $customer; + $customer->setStore($this->getSession()->getStore()) + ->save(); + $this->getSession()->setCustomer($customer); + $customer->addData($this->getData('account')); + } + else { $customer = $this->getSession()->getCustomer(); $customer->addData($this->getData('account')); } $this->getQuote()->setCustomer($customer); diff --git a/app/code/core/Mage/Adminhtml/Model/Session/Quote.php b/app/code/core/Mage/Adminhtml/Model/Session/Quote.php index 4222aa9632..be7fa44394 100644 --- a/app/code/core/Mage/Adminhtml/Model/Session/Quote.php +++ b/app/code/core/Mage/Adminhtml/Model/Session/Quote.php @@ -99,14 +99,30 @@ public function getQuote() } /** + * Set customer model object + * To enable quick switch of preconfigured customer + * @param Mage_Customer_Model_Customer $customer + * @return Mage_Adminhtml_Model_Session_Quote + */ + public function setCustomer(Mage_Customer_Model_Customer $customer) + { + $this->_customer = $customer; + return $this; + } + +/** * Retrieve customer model object - * + * @param bool $forceReload + * @param bool $useSetStore * @return Mage_Customer_Model_Customer */ - public function getCustomer() + public function getCustomer($forceReload=false, $useSetStore=false) { - if (is_null($this->_customer)) { + if (is_null($this->_customer) || $forceReload) { $this->_customer = Mage::getModel('customer/customer'); + if ($useSetStore && $this->getStore()->getId()) { + $this->_customer->setStore($this->getStore()); + } if ($customerId = $this->getCustomerId()) { $this->_customer->load($customerId); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php index fac76407ab..d677c4e2a4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php @@ -155,6 +155,10 @@ public function saveAction() $data['frontend_input'] = $model->getFrontendInput(); } + if (!isset($data['is_configurable'])) { + $data['is_configurable'] = 0; + } + if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) { $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index ecac02e5b0..7fb0d9ad2e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -427,6 +427,10 @@ public function validateAction() $response->setAttribute($e->getAttributeCode()); $response->setMessage($e->getMessage()); } + catch (Mage_Core_Exception $e) { + $response->setError(true); + $response->setMessage($e->getMessage()); + } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); $this->_initLayoutMessages('adminhtml/session'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php index 53a242e9e0..5886a23667 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php @@ -66,168 +66,192 @@ public function gridAction() public function startAction() { - $queue = Mage::getModel('newsletter/queue') - ->load($this->getRequest()->getParam('id')); - if ($queue->getId()) { - if (!in_array($queue->getQueueStatus(), - array(Mage_Newsletter_Model_Queue::STATUS_NEVER, - Mage_Newsletter_Model_Queue::STATUS_PAUSE))) { - $this->_redirect('*/*'); - return; - } - - $queue->setQueueStartAt(Mage::getSingleton('core/date')->gmtDate()) - ->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING) - ->save(); - } - - $this->_redirect('*/*'); + $queue = Mage::getModel('newsletter/queue') + ->load($this->getRequest()->getParam('id')); + if ($queue->getId()) { + if (!in_array($queue->getQueueStatus(), + array(Mage_Newsletter_Model_Queue::STATUS_NEVER, + Mage_Newsletter_Model_Queue::STATUS_PAUSE))) { + $this->_redirect('*/*'); + return; + } + + $queue->setQueueStartAt(Mage::getSingleton('core/date')->gmtDate()) + ->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING) + ->save(); + } + + $this->_redirect('*/*'); } public function pauseAction() { - $queue = Mage::getSingleton('newsletter/queue') - ->load($this->getRequest()->getParam('id')); + $queue = Mage::getSingleton('newsletter/queue') + ->load($this->getRequest()->getParam('id')); - if (!in_array($queue->getQueueStatus(), - array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) { - $this->_redirect('*/*'); - return; - } + if (!in_array($queue->getQueueStatus(), + array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) { + $this->_redirect('*/*'); + return; + } - $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_PAUSE); - $queue->save(); + $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_PAUSE); + $queue->save(); - $this->_redirect('*/*'); + $this->_redirect('*/*'); } public function resumeAction() { - $queue = Mage::getSingleton('newsletter/queue') - ->load($this->getRequest()->getParam('id')); + $queue = Mage::getSingleton('newsletter/queue') + ->load($this->getRequest()->getParam('id')); - if (!in_array($queue->getQueueStatus(), - array(Mage_Newsletter_Model_Queue::STATUS_PAUSE))) { - $this->_redirect('*/*'); - return; - } + if (!in_array($queue->getQueueStatus(), + array(Mage_Newsletter_Model_Queue::STATUS_PAUSE))) { + $this->_redirect('*/*'); + return; + } - $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING); - $queue->save(); + $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING); + $queue->save(); - $this->_redirect('*/*'); + $this->_redirect('*/*'); } public function cancelAction() { - $queue = Mage::getSingleton('newsletter/queue') - ->load($this->getRequest()->getParam('id')); + $queue = Mage::getSingleton('newsletter/queue') + ->load($this->getRequest()->getParam('id')); - if (!in_array($queue->getQueueStatus(), - array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) { - $this->_redirect('*/*'); - return; - } + if (!in_array($queue->getQueueStatus(), + array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) { + $this->_redirect('*/*'); + return; + } - $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_CANCEL); - $queue->save(); + $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_CANCEL); + $queue->save(); - $this->_redirect('*/*'); + $this->_redirect('*/*'); } public function sendingAction() { - // Todo: put it somewhere in config! - $countOfQueue = 3; - $countOfSubscritions = 20; + // Todo: put it somewhere in config! + $countOfQueue = 3; + $countOfSubscritions = 20; - $collection = Mage::getResourceModel('newsletter/queue_collection') - ->setPageSize($countOfQueue) - ->setCurPage(1) - ->addOnlyForSendingFilter() - ->load(); + $collection = Mage::getResourceModel('newsletter/queue_collection') + ->setPageSize($countOfQueue) + ->setCurPage(1) + ->addOnlyForSendingFilter() + ->load(); $collection->walk('sendPerSubscriber', array($countOfSubscritions)); } - public function editAction() { - $queue = Mage::getSingleton('newsletter/queue') - ->load($this->getRequest()->getParam('id')); - - Mage::register('current_queue', $queue); + Mage::register('current_queue', Mage::getSingleton('newsletter/queue')); + $id = $this->getRequest()->getParam('id'); + $templateId = $this->getRequest()->getParam('template_id'); + if ($id) { + Mage::registry('current_queue')->load($id); + } elseif ($templateId) { + $template = Mage::getModel('newsletter/template')->load($templateId)->preprocess(); + Mage::registry('current_queue')->setTemplateId($template->getId()); + } - $this->loadLayout(); + $this->loadLayout(); - $this->_setActiveMenu('newsletter/queue'); + $this->_setActiveMenu('newsletter/queue'); $this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Queue'), Mage::helper('newsletter')->__('Newsletter Queue'), $this->getUrl('*/newsletter_queue')); $this->_addBreadcrumb(Mage::helper('newsletter')->__('Edit Queue'), Mage::helper('newsletter')->__('Edit Queue')); $this->_addContent( - $this->getLayout()->createBlock('adminhtml/newsletter_queue_edit', 'queue.edit') + $this->getLayout()->createBlock('adminhtml/newsletter_queue_edit', 'queue.edit') ); - $this->renderLayout(); + $this->renderLayout(); } public function saveAction() { - $queue = Mage::getSingleton('newsletter/queue') - ->load($this->getRequest()->getParam('id')); - - if (!in_array($queue->getQueueStatus(), - array(Mage_Newsletter_Model_Queue::STATUS_NEVER, - Mage_Newsletter_Model_Queue::STATUS_PAUSE))) { - $this->_redirect('*/*'); - return; - } - - $format = Mage::app()->getLocale()->getDateTimeFormat( - Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM - ); - - if ($queue->getQueueStatus()==Mage_Newsletter_Model_Queue::STATUS_NEVER) { - if ($this->getRequest()->getParam('start_at')) { - $date = Mage::app()->getLocale()->date($this->getRequest()->getParam('start_at'), $format); - $time = $date->getTimestamp(); - $queue->setQueueStartAt( - Mage::getModel('core/date')->gmtDate(null, $time) - ); - } else { - $queue->setQueueStartAt(null); - } - } - - $queue->setStores($this->getRequest()->getParam('stores', array())); - - $queue->addTemplateData($queue); - $queue->getTemplate() - ->setTemplateSubject($this->getRequest()->getParam('subject')) - ->setTemplateSenderName($this->getRequest()->getParam('sender_name')) - ->setTemplateSenderEmail($this->getRequest()->getParam('sender_email')) - ->setTemplateTextPreprocessed($this->getRequest()->getParam('text')); - - if ($queue->getQueueStatus() == Mage_Newsletter_Model_Queue::STATUS_PAUSE - && $this->getRequest()->getParam('_resume', false)) { - $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING); - } - - $queue->setSaveTemplateFlag(true); - - try { - $queue->save(); - } - catch (Exception $e) { - echo $e->getMessage(); - exit; - } - $this->_redirect('*/*'); + try { + // create new queue from template, if specified + $templateId = $this->getRequest()->getParam('template_id'); + if ($templateId) { + $template = Mage::getModel('newsletter/template')->load($templateId); + if (!$template->getId() || $template->getIsSystem()) { + Mage::throwException($this->__('Wrong newsletter template.')); + } + $template->preprocess(); + $queue = Mage::getModel('newsletter/queue') + ->setTemplateId($template->getId()) + ->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_NEVER); + $template->save(); + } + else { + $queue = Mage::getSingleton('newsletter/queue') + ->load($this->getRequest()->getParam('id')); + } + + if (!in_array($queue->getQueueStatus(), + array(Mage_Newsletter_Model_Queue::STATUS_NEVER, + Mage_Newsletter_Model_Queue::STATUS_PAUSE))) { + $this->_redirect('*/*'); + return; + } + + $format = Mage::app()->getLocale()->getDateTimeFormat( + Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM + ); + + if ($queue->getQueueStatus()==Mage_Newsletter_Model_Queue::STATUS_NEVER) { + if ($this->getRequest()->getParam('start_at')) { + $date = Mage::app()->getLocale()->date($this->getRequest()->getParam('start_at'), $format); + $time = $date->getTimestamp(); + $queue->setQueueStartAt( + Mage::getModel('core/date')->gmtDate(null, $time) + ); + } else { + $queue->setQueueStartAt(null); + } + } + + $queue->setStores($this->getRequest()->getParam('stores', array())); + + $queue->addTemplateData($queue); + $queue->getTemplate() + ->setTemplateSubject($this->getRequest()->getParam('subject')) + ->setTemplateSenderName($this->getRequest()->getParam('sender_name')) + ->setTemplateSenderEmail($this->getRequest()->getParam('sender_email')) + ->setTemplateTextPreprocessed($this->getRequest()->getParam('text')); + + if ($queue->getQueueStatus() == Mage_Newsletter_Model_Queue::STATUS_PAUSE + && $this->getRequest()->getParam('_resume', false)) { + $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING); + } + + $queue->setSaveTemplateFlag(true); + $queue->save(); + $this->_redirect('*/*'); + } + catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + $id = $this->getRequest()->getParam('id'); + if ($id) { + $this->_redirect('*/*/edit', array('id' => $id)); + } + else { + $this->_redirectReferer(); + } + } } protected function _isAllowed() { - return Mage::getSingleton('admin/session')->isAllowed('newsletter/queue'); + return Mage::getSingleton('admin/session')->isAllowed('newsletter/queue'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php index 3084629c3a..05e1e7c858 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php @@ -187,28 +187,6 @@ public function previewAction () $this->renderLayout(); } - /** - * Queue Newsletter - * - */ - public function toqueueAction () - { - $template = Mage::getModel('newsletter/template') - ->load($this->getRequest()->getParam('id')); - if (!$template->getIsSystem()) { - $template->preprocess(); - $queue = Mage::getModel('newsletter/queue') - ->setTemplateId($template->getId()) - ->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_NEVER) - ->save(); - $template->save(); - $this->_redirect('*/newsletter_queue/edit', array('id' => $queue->getId())); - } - else { - $this->_redirect('*/*'); - } - } - /** * Check is allowed access * diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php index 26e22e00c9..a5b8131838 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php @@ -198,8 +198,8 @@ public function addCommentAction() $order->addStatusToHistory($data['status'], $data['comment'], $notify); $comment = trim(strip_tags($data['comment'])); - $order->sendOrderUpdateEmail($notify, $comment); $order->save(); + $order->sendOrderUpdateEmail($notify, $comment); $this->loadLayout('empty'); $this->renderLayout(); diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php index 9fc994432a..c3311f5a54 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php @@ -279,11 +279,7 @@ protected function _importRates() unset($csvData[0][$u]); } } - - if ($csvData[0] == $csvFields) { - Mage::getModel('tax/calculation_rate')->deleteAllRates(); - foreach ($csvData as $k => $v) { if ($k == 0) { continue; @@ -329,8 +325,11 @@ protected function _importRates() 'rate'=>$v[4], ); - $rateModel = Mage::getModel('tax/calculation_rate') - ->setData($rateData); + $rateModel = Mage::getModel('tax/calculation_rate')->loadByCode($rateData['code']); + foreach($rateData as $dataName => $dataValue) { + $rateModel->setData($dataName, $dataValue); + } + $titles = array(); foreach ($stores as $field=>$id) { $titles[$id]=$v[$field]; diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php index 2de9114fc5..3ead699a4c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -63,9 +63,9 @@ protected function _initRegistry() */ public function indexAction() { + $this->_initRegistry(); $this->loadLayout(); $this->_setActiveMenu('catalog/urlrewrite'); - $this->_initRegistry(); $this->_addContent( $this->getLayout()->createBlock('adminhtml/urlrewrite') ); @@ -78,9 +78,9 @@ public function indexAction() */ public function editAction() { + $this->_initRegistry(); $this->loadLayout(); $this->_setActiveMenu('catalog/urlrewrite'); - $this->_initRegistry(); $this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit')); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $this->renderLayout(); @@ -150,9 +150,9 @@ public function saveAction() // save and redirect $model->save(); - Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__( - 'Urlrewrite has been successfully saved' - )); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('adminhtml')->__('Urlrewrite has been successfully saved') + ); $this->_redirect('*/*/'); return; } @@ -178,9 +178,9 @@ public function deleteAction() if (Mage::registry('current_urlrewrite')->getId()) { try { Mage::registry('current_urlrewrite')->delete(); - Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__( - 'Urlrewrite has been successfully deleted' - )); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('adminhtml')->__('Urlrewrite has been successfully deleted') + ); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); diff --git a/app/code/core/Mage/Api/Model/Acl/Assert/Ip.php b/app/code/core/Mage/Api/Model/Acl/Assert/Ip.php index 5546d3f04c..de5e6fafe8 100644 --- a/app/code/core/Mage/Api/Model/Acl/Assert/Ip.php +++ b/app/code/core/Mage/Api/Model/Acl/Assert/Ip.php @@ -46,7 +46,7 @@ class Mage_Api_Model_Acl_Assert_Ip implements Zend_Acl_Assert_Interface public function assert(Mage_Api_Model_Acl $acl, Mage_Api_Model_Acl_Role $role = null, Mage_Api_Model_Acl_Resource $resource = null, $privilege = null) { - return $this->_isCleanIP($_SERVER['REMOTE_ADDR']); + return $this->_isCleanIP(Mage::helper('core/http')->getRemoteAddr()); } protected function _isCleanIP($ip) diff --git a/app/code/core/Mage/Backup/Model/Backup.php b/app/code/core/Mage/Backup/Model/Backup.php index 46979e10fe..c70fa2feed 100644 --- a/app/code/core/Mage/Backup/Model/Backup.php +++ b/app/code/core/Mage/Backup/Model/Backup.php @@ -70,8 +70,8 @@ public function load($fileName, $filePath) 'id' => $filePath . DS . $fileName, 'time' => (int)$time, 'path' => $filePath, - 'time_formated' => date('Y-m-d H:i:s', (int)$time)) - ); + 'date_object' => new Zend_Date((int)$time) + )); $this->setType($type); return $this; } diff --git a/app/code/core/Mage/Backup/Model/Fs/Collection.php b/app/code/core/Mage/Backup/Model/Fs/Collection.php index e43e36d726..b7d72785dd 100644 --- a/app/code/core/Mage/Backup/Model/Fs/Collection.php +++ b/app/code/core/Mage/Backup/Model/Fs/Collection.php @@ -31,200 +31,55 @@ * @package Mage_Backup * @author Magento Core Team */ - -class Mage_Backup_Model_Fs_Collection extends Varien_Data_Collection +class Mage_Backup_Model_Fs_Collection extends Varien_Data_Collection_Filesystem { /** - * Is loaded data flag - * @var boolean + * Folder, where all backups are stored + * + * @var string */ - protected $_isLoaded = false; - + protected $_baseDir; /** - * Constructor - * - * Sets default item object class and default sort order. + * Set collection specific parameters and make sure backups folder will exist */ public function __construct() { parent::__construct(); - $this->setItemObjectClass(Mage::getConfig()->getModelClassName('backup/backup')) - ->setOrder('time','desc'); - - } - - /** - * Loads data from backup directory - * - * @return Mage_Backup_Model_Fs_Collection - */ - public function getSize() - { - $this->_loadFiles(); - return $this->_totalRecords; - } - - public function load($printQuery = false, $logQuery = false) - { - if (!$this->_isLoaded) { - $this->_loadFiles(); - if($this->getPageSize()) { - $this->_items = array_slice($this->_items, ($this->getCurPage()-1)*$this->getPageSize(), $this->getPageSize()); - } - } - - return $this; - } - - protected function _loadFiles() - { - if (!$this->_isLoaded) { - - $readPath = Mage::getBaseDir('var') . DS . "backups"; - - $ioProxy = new Varien_Io_File(); - - try { - $ioProxy->open(array('path'=>$readPath)); - } - catch (Exception $e) { - $ioProxy->mkdir($readPath, 0777); - $ioProxy->chmod($readPath, 0777); - $ioProxy->open(array('path'=>$readPath)); - } - if (!is_file($readPath . DS . ".htaccess")) { - // Deny from reading in browser - $ioProxy->write(".htaccess","deny from all", 0644); - } + $this->_baseDir = Mage::getBaseDir('var') . DS . 'backups'; - - $list = $ioProxy->ls(Varien_Io_File::GREP_FILES); - - $fileExtension = constant($this->_itemObjectClass . "::BACKUP_EXTENSION"); - - foreach ($list as $entry) { - if ($entry['filetype'] == $fileExtension) { - $item = new $this->_itemObjectClass(); - $item->load($entry['text'], $readPath); - $item->setSize($entry['size']); - if ($this->_checkCondition($item)) { - $this->addItem($item); - } - } - } - - - $this->_totalRecords = count($this->_items); - - if ($this->_totalRecords > 1) { - usort($this->_items, array(&$this, 'compareByTypeOrDate')); - } - - $this->_isLoaded = true; + // check for valid base dir + $ioProxy = new Varien_Io_File(); + $ioProxy->mkdir($this->_baseDir); + if (!is_file($this->_baseDir . DS . '.htaccess')) { + $ioProxy->open(array('path' => $this->_baseDir)); + $ioProxy->write('.htaccess', 'deny from all', 0644); } - return $this; - } - - /** - * Set sort order for items - * - * @param string $field - * @param string $direction - * @return Mage_Backup_Model_Fs_Collection - */ - public function setOrder($field, $direction = 'desc') - { - $direction = (strtoupper($direction)=='ASC') ? 1 : -1; - $this->_orders = array($field, $direction); - return $this; + // set collection specific params + $this + ->setOrder('time', self::SORT_ORDER_DESC) + ->addTargetDir($this->_baseDir) + ->setFilesFilter('/^[a-z0-9\-\_]+\.' . preg_quote(Mage_Backup_Model_Backup::BACKUP_EXTENSION, '/') . '$/') + ->setCollectRecursively(false) + ; } /** - * Function for comparing two items in collection + * Get backup-specific data from model for each row * - * @param Varien_Object $item1 - * @param Varien_Object $item2 - * @return boolean + * @param string $filename + * @return array */ - public function compareByTypeOrDate(Varien_Object $item1,Varien_Object $item2) + protected function _generateRow($filename) { - if (is_string($item1->getData($this->_orders[0]))) { - return strcmp($item1->getData($this->_orders[0]),$item2->getData($this->_orders[0]))*(-1*$this->_orders[1]); - } else if ($item1->getData($this->_orders[0]) < $item2->getData($this->_orders[0])) { - return 1*(-1*$this->_orders[1]); - } else if ($item1->getData($this->_orders[0]) > $item2->getData($this->_orders[0])) { - return -1*(-1*$this->_orders[1]); - } else { - return 0; + $row = parent::_generateRow($filename); + foreach (Mage::getSingleton('backup/backup')->load($row['basename'], $this->_baseDir) + ->getData() as $key => $value) { + $row[$key] = $value; } - } - - public function addFieldToFilter($fieldName, $condition) - { - $this->_filters[$fieldName] = $condition; - return $this; - } - - protected function _checkCondition($item) - { - foreach ($this->_filters as $field => $condition) { - if (is_array($condition)) { - if (isset($condition['from']) || isset($condition['to'])) { - if ($field == 'time_formated') { - $format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); - if (isset($condition['from'])) { - $condition['from'] = Mage::app()->getLocale()->date($condition['from'], $format)->getTimestamp() - + Mage::app()->getLocale()->date($condition['from'], $format)->getGmtOffset(); - } - if (isset($condition['to'])) { - $condition['to'] = Mage::app()->getLocale()->date($condition['to'], $format)->getTimestamp() - + Mage::app()->getLocale()->date($condition['to'], $format)->getGmtOffset(); - } - $field = 'time'; - } - - if (isset($condition['from']) && $item->getData($field) < $condition['from']) { - return false; - } - if (isset($condition['to']) && $item->getData($field) > $condition['to']) { - return false; - } - } - elseif (!empty($condition['neq']) && $item->getData($field) == $condition['neq']) { - return false; - } - elseif (!empty($condition['like']) && strpos($item->getData($field), trim($condition['like'], '%')) === false) { - return false; - } - elseif (!empty($condition['nlike']) && strpos($item->getData($field), trim($condition['nlike'], '%')) !== false) { - return false; - } - elseif (!empty($condition['in'])) { - $values = $condition['in']; - if(!is_array($values)) { - $values = array($values); - } - if(!in_array($item->getData($field), $values)) { - return false; - } - } - elseif (!empty($condition['nin'])) { - $values = $condition['in']; - if(!is_array($values)) { - $values = array($values); - } - if(in_array($item->getData($field), $values)) { - return false; - } - } - } else if($item->getData($field) != $condition) { - return false; - } - } - - return true; + $row['size'] = filesize($filename); + return $row; } } \ No newline at end of file diff --git a/app/code/core/Mage/Bundle/Model/Mysql4/Price/Index.php b/app/code/core/Mage/Bundle/Model/Mysql4/Price/Index.php index 80da60ccf8..2459b64464 100644 --- a/app/code/core/Mage/Bundle/Model/Mysql4/Price/Index.php +++ b/app/code/core/Mage/Bundle/Model/Mysql4/Price/Index.php @@ -275,8 +275,11 @@ public function getSelections($productId) array('selection_table' => $this->getTable('bundle/selection')), 'selection_table.option_id=option_table.option_id', array('selection_id', 'product_id', 'selection_price_type', - 'selection_price_value', 'selection_qty', 'selection_can_change_qty') - ) + 'selection_price_value', 'selection_qty', 'selection_can_change_qty')) + ->join( + array('e' => $this->getTable('catalog/product')), + 'e.entity_id=selection_table.product_id AND e.required_options=0', + array()) ->where('option_table.parent_id=?', $productId); $query = $this->_getReadAdapter()->query($select); while ($row = $query->fetch()) { @@ -674,6 +677,7 @@ public function _calculateBundleSelections(array $options, array $salableStatus, $productId, $priceType, $basePrice, $priceData, $priceIndex, $website, $group) { $minPrice = $maxPrice = $basePrice; + $optPrice = 0; foreach ($options as $option) { $optionPrices = array(); @@ -725,6 +729,9 @@ public function _calculateBundleSelections(array $options, array $salableStatus, if ($option['required']) { $minPrice += min($optionPrices); } + else { + $optPrice = $optPrice && $optPrice < min($optionPrices) ? $optPrice : min($optionPrices); + } if (in_array($option['type'], array('multi', 'checkbox'))) { $maxPrice += array_sum($optionPrices); } @@ -733,6 +740,10 @@ public function _calculateBundleSelections(array $options, array $salableStatus, } } } + + if ($minPrice == 0) { + $minPrice = $optPrice; + } return array($minPrice, $maxPrice); } diff --git a/app/code/core/Mage/Bundle/Model/Mysql4/Selection.php b/app/code/core/Mage/Bundle/Model/Mysql4/Selection.php index cf8a679934..bca5a09ef6 100644 --- a/app/code/core/Mage/Bundle/Model/Mysql4/Selection.php +++ b/app/code/core/Mage/Bundle/Model/Mysql4/Selection.php @@ -151,6 +151,9 @@ public function getChildrenIds($parentId, $required = true) } } } + if (!$childrenIds) { + $childrenIds = array(array()); + } } return $childrenIds; diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php index 1fba5ee4eb..e00070b470 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Abstract.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Bundle - * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) + * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -54,7 +54,8 @@ public function getChilds($item) if ($_items) { foreach ($_items as $_item) { - if ($parentItem = $_item->getOrderItem()->getParentItem()) { + $parentItem = $_item->getOrderItem()->getParentItem(); + if ($parentItem) { $_itemsArray[$parentItem->getId()][$_item->getOrderItemId()] = $_item; } else { $_itemsArray[$_item->getOrderItem()->getId()][$_item->getOrderItemId()] = $_item; @@ -81,17 +82,23 @@ public function isShipmentSeparately($item = null) if ($item->getOrderItem()) { $item = $item->getOrderItem(); } - if ($parentItem = $item->getParentItem()) { - if ($options = $parentItem->getProductOptions()) { - if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { + + $parentItem = $item->getParentItem(); + if ($parentItem) { + $options = $parentItem->getProductOptions(); + if ($options) { + if (isset($options['shipment_type']) + && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { return true; } else { return false; } } } else { - if ($options = $item->getProductOptions()) { - if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { + $options = $item->getProductOptions(); + if ($options) { + if (isset($options['shipment_type']) + && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { return false; } else { return true; @@ -100,8 +107,10 @@ public function isShipmentSeparately($item = null) } } - if ($options = $this->getOrderItem()->getProductOptions()) { - if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { + $options = $this->getOrderItem()->getProductOptions(); + if ($options) { + if (isset($options['shipment_type']) + && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { return true; } } @@ -120,8 +129,11 @@ public function isChildCalculated($item = null) if ($item->getOrderItem()) { $item = $item->getOrderItem(); } - if ($parentItem = $item->getParentItem()) { - if ($options = $parentItem->getProductOptions()) { + + $parentItem = $item->getParentItem(); + if ($parentItem) { + $options = $parentItem->getProductOptions(); + if ($options) { if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { return true; } else { @@ -129,7 +141,8 @@ public function isChildCalculated($item = null) } } } else { - if ($options = $item->getProductOptions()) { + $options = $item->getProductOptions(); + if ($options) { if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { return false; } else { @@ -139,7 +152,8 @@ public function isChildCalculated($item = null) } } - if ($options = $this->getOrderItem()->getProductOptions()) { + $options = $this->getOrderItem()->getProductOptions(); + if ($options) { if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { return true; @@ -156,7 +170,8 @@ public function isChildCalculated($item = null) */ public function getBundleOptions($item = null) { - if ($options = $this->getOrderItem()->getProductOptions()) { + $options = $this->getOrderItem()->getProductOptions(); + if ($options) { if (isset($options['bundle_options'])) { return $options['bundle_options']; } @@ -193,7 +208,8 @@ public function getOrderOptions($item = null) { $result = array(); - if ($options = $this->getOrderItem()->getProductOptions()) { + $options = $this->getOrderItem()->getProductOptions(); + if ($options) { if (isset($options['options'])) { $result = array_merge($result, $options['options']); } @@ -231,12 +247,14 @@ public function getValueHtml($item) { $result = strip_tags($item->getName()); if (!$this->isShipmentSeparately($item)) { - if ($attributes = $this->getSelectionAttributes($item)) { + $attributes = $this->getSelectionAttributes($item); + if ($attributes) { $result = sprintf('%d', $attributes['qty']) . ' x ' . $result; } } if (!$this->isChildCalculated($item)) { - if ($attributes = $this->getSelectionAttributes($item)) { + $attributes = $this->getSelectionAttributes($item); + if ($attributes) { $result .= " " . strip_tags($this->getOrderItem()->getOrder()->formatPrice($attributes['price'])); } } diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php index 77590e5787..980f1dbb82 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -55,7 +55,8 @@ public function draw() $x = $leftBound; $line = array(); - if ($attributes = $this->getSelectionAttributes($_item)) { + $attributes = $this->getSelectionAttributes($_item); + if (is_array($attributes)) { $optionId = $attributes['option_id']; } else { @@ -74,7 +75,7 @@ public function draw() if ($_prevOptionId != $attributes['option_id']) { $line[0] = array( 'font' => 'italic', - 'text' => $attributes['option_label'], + 'text' => Mage::helper('core/string')->str_split($attributes['option_label'],60, true, true), 'feed' => $x ); @@ -178,21 +179,17 @@ public function draw() } - if ($item->getOrderItem()->getProductOptions()) { - $options = $item->getOrderItem()->getProductOptions(); + // custom options + $options = $item->getOrderItem()->getProductOptions(); + if ($options) { if (isset($options['options'])) { foreach ($options['options'] as $option) { $lines = array(); - $text = array(); - foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true) as $_option) { - $text[] = $_option; - } - - $lines = array(array( - 'text' => $text, + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), 'font' => 'italic', 'feed' => $leftBound - )); + ); if ($option['value']) { $text = array(); @@ -204,7 +201,7 @@ public function draw() } } - $lines[] = array( + $lines[][] = array( 'text' => $text, 'feed' => $leftBound + 5 ); @@ -221,4 +218,4 @@ public function draw() $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true)); $this->setPage($page); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php index 19e15010d6..a49b0fc468 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php @@ -54,7 +54,8 @@ public function draw() foreach ($items as $_item) { $line = array(); - if ($attributes = $this->getSelectionAttributes($_item)) { + $attributes = $this->getSelectionAttributes($_item); + if (is_array($attributes)) { $optionId = $attributes['option_id']; } else { @@ -72,7 +73,7 @@ public function draw() if ($_prevOptionId != $attributes['option_id']) { $line[0] = array( 'font' => 'italic', - 'text' => $attributes['option_label'], + 'text' => Mage::helper('core/string')->str_split($attributes['option_label'], 70, true, true), 'feed' => 35 ); @@ -95,13 +96,8 @@ public function draw() $feed = 35; $name = $_item->getName(); } - $text = array(); - foreach (Mage::helper('core/string')->str_split($name, 55, true, true) as $part) { - $text[] = $part; - } - $line[] = array( - 'text' => $text, + 'text' => Mage::helper('core/string')->str_split($name, 55, true, true), 'feed' => $feed ); @@ -152,33 +148,29 @@ public function draw() $drawItems[$optionId]['lines'][] = $line; } - if ($item->getOrderItem()->getProductOptions()) { - $options = $item->getOrderItem()->getProductOptions(); + // custom options + $options = $item->getOrderItem()->getProductOptions(); + if ($options) { if (isset($options['options'])) { foreach ($options['options'] as $option) { $lines = array(); - $text = array(); - foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true) as $_option) { - $text[] = $_option; - } - - $lines = array(array( - 'text' => $text, + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), 'font' => 'italic', 'feed' => 35 - )); + ); if ($option['value']) { $text = array(); $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { - foreach (Mage::helper('core/string')->str_split($value, 70, true, true) as $_value) { + foreach (Mage::helper('core/string')->str_split($value, 50, true, true) as $_value) { $text[] = $_value; } } - $lines[] = array( + $lines[][] = array( 'text' => $text, 'feed' => 40 ); @@ -196,4 +188,4 @@ public function draw() $this->setPage($page); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php index 587735584f..1b24b04f5c 100644 --- a/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php +++ b/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php @@ -40,7 +40,6 @@ class Mage_Bundle_Model_Sales_Order_Pdf_Items_Shipment extends Mage_Bundle_Model */ public function draw() { - $order = $this->getOrder(); $item = $this->getItem(); $pdf = $this->getPdf(); $page = $this->getPage(); @@ -56,7 +55,8 @@ public function draw() foreach ($items as $_item) { $line = array(); - if ($attributes = $this->getSelectionAttributes($_item)) { + $attributes = $this->getSelectionAttributes($_item); + if (is_array($attributes)) { $optionId = $attributes['option_id']; } else { @@ -74,7 +74,7 @@ public function draw() if ($_prevOptionId != $attributes['option_id']) { $line[0] = array( 'font' => 'italic', - 'text' => $attributes['option_label'], + 'text' => Mage::helper('core/string')->str_split($attributes['option_label'],60, true, true), 'feed' => 60 ); @@ -84,6 +84,8 @@ public function draw() ); $line = array(); + + $_prevOptionId = $attributes['option_id']; } } @@ -134,33 +136,29 @@ public function draw() $drawItems[$optionId]['lines'][] = $line; } - if ($item->getOrderItem()->getProductOptions()) { - $options = $item->getOrderItem()->getProductOptions(); + // custom options + $options = $item->getOrderItem()->getProductOptions(); + if ($options) { if (isset($options['options'])) { foreach ($options['options'] as $option) { $lines = array(); - $text = array(); - foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true) as $_option) { - $text[] = $_option; - } - - $lines = array(array( - 'text' => $text, + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), 'font' => 'italic', 'feed' => 60 - )); + ); if ($option['value']) { $text = array(); $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { - foreach (Mage::helper('core/string')->str_split($value, 70, true, true) as $_value) { + foreach (Mage::helper('core/string')->str_split($value, 50, true, true) as $_value) { $text[] = $_value; } } - $lines[] = array( + $lines[][] = array( 'text' => $text, 'feed' => 65 ); diff --git a/app/code/core/Mage/Catalog/Block/Layer/State.php b/app/code/core/Mage/Catalog/Block/Layer/State.php index c46f4f238a..6cfe6acaf7 100644 --- a/app/code/core/Mage/Catalog/Block/Layer/State.php +++ b/app/code/core/Mage/Catalog/Block/Layer/State.php @@ -66,7 +66,7 @@ public function getClearUrl() { $filterState = array(); foreach ($this->getActiveFilters() as $item) { - $filterState[$item->getFilter()->getRequestVar()] = $item->getFilter()->getResetValue(); + $filterState[$item->getFilter()->getRequestVar()] = $item->getFilter()->getCleanValue(); } $params['_current'] = true; $params['_use_rewrite'] = true; diff --git a/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php b/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php index 0c785566e8..2ac4c24f9f 100644 --- a/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php +++ b/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php @@ -20,10 +20,11 @@ * * @category Mage * @package Mage_Catalog - * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) + * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + /** * Product list toolbar * @@ -198,16 +199,27 @@ public function getModeVarName() */ public function getCurrentOrder() { - $order = $this->getRequest()->getParam($this->getOrderVarName()); $orders = $this->getAvailableOrders(); + $order = $this->getRequest()->getParam($this->getOrderVarName()); if ($order && isset($orders[$order])) { - return $order; + Mage::getSingleton('catalog/session')->setSortOrder($order); + } + else { + $order = Mage::getSingleton('catalog/session')->getSortOrder(); + } + + // validate session value + if (!isset($orders[$order])) { + $order = $this->_orderField; } - if ($this->_orderField && isset($orders[$this->_orderField])) { - return $this->_orderField; + + // validate has order value + if (!isset($orders[$order])) { + $keys = array_keys($orders); + $order = $keys[0]; } - $keys = array_keys($orders); - return $keys[0]; + + return $order; } /** @@ -217,13 +229,21 @@ public function getCurrentOrder() */ public function getCurrentDirection() { - if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) { - $dir = strtolower($dir); - if (in_array($dir, array('asc', 'desc'))) { - return $dir; - } + $directions = array('asc', 'desc'); + $dir = strtolower($this->getRequest()->getParam($this->getDirectionVarName())); + if ($dir && in_array($dir, $directions)) { + Mage::getSingleton('catalog/session')->setSortDirection($dir); + } + else { + $dir = Mage::getSingleton('catalog/session')->getSortDirection(); } - return $this->_direction; + + // validate direction + if (!$dir || !in_array($dir, $directions)) { + $dir = $this->_direction; + } + + return $dir; } /** diff --git a/app/code/core/Mage/Catalog/Model/Category.php b/app/code/core/Mage/Catalog/Model/Category.php index 6ab57def9b..1e31b2a3d3 100644 --- a/app/code/core/Mage/Catalog/Model/Category.php +++ b/app/code/core/Mage/Catalog/Model/Category.php @@ -810,4 +810,15 @@ public function getDefaultSortBy() { return $sortBy; } + + /** + * Validate attribute values + * + * @throws Mage_Eav_Model_Entity_Attribute_Exception + * @return bool|array + */ + public function validate() + { + return $this->_getResource()->validate($this); + } } diff --git a/app/code/core/Mage/Catalog/Model/Category/Api.php b/app/code/core/Mage/Catalog/Model/Category/Api.php index 145199ea26..4f0898aea7 100644 --- a/app/code/core/Mage/Catalog/Model/Category/Api.php +++ b/app/code/core/Mage/Catalog/Model/Category/Api.php @@ -236,13 +236,10 @@ public function info($categoryId, $store = null, $attributes = null) */ public function create($parentId, $categoryData, $store = null) { - $parent_category = $this->_initCategory($parentId); - + $parent_category = $this->_initCategory($parentId); $category = Mage::getModel('catalog/category') ->setStoreId($this->_getStoreId($store)); - - $category->addData(array('path'=>implode('/',$parent_category->getPathIds()))); $category ->setAttributeSetId($category->getDefaultAttributeSetId()); @@ -257,10 +254,25 @@ public function create($parentId, $categoryData, $store = null) ); } } + $category->setParentId($parent_category->getId()); + try { + $validate = $category->validate(); + if ($validate !== true) { + foreach ($validate as $code => $error) { + if ($error === true) { + Mage::throwException(Mage::helper('catalog')->__('Attribute "%s" is required', $code)); + } + else { + Mage::throwException($error); + } + } + } + $category->save(); - } catch (Mage_Core_Exception $e) { + } + catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } @@ -290,8 +302,21 @@ public function update($categoryId, $categoryData, $store = null) } try { + $validate = $category->validate(); + if ($validate !== true) { + foreach ($validate as $code => $error) { + if ($error === true) { + Mage::throwException(Mage::helper('catalog')->__('Attribute "%s" is required', $code)); + } + else { + Mage::throwException($error); + } + } + } + $category->save(); - } catch (Mage_Core_Exception $e) { + } + catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } diff --git a/app/code/core/Mage/Catalog/Model/Category/Api/V2.php b/app/code/core/Mage/Catalog/Model/Category/Api/V2.php index 7f7f8cc48d..7e301f6af1 100644 --- a/app/code/core/Mage/Catalog/Model/Category/Api/V2.php +++ b/app/code/core/Mage/Catalog/Model/Category/Api/V2.php @@ -96,8 +96,21 @@ public function create($parentId, $categoryData, $store = null) } $category->setParentId($parent_category->getId()); try { + $validate = $category->validate(); + if ($validate !== true) { + foreach ($validate as $code => $error) { + if ($error === true) { + Mage::throwException(Mage::helper('catalog')->__('Attribute "%s" is required', $code)); + } + else { + Mage::throwException($error); + } + } + } + $category->save(); - } catch (Mage_Core_Exception $e) { + } + catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } @@ -128,8 +141,20 @@ public function update($categoryId, $categoryData, $store = null) } try { + $validate = $category->validate(); + if ($validate !== true) { + foreach ($validate as $code => $error) { + if ($error === true) { + Mage::throwException(Mage::helper('catalog')->__('Attribute "%s" is required', $code)); + } + else { + Mage::throwException($error); + } + } + } $category->save(); - } catch (Mage_Core_Exception $e) { + } + catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } diff --git a/app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php b/app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php index 9a3312dea5..5ffebf2fd7 100644 --- a/app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php @@ -79,6 +79,16 @@ public function getResetValue() return null; } + /** + * Retrieve filter value for Clear All Items filter state + * + * @return mixed + */ + public function getCleanValue() + { + return null; + } + /** * Apply filter to collection * diff --git a/app/code/core/Mage/Catalog/Model/Product.php b/app/code/core/Mage/Catalog/Model/Product.php index 3bbcb2c8c2..8a107c438a 100644 --- a/app/code/core/Mage/Catalog/Model/Product.php +++ b/app/code/core/Mage/Catalog/Model/Product.php @@ -149,7 +149,9 @@ public function getUrlModel() */ public function validate() { + Mage::dispatchEvent($this->_eventPrefix.'_validate_before', array($this->_eventObject=>$this)); $this->_getResource()->validate($this); + Mage::dispatchEvent($this->_eventPrefix.'_validate_after', array($this->_eventObject=>$this)); return $this; } diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Tierprice.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Tierprice.php index 4225368cde..e1274eb12e 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Tierprice.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Tierprice.php @@ -149,9 +149,9 @@ public function afterLoad($object) $data = $this->_getResource() ->loadProductPrices($object, $this->getAttribute()); foreach ($data as $k => $v) { + $data[$k]['website_price'] = $v['price']; if ($v['all_groups']) { $data[$k]['cust_group'] = Mage_Customer_Model_Group::CUST_GROUP_ALL; - $data[$k]['website_price'] = $v['price']; } } diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api/V2.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api/V2.php index 1ec76bdb17..7f00e2b8af 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api/V2.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api/V2.php @@ -88,12 +88,12 @@ public function create($productId, $data, $store = null) $tmpDirectory = Mage::getBaseDir('var') . DS . 'api' . DS . $this->_getSession()->getSessionId(); - if (isset($data['file']['name']) && $data['file']['name']) { - $fileName = $data['file']['name']; + if (isset($data->file->name) && $data->file->name) { + $fileName = $data->file->name; } else { $fileName = 'image'; } - $fileName .= '.' . $this->_mimeTypes[$data['file']['mime']]; + $fileName .= '.' . $this->_mimeTypes[$data->file->mime]; $ioAdapter = new Varien_Io_File(); try { diff --git a/app/code/core/Mage/Catalog/Model/Product/Image.php b/app/code/core/Mage/Catalog/Model/Product/Image.php index c7d497cf86..2db9c23f61 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Image.php +++ b/app/code/core/Mage/Catalog/Model/Product/Image.php @@ -187,6 +187,9 @@ protected function _getNeedMemoryForFile($file = null) $imageInfo = getimagesize($file); + if (!isset($imageInfo[0]) || !isset($imageInfo[1])) { + return 0; + } if (!isset($imageInfo['channels'])) { // if there is no info about this parameter lets set it for maximum $imageInfo['channels'] = 4; diff --git a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php index c27042ebbc..8950030fe3 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php +++ b/app/code/core/Mage/Catalog/Model/Product/Option/Type/Date.php @@ -131,7 +131,7 @@ public function prepareForCart() } $date = new Zend_Date($timestamp); - $result = $date->toString(Varien_date::DATETIME_INTERNAL_FORMAT); + $result = $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT); // Save date in internal format to avoid locale date bugs $this->_setInternalInRequest($result); diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category.php index 39119317d9..98672da76b 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category.php @@ -559,6 +559,93 @@ protected function _getIsActiveAttributeId() return $this->_isActiveAttributeId; } + /** + * Refresh Category Product Index for Store Root Catgory + * + * @param array|int $productIds + * @param array|int $storeIds + * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category + */ + protected function _refreshRootCategoryProductIndex($productIds = array(), $storeIds = array()) + { + if (is_numeric($storeIds)) { + $storeIds = array($storeIds); + } + elseif (!is_array($storeIds) || empty($storeIds)) { + $storeIds = array(); + foreach (Mage::app()->getStores() as $store) { + $storeIds[] = $store->getId(); + } + } + + /** + * Prepare visibility and status attributes information + */ + $status = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'status'); + $visibility = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'visibility'); + $statusTable = $status->getBackend()->getTable(); + $visibilityTable = $visibility->getBackend()->getTable(); + + $indexTable = $this->getTable('catalog/category_product_index'); + + foreach ($storeIds as $storeId) { + $store = Mage::app()->getStore($storeId); + $categoryId = $store->getRootCategoryId(); + + $select = $this->_getWriteAdapter()->select() + ->from(array('e' => $this->getTable('catalog/product')), null) + ->joinLeft( + array('i' => $indexTable), + 'e.entity_id=i.product_id AND i.category_id=' . (int)$categoryId + . ' AND i.store_id=' . (int) $storeId, + array()) + ->joinInner( + array('pw' => $this->getTable('catalog/product_website')), + 'e.entity_id=pw.product_id AND pw.website_id=' . (int)$store->getWebsiteId(), + array()) + ->join( + array('t_v_default' => $visibilityTable), + 't_v_default.entity_id=e.entity_id' + . ' AND t_v_default.attribute_id=' . (int)$visibility->getAttributeId() + . ' AND t_v_default.store_id=0', + array()) + ->joinLeft( + array('t_v' => $visibilityTable), + 't_v.entity_id=e.entity_id' + . ' AND t_v.attribute_id=' . (int)$visibility->getAttributeId() + . ' AND t_v.store_id='. (int)$storeId, + array()) + ->join( + array('t_s_default' => $statusTable), + 't_s_default.entity_id=e.entity_id' + . ' AND t_s_default.attribute_id=' . (int)$status->getAttributeId() + . ' AND t_s_default.store_id=0', + array()) + ->joinLeft( + array('t_s' => $statusTable), + 't_s.entity_id=e.entity_id' + . ' AND t_s.attribute_id=' . (int)$status->getAttributeId() + . ' AND t_s.store_id='. (int)$storeId, + array()) + ->where('i.product_id IS NULL') + ->where('IFNULL(t_s.value, t_s_default.value)=?', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); + + $select->columns(new Zend_Db_Expr($categoryId)); + $select->columns('e.entity_id'); + $select->columns(new Zend_Db_Expr(0)); + $select->columns(new Zend_Db_Expr(0)); + $select->columns(new Zend_Db_Expr($storeId)); + $select->columns(new Zend_Db_Expr('IFNULL(t_v.value, t_v_default.value)')); + + if (!empty($productIds)) { + $select->where('e.entity_id IN(?)', $productIds); + } + + $this->_getWriteAdapter()->query($select->insertFromSelect($indexTable)); + } + return $this; + } + /** * Rebuild associated products index * @@ -683,6 +770,8 @@ public function refreshProductIndex($categoryIds = array(), $productIds = array( $this->_getWriteAdapter()->query($query); } + + $this->_refreshRootCategoryProductIndex($productIds, array($storeId)); } return $this; } diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Flat.php index 658d80e838..d2ecb36c67 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Flat.php @@ -401,22 +401,22 @@ protected function _getTableSqlSchema($storeId = 0) */ public function rebuild() { - $_read = $this->_getReadAdapter(); + $_conn = $this->_getWriteAdapter(); if ($this->getUseStoreTables()) { $stores = array(); - $selectStores = $_read->select() + $selectStores = $_conn->select() ->from($this->getTable('core/store'), 'store_id'); $stores = array(); - foreach ($_read->fetchAll($selectStores) as $store) { + foreach ($_conn->fetchAll($selectStores) as $store) { $stores[] = $store['store_id']; } $this->_createTable($stores); } else { $this->_createTable(0); } - $select = $this->_getReadAdapter()->select() + $select = $_conn->select() ->from($this->getTable('catalog/category'), 'entity_id'); - $_categories = $this->_getReadAdapter()->fetchAll($select); + $_categories = $_conn->fetchAll($select); foreach ($_categories as $_category) { foreach ($stores as $store) { $_tmpCategory = Mage::getModel('catalog/category') @@ -453,18 +453,17 @@ protected function _createTable($stores) if (!is_array($stores)) { $stores = (int) $stores; } - $_read = $this->_getReadAdapter(); - $_write = $this->_getWriteAdapter(); + $_conn = $this->_getWriteAdapter(); if ($this->getUseStoreTables() && is_array($stores)) { foreach ($stores as $store) { - $_read->query("DROP TABLE IF EXISTS `{$this->getMainStoreTable($store)}`"); - $_read->query($this->_getTableSqlSchema($store)); + $_conn->query("DROP TABLE IF EXISTS `{$this->getMainStoreTable($store)}`"); + $_conn->query($this->_getTableSqlSchema($store)); } } else { - $_read->query("DROP TABLE IF EXISTS `{$this->getMainStoreTable($stores)}`"); - $_read->query($this->_getTableSqlSchema($stores)); + $_conn->query("DROP TABLE IF EXISTS `{$this->getMainStoreTable($stores)}`"); + $_conn->query($this->_getTableSqlSchema($stores)); } - $selectAttribute = $_read->select() + $selectAttribute = $_conn->select() ->from($this->getTable('eav/entity_type'), array()) ->join( $this->getTable('eav/attribute'), @@ -472,7 +471,7 @@ protected function _createTable($stores) $this->getTable('eav/attribute').'.*' ) ->where($this->getTable('eav/entity_type').'.entity_type_code=?', 'catalog_category'); - $resultAttribute = $_read->fetchAll($selectAttribute); + $resultAttribute = $_conn->fetchAll($selectAttribute); foreach ($resultAttribute as $attribute) { $type = ''; switch ($attribute['backend_type']) { @@ -495,10 +494,10 @@ protected function _createTable($stores) if ($type) { if ($this->getUseStoreTables() && is_array($stores)) { foreach ($stores as $store) { - $_write->addColumn($this->getMainStoreTable($store), $attribute['attribute_code'], $type); + $_conn->addColumn($this->getMainStoreTable($store), $attribute['attribute_code'], $type); } } else { - $_write->addColumn($this->getMainStoreTable($stores), $attribute['attribute_code'], $type); + $_conn->addColumn($this->getMainStoreTable($stores), $attribute['attribute_code'], $type); } } } @@ -529,7 +528,7 @@ protected function _deleteTable($stores) $stores = array($stores); } foreach ($stores as $store) { - $_tableExist = $this->_getReadAdapter()->query( + $_tableExist = $this->_getWriteAdapter()->query( "DROP TABLE IF EXISTS `{$this->getMainStoreTable($store)}`" ); } @@ -546,10 +545,10 @@ protected function _deleteTable($stores) protected function _synchronize($category, $action = null) { if (is_null($action)) { - $select = $this->_getReadAdapter()->select() + $select = $this->_getWriteAdapter()->select() ->from($this->getMainStoreTable($category->getStoreId()), 'entity_id') ->where('entity_id = ?', $category->getId()); - if ($result = $this->_getReadAdapter()->fetchOne($select)) { + if ($result = $this->_getWriteAdapter()->fetchOne($select)) { $action = 'update'; } else { $action = 'insert'; @@ -561,7 +560,7 @@ protected function _synchronize($category, $action = null) $this->_getWriteAdapter()->update( $this->getMainStoreTable($category->getStoreId()), $this->_prepareDataForAllFields($category), - $this->_getReadAdapter()->quoteInto('entity_id = ?', $category->getId()) + $this->_getWriteAdapter()->quoteInto('entity_id = ?', $category->getId()) ); } elseif ($action == 'insert') { // insert @@ -591,9 +590,9 @@ protected function _move($prevParentPath, $parentPath) 'children_count', 'updated_at' ); - $select = $this->_getReadAdapter()->select() + $select = $this->_getWriteAdapter()->select() ->from($this->getTable('core/store'), 'store_id'); - $stores = $this->_getReadAdapter()->fetchAll($select); + $stores = $this->_getWriteAdapter()->fetchAll($select); foreach ($stores as $store) { $update = "UPDATE {$this->getMainStoreTable($store['store_id'])}, {$this->getTable('catalog/category')} SET"; foreach ($_staticFields as $field) { @@ -620,11 +619,11 @@ public function synchronize($category = null, $storeIds = array()) if (is_null($category)) { $storesCondition = ''; if (!empty($storeIds)) { - $storesCondition = $this->_getReadAdapter()->quoteInto( + $storesCondition = $this->_getWriteAdapter()->quoteInto( ' AND s.store_id IN (?)', $storeIds ); } - $stores = $this->_getReadAdapter()->fetchAll(" + $stores = $this->_getWriteAdapter()->fetchAll(" SELECT s.store_id, s.website_id, c.path AS root_path FROM @@ -637,17 +636,17 @@ public function synchronize($category = null, $storeIds = array()) {$storesCondition} "); foreach ($stores as $store) { - $select = $this->_getReadAdapter()->select() + $select = $this->_getWriteAdapter()->select() ->from($this->getTable('catalog/category'), 'entity_id') ->where('path LIKE ?', "{$store['root_path']}/%") ->orWhere('path = ?', $store['root_path']); - $_categories = $this->_getReadAdapter()->fetchAll($select); - if (!$this->_getReadAdapter()->showTableStatus($this->getMainStoreTable($store['store_id']))) { + $_categories = $this->_getWriteAdapter()->fetchAll($select); + if (!$this->_getWriteAdapter()->showTableStatus($this->getMainStoreTable($store['store_id']))) { $this->_createTable($store['store_id']); } $this->_getWriteAdapter()->delete( $this->getMainStoreTable($store['store_id']), - $this->_getReadAdapter()->quoteInto('store_id = ?', $store['store_id']) + $this->_getWriteAdapter()->quoteInto('store_id = ?', $store['store_id']) ); foreach ($_categories as $_category) { $_tmpCategory = Mage::getModel('catalog/category') @@ -700,10 +699,10 @@ public function move($categoryId, $prevParentId, $parentId) foreach ($prevParent->getStoreIds() as $storeId) { $this->_getWriteAdapter()->delete( $this->getMainStoreTable($storeId), - $this->_getReadAdapter()->quoteInto('entity_id = ?', $categoryId) + $this->_getWriteAdapter()->quoteInto('entity_id = ?', $categoryId) ); } - $categoryPath = $this->_getReadAdapter()->fetchOne(" + $categoryPath = $this->_getWriteAdapter()->fetchOne(" SELECT path FROM @@ -711,11 +710,11 @@ public function move($categoryId, $prevParentId, $parentId) WHERE entity_id = '$categoryId' "); - $select = $this->_getReadAdapter()->select() + $select = $this->_getWriteAdapter()->select() ->from($this->getTable('catalog/category'), 'entity_id') ->where('path LIKE ?', "$categoryPath/%") ->orWhere('path = ?', $categoryPath); - $_categories = $this->_getReadAdapter()->fetchAll($select); + $_categories = $this->_getWriteAdapter()->fetchAll($select); foreach ($_categories as $_category) { foreach ($parent->getStoreIds() as $storeId) { $_tmpCategory = Mage::getModel('catalog/category') @@ -757,7 +756,7 @@ public function move($categoryId, $prevParentId, $parentId) */ protected function _prepareDataForAllFields($category, $replaceFields = array()) { - $table = $this->_getReadAdapter()->describeTable($this->getMainStoreTable($category->getStoreId())); + $table = $this->_getWriteAdapter()->describeTable($this->getMainStoreTable($category->getStoreId())); $data = array(); foreach ($table as $column=>$columnData) { if (null !== $category->getData($column)) { diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product.php index 15b68e7aaf..1160709652 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product.php @@ -136,7 +136,7 @@ protected function _afterSave(Varien_Object $product) ->refreshIndex($product); parent::_afterSave($product); - return $this; + return $this; } /** @@ -234,6 +234,12 @@ protected function _saveCategories(Varien_Object $object) return $this; } + /** + * Refresh Product Enabled Index + * + * @param Mage_Catalog_Model_Product $product + * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product + */ public function refreshIndex($product) { /** @@ -265,7 +271,20 @@ public function refreshIndex($product) $indexCategoryIds = array_unique($indexCategoryIds); $indexProductIds = array($product->getId()); - Mage::getResourceSingleton('catalog/category')->refreshProductIndex($indexCategoryIds, $indexProductIds); + Mage::getResourceSingleton('catalog/category') + ->refreshProductIndex($indexCategoryIds, $indexProductIds); + } + else { + $websites = $product->getWebsiteIds(); + if ($websites) { + $storeIds = array(); + foreach ($websites as $websiteId) { + $website = Mage::app()->getWebsite($websiteId); + $storeIds = array_merge($storeIds, $website->getStoreIds()); + } + Mage::getResourceSingleton('catalog/category') + ->refreshProductIndex(array(), array($product->getId()), $storeIds); + } } /** @@ -311,8 +330,8 @@ public function refreshEnabledIndex($store=null, $product=null) ); $deleteCondition = $this->_getWriteAdapter()->quoteInto(' AND product_id IN (?)', $product); } - $this->_getWriteAdapter()->delete($indexTable, 'store_id='.$storeId.$deleteCondition); - $query = "INSERT INTO $indexTable + $this->_getWriteAdapter()->delete($indexTable, 'store_id='.$storeId.$deleteCondition); + $query = "INSERT INTO $indexTable SELECT t_v_default.entity_id, {$storeId}, IFNULL(t_v.value, t_v_default.value) FROM @@ -335,12 +354,12 @@ public function refreshEnabledIndex($store=null, $product=null) t_v_default.attribute_id='{$visibilityAttributeId}' AND t_v_default.store_id=0{$productsCondition} AND (IFNULL(t_s.value, t_s_default.value)=".Mage_Catalog_Model_Product_Status::STATUS_ENABLED.")"; - $this->_getWriteAdapter()->query($query); + $this->_getWriteAdapter()->query($query); } elseif (is_null($store)) { foreach ($product->getStoreIds() as $storeId) { - $store = Mage::app()->getStore($storeId); - $this->refreshEnabledIndex($store, $product); + $store = Mage::app()->getStore($storeId); + $this->refreshEnabledIndex($store, $product); } } else { diff --git a/app/code/core/Mage/Catalog/etc/wsdl.xml b/app/code/core/Mage/Catalog/etc/wsdl.xml index 9f372552ee..73b8ebd58f 100644 --- a/app/code/core/Mage/Catalog/etc/wsdl.xml +++ b/app/code/core/Mage/Catalog/etc/wsdl.xml @@ -319,6 +319,7 @@ + diff --git a/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-install-0.7.0.php index 296329ee45..e33a0b1e20 100644 --- a/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-install-0.7.0.php +++ b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-install-0.7.0.php @@ -500,8 +500,6 @@ insert into {$this->getTable('catalog_product_visibility')}(`visibility_id`,`visibility_code`) values (1,'Nowhere'),(2,'Catalog'),(3,'Search'),(4,'Catalog, Search'); -insert into {$this->getTable('core_email_template')}(`template_id`,`template_code`,`template_text`,`template_type`,`template_subject`,`template_sender_name`,`template_sender_email`,`added_at`,`modified_at`) values (NULL,'Send product to a friend','Welcome, {{var name}}

Please look at {{var product.name}}

Here is message:
{{var message}}

',2,'Welcome, {{var name}}',NULL,NULL,NOW(),NOW()); - ALTER TABLE `{$this->getTable('catalog_category_entity')}` ADD `path` VARCHAR( 255 ) NOT NULL, ADD `position` INT NOT NULL; ALTER TABLE `{$installer->getTable('catalog_category_entity')}` ADD `level` INT NOT NULL; diff --git a/app/code/core/Mage/CatalogIndex/Model/Observer.php b/app/code/core/Mage/CatalogIndex/Model/Observer.php index e1f16e5c37..bfb5881e31 100644 --- a/app/code/core/Mage/CatalogIndex/Model/Observer.php +++ b/app/code/core/Mage/CatalogIndex/Model/Observer.php @@ -184,7 +184,7 @@ public function processAttributeChangeEvent(Varien_Event_Observer $observer) /** * @todo add flag to attribute model which will notify what options was changed */ - $attribute = $observer->getAttribute(); + $attribute = $observer->getEvent()->getAttribute(); $tags = array( Mage_Eav_Model_Entity_Attribute::CACHE_TAG.':'.$attribute->getId() ); @@ -269,6 +269,9 @@ public function cleanCache(Varien_Event_Observer $observer) public function catalogCategorySaveAfter(Varien_Event_Observer $observer) { $category = $observer->getEvent()->getCategory(); + if ($category->getInitialSetupFlag()) { + return $this; + } $tags = array( Mage_Catalog_Model_Category::CACHE_TAG.':'.$category->getPath() ); diff --git a/app/code/core/Mage/CatalogRule/Model/Observer.php b/app/code/core/Mage/CatalogRule/Model/Observer.php index 1adedd63e7..d93740c0a4 100644 --- a/app/code/core/Mage/CatalogRule/Model/Observer.php +++ b/app/code/core/Mage/CatalogRule/Model/Observer.php @@ -87,19 +87,19 @@ public function processFrontFinalPrice($observer) $storeId = $product->getStoreId(); if ($observer->hasDate()) { - $date = $observer->getDate(); + $date = $observer->getEvent()->getDate(); } else { $date = Mage::app()->getLocale()->storeTimeStamp($storeId); } if ($observer->hasWebsiteId()) { - $wId = $observer->getWebsiteId(); + $wId = $observer->getEvent()->getWebsiteId(); } else { $wId = Mage::app()->getStore($storeId)->getWebsiteId(); } if ($observer->hasCustomerGroupId()) { - $gId = $observer->getCustomerGroupId(); + $gId = $observer->getEvent()->getCustomerGroupId(); } else { $gId = Mage::getSingleton('customer/session')->getCustomerGroupId(); } diff --git a/app/code/core/Mage/CatalogSearch/Helper/Data.php b/app/code/core/Mage/CatalogSearch/Helper/Data.php index 0c19e426f2..c8087a96ee 100644 --- a/app/code/core/Mage/CatalogSearch/Helper/Data.php +++ b/app/code/core/Mage/CatalogSearch/Helper/Data.php @@ -116,6 +116,8 @@ public function getQueryText() $this->_queryText = null; } $this->_queryText = trim($this->_queryText); + $this->_queryText = Mage::helper('core/string')->cleanString($this->_queryText); + if (Mage::helper('core/string')->strlen($this->_queryText) > $this->getMaxQueryLength()) { $this->_queryText = Mage::helper('core/string')->substr( $this->_queryText, diff --git a/app/code/core/Mage/CatalogSearch/controllers/ResultController.php b/app/code/core/Mage/CatalogSearch/controllers/ResultController.php index 854ce15eb3..647d07851e 100644 --- a/app/code/core/Mage/CatalogSearch/controllers/ResultController.php +++ b/app/code/core/Mage/CatalogSearch/controllers/ResultController.php @@ -76,6 +76,7 @@ public function indexAction() $this->loadLayout(); $this->_initLayoutMessages('catalog/session'); + $this->_initLayoutMessages('checkout/session'); $this->renderLayout(); if (!Mage::helper('catalogSearch')->isMinQueryLength()) { diff --git a/app/code/core/Mage/Checkout/Model/Session.php b/app/code/core/Mage/Checkout/Model/Session.php index edff7172b8..6837502601 100644 --- a/app/code/core/Mage/Checkout/Model/Session.php +++ b/app/code/core/Mage/Checkout/Model/Session.php @@ -82,8 +82,8 @@ public function getQuote() $this->_quote = $quote; } - if (isset($_SERVER['REMOTE_ADDR'])) { - $this->_quote->setRemoteIp($_SERVER['REMOTE_ADDR']); + if ($remoteAddr = Mage::helper('core/http')->getRemoteAddr()) { + $this->_quote->setRemoteIp($remoteAddr); } return $this->_quote; } diff --git a/app/code/core/Mage/Checkout/controllers/OnepageController.php b/app/code/core/Mage/Checkout/controllers/OnepageController.php index f5a056fe22..b5f9a73faa 100644 --- a/app/code/core/Mage/Checkout/controllers/OnepageController.php +++ b/app/code/core/Mage/Checkout/controllers/OnepageController.php @@ -27,6 +27,12 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action { + protected $_sectionUpdateFunctions = array( + 'payment-method' => '_getPaymentMethodsHtml', + 'shipping-method' => '_getShippingMethodsHtml', + 'review' => '_getReviewHtml', + ); + /** * @return Mage_Checkout_OnepageController */ @@ -100,6 +106,11 @@ protected function _getAdditionalHtml() return $output; } + protected function _getReviewHtml() + { + return $this->getLayout()->getBlock('root')->toHtml(); + } + /** * Enter description here... * @@ -349,7 +360,7 @@ public function savePaymentAction() $result['goto_section'] = 'review'; $result['update_section'] = array( 'name' => 'review', - 'html' => $this->getLayout()->getBlock('root')->toHtml() + 'html' => $this->_getReviewHtml() ); // $result['review_html'] = $this->getLayout()->getBlock('root')->toHtml(); @@ -393,6 +404,23 @@ public function saveOrderAction() $result['success'] = false; $result['error'] = true; $result['error_messages'] = $e->getMessage(); + + if ($gotoSection = $this->getOnepage()->getCheckout()->getGotoSection()) { + $result['goto_section'] = $gotoSection; + $this->getOnepage()->getCheckout()->setGotoSection(null); + } + + if ($updateSection = $this->getOnepage()->getCheckout()->getUpdateSection()) { + if (isset($this->_sectionUpdateFunctions[$updateSection])) { + $updateSectionFunction = $this->_sectionUpdateFunctions[$updateSection]; + $result['update_section'] = array( + 'name' => $updateSection, + 'html' => $this->$updateSectionFunction() + ); + } + $this->getOnepage()->getCheckout()->setUpdateSection(null); + } + $this->getOnepage()->getQuote()->save(); } catch (Exception $e) { diff --git a/app/code/core/Mage/Compiler/Model/Process.php b/app/code/core/Mage/Compiler/Model/Process.php index aff3b9ec28..a7c195bd0b 100644 --- a/app/code/core/Mage/Compiler/Model/Process.php +++ b/app/code/core/Mage/Compiler/Model/Process.php @@ -41,6 +41,8 @@ class Mage_Compiler_Model_Process protected $_includePaths = array(); protected $_processedClasses= array(); + protected $_controllerFolders = array(); + public function __construct($options=array()) { if (isset($options['compile_dir'])) { @@ -102,6 +104,7 @@ protected function _copy($source, $target, $firstIteration = true) } $sourceFile = $source . DS . $file; if ($file == 'controllers') { + $this->_controllerFolders[] = $sourceFile; continue; } @@ -143,6 +146,57 @@ protected function _copyZendLocaleData($destDir) return $this; } + /** + * Copy controllers with folders structure + * + * @param string $basePath base include path where files are located + * @return Mage_Compiler_Model_Process + */ + protected function _copyControllers($basePath) + { + foreach ($this->_controllerFolders as $path) { + $relPath = str_replace($basePath, '', $path); + $relPath = trim($relPath, DS); + $arrDirs = explode(DS, $relPath); + $destPath = $this->_includeDir; + foreach ($arrDirs as $dir) { + $destPath.= DS.$dir; + $this->_mkdir($destPath); + } + $this->_copyAll($path, $destPath); + } + return $this; + } + + /** + * Copy all files and subfolders + * + * @param string $source + * @param string $target + * @return Mage_Compiler_Model_Process + */ + protected function _copyAll($source, $target) + { + if (is_dir($source)) { + $this->_mkdir($target); + $dir = dir($source); + while (false !== ($file = $dir->read())) { + if (($file[0] == '.')) { + continue; + } + $sourceFile = $source . DS . $file; + $targetFile = $target . DS . $file; + $this->_copyAll($sourceFile, $targetFile); + } + } else { + if (!in_array(substr($source, strlen($source)-4, 4), array('.php'))) { + return $this; + } + copy($source, $target); + } + return $this; + } + /** * Create directory if not exist * @@ -159,7 +213,8 @@ protected function _mkdir($dir) } /** - * Copy files from all include directories to one + * Copy files from all include directories to one. + * Lib files and controllers files will be copied as is * * @return Mage_Compiler_Model_Process */ @@ -168,10 +223,16 @@ protected function _collectFiles() $paths = $this->_getIncludePaths(); $paths = array_reverse($paths); $destDir= $this->_includeDir; + $libDir = Mage::getBaseDir('lib'); $this->_mkdir($destDir); foreach ($paths as $path) { + $this->_controllerFolders = array(); $this->_copy($path, $destDir); + $this->_copyControllers($path); + if ($path == $libDir) { + $this->_copyAll($libDir, $destDir); + } } $destDir.= DS.'Data'; @@ -370,7 +431,7 @@ public function validate() { $result = array(); if (!is_writeable($this->_compileDir)) { - $result[] = Mage::helper('compiler')->__('Directory "%s" must be writeable', $this->_includeDir); + $result[] = Mage::helper('compiler')->__('Directory "%s" must be writeable', $this->_compileDir); } $file = $this->_compileDir.DS.'config.php'; if (!is_writeable($file)) { diff --git a/app/code/core/Mage/Compiler/controllers/ProcessController.php b/app/code/core/Mage/Compiler/controllers/ProcessController.php index 6edeef4411..480737aef9 100644 --- a/app/code/core/Mage/Compiler/controllers/ProcessController.php +++ b/app/code/core/Mage/Compiler/controllers/ProcessController.php @@ -105,6 +105,6 @@ public function enableAction() protected function _isAllowed() { - return Mage::getSingleton('admin/session')->isAllowed('compiler'); + return Mage::getSingleton('admin/session')->isAllowed('system/tools/compiler'); } } \ No newline at end of file diff --git a/app/code/core/Mage/Core/Controller/Front/Action.php b/app/code/core/Mage/Core/Controller/Front/Action.php index 931534b38d..81a36e3f7b 100644 --- a/app/code/core/Mage/Core/Controller/Front/Action.php +++ b/app/code/core/Mage/Core/Controller/Front/Action.php @@ -55,7 +55,7 @@ public function postDispatch() { parent::postDispatch(); if (!$this->getFlag('', self::FLAG_NO_START_SESSION )) { - Mage::getSingleton('core/session')->setLastUrl(Mage::getUrl('*/*/*'), array('_current'=>true)); + Mage::getSingleton('core/session')->setLastUrl(Mage::getUrl('*/*/*', array('_current'=>true))); } return $this; } diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php index eb39dfcb20..72f3e3e7ad 100644 --- a/app/code/core/Mage/Core/Controller/Request/Http.php +++ b/app/code/core/Mage/Core/Controller/Request/Http.php @@ -44,6 +44,14 @@ class Mage_Core_Controller_Request_Http extends Zend_Controller_Request_Http protected $_storeCode = null; protected $_requestString = ''; + /** + * Path info array used before applying rewrite from config + * + * @var null || array + */ + protected $_rewritedPathInfo= null; + protected $_requestedRouteName = null; + protected $_route; protected $_directFrontNames = array(); @@ -116,7 +124,8 @@ public function setPathInfo($pathInfo = null) } // Remove the query string from REQUEST_URI - if ($pos = strpos($requestUri, '?')) { + $pos = strpos($requestUri, '?'); + if ($pos) { $requestUri = substr($requestUri, 0, $pos); } @@ -154,6 +163,22 @@ public function setPathInfo($pathInfo = null) return $this; } + /** + * Specify new path info + * It happen when occur rewrite based on configuration + * + * @param string $pathInfo + * @return Mage_Core_Controller_Request_Http + */ + public function rewritePathInfo($pathInfo) + { + if (($pathInfo != $this->getPathInfo()) && ($this->_rewritedPathInfo === null)) { + $this->_rewritedPathInfo = explode('/', trim($this->getPathInfo(), '/')); + } + $this->setPathInfo($pathInfo); + return $this; + } + /** * Check if can be store code as part of url * @@ -292,4 +317,78 @@ public function getControllerModule() { return $this->_controllerModule; } + + /** + * Retrieve the module name + * + * @return string + */ + public function getModuleName() + { + return $this->_module; + } + /** + * Retrieve the controller name + * + * @return string + */ + public function getControllerName() + { + return $this->_controller; + } + /** + * Retrieve the action name + * + * @return string + */ + public function getActionName() + { + return $this->_action; + } + + /** + * Get route name used in request (ignore rewrite) + * + * @return string + */ + public function getRequestedRouteName() + { + if ($this->_requestedRouteName === null) { + if ($this->_rewritedPathInfo !== null && isset($this->_rewritedPathInfo[0])) { + $fronName = $this->_rewritedPathInfo[0]; + $router = Mage::app()->getFrontController()->getRouterByFrontName($fronName); + $this->_requestedRouteName = $router->getRouteByFrontName($fronName); + } else { + // no rewritten path found, use default route name + return $this->getRouteName(); + } + } + return $this->_requestedRouteName; + } + + /** + * Get controller name used in request (ignore rewrite) + * + * @return string + */ + public function getRequestedControllerName() + { + if (($this->_rewritedPathInfo !== null) && isset($this->_rewritedPathInfo[1])) { + return $this->_rewritedPathInfo[1]; + } + return $this->getControllerName(); + } + + /** + * Get action name used in request (ignore rewrite) + * + * @return string + */ + public function getRequestedActionName() + { + if (($this->_rewritedPathInfo !== null) && isset($this->_rewritedPathInfo[2])) { + return $this->_rewritedPathInfo[2]; + } + return $this->getActionName(); + } } \ No newline at end of file diff --git a/app/code/core/Mage/Core/Controller/Response/Http.php b/app/code/core/Mage/Core/Controller/Response/Http.php index d02a9b46e0..3493815003 100644 --- a/app/code/core/Mage/Core/Controller/Response/Http.php +++ b/app/code/core/Mage/Core/Controller/Response/Http.php @@ -74,4 +74,10 @@ public function sendHeaders() } parent::sendHeaders(); } + + public function sendResponse() + { + Mage::dispatchEvent('http_response_send_before', array('response'=>$this)); + return parent::sendResponse(); + } } \ No newline at end of file diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php index 66661a9970..1454746657 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Action.php +++ b/app/code/core/Mage/Core/Controller/Varien/Action.php @@ -185,9 +185,9 @@ public function setFlag($action, $flag, $value) */ public function getFullActionName($delimiter='_') { - return $this->getRequest()->getRouteName().$delimiter. - $this->getRequest()->getControllerName().$delimiter. - $this->getRequest()->getActionName(); + return $this->getRequest()->getRequestedRouteName().$delimiter. + $this->getRequest()->getRequestedControllerName().$delimiter. + $this->getRequest()->getRequestedActionName(); } /** diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php index e9992b60e7..54ecdf72af 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Front.php +++ b/app/code/core/Mage/Core/Controller/Varien/Front.php @@ -214,6 +214,11 @@ public function getRouterByFrontName($frontName) return $router; } + /** + * Apply configuration rewrites to current url + * + * @return Mage_Core_Controller_Varien_Front + */ public function rewrite() { $request = $this->getRequest(); @@ -227,8 +232,37 @@ public function rewrite() if (empty($from) || empty($to)) { continue; } + $from = $this->_processRewriteUrl($from); + $to = $this->_processRewriteUrl($to); + $pathInfo = preg_replace($from, $to, $request->getPathInfo()); - $request->setPathInfo($pathInfo); + + if (isset($rewrite->complete)) { + $request->setPathInfo($pathInfo); + } else { + $request->rewritePathInfo($pathInfo); + } + } + } + + /** + * Replace route name placeholders in url to front name + * + * @param string $url + * @return string + */ + protected function _processRewriteUrl($url) + { + $startPos = strpos($url, '{'); + if ($startPos!==false) { + $endPos = strpos($url, '}'); + $routeName = substr($url, $startPos+1, $endPos-$startPos-1); + $router = $this->getRouterByRoute($routeName); + if ($router) { + $fronName = $router->getFrontNameByRoute($routeName); + $url = str_replace('{'.$routeName.'}', $fronName, $url); + } } + return $url; } } \ No newline at end of file diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index 54bf76af4f..60945b8c35 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -284,10 +284,11 @@ public function isDevAllowed($storeId=null) $allow = true; $allowedIps = Mage::getStoreConfig('dev/restrict/allow_ips', $storeId); - if (!empty($allowedIps) && isset($_SERVER['REMOTE_ADDR'])) { + $remoteAddr = Mage::helper('core/http')->getRemoteAddr(); + if (!empty($allowedIps) && !empty($remoteAddr)) { $allowedIps = preg_split('#\s*,\s*#', $allowedIps, null, PREG_SPLIT_NO_EMPTY); - if (array_search($_SERVER['REMOTE_ADDR'], $allowedIps)===false - && array_search($_SERVER['HTTP_HOST'], $allowedIps)===false) { + if (array_search($remoteAddr, $allowedIps) === false + && array_search(Mage::helper('core/http')->getHttpHost(), $allowedIps) === false) { $allow = false; } } diff --git a/app/code/core/Mage/Core/Helper/Http.php b/app/code/core/Mage/Core/Helper/Http.php index c868ad20a8..d364883c7a 100644 --- a/app/code/core/Mage/Core/Helper/Http.php +++ b/app/code/core/Mage/Core/Helper/Http.php @@ -18,20 +18,36 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_Rss - * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Core + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * Default rss helper + * Core Http Helper * + * @category Mage + * @package Mage_Core * @author Magento Core Team */ class Mage_Core_Helper_Http extends Mage_Core_Helper_Abstract { - public function authValidate($headers=null) + const XML_NODE_REMOTE_ADDR_HEADERS = 'global/remote_addr_headers'; + + /** + * Remote address cache + * + * @var string + */ + protected $_remoteAddr; + + /** + * Validate and retrieve user and password from HTTP + * + * @return array + */ + public function authValidate($headers = null) { if(!is_null($headers)) { $_SERVER = $headers; @@ -39,6 +55,7 @@ public function authValidate($headers=null) $user = ''; $pass = ''; + // moshe's fix for CGI if (empty($_SERVER['HTTP_AUTHORIZATION'])) { foreach ($_SERVER as $k=>$v) { @@ -64,13 +81,17 @@ public function authValidate($headers=null) list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1))); } - if(!$user || !$pass) { + if (!$user || !$pass) { $this->authFailed(); } return array($user, $pass); } + /** + * Send auth failed Headers and exit + * + */ public function authFailed() { Mage::app()->getResponse() @@ -80,4 +101,165 @@ public function authFailed() ->sendResponse(); exit; } -} \ No newline at end of file + + /** + * Retrieve Remote Addresses Additional check Headers + * + * @return array + */ + public function getRemoteAddrHeaders() + { + $headers = array(); + $element = Mage::getConfig()->getNode(self::XML_NODE_REMOTE_ADDR_HEADERS); + if ($element instanceof Mage_Core_Model_Config_Element) { + foreach ($element->children() as $node) { + $headers[] = (string)$node; + } + } + + return $headers; + } + + /** + * Retrieve Client Remote Address + * + * @param bool $ipToLong converting IP to long format + * @return string IPv4|long + */ + public function getRemoteAddr($ipToLong = false) + { + if (is_null($this->_remoteAddr)) { + $headers = $this->getRemoteAddrHeaders(); + foreach ($headers as $var) { + if ($this->_getRequest()->getServer($var, false)) { + $this->_remoteAddr = $_SERVER[$var]; + break; + } + } + + if (!$this->_remoteAddr) { + $this->_remoteAddr = $this->_getRequest()->getServer('REMOTE_ADDR'); + } + } + + if (!$this->_remoteAddr) { + return false; + } + + return $ipToLong ? ip2long($this->_remoteAddr) : $this->_remoteAddr; + } + + /** + * Retrieve Server IP address + * + * @param bool $ipToLong converting IP to long format + * @return string IPv4|long + */ + public function getServerAddr($ipToLong = false) + { + $address = $this->_getRequest()->getServer('SERVER_ADDR'); + if (!$address) { + return false; + } + return $ipToLong ? ip2long($address) : $address; + } + + /** + * Retrieve HTTP "clean" value + * + * @param string $var + * @param boolean $clean clean non UTF-8 characters + * @return string + */ + protected function _getHttpCleanValue($var, $clean = true) + { + $value = $this->_getRequest()->getServer($var, ''); + if ($clean) { + $value = Mage::helper('core/string')->cleanString($value); + } + + return $value; + } + + /** + * Retrieve HTTP HOST + * + * @param boolean $clean clean non UTF-8 characters + * @return string + */ + public function getHttpHost($clean = true) + { + return $this->_getHttpCleanValue('HTTP_HOST', $clean); + } + + /** + * Retrieve HTTP USER AGENT + * + * @param boolean $clean clean non UTF-8 characters + * @return string + */ + public function getHttpUserAgent($clean = true) + { + return $this->_getHttpCleanValue('HTTP_USER_AGENT', $clean); + } + + /** + * Retrieve HTTP ACCEPT LANGUAGE + * + * @param boolean $clean clean non UTF-8 characters + * @return string + */ + public function getHttpAcceptLanguage($clean = true) + { + return $this->_getHttpCleanValue('HTTP_ACCEPT_LANGUAGE', $clean); + } + + /** + * Retrieve HTTP ACCEPT CHARSET + * + * @param boolean $clean clean non UTF-8 characters + * @return string + */ + public function getHttpAcceptCharset($clean = true) + { + return $this->_getHttpCleanValue('HTTP_ACCEPT_CHARSET', $clean); + } + + /** + * Retrieve HTTP REFERER + * + * @param boolean $clean clean non UTF-8 characters + * @return string + */ + public function getHttpReferer($clean = true) + { + return $this->_getHttpCleanValue('HTTP_REFERER', $clean); + } + + /** + * Returns the REQUEST_URI taking into account + * platform differences between Apache and IIS + * + * @param boolean $clean clean non UTF-8 characters + * @return string + */ + public function getRequestUri($clean = false) + { + $uri = $this->_getRequest()->getRequestUri(); + if ($clean) { + $uri = Mage::helper('core/string')->cleanString($uri); + } + return $uri; + } + + /** + * Validate IP address + * + * @param string $address + * @return boolean + */ + public function validateIpAddr($address) + { + return preg_match('#^(1?\d{1,2}|2([0-4]\d|5[0-5]))(\.(1?\d{1,2}|2([0-4]\d|5[0-5]))){3}$#', $address); + } +} diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index ba872a7c55..5a64ae7fb4 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -254,4 +254,15 @@ function splitWords($str, $uniqueOnly = false, $maxWordLenght = 0, $wordSeparato } return $result; } + + /** + * Clean non UTF-8 characters + * + * @param string $string + * @return string + */ + public function cleanString($string) + { + return iconv(self::ICONV_CHARSET, self::ICONV_CHARSET . '//IGNORE', $string); + } } diff --git a/app/code/core/Mage/Core/Model/Abstract.php b/app/code/core/Mage/Core/Model/Abstract.php index 9273a6446c..40e9e6084e 100644 --- a/app/code/core/Mage/Core/Model/Abstract.php +++ b/app/code/core/Mage/Core/Model/Abstract.php @@ -377,4 +377,4 @@ public function getEntityId() { return $this->_getData('entity_id'); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php index 2a4df7ae5b..eb9b35c0de 100644 --- a/app/code/core/Mage/Core/Model/App.php +++ b/app/code/core/Mage/Core/Model/App.php @@ -704,7 +704,8 @@ public function getDefaultStoreView() { foreach ($this->getWebsites() as $_website) { if ($_website->getIsDefault()) { - if ($_defaultStore = $this->getGroup($_website->getDefaultGroupId())->getDefaultStore()) { + $_defaultStore = $this->getGroup($_website->getDefaultGroupId())->getDefaultStore(); + if ($_defaultStore) { return $_defaultStore; } } @@ -954,7 +955,8 @@ public function getCache() { if (!$this->_cache) { $backend = strtolower((string)Mage::getConfig()->getNode('global/cache/backend')); - if (!$cachePrefix = (string)Mage::getConfig()->getNode('global/cache/prefix')) { + $cachePrefix = (string)Mage::getConfig()->getNode('global/cache/prefix'); + if (!$cachePrefix) { $cachePrefix = md5(Mage::getConfig()->getBaseDir()); } if (extension_loaded('apc') && ini_get('apc.enabled') && $backend == 'apc') { @@ -1001,13 +1003,18 @@ public function getCache() else { $lifetime = 7200; } - $this->_cache = Zend_Cache::factory('Core', $backend, + $this->_cache = Zend_Cache::factory( + 'Core', + $backend, array( 'caching' => true, 'lifetime' => $lifetime, 'automatic_cleaning_factor' => 0, ), - $backendAttributes + $backendAttributes, + false, + false, + true ); } return $this->_cache; @@ -1133,7 +1140,8 @@ public function saveUseCache($data) //Mage::app()->saveCache(serialize($cacheData), 'use_cache', array(), null); $filename = $this->getUseCacheFilename(); - if (!$fp = @fopen($filename, 'w')) { + $fp = @fopen($filename, 'w'); + if (!$fp) { Mage::throwException($filename.' is not writable, unable to save cache settings'); } @fwrite($fp, serialize($data)); @@ -1288,7 +1296,8 @@ public function getUseSessionVar() */ public function getAnyStoreView() { - if ($store = $this->getDefaultStoreView()) { + $store = $this->getDefaultStoreView(); + if ($store) { return $store; } foreach ($this->getStores() as $store) { @@ -1329,4 +1338,34 @@ public function setIsSingleStoreModeAllowed($value) $this->_isSingleStoreAllowed = (bool)$value; return $this; } + + /** + * Prepare array of store groups + * can be filtered to contain default store group or not by $withDefault flag + * depending on flag $codeKey array keys can be group id or group code + * + * @param bool $withDefault + * @param bool $codeKey + * @return array + */ + public function getGroups($withDefault = false, $codeKey = false) + { + $groups = array(); + if (is_array($this->_groups)) { + foreach ($this->_groups as $group) { + if (!$withDefault && $group->getId() == 0) { + continue; + } + if ($codeKey) { + $groups[$group->getCode()] = $group; + } + else { + $groups[$group->getId()] = $group; + } + } + } + + return $groups; + } + } diff --git a/app/code/core/Mage/Core/Model/Email/Template/Filter.php b/app/code/core/Mage/Core/Model/Email/Template/Filter.php index d5a39d0656..3618caa056 100644 --- a/app/code/core/Mage/Core/Model/Email/Template/Filter.php +++ b/app/code/core/Mage/Core/Model/Email/Template/Filter.php @@ -55,6 +55,22 @@ class Mage_Core_Model_Email_Template_Filter extends Varien_Filter_Template */ protected static $_urlInstance; + /** + * Modifier Callbacks + * + * @var array + */ + protected $_modifiers = array('nl2br' => ''); + + /** + * Setup callbacks for filters + * + */ + public function __construct() + { + $this->_modifiers['escape'] = array($this, 'modifierEscape'); + } + /** * Set use absolute links flag * @@ -285,4 +301,76 @@ public function htmlescapeDirective($construction) return Mage::helper('core')->htmlEscape($params['var'], $allowedTags); } + + /** + * Var directive with modifiers support + * + * @param array $construction + * @return string + */ + public function varDirective($construction) + { + if (count($this->_templateVars)==0) { + // If template preprocessing + return $construction[0]; + } + + $parts = explode('|', $construction[2], 2); + if (2 === count($parts)) { + list($variableName, $modifiersString) = $parts; + return $this->_amplifyModifiers($this->_getVariable($variableName, ''), $modifiersString); + } + return $this->_getVariable($construction[2], ''); + } + + /** + * Apply modifiers one by one, with specified params + * + * Modifier syntax: modifier1[:param1:param2:...][|modifier2:...] + * + * @param string $value + * @param string $modifiers + * @return string + */ + protected function _amplifyModifiers($value, $modifiers) + { + foreach (explode('|', $modifiers) as $part) { + if (empty($part)) { + continue; + } + $params = explode(':', $part); + $modifier = array_shift($params); + if (isset($this->_modifiers[$modifier])) { + $callback = $this->_modifiers[$modifier]; + if (!$callback) { + $callback = $modifier; + } + array_unshift($params, $value); + $value = call_user_func_array($callback, $params); + } + } + return $value; + } + + /** + * Escape specified string + * + * @param string $value + * @param string $type + * @return string + */ + public function modifierEscape($value, $type = 'html') + { + switch ($type) { + case 'html': + return htmlspecialchars($value, ENT_QUOTES); + + case 'htmlentities': + return htmlentities($value, ENT_QUOTES); + + case 'url': + return rawurlencode($value); + } + return $value; + } } diff --git a/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php b/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php index d37bf9dbc7..16e8f2febc 100644 --- a/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php +++ b/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php @@ -192,9 +192,21 @@ public function load($printQuery = false, $logQuery = false) Mage::dispatchEvent('core_collection_abstract_load_before', array('collection' => $this)); } parent::load($printQuery, $logQuery); + return $this; + } + + /** + * Redeclare after load method for specifying collection items original data + * + * @return Mage_Core_Model_Mysql4_Collection_Abstract + */ + protected function _afterLoad() + { + parent::_afterLoad(); foreach ($this->_items as $item) { $item->setOrigData(); } + Mage::dispatchEvent('core_collection_abstract_load_after', array('collection' => $this)); return $this; } diff --git a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php index e80d74eedf..cad2ee993e 100644 --- a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php +++ b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php @@ -384,8 +384,8 @@ public function getValidatorData() ); // collect ip data - if (isset($_SERVER['REMOTE_ADDR'])) { - $parts[self::VALIDATOR_REMOTE_ADDR_KEY] = (string)$_SERVER['REMOTE_ADDR']; + if (Mage::helper('core/http')->getRemoteAddr()) { + $parts[self::VALIDATOR_REMOTE_ADDR_KEY] = Mage::helper('core/http')->getRemoteAddr(); } if (isset($_ENV['HTTP_VIA'])) { $parts[self::VALIDATOR_HTTP_VIA_KEY] = (string)$_ENV['HTTP_VIA']; diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php index c24bc53d4d..97c3065685 100644 --- a/app/code/core/Mage/Core/Model/Url.php +++ b/app/code/core/Mage/Core/Model/Url.php @@ -342,7 +342,7 @@ public function setRoutePath($data) $route = array_shift($a); if ('*'===$route) { - $route = $this->getRequest()->getRouteName(); + $route = $this->getRequest()->getRequestedRouteName(); } $this->setRouteName($route); $routePath = $route.'/'; @@ -350,7 +350,7 @@ public function setRoutePath($data) if (!empty($a)) { $controller = array_shift($a); if ('*'===$controller) { - $controller = $this->getRequest()->getControllerName(); + $controller = $this->getRequest()->getRequestedControllerName(); } $this->setControllerName($controller); $routePath .= $controller.'/'; @@ -359,7 +359,7 @@ public function setRoutePath($data) if (!empty($a)) { $action = array_shift($a); if ('*'===$action) { - $action = $this->getRequest()->getActionName(); + $action = $this->getRequest()->getRequestedActionName(); } $this->setActionName($action); $routePath .= $action.'/'; @@ -570,8 +570,8 @@ public function setRouteParams(array $data, $unsetOldParams=true) ) { $this->setQueryParam('___store', $this->getStore()->getCode()); } - unset($data['_store_to_url']); } + unset($data['_store_to_url']); foreach ($data as $k=>$v) { $this->setRouteParam($k, $v); diff --git a/app/code/core/Mage/Customer/Helper/Data.php b/app/code/core/Mage/Customer/Helper/Data.php index efc0cc1374..1dbbfc4294 100644 --- a/app/code/core/Mage/Customer/Helper/Data.php +++ b/app/code/core/Mage/Customer/Helper/Data.php @@ -34,6 +34,11 @@ */ class Mage_Customer_Helper_Data extends Mage_Core_Helper_Abstract { + /** + * Query param name for last url visited + */ + const REFERER_QUERY_PARAM_NAME = 'referer'; + /** * Customer groups collection * @@ -120,7 +125,21 @@ public function customerHasAddresses() */ public function getLoginUrl() { - return $this->_getUrl('customer/account/login'); + $params = array(); + + $referer = $this->_getRequest()->getParam(self::REFERER_QUERY_PARAM_NAME); + + if (!$referer && !Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) { + if (!Mage::getSingleton('customer/session')->getNoReferer()) { + $referer = Mage::getUrl('*/*/*', array('_current' => true)); + $referer = Mage::helper('core')->urlEncode($referer); + } + } + if ($referer) { + $params = array(self::REFERER_QUERY_PARAM_NAME => $referer); + } + + return $this->_getUrl('customer/account/login', $params); } /** @@ -130,7 +149,11 @@ public function getLoginUrl() */ public function getLoginPostUrl() { - return $this->_getUrl('customer/account/loginPost'); + $params = array(); + if ($this->_getRequest()->getParam(self::REFERER_QUERY_PARAM_NAME)) { + $params = array(self::REFERER_QUERY_PARAM_NAME => $this->_getRequest()->getParam(self::REFERER_QUERY_PARAM_NAME)); + } + return $this->_getUrl('customer/account/loginPost', $params); } /** diff --git a/app/code/core/Mage/Customer/Model/Address.php b/app/code/core/Mage/Customer/Model/Address.php index 7272b661e5..d14018b0af 100644 --- a/app/code/core/Mage/Customer/Model/Address.php +++ b/app/code/core/Mage/Customer/Model/Address.php @@ -43,22 +43,23 @@ protected function _construct() /** * Retrieve address customer identifier * - * @return int + * @return integer */ public function getCustomerId() { - return $this->_getResource()->getCustomerId($this); + return $this->_getData('customer_id') ? $this->_getData('customer_id') : $this->getParentId(); } /** * Declare address customer identifier * - * @param unknown_type $id - * @return unknown + * @param integer $id + * @return Mage_Customer_Model_Address */ public function setCustomerId($id) { - $this->_getResource()->setCustomerId($this, $id); + $this->setParentId($id); + $this->setData('customer_id', $id); return $this; } @@ -86,7 +87,7 @@ public function getCustomer() */ public function delete() { - $this->_getResource()->delete($this); + parent::delete(); $this->setData(array()); return $this; } diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php index d76fad57d9..a35571d60a 100644 --- a/app/code/core/Mage/Customer/Model/Customer.php +++ b/app/code/core/Mage/Customer/Model/Customer.php @@ -650,6 +650,7 @@ public function getSharedWebsiteIds() public function setStore(Mage_Core_Model_Store $store) { $this->setStoreId($store->getId()); + $this->setWebsiteId($store->getWebsite()->getId()); return $this; } @@ -1041,4 +1042,15 @@ public function canSkipConfirmation() return $this->getId() && $this->hasSkipConfirmationIfEmail() && strtolower($this->getSkipConfirmationIfEmail()) === strtolower($this->getEmail()); } + + public function __clone() + { + $newAddressCollection = $this->getPrimaryAddresses(); + $newAddressCollection = array_merge($newAddressCollection, $this->getAdditionalAddresses()); + $this->setId(null); + $this->cleanAllAddresses(); + foreach ($newAddressCollection as $address) { + $this->addAddress(clone $address); + } + } } diff --git a/app/code/core/Mage/Customer/Model/Entity/Address.php b/app/code/core/Mage/Customer/Model/Entity/Address.php index 63c78aea9b..630c8d34e1 100644 --- a/app/code/core/Mage/Customer/Model/Entity/Address.php +++ b/app/code/core/Mage/Customer/Model/Entity/Address.php @@ -59,11 +59,26 @@ protected function _afterSave(Varien_Object $address) return $this; } + /** + * Return customer id + * + * @deprecated + * @param Mage_Customer_Model_Address $object + * @return integer + */ public function getCustomerId($object) { return $object->getData('customer_id') ? $object->getData('customer_id') :$object->getParentId(); } + /** + * Set customer id + * + * @deprecated + * @param Mage_Customer_Model_Address $object + * @param integer $id + * @return Mage_Customer_Model_Address + */ public function setCustomerId($object, $id) { $object->setParentId($id); diff --git a/app/code/core/Mage/Customer/Model/Entity/Customer.php b/app/code/core/Mage/Customer/Model/Entity/Customer.php index 8b45b76bc8..51fba527b7 100644 --- a/app/code/core/Mage/Customer/Model/Entity/Customer.php +++ b/app/code/core/Mage/Customer/Model/Entity/Customer.php @@ -126,12 +126,34 @@ protected function _saveAddresses(Mage_Customer_Model_Customer $customer) { foreach ($customer->getAddresses() as $address) { if ($address->getData('_deleted')) { + if ($address->getId() == $customer->getData('default_billing')) { + $customer->setData('default_billing', null); + } + if ($address->getId() == $customer->getData('default_shipping')) { + $customer->setData('default_shipping', null); + } $address->delete(); } else { $address->setParentId($customer->getId()) ->setStoreId($customer->getStoreId()) ->save(); + if ($address->getIsPrimaryBilling() + && $address->getId() != $customer->getData('default_billing')) + { + $customer->setData('default_billing', $address->getId()); + } + if ($address->getIsPrimaryShipping() + && $address->getId() != $customer->getData('default_shipping')) + { + $customer->setData('default_shipping', $address->getId()); + } + } + if ($customer->dataHasChangedFor('default_billing')) { + $this->saveAttribute($customer, 'default_billing'); + } + if ($customer->dataHasChangedFor('default_shipping')) { + $this->saveAttribute($customer, 'default_shipping'); } } return $this; diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php index 770e017d5d..dc98ca5f8a 100644 --- a/app/code/core/Mage/Customer/controllers/AccountController.php +++ b/app/code/core/Mage/Customer/controllers/AccountController.php @@ -70,9 +70,22 @@ public function preDispatch() if (!$this->_getSession()->authenticate($this)) { $this->setFlag('', 'no-dispatch', true); } + } else { + $this->_getSession()->setNoReferer(true); } } + /** + * Action postdispatch + * + * Remove No-referer flag from customer session after each action + */ + public function postDispatch() + { + parent::postDispatch(); + $this->_getSession()->unsNoReferer(false); + } + /** * Default customer account page */ @@ -145,9 +158,38 @@ public function loginPostAction() $session->addError($this->__('Login and password are required')); } } + + $this->_loginPostRedirect(); + } + + /** + * Define target URL and redirect customer after logging in + */ + protected function _loginPostRedirect() + { + $session = $this->_getSession(); + if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl() ) { + + // Set default URL to redirect customer to $session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl()); + + // Redirect customer to the last page visited after logging in + if ($session->isLoggedIn()) + { + if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) { + if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) { + $referer = Mage::helper('core')->urlDecode($referer); + if ($this->_isUrlInternal($referer)) { + $session->setBeforeAuthUrl($referer); + } + } + } + } else { + $session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl()); + } } + $this->_redirectUrl($session->getBeforeAuthUrl(true)); } diff --git a/app/code/core/Mage/Customer/etc/config.xml b/app/code/core/Mage/Customer/etc/config.xml index ba90c893e8..f05f5af695 100644 --- a/app/code/core/Mage/Customer/etc/config.xml +++ b/app/code/core/Mage/Customer/etc/config.xml @@ -28,7 +28,7 @@ - 0.8.10 + 0.8.11 @@ -378,6 +378,9 @@ T: {{var telephone}} + + 1 + \ No newline at end of file diff --git a/app/code/core/Mage/Customer/etc/system.xml b/app/code/core/Mage/Customer/etc/system.xml index 5dd297e3ce..9b2edd1a50 100644 --- a/app/code/core/Mage/Customer/etc/system.xml +++ b/app/code/core/Mage/Customer/etc/system.xml @@ -262,7 +262,26 @@ + + + 90 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + Customer will stay on the current page if "No" is selected + 1 + 1 + 1 + 0 + + + - \ No newline at end of file + diff --git a/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-0.8.10-0.8.11.php b/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-0.8.10-0.8.11.php new file mode 100644 index 0000000000..d2bf9e7c0f --- /dev/null +++ b/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-0.8.10-0.8.11.php @@ -0,0 +1,35 @@ +startSetup(); + +$installer->getConnection()->dropKey($installer->getTable('customer_address_entity_text'), 'IDX_VALUE'); +$installer->getConnection()->dropKey($installer->getTable('customer_entity_text'), 'IDX_VALUE'); + +$installer->endSetup(); diff --git a/app/code/core/Mage/Directory/Model/Currency.php b/app/code/core/Mage/Directory/Model/Currency.php index e792a120a6..5e8f3e0f0d 100644 --- a/app/code/core/Mage/Directory/Model/Currency.php +++ b/app/code/core/Mage/Directory/Model/Currency.php @@ -107,7 +107,7 @@ public function load($id, $field=null) } /** - * Get currency rate + * Get currency rate (only base=>allowed) * * @param string $toCurrency * @return double @@ -128,6 +128,29 @@ public function getRate($toCurrency) } return $rates[$code]; } + + /** + * Get currency rate (base=>allowed or allowed=>base) + * + * @param string $toCurrency + * @return double + */ + public function getAnyRate($toCurrency) + { + if (is_string($toCurrency)) { + $code = $toCurrency; + } elseif ($toCurrency instanceof Mage_Directory_Model_Currency) { + $code = $toCurrency->getCurrencyCode(); + } else { + throw Mage::exception('Mage_Directory', Mage::helper('directory')->__('Invalid target currency')); + } + $rates = $this->getRates(); + if (!isset($rates[$code])) { + $rates[$code] = $this->_getResource()->getAnyRate($this->getCode(), $toCurrency); + $this->setRates($rates); + } + return $rates[$code]; + } /** * Convert price to currency format diff --git a/app/code/core/Mage/Directory/Model/Mysql4/Currency.php b/app/code/core/Mage/Directory/Model/Mysql4/Currency.php index 34800f98cd..bd07677ff4 100644 --- a/app/code/core/Mage/Directory/Model/Mysql4/Currency.php +++ b/app/code/core/Mage/Directory/Model/Mysql4/Currency.php @@ -61,7 +61,7 @@ public function __construct() } /** - * Retrieve currency rate + * Retrieve currency rate (only base=>allowed) * * @param string $currencyFrom * @param string $currencyTo @@ -93,6 +93,42 @@ public function getRate($currencyFrom, $currencyTo) return self::$_rateCache[$currencyFrom][$currencyTo]; } + + /** + * Retrieve currency rate (base=>allowed or allowed=>base) + * + * @param string $currencyFrom + * @param string $currencyTo + * @return float + */ + public function getAnyRate($currencyFrom, $currencyTo) + { + if ($currencyFrom instanceof Mage_Directory_Model_Currency) { + $currencyFrom = $currencyFrom->getCode(); + } + + if ($currencyTo instanceof Mage_Directory_Model_Currency) { + $currencyTo = $currencyTo->getCode(); + } + + if ($currencyFrom == $currencyTo) { + return 1; + } + + if (!isset(self::$_rateCache[$currencyFrom][$currencyTo])) { + $read = $this->_getReadAdapter(); + $select = $read->select() + ->from($this->_currencyRateTable, new Zend_Db_Expr($read->quoteInto('if(currency_from=?,rate,1/rate)', strtoupper($currencyFrom)))) + ->where('currency_from=?', strtoupper($currencyFrom)) + ->where('currency_to=?', strtoupper($currencyTo)) + ->orWhere('currency_from=?', strtoupper($currencyTo)) + ->where('currency_to=?', strtoupper($currencyFrom)); + + self::$_rateCache[$currencyFrom][$currencyTo] = $read->fetchOne($select); + } + + return self::$_rateCache[$currencyFrom][$currencyTo]; + } /** * Saving currency rates diff --git a/app/code/core/Mage/Directory/etc/config.xml b/app/code/core/Mage/Directory/etc/config.xml index 9f8ee1f123..0aa56f69a8 100644 --- a/app/code/core/Mage/Directory/etc/config.xml +++ b/app/code/core/Mage/Directory/etc/config.xml @@ -28,7 +28,7 @@ - 0.8.4 + 0.8.5 diff --git a/app/code/core/Mage/Directory/sql/directory_setup/mysql4-upgrade-0.8.4-0.8.5.php b/app/code/core/Mage/Directory/sql/directory_setup/mysql4-upgrade-0.8.4-0.8.5.php new file mode 100644 index 0000000000..95fec9c964 --- /dev/null +++ b/app/code/core/Mage/Directory/sql/directory_setup/mysql4-upgrade-0.8.4-0.8.5.php @@ -0,0 +1,39 @@ +startSetup(); + +$installer->run(" + UPDATE {$installer->getTable('directory/country_region')} + SET code = 'GR' + WHERE region_id = 113 +"); + +$installer->endSetup(); diff --git a/app/code/core/Mage/Downloadable/Model/Observer.php b/app/code/core/Mage/Downloadable/Model/Observer.php index f7aad8684f..d62f69ec29 100644 --- a/app/code/core/Mage/Downloadable/Model/Observer.php +++ b/app/code/core/Mage/Downloadable/Model/Observer.php @@ -155,7 +155,7 @@ public function setLinkStatus($observer) /* @var $order Mage_Sales_Model_Order */ $status = ''; $orderItemsIds = array(); - $orderItemStatusToEnable = Mage::getStoreConfig(Mage_Downloadable_Model_Link_Purchased_Item::XML_PATH_ORDER_ITEM_STATUS); + $orderItemStatusToEnable = Mage::getStoreConfig(Mage_Downloadable_Model_Link_Purchased_Item::XML_PATH_ORDER_ITEM_STATUS, $order->getStoreId()); if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) { $status = Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PENDING; } elseif ($order->getState() == Mage_Sales_Model_Order::STATE_CANCELED diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php index cf10ad8d1c..90ddfeacf9 100644 --- a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php +++ b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Abstract.php @@ -32,8 +32,13 @@ * @package Mage_Downloadable * @author Magento Core Team */ -class Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract extends Mage_Sales_Model_Order_Pdf_Items_Abstract +abstract class Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract extends Mage_Sales_Model_Order_Pdf_Items_Abstract { + /** + * Downloadable links purchased model + * + * @var Mage_Downloadable_Model_Link_Purchased + */ protected $_purchasedLinks = null; /** @@ -64,6 +69,4 @@ public function getLinksTitle() } return Mage::getStoreConfig(Mage_Downloadable_Model_Link::XML_PATH_LINKS_TITLE); } - - public function draw(){} -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php index 598638d82d..23dd80963a 100644 --- a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -34,105 +34,130 @@ */ class Mage_Downloadable_Model_Sales_Order_Pdf_Items_Creditmemo extends Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract { + /** + * Draw item line + * + */ public function draw() { $order = $this->getOrder(); $item = $this->getItem(); $pdf = $this->getPdf(); $page = $this->getPage(); + $lines = array(); -// Mage::getModel('sales/order_pdf_items_creditmemo_default') -// ->setOrder($this->getOrder()) -// ->setItem($this->getItem()) -// ->setPdf($this->getPdf()) -// ->setPage($this->getPage()) -// ->draw(); - - $shift = array(0, 10, 0); $leftBound = 35; $rightBound = 565; - // draw name - $this->_setFontRegular(); $x = $leftBound; - foreach (Mage::helper('core/string')->str_split($item->getName(), $x, true, true) as $key => $part) { - $page->drawText($part, $x, $pdf->y - $shift[0], 'UTF-8'); - $shift[0] += 10; - } - // draw options - $options = $this->getItemOptions(); - if (isset($options)) { - foreach ($options as $option) { - // draw options label - $this->_setFontItalic(); - foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), $x, false, true) as $_option) { - $page->drawText($_option, $x, $pdf->y - $shift[0], 'UTF-8'); - $shift[0] += 10; - } - // draw options value - $this->_setFontRegular(); - $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); - foreach (Mage::helper('core/string')->str_split($_printValue, $x, true, true) as $_value) { - $page->drawText($_value, $x + 5, $pdf->y - $shift[0], 'UTF-8'); - $shift[0] += 10; - } - } - } - // draw product description - foreach ($this->_parseDescription() as $description){ - $page->drawText(strip_tags($description), $x + 5, $pdf->y - $shift[1], 'UTF-8'); - $shift[1] += 10; - } - $x += 220; + // draw Product name + $lines[0] = array(array( + 'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true), + 'feed' => $x, + )); + $x += 220; // draw SKU - foreach (Mage::helper('core/string')->str_split($this->getSku($item), 25) as $key => $part) { - $page->drawText($part, $x, $pdf->y - $shift[2], 'UTF-8'); - $shift[2] += 10; - } - $x += 100; + $lines[0][] = array( + 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), + 'feed' => $x + ); - $font = $this->_setFontBold(); + $x += 100; + // draw Total (ex) + $lines[0][] = array( + 'text' => $order->formatPriceTxt($item->getRowTotal()), + 'feed' => $x, + 'font' => 'bold', + 'align' => 'right', + 'width' => 50, + ); - // draw Total(ex) - $text = $order->formatPriceTxt($item->getRowTotal()); - $page->drawText($text, $pdf->getAlignRight($text, $x, 50, $font, 7), $pdf->y, 'UTF-8'); $x += 50; - // draw Discount - $text = $order->formatPriceTxt(-$item->getDiscountAmount()); - $page->drawText($text, $pdf->getAlignRight($text, $x, 50, $font, 7), $pdf->y, 'UTF-8'); - $x += 50; + $lines[0][] = array( + 'text' => $order->formatPriceTxt(-$item->getDiscountAmount()), + 'feed' => $x, + 'font' => 'bold', + 'align' => 'right', + 'width' => 50, + ); + $x += 50; // draw QTY - $text = $item->getQty() * 1; - $page->drawText($text, $pdf->getAlignCenter($text, $x, 30, $font, 7), $pdf->y, 'UTF-8'); - $x += 30; + $lines[0][] = array( + 'text' => $item->getQty()*1, + 'feed' => $x, + 'font' => 'bold', + 'align' => 'center', + 'width' => 30, + ); + $x += 30; // draw Tax - $text = $order->formatPriceTxt($item->getTaxAmount()); - $page->drawText($text, $pdf->getAlignRight($text, $x, 45, $font, 7, 10), $pdf->y, 'UTF-8'); + $lines[0][] = array( + 'text' => $order->formatPriceTxt($item->getTaxAmount()), + 'feed' => $x, + 'font' => 'bold', + 'align' => 'right', + 'width' => 45, + ); + $x += 45; + // draw Subtotal + $lines[0][] = array( + 'text' => $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount()), + 'feed' => $rightBound, + 'font' => 'bold', + 'align' => 'right' + ); + + // draw options + $options = $this->getItemOptions(); + if ($options) { + foreach ($options as $option) { + // draw options label + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), + 'font' => 'italic', + 'feed' => $leftBound + ); - // draw Total(inc) - $text = $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount()); - $page->drawText($text, $pdf->getAlignRight($text, $x, $rightBound - $x, $font, 7, 0), $pdf->y, 'UTF-8'); + // draw options value + $_printValue = isset($option['print_value']) + ? $option['print_value'] + : strip_tags($option['value']); + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($_printValue, 50, true, true), + 'feed' => $leftBound + 5 + ); + } + } - // draw Links Section Title - $this->_setFontItalic(); - $pdf->y -= 10; - $x = $leftBound; + // downloadable Items $_purchasedItems = $this->getLinks()->getPurchasedItems(); - $page->drawText($this->getLinksTitle(), $x, $pdf->y, 'UTF-8'); + + // draw Links title + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($this->getLinksTitle(), 70, true, true), + 'font' => 'italic', + 'feed' => 35 + ); // draw Links - $this->_setFontRegular(); foreach ($_purchasedItems as $_link) { - $pdf->y -= 10; -// $text = $_link->getLinkTitle() . ' ('.$_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():'U').')'; - $text = $_link->getLinkTitle(); - $page->drawText($text, $x+10, $pdf->y, 'UTF-8'); + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($_link->getLinkTitle(), 50, true, true), + 'feed' => 40 + ); } - $pdf->y -= 15; + + $lineBlock = array( + 'lines' => $lines, + 'height' => 10 + ); + + $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true)); + $this->setPage($page); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php index 61c35ddc2f..b73e13198a 100644 --- a/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php @@ -34,88 +34,108 @@ */ class Mage_Downloadable_Model_Sales_Order_Pdf_Items_Invoice extends Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract { + /** + * Draw item line + * + */ public function draw() { $order = $this->getOrder(); $item = $this->getItem(); $pdf = $this->getPdf(); $page = $this->getPage(); - $shift = array(0, 10, 0); - $leftBound = 35; + $lines = array(); - $this->_setFontRegular(); + // draw Product name + $lines[0] = array(array( + 'text' => Mage::helper('core/string')->str_split($item->getName(), 64, true, true), + 'feed' => 35, + )); - $page->drawText($item->getQty()*1, 435, $pdf->y, 'UTF-8'); + // draw SKU + $lines[0][] = array( + 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), + 'feed' => 255 + ); - /* in case Product name is longer than 80 chars - it is written in a few lines */ - foreach (Mage::helper('core/string')->str_split($item->getName(), 60, true, true) as $key => $part) { - $page->drawText($part, 35, $pdf->y-$shift[0], 'UTF-8'); - $shift[0] += 10; - } + // draw QTY + $lines[0][] = array( + 'text' => $item->getQty()*1, + 'feed' => 435 + ); + + // draw Price + $lines[0][] = array( + 'text' => $order->formatPriceTxt($item->getPrice()), + 'feed' => 395, + 'font' => 'bold', + 'align' => 'right' + ); + + // draw Tax + $lines[0][] = array( + 'text' => $order->formatPriceTxt($item->getTaxAmount()), + 'feed' => 495, + 'font' => 'bold', + 'align' => 'right' + ); + // draw Subtotal + $lines[0][] = array( + 'text' => $order->formatPriceTxt($item->getRowTotal()), + 'feed' => 565, + 'font' => 'bold', + 'align' => 'right' + ); + + // custom options $options = $this->getItemOptions(); - if (isset($options)) { + if ($options) { foreach ($options as $option) { // draw options label - $this->_setFontItalic(); - foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true) as $_option) { - $page->drawText($_option, 35, $pdf->y-$shift[0], 'UTF-8'); - $shift[0] += 10; - } - // draw options value - $this->_setFontRegular(); + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), + 'font' => 'italic', + 'feed' => 35 + ); + if ($option['value']) { $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { - foreach (Mage::helper('core/string')->str_split($value, 60,true,true) as $_value) { - $page->drawText($_value, 40, $pdf->y-$shift[0], 'UTF-8'); - $shift[0] += 10; - } + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($value, 50, true, true), + 'feed' => 40 + ); } } } } - foreach ($this->_parseDescription() as $description){ - $page->drawText(strip_tags($description), 65, $pdf->y-$shift[1], 'UTF-8'); - $shift[1] += 10; - } - - /* in case Product SKU is longer than 36 chars - it is written in a few lines */ - foreach (Mage::helper('core/string')->str_split($this->getSku($item), 25) as $key => $part) { - if ($key > 0) { - $shift[2] += 10; - } - $page->drawText($part, 240, $pdf->y-$shift[2], 'UTF-8'); - } - - $font = $this->_setFontBold(); - - $row_total = $order->formatPriceTxt($item->getRowTotal()); - $page->drawText($row_total, 565-$pdf->widthForStringUsingFontSize($row_total, $font, 7), $pdf->y, 'UTF-8'); - - $price = $order->formatPriceTxt($item->getPrice()); - $page->drawText($price, 395-$pdf->widthForStringUsingFontSize($price, $font, 7), $pdf->y, 'UTF-8'); - - $tax = $order->formatPriceTxt($item->getTaxAmount()); - $page->drawText($tax, 495-$pdf->widthForStringUsingFontSize($tax, $font, 7), $pdf->y, 'UTF-8'); - - // draw Links Section Title - $this->_setFontItalic(); - $pdf->y -= 10; - $x = $leftBound; + // downloadable Items $_purchasedItems = $this->getLinks()->getPurchasedItems(); - $page->drawText($this->getLinksTitle(), $x, $pdf->y, 'UTF-8'); + + // draw Links title + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($this->getLinksTitle(), 70, true, true), + 'font' => 'italic', + 'feed' => 35 + ); // draw Links - $this->_setFontRegular(); foreach ($_purchasedItems as $_link) { - $pdf->y -= 10; -// $text = $_link->getLinkTitle() . ' ('.$_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():'U').')'; - $text = $_link->getLinkTitle(); - $page->drawText($text, $x+10, $pdf->y, 'UTF-8'); + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($_link->getLinkTitle(), 50, true, true), + 'feed' => 40 + ); } - $pdf->y -= 15; + + $lineBlock = array( + 'lines' => $lines, + 'height' => 10 + ); + + $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true)); + $this->setPage($page); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Downloadable/etc/config.xml b/app/code/core/Mage/Downloadable/etc/config.xml index e4cc585799..3ed7b20b9a 100644 --- a/app/code/core/Mage/Downloadable/etc/config.xml +++ b/app/code/core/Mage/Downloadable/etc/config.xml @@ -846,7 +846,7 @@ - downloadable/customer/ + /downloadable/customer/ diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index f9e6f34f2b..90d0c14532 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -711,14 +711,27 @@ public function isAttributeStatic($attribute) * Validate all object's attributes against configuration * * @param Varien_Object $object - * @return Varien_Object + * @throws Mage_Eav_Model_Entity_Attribute_Exception + * @return bool|array */ public function validate($object) { $this->loadAllAttributes($object); - $this->walkAttributes('backend/validate', array($object)); + $result = $this->walkAttributes('backend/validate', array($object)); + $errors = array(); + foreach ($result as $attributeCode => $error) { + if ($error === false) { + $errors[$attributeCode] = true; + } + elseif (is_string($error)) { + $errors[$attributeCode] = $error; + } + } + if (!$errors) { + return true; + } - return $this; + return $errors; } /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php index acd4a8cc6a..a617392838 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Abstract.php @@ -176,10 +176,11 @@ public function getDefaultValue() public function validate($object) { $attrCode = $this->getAttribute()->getAttributeCode(); - if ($this->getAttribute()->getIsRequired() && !$object->getData($attrCode)) { + $value = $object->getData($attrCode); + if ($this->getAttribute()->getIsRequired() && $this->getAttribute()->isValueEmpty($value)) { return false; } - $value = $object->getData($this->getAttribute()->getAttributeCode()); + if ($this->getAttribute()->getIsUnique() && !$this->getAttribute()->getIsRequired() && ($value == '' || $this->getAttribute()->isValueEmpty($value))) { return true; } diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php index 0da88c1d55..2b0682a0ad 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php @@ -153,12 +153,16 @@ public function organizeData($data) * * @param string $name * @throws Mage_Core_Exception + * @return bool */ - public function validate($name) + public function validate() { - if (!$this->_getResource()->validate($this, $name)) { - Mage::throwException(Mage::helper('eav')->__('Attribute set with the "%s" name already exists',$name)); + if (!$this->_getResource()->validate($this, $this->getAttributeSetName())) { + Mage::throwException( + Mage::helper('eav')->__('Attribute set with the "%s" name already exists', $this->getAttributeSetName()) + ); } + return true; } /** diff --git a/app/code/core/Mage/Eav/Model/Entity/Setup.php b/app/code/core/Mage/Eav/Model/Entity/Setup.php index 66fc507d93..26217ff49b 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Setup.php +++ b/app/code/core/Mage/Eav/Model/Entity/Setup.php @@ -540,6 +540,7 @@ public function addAttribute($entityTypeId, $code, array $attr) 'frontend_input' => $this->_getValue($attr, 'input', 'text'), 'frontend_input_renderer' => $this->_getValue($attr, 'input_renderer', ''), 'frontend_label' => $this->_getValue($attr, 'label', ''), + 'frontend_class' => $this->_getValue($attr, 'frontend_class', ''), 'source_model' => $this->_getValue($attr, 'source', ''), 'is_global' => $this->_getValue($attr, 'global', 1), 'is_visible' => $this->_getValue($attr, 'visible', 1), diff --git a/app/code/core/Mage/Eav/Model/Entity/Type.php b/app/code/core/Mage/Eav/Model/Entity/Type.php index 57894492df..37f4439837 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Type.php +++ b/app/code/core/Mage/Eav/Model/Entity/Type.php @@ -155,6 +155,9 @@ public function fetchNewIncrementId($storeId=null) //throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Valid store_id is expected!')); } + // Start transaction to run SELECT ... FOR UPDATE + $this->_getResource()->beginTransaction(); + $entityStoreConfig = Mage::getModel('eav/entity_store') ->loadByEntityStore($this->getId(), $storeId); @@ -182,6 +185,9 @@ public function fetchNewIncrementId($storeId=null) $entityStoreConfig->setIncrementLastId($incrementId); $entityStoreConfig->save(); + // Commit increment_last_id changes + $this->_getResource()->commit(); + return $incrementId; } diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Store.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Store.php index b50627476d..9fe7e6a9ed 100644 --- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Store.php +++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Store.php @@ -25,13 +25,13 @@ */ -class Mage_Eav_Model_Mysql4_Entity_Store extends Mage_Core_Model_Mysql4_Abstract +class Mage_Eav_Model_Mysql4_Entity_Store extends Mage_Core_Model_Mysql4_Abstract { protected function _construct() { $this->_init('eav/entity_store', 'entity_store_id'); } - + /** * Load an object by entity type and store * @@ -42,9 +42,10 @@ protected function _construct() */ public function loadByEntityStore(Mage_Core_Model_Abstract $object, $entityTypeId, $storeId) { - $read = $this->_getReadAdapter(); + $read = $this->_getWriteAdapter(); $select = $read->select()->from($this->getMainTable()) + ->forUpdate(true) ->where('entity_type_id=?', $entityTypeId) ->where('store_id=?', $storeId); $data = $read->fetchRow($select); diff --git a/app/code/core/Mage/GiftMessage/Block/Message/Inline.php b/app/code/core/Mage/GiftMessage/Block/Message/Inline.php index 8e76001364..9cba6c6c89 100644 --- a/app/code/core/Mage/GiftMessage/Block/Message/Inline.php +++ b/app/code/core/Mage/GiftMessage/Block/Message/Inline.php @@ -111,6 +111,9 @@ public function getItems() if(!$this->getData('items')) { $items = array(); foreach ($this->getEntity()->getAllItems() as $item) { + if ($item->getParentItem()) { + continue; + } if($this->helper('giftmessage/message')->isMessagesAvailable( substr($this->getType(), 0, 5)=='multi' ? 'address_item' : 'item', $item)) { $items[] = $item; } diff --git a/app/code/core/Mage/GoogleBase/Block/Adminhtml/Types/Grid.php b/app/code/core/Mage/GoogleBase/Block/Adminhtml/Types/Grid.php index 07ceaf6e91..e8842d3c29 100644 --- a/app/code/core/Mage/GoogleBase/Block/Adminhtml/Types/Grid.php +++ b/app/code/core/Mage/GoogleBase/Block/Adminhtml/Types/Grid.php @@ -54,14 +54,12 @@ protected function _prepareColumns() $this->addColumn('attribute_set_name', array( 'header' => $this->__('Attributes Set'), - 'width' => '150px', 'index' => 'attribute_set_name', )); $this->addColumn('gbase_itemtype', array( 'header' => $this->__('Google Base Item type'), - 'width' => '150px', 'index' => 'gbase_itemtype', )); diff --git a/app/code/core/Mage/GoogleBase/Model/Config.php b/app/code/core/Mage/GoogleBase/Model/Config.php index 50856a1d40..c77ed4ccee 100644 --- a/app/code/core/Mage/GoogleBase/Model/Config.php +++ b/app/code/core/Mage/GoogleBase/Model/Config.php @@ -71,6 +71,17 @@ public function getAccountPassword($storeId = null) return $this->getConfigData('password', $storeId); } + /** + * Google Account type + * + * @param int $storeId + * @return string + */ + public function getAccountType($storeId = null) + { + return $this->getConfigData('account_type', $storeId); + } + /** * Google Account target country info * diff --git a/app/code/core/Mage/GoogleBase/Model/Service.php b/app/code/core/Mage/GoogleBase/Model/Service.php index ebdc8542d7..0200b8f655 100644 --- a/app/code/core/Mage/GoogleBase/Model/Service.php +++ b/app/code/core/Mage/GoogleBase/Model/Service.php @@ -42,11 +42,16 @@ public function getClient($storeId = null, $loginToken = null, $loginCaptcha = n { $user = $this->getConfig()->getAccountLogin($storeId); $pass = $this->getConfig()->getAccountPassword($storeId); + $type = $this->getConfig()->getAccountType($storeId); // Create an authenticated HTTP client $errorMsg = Mage::helper('googlebase')->__('Unable to connect to Google Base. Please, check Account settings in configuration.'); try { - $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gbase::AUTH_SERVICE_NAME, null, '', $loginToken, $loginCaptcha); + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gbase::AUTH_SERVICE_NAME, null, '', + $loginToken, $loginCaptcha, + Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, + $type + ); } catch (Zend_Gdata_App_CaptchaRequiredException $e) { throw $e; } catch (Zend_Gdata_App_HttpException $e) { diff --git a/app/code/core/Mage/GoogleBase/Model/Service/Item.php b/app/code/core/Mage/GoogleBase/Model/Service/Item.php index c3cc0a16d8..627f296cb0 100644 --- a/app/code/core/Mage/GoogleBase/Model/Service/Item.php +++ b/app/code/core/Mage/GoogleBase/Model/Service/Item.php @@ -280,6 +280,8 @@ protected function _setUniversalData() $entry->setContent($content); } + $this->_setAttributePrice(false, $object->getPrice()); + if ($object->getQuantity()) { $quantity = $object->getQuantity() ? max(1, (int)$object->getQuantity()) : 1; $this->_setAttribute('quantity', $quantity, 'int'); @@ -329,12 +331,15 @@ protected function _setAttribute($attribute, $value, $type = 'text') */ protected function _setAttributePrice($attribute, $value, $type = 'text') { - $targetCountry = $this->getConfig()->getTargetCountry($this->getStoreId()); - $this->_setAttribute( - $this->getConfig()->getCountryInfo($targetCountry, 'price_attribute_name', $this->getStoreId()), - sprintf('%.2f', $value), - 'floatUnit' - ); + if (!$this->getData('price_assigned')) { + $targetCountry = $this->getConfig()->getTargetCountry($this->getStoreId()); + $this->_setAttribute( + $this->getConfig()->getCountryInfo($targetCountry, 'price_attribute_name', $this->getStoreId()), + sprintf('%.2f', $value), + 'floatUnit' + ); + $this->setData('price_assigned', true); + } } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Backup/Grid/Filter/Type.php b/app/code/core/Mage/GoogleBase/Model/Source/Accounttype.php similarity index 57% rename from app/code/core/Mage/Adminhtml/Block/Backup/Grid/Filter/Type.php rename to app/code/core/Mage/GoogleBase/Model/Source/Accounttype.php index 19dd9f93e9..387eddf14b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Backup/Grid/Filter/Type.php +++ b/app/code/core/Mage/GoogleBase/Model/Source/Accounttype.php @@ -19,37 +19,26 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Adminhtml + * @package Mage_GoogleBase * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * Backup type column filter + * Google Data Api account types Source * * @category Mage - * @package Mage_Adminhtml - * @author Magento Core Team + * @package Mage_GoogleBase + * @author Magento Core Team */ -class Mage_Adminhtml_Block_Backup_Grid_Filter_Type extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select +class Mage_GoogleBase_Model_Source_Accounttype { - protected function _getOptions() + public function toOptionArray() { - $options = array( - array( - 'value'=>'', - 'label'=>Mage::helper('backup')->__('All types') - ), - array( - 'value'=>'db', - 'label'=>Mage::helper('backup')->__('DB') - ), - ); - return $options; - } - - public function getCondition() - { - return $this->getValue(); + return array( + array('value' => 'HOSTED_OR_GOOGLE', 'label' => Mage::helper('googlebase')->__('Hosted or Google')), + array('value' => 'GOOGLE', 'label' => Mage::helper('googlebase')->__('Google')), + array('value' => 'HOSTED', 'label' => Mage::helper('googlebase')->__('Hosted')) + ); } } \ No newline at end of file diff --git a/app/code/core/Mage/GoogleBase/controllers/ItemsController.php b/app/code/core/Mage/GoogleBase/controllers/ItemsController.php index e76e988d31..16041bd010 100644 --- a/app/code/core/Mage/GoogleBase/controllers/ItemsController.php +++ b/app/code/core/Mage/GoogleBase/controllers/ItemsController.php @@ -364,14 +364,21 @@ protected function _parseGdataExceptionMessage($message) $result[] = $row; continue; } - try { - $xml = new Varien_Simplexml_Element($row); - $error = $xml->getAttribute('reason'); - $result[] = $error; - } catch (Exception $e) { - continue; + + // parse not well-formatted xml + preg_match_all('/(reason|field|type)=\"([^\"]+)\"/', $row, $matches); + + if (is_array($matches) && count($matches) == 3) { + if (is_array($matches[1]) && count($matches[1]) > 0) { + $c = count($matches[1]); + for ($i = 0; $i < $c; $i++) { + if (isset($matches[2][$i])) { + $result[] = ucfirst($matches[1][$i]) . ': ' . $matches[2][$i]; + } + } + } } } - return implode(" ", $result); + return implode(". ", $result); } } diff --git a/app/code/core/Mage/GoogleBase/etc/config.xml b/app/code/core/Mage/GoogleBase/etc/config.xml index 48b47b9d06..4689f2b5ca 100644 --- a/app/code/core/Mage/GoogleBase/etc/config.xml +++ b/app/code/core/Mage/GoogleBase/etc/config.xml @@ -193,6 +193,7 @@ US + HOSTED_OR_GOOGLE United States diff --git a/app/code/core/Mage/GoogleBase/etc/system.xml b/app/code/core/Mage/GoogleBase/etc/system.xml index f5401c2ab7..01a49fbe3a 100644 --- a/app/code/core/Mage/GoogleBase/etc/system.xml +++ b/app/code/core/Mage/GoogleBase/etc/system.xml @@ -53,11 +53,20 @@ 1 1 + + + select + googlebase/source_accounttype + 3 + 1 + 1 + 1 + select googlebase/source_country - 3 + 90 1 1 1 diff --git a/app/code/core/Mage/Log/Model/Mysql4/Visitor.php b/app/code/core/Mage/Log/Model/Mysql4/Visitor.php index e0a7185ffa..1958805444 100644 --- a/app/code/core/Mage/Log/Model/Mysql4/Visitor.php +++ b/app/code/core/Mage/Log/Model/Mysql4/Visitor.php @@ -99,15 +99,27 @@ protected function _afterSave(Mage_Core_Model_Abstract $visitor) */ protected function _saveVisitorInfo($visitor) { + /* @var $stringHelper Mage_Core_Helper_String */ + $stringHelper = Mage::helper('core/string'); + + $referer = $stringHelper->cleanString($visitor->getHttpReferer()); + $referer = $stringHelper->substr($referer, 0, 255); + $userAgent = $stringHelper->cleanString($visitor->getHttpUserAgent()); + $userAgent = $stringHelper->substr($userAgent, 0, 255); + $charset = $stringHelper->cleanString($visitor->getHttpAcceptCharset()); + $charset = $stringHelper->substr($charset, 0, 255); + $language = $stringHelper->cleanString($visitor->getHttpAcceptLanguage()); + $language = $stringHelper->substr($language, 0, 255); + $write = $this->_getWriteAdapter(); $data = array( - 'visitor_id' => $visitor->getId(), - 'http_referer' => Mage::helper('core/string')->substr($visitor->getHttpReferer(), 0, 250), - 'http_user_agent' => $visitor->getHttpUserAgent(), - 'http_accept_charset'=>$visitor->getHttpAcceptCharset(), - 'http_accept_language'=>$visitor->getHttpAcceptLanguage(), - 'server_addr' => $visitor->getServerAddr(), - 'remote_addr' => $visitor->getRemoteAddr(), + 'visitor_id' => $visitor->getId(), + 'http_referer' => $stringHelper->substr($visitor->getHttpReferer(), 0, 255), + 'http_user_agent' => $stringHelper->substr($visitor->getHttpUserAgent(), 0, 255), + 'http_accept_charset' => $stringHelper->substr($visitor->getHttpAcceptCharset(), 0, 255), + 'http_accept_language' => $stringHelper->substr($visitor->getHttpAcceptLanguage(), 0, 255), + 'server_addr' => $visitor->getServerAddr(), + 'remote_addr' => $visitor->getRemoteAddr(), ); $write->insert($this->getTable('log/visitor_info'), $data); diff --git a/app/code/core/Mage/Log/Model/Mysql4/Visitor/Online/Collection.php b/app/code/core/Mage/Log/Model/Mysql4/Visitor/Online/Collection.php index a47f9638bf..66a69835b4 100644 --- a/app/code/core/Mage/Log/Model/Mysql4/Visitor/Online/Collection.php +++ b/app/code/core/Mage/Log/Model/Mysql4/Visitor/Online/Collection.php @@ -34,6 +34,13 @@ */ class Mage_Log_Model_Mysql4_Visitor_Online_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract { + /** + * joined fields array + * + * @var array + */ + protected $_fields = array(); + /** * Initialize collection model * @@ -70,6 +77,8 @@ public function addCustomerData() sprintf('%s.entity_id=main_table.customer_id', $tableAlias), array($alias => $attribute->getAttributeCode()) ); + + $this->_fields[$alias] = sprintf('%s.%s', $tableAlias, $attribute->getAttributeCode()); } else { $tableAlias = 'customer_' . $attribute->getAttributeCode(); @@ -84,6 +93,8 @@ public function addCustomerData() join(' AND ', $joinConds), array($alias => 'value') ); + + $this->_fields[$alias] = sprintf('%s.value', $tableAlias); } } @@ -105,4 +116,27 @@ public function addWebsiteFilter($websiteIds) } return $this; } + + /** + * Add field filter to collection + * + * If $attribute is an array will add OR condition with following format: + * array( + * array('attribute'=>'firstname', 'like'=>'test%'), + * array('attribute'=>'lastname', 'like'=>'test%'), + * ) + * + * @see self::_getConditionSql for $condition + * @param string|array $attribute + * @param null|string|array $condition + * @return Mage_Eav_Model_Entity_Collection_Abstract + */ + public function addFieldToFilter($field, $condition=null) + { + if (isset($this->_fields[$field])) { + $field = $this->_fields[$field]; + } + + return parent::addFieldToFilter($field, $condition); + } } diff --git a/app/code/core/Mage/Log/Model/Visitor.php b/app/code/core/Mage/Log/Model/Visitor.php index ec34d8818e..d849cc97a6 100644 --- a/app/code/core/Mage/Log/Model/Visitor.php +++ b/app/code/core/Mage/Log/Model/Visitor.php @@ -63,18 +63,20 @@ public function getResource() */ public function initServerData() { - $s = $_SERVER; + /* @var $helper Mage_Core_Helper_Http */ + $helper = Mage::helper('core/http'); + $this->addData(array( - 'server_addr' => empty($s['SERVER_ADDR']) ? '' : ip2long($s['SERVER_ADDR']), - 'remote_addr' => empty($s['REMOTE_ADDR']) ? '' : ip2long($s['REMOTE_ADDR']), - 'http_secure' => Mage::app()->getStore()->isCurrentlySecure(), - 'http_host' => empty($s['HTTP_HOST']) ? '' : $s['HTTP_HOST'], - 'http_user_agent' => empty($s['HTTP_USER_AGENT']) ? '' : $s['HTTP_USER_AGENT'], - 'http_accept_language'=> empty($s['HTTP_ACCEPT_LANGUAGE']) ? '' : $s['HTTP_ACCEPT_LANGUAGE'], - 'http_accept_charset'=> empty($s['HTTP_ACCEPT_CHARSET']) ? '' : $s['HTTP_ACCEPT_CHARSET'], - 'request_uri' => empty($s['REQUEST_URI']) ? '' : $s['REQUEST_URI'], - 'session_id' => $this->_getSession()->getSessionId(), - 'http_referer' => empty($s['HTTP_REFERER']) ? '' : $s['HTTP_REFERER'], + 'server_addr' => $helper->getServerAddr(true), + 'remote_addr' => $helper->getRemoteAddr(true), + 'http_secure' => Mage::app()->getStore()->isCurrentlySecure(), + 'http_host' => $helper->getHttpHost(true), + 'http_user_agent' => $helper->getHttpUserAgent(true), + 'http_accept_language' => $helper->getHttpAcceptLanguage(true), + 'http_accept_charset' => $helper->getHttpAcceptCharset(true), + 'request_uri' => $helper->getRequestUri(true), + 'session_id' => $this->_getSession()->getSessionId(), + 'http_referer' => $helper->getHttpReferer(true), )); return $this; diff --git a/app/code/core/Mage/Page/Model/Config.php b/app/code/core/Mage/Page/Model/Config.php index 878608dc54..3ad3de3ca8 100644 --- a/app/code/core/Mage/Page/Model/Config.php +++ b/app/code/core/Mage/Page/Model/Config.php @@ -1,111 +1,129 @@ - - */ -class Mage_Page_Model_Config -{ - const XML_PATH_PAGE_LAYOUTS = 'global/page/layouts'; - - /** - * Available page layouts - * - * @var array - */ - protected $_pageLayouts = null; - - /** - * Initialize page layouts list - * - * @return Mage_Page_Model_Config - */ - protected function _initPageLayouts() - { - if ($this->_pageLayouts === null) { - $this->_pageLayouts = array(); - - foreach (Mage::getConfig()->getNode(self::XML_PATH_PAGE_LAYOUTS)->children() as $layoutCode => $layoutConfig) { - $this->_pageLayouts[$layoutCode] = new Varien_Object(array( - 'label' => Mage::helper('page')->__((string)$layoutConfig->label), - 'code' => $layoutCode, - 'template' => (string) $layoutConfig->template, - 'layout_handle' => (string) $layoutConfig->layout_handle - )); - } - } - - return $this; - } - - /** - * Retrieve available page layouts - * - * @return array - */ - public function getPageLayouts() - { - $this->_initPageLayouts(); - return $this->_pageLayouts; - } - - /** - * Retrieve page layout by code - * - * @param string $layoutCode - * @return Varien_Object|boolean - */ - public function getPageLayout($layoutCode) - { - $this->_initPageLayouts(); - - if (isset($this->_pageLayouts[$layoutCode])) { - return $this->_pageLayouts[$layoutCode]; - } - - return false; - } - - /** - * Retrieve page layout handles - * - * @return array - */ - public function getPageLayoutHandles() - { - $handles = array(); - - foreach ($this->getPageLayouts() as $layout) { - $handles[$layout->getCode()] = $layout->getLayoutHandle(); - } - - return $handles; - } -} + + */ +class Mage_Page_Model_Config +{ + const XML_PATH_PAGE_LAYOUTS = 'global/page/layouts'; + const XML_PATH_CMS_LAYOUTS = 'global/cms/layouts'; + + /** + * Available page layouts + * + * @var array + */ + protected $_pageLayouts = null; + + /** + * Initialize page layouts list + * + * @return Mage_Page_Model_Config + */ + protected function _initPageLayouts() + { + if ($this->_pageLayouts === null) { + $this->_pageLayouts = array(); + $this->_appendPageLayouts(self::XML_PATH_CMS_LAYOUTS); + $this->_appendPageLayouts(self::XML_PATH_PAGE_LAYOUTS); + } + return $this; + } + + /** + * Fill in $_pageLayouts by reading layouts from config + * + * @param string $xmlPath XML path to layouts root + * @return Mage_Page_Model_Config + */ + protected function _appendPageLayouts($xmlPath) + { + if (!Mage::getConfig()->getNode($xmlPath)) { + return $this; + } + if (!is_array($this->_pageLayouts)) { + $this->_pageLayouts = array(); + } + foreach (Mage::getConfig()->getNode($xmlPath)->children() as $layoutCode => $layoutConfig) { + $this->_pageLayouts[$layoutCode] = new Varien_Object(array( + 'label' => Mage::helper('page')->__((string)$layoutConfig->label), + 'code' => $layoutCode, + 'template' => (string) $layoutConfig->template, + 'layout_handle' => (string) $layoutConfig->layout_handle + )); + } + return $this; + } + + /** + * Retrieve available page layouts + * + * @return array + */ + public function getPageLayouts() + { + $this->_initPageLayouts(); + return $this->_pageLayouts; + } + + /** + * Retrieve page layout by code + * + * @param string $layoutCode + * @return Varien_Object|boolean + */ + public function getPageLayout($layoutCode) + { + $this->_initPageLayouts(); + + if (isset($this->_pageLayouts[$layoutCode])) { + return $this->_pageLayouts[$layoutCode]; + } + + return false; + } + + /** + * Retrieve page layout handles + * + * @return array + */ + public function getPageLayoutHandles() + { + $handles = array(); + + foreach ($this->getPageLayouts() as $layout) { + $handles[$layout->getCode()] = $layout->getLayoutHandle(); + } + + return $handles; + } +} diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php index cbbef2b19f..ea1298c895 100644 --- a/app/code/core/Mage/Paygate/Model/Authorizenet.php +++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php @@ -432,7 +432,8 @@ protected function _postRequest(Varien_Object $request) ->setTransactionType($r[11]) ->setCustomerId($r[12]) ->setMd5Hash($r[37]) - ->setCardCodeResponseCode($r[39]); + ->setCardCodeResponseCode($r[38]) + ->setCAVVResponseCode($r[39]); } else { Mage::throwException( Mage::helper('paygate')->__('Error in payment gateway') diff --git a/app/code/core/Mage/Paypal/Model/Standard.php b/app/code/core/Mage/Paypal/Model/Standard.php index de8459eadb..d0aa39870c 100644 --- a/app/code/core/Mage/Paypal/Model/Standard.php +++ b/app/code/core/Mage/Paypal/Model/Standard.php @@ -36,6 +36,8 @@ class Mage_Paypal_Model_Standard extends Mage_Payment_Model_Method_Abstract const PAYMENT_TYPE_AUTH = 'AUTHORIZATION'; const PAYMENT_TYPE_SALE = 'SALE'; + const DATA_CHARSET = 'utf-8'; + protected $_code = 'paypal_standard'; protected $_formBlockType = 'paypal/standard_form'; protected $_allowCurrencyCode = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD'); @@ -144,7 +146,7 @@ public function onInvoiceCreate(Mage_Sales_Model_Invoice_Payment $payment) public function canCapture() { - return true; + return false; } public function getOrderPlaceRedirectUrl() @@ -176,6 +178,7 @@ public function getStandardCheckoutFormFields() */ $sArr = array( + 'charset' => self::DATA_CHARSET, 'business' => Mage::getStoreConfig('paypal/wps/business_account'), 'return' => Mage::getUrl('paypal/standard/success',array('_secure' => true)), 'cancel_return' => Mage::getUrl('paypal/standard/cancel',array('_secure' => false)), @@ -416,7 +419,7 @@ public function ipnPostSubmit() ->addObject($invoice->getOrder()) ->save(); $order->setState( - Mage_Sales_Model_Order::STATE_PROCESSING, $newOrderStatus, + Mage_Sales_Model_Order::STATE_COMPLETE, true, Mage::helper('paypal')->__('Invoice #%s created', $invoice->getIncrementId()), $notified = true ); diff --git a/app/code/core/Mage/Paypal/controllers/ExpressController.php b/app/code/core/Mage/Paypal/controllers/ExpressController.php index 7a1b119a5d..eb48f1d530 100644 --- a/app/code/core/Mage/Paypal/controllers/ExpressController.php +++ b/app/code/core/Mage/Paypal/controllers/ExpressController.php @@ -171,6 +171,14 @@ public function saveOrderAction() } } + $customer = $this->getReview()->getQuote()->getCustomer(); + if (!$customer || !$customer->getId()) { + $this->getReview()->getQuote() + ->setCustomerIsGuest(true) + ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); + } + unset($customer); // for backward compatibility, see logic after place order + $billing = $this->getReview()->getQuote()->getBillingAddress(); $shipping = $this->getReview()->getQuote()->getShippingAddress(); diff --git a/app/code/core/Mage/PaypalUk/Model/Express.php b/app/code/core/Mage/PaypalUk/Model/Express.php index 92b1fcc1af..d83a2ef160 100644 --- a/app/code/core/Mage/PaypalUk/Model/Express.php +++ b/app/code/core/Mage/PaypalUk/Model/Express.php @@ -316,8 +316,7 @@ public function placeOrder(Varien_Object $payment) $payment->setLastTransId($api->getTransactionId()); } } else { - $e = $api->getError(); - die($e['message']); + $this->throwError(); } return $this; } diff --git a/app/code/core/Mage/PaypalUk/controllers/ExpressController.php b/app/code/core/Mage/PaypalUk/controllers/ExpressController.php index e99552904d..caff3eacda 100644 --- a/app/code/core/Mage/PaypalUk/controllers/ExpressController.php +++ b/app/code/core/Mage/PaypalUk/controllers/ExpressController.php @@ -166,6 +166,15 @@ public function saveOrderAction() return; } } + + $customer = $this->getReview()->getQuote()->getCustomer(); + if (!$customer || !$customer->getId()) { + $this->getReview()->getQuote() + ->setCustomerIsGuest(true) + ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); + } + unset($customer); // for backward compatibility, see logic after place order + $billing = $this->getReview()->getQuote()->getBillingAddress(); $shipping = $this->getReview()->getQuote()->getShippingAddress(); diff --git a/app/code/core/Mage/PaypalUk/etc/config.xml b/app/code/core/Mage/PaypalUk/etc/config.xml index 580ad2b77c..917a58142a 100644 --- a/app/code/core/Mage/PaypalUk/etc/config.xml +++ b/app/code/core/Mage/PaypalUk/etc/config.xml @@ -138,13 +138,13 @@ - Authorization + authorize paypaluk/express PaypalUk Express 0 - Authorization + authorize paypaluk/direct PaypalUk Direct AE,VI,MC,DI diff --git a/app/code/core/Mage/Poll/Model/Poll.php b/app/code/core/Mage/Poll/Model/Poll.php index e7bd347702..085f4e49dc 100644 --- a/app/code/core/Mage/Poll/Model/Poll.php +++ b/app/code/core/Mage/Poll/Model/Poll.php @@ -118,7 +118,7 @@ public function isVoted($pollId = null) } // check by ip - if (count($this->_getResource()->getVotedPollIdsByIp($_SERVER['REMOTE_ADDR'], $pollId))) { + if (count($this->_getResource()->getVotedPollIdsByIp(Mage::helper('core/http')->getRemoteAddr(), $pollId))) { return true; } @@ -194,7 +194,7 @@ public function getVotedPollsIds() } // load from db for this ip - foreach ($this->_getResource()->getVotedPollIdsByIp($_SERVER['REMOTE_ADDR']) as $pollId) { + foreach ($this->_getResource()->getVotedPollIdsByIp(Mage::helper('core/http')->getRemoteAddr()) as $pollId) { $idsArray[$pollId] = $pollId; } diff --git a/app/code/core/Mage/Poll/controllers/VoteController.php b/app/code/core/Mage/Poll/controllers/VoteController.php index c5bb6adeeb..3ffbcdb7a5 100644 --- a/app/code/core/Mage/Poll/controllers/VoteController.php +++ b/app/code/core/Mage/Poll/controllers/VoteController.php @@ -53,7 +53,7 @@ public function addAction() if ($poll->getId() && !$poll->getClosed() && !$poll->isVoted()) { $vote = Mage::getModel('poll/poll_vote') ->setPollAnswerId($answerId) - ->setIpAddress(ip2long($this->getRequest()->getServer('REMOTE_ADDR'))) + ->setIpAddress(Mage::helper('core/http')->getRemoteAddr(true)) ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()); $poll->addVote($vote); diff --git a/app/code/core/Mage/ProductAlert/Block/Email/Abstract.php b/app/code/core/Mage/ProductAlert/Block/Email/Abstract.php index 78a32cc36d..53bf666288 100644 --- a/app/code/core/Mage/ProductAlert/Block/Email/Abstract.php +++ b/app/code/core/Mage/ProductAlert/Block/Email/Abstract.php @@ -52,7 +52,7 @@ abstract class Mage_ProductAlert_Block_Email_Abstract extends Mage_Core_Block_Te * Set Store scope * * @param int|string|Mage_Core_Model_Website|Mage_Core_Model_Store $store - * @param Mage_ProductAlert_Block_Email_Price + * @return Mage_ProductAlert_Block_Email_Abstract */ public function setStore($store) { diff --git a/app/code/core/Mage/ProductAlert/Model/Email.php b/app/code/core/Mage/ProductAlert/Model/Email.php index 115179df17..062c719971 100644 --- a/app/code/core/Mage/ProductAlert/Model/Email.php +++ b/app/code/core/Mage/ProductAlert/Model/Email.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_ProductAlert - * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) + * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -30,7 +30,7 @@ * * @category Mage * @package Mage_ProductAlert - * @author Magento Core Team + * @author Magento Core Team */ class Mage_ProductAlert_Model_Email extends Mage_Core_Model_Abstract { @@ -247,15 +247,23 @@ public function send() return false; } - Mage::getDesign()->setStore($storeId); - Mage::getDesign()->setArea('frontend'); + // set design parameters, required for email (remember current) + $currentDesign = Mage::getDesign()->setAllGetOld(array( + 'store' => $storeId, + 'area' => 'frontend', + 'package' => Mage::getStoreConfig('design/package/name', $storeId), + )); + + Mage::app()->getLocale()->emulate($storeId); $translate = Mage::getSingleton('core/translate'); /* @var $translate Mage_Core_Model_Translate */ $translate->setTranslateInline(false); if ($this->_type == 'price') { - $this->_getPriceBlock()->setStore($store); + $this->_getPriceBlock() + ->setStore($store) + ->reset(); foreach ($this->_priceProducts as $product) { $product->setCustomerGroupId($this->_customer->getGroupId()); $this->_getPriceBlock()->addProduct($product); @@ -264,7 +272,9 @@ public function send() $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId); } elseif ($this->_type == 'stock') { - $this->_getStockBlock()->setStore($store); + $this->_getStockBlock() + ->setStore($store) + ->reset(); foreach ($this->_stockProducts as $product) { $product->setCustomerGroupId($this->_customer->getGroupId()); $this->_getStockBlock()->addProduct($product); @@ -273,6 +283,7 @@ public function send() $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId); } else { + Mage::app()->getLocale()->revert(); return false; } @@ -293,6 +304,10 @@ public function send() $translate->setTranslateInline(true); + // revert current design + Mage::getDesign()->setAllGetOld($currentDesign); + Mage::app()->getLocale()->revert(); + return true; } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Rating/Model/Mysql4/Rating.php b/app/code/core/Mage/Rating/Model/Mysql4/Rating.php index e66b42d179..983c56df37 100644 --- a/app/code/core/Mage/Rating/Model/Mysql4/Rating.php +++ b/app/code/core/Mage/Rating/Model/Mysql4/Rating.php @@ -143,35 +143,37 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) { return $this; } - public function getEntitySummary($object, $onlyForCurrentStore = true) + /** + * Perform actions after object delete + * Prepare rating data for reaggregate all data for reviews + * + * @param Mage_Core_Model_Abstract $object + * @return Mage_Rating_Model_Mysql4_Rating + */ + protected function _afterDelete(Mage_Core_Model_Abstract $object) { - $read = $this->_getReadAdapter(); - $sql = "SELECT - SUM({$this->getTable('rating_vote')}.percent) as sum, - COUNT(*) as count, - {$this->getTable('review/review_store')}.store_id - FROM - {$this->getTable('rating_vote')} - INNER JOIN - {$this->getTable('review/review')} - ON {$this->getTable('rating_vote')}.review_id={$this->getTable('review/review')}.review_id - LEFT JOIN - {$this->getTable('review/review_store')} - ON {$this->getTable('rating_vote')}.review_id={$this->getTable('review/review_store')}.review_id - INNER JOIN - {$this->getTable('rating/rating_store')} AS rst - ON rst.rating_id = {$this->getTable('rating_vote')}.rating_id AND rst.store_id = {$this->getTable('review/review_store')}.store_id - INNER JOIN - {$this->getTable('review/review_status')} AS review_status - ON {$this->getTable('review/review')}.status_id = review_status.status_id - WHERE - {$read->quoteInto($this->getTable('rating_vote').'.entity_pk_value=?', $object->getEntityPkValue())} - AND review_status.status_code = 'approved' - GROUP BY - {$this->getTable('rating_vote')}.entity_pk_value, {$this->getTable('review/review_store')}.store_id"; - - $data = $read->fetchAll($sql); + parent::_afterDelete($object); + $data = $this->_getEntitySummaryData($object); + $summary = array(); + foreach ($data as $row) { + $clone = clone $object; + $clone->addData( $row ); + $summary[$clone->getStoreId()][$clone->getEntityPkValue()] = $clone; + } + Mage::getResourceModel('review/review_summary')->reAggregate($summary); + return $this; + } + /** + * Return array of rating summary + * + * @param Mage_Rating_Model_Rating $object + * @param boolean $onlyForCurrentStore + * @return array + */ + public function getEntitySummary($object, $onlyForCurrentStore = true) + { + $data = $this->_getEntitySummaryData($object); if($onlyForCurrentStore) { foreach ($data as $row) { @@ -205,9 +207,46 @@ public function getEntitySummary($object, $onlyForCurrentStore = true) } } + return array_values($result); + } + /** + * Return data of rating summary + * + * @param Mage_Rating_Model_Rating $object + * @return array + */ + protected function _getEntitySummaryData($object) + { + $read = $this->_getReadAdapter(); + $sql = "SELECT + {$this->getTable('rating_vote')}.entity_pk_value as entity_pk_value, + SUM({$this->getTable('rating_vote')}.percent) as sum, + COUNT(*) as count, + {$this->getTable('review/review_store')}.store_id + FROM + {$this->getTable('rating_vote')} + INNER JOIN + {$this->getTable('review/review')} + ON {$this->getTable('rating_vote')}.review_id={$this->getTable('review/review')}.review_id + LEFT JOIN + {$this->getTable('review/review_store')} + ON {$this->getTable('rating_vote')}.review_id={$this->getTable('review/review_store')}.review_id + INNER JOIN + {$this->getTable('rating/rating_store')} AS rst + ON rst.rating_id = {$this->getTable('rating_vote')}.rating_id AND rst.store_id = {$this->getTable('review/review_store')}.store_id + INNER JOIN + {$this->getTable('review/review_status')} AS review_status + ON {$this->getTable('review/review')}.status_id = review_status.status_id + WHERE "; + if ($object->getEntityPkValue()) { + $sql .= "{$read->quoteInto($this->getTable('rating_vote').'.entity_pk_value=?', $object->getEntityPkValue())} AND "; + } + $sql .= "review_status.status_code = 'approved' + GROUP BY + {$this->getTable('rating_vote')}.entity_pk_value, {$this->getTable('review/review_store')}.store_id"; - return array_values($result); + return $read->fetchAll($sql); } public function getReviewSummary($object, $onlyForCurrentStore = true) diff --git a/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option.php b/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option.php index 6007b9d998..c621feb3fc 100644 --- a/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option.php +++ b/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option.php @@ -91,8 +91,8 @@ public function addVote($option) ); if( !$option->getDoUpdate() ) { - $data['remote_ip'] = $action->getRequest()->getServer('REMOTE_ADDR'); - $data['remote_ip_long'] = ip2long($action->getRequest()->getServer('REMOTE_ADDR')); + $data['remote_ip'] = Mage::helper('core/http')->getRemoteAddr(); + $data['remote_ip_long'] = Mage::helper('core/http')->getRemoteAddr(true); $data['customer_id'] = Mage::getSingleton('customer/session')->getCustomerId(); $data['entity_pk_value'] = $option->getEntityPkValue(); $data['rating_id'] = $option->getRatingId(); diff --git a/app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php b/app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php new file mode 100644 index 0000000000..0a208b9a9d --- /dev/null +++ b/app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php @@ -0,0 +1,174 @@ + + */ + +class Mage_Reports_Model_Mysql4_Product_Lowstock_Collection extends Mage_Reports_Model_Mysql4_Product_Collection +{ + protected $_inventoryItemResource = null; + protected $_inventoryItemJoined = false; + protected $_inventoryItemTableAlias = 'lowstock_inventory_item'; + + /** + * @return string + */ + protected function _getInventoryItemResource() + { + if (is_null($this->_inventoryItemResource)) { + $this->_inventoryItemResource = Mage::getResourceSingleton('cataloginventory/stock_item'); + } + return $this->_inventoryItemResource; + } + + /** + * @return string + */ + protected function _getInventoryItemTable() + { + return $this->_getInventoryItemResource()->getMainTable(); + } + + /** + * @return string + */ + protected function _getInventoryItemIdField() + { + return $this->_getInventoryItemResource()->getIdFieldName(); + } + + /** + * @return string + */ + protected function _getInventoryItemTableAlias() + { + return $this->_inventoryItemTableAlias; + } + + /** + * @param array|string $fields + * @return string + */ + protected function _processInventoryItemFields($fields) + { + if (is_array($fields)) { + $aliasArr = array(); + foreach ($fields as &$field) { + if ( is_string($field) && strpos($field, '(') === false ) { + $field = sprintf('%s.%s', $this->_getInventoryItemTableAlias(), $field); + } + } + unset($field); + return $fields; + } + return sprintf('%s.%s', $this->_getInventoryItemTableAlias(), $fields); + } + + /** + * Join cataloginventory_stock_item table for further + * stock_item values filters + * @return Mage_Reports_Model_Mysql4_Product_Collection + */ + public function joinInventoryItem($fields=array()) { + if ( !$this->_inventoryItemJoined ) { + $this->getSelect()->join( + array($this->_getInventoryItemTableAlias() => $this->_getInventoryItemTable()), + sprintf('e.%s=%s.product_id', + $this->getEntity()->getEntityIdField(), + $this->_getInventoryItemTableAlias() + ), + array() + ); + $this->_inventoryItemJoined = true; + } + if (is_string($fields)) { + $fields = array($fields); + } + if (!empty($fields)) { + $this->getSelect()->columns($this->_processInventoryItemFields($fields)); + } + return $this; + } + + /** + * @param array|string $typeFilter + * @return Mage_Reports_Model_Mysql4_Product_Collection + */ + public function filterByProductType($typeFilter) + { + if (!is_string($typeFilter) && !is_array($typeFilter)) { + Mage::throwException( + Mage::helper('catalog')->__('Wrong product type filter specified') + ); + } + $this->addAttributeToFilter('type_id', $typeFilter); + return $this; + } + + /** + * @return Mage_Reports_Model_Mysql4_Product_Collection + */ + public function filterByIsQtyProductTypes() + { + $this->filterByProductType( + array_keys(array_filter(Mage::helper('cataloginventory')->getIsQtyTypeIds())) + ); + return $this; + } + + /** + * @param int|null $storeId + * @return Mage_Reports_Model_Mysql4_Product_Collection + */ + public function useManageStockFilter($storeId=null) + { + $this->joinInventoryItem(); + $this->getSelect()->where(sprintf('IF(%s,%d,%s)=1', + $this->_processInventoryItemFields('use_config_manage_stock'), + (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK,$storeId), + $this->_processInventoryItemFields('manage_stock'))); + return $this; + } + + /** + * @param int|null $storeId + * @return Mage_Reports_Model_Mysql4_Product_Collection + */ + public function useNotifyStockQtyFilter($storeId=null) + { + $this->joinInventoryItem(array('qty')); + $this->getSelect()->where(sprintf('qty < IF(%s,%d,%s)', + $this->_processInventoryItemFields('use_config_notify_stock_qty'), + (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY,$storeId), + $this->_processInventoryItemFields('notify_stock_qty'))); + return $this; + } +} diff --git a/app/code/core/Mage/Reports/Model/Totals.php b/app/code/core/Mage/Reports/Model/Totals.php index 4402d2fcfd..ef0e630136 100644 --- a/app/code/core/Mage/Reports/Model/Totals.php +++ b/app/code/core/Mage/Reports/Model/Totals.php @@ -33,18 +33,30 @@ */ class Mage_Reports_Model_Totals { + /** + * Retrieve count totals + * + * @param Mage_Adminhtml_Block_Report_Grid $grid + * @param string $from + * @param string $to + * @return Varien_Object + */ public function countTotals($grid, $from, $to) { $columns = array(); - foreach ($grid->getColumns() as $col) + foreach ($grid->getColumns() as $col) { $columns[$col->getIndex()] = array("total" => $col->getTotal(), "value" => 0); + } $count = 0; $report = $grid->getCollection()->getReportFull($from, $to); - foreach ($report as $item) - { + foreach ($report as $item) { + if ($grid->getSubReportSize() && $count >= $grid->getSubReportSize()) { + continue; + } $data = $item->getData(); - foreach ($columns as $field=>$a){ + + foreach ($columns as $field=>$a) { if ($field !== '') { $columns[$field]['value'] = $columns[$field]['value'] + (isset($data[$field]) ? $data[$field] : 0); } @@ -52,8 +64,7 @@ public function countTotals($grid, $from, $to) $count++; } $data = array(); - foreach ($columns as $field=>$a) - { + foreach ($columns as $field => $a) { if ($a['total'] == 'avg') { if ($field !== '') { if ($count != 0) { @@ -74,7 +85,6 @@ public function countTotals($grid, $from, $to) } $totals = new Varien_Object(); - $totals->setData($data); return $totals; diff --git a/app/code/core/Mage/Review/Model/Mysql4/Review/Summary.php b/app/code/core/Mage/Review/Model/Mysql4/Review/Summary.php index feab4dc93b..bb461a1285 100644 --- a/app/code/core/Mage/Review/Model/Mysql4/Review/Summary.php +++ b/app/code/core/Mage/Review/Model/Mysql4/Review/Summary.php @@ -45,4 +45,35 @@ protected function _getLoadSelect($field, $value, $object) $select->where('store_id = ?', (int)$object->getStoreId()); return $select; } + + /** + * Reaggregate all data by rating summary + * + * @param array $summary + * @return Mage_Review_Model_Mysql4_Review_Summary + */ + public function reAggregate($summary) + { + $select = $this->_getWriteAdapter()->select() + ->from($this->getMainTable()) + ->group(array('entity_pk_value', 'store_id')); + foreach ($this->_getWriteAdapter()->fetchAll($select) as $row) { + if (isset($summary[$row['store_id']]) && isset($summary[$row['store_id']][$row['entity_pk_value']])) { + $summaryItem = $summary[$row['store_id']][$row['entity_pk_value']]; + if ($summaryItem->getCount()) { + $ratingSummary = round($summaryItem->getSum() / $summaryItem->getCount()); + } else { + $ratingSummary = $summaryItem->getSum(); + } + } else { + $ratingSummary = 0; + } + $this->_getWriteAdapter()->update( + $this->getMainTable(), + array('rating_summary' => $ratingSummary), + $this->_getWriteAdapter()->quoteInto('primary_id = ?', $row['primary_id']) + ); + } + return $this; + } } \ No newline at end of file diff --git a/app/code/core/Mage/Rule/Model/Rule.php b/app/code/core/Mage/Rule/Model/Rule.php index e2375df648..86eb0c0682 100644 --- a/app/code/core/Mage/Rule/Model/Rule.php +++ b/app/code/core/Mage/Rule/Model/Rule.php @@ -150,10 +150,10 @@ public function loadPost(array $rule) { $arr = $this->_convertFlatToRecursive($rule); if (isset($arr['conditions'])) { - $this->getConditions()->loadArray($arr['conditions'][1]); + $this->getConditions()->setConditions(array())->loadArray($arr['conditions'][1]); } if (isset($arr['actions'])) { - $this->getActions()->loadArray($arr['actions'][1]); + $this->getActions()->setActions(array())->loadArray($arr['actions'][1]); } return $this; diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Sale/Collection.php b/app/code/core/Mage/Sales/Model/Mysql4/Sale/Collection.php index c2e7d1f644..b7c17d5fb2 100644 --- a/app/code/core/Mage/Sales/Model/Mysql4/Sale/Collection.php +++ b/app/code/core/Mage/Sales/Model/Mysql4/Sale/Collection.php @@ -95,6 +95,8 @@ public function load($printQuery = false, $logQuery = false) ->where('sales.customer_id=?', $this->_customer->getId()); } + Mage::dispatchEvent('sales_sale_collection_query_before', array('collection' => $this)); + $this->printLogQuery($printQuery, $logQuery); try { $values = $this->_read->fetchAll($this->getSelect()->__toString()); @@ -123,6 +125,12 @@ public function load($printQuery = false, $logQuery = false) return $this; } + public function addStoreFilter($storeIds) + { + $this->getSelect()->where('store_id IN (?)', $storeIds); + return $this; + } + /** * Print and/or log query * diff --git a/app/code/core/Mage/Sales/Model/Order/Api.php b/app/code/core/Mage/Sales/Model/Order/Api.php index 7d6ad36589..7b0f7d4be1 100644 --- a/app/code/core/Mage/Sales/Model/Order/Api.php +++ b/app/code/core/Mage/Sales/Model/Order/Api.php @@ -163,8 +163,8 @@ public function addComment($orderIncrementId, $status, $comment = null, $notify Mage::getDesign()->setArea('frontend'); } - $order->sendOrderUpdateEmail($notify, $comment); $order->save(); + $order->sendOrderUpdateEmail($notify, $comment); if ($notify && $comment) { Mage::getDesign()->setStore($oldStore); Mage::getDesign()->setArea($oldArea); diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php index 0865433c99..7a43a01410 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php @@ -166,7 +166,7 @@ protected function insertAddress(&$page, $store = null) protected function _formatAddress($address) { $return = array(); - foreach (split("\|", $address) as $str) { + foreach (split('\|', $address) as $str) { foreach (Mage::helper('core/string')->str_split($str, 65, true, true) as $part) { if (empty($part)) { continue; diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php index 304e489bb8..67d61ba463 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php @@ -77,8 +77,8 @@ public function getPdf($invoices = array()) /* Add table head */ $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4)); - $page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8'); - $page->drawText(Mage::helper('sales')->__('SKU'), 240, $this->y, 'UTF-8'); + $page->drawText(Mage::helper('sales')->__('Products'), 35, $this->y, 'UTF-8'); + $page->drawText(Mage::helper('sales')->__('SKU'), 255, $this->y, 'UTF-8'); $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8'); $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8'); $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8'); @@ -138,7 +138,7 @@ public function newPage(array $settings = array()) $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4)); $page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8'); - $page->drawText(Mage::helper('sales')->__('SKU'), 240, $this->y, 'UTF-8'); + $page->drawText(Mage::helper('sales')->__('SKU'), 255, $this->y, 'UTF-8'); $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8'); $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8'); $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8'); diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php index 0ee2420f2c..602e915296 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php @@ -226,6 +226,11 @@ protected function _formatOptionValue($value) } } + /** + * @deprecated To be Removed on next release + * + * @return array + */ protected function _parseDescription() { $description = $this->getItem()->getDescription(); diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php index dfb68a9750..3cfc6bfbd0 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Creditmemo/Default.php @@ -40,67 +40,26 @@ public function draw() $item = $this->getItem(); $pdf = $this->getPdf(); $page = $this->getPage(); - $shift = array(0, 10, 0); + $lines = array(); + $leftBound = 35; $rightBound = 565; - // draw name -// $this->_setFontRegular(); $x = $leftBound; // draw Product name $lines[0] = array(array( 'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true), 'feed' => $x, )); -// foreach (Mage::helper('core/string')->str_split($item->getName(), $x, true, true) as $key => $part) { -// $page->drawText($part, $x, $pdf->y - $shift[0], 'UTF-8'); -// $shift[0] += 10; -// } - - // draw options - if ($options = $this->getItemOptions()) { - foreach ($options as $option) { - // draw options label - // draw options label - $lines[][] = array( - 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true), - 'font' => 'italic', - 'feed' => $x - ); -// -// $this->_setFontItalic(); -// foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), $x, false, true) as $_option) { -// $page->drawText($_option, $x, $pdf->y - $shift[0], 'UTF-8'); -// $shift[0] += 10; -// } - // draw options value - -// $this->_setFontRegular(); - $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); - $lines[][] = array( - 'text' => Mage::helper('core/string')->str_split($_printValue, 55, true, true), - 'feed' => $x + 5 - ); -// foreach (Mage::helper('core/string')->str_split($_printValue, $x, true, true) as $_value) { -// $page->drawText($_value, $x + 5, $pdf->y - $shift[0], 'UTF-8'); -// $shift[0] += 10; -// } - } - } $x += 220; - // draw SKU $lines[0][] = array( 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), 'feed' => $x ); -// foreach (Mage::helper('core/string')->str_split($this->getSku($item), 25) as $key => $part) { -// $page->drawText($part, $x, $pdf->y - $shift[2], 'UTF-8'); -// $shift[2] += 10; -// } - $x += 100; + $x += 100; // draw Total (ex) $lines[0][] = array( 'text' => $order->formatPriceTxt($item->getRowTotal()), @@ -109,8 +68,8 @@ public function draw() 'align' => 'right', 'width' => 50, ); - $x += 50; + $x += 50; // draw Discount $lines[0][] = array( 'text' => $order->formatPriceTxt(-$item->getDiscountAmount()), @@ -119,8 +78,8 @@ public function draw() 'align' => 'right', 'width' => 50, ); - $x += 50; + $x += 50; // draw QTY $lines[0][] = array( 'text' => $item->getQty()*1, @@ -129,8 +88,8 @@ public function draw() 'align' => 'center', 'width' => 30, ); - $x += 30; + $x += 30; // draw Tax $lines[0][] = array( 'text' => $order->formatPriceTxt($item->getTaxAmount()), @@ -139,8 +98,8 @@ public function draw() 'align' => 'right', 'width' => 45, ); - $x += 45; + $x += 45; // draw Subtotal $lines[0][] = array( 'text' => $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount()), @@ -149,33 +108,26 @@ public function draw() 'align' => 'right' ); -// $font = $this->_setFontBold(); + // draw options + $options = $this->getItemOptions(); + if ($options) { + foreach ($options as $option) { + // draw options label + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), + 'font' => 'italic', + 'feed' => $leftBound + ); + + // draw options value + $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($_printValue, 50, true, true), + 'feed' => $leftBound + 5 + ); + } + } - // draw Total(ex) -// $text = $order->formatPriceTxt($item->getRowTotal()); -// $page->drawText($text, $pdf->getAlignRight($text, $x, 50, $font, 7), $pdf->y, 'UTF-8'); -// $x += 50; -// -// // draw Discount -// $text = $order->formatPriceTxt(-$item->getDiscountAmount()); -// $page->drawText($text, $pdf->getAlignRight($text, $x, 50, $font, 7), $pdf->y, 'UTF-8'); -// $x += 50; -// -// // draw QTY -// $text = $item->getQty() * 1; -// $page->drawText($text, $pdf->getAlignCenter($text, $x, 30, $font, 7), $pdf->y, 'UTF-8'); -// $x += 30; -// -// // draw Tax -// $text = $order->formatPriceTxt($item->getTaxAmount()); -// $page->drawText($text, $pdf->getAlignRight($text, $x, 45, $font, 7, 10), $pdf->y, 'UTF-8'); -// $x += 45; -// -// // draw Total(inc) -// $text = $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount()); -// $page->drawText($text, $pdf->getAlignRight($text, $x, $rightBound - $x, $font, 7, 0), $pdf->y, 'UTF-8'); -// -// $pdf->y -= max($shift) + 10; $lineBlock = array( 'lines' => $lines, 'height' => 10 @@ -184,4 +136,4 @@ public function draw() $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true)); $this->setPage($page); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php index bb8ff9949c..15efaed163 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php @@ -55,7 +55,7 @@ public function draw() // draw SKU $lines[0][] = array( 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), - 'feed' => 240 + 'feed' => 255 ); // draw QTY @@ -64,28 +64,6 @@ public function draw() 'feed' => 435 ); - if ($options = $this->getItemOptions()) { - foreach ($options as $option) { - // draw options label - $lines[][] = array( - 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true), - 'font' => 'italic', - 'feed' => 35 - ); - - if ($option['value']) { - $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); - $values = explode(', ', $_printValue); - foreach ($values as $value) { - $lines[][] = array( - 'text' => Mage::helper('core/string')->str_split($value, 55, true, true), - 'feed' => 40 - ); - } - } - } - } - // draw Price $lines[0][] = array( 'text' => $order->formatPriceTxt($item->getPrice()), @@ -110,6 +88,30 @@ public function draw() 'align' => 'right' ); + // custom options + $options = $this->getItemOptions(); + if ($options) { + foreach ($options as $option) { + // draw options label + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), + 'font' => 'italic', + 'feed' => 35 + ); + + if ($option['value']) { + $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); + $values = explode(', ', $_printValue); + foreach ($values as $value) { + $lines[][] = array( + 'text' => Mage::helper('core/string')->str_split($value, 50, true, true), + 'feed' => 40 + ); + } + } + } + } + $lineBlock = array( 'lines' => $lines, 'height' => 10 diff --git a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php index b1d2aa776e..719d920d3c 100644 --- a/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php +++ b/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php @@ -20,7 +20,7 @@ * * @category Mage * @package Mage_Sales - * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) + * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -40,7 +40,6 @@ class Mage_Sales_Model_Order_Pdf_Items_Shipment_Default extends Mage_Sales_Model */ public function draw() { - $order = $this->getOrder(); $item = $this->getItem(); $pdf = $this->getPdf(); $page = $this->getPage(); @@ -58,21 +57,30 @@ public function draw() 'feed' => 35 ); - if ($options = $this->getItemOptions()) { + // draw SKU + $lines[0][] = array( + 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), + 'feed' => 440 + ); + + // Custom options + $options = $this->getItemOptions(); + if ($options) { foreach ($options as $option) { // draw options label $lines[][] = array( - 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true), + 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true), 'font' => 'italic', 'feed' => 60 ); + // draw options value if ($option['value']) { $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); $values = explode(', ', $_printValue); foreach ($values as $value) { $lines[][] = array( - 'text' => Mage::helper('core/string')->str_split($value, 55, true, true), + 'text' => Mage::helper('core/string')->str_split($value, 50, true, true), 'feed' => 65 ); } @@ -80,12 +88,6 @@ public function draw() } } - // draw SKU - $lines[0][] = array( - 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25), - 'feed' => 440 - ); - $lineBlock = array( 'lines' => $lines, 'height' => 10 diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index 3a1c473841..30efefb937 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -471,6 +471,7 @@ protected function _beforeSave() Mage::helper('sales')->__('Cannot create an empty shipment.') ); } + return parent::_beforeSave(); } protected function _beforeDelete() diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Discount.php b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Discount.php index 0bc9b2d480..f961e0a176 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Discount.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Discount.php @@ -75,11 +75,6 @@ public function collect(Mage_Sales_Model_Quote_Address $address) */ if ($item->getHasChildren() && $item->isChildrenCalculated()) { - $eventArgs['item'] = $item; - Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs); - if ($item->getDiscountAmount() || $item->getFreeShipping()) { - $hasDiscount = true; - } foreach ($item->getChildren() as $child) { $eventArgs['item'] = $child; Mage::dispatchEvent('sales_quote_address_discount_item', $eventArgs); diff --git a/app/code/core/Mage/Sales/Model/Quote/Item.php b/app/code/core/Mage/Sales/Model/Quote/Item.php index c24c0cfba7..9f9f227496 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Item.php +++ b/app/code/core/Mage/Sales/Model/Quote/Item.php @@ -288,6 +288,10 @@ public function representProduct($product) $itemOptions = $this->getOptions(); $productOptions = $product->getCustomOptions(); + if (count($itemOptions) != count($productOptions)) { + return false; + } + foreach ($itemOptions as $option) { $code = $option->getCode(); if (in_array($code, $this->_notRepresentOptions )) { diff --git a/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php b/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php index 7fd762e1ad..1e9d524c78 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php @@ -358,6 +358,26 @@ public function getTaxAmount() } } + /** + * Get item base tax amount + * + * @return decimal + */ + public function getBaseTaxAmount() + { + $priceType = $this->getProduct()->getPriceType(); + if ($this->getHasChildren() && (null !== $priceType) && (int)$priceType === Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { + $baseAmount = 0; + foreach ($this->getChildren() as $child) { + $baseAmount+= $child->getBaseTaxAmount(); + } + return $baseAmount; + } + else { + return $this->_getData('base_tax_amount'); + } + } + /** * Get item price (item price always exclude price) * diff --git a/app/code/core/Mage/Sales/Model/Quote/Payment.php b/app/code/core/Mage/Sales/Model/Quote/Payment.php index 90559d07b3..bc3f41376f 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Payment.php +++ b/app/code/core/Mage/Sales/Model/Quote/Payment.php @@ -107,7 +107,7 @@ protected function _beforeSave() } $method->prepareSave(); if ($this->getQuote()) { - $this->setParentId($this->getQuote()->getId()); + $this->setQuoteId($this->getQuote()->getId()); } return parent::_beforeSave(); } diff --git a/app/code/core/Mage/SalesRule/Model/Rule.php b/app/code/core/Mage/SalesRule/Model/Rule.php index d412895272..432efeb399 100644 --- a/app/code/core/Mage/SalesRule/Model/Rule.php +++ b/app/code/core/Mage/SalesRule/Model/Rule.php @@ -87,10 +87,10 @@ public function loadPost(array $rule) { $arr = $this->_convertFlatToRecursive($rule); if (isset($arr['conditions'])) { - $this->getConditions()->loadArray($arr['conditions'][1]); + $this->getConditions()->setConditions(array())->loadArray($arr['conditions'][1]); } if (isset($arr['actions'])) { - $this->getActions()->loadArray($arr['actions'][1], 'actions'); + $this->getActions()->setActions(array())->loadArray($arr['actions'][1], 'actions'); } return $this; diff --git a/app/code/core/Mage/Sendfriend/etc/config.xml b/app/code/core/Mage/Sendfriend/etc/config.xml index f406a2f580..156b2db85b 100644 --- a/app/code/core/Mage/Sendfriend/etc/config.xml +++ b/app/code/core/Mage/Sendfriend/etc/config.xml @@ -98,11 +98,11 @@ - + singleton sendfriend/sendfriend register - + diff --git a/app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php b/app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php index 607b9bd6fd..078b29ea5f 100644 --- a/app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php +++ b/app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php @@ -1,103 +1,114 @@ - - */ -class Mage_Shipping_Model_Carrier_Flatrate - extends Mage_Shipping_Model_Carrier_Abstract - implements Mage_Shipping_Model_Carrier_Interface -{ - - protected $_code = 'flatrate'; - - /** - * Enter description here... - * - * @param Mage_Shipping_Model_Rate_Request $data - * @return Mage_Shipping_Model_Rate_Result - */ - public function collectRates(Mage_Shipping_Model_Rate_Request $request) - { - if (!$this->getConfigFlag('active')) { - return false; - } - - $freeBoxes = 0; - if ($request->getAllItems()) { - foreach ($request->getAllItems() as $item) { - if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) { - $freeBoxes+=$item->getQty(); - } - } - } - $this->setFreeBoxes($freeBoxes); - - $result = Mage::getModel('shipping/rate_result'); - if ($this->getConfigData('type') == 'O') { // per order - $shippingPrice = $this->getConfigData('price'); - } elseif ($this->getConfigData('type') == 'I') { // per item - $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price')); - } else { - $shippingPrice = false; - } - - $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice); - - if ($shippingPrice !== false) { - $method = Mage::getModel('shipping/rate_result_method'); - - $method->setCarrier('flatrate'); - $method->setCarrierTitle($this->getConfigData('title')); - - $method->setMethod('flatrate'); - $method->setMethodTitle($this->getConfigData('name')); - - if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) { - $shippingPrice = '0.00'; - } - - - $method->setPrice($shippingPrice); - $method->setCost($shippingPrice); - - $result->append($method); - } - - return $result; - } - - public function getAllowedMethods() - { - return array('flatrate'=>$this->getConfigData('name')); - } - -} + + */ +class Mage_Shipping_Model_Carrier_Flatrate + extends Mage_Shipping_Model_Carrier_Abstract + implements Mage_Shipping_Model_Carrier_Interface +{ + + protected $_code = 'flatrate'; + + /** + * Enter description here... + * + * @param Mage_Shipping_Model_Rate_Request $data + * @return Mage_Shipping_Model_Rate_Result + */ + public function collectRates(Mage_Shipping_Model_Rate_Request $request) + { + if (!$this->getConfigFlag('active')) { + return false; + } + + $freeBoxes = 0; + if ($request->getAllItems()) { + foreach ($request->getAllItems() as $item) { + + if ($item->getProduct()->isVirtual() || $item->getParentItem()) { + continue; + } + + if ($item->getHasChildren() && $item->isShipSeparately()) { + foreach ($item->getChildren() as $child) { + if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) { + $freeBoxes += $item->getQty() * $child->getQty(); + } + } + } elseif ($item->getFreeShipping()) { + $freeBoxes += $item->getQty(); + } + } + } + $this->setFreeBoxes($freeBoxes); + + $result = Mage::getModel('shipping/rate_result'); + if ($this->getConfigData('type') == 'O') { // per order + $shippingPrice = $this->getConfigData('price'); + } elseif ($this->getConfigData('type') == 'I') { // per item + $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price')); + } else { + $shippingPrice = false; + } + + $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice); + + if ($shippingPrice !== false) { + $method = Mage::getModel('shipping/rate_result_method'); + + $method->setCarrier('flatrate'); + $method->setCarrierTitle($this->getConfigData('title')); + + $method->setMethod('flatrate'); + $method->setMethodTitle($this->getConfigData('name')); + + if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) { + $shippingPrice = '0.00'; + } + + + $method->setPrice($shippingPrice); + $method->setCost($shippingPrice); + + $result->append($method); + } + + return $result; + } + + public function getAllowedMethods() + { + return array('flatrate'=>$this->getConfigData('name')); + } + +} diff --git a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php index 532d9e4d10..049029971d 100644 --- a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php +++ b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php @@ -168,21 +168,22 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=') $this->_select->where('e.' . $attributeCode . $conditionRule, $value); } else { - if ($attribute['is_global']) { + $this->_select->join( + array('t1_'.$attributeCode => $attribute['table']), + 'e.entity_id=t1_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.store_id=0', + array() + ) + ->where('t1_'.$attributeCode.'.attribute_id=?', $attribute['attribute_id']); + if ($attribute['is_global']) { + $this->_select->where('t1_'.$attributeCode.'.value'.$conditionRule, $value); } else { - $this->_select->join( - array('t1_'.$attributeCode => $attribute['table']), - 'e.entity_id=t1_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.store_id=0', - array() - ) - ->joinLeft( + $this->_select->joinLeft( array('t2_'.$attributeCode => $attribute['table']), $this->_getWriteAdapter()->quoteInto('t1_'.$attributeCode.'.entity_id = t2_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.attribute_id = t2_'.$attributeCode.'.attribute_id AND t2_'.$attributeCode.'.store_id=?', $storeId), array() ) - ->where('t1_'.$attributeCode.'.attribute_id=?', $attribute['attribute_id']) ->where('IFNULL(t2_'.$attributeCode.'.value, t1_'.$attributeCode.'.value)'.$conditionRule, $value); } } diff --git a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php index a8f2754690..e8cd244544 100644 --- a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php +++ b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php @@ -102,21 +102,22 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=') $this->_select->where('e.' . $attributeCode . $conditionRule, $value); } else { - if ($attribute['is_global']) { + $this->_select->join( + array('t1_'.$attributeCode => $attribute['table']), + 'e.entity_id=t1_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.store_id=0', + array() + ) + ->where('t1_'.$attributeCode.'.attribute_id=?', $attribute['attribute_id']); + if ($attribute['is_global']) { + $this->_select->where('t1_'.$attributeCode.'.value'.$conditionRule, $value); } else { - $this->_select->join( - array('t1_'.$attributeCode => $attribute['table']), - 'e.entity_id=t1_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.store_id=0', - array() - ) - ->joinLeft( + $this->_select->joinLeft( array('t2_'.$attributeCode => $attribute['table']), $this->_getWriteAdapter()->quoteInto('t1_'.$attributeCode.'.entity_id = t2_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.attribute_id = t2_'.$attributeCode.'.attribute_id AND t2_'.$attributeCode.'.store_id=?', $storeId), array() ) - ->where('t1_'.$attributeCode.'.attribute_id=?', $attribute['attribute_id']) ->where('IFNULL(t2_'.$attributeCode.'.value, t1_'.$attributeCode.'.value)'.$conditionRule, $value); } } diff --git a/app/code/core/Mage/Sitemap/Model/Sitemap.php b/app/code/core/Mage/Sitemap/Model/Sitemap.php index b0ccdf459b..1e1f2207b4 100644 --- a/app/code/core/Mage/Sitemap/Model/Sitemap.php +++ b/app/code/core/Mage/Sitemap/Model/Sitemap.php @@ -99,6 +99,16 @@ protected function getPath() return $this->_filePath; } + /** + * Return full file name with path + * + * @return string + */ + public function getPreparedFilename() + { + return $this->getPath() . $this->getSitemapFilename(); + } + /** * Generate XML file * diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index 09301792c9..c1a8275268 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -85,7 +85,8 @@ protected function _getProductCollection() ->addTagFilter($this->getTag()->getId()) ->addStoreFilter() ->addMinimalPrice() - ->addUrlRewrite(); + ->addUrlRewrite() + ->setActiveFilter(); Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_productCollection); Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($this->_productCollection); } diff --git a/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php b/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php index db0d993b9e..91d5d674c1 100644 --- a/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php +++ b/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php @@ -34,51 +34,72 @@ class Mage_Tag_Model_Mysql4_Tag_Relation extends Mage_Core_Model_Mysql4_Abstract { + /** + * Initialize resource connection and define table resource + * + */ protected function _construct() { $this->_init('tag/relation', 'tag_relation_id'); } + /** + * Load by Tag and Customer + * + * @param Mage_Tag_Model_Tag_Relation $model + * @return Mage_Tag_Model_Mysql4_Tag_Relation + */ public function loadByTagCustomer($model) { - if( $model->getTagId() && $model->getCustomerId() ) { + if ($model->getTagId() && $model->getCustomerId()) { $read = $this->_getReadAdapter(); - $select = $read->select(); - - $select->from($this->getMainTable()) + $select = $read->select() + ->from($this->getMainTable()) ->join($this->getTable('tag/tag'), "{$this->getTable('tag/tag')}.tag_id = {$this->getMainTable()}.tag_id") ->where("{$this->getMainTable()}.tag_id = ?", $model->getTagId()) ->where('customer_id = ?', $model->getCustomerId()); - if( $model->getProductId() ) { + if ($model->getProductId()) { $select->where("{$this->getMainTable()}.product_id = ?", $model->getProductId()); } - if( $model->hasStoreId() ) { + if ($model->hasStoreId()) { $select->where("{$this->getMainTable()}.store_id = ?", $model->getStoreId()); } $data = $read->fetchRow($select); $model->setData( ( is_array($data) ) ? $data : array() ); - return $this; - } else { - return $this; } + + return $this; } + /** + * Retrieve Tagged Products + * + * @param Mage_Tag_Model_Tag_Relation $model + * @return array + */ public function getProductIds($model) { $select = $this->_getReadAdapter()->select() ->from($this->getMainTable(), 'product_id') - ->where("tag_id = ?", $model->getTagId()) + ->where("tag_id=?", $model->getTagId()) ->where('customer_id=?', $model->getCustomerId()) ->where('active=1'); - if( $model->hasStoreId() ) { + if ($model->hasStoreId()) { $select->where('store_id = ?', $model->getStoreId()); } return $this->_getReadAdapter()->fetchCol($select); } + /** + * Deactivate tag relations by tag and customer + * + * @param int $tagId + * @param int $customerId + * @return Mage_Tag_Model_Mysql4_Tag_Relation + */ public function deactivate($tagId, $customerId) { $condition = $this->_getWriteAdapter()->quoteInto('tag_id = ?', $tagId) . ' AND '; @@ -87,4 +108,4 @@ public function deactivate($tagId, $customerId) $this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition); return $this; } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Tag/Model/Tag/Relation.php b/app/code/core/Mage/Tag/Model/Tag/Relation.php index 60e20936ad..e794aa017e 100644 --- a/app/code/core/Mage/Tag/Model/Tag/Relation.php +++ b/app/code/core/Mage/Tag/Model/Tag/Relation.php @@ -20,27 +20,50 @@ * * @category Mage * @package Mage_Tag - * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) + * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + /** * Tag relation model * * @category Mage * @package Mage_Tag - * @author Magento Core Team + * @author Magento Core Team */ - class Mage_Tag_Model_Tag_Relation extends Mage_Core_Model_Abstract { const STATUS_ACTIVE = 1; + /** + * Initialize resource model + * + */ protected function _construct() { $this->_init('tag/tag_relation'); } + /** + * Retrieve Resource Instance wrapper + * + * @return Mage_Tag_Model_Mysql4_Tag_Relation + */ + protected function _getResource() + { + return parent::_getResource(); + } + + /** + * Load relation by Product (optional), tag, customer and store + * + * @param int $productId + * @param int $tagId + * @param int $customerId + * @param int $storeId + * @return Mage_Tag_Model_Tag_Relation + */ public function loadByTagCustomer($productId=null, $tagId, $customerId, $storeId=null) { $this->setProductId($productId); @@ -53,6 +76,11 @@ public function loadByTagCustomer($productId=null, $tagId, $customerId, $storeId return $this; } + /** + * Retrieve Relation Product Ids + * + * @return array + */ public function getProductIds() { $ids = $this->getData('product_ids'); @@ -63,9 +91,14 @@ public function getProductIds() return $ids; } + /** + * Deactivate tag relations (using current settings) + * + * @return Mage_Tag_Model_Tag_Relation + */ public function deactivate() { $this->_getResource()->deactivate($this->getTagId(), $this->getCustomerId()); return $this; } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Tag/controllers/CustomerController.php b/app/code/core/Mage/Tag/controllers/CustomerController.php index 8db857d137..be66d6017c 100644 --- a/app/code/core/Mage/Tag/controllers/CustomerController.php +++ b/app/code/core/Mage/Tag/controllers/CustomerController.php @@ -159,24 +159,29 @@ public function saveAction() return; } - if($tagId) { + if ($tagId) { try { $productId = 0; - $isNew = false; $message = false; $storeId = Mage::app()->getStore()->getId(); $tagModel = Mage::getModel('tag/tag'); $tagModel->load($tagId); - if( $tagModel->getName() != $tagName ) { + /* @var $tagRelationModel Mage_Tag_Model_Tag_Relation */ + $tagRelationModel = Mage::getModel('tag/tag_relation'); + // rename isset tag + if ($tagModel->getName() != $tagName) { + // deactivate old tagged products + $tagRelationModel->loadByTagCustomer(null, $tagModel->getId(), $customerId, $storeId) + ->deactivate(); + $tagModel->loadByName($tagName); if($tagModel->getId()) { $status = $tagModel->getStatus(); } else { - $isNew = true; $message= Mage::helper('tag')->__('Thank you. Your tag has been accepted for moderation.'); $status = $tagModel->getPendingStatus(); } @@ -187,19 +192,18 @@ public function saveAction() ->save(); } - $tagRalationModel = Mage::getModel('tag/tag_relation'); - $tagRalationModel->loadByTagCustomer(null, $tagId, $customerId, $storeId); + $tagRelationModel->loadByTagCustomer(null, $tagId, $customerId, $storeId); - if ($tagRalationModel->getCustomerId() == $customerId ) { - $productIds = $tagRalationModel->getProductIds(); - if ($tagRalationModel->getTagId()!=$tagModel->getId()) { - $tagRalationModel->deactivate(); + if ($tagRelationModel->getCustomerId() == $customerId ) { + $productIds = $tagRelationModel->getProductIds(); + if ($tagRelationModel->getTagId()!=$tagModel->getId()) { + $tagRelationModel->deactivate(); } else { - $tagRalationModel->delete(); + $tagRelationModel->delete(); } foreach ($productIds as $productId) { - $newTagRalationModel = Mage::getModel('tag/tag_relation') + Mage::getModel('tag/tag_relation') ->setTagId($tagModel->getId()) ->setCustomerId($customerId) ->setStoreId($storeId) @@ -209,16 +213,21 @@ public function saveAction() } } - if( $tagModel->getId() ) { + if ($tagModel->getId()) { $tagModel->aggregate(); $this->getResponse()->setRedirect(Mage::getUrl('*/*/')); } + $message = ($message) ? $message : Mage::helper('tag')->__('Your tag was successfully saved'); Mage::getSingleton('tag/session')->addSuccess($message); $this->_redirect('*/*/'); return; - } catch (Exception $e) { - Mage::getSingleton('tag/session')->addError( + } + catch (Mage_Core_Exception $e) { + Mage::getSingleton('tag/session')->addError($e->getMessage()); + } + catch (Exception $e) { + Mage::getSingleton('tag/session')->addException($e, Mage::helper('tag')->__('Unable to save your tag. Please, try again later.') ); } diff --git a/app/code/core/Mage/Tax/Model/Calculation/Rate.php b/app/code/core/Mage/Tax/Model/Calculation/Rate.php index 7f013bca80..6ff5d18c0e 100644 --- a/app/code/core/Mage/Tax/Model/Calculation/Rate.php +++ b/app/code/core/Mage/Tax/Model/Calculation/Rate.php @@ -127,4 +127,17 @@ public function deleteAllRates() Mage::dispatchEvent('tax_settings_change_after'); return $this; } + + /** + * Load rate model by code + * + * @param string $code + * @return Mage_Tax_Model_Calculation_Rate + */ + public function loadByCode($code) + { + $this->load($code, 'code'); + return $this; + } + } \ No newline at end of file diff --git a/app/code/core/Mage/Tax/Model/Mysql4/Setup.php b/app/code/core/Mage/Tax/Model/Mysql4/Setup.php index 972e951c70..32a573b14e 100644 --- a/app/code/core/Mage/Tax/Model/Mysql4/Setup.php +++ b/app/code/core/Mage/Tax/Model/Mysql4/Setup.php @@ -18,19 +18,25 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_Tax - * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Tax + * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * Tax Setup Model + * Tax Setup Resource Model * - * @author Magento Core Team + * @category Mage + * @package Mage_Tax + * @author Magento Core Team */ class Mage_Tax_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup { + /** + * Convert old Tax data + * + */ public function convertOldTaxData() { $oldRules = $this->_loadTableData('tax_rule'); @@ -54,18 +60,18 @@ public function convertOldTaxData() continue; } - $region = Mage::getModel('directory/region')->load($rate['tax_region_id']); + $region = Mage::getModel('directory/region')->load($rate['tax_region_id']); $regionName = $region->getCode() ? $region->getCode() : '*'; - $code = "{$rate['tax_country_id']}-{$regionName}-{$rate['tax_postcode']}-{$type['type_name']}"; + $code = "{$rate['tax_country_id']}-{$regionName}-{$rate['tax_postcode']}-{$type['type_name']}"; if ($rateValue > 0) { $insertData = array( - 'tax_country_id'=>$rate['tax_country_id'], - 'tax_region_id'=>$rate['tax_region_id'], - 'tax_postcode'=>$rate['tax_postcode'], - 'code'=>$code, - 'rate'=>$rateValue, - ); + 'tax_country_id' => $rate['tax_country_id'], + 'tax_region_id' => $rate['tax_region_id'], + 'tax_postcode' => $rate['tax_postcode'], + 'code' => $code, + 'rate' => $rateValue, + ); $newRateModel = Mage::getModel('tax/calculation_rate'); @@ -77,32 +83,37 @@ public function convertOldTaxData() } foreach ($oldRules as $rule) { - if (!isset($ratesByType[$rule['tax_rate_type_id']]) || !count($ratesByType[$rule['tax_rate_type_id']])){ + if (!isset($ratesByType[$rule['tax_rate_type_id']]) || !count($ratesByType[$rule['tax_rate_type_id']])) { continue; } $customerTaxClasses = array($rule['tax_customer_class_id']); $productTaxClasses = array($rule['tax_product_class_id']); - $ctc = Mage::getModel('tax/class')->load($rule['tax_customer_class_id']); - $ptc = Mage::getModel('tax/class')->load($rule['tax_product_class_id']); - $type = $rateById[$rule['tax_rate_type_id']]; + $ctc = Mage::getModel('tax/class')->load($rule['tax_customer_class_id']); + $ptc = Mage::getModel('tax/class')->load($rule['tax_product_class_id']); + $type = $rateById[$rule['tax_rate_type_id']]; - $rates = $ratesByType[$rule['tax_rate_type_id']]; - $code = "{$ctc->getClassName()}-{$ptc->getClassName()}-{$type}"; + $rates = $ratesByType[$rule['tax_rate_type_id']]; + $code = "{$ctc->getClassName()}-{$ptc->getClassName()}-{$type}"; $ruleData = array( - 'tax_rate'=>$rates, - 'tax_product_class'=>$productTaxClasses, - 'tax_customer_class'=>$customerTaxClasses, - 'code'=>$code, - 'priority'=>1, - 'position'=>1 - ); + 'tax_rate' => $rates, + 'tax_product_class' => $productTaxClasses, + 'tax_customer_class' => $customerTaxClasses, + 'code' => $code, + 'priority' => 1, + 'position' => 1 + ); Mage::getModel('tax/calculation_rule')->setData($ruleData)->save(); } } + /** + * Load Tax Table Data + * + * @return array + */ protected function _loadTableData($table) { $table = $this->getTable($table); @@ -111,20 +122,24 @@ protected function _loadTableData($table) return $this->_conn->fetchAll($select); } + /** + * Load Old Rate Data + * + * @return array + */ protected function _loadOldRates($oldRateTypes) { - - $table = $this->getTable('tax_rate'); - $select = $this->_conn->select(); - $select->from(array('main_table'=>$table)); + $table = $this->getTable('tax_rate'); + $select = $this->_conn->select() + ->from(array('main_table'=>$table)); foreach ($oldRateTypes as $type){ $id = $type['type_id']; $select->joinLeft( - array("data_{$id}"=>$this->getTable('tax_rate_data')), - "data_{$id}.rate_type_id = {$id} AND data_{$id}.tax_rate_id = main_table.tax_rate_id", - array("data_{$id}"=>'rate_value') - ); + array("data_{$id}"=>$this->getTable('tax_rate_data')), + "data_{$id}.rate_type_id = {$id} AND data_{$id}.tax_rate_id = main_table.tax_rate_id", + array("data_{$id}"=>'rate_value') + ); } return $this->_conn->fetchAll($select); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.6-0.7.7.php b/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.6-0.7.7.php index 4c812a1eb8..65cf8e1db7 100644 --- a/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.6-0.7.7.php +++ b/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.6-0.7.7.php @@ -24,8 +24,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +/* @var $installer Mage_Tax_Model_Mysql4_Setup */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ + $installer->startSetup(); @@ -40,7 +41,7 @@ PRIMARY KEY ( `tax_calculation_rate_id` ), KEY `IDX_TAX_CALCULATION_RATE` (`tax_country_id`, `tax_region_id`, `tax_postcode`), KEY `IDX_TAX_CALCULATION_RATE_CODE` (`code`) -) ENGINE = InnoDB; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; CREATE TABLE `{$installer->getTable('tax_calculation_rate_title')}` ( `tax_calculation_rate_title_id` INT NOT NULL AUTO_INCREMENT , @@ -51,7 +52,7 @@ KEY `IDX_TAX_CALCULATION_RATE_TITLE` (`tax_calculation_rate_id`, `store_id`), KEY `FK_TAX_CALCULATION_RATE_TITLE_RATE` (`tax_calculation_rate_id`), KEY `FK_TAX_CALCULATION_RATE_TITLE_STORE` (`store_id`) -) ENGINE = InnoDB; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; CREATE TABLE `{$installer->getTable('tax_calculation_rule')}` ( `tax_calculation_rule_id` INT NOT NULL AUTO_INCREMENT , @@ -61,7 +62,7 @@ PRIMARY KEY ( `tax_calculation_rule_id` ), KEY `IDX_TAX_CALCULATION_RULE` (`priority`, `position`, `tax_calculation_rule_id`), KEY `IDX_TAX_CALCULATION_RULE_CODE` (`code`) -) ENGINE = InnoDB; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; CREATE TABLE `{$installer->getTable('tax_calculation')}` ( `tax_calculation_rate_id` INT NOT NULL, @@ -73,7 +74,7 @@ KEY `FK_TAX_CALCULATION_CTC` (`customer_tax_class_id`), KEY `FK_TAX_CALCULATION_PTC` (`product_tax_class_id`), KEY `IDX_TAX_CALCULATION` (`tax_calculation_rate_id`, `customer_tax_class_id`, `product_tax_class_id`) -) ENGINE = InnoDB; +) ENGINE = InnoDB DEFAULT CHARSET = utf8; "); @@ -86,8 +87,7 @@ $installer->getConnection()->addConstraint('FK_TAX_CALCULATION_PTC', $installer->getTable('tax_calculation'), 'product_tax_class_id', $installer->getTable('tax_class'), 'class_id'); -$this->convertOldTaxData(); - +$installer->convertOldTaxData(); $installer->run(" DROP TABLE `{$installer->getTable('tax_rule')}`; @@ -96,5 +96,4 @@ DROP TABLE `{$installer->getTable('tax_rate')}`; "); - -$installer->endSetup(); \ No newline at end of file +$installer->endSetup(); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php index 3ee8bc0aa1..de9982aa20 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php @@ -179,7 +179,11 @@ protected function _getXmlQuotes() $package = $xml->addChild('Package'); $package->addAttribute('ID', 0); - $package->addChild('Service', $r->getService()); + $service = $this->getCode('service_to_code', $r->getService()); + if (!$service) { + $service = $r->getService(); + } + $package->addChild('Service', $service); // no matter Letter, Flat or Parcel, use Parcel if ($r->getService() == 'FIRST CLASS') { @@ -192,7 +196,12 @@ protected function _getXmlQuotes() $package->addChild('Ounces', $r->getWeightOunces()); // $package->addChild('Pounds', '0'); // $package->addChild('Ounces', '3'); - $package->addChild('Container', $r->getContainer()); + + // Because some methods don't accept VARIABLE and (NON)RECTANGULAR containers + if (strtoupper($r->getContainer()) == 'FLAT RATE ENVELOPE' || strtoupper($r->getContainer()) == 'FLAT RATE BOX') { + $package->addChild('Container', $r->getContainer()); + } + $package->addChild('Size', $r->getSize()); $package->addChild('Machinable', $r->getMachinable()); diff --git a/app/code/core/Mage/Wishlist/Model/Observer.php b/app/code/core/Mage/Wishlist/Model/Observer.php index 33203657e4..982af932d6 100644 --- a/app/code/core/Mage/Wishlist/Model/Observer.php +++ b/app/code/core/Mage/Wishlist/Model/Observer.php @@ -86,7 +86,7 @@ public function processCartUpdateBefore($observer) public function processAddToCart($observer) { - $request = $observer->getRequest(); + $request = $observer->getEvent()->getRequest(); $sharedWishlist = Mage::getSingleton('checkout/session')->getSharedWishlist(); $messages = Mage::getSingleton('checkout/session')->getWishlistPendingMessages(); $urls = Mage::getSingleton('checkout/session')->getWishlistPendingUrls(); @@ -129,7 +129,7 @@ public function processAddToCart($observer) Mage::getSingleton('checkout/session')->addError($message); - $observer->getResponse()->setRedirect($url); + $observer->getEvent()->getResponse()->setRedirect($url); Mage::getSingleton('checkout/session')->setNoCartRedirect(true); } } diff --git a/app/code/core/Mage/Wishlist/Model/Wishlist.php b/app/code/core/Mage/Wishlist/Model/Wishlist.php index 44d0f69f3e..bb13f8ba4a 100644 --- a/app/code/core/Mage/Wishlist/Model/Wishlist.php +++ b/app/code/core/Mage/Wishlist/Model/Wishlist.php @@ -205,14 +205,23 @@ public function getDataForSave() } /** - * Retrieve shared store ids + * Retrieve shared store ids for current website or all stores if $current is false * + * @param bool $current Use current website or not * @return array */ - public function getSharedStoreIds() + public function getSharedStoreIds($current = true) { if (is_null($this->_storeIds)) { - $this->_storeIds = $this->getStore()->getWebsite()->getStoreIds(); + if ($current) { + $this->_storeIds = $this->getStore()->getWebsite()->getStoreIds(); + } else { + $_storeIds = array(); + foreach (Mage::app()->getStores() as $store) { + $_storeIds[] = $store->getId(); + } + $this->_storeIds = $_storeIds; + } } return $this->_storeIds; } diff --git a/app/code/core/Mage/Wishlist/etc/system.xml b/app/code/core/Mage/Wishlist/etc/system.xml index bb8e97562f..6c221c0c07 100644 --- a/app/code/core/Mage/Wishlist/etc/system.xml +++ b/app/code/core/Mage/Wishlist/etc/system.xml @@ -34,7 +34,7 @@ 140 1 1 - 0 + 1 diff --git a/app/design/adminhtml/default/default/layout/customer.xml b/app/design/adminhtml/default/default/layout/customer.xml index 15e15bd5f8..c6dc6844c1 100644 --- a/app/design/adminhtml/default/default/layout/customer.xml +++ b/app/design/adminhtml/default/default/layout/customer.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category design_default - * @package Enterprise + * @package Mage * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -44,4 +44,4 @@ - \ No newline at end of file + diff --git a/app/design/adminhtml/default/default/layout/main.xml b/app/design/adminhtml/default/default/layout/main.xml index 3229b55b5f..90846eb814 100644 --- a/app/design/adminhtml/default/default/layout/main.xml +++ b/app/design/adminhtml/default/default/layout/main.xml @@ -147,9 +147,7 @@ Access denied - - Access denied

Access denied.

]]>
-
+
diff --git a/app/design/adminhtml/default/default/template/access_denied.phtml b/app/design/adminhtml/default/default/template/access_denied.phtml new file mode 100644 index 0000000000..bac8dce66a --- /dev/null +++ b/app/design/adminhtml/default/default/template/access_denied.phtml @@ -0,0 +1,40 @@ + + +

helper('adminhtml')->__('Access denied') ?>

+hasAvailaleResources()): ?> +

+helper('adminhtml')->__('Please try to logout and sign in again.') ?>
+helper('adminhtml')->__('If this message persists, please contact the store owner.') ?> +

+ +

helper('adminhtml')->__('Access denied.') ?>

+ \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml index 33621f4cfd..8ca47db708 100644 --- a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml +++ b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/create/items/renderer.phtml @@ -222,15 +222,17 @@   + canParentReturnToStock($_item)) : ?> canShowPriceInfo($_item)): ?> - canReturnToStock()) : ?> + canReturnItemToStock($_item)) : ?> getBackToStock()):?> checked="checked" />   + canShowPriceInfo($_item)): ?> canEditQty()) : ?> diff --git a/app/design/adminhtml/default/default/template/catalog/category/edit.phtml b/app/design/adminhtml/default/default/template/catalog/category/edit.phtml index fdb5458926..40da9ae757 100644 --- a/app/design/adminhtml/default/default/template/catalog/category/edit.phtml +++ b/app/design/adminhtml/default/default/template/catalog/category/edit.phtml @@ -96,6 +96,12 @@ } } }); + var headers = $$('div.content-header-floating'); + for(var i=0; i
- - - - - -

getHeader() . ($this->getCategoryId() ? ' (' . Mage::helper('catalog')->__('ID: %s', $this->getCategoryId()) . ')' : '') ?>

+

getHeader() . ($this->getCategoryId() ? ' (' . Mage::helper('catalog')->__('ID: %s', $this->getCategoryId()) . ')' : '') ?>

+

getResetButtonHtml() ?> getCategoryId()): ?> getDeleteButtonHtml() ?> getAdditionalButtonsHtml(); ?> getSaveButtonHtml() ?> -

+

hasStoreRootCategory()): ?> getTabsHtml() ?> @@ -198,5 +194,8 @@ } $('active_tab_id').tabsJsObject = ; + +updateTopButtonToolbarToggle(); + //]]> \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml b/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml index c3912b21b4..57e804c3c2 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml @@ -52,8 +52,12 @@ -

getAddGroupButton() ?> getDeleteGroupButton() ?>

-

__('Double click on a group to rename it') ?>

+ + getIsReadOnly()): ?> +

getAddGroupButton() ?> getDeleteGroupButton() ?>

+

__('Double click on a group to rename it') ?>

+ + getSetsFilterHtml() ?> getGroupTreeHtml() ?> @@ -70,6 +74,9 @@
\ No newline at end of file diff --git a/app/design/frontend/default/default/template/email/order/items.phtml b/app/design/frontend/default/default/template/email/order/items.phtml index 746e4e625c..bc8d188102 100644 --- a/app/design/frontend/default/default/template/email/order/items.phtml +++ b/app/design/frontend/default/default/template/email/order/items.phtml @@ -46,7 +46,7 @@ getGiftMessageId() && $_giftMessage = $this->helper('giftmessage/message')->getGiftMessage($_order->getGiftMessageId())): ?> - __('Gift Message') ?> + __('Gift Message for this Order') ?>
__('From:'); ?> htmlEscape($_giftMessage->getSender()) ?>
__('To:'); ?> htmlEscape($_giftMessage->getRecipient()) ?>
__('Message:'); ?>
htmlEscape($_giftMessage->getMessage()) ?> @@ -81,4 +81,4 @@ - \ No newline at end of file + diff --git a/app/etc/local.xml.additional b/app/etc/local.xml.additional index 6c2eb5aae0..d1530b7c83 100644 --- a/app/etc/local.xml.additional +++ b/app/etc/local.xml.additional @@ -51,5 +51,9 @@ to app/etc/local.xml manually. -
+ + HTTP_X_REAL_IP + HTTP_X_FORWARDED_FOR + +
diff --git a/app/etc/local.xml.template b/app/etc/local.xml.template index f8e9a42867..578b008004 100644 --- a/app/etc/local.xml.template +++ b/app/etc/local.xml.template @@ -49,8 +49,8 @@ {{session_save}} - - + + @@ -58,5 +58,5 @@ - + diff --git a/app/etc/modules/Mage_All.xml b/app/etc/modules/Mage_All.xml index a062041f08..1fb9173d56 100644 --- a/app/etc/modules/Mage_All.xml +++ b/app/etc/modules/Mage_All.xml @@ -110,22 +110,31 @@ - + true core + + - - + + true core - - + + - + + + true + core + + + + true core @@ -365,15 +374,6 @@ - - true - core - - - - - - true core diff --git a/app/locale/en_US/Mage_Adminhtml.csv b/app/locale/en_US/Mage_Adminhtml.csv index 68d9465745..7258610027 100644 --- a/app/locale/en_US/Mage_Adminhtml.csv +++ b/app/locale/en_US/Mage_Adminhtml.csv @@ -30,7 +30,6 @@ "2YTD","2YTD" "6 Hours","6 Hours" "

404 Error

Page not found.

","

404 Error

Page not found.

" -"

Access denied

Access denied.

","

Access denied

Access denied.

" "A new password was sent to your email address. Please check your email and click Back to Login.","A new password was sent to your email address. Please check your email and click Back to Login." "API Stability","API Stability" "API Version","API Version" @@ -38,6 +37,8 @@ "About the calendar","About the calendar" "Access Denied.","Access Denied." "Access Deny","Access Deny" +"Access denied","Access denied" +"Access denied.","Access denied." "Account Created in:","Account Created in:" "Account Created on (%s):","Account Created on (%s):" "Account Created on:","Account Created on:" @@ -53,24 +54,24 @@ "Add Exception","Add Exception" "Add Field Mapping","Add Field Mapping" "Add Field with URL:","Add Field with URL:" +"Add Gift Card","Add Gift Card" "Add Maintainer","Add Maintainer" "Add New Image","Add New Image" "Add New Profile","Add New Profile" "Add New Role","Add New Role" "Add New Template","Add New Template" -"Add New Urlrewrite","Add New Urlrewrite" +"Add New URL Rewrite","Add New URL Rewrite" "Add New User","Add New User" "Add New osCommerce Profile","Add New osCommerce Profile" "Add PHP Extension dependency","Add PHP Extension dependency" "Add Package dependency","Add Package dependency" "Add Subpackage dependency","Add Subpackage dependency" -"Add Urlrewrite","Add Urlrewrite" -"Add Urlrewrite for a Category","Add Urlrewrite for a Category" -"Add Urlrewrite for a Product","Add Urlrewrite for a Product" +"Add URL Rewrite","Add URL Rewrite" +"Add URL Rewrite for a Category","Add URL Rewrite for a Category" +"Add URL Rewrite for a Product","Add URL Rewrite for a Product" "Add after","Add after" "Add new Role","Add new Role" "Add new store view map","Add new store view map" -"Add new website map","Add new website map" "Address Type:","Address Type:" "Admin","Admin" "Advanced Admin Section","Advanced Admin Section" @@ -147,6 +148,7 @@ "Can not delete tracking number.","Can not delete tracking number." "Can not do credit memo for order","Can not do credit memo for order" "Can not do invoice for order","Can not do invoice for order" +"Can not do shipment for order separate from invoice.","Can not do shipment for order separate from invoice." "Can not do shipment for order.","Can not do shipment for order." "Can not initialize shipment for adding tracking number.","Can not initialize shipment for adding tracking number." "Can not initialize shipment for delete tracking number.","Can not initialize shipment for delete tracking number." @@ -162,6 +164,8 @@ "Cancel","Cancel" "Card Verification Number","Card Verification Number" "Catalog","Catalog" +"Catalog Index rebuild error. Please try again later","Catalog Index rebuild error. Please try again later" +"Catalog Index was rebuilt successfully","Catalog Index was rebuilt successfully" "Catalog Rewrites","Catalog Rewrites" "Catalog Rewrites was refreshed successfully","Catalog Rewrites was refreshed successfully" "Catalog Rewrites were refreshed successfully","Catalog Rewrites were refreshed successfully" @@ -185,6 +189,7 @@ "Confirmed email:","Confirmed email:" "Conflicts","Conflicts" "Connect with the Magento Community","Connect with the Magento Community" +"Content","Content" "Contents","Contents" "Convert to Plain Text","Convert to Plain Text" "Cookie (Unsafe)","Cookie (Unsafe)" @@ -197,9 +202,8 @@ "Create Extension Package","Create Extension Package" "Create New Attribute","Create New Attribute" "Create New Staging Store View","Create New Staging Store View" -"Create Urlrewrite:","Create Urlrewrite:" +"Create URL Rewrite:","Create URL Rewrite:" "Create a backup","Create a backup" -"Created %s items","Created %s items" "Created At","Created At" "Credit Card Number","Credit Card Number" "Credit Card Number: xxxx-%s","Credit Card Number: xxxx-%s" @@ -288,7 +292,7 @@ "Edit System Template","Edit System Template" "Edit Tag","Edit Tag" "Edit Template","Edit Template" -"Edit Urlrewrite","Edit Urlrewrite" +"Edit URL Rewrite","Edit URL Rewrite" "Edit User","Edit User" "Edit User '%s'","Edit User '%s'" "Edit Website","Edit Website" @@ -308,6 +312,7 @@ "Error while create backup. Please try again later","Error while create backup. Please try again later" "Error while deleting this role. Please try again later.","Error while deleting this role. Please try again later." "Error while deleting this set.","Error while deleting this set." +"Error while deleting this template. Please try again later.","Error while deleting this template. Please try again later." "Error while finished process. Please refresh cache","Error while finished process. Please refresh cache" "Error while refreshed Catalog Rewrites. Please try again later","Error while refreshed Catalog Rewrites. Please try again later" "Error while refreshed Layered Navigation Indices. Please try again later","Error while refreshed Layered Navigation Indices. Please try again later" @@ -315,6 +320,7 @@ "Error while saving account. Please try again later","Error while saving account. Please try again later" "Error while saving this configuration: ","Error while saving this configuration: " "Error while saving this role. Please try again later.","Error while saving this role. Please try again later." +"Error while saving this template. Please try again later.","Error while saving this template. Please try again later." "Error while updating selected review(s). Please try again later.","Error while updating selected review(s). Please try again later." "Excl. Tax","Excl. Tax" "Exclude","Exclude" @@ -339,7 +345,6 @@ "File name:","File name:" "File size should be more than 0 bytes","File size should be more than 0 bytes" "Final Price","Final Price" -"Finished items creation.","Finished items creation." "Finished profile execution.","Finished profile execution." "First Name","First Name" "First Name:","First Name:" @@ -349,6 +354,7 @@ "Flat Catalog Category was rebuilt successfully","Flat Catalog Category was rebuilt successfully" "Flat Catalog Product rebuild error. Please try again later","Flat Catalog Product rebuild error. Please try again later" "Flat Catalog Product was rebuilt successfully","Flat Catalog Product was rebuilt successfully" +"Folder","Folder" "For category","For category" "For latest version visit: %s","For latest version visit: %s" "For product","For product" @@ -378,6 +384,7 @@ "ID","ID" "ID Path","ID Path" "IP Address","IP Address" +"If this message persists, please contact the store owner.","If this message persists, please contact the store owner." "Ignore","Ignore" "Image cache was cleared successfully","Image cache was cleared successfully" "Images","Images" @@ -414,11 +421,13 @@ "Invalid URL","Invalid URL" "Invalid Username or Password.","Invalid Username or Password." "Invalid directory: %s","Invalid directory: %s" +"Invalid email address ""%s""","Invalid email address ""%s""" "Invalid file: %s","Invalid file: %s" "Invalid input data for %s => %s rate","Invalid input data for %s => %s rate" "Invalid input:","Invalid input:" "Invalid parrent block for this block","Invalid parrent block for this block" "Invalid section value","Invalid section value" +"Invalid sender name ""%s""","Invalid sender name ""%s""" "Invalid store value","Invalid store value" "Invalid website value","Invalid website value" "Inventory Stock Status","Inventory Stock Status" @@ -437,7 +446,6 @@ "Issue Number","Issue Number" "Issuer: %s","Issuer: %s" "Items","Items" -"Items to merge","Items to merge" "Kb","Kb" "Last 24 hours","Last 24 hours" "Last 5 Orders","Last 5 Orders" @@ -496,7 +504,6 @@ "Manage Stores","Manage Stores" "Manage osCommerce Orders","Manage osCommerce Orders" "Manage osCommerce Profiles","Manage osCommerce Profiles" -"Mapping Configuration","Mapping Configuration" "Matched expression","Matched expression" "Max","Max" "Maximum","Maximum" @@ -506,7 +513,6 @@ "Messages Inbox","Messages Inbox" "Min","Min" "Minimum","Minimum" -"Module version conflict!","Module version conflict!" "Month","Month" "Most Viewed Products","Most Viewed Products" "Multiple Select","Multiple Select" @@ -591,6 +597,8 @@ "Path:","Path:" "PayPal Email","PayPal Email" "Payment Data Transfer (PDT)","Payment Data Transfer (PDT)" +"Payment method instance is not available","Payment method instance is not available" +"Payment method is not available","Payment method is not available" "Payment method must be specified","Payment method must be specified" "Pending Tags","Pending Tags" "Pending installation...","Pending installation..." @@ -636,6 +644,7 @@ "Please select tag(s)","Please select tag(s)" "Please specify admin custom URL","Please specify admin custom URL" "Please specify at least start or end date.","Please specify at least start or end date." +"Please try to logout and sign in again.","Please try to logout and sign in again." "Please use in this field only ""a-z,0-9,_"".","Please use in this field only ""a-z,0-9,_""." "Please use letters only (a-z) in this field.","Please use letters only (a-z) in this field." "Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.","Please use numbers only in this field. please avoid spaces or other characters such as dots or commas." @@ -662,7 +671,6 @@ "Price alert subscription was saved successfully","Price alert subscription was saved successfully" "Price:","Price:" "Primary Billing Address","Primary Billing Address" -"Processed %s%% %s/%d items","Processed %s%% %s/%d items" "Processed %s%% %s/%d records","Processed %s%% %s/%d records" "Product","Product" "Product Thumbnail Itself","Product Thumbnail Itself" @@ -691,6 +699,7 @@ "Rating was successfully saved","Rating was successfully saved" "Read details","Read details" "Rebuild","Rebuild" +"Rebuild Catalog Index","Rebuild Catalog Index" "Rebuild Flat Catalog Category","Rebuild Flat Catalog Category" "Rebuild Flat Catalog Product","Rebuild Flat Catalog Product" "Recent Orders","Recent Orders" @@ -726,6 +735,7 @@ "Role Information","Role Information" "Role Name","Role Name" "Role Resources","Role Resources" +"Role Scopes","Role Scopes" "Role Users","Role Users" "Role successfully deleted.","Role successfully deleted." "Role successfully saved.","Role successfully saved." @@ -747,6 +757,7 @@ "Samples","Samples" "Save","Save" "Save & Generate","Save & Generate" +"Save & Send Email","Save & Send Email" "Save Account","Save Account" "Save And Continue Edit","Save And Continue Edit" "Save As...","Save As..." @@ -775,7 +786,6 @@ "Select Range","Select Range" "Select Visible","Select Visible" "Select date","Select date" -"Select website from map","Select website from map" "Select website to map","Select website to map" "Selected allow currency ""%s"" is not available in installed currencies","Selected allow currency ""%s"" is not available in installed currencies" "Selected base currency is not available in installed currencies","Selected base currency is not available in installed currencies" @@ -812,6 +822,7 @@ "Spreadsheet Name:","Spreadsheet Name:" "Stability","Stability" "Staging Store: ","Staging Store: " +"Staging Website - Merge Configuration","Staging Website - Merge Configuration" "Staging Website: ","Staging Website: " "Start Date","Start Date" "Starting profile execution, please wait...","Starting profile execution, please wait..." @@ -821,6 +832,7 @@ "Stock Quantity:","Stock Quantity:" "Stock notification was saved successfully","Stock notification was saved successfully" "Store","Store" +"Store Credit","Store Credit" "Store Email Addresses Section","Store Email Addresses Section" "Store View","Store View" "Store:","Store:" @@ -862,6 +874,7 @@ "This account is inactive.","This account is inactive." "This attribute set don\'t have attributes which we can use for configurable product","This attribute set don\'t have attributes which we can use for configurable product" "This attribute shares the same value in all the stores","This attribute shares the same value in all the stores" +"This is a demo store. Any orders placed through this store will not be honored or fulfilled.","This is a demo store. Any orders placed through this store will not be honored or fulfilled." "This is a required field.","This is a required field." "This product is currently disabled","This product is currently disabled" "This section is not allowed.","This section is not allowed." @@ -890,6 +903,10 @@ "Transactional Emails","Transactional Emails" "Type","Type" "Type:","Type:" +"URL Rewrite Information","URL Rewrite Information" +"URL Rewrite Management","URL Rewrite Management" +"URL Rewrite has been successfully deleted","URL Rewrite has been successfully deleted" +"URL Rewrite has been successfully saved","URL Rewrite has been successfully saved" "Unable to find a poll to delete","Unable to find a poll to delete" "Unable to find a tag to delete","Unable to find a tag to delete" "Unable to find a user to delete","Unable to find a user to delete" @@ -900,6 +917,7 @@ "Uninstalling selected packages, please wait...","Uninstalling selected packages, please wait..." "Unknown","Unknown" "Unknown error","Unknown error" +"Unlimited","Unlimited" "Unselect All","Unselect All" "Unselect Visible","Unselect Visible" "Update","Update" @@ -921,10 +939,9 @@ "Upload and Install","Upload and Install" "Upload import file","Upload import file" "Upload local file:","Upload local file:" -"Url Rewrite Management","Url Rewrite Management" -"Urlrewrite Information","Urlrewrite Information" "Use Config Settings","Use Config Settings" "Use Default Value","Use Default Value" +"Use Store Credit (%s available)","Use Store Credit (%s available)" "Use default","Use default" "Use website","Use website" "User","User" @@ -955,17 +972,17 @@ "Warning!\r\nThis action will remove those users from already assigned roles\r\nAre you sure?","Warning!\r\nThis action will remove those users from already assigned roles\r\nAre you sure?" "Warning: Please don't close window during importing/exporting data","Warning: Please don't close window during importing/exporting data" "Watermark File for %s","Watermark File for %s" +"We detected that your JavaScript seem to be disabled.","We detected that your JavaScript seem to be disabled." "We\'re in our typing table, coding away more features for Magento. Thank you for your patience.","We\'re in our typing table, coding away more features for Magento. Thank you for your patience." "Web Section","Web Section" "Web Services","Web Services" "Web services","Web services" "Website","Website" "Website: ","Website: " -"Websites","Websites" -"Websites / Stores","Websites / Stores" "What is this?","What is this?" "Wishlist Report","Wishlist Report" "Wrong column format","Wrong column format" +"Wrong newsletter template.","Wrong newsletter template." "Wrong tab configuration","Wrong tab configuration" "XML","XML" "YTD","YTD" @@ -977,6 +994,7 @@ "You have","You have" "You have not enought permissions to login.","You have not enought permissions to login." "You have not enought permissions to use this functionality.","You have not enought permissions to use this functionality." +"You must have JavaScript enabled in your browser to utilize the functionality of this website.","You must have JavaScript enabled in your browser to utilize the functionality of this website." "You need specify carrier.","You need specify carrier." "You need to specify order items","You need to specify order items" "You successfully logged out.","You successfully logged out." @@ -1004,4 +1022,4 @@ "store(%s) scope","store(%s) scope" "to","to" "website(%s) scope","website(%s) scope" -"{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure Url / Base Secure Url. It is highly recommended to change this value in your Magento configuration.","{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure Url / Base Secure Url. It is highly recommended to change this value in your Magento configuration." +"{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. It is highly recommended to change this value in your Magento configuration.","{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. It is highly recommended to change this value in your Magento configuration." diff --git a/app/locale/en_US/Mage_Api.csv b/app/locale/en_US/Mage_Api.csv index 0bc33c07e6..f94981ee22 100644 --- a/app/locale/en_US/Mage_Api.csv +++ b/app/locale/en_US/Mage_Api.csv @@ -26,6 +26,7 @@ "Add","Add" "Add Contents Path","Add Contents Path" "Add Field with URL:","Add Field with URL:" +"Add Gift Card","Add Gift Card" "Add Maintainer","Add Maintainer" "Add New Role","Add New Role" "Add New Template","Add New Template" @@ -34,7 +35,6 @@ "Add Package dependency","Add Package dependency" "Add Subpackage dependency","Add Subpackage dependency" "Add new store view map","Add new store view map" -"Add new website map","Add new website map" "Address Type:","Address Type:" "All","All" "All Websites","All Websites" @@ -60,11 +60,11 @@ "Comments History","Comments History" "Confirmed email:","Confirmed email:" "Connect with the Magento Community","Connect with the Magento Community" +"Content","Content" "Contents","Contents" "Country:","Country:" "Create New Staging Store View","Create New Staging Store View" "Create a backup","Create a backup" -"Created %s items","Created %s items" "Credit Card Number","Credit Card Number" "Credit Card Number: xxxx-%s","Credit Card Number: xxxx-%s" "Credit Card Type","Credit Card Type" @@ -119,7 +119,6 @@ "File Information","File Information" "File name:","File name:" "Final Price","Final Price" -"Finished items creation.","Finished items creation." "First Name:","First Name:" "For latest version visit: %s","For latest version visit: %s" "From","From" @@ -148,7 +147,6 @@ "Invoice Totals","Invoice Totals" "Issue Number","Issue Number" "Issuer: %s","Issuer: %s" -"Items to merge","Items to merge" "Last 5 Orders","Last 5 Orders" "Last 5 Search Terms","Last 5 Search Terms" "Last Logged In (%s):","Last Logged In (%s):" @@ -171,11 +169,9 @@ "Magento™ is a trademark of Irubin Consulting Inc. DBA Varien.
Copyright © %s Irubin Consulting Inc.","Magento™ is a trademark of Irubin Consulting Inc. DBA Varien.
Copyright © %s Irubin Consulting Inc." "Maintainers","Maintainers" "Manage Stores","Manage Stores" -"Mapping Configuration","Mapping Configuration" "Max","Max" "Merge Now","Merge Now" "Min","Min" -"Module version conflict!","Module version conflict!" "N/A","N/A" "Name","Name" "Name on Card","Name on Card" @@ -244,7 +240,6 @@ "Price","Price" "Price:","Price:" "Primary Billing Address","Primary Billing Address" -"Processed %s%% %s/%d items","Processed %s%% %s/%d items" "Product","Product" "Products","Products" "Profile Information","Profile Information" @@ -258,6 +253,7 @@ "Resource Access","Resource Access" "Resources","Resources" "Role","Role" +"Role Scopes","Role Scopes" "Role Users","Role Users" "Roles","Roles" "Roles Resources","Roles Resources" @@ -269,7 +265,6 @@ "Select Range","Select Range" "Select Visible","Select Visible" "Select date","Select date" -"Select website from map","Select website from map" "Select website to map","Select website to map" "Shipment Comments","Shipment Comments" "Shipment History","Shipment History" @@ -282,12 +277,14 @@ "Sort Order","Sort Order" "Spreadsheet Name:","Spreadsheet Name:" "Staging Store: ","Staging Store: " +"Staging Website - Merge Configuration","Staging Website - Merge Configuration" "Staging Website: ","Staging Website: " "Start Date","Start Date" "State/Province:","State/Province:" "Status","Status" "Status:","Status:" "Stock Quantity:","Stock Quantity:" +"Store Credit","Store Credit" "Store:","Store:" "Store: ","Store: " "Subpackage","Subpackage" @@ -300,6 +297,7 @@ "Switch/Solo/Maestro(UK Domestic) card issue number: %s","Switch/Solo/Maestro(UK Domestic) card issue number: %s" "Switch/Solo/Maestro(UK Domestic) card start Date: %s/%s","Switch/Solo/Maestro(UK Domestic) card start Date: %s/%s" "The information in this tab has been changed.","The information in this tab has been changed." +"This is a demo store. Any orders placed through this store will not be honored or fulfilled.","This is a demo store. Any orders placed through this store will not be honored or fulfilled." "This is a required field.","This is a required field." "This tab contains invalid data. Please solve the problem before saving.","This tab contains invalid data. Please solve the problem before saving." "Thumbnail","Thumbnail" @@ -319,6 +317,7 @@ "Upload Local File","Upload Local File" "Upload local file:","Upload local file:" "Use Default Value","Use Default Value" +"Use Store Credit (%s available)","Use Store Credit (%s available)" "User","User" "User Name","User Name" "User Roles","User Roles" @@ -332,14 +331,14 @@ "Warning! Empty value can cause problems with CSV format.","Warning! Empty value can cause problems with CSV format." "Warning!\r\nThis action will remove this user from already assigned role\r\nAre you sure?","Warning!\r\nThis action will remove this user from already assigned role\r\nAre you sure?" "Warning!\r\nThis action will remove those users from already assigned roles\r\nAre you sure?","Warning!\r\nThis action will remove those users from already assigned roles\r\nAre you sure?" +"We detected that your JavaScript seem to be disabled.","We detected that your JavaScript seem to be disabled." "Web Services","Web Services" "Web Services Configuration","Web Services Configuration" "Website: ","Website: " -"Websites","Websites" -"Websites / Stores","Websites / Stores" "What is this?","What is this?" "Yes","Yes" "You have","You have" +"You must have JavaScript enabled in your browser to utilize the functionality of this website.","You must have JavaScript enabled in your browser to utilize the functionality of this website." "Your Account has been deactivated.","Your Account has been deactivated." "Your server PHP settings allow you to upload files not more than %s at a time. Please modify post_max_size (currently is %s) and upload_max_filesize (currently is %s) values in php.ini if you want to upload larger files.","Your server PHP settings allow you to upload files not more than %s at a time. Please modify post_max_size (currently is %s) and upload_max_filesize (currently is %s) values in php.ini if you want to upload larger files." "Zip/Postal Code:","Zip/Postal Code:" diff --git a/app/locale/en_US/Mage_Backup.csv b/app/locale/en_US/Mage_Backup.csv index 82256b4e32..d747e28551 100644 --- a/app/locale/en_US/Mage_Backup.csv +++ b/app/locale/en_US/Mage_Backup.csv @@ -1,5 +1,4 @@ "Action","Action" -"All types","All types" "Backup file ""%s"" can\'t read or write","Backup file ""%s"" can\'t read or write" "Backup file ""%s"" doesn\'t exist","Backup file ""%s"" doesn\'t exist" "Backup file doesn't exist","Backup file doesn't exist" diff --git a/app/locale/en_US/Mage_Catalog.csv b/app/locale/en_US/Mage_Catalog.csv index c11eb366c4..fba819815a 100644 --- a/app/locale/en_US/Mage_Catalog.csv +++ b/app/locale/en_US/Mage_Catalog.csv @@ -32,7 +32,6 @@ "Add Tier","Add Tier" "Add to Cart","Add to Cart" "Add to Compare","Add to Compare" -"Add to My Wishlist","Add to My Wishlist" "Add to Wishlist","Add to Wishlist" "Additional Information","Additional Information" "All","All" @@ -56,6 +55,7 @@ "Assigned Products","Assigned Products" "Associated Products","Associated Products" "Attrib. Set Name","Attrib. Set Name" +"Attribute ""%s"" is required","Attribute ""%s"" is required" "Attribute Code","Attribute Code" "Attribute Information","Attribute Information" "Attribute Label","Attribute Label" @@ -182,6 +182,7 @@ "Double click on above image to view full picture","Double click on above image to view full picture" "Dropdown","Dropdown" "Duplicate","Duplicate" +"Duplicate amount found.","Duplicate amount found." "Duplicate website tier price customer group and quantity.","Duplicate website tier price customer group and quantity." "Duplicate website, country and state tax found.","Duplicate website, country and state tax found." "Edit","Edit" @@ -191,6 +192,8 @@ "Edit Search","Edit Search" "Edit Search '%s'","Edit Search '%s'" "Email","Email" +"Email template is not specified by administrator","Email template is not specified by administrator" +"Email to %s was not sent","Email to %s was not sent" "Email to a Friend","Email to a Friend" "Empty","Empty" "Enabled","Enabled" @@ -258,6 +261,8 @@ "Invalid product type specified, skipping the record","Invalid product type specified, skipping the record" "Invalid store specified","Invalid store specified" "Invalid store specified, skipping the record","Invalid store specified, skipping the record" +"Invalid tier prices. Product is not associated to the requested website.","Invalid tier prices. Product is not associated to the requested website." +"Invalid transactional email code","Invalid transactional email code" "Inventory","Inventory" "Is Default","Is Default" "Is Required","Is Required" @@ -352,7 +357,8 @@ "Please select product(s)","Please select product(s)" "Please select products for attributes update","Please select products for attributes update" "Please select static block ...","Please select static block ..." -"Please set up merge date/time .","Please set up merge date/time ." +"Please set up merge date/time","Please set up merge date/time" +"Please set up merge date/time later then present date","Please set up merge date/time later then present date" "Please specify date required option(s)","Please specify date required option(s)" "Please specify the product option(s)","Please specify the product option(s)" "Please specify the product required option(s)","Please specify the product required option(s)" @@ -543,6 +549,7 @@ "There was an error while removing products from websites","There was an error while removing products from websites" "There was an error while updating product(s) attributes","There was an error while updating product(s) attributes" "There was an error while updating product(s) status","There was an error while updating product(s) status" +"This attribute is used in configurable products. You cannot remove it from the attribute set.","This attribute is used in configurable products. You cannot remove it from the attribute set." "This attribute no longer exists","This attribute no longer exists" "This group contains attributes, used in configurable products. Please move these attributes to another group and try again.","This group contains attributes, used in configurable products. Please move these attributes to another group and try again." "This group contains system attributes. Please move system attributes to another group and try again.","This group contains system attributes. Please move system attributes to another group and try again." @@ -559,6 +566,8 @@ "Total of %d record(s) were successfully deleted","Total of %d record(s) were successfully deleted" "Total of %d record(s) were successfully updated","Total of %d record(s) were successfully updated" "Type","Type" +"URL Rewrite Management","URL Rewrite Management" +"URL rewrite save problem.","URL rewrite save problem." "Unable to complete request. Please try again later.","Unable to complete request. Please try again later." "Unable to find a search term to delete","Unable to find a search term to delete" "Unable to find an attribute to delete","Unable to find an attribute to delete" @@ -581,7 +590,6 @@ "Upload new product image ","Upload new product image " "Url","Url" "Url Rewrite Management","Url Rewrite Management" -"Url rewrie save problem.","Url rewrie save problem." "Use Config Settings","Use Config Settings" "Use Default Value","Use Default Value" "Use Flat Catalog Category","Use Flat Catalog Category" @@ -593,6 +601,7 @@ "Use To Create Configurable Product","Use To Create Configurable Product" "Use Tree Like Category Sitemap","Use Tree Like Category Sitemap" "Use categories path for product URLs","Use categories path for product URLs" +"Use for Price Rule Conditions","Use for Price Rule Conditions" "Use in advanced search","Use in advanced search" "Use in quick search","Use in quick search" "Used for sorting in product listing","Used for sorting in product listing" @@ -609,14 +618,15 @@ "Watermark Default Size","Watermark Default Size" "Watermark Position","Watermark Position" "We Also Recommend","We Also Recommend" -"Web Site Item Must be checked","Web Site Item Must be checked" -"Web Site Store Must be checked","Web Site Store Must be checked" "Website","Website" +"Website Item Must be checked","Website Item Must be checked" +"Website Store Must be checked","Website Store Must be checked" "Websites","Websites" "Wrong BuyRequest instance in options group","Wrong BuyRequest instance in options group" "Wrong option instance type in options group","Wrong option instance type in options group" "Wrong option type to get group instance.","Wrong option type to get group instance." "Wrong product instance type in options group","Wrong product instance type in options group" +"Wrong product type filter specified","Wrong product type filter specified" "Wrong quote item instance in options group","Wrong quote item instance in options group" "Wrong quote item option instance in options group","Wrong quote item option instance in options group" "Year Range","Year Range" @@ -624,9 +634,13 @@ "Yes/No","Yes/No" "You cannot delete this attribute","You cannot delete this attribute" "You cannot edit this attribute","You cannot edit this attribute" +"You cannot email this product to a friend","You cannot email this product to a friend" "You cannot remove system attribute from this set.","You cannot remove system attribute from this set." +"You cannot send more than %d emails at a time","You cannot send more than %d emails at a time" "You cannot update this attribute","You cannot update this attribute" +"You have exceeded limit of %d sends in an hour","You have exceeded limit of %d sends in an hour" "You have no items to compare.","You have no items to compare." +"You have to specify at least one recipient","You have to specify at least one recipient" "You may also be interested in the following product(s)","You may also be interested in the following product(s)" "Zoom In","Zoom In" "Zoom Out","Zoom Out" diff --git a/app/locale/en_US/Mage_CatalogRule.csv b/app/locale/en_US/Mage_CatalogRule.csv index 499be3e8f4..21848b09c3 100644 --- a/app/locale/en_US/Mage_CatalogRule.csv +++ b/app/locale/en_US/Mage_CatalogRule.csv @@ -55,7 +55,6 @@ "Start at: %s","Start at: %s" "Status","Status" "Stop further rules processing","Stop further rules processing" -"The page you are trying to save no longer exists","The page you are trying to save no longer exists" "There are rules that have been changed but not applied. Please, click Apply Rules in order to see immediate effect in catalog.","There are rules that have been changed but not applied. Please, click Apply Rules in order to see immediate effect in catalog." "This rule no longer exists","This rule no longer exists" "To Date","To Date" @@ -63,4 +62,5 @@ "Unable to find a page to delete","Unable to find a page to delete" "Update product's %s %s: %s","Update product's %s %s: %s" "Websites","Websites" +"Wrong rule specified.","Wrong rule specified." "Yes","Yes" diff --git a/app/locale/en_US/Mage_Checkout.csv b/app/locale/en_US/Mage_Checkout.csv index 32aaca17cf..94f726dd3d 100644 --- a/app/locale/en_US/Mage_Checkout.csv +++ b/app/locale/en_US/Mage_Checkout.csv @@ -140,7 +140,6 @@ "Please continue shopping.","Please continue shopping." "Please agree to all Terms and Conditions before placing the order.","Please agree to all Terms and Conditions before placing the order." "Please agree to all Terms and Conditions before placing the orders.","Please agree to all Terms and Conditions before placing the orders." -"Please enter a valid zip code. For example 90602 or 90602-1234.","Please enter a valid zip code. For example 90602 or 90602-1234." "Please log in below:","Please log in below:" "Please select region, state or province","Please select region, state or province" "Please select shipping address for applicable items","Please select shipping address for applicable items" diff --git a/app/locale/en_US/Mage_Cms.csv b/app/locale/en_US/Mage_Cms.csv index b5c71d6122..148d9bf205 100644 --- a/app/locale/en_US/Mage_Cms.csv +++ b/app/locale/en_US/Mage_Cms.csv @@ -9,6 +9,7 @@ "Block was successfully saved","Block was successfully saved" "CMS","CMS" "CMS Home Page","CMS Home Page" +"CMS No Cookies Page","CMS No Cookies Page" "CMS No Route Page","CMS No Route Page" "Content","Content" "Custom Design","Custom Design" @@ -49,10 +50,12 @@ "Page was successfully saved","Page was successfully saved" "Poll Manager","Poll Manager" "Product Tax Class Information","Product Tax Class Information" +"Redirect to CMS-page if cookies are disabled","Redirect to CMS-page if cookies are disabled" "SEF URL Identifier","SEF URL Identifier" "Save Block","Save Block" "Save Page","Save Page" "Show breadcrumbs for CMS pages","Show breadcrumbs for CMS pages" +"Show notice if JavaScipt is disabled","Show notice if JavaScipt is disabled" "Static Blocks","Static Blocks" "Status","Status" "Store View","Store View" diff --git a/app/locale/en_US/Mage_Compiler.csv b/app/locale/en_US/Mage_Compiler.csv new file mode 100644 index 0000000000..a90e46a7a8 --- /dev/null +++ b/app/locale/en_US/Mage_Compiler.csv @@ -0,0 +1,21 @@ +"Collected Files Count","Collected Files Count" +"Compilation","Compilation" +"Compilation (Beta)","Compilation (Beta)" +"Compilation State","Compilation State" +"Compilation error","Compilation error" +"Compilation successfully finished","Compilation successfully finished" +"Compiled","Compiled" +"Compiled Scopes Count","Compiled Scopes Count" +"Compiler Status","Compiler Status" +"Compiler include path disabled","Compiler include path disabled" +"Compiler include path enabled","Compiler include path enabled" +"Compiler module is now in Beta (not to be used in production environment)","Compiler module is now in Beta (not to be used in production environment)" +"Directory ""%s"" must be writeable","Directory ""%s"" must be writeable" +"Disable","Disable" +"Disabled","Disabled" +"Enable","Enable" +"Enabled","Enabled" +"File ""%s"" must be writeable","File ""%s"" must be writeable" +"Not Compiled","Not Compiled" +"Run Compilation Process","Run Compilation Process" +"Scopes Compilation Settings","Scopes Compilation Settings" diff --git a/app/locale/en_US/Mage_Core.csv b/app/locale/en_US/Mage_Core.csv index fab0198237..20b4997106 100644 --- a/app/locale/en_US/Mage_Core.csv +++ b/app/locale/en_US/Mage_Core.csv @@ -22,11 +22,13 @@ "Before modifying the website code please make sure that it is not used in index.php","Before modifying the website code please make sure that it is not used in index.php" "Block with name ""%s"" already exists","Block with name ""%s"" already exists" "Blocks HTML output","Blocks HTML output" +"Browser Capabilities Detection","Browser Capabilities Detection" "Can't retrieve request object","Can't retrieve request object" "Can\'t retrieve entity config: %s","Can\'t retrieve entity config: %s" "Cancel","Cancel" "Cannot Delete Email Template","Cannot Delete Email Template" "Cannot complete this operation from non-admin area.","Cannot complete this operation from non-admin area." +"Card type doesn\'t match credit card number","Card type doesn\'t match credit card number" "Category object is required for determining product request path","Category object is required for determining product request path" "Code","Code" "Collections Data","Collections Data" @@ -40,6 +42,7 @@ "Create Store","Create Store" "Create Store View","Create Store View" "Create Website","Create Website" +"Credit card number doesn\'t match credit card type","Credit card number doesn\'t match credit card type" "Current package name","Current package name" "Custom Design","Custom Design" "Custom admin URL","Custom admin URL" @@ -72,6 +75,7 @@ "Developer Client Restrictions","Developer Client Restrictions" "Disable email communications","Disable email communications" "Disable modules output","Disable modules output" +"Display demo store notice","Display demo store notice" "Duplicate Of Template Code","Duplicate Of Template Code" "Edit Design Change","Edit Design Change" "Edit Store","Edit Store" @@ -79,6 +83,7 @@ "Edit Website","Edit Website" "Empty identifier field name","Empty identifier field name" "Empty main table name","Empty main table name" +"Enable Prototype Deprecation Log","Enable Prototype Deprecation Log" "Enabled","Enabled" "Enabled for Admin","Enabled for Admin" "Enabled for Frontend","Enabled for Frontend" @@ -108,6 +113,7 @@ "Invalid messages storage ""%s"" for layout messages initialization","Invalid messages storage ""%s"" for layout messages initialization" "Invalid transactional email code: ","Invalid transactional email code: " "Invalid websites configuration path: %s","Invalid websites configuration path: %s" +"JavaScript Settings","JavaScript Settings" "Layout","Layout" "Layouts","Layouts" "Leave empty for access from any location","Leave empty for access from any location" @@ -120,6 +126,8 @@ "Logo Image Src","Logo Image Src" "Manage Stores","Manage Stores" "Match expressions in the same order as displayed in the configuration.","Match expressions in the same order as displayed in the configuration." +"Maximum length exceeded.","Maximum length exceeded." +"Merge JavaScript Files","Merge JavaScript Files" "Miscellaneous HTML","Miscellaneous HTML" "Miscellaneous scripts","Miscellaneous scripts" "Model class does not exist: %s","Model class does not exist: %s" @@ -142,6 +150,7 @@ "Please enter a valid URL. For example http://www.example.com or www.example.com","Please enter a valid URL. For example http://www.example.com or www.example.com" "Please enter a valid URL. http:// is required","Please enter a valid URL. http:// is required" "Please enter a valid credit card number.","Please enter a valid credit card number." +"Please enter a valid credit card verification number.","Please enter a valid credit card verification number." "Please enter a valid date.","Please enter a valid date." "Please enter a valid email address. For example johndoe@domain.com.","Please enter a valid email address. For example johndoe@domain.com." "Please enter a valid number in this field.","Please enter a valid number in this field." @@ -150,6 +159,7 @@ "Please enter a valid zip code.","Please enter a valid zip code." "Please enter a valid zip code. For example 90602 or 90602-1234.","Please enter a valid zip code. For example 90602 or 90602-1234." "Please enter valid password.","Please enter valid password." +"Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%","Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%" "Please make sure that Base URL ends with '/' (slash), e.g. http://yourdomain/magento/","Please make sure that Base URL ends with '/' (slash), e.g. http://yourdomain/magento/" "Please make sure your passwords match.","Please make sure your passwords match." "Please select State/Province.","Please select State/Province." @@ -161,6 +171,7 @@ "Please use letters only (a-z or A-Z) in this field.","Please use letters only (a-z or A-Z) in this field." "Please use letters only (a-z) in this field.","Please use letters only (a-z) in this field." "Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.","Please use numbers only in this field. please avoid spaces or other characters such as dots or commas." +"Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.","Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter." "Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.","Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed." "Please use only letters (a-z) or numbers (0-9) or spaces and # only in this field.","Please use only letters (a-z) or numbers (0-9) or spaces and # only in this field." "Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.","Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter." @@ -169,7 +180,6 @@ "Polls","Polls" "Port (25)","Port (25)" "Profiler","Profiler" -"Prototype Deprecation Log","Prototype Deprecation Log" "Request path for specified store","Request path for specified store" "Requested invalid store ""%s""","Requested invalid store ""%s""" "Resource is not set","Resource is not set" @@ -188,7 +198,7 @@ "Sender name","Sender name" "Services","Services" "Session Cookie management","Session Cookie management" -"Session Lifetime, Seconds","Session Lifetime, Seconds" +"Session Lifetime (seconds)","Session Lifetime (seconds)" "Session Validation Settings","Session Validation Settings" "Set as default","Set as default" "Skin (Images / CSS)","Skin (Images / CSS)" @@ -268,6 +278,7 @@ "Welcome Text","Welcome Text" "Wrong number of arguments for %s","Wrong number of arguments for %s" "Yes","Yes" +"Your design change for the specified store intersects with another one, please specify another date range","Your design change for the specified store intersects with another one, please specify another date range" "Your order can not be completed at this time as there is no payment methods available for it.","Your order can not be completed at this time as there is no payment methods available for it." "Your order can not be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","Your order can not be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address." "Your session has been expired, you will be relogged in now.","Your session has been expired, you will be relogged in now." diff --git a/app/locale/en_US/Mage_Customer.csv b/app/locale/en_US/Mage_Customer.csv index 2dc08c1b4b..7058d33028 100644 --- a/app/locale/en_US/Mage_Customer.csv +++ b/app/locale/en_US/Mage_Customer.csv @@ -78,6 +78,7 @@ "Customer doesn't have primary billing address","Customer doesn't have primary billing address" "Customer email already exists","Customer email already exists" "Customer website id must be specified, when using website scope.","Customer website id must be specified, when using website scope." +"Customer will stay on the current page if ""No"" is selected","Customer will stay on the current page if ""No"" is selected" "Customers","Customers" "Customers Only","Customers Only" "Customers Section","Customers Section" @@ -170,6 +171,7 @@ "Log in or Create an Account","Log in or Create an Account" "Login","Login" "Login Information","Login Information" +"Login Options","Login Options" "Login and password are required","Login and password are required" "Login or Create an Account","Login or Create an Account" "M.I.","M.I." @@ -266,6 +268,7 @@ "Qty","Qty" "Recent Orders","Recent Orders" "Records for ""","Records for """ +"Redirect Customer to Account Dashboard after Logging in","Redirect Customer to Account Dashboard after Logging in" "Refunded","Refunded" "Registered Customers","Registered Customers" "Remove","Remove" @@ -274,9 +277,9 @@ "Retrieve address info","Retrieve address info" "Retrieve customer addresses","Retrieve customer addresses" "Retrieve customer data","Retrieve customer data" -"Retrieve customer's groups","Retrieve customer's groups" +"Retrieve customer groups","Retrieve customer groups" +"Retrieve customer info","Retrieve customer info" "Retrieve customers","Retrieve customers" -"Retrieve customers info","Retrieve customers info" "Retrieve your confirmation link here","Retrieve your confirmation link here" "Retrieve your password here","Retrieve your password here" "SKU","SKU" @@ -289,6 +292,7 @@ "Save Password","Save Password" "Saved ","Saved " "Semicolon (;) separated values.
Put semicolon in the beginning for empty first option.
Leave empty for open text field.","Semicolon (;) separated values.
Put semicolon in the beginning for empty first option.
Leave empty for open text field." +"Send From","Send From" "Send Welcome Email after Confirmation","Send Welcome Email after Confirmation" "Send auto-generated password","Send auto-generated password" "Send confirmation link","Send confirmation link" @@ -299,8 +303,6 @@ "Set as Default Billing Address","Set as Default Billing Address" "Set as Default Shipping Address","Set as Default Shipping Address" "Share Customer Accounts","Share Customer Accounts" -"Ship to First name","Ship to First name" -"Ship to Last name","Ship to Last name" "Shipped to First Name","Shipped to First Name" "Shipped to Last Name","Shipped to Last Name" "Shipped to Name","Shipped to Name" diff --git a/app/locale/en_US/Mage_GoogleBase.csv b/app/locale/en_US/Mage_GoogleBase.csv index 617b71bfd4..fcfd3761cb 100644 --- a/app/locale/en_US/Mage_GoogleBase.csv +++ b/app/locale/en_US/Mage_GoogleBase.csv @@ -1,3 +1,4 @@ +"Account Type","Account Type" "Account login","Account login" "Account password","Account password" "Active","Active" @@ -22,7 +23,6 @@ "Confirm","Confirm" "Current Mapping will be reloaded. Continue?","Current Mapping will be reloaded. Continue?" "Custom attribute, no mapping","Custom attribute, no mapping" -"Default Store (%s)","Default Store (%s)" "Delete","Delete" "Delete Mapping","Delete Mapping" "Edit Item Type","Edit Item Type" @@ -31,6 +31,7 @@ "Euro","Euro" "Expires","Expires" "Germany","Germany" +"Google","Google" "Google Base","Google Base" "Google Base Attribute","Google Base Attribute" "Google Base ID","Google Base ID" @@ -38,6 +39,8 @@ "Google Base Item type","Google Base Item type" "Google Base Items","Google Base Items" "Hide","Hide" +"Hosted","Hosted" +"Hosted or Google","Hosted or Google" "Impr.","Impr." "Invalid Product Model for Google Base Item","Invalid Product Model for Google Base Item" "Item Type was deleted","Item Type was deleted" @@ -72,6 +75,7 @@ "Total of %d product(s) were successfully added to Google Base","Total of %d product(s) were successfully added to Google Base" "US Dollar","US Dollar" "Unable to connect to Google Base. Please, check Account settings in configuration.","Unable to connect to Google Base. Please, check Account settings in configuration." +"Unable to select a Store View","Unable to select a Store View" "United Kingdom","United Kingdom" "United States","United States" "Update Google Base item when product is updated","Update Google Base item when product is updated" diff --git a/app/locale/en_US/Mage_Install.csv b/app/locale/en_US/Mage_Install.csv index 97af1fca4e..edac956b16 100644 --- a/app/locale/en_US/Mage_Install.csv +++ b/app/locale/en_US/Mage_Install.csv @@ -58,6 +58,7 @@ "Installation","Installation" "Installation Guide","Installation Guide" "Last Name","Last Name" +"License Agreement","License Agreement" "Locale","Locale" "Locale settings","Locale settings" "Localization","Localization" @@ -110,3 +111,4 @@ "You can specify server port, ex.: localhost:3307
If you are not using default UNIX socket, you can specify it here instead of host, ex.: /var/run/mysqld/mysqld.sock","You can specify server port, ex.: localhost:3307
If you are not using default UNIX socket, you can specify it here instead of host, ex.: /var/run/mysqld/mysqld.sock" "You could enable this option to use web server rewrites functionality for improved search engines optimization.","You could enable this option to use web server rewrites functionality for improved search engines optimization." "You're All Set","You're All Set" +"You're All Set!","You're All Set!" diff --git a/app/locale/en_US/Mage_Newsletter.csv b/app/locale/en_US/Mage_Newsletter.csv index ddf2abb0b7..5a8bfe3ae7 100644 --- a/app/locale/en_US/Mage_Newsletter.csv +++ b/app/locale/en_US/Mage_Newsletter.csv @@ -1,4 +1,5 @@ " Copy"," Copy" +" Follow this link to unsubscribe {{var subscriber.getUnsubscriptionLink()}}"," Follow this link to unsubscribe {{var subscriber.getUnsubscriptionLink()}}" "Action","Action" "Add New Template","Add New Template" "Add to Queue","Add to Queue" @@ -8,7 +9,6 @@ "Cancel","Cancel" "Cancelled","Cancelled" "Cannot delete subscriber","Cannot delete subscriber" -"Cannot delete template","Cannot delete template" "Cannot mark as received subscriber","Cannot mark as received subscriber" "Cannot save your subscription: %s","Cannot save your subscription: %s" "Confirmation Email Sender","Confirmation Email Sender" @@ -73,7 +73,7 @@ "Queue Date Start","Queue Date Start" "Queue Finish","Queue Finish" "Queue Information","Queue Information" -"Queue Newsletter","Queue Newsletter" +"Queue Newsletter...","Queue Newsletter..." "Queue Start","Queue Start" "Queue Subject","Queue Subject" "Recipients","Recipients" diff --git a/app/locale/en_US/Mage_Page.csv b/app/locale/en_US/Mage_Page.csv index 2991e3d60d..a946e7a392 100644 --- a/app/locale/en_US/Mage_Page.csv +++ b/app/locale/en_US/Mage_Page.csv @@ -8,6 +8,10 @@ "- Use the %s, %s buttons to select year","- Use the %s, %s buttons to select year" "- or Shift-click to decrease it","- or Shift-click to decrease it" "- or click and drag for faster selection.","- or click and drag for faster selection." +"1 column","1 column" +"2 columns with left bar","2 columns with left bar" +"2 columns with right bar","2 columns with right bar" +"3 columns","3 columns" "About the calendar","About the calendar" "Click here if nothing has happened","Click here if nothing has happened" "Close","Close" @@ -19,6 +23,7 @@ "Display %s first","Display %s first" "Distributed under GNU LGPL. See %s for details.","Distributed under GNU LGPL. See %s for details." "Drag to move","Drag to move" +"Empty","Empty" "For latest version visit: %s","For latest version visit: %s" "Go Today","Go Today" "Help Us to Keep Magento Healthy","Help Us to Keep Magento Healthy" @@ -43,7 +48,9 @@ "This is a demo store. Any orders placed through this store will not be honored or fulfilled.","This is a demo store. Any orders placed through this store will not be honored or fulfilled." "Time selection:","Time selection:" "Time:","Time:" +"We detected that your JavaScript seem to be disabled.","We detected that your JavaScript seem to be disabled." "Welcome, %s!","Welcome, %s!" +"You must have JavaScript enabled in your browser to utilize the functionality of this website.","You must have JavaScript enabled in your browser to utilize the functionality of this website." "You're currently on:","You're currently on:" "Your Language","Your Language" "Your Language:","Your Language:" diff --git a/app/locale/en_US/Mage_Paypal.csv b/app/locale/en_US/Mage_Paypal.csv index 5702d1f4ff..56bd2024fd 100644 --- a/app/locale/en_US/Mage_Paypal.csv +++ b/app/locale/en_US/Mage_Paypal.csv @@ -1,10 +1,3 @@ -" - Example: https://www.paypal.com/au/cgi-bin/webscr?cmd=_express-checkout&useraction=&token= - Where <user_action> is 'commit' or 'continue', depending on your preference of commit button text. - "," - Example: https://www.paypal.com/au/cgi-bin/webscr?cmd=_express-checkout&useraction=&token= - Where <user_action> is 'commit' or 'continue', depending on your preference of commit button text. - " "API Password","API Password" "API Signature","API Signature" "API User Name","API User Name" @@ -29,6 +22,7 @@ "Enabled","Enabled" "Error in creating an invoice","Error in creating an invoice" "Error in refunding the payment","Error in refunding the payment" +"Example: https://www.paypal.com/au/cgi-bin/webscr?cmd=_express-checkout&useraction=&token= Where <user_action> is 'commit' or 'continue', depending on your preference of commit button text.","Example: https://www.paypal.com/au/cgi-bin/webscr?cmd=_express-checkout&useraction=&token= Where <user_action> is 'commit' or 'continue', depending on your preference of commit button text." "Expiration Date","Expiration Date" "Expiration Date: %s/%s","Expiration Date: %s/%s" "Incl. Tax","Incl. Tax" diff --git a/app/locale/en_US/Mage_ProductAlert.csv b/app/locale/en_US/Mage_ProductAlert.csv index 85d992103f..fbf1efa10e 100644 --- a/app/locale/en_US/Mage_ProductAlert.csv +++ b/app/locale/en_US/Mage_ProductAlert.csv @@ -18,6 +18,7 @@ "Product not found","Product not found" "Product price alert","Product price alert" "Product stock alert","Product stock alert" +"Regular Price:","Regular Price:" "Sign up for price alert","Sign up for price alert" "Sign up to get notified when this product is back in stock","Sign up to get notified when this product is back in stock" "Special price:","Special price:" diff --git a/app/locale/en_US/Mage_Reports.csv b/app/locale/en_US/Mage_Reports.csv index 1f0b7e9742..1cb844bf15 100644 --- a/app/locale/en_US/Mage_Reports.csv +++ b/app/locale/en_US/Mage_Reports.csv @@ -35,6 +35,7 @@ "Guest","Guest" "Hits","Hits" "ID","ID" +"Index model name must be defined","Index model name must be defined" "Invalid date specified","Invalid date specified" "Invoiced","Invoiced" "Items Ordered","Items Ordered" @@ -80,12 +81,12 @@ "Price","Price" "Product Name","Product Name" "Product Reviews","Product Reviews" -"Product Sku","Product Sku" +"Product SKU","Product SKU" "Product Tags","Product Tags" "Products","Products" +"Products Ordered","Products Ordered" "Products Report","Products Report" "Products Reviews","Products Reviews" -"Products Sold","Products Sold" "Products Tags","Products Tags" "Products in carts","Products in carts" "Purchases","Purchases" diff --git a/app/locale/en_US/Mage_Sales.csv b/app/locale/en_US/Mage_Sales.csv index 71b4a26e00..725a877c3d 100644 --- a/app/locale/en_US/Mage_Sales.csv +++ b/app/locale/en_US/Mage_Sales.csv @@ -1,5 +1,6 @@ " The customer doesn\'t exist in the system anymore"," The customer doesn\'t exist in the system anymore" """%s"" coupon code is not valid.","""%s"" coupon code is not valid." +"%s","%s" "%s / %s rate:","%s / %s rate:" "%s for %s","%s for %s" "%s order(s) successfully canceled","%s order(s) successfully canceled" @@ -28,10 +29,10 @@ "Add new tracking number","Add new tracking number" "Add to Cart","Add to Cart" "Address","Address" +"Address model is not defined","Address model is not defined" +"Address total model should be extended from Mage_Sales_Model_Quote_Address_Total_Abstract","Address total model should be extended from Mage_Sales_Model_Quote_Address_Total_Abstract" "Adjustment Fee","Adjustment Fee" -"Adjustment Fee:","Adjustment Fee:" "Adjustment Refund","Adjustment Refund" -"Adjustment Refund:","Adjustment Refund:" "Allow Reorder","Allow Reorder" "Amount","Amount" "Append Comments","Append Comments" @@ -48,7 +49,6 @@ "Billing Address","Billing Address" "Buy %s for price %s","Buy %s for price %s" "Can not add order history.","Can not add order history." -"Can not create block ""%s""","Can not create block ""%s""" "Can not do invoice for order.","Can not do invoice for order." "Can not do shipment for order.","Can not do shipment for order." "Can not register existing creditmemo","Can not register existing creditmemo" @@ -151,7 +151,6 @@ "Gift Message for this Order","Gift Message for this Order" "Grand Total","Grand Total" "Grand Total to be charged","Grand Total to be charged" -"Grand Total:","Grand Total:" "Guest","Guest" "Hold","Hold" "Hold action is not available","Hold action is not available" @@ -161,7 +160,9 @@ "If empty, the default error above will be used","If empty, the default error above will be used" "Incl. Tax","Incl. Tax" "Information","Information" +"Invalid block: %s","Invalid block: %s" "Invalid carrier specified.","Invalid carrier specified." +"Invalid draw line data. Please define ""lines"" array","Invalid draw line data. Please define ""lines"" array" "Invalid item option format","Invalid item option format" "Invalid qty to invoice item ""%s""","Invalid qty to invoice item ""%s""" "Invalid qty to refund item ""%s""","Invalid qty to refund item ""%s""" @@ -205,7 +206,6 @@ "Items Refunded","Items Refunded" "Items Shipped","Items Shipped" "Items options declare error.","Items options declare error." -"Items to Invoice","Items to Invoice" "Items to Refund","Items to Refund" "Items to Ship","Items to Ship" "Last ordered items","Last ordered items" @@ -239,6 +239,7 @@ "New Order for Guest","New Order for Guest" "New Shipment","New Shipment" "New Shipment for Guest","New Shipment for Guest" +"New Shipment for Order #%s","New Shipment for Order #%s" "New Status","New Status" "Newsletter Subscription","Newsletter Subscription" "No Items","No Items" @@ -280,7 +281,6 @@ "Order Shipments","Order Shipments" "Order Status","Order Status" "Order Subtotal","Order Subtotal" -"Order Subtotal:","Order Subtotal:" "Order Total","Order Total" "Order Totals","Order Totals" "Order Update","Order Update" @@ -314,10 +314,12 @@ "Payment Information","Payment Information" "Payment Method","Payment Method" "Payment Method:","Payment Method:" +"Pdf total model should extend Mage_Sales_Model_Order_Pdf_Total_Default","Pdf total model should extend Mage_Sales_Model_Order_Pdf_Total_Default" "Pending","Pending" "Pending PayPal","Pending PayPal" "Pending Payment","Pending Payment" "Placed from IP","Placed from IP" +"Please define PDF object before using","Please define PDF object before using" "Please enter positive number in this field.","Please enter positive number in this field." "Please select a customer","Please select a customer" "Please select a store","Please select a store" @@ -414,6 +416,7 @@ "Shipment","Shipment" "Shipment #","Shipment #" "Shipment #%s","Shipment #%s" +"Shipment #%s (%s)","Shipment #%s (%s)" "Shipment Comment Email Sender","Shipment Comment Email Sender" "Shipment Comment Email Template","Shipment Comment Email Template" "Shipment Comment Email Template for Guest","Shipment Comment Email Template for Guest" @@ -430,7 +433,6 @@ "Shipped By","Shipped By" "Shipping","Shipping" "Shipping & Handling","Shipping & Handling" -"Shipping & Handling:","Shipping & Handling:" "Shipping & Handling","Shipping & Handling" "Shipping & Handling Information","Shipping & Handling Information" "Shipping Address","Shipping Address" @@ -462,7 +464,6 @@ "Subtotal:","Subtotal:" "TAX/VAT Number","TAX/VAT Number" "Tax","Tax" -"Tax :","Tax :" "Tax Amount","Tax Amount" "Tax Percent","Tax Percent" "Telephone","Telephone" diff --git a/app/locale/en_US/Mage_SalesRule.csv b/app/locale/en_US/Mage_SalesRule.csv index 3a1508e833..139b2fd428 100644 --- a/app/locale/en_US/Mage_SalesRule.csv +++ b/app/locale/en_US/Mage_SalesRule.csv @@ -71,7 +71,6 @@ "Status","Status" "Stop further rules processing","Stop further rules processing" "Subtotal","Subtotal" -"The page you are trying to save no longer exists","The page you are trying to save no longer exists" "This rule no longer exists","This rule no longer exists" "To Date","To Date" "To Fixed Amount","To Fixed Amount" @@ -86,4 +85,5 @@ "Update the Product","Update the Product" "Uses per coupon","Uses per coupon" "Uses per customer","Uses per customer" +"Wrong rule specified.","Wrong rule specified." "Yes","Yes" diff --git a/app/locale/en_US/Mage_Sendfriend.csv b/app/locale/en_US/Mage_Sendfriend.csv index b3dac7de3f..4582c4c5bd 100644 --- a/app/locale/en_US/Mage_Sendfriend.csv +++ b/app/locale/en_US/Mage_Sendfriend.csv @@ -1,5 +1,6 @@ "Add Recipient","Add Recipient" "Allow for Guests","Allow for Guests" +"Back","Back" "Email Address","Email Address" "Email Address:","Email Address:" "Email templates","Email templates" diff --git a/app/locale/en_US/Mage_Shipping.csv b/app/locale/en_US/Mage_Shipping.csv index 4692d99249..48986109cf 100644 --- a/app/locale/en_US/Mage_Shipping.csv +++ b/app/locale/en_US/Mage_Shipping.csv @@ -22,6 +22,7 @@ "Free Shipping","Free Shipping" "Handling Fee","Handling Fee" "Import","Import" +"Include Virtual products in Price calculation","Include Virtual products in Price calculation" "Info:","Info:" "Invalid %s ""%s"" in the Row #%s","Invalid %s ""%s"" in the Row #%s" "Invalid Country ""%s"" in the Row #%s","Invalid Country ""%s"" in the Row #%s" @@ -62,6 +63,7 @@ "Store Pickup","Store Pickup" "Table rates","Table rates" "The shipping module is not available for selected delivery country","The shipping module is not available for selected delivery country" +"The shipping module is not available.","The shipping module is not available." "There is no tracking available for this shipment.","There is no tracking available for this shipment." "There is no tracking available.","There is no tracking available." "This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.","This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us." diff --git a/app/locale/en_US/Mage_Tax.csv b/app/locale/en_US/Mage_Tax.csv index 1f42088005..38718287ed 100644 --- a/app/locale/en_US/Mage_Tax.csv +++ b/app/locale/en_US/Mage_Tax.csv @@ -13,7 +13,6 @@ "Class Name","Class Name" "Code","Code" "Country","Country" -"Country/Region/Postal code combination","Country/Region/Postal code combination" "County","County" "Custom price if available","Custom price if available" "Customer Tax Class","Customer Tax Class" @@ -22,7 +21,7 @@ "Default Country","Default Country" "Default Post Code","Default Post Code" "Default State","Default State" -"Default Tax Origin Calculation","Default Tax Origin Calculation" +"Default Tax Destination Calculation","Default Tax Destination Calculation" "Delete Class","Delete Class" "Delete Rate","Delete Rate" "Delete Rule","Delete Rule" @@ -30,6 +29,7 @@ "Display Cart/Order Prices","Display Cart/Order Prices" "Display Product Prices","Display Product Prices" "Display Shipping Prices","Display Shipping Prices" +"Display Subtotal","Display Subtotal" "Display Zero Tax Subtotal","Display Zero Tax Subtotal" "Display full tax summary","Display full tax summary" "Edit Class","Edit Class" @@ -44,7 +44,6 @@ "Error while saving this tax class. Class with the same name ","Error while saving this tax class. Class with the same name " "Error while saving this tax class. Please try again later.","Error while saving this tax class. Please try again later." "Error while saving this tax rule. Please try again later.","Error while saving this tax rule. Please try again later." -"Error while saving this tax rule. This product tax class, customer tax class and tax rate combination","Error while saving this tax rule. This product tax class, customer tax class and tax rate combination" "Excl. Tax","Excl. Tax" "Excl. Tax:","Excl. Tax:" "Excluding tax","Excluding tax" @@ -57,8 +56,6 @@ "Incl. Tax:","Incl. Tax:" "Including and excluding tax","Including and excluding tax" "Including tax","Including tax" -"Incorrect rate Data","Incorrect rate Data" -"Invalid data for tax rate calculation","Invalid data for tax rate calculation" "Invalid file format upload attempt","Invalid file format upload attempt" "Invalid file upload attempt","Invalid file upload attempt" "Manage Customer Tax Classes","Manage Customer Tax Classes" @@ -82,6 +79,7 @@ "Product Tax Classes","Product Tax Classes" "Rate","Rate" "Reset","Reset" +"Row Total","Row Total" "Sales","Sales" "Save Class","Save Class" "Save Rate","Save Rate" @@ -90,8 +88,11 @@ "Sort Order","Sort Order" "State","State" "State/Region","State/Region" +"Subtotal (Excl. Tax)","Subtotal (Excl. Tax)" +"Subtotal (Incl. Tax)","Subtotal (Incl. Tax)" "Tax","Tax" "Tax Based On","Tax Based On" +"Tax Calculation Method Based On","Tax Calculation Method Based On" "Tax Class for Shipping","Tax Class for Shipping" "Tax Classes","Tax Classes" "Tax Identifier","Tax Identifier" @@ -111,6 +112,8 @@ "Tax rule was successfully saved","Tax rule was successfully saved" "This class no longer exists","This class no longer exists" "This rule no longer exists","This rule no longer exists" +"Total","Total" +"Unit Price","Unit Price" "XML","XML" "You cannot delete this tax class as it is used for %d customer groups.","You cannot delete this tax class as it is used for %d customer groups." "You cannot delete this tax class as it is used for %d products.","You cannot delete this tax class as it is used for %d products." diff --git a/app/locale/en_US/Mage_Wishlist.csv b/app/locale/en_US/Mage_Wishlist.csv index 39084ab5c7..fa0ab62292 100644 --- a/app/locale/en_US/Mage_Wishlist.csv +++ b/app/locale/en_US/Mage_Wishlist.csv @@ -9,11 +9,13 @@ "Are you sure you want to remove this product from your wishlist?","Are you sure you want to remove this product from your wishlist?" "Are you sure you would like to remove this item from the wishlist?","Are you sure you would like to remove this item from the wishlist?" "Back","Back" +"Can not add item to shopping cart","Can not add item to shopping cart" "Can\'t save description %s","Can\'t save description %s" "Cannot create wishlist","Cannot create wishlist" "Cannot specify product","Cannot specify product" "Check this checkbox if you want to add a link to an rss feed to your wishlist.","Check this checkbox if you want to add a link to an rss feed to your wishlist." "Comment","Comment" +"Comment:","Comment:" "Email Sender","Email Sender" "Email Template","Email Template" "Email address can\'t be empty.","Email address can\'t be empty." diff --git a/js/mage/adminhtml/rules.js b/js/mage/adminhtml/rules.js index 7db67ee268..9076a9d903 100644 --- a/js/mage/adminhtml/rules.js +++ b/js/mage/adminhtml/rules.js @@ -308,7 +308,7 @@ VarienRulesForm.prototype = { this.chooserSelectedItems.set(element.value,1); } } else { - this.chooserSelectedItems.remove(element.value); + this.chooserSelectedItems.unset(element.value); } grid.reloadParams = {'selected[]':this.chooserSelectedItems.keys()}; this.updateElement.value = this.chooserSelectedItems.keys().join(', '); diff --git a/js/mage/adminhtml/tools.js b/js/mage/adminhtml/tools.js index 9da3f578c2..c2c6bd0e47 100644 --- a/js/mage/adminhtml/tools.js +++ b/js/mage/adminhtml/tools.js @@ -181,8 +181,12 @@ function syncOnchangeValue(baseElem, distElem){ if (!navigator.appVersion.match('MSIE 6.')) { var header, header_offset, header_copy; - Event.observe(window, 'load', function() { + createTopButtonToolbarToggle(); + }); + + function createTopButtonToolbarToggle() + { var headers = $$('.content-header'); for(var i=0; i_orders[$field] = $direction; return $this; diff --git a/lib/Varien/Data/Collection/Db.php b/lib/Varien/Data/Collection/Db.php index c7ee9e3ad5..571c78ee86 100644 --- a/lib/Varien/Data/Collection/Db.php +++ b/lib/Varien/Data/Collection/Db.php @@ -373,6 +373,9 @@ protected function _getConditionSql($fieldName, $condition) { $sql = ''; $fieldName = $this->_getConditionFieldName($fieldName); + if (is_array($condition) && isset($condition['field_expr'])) { + $fieldName = str_replace('#?', $this->getConnection()->quoteIdentifier($fieldName), $condition['field_expr']); + } if (is_array($condition)) { if (isset($condition['from']) || isset($condition['to'])) { if (isset($condition['from'])) { diff --git a/lib/Varien/Data/Collection/Filesystem.php b/lib/Varien/Data/Collection/Filesystem.php new file mode 100644 index 0000000000..3922829498 --- /dev/null +++ b/lib/Varien/Data/Collection/Filesystem.php @@ -0,0 +1,697 @@ +_allowedDirsMask = (string)$regex; + return $this; + } + + /** + * Allowed files mask setter + * Set empty to not filter + * + * @param string $regex + * @return Varien_Data_Collection_Files + */ + public function setFilesFilter($regex) + { + $this->_allowedFilesMask = (string)$regex; + return $this; + } + + /** + * Disallowed files mask setter + * Set empty value to not use this filter + * + * @param string $regex + * @return Varien_Data_Collection_Files + */ + public function setDisallowedFilesFilter($regex) + { + $this->_disallowedFilesMask = (string)$regex; + return $this; + } + + /** + * Set whether to collect dirs + * + * @param bool $value + * @return Varien_Data_Collection_Filesystem + */ + public function setCollectDirs($value) + { + $this->_collectDirs = (bool)$value; + return $this; + } + + /** + * Set whether to collect files + * + * @param bool $value + * @return Varien_Data_Collection_Filesystem + */ + public function setCollectFiles($value) + { + $this->_collectDirs = (bool)$value; + return $this; + } + + /** + * Set whether to collect recursively + * + * @param bool $value + * @return Varien_Data_Collection_Filesystem + */ + public function setCollectRecursively($value) + { + $this->_collectRecursively = (bool)$value; + return $this; + } + + /** + * Target directory setter. Adds directory to be scanned + * + * @param string $value + * @return Varien_Data_Collection_Filesystem + */ + public function addTargetDir($value) + { + $value = (string)$value; + if (!is_dir($value)) { + throw new Exception('Unable to set target directory.'); + } + $this->_targetDirs[$value] = $value; + return $this; + } + + /** + * Set whether to collect directories before files + * Works *before* sorting. + * + * @param bool $value + * @return Varien_Data_Collection_Filesystem + */ + public function setDirsFirst($value) + { + $this->_dirsFirst = (bool)$value; + return $this; + } + + /** + * Get files from specified directory recursively (if needed) + * + * @param string|array $dir + */ + protected function _collectRecursive($dir) + { + $collectedResult = array(); + if (!is_array($dir)) { + $dir = array($dir); + } + foreach ($dir as $folder) { + foreach (glob($folder . DIRECTORY_SEPARATOR . '*') as $node) { + $collectedResult[] = $node; + } + } + if (!is_array($collectedResult)) { + return; + } + + foreach ($collectedResult as $item) { + if (is_dir($item) && (!$this->_allowedDirsMask || preg_match($this->_allowedDirsMask, basename($item)))) { + if ($this->_collectDirs) { + if ($this->_dirsFirst) { + $this->_collectedDirs[] = $item; + } + else { + $this->_collectedFiles[] = $item; + } + } + if ($this->_collectRecursively) { + $this->_collectRecursive($item); + } + } + elseif ($this->_collectFiles && is_file($item) + && (!$this->_allowedFilesMask || preg_match($this->_allowedFilesMask, basename($item))) + && (!$this->_disallowedFilesMask || !preg_match($this->_disallowedFilesMask, basename($item)))) { + $this->_collectedFiles[] = $item; + } + } + } + + /** + * Lauch data collecting + * + * @param bool $printQuery + * @param bool $logQuery + * @return Varien_Data_Collection_Filesystem + */ + public function loadData($printQuery = false, $logQuery = false) + { + if ($this->isLoaded()) { + return $this; + } + if (empty($this->_targetDirs)) { + throw new Exception('Please specify at least one target directory.'); + } + + $this->_collectedFiles = array(); + $this->_collectedDirs = array(); + $this->_collectRecursive($this->_targetDirs); + $this->_generateAndFilterAndSort('_collectedFiles'); + if ($this->_dirsFirst) { + $this->_generateAndFilterAndSort('_collectedDirs'); + $this->_collectedFiles = array_merge($this->_collectedDirs, $this->_collectedFiles); + } + + // calculate totals + $this->_totalRecords = count($this->_collectedFiles); + $this->_setIsLoaded(); + + // paginate and add items + $from = ($this->getCurPage() - 1) * $this->getPageSize(); + $to = $from + $this->getPageSize() - 1; + $cnt = 0; + foreach ($this->_collectedFiles as $row) { + $cnt++; + if ($cnt < $from || $cnt > $to) { + continue; + } + $item = new $this->_itemObjectClass(); + $this->addItem($item->addData($row)); + if (!$item->hasId()) { + $item->setId($cnt); + } + } + + return $this; + } + + /** + * With specified collected items: + * - generate data + * - apply filters + * - sort + * + * @param string $attributeName '_collectedFiles' | '_collectedDirs' + */ + private function _generateAndFilterAndSort($attributeName) + { + // generate custom data (as rows with columns) basing on the filenames + foreach ($this->$attributeName as $key => $filename) { + $this->{$attributeName}[$key] = $this->_generateRow($filename); + } + + // apply filters on generated data + if (!empty($this->_filters)) { + foreach ($this->$attributeName as $key => $row) { + if (!$this->_filterRow($row)) { + unset($this->{$attributeName}[$key]); + } + } + } + + // sort (keys are lost!) + if (!empty($this->_orders)) { + usort($this->$attributeName, array($this, '_usort')); + } + } + + /** + * Callback for sorting items + * Currently supports only sorting by one column + * + * @param array $a + * @param array $b + * @return int + */ + protected function _usort($a, $b) + { + foreach ($this->_orders as $key => $direction) { + $result = $a[$key] > $b[$key] ? 1 : ($a[$key] < $b[$key] ? -1 : 0); + return (self::SORT_ORDER_ASC === strtoupper($direction) ? $result : -$result); + break; + } + } + + /** + * Set select order + * Currently supports only sorting by one column + * + * @param string $field + * @param string $direction + * @return Varien_Data_Collection + */ + public function setOrder($field, $direction = self::SORT_ORDER_DESC) + { + $this->_orders = array($field => $direction); + return $this; + } + + /** + * Generate item row basing on the filename + * + * @param string $filename + * @return array + */ + protected function _generateRow($filename) + { + return array( + 'filename' => $filename, + 'basename' => basename($filename), + ); + } + + /** + * Set a custom filter with callback + * The callback must take 3 params: + * string $field - field key, + * mixed $filterValue - value to filter by, + * array $row - a generated row (before generaring varien objects) + * + * @param string $field + * @param mixed $value + * @param string $type 'and'|'or' + * @param callback $callback + * @param bool $isInverted + * @return Varien_Data_Collection_Filesystem + */ + public function addCallbackFilter($field, $value, $type, $callback, $isInverted = false) + { + $this->_filters[$this->_filterIncrement] = array( + 'field' => $field, + 'value' => $value, + 'is_and' => 'and' === $type, + 'callback' => $callback, + 'is_inverted' => $isInverted + ); + $this->_filterIncrement++; + return $this; + } + + /** + * The filters renderer and caller + * Aplies to each row, renders once. + * + * @param array $row + * @return bool + */ + protected function _filterRow($row) + { + // render filters once + if (!$this->_isFiltersRendered) { + $eval = ''; + for ($i = 0; $i < $this->_filterIncrement; $i++) { + if (isset($this->_filterBrackets[$i])) { + $eval .= $this->_renderConditionBeforeFilterElement($i, $this->_filterBrackets[$i]['is_and']) + . $this->_filterBrackets[$i]['value']; + } + else { + $f = '$this->_filters[' . $i . ']'; + $eval .= $this->_renderConditionBeforeFilterElement($i, $this->_filters[$i]['is_and']) + . ($this->_filters[$i]['is_inverted'] ? '!' : '') + . '$this->_invokeFilter(' . "{$f}['callback'], array({$f}['field'], {$f}['value'], " . '$row))'; + } + } + $this->_filterEvalRendered = $eval; + $this->_isFiltersRendered = true; + } + $result = false; + if ($this->_filterEvalRendered) { + eval('$result = ' . $this->_filterEvalRendered . ';'); + } + return $result; + } + + /** + * Invokes specified callback + * Skips, if there is no filtered key in the row + * + * @param callback $callback + * @param array $callbackParams + * @return bool + */ + protected function _invokeFilter($callback, $callbackParams) + { + list($field, $value, $row) = $callbackParams; + if (!array_key_exists($field, $row)) { + return false; + } + return call_user_func_array($callback, $callbackParams); + } + + /** + * Fancy field filter + * + * @param string $field + * @param mixed $cond + * @param string $type 'and' | 'or' + * @see Varien_Data_Collection_Db::addFieldToFilter() + * @return Varien_Data_Collection_Filesystem + */ + public function addFieldToFilter($field, $cond, $type = 'and') + { + $inverted = true; + + // simply check whether equals + if (!is_array($cond)) { + return $this->addCallbackFilter($field, $cond, $type, array($this, 'filterCallbackEq')); + } + + // versatile filters + if (isset($cond['from']) || isset($cond['to'])) { + $this->_addFilterBracket('(', 'and' === $type); + if (isset($cond['from'])) { + $this->addCallbackFilter($field, $cond['from'], 'and', array($this, 'filterCallbackIsLessThan'), $inverted); + } + if (isset($cond['to'])) { + $this->addCallbackFilter($field, $cond['to'], 'and', array($this, 'filterCallbackIsMoreThan'), $inverted); + } + return $this->_addFilterBracket(')'); + } + if (isset($cond['eq'])) { + return $this->addCallbackFilter($field, $cond['eq'], $type, array($this, 'filterCallbackEq')); + } + if (isset($cond['neq'])) { + return $this->addCallbackFilter($field, $cond['neq'], $type, array($this, 'filterCallbackEq'), $inverted); + } + if (isset($cond['like'])) { + return $this->addCallbackFilter($field, $cond['like'], $type, array($this, 'filterCallbackLike')); + } + if (isset($cond['nlike'])) { + return $this->addCallbackFilter($field, $cond['nlike'], $type, array($this, 'filterCallbackLike'), $inverted); + } + if (isset($cond['in'])) { + return $this->addCallbackFilter($field, $cond['in'], $type, array($this, 'filterCallbackInArray')); + } + if (isset($cond['nin'])) { + return $this->addCallbackFilter($field, $cond['nin'], $type, array($this, 'filterCallbackIn'), $inverted); + } + if (isset($cond['notnull'])) { + return $this->addCallbackFilter($field, $cond['notnull'], $type, array($this, 'filterCallbackIsNull'), $inverted); + } + if (isset($cond['null'])) { + return $this->addCallbackFilter($field, $cond['null'], $type, array($this, 'filterCallbackIsNull')); + } + if (isset($cond['moreq'])) { + return $this->addCallbackFilter($field, $cond['moreq'], $type, array($this, 'filterCallbackIsLessThan'), $inverted); + } + if (isset($cond['gt'])) { + return $this->addCallbackFilter($field, $cond['gt'], $type, array($this, 'filterCallbackIsMoreThan')); + } + if (isset($cond['lt'])) { + return $this->addCallbackFilter($field, $cond['lt'], $type, array($this, 'filterCallbackIsLessThan')); + } + if (isset($cond['gteq'])) { + return $this->addCallbackFilter($field, $cond['gteq'], $type, array($this, 'filterCallbackIsLessThan'), $inverted); + } + if (isset($cond['lteq'])) { + return $this->addCallbackFilter($field, $cond['lteq'], $type, array($this, 'filterCallbackIsMoreThan'), $inverted); + } + if (isset($cond['finset'])) { + $filterValue = ($cond['finset'] ? explode(',', $cond['finset']) : array()); + return $this->addCallbackFilter($field, $filterValue, $type, array($this, 'filterCallbackInArray')); + } + + // add OR recursively + foreach ($cond as $orCond) { + $this->_addFilterBracket('(', 'and' === $type); + $this->addFieldToFilter($field, $orCond, 'or'); + $this->_addFilterBracket(')'); + } + return $this; + } + + /** + * Prepare a bracket into filters + * + * @param string $bracket + * @param bool $isAnd + * @return Varien_Data_Collection_Filesystem + */ + protected function _addFilterBracket($bracket = '(', $isAnd = true) + { + $this->_filterBrackets[$this->_filterIncrement] = array( + 'value' => $bracket === ')' ? ')' : '(', + 'is_and' => $isAnd, + ); + $this->_filterIncrement++; + return $this; + } + + /** + * Render condition sign before element, if required + * + * @param int $increment + * @param bool $isAnd + * @return string + */ + protected function _renderConditionBeforeFilterElement($increment, $isAnd) + { + if (isset($this->_filterBrackets[$increment]) && ')' === $this->_filterBrackets[$increment]['value']) { + return ''; + } + $prevIncrement = $increment - 1; + $prevBracket = false; + if (isset($this->_filterBrackets[$prevIncrement])) { + $prevBracket = $this->_filterBrackets[$prevIncrement]['value']; + } + if ($prevIncrement < 0 || $prevBracket === '(') { + return ''; + } + return ($isAnd ? ' && ' : ' || '); + } + + /** + * Does nothing. Intentionally disabled parent method + * + * @return Varien_Data_Collection_Filesystem + */ + public function addFilter($field, $value, $type = 'and') + { + return $this; + } + + /** + * Get all ids of collected items + * + * @return array + */ + public function getAllIds() + { + return array_keys($this->_items); + } + + /** + * Callback method for 'like' fancy filter + * + * @param string $field + * @param mixed $filterValue + * @param array $row + * @return bool + * @see addFieldToFilter() + * @see addCallbackFilter() + */ + public function filterCallbackLike($field, $filterValue, $row) + { + $filterValueRegex = str_replace('%', '(.*?)', preg_quote($filterValue, '/')); + return (bool)preg_match("/^{$filterValueRegex}$/i", $row[$field]); + } + + /** + * Callback method for 'eq' fancy filter + * + * @param string $field + * @param mixed $filterValue + * @param array $row + * @return bool + * @see addFieldToFilter() + * @see addCallbackFilter() + */ + public function filterCallbackEq($field, $filterValue, $row) + { + return $filterValue == $row[$field]; + } + + /** + * Callback method for 'in' fancy filter + * + * @param string $field + * @param mixed $filterValue + * @param array $row + * @return bool + * @see addFieldToFilter() + * @see addCallbackFilter() + */ + public function filterCallbackInArray($field, $filterValue, $row) + { + return in_array($row[$field], $filterValue); + } + + /** + * Callback method for 'isnull' fancy filter + * + * @param string $field + * @param mixed $filterValue + * @param array $row + * @return bool + * @see addFieldToFilter() + * @see addCallbackFilter() + */ + public function filterCallbackIsNull($field, $filterValue, $row) + { + return null === $row[$field]; + } + + /** + * Callback method for 'moreq' fancy filter + * + * @param string $field + * @param mixed $filterValue + * @param array $row + * @return bool + * @see addFieldToFilter() + * @see addCallbackFilter() + */ + public function filterCallbackIsMoreThan($field, $filterValue, $row) + { + return $row[$field] > $filterValue; + } + + /** + * Callback method for 'leq' fancy filter + * + * @param string $field + * @param mixed $filterValue + * @param array $row + * @return bool + * @see addFieldToFilter() + * @see addCallbackFilter() + */ + public function filterCallbackIsLessThan($field, $filterValue, $row) + { + return $row[$field] < $filterValue; + } +} diff --git a/lib/Varien/Data/Form/Element/Fieldset.php b/lib/Varien/Data/Form/Element/Fieldset.php index 0775a06a96..bd9c9a49be 100644 --- a/lib/Varien/Data/Form/Element/Fieldset.php +++ b/lib/Varien/Data/Form/Element/Fieldset.php @@ -34,6 +34,19 @@ */ class Varien_Data_Form_Element_Fieldset extends Varien_Data_Form_Element_Abstract { + /** + * Sort child elements by specified data key + * + * @var string + */ + protected $_sortChildrenByKey = ''; + + /** + * Children sort direction + * + * @var int + */ + protected $_sortChildrenDirection = SORT_ASC; /** * Enter description here... @@ -72,7 +85,7 @@ public function getElementHtml() public function getChildrenHtml() { $html = ''; - foreach ($this->getElements() as $element) { + foreach ($this->getSortedElements() as $element) { if ($element->getType() != 'fieldset') { $html.= $element->toHtml(); } @@ -88,7 +101,7 @@ public function getChildrenHtml() public function getSubFieldsetHtml() { $html = ''; - foreach ($this->getElements() as $element) { + foreach ($this->getSortedElements() as $element) { if ($element->getType() == 'fieldset') { $html.= $element->toHtml(); } @@ -126,4 +139,48 @@ public function addField($elementId, $type, $config, $after=false) return $element; } + /** + * Commence sorting elements by values by specified data key + * + * @param string $key + * @param int $direction + * @return Varien_Data_Form_Element_Fieldset + */ + public function setSortElementsByAttribute($key, $direction = SORT_ASC) + { + $this->_sortChildrenByKey = $key; + $this->_sortDirection = $direction; + return $this; + } + + /** + * Get sorted elements as array + * + * @return array + */ + public function getSortedElements() + { + $elements = array(); + // sort children by value by specified key + if ($this->_sortChildrenByKey) { + $sortKey = $this->_sortChildrenByKey; + $uniqueIncrement = 0; // in case if there are elements with same values + foreach ($this->getElements() as $e) { + $key = '_' . $uniqueIncrement; + if ($e->hasData($sortKey)) { + $key = $e->getDataUsingMethod($sortKey) . $key; + } + $elements[$key] = $e; + $uniqueIncrement++; + } + ksort($elements, $this->_sortChildrenDirection); + $elements = array_values($elements); + } + else { + foreach ($this->getElements() as $element) { + $elements[] = $element; + } + } + return $elements; + } } diff --git a/lib/Zend/Gdata/App.php b/lib/Zend/Gdata/App.php index 7baa372e8f..4934f910d7 100644 --- a/lib/Zend/Gdata/App.php +++ b/lib/Zend/Gdata/App.php @@ -935,7 +935,7 @@ public function __call($method, $args) $foundClassName = null; foreach ($this->_registeredPackages as $name) { try { - @#Zend_Loader::loadClass("${name}_${class}"); + @Zend_Loader::loadClass("${name}_${class}"); $foundClassName = "${name}_${class}"; break; } catch (Zend_Exception $e) { diff --git a/skin/frontend/default/blue/js/opcheckout.js b/skin/frontend/default/blue/js/opcheckout.js index 19b5be6c56..b9f2f813b3 100644 --- a/skin/frontend/default/blue/js/opcheckout.js +++ b/skin/frontend/default/blue/js/opcheckout.js @@ -777,6 +777,16 @@ Review.prototype = { } alert(msg); } + + if (response.update_section) { + $('checkout-'+response.update_section.name+'-load').update(response.update_section.html); + response.update_section.html.evalScripts(); + } + + if (response.goto_section) { + checkout.gotoSection(response.goto_section); + checkout.reloadProgressBlock(); + } } }, diff --git a/skin/frontend/default/default/js/opcheckout.js b/skin/frontend/default/default/js/opcheckout.js index 26cc44a113..fd3ddf9a38 100644 --- a/skin/frontend/default/default/js/opcheckout.js +++ b/skin/frontend/default/default/js/opcheckout.js @@ -777,6 +777,16 @@ Review.prototype = { } alert(msg); } + + if (response.update_section) { + $('checkout-'+response.update_section.name+'-load').update(response.update_section.html); + response.update_section.html.evalScripts(); + } + + if (response.goto_section) { + checkout.gotoSection(response.goto_section); + checkout.reloadProgressBlock(); + } } },