*/
-class Mage_Paybox_Block_System_Failure extends Mage_Core_Block_Template
+class Mage_Adminhtml_Block_Notification_Survey extends Mage_Adminhtml_Block_Template
{
/**
- * Enter description here...
+ * Check whether survey question can show
*
- * @return Mage_Checkout_Model_Session
+ * @return boolean
*/
- public function getCheckout()
+ public function canShow()
{
- return Mage::getSingleton('checkout/session');
- }
-
- public function getErrorMessage()
- {
- $msg = Mage::helper('paybox')->__($this->getCheckout()->getPayboxErrorMessage());
- $this->getCheckout()->unsPayboxErrorMessage();
- return $msg;
+ $adminSession = Mage::getSingleton('admin/session');
+ $seconds = intval(date('s', time()));
+ if ($adminSession->getHideSurveyQuestion() || !$adminSession->isAllowed('all')
+ || Mage_AdminNotification_Model_Survey::isSurveyViewed()
+ || !Mage_AdminNotification_Model_Survey::isSurveyUrlValid())
+ {
+ return false;
+ }
+ return true;
}
/**
- * Get continue shopping url
+ * Return survey url
+ *
+ * @return string
*/
- public function getContinueShoppingUrl()
+ public function getSurveyUrl()
{
- return Mage::getUrl('checkout/cart', array('_secure' => true));
+ return Mage_AdminNotification_Model_Survey::getSurveyUrl();
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Roleinfo.php b/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Roleinfo.php
index 916b26e433..071937e2c6 100644
--- a/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Roleinfo.php
+++ b/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Roleinfo.php
@@ -88,6 +88,8 @@ protected function _initForm()
)
);
+ $fieldset->addField('in_role_user_old', 'hidden', array('name' => 'in_role_user_old'));
+
$form->setValues($this->getRole()->getData());
$this->setForm($form);
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php
index 669cca7aa6..8708d37a59 100644
--- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php
+++ b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php
@@ -60,7 +60,7 @@ protected function _prepareLayout()
->setData(array(
'label' => Mage::helper('poll')->__('Delete'),
'onclick' => 'answer.del(this)',
- 'class' => 'delete f-right'
+ 'class' => 'delete'
))
);
diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php
index b03e589261..423054b75e 100644
--- a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php
+++ b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php
@@ -159,6 +159,8 @@ protected function _prepareForm()
'required' => true,
))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/actions'));
+ Mage::dispatchEvent('adminhtml_block_salesrule_actions_prepareform', array('form' => $form));
+
$form->setValues($model->getData());
if ($model->isReadonly()) {
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php b/app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php
index a1e45e7432..cc5c046f57 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Filter/Form.php
@@ -58,6 +58,8 @@ protected function _prepareForm()
$form = new Varien_Data_Form(
array('id' => 'filter_form', 'action' => $actionUrl, 'method' => 'get')
);
+ $htmlIdPrefix = 'sales_report_';
+ $form->setHtmlIdPrefix($htmlIdPrefix);
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('reports')->__('Filter')));
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
@@ -66,6 +68,35 @@ protected function _prepareForm()
'name' => 'store_ids'
));
+ $statuses = Mage::getModel('sales/order_config')->getStatuses();
+ $values = array();
+ foreach ($statuses as $code => $label) {
+ if (false === strpos($code, 'pending')) {
+ $values[] = array(
+ 'label' => Mage::helper('reports')->__($label),
+ 'value' => $code
+ );
+ }
+ }
+
+ $fieldset->addField('report_type', 'select', array(
+ 'name' => 'report_type',
+ 'options' => $this->_reportTypeOptions,
+ 'label' => Mage::helper('reports')->__('Report Type'),
+ 'title' => Mage::helper('reports')->__('Report Type')
+ ));
+
+ $fieldset->addField('period_type', 'select', array(
+ 'name' => 'period_type',
+ 'options' => array(
+ 'day' => Mage::helper('reports')->__('Day'),
+ 'month' => Mage::helper('reports')->__('Month'),
+ 'year' => Mage::helper('reports')->__('Year')
+ ),
+ 'label' => Mage::helper('reports')->__('Period'),
+ 'title' => Mage::helper('reports')->__('Period')
+ ));
+
$fieldset->addField('from', 'date', array(
'name' => 'from',
'format' => $dateFormatIso,
@@ -84,40 +115,21 @@ protected function _prepareForm()
'required' => true
));
- $fieldset->addField('period_type', 'select', array(
- 'name' => 'period_type',
- 'options' => array(
- 'day' => Mage::helper('reports')->__('Day'),
- 'month' => Mage::helper('reports')->__('Month'),
- 'year' => Mage::helper('reports')->__('Year')
- ),
- 'label' => Mage::helper('reports')->__('Period Type'),
- 'title' => Mage::helper('reports')->__('Period Type')
- ));
-
- $fieldset->addField('report_type', 'select', array(
- 'name' => 'report_type',
- 'options' => $this->_reportTypeOptions,
- 'label' => Mage::helper('reports')->__('Report Type'),
- 'title' => Mage::helper('reports')->__('Report Type')
+ $fieldset->addField('show_order_statuses', 'select', array(
+ 'name' => 'show_order_statuses',
+ 'label' => Mage::helper('reports')->__('Order Status'),
+ 'title' => Mage::helper('reports')->__('Order Status'),
+ 'options' => array(
+ '0' => Mage::helper('reports')->__('Any'),
+ '1' => Mage::helper('reports')->__('Specified'),
+ ),
+ 'note' => Mage::helper('reports')->__('Applies to Any of the Specified Order Statuses'),
));
- $statuses = Mage::getModel('sales/order_config')->getStatuses();
- $values = array();
- foreach ($statuses as $code => $label) {
- if (false === strpos($code, 'pending')) {
- $values[] = array(
- 'label' => Mage::helper('reports')->__($label),
- 'value' => $code
- );
- }
- }
-
$fieldset->addField('order_statuses', 'multiselect', array(
'name' => 'order_statuses',
'values' => $values,
- 'label' => Mage::helper('reports')->__('Status'),
- 'title' => Mage::helper('reports')->__('Status')
+ 'display' => 'none'
));
$fieldset->addField('show_empty_rows', 'select', array(
@@ -126,13 +138,21 @@ protected function _prepareForm()
'1' => 'Yes',
'0' => 'No'
),
- 'label' => Mage::helper('reports')->__('Show Empty Rows'),
- 'title' => Mage::helper('reports')->__('Show Empty Rows')
+ 'label' => Mage::helper('reports')->__('Empty Rows'),
+ 'title' => Mage::helper('reports')->__('Empty Rows')
));
$form->addValues($this->getFilterData()->getData());
$form->setUseContainer(true);
$this->setForm($form);
+
+ // define field dependencies
+ $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
+ ->addFieldMap("{$htmlIdPrefix}show_order_statuses", 'show_order_statuses')
+ ->addFieldMap("{$htmlIdPrefix}order_statuses", 'order_statuses')
+ ->addFieldDependence('order_statuses', 'show_order_statuses', '1')
+ );
+
return parent::_prepareForm();
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php
index 0a26020be6..5afaf923eb 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php
@@ -45,8 +45,10 @@ protected function _getUpdatedAt($reportCode)
{
$flag = Mage::getModel('reports/flag')->setReportFlagCode($reportCode)->loadSelf();
return ($flag->hasData())
- ? Mage::app()->getLocale()->storeDate(0, $flag->getLastUpdate(), true)
- : Mage::helper('reports')->__('undefined');
+ ? Mage::app()->getLocale()->storeDate(
+ 0, new Zend_Date($flag->getLastUpdate(), Varien_Date::DATETIME_INTERNAL_FORMAT), true
+ )
+ : '';
}
protected function _prepareCollection()
@@ -57,37 +59,37 @@ protected function _prepareCollection()
array(
'id' => 'sales',
'report' => Mage::helper('reports')->__('Sales'),
- 'comment' => '',
+ 'comment' => Mage::helper('reports')->__('Total Ordered Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_ORDER_FLAG_CODE)
),
array(
'id' => 'tax',
'report' => Mage::helper('reports')->__('Tax'),
- 'comment' => '',
+ 'comment' => Mage::helper('reports')->__('Order Taxes Report Grouped by Tax Rates'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_TAX_FLAG_CODE)
),
array(
'id' => 'shipping',
'report' => Mage::helper('reports')->__('Shipping'),
- 'comment' => '',
+ 'comment' => Mage::helper('reports')->__('Total Shipped Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_SHIPPING_FLAG_CODE)
),
array(
'id' => 'invoiced',
'report' => Mage::helper('reports')->__('Total Invoiced'),
- 'comment' => '',
+ 'comment' => Mage::helper('reports')->__('Total Invoiced VS Paid Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_INVOICE_FLAG_CODE)
),
array(
'id' => 'refunded',
'report' => Mage::helper('reports')->__('Total Refunded'),
- 'comment' => '',
+ 'comment' => Mage::helper('reports')->__('Total Refunded Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_REFUNDED_FLAG_CODE)
),
array(
'id' => 'coupons',
'report' => Mage::helper('reports')->__('Coupons'),
- 'comment' => '',
+ 'comment' => Mage::helper('reports')->__('Promotion Coupons Usage Report'),
'updated_at' => $this->_getUpdatedAt(Mage_Reports_Model_Flag::REPORT_COUPNS_FLAG_CODE)
)
);
@@ -114,7 +116,7 @@ protected function _prepareColumns()
));
$this->addColumn('comment', array(
- 'header' => Mage::helper('reports')->__('Comment'),
+ 'header' => Mage::helper('reports')->__('Description'),
'index' => 'comment',
'type' => 'string',
'sortable' => false
@@ -123,26 +125,11 @@ protected function _prepareColumns()
$this->addColumn('updated_at', array(
'header' => Mage::helper('reports')->__('Updated At'),
'index' => 'updated_at',
- 'type' => 'string',
+ 'type' => 'datetime',
'width' => 200,
'sortable' => false
));
- $this->addColumn('action', array(
- 'header' => Mage::helper('reports')->__('Action'),
- 'index' => 'id',
- 'type' => 'action',
- 'actions' => array(
- array(
- 'caption' => Mage::helper('index')->__('Refresh Recent'),
- 'url' => array('base'=>'*/*/refreshRecent'),
- 'field' => 'code'
- ),
- ),
- 'width' => 100,
- 'sortable' => false
- ));
-
return parent::_prepareColumns();
}
@@ -152,15 +139,16 @@ protected function _prepareMassaction()
$this->getMassactionBlock()->setFormFieldName('code');
$this->getMassactionBlock()->addItem('refresh_lifetime', array(
- 'label' => Mage::helper('reports')->__('Refresh Lifetime Statistics'),
- 'url' => $this->getUrl('*/*/refreshLifetime'),
- 'confirm' => Mage::helper('reports')->__('Are you sure you want to refresh lifetime statistics? There can be performance impact during this operation.')
+ 'label' => Mage::helper('reports')->__('Refresh Lifetime Statistics'),
+ 'url' => $this->getUrl('*/*/refreshLifetime'),
+ 'confirm' => Mage::helper('reports')->__('Are you sure you want to refresh lifetime statistics? There can be performance impact during this operation.')
));
$this->getMassactionBlock()->addItem('refresh_recent', array(
- 'label' => Mage::helper('reports')->__('Refresh Statistics for Last Day'),
- 'url' => $this->getUrl('*/*/refreshRecent'),
- 'confirm' => Mage::helper('reports')->__('Are you sure?')
+ 'label' => Mage::helper('reports')->__('Refresh Statistics for Last Day'),
+ 'url' => $this->getUrl('*/*/refreshRecent'),
+ 'confirm' => Mage::helper('reports')->__('Are you sure?'),
+ 'selected' => true
));
return $this;
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons.php
index 7ab5f1d668..c3a681dbe9 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons.php
@@ -37,12 +37,12 @@ class Mage_Adminhtml_Block_Report_Sales_Coupons extends Mage_Adminhtml_Block_Wid
public function __construct()
{
$this->_controller = 'report_sales_coupons';
- $this->_headerText = Mage::helper('reports')->__('Coupons');
+ $this->_headerText = Mage::helper('reports')->__('Coupons Usage Report');
parent::__construct();
$this->setTemplate('report/grid/container.phtml');
$this->_removeButton('add');
$this->addButton('filter_form_submit', array(
- 'label' => Mage::helper('reports')->__('Generate Report'),
+ 'label' => Mage::helper('reports')->__('Show Report'),
'onclick' => 'filterFormSubmit()'
));
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php
index d1986ab28a..217db36c16 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Coupons/Grid.php
@@ -54,9 +54,10 @@ protected function _prepareColumns()
$this->addColumn('period', array(
'header' => Mage::helper('reports')->__('Period'),
'index' => 'period',
- 'type' => 'string',
'width' => 100,
'sortable' => false,
+ 'period_type' => $this->getPeriodType(),
+ 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
'totals_label' => Mage::helper('adminhtml')->__('Total'),
'subtotals_label' => Mage::helper('adminhtml')->__('SubTotal')
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php
new file mode 100644
index 0000000000..74ee4fd311
--- /dev/null
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php
@@ -0,0 +1,112 @@
+
+ */
+
+class Mage_Adminhtml_Block_Report_Sales_Grid_Column_Renderer_Date
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Date
+{
+ /**
+ * Retrieve date format
+ *
+ * @return string
+ */
+ protected function _getFormat()
+ {
+ $format = $this->getColumn()->getFormat();
+ if (!$format) {
+ if (is_null(self::$_format)) {
+ try {
+ $localeCode = Mage::app()->getLocale()->getLocaleCode();
+ $localeData = new Zend_Locale_Data;
+ switch ($this->getColumn()->getPeriodType()) {
+ case 'month' :
+ self::$_format = $localeData->getContent($localeCode, 'dateitem', 'yM');
+ break;
+
+ case 'year' :
+ self::$_format = $localeData->getContent($localeCode, 'dateitem', 'y');
+ break;
+
+ default:
+ self::$_format = Mage::app()->getLocale()->getDateFormat(
+ Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM
+ );
+ break;
+ }
+ }
+ catch (Exception $e) {
+
+ }
+ }
+ $format = self::$_format;
+ }
+ return $format;
+ }
+
+ /**
+ * Renders grid column
+ *
+ * @param Varien_Object $row
+ * @return string
+ */
+ public function render(Varien_Object $row)
+ {
+ if ($data = $row->getData($this->getColumn()->getIndex())) {
+ switch ($this->getColumn()->getPeriodType()) {
+ case 'month' :
+ $dateFormat = 'yyyy-MM';
+ break;
+ case 'year' :
+ $dateFormat = 'yyyy';
+ break;
+ default:
+ $dateFormat = Varien_Date::DATE_INTERNAL_FORMAT;
+ break;
+ }
+
+ $format = $this->_getFormat();
+ try {
+ $data = ($this->getColumn()->getGmtoffset())
+ ? Mage::app()->getLocale()->date($data, $dateFormat)->toString($format)
+ : Mage::getSingleton('core/locale')->date($data, Zend_Date::ISO_8601, null, false)->toString($format);
+ }
+ catch (Exception $e) {
+ $data = ($this->getColumn()->getTimezone())
+ ? Mage::app()->getLocale()->date($data, $dateFormat)->toString($format)
+ : Mage::getSingleton('core/locale')->date($data, $dateFormat, null, false)->toString($format);
+ }
+ return $data;
+ }
+ return $this->getColumn()->getDefault();
+ }
+}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced.php
index f69e13a50c..8cabc80590 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced.php
@@ -37,12 +37,12 @@ class Mage_Adminhtml_Block_Report_Sales_Invoiced extends Mage_Adminhtml_Block_Wi
public function __construct()
{
$this->_controller = 'report_sales_invoiced';
- $this->_headerText = Mage::helper('reports')->__('Total invoiced');
+ $this->_headerText = Mage::helper('reports')->__('Total Invoiced VS Paid Report');
parent::__construct();
$this->setTemplate('report/grid/container.phtml');
$this->_removeButton('add');
$this->addButton('filter_form_submit', array(
- 'label' => Mage::helper('reports')->__('Generate Report'),
+ 'label' => Mage::helper('reports')->__('Show Report'),
'onclick' => 'filterFormSubmit()'
));
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php
index b37ed9dafa..b571b446f6 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Invoiced/Grid.php
@@ -53,9 +53,10 @@ protected function _prepareColumns()
$this->addColumn('period', array(
'header' => Mage::helper('sales')->__('Period'),
'index' => 'period',
- 'type' => 'string',
'width' => 100,
'sortable' => false,
+ 'period_type' => $this->getPeriodType(),
+ 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
'totals_label' => Mage::helper('adminhtml')->__('Total')
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded.php
index 8cecd021c0..13f78d96f3 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded.php
@@ -37,12 +37,12 @@ class Mage_Adminhtml_Block_Report_Sales_Refunded extends Mage_Adminhtml_Block_Wi
public function __construct()
{
$this->_controller = 'report_sales_refunded';
- $this->_headerText = Mage::helper('reports')->__('Total refunded');
+ $this->_headerText = Mage::helper('reports')->__('Total Refunded Report');
parent::__construct();
$this->setTemplate('report/grid/container.phtml');
$this->_removeButton('add');
$this->addButton('filter_form_submit', array(
- 'label' => Mage::helper('reports')->__('Generate Report'),
+ 'label' => Mage::helper('reports')->__('Show Report'),
'onclick' => 'filterFormSubmit()'
));
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php
index f519102178..7f428dfe88 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Refunded/Grid.php
@@ -53,9 +53,10 @@ protected function _prepareColumns()
$this->addColumn('period', array(
'header' => Mage::helper('sales')->__('Period'),
'index' => 'period',
- 'type' => 'string',
'width' => 100,
'sortable' => false,
+ 'period_type' => $this->getPeriodType(),
+ 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
'totals_label' => Mage::helper('adminhtml')->__('Total')
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales.php
index 2e6d36cf74..c89e2f9c24 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales.php
@@ -38,12 +38,12 @@ class Mage_Adminhtml_Block_Report_Sales_Sales extends Mage_Adminhtml_Block_Widge
public function __construct()
{
$this->_controller = 'report_sales_sales';
- $this->_headerText = Mage::helper('reports')->__('Sales Report');
+ $this->_headerText = Mage::helper('reports')->__('Total Ordered Report');
parent::__construct();
$this->setTemplate('report/grid/container.phtml');
$this->_removeButton('add');
$this->addButton('filter_form_submit', array(
- 'label' => Mage::helper('reports')->__('Generate Report'),
+ 'label' => Mage::helper('reports')->__('Show Report'),
'onclick' => 'filterFormSubmit()'
));
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php
index d76e5eee01..98dfad2530 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Sales/Grid.php
@@ -53,9 +53,10 @@ protected function _prepareColumns()
$this->addColumn('period', array(
'header' => Mage::helper('sales')->__('Period'),
'index' => 'period',
- 'type' => 'string',
'width' => 100,
'sortable' => false,
+ 'period_type' => $this->getPeriodType(),
+ 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
'totals_label' => Mage::helper('adminhtml')->__('Total')
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping.php
index 653dea605d..924cc0aab8 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping.php
@@ -37,12 +37,12 @@ class Mage_Adminhtml_Block_Report_Sales_Shipping extends Mage_Adminhtml_Block_Wi
public function __construct()
{
$this->_controller = 'report_sales_shipping';
- $this->_headerText = Mage::helper('reports')->__('Shipping');
+ $this->_headerText = Mage::helper('reports')->__('Total Shipped Report');
parent::__construct();
$this->setTemplate('report/grid/container.phtml');
$this->_removeButton('add');
$this->addButton('filter_form_submit', array(
- 'label' => Mage::helper('reports')->__('Generate Report'),
+ 'label' => Mage::helper('reports')->__('Show Report'),
'onclick' => 'filterFormSubmit()'
));
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php
index 8d598aed25..43b734043f 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Shipping/Grid.php
@@ -54,9 +54,10 @@ protected function _prepareColumns()
$this->addColumn('period', array(
'header' => Mage::helper('adminhtml')->__('Period'),
'index' => 'period',
- 'type' => 'string',
'width' => 100,
'sortable' => false,
+ 'period_type' => $this->getPeriodType(),
+ 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
'totals_label' => Mage::helper('adminhtml')->__('Total'),
'subtotals_label' => Mage::helper('adminhtml')->__('SubTotal')
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax.php
index 7630a6ac11..5b19c5f7bd 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax.php
@@ -37,12 +37,12 @@ class Mage_Adminhtml_Block_Report_Sales_Tax extends Mage_Adminhtml_Block_Widget_
public function __construct()
{
$this->_controller = 'report_sales_tax';
- $this->_headerText = Mage::helper('reports')->__('Tax');
+ $this->_headerText = Mage::helper('reports')->__('Order Taxes Report Grouped by Tax Rate');
parent::__construct();
$this->setTemplate('report/grid/container.phtml');
$this->_removeButton('add');
$this->addButton('filter_form_submit', array(
- 'label' => Mage::helper('reports')->__('Generate Report'),
+ 'label' => Mage::helper('reports')->__('Show Report'),
'onclick' => 'filterFormSubmit()'
));
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php
index 6fa57c42b2..6152dd9a49 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Sales/Tax/Grid.php
@@ -54,9 +54,10 @@ protected function _prepareColumns()
$this->addColumn('period', array(
'header' => Mage::helper('sales')->__('Period'),
'index' => 'period',
- 'type' => 'string',
'width' => '100',
'sortable' => false,
+ 'period_type' => $this->getPeriodType(),
+ 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
'totals_label' => Mage::helper('adminhtml')->__('Total'),
'subtotals_label' => Mage::helper('adminhtml')->__('SubTotal')
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Review/Grid.php b/app/code/core/Mage/Adminhtml/Block/Review/Grid.php
index e92000a609..b2be8b61c9 100644
--- a/app/code/core/Mage/Adminhtml/Block/Review/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Review/Grid.php
@@ -166,6 +166,7 @@ protected function _prepareColumns()
'align' =>'left',
'type' => 'text',
'index' => 'name',
+ 'escape' => true
));
$this->addColumn('sku', array(
@@ -174,6 +175,7 @@ protected function _prepareColumns()
'type' => 'text',
'width' => '50px',
'index' => 'sku',
+ 'escape' => true
));
$this->addColumn('action',
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php
index 6bcebb2966..708d5d0254 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Customer/Grid.php
@@ -98,14 +98,12 @@ protected function _prepareColumns()
'index' =>'billing_regione',
));
- if (!Mage::app()->isSingleStoreMode()) {
- $this->addColumn('store_name', array(
- 'header' =>Mage::helper('sales')->__('Signed Up From'),
- 'align' => 'center',
- 'index' =>'store_name',
- 'width' =>'130px',
- ));
- }
+ $this->addColumn('store_name', array(
+ 'header' =>Mage::helper('sales')->__('Signed Up From'),
+ 'align' => 'center',
+ 'index' =>'store_name',
+ 'width' =>'130px',
+ ));
return parent::_prepareColumns();
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Data.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Data.php
index 18e00b3067..04bbda3270 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Data.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Data.php
@@ -48,7 +48,7 @@ public function getAvailableCurrencies()
$dirtyCodes
);
foreach ($dirtyCodes as $code) {
- if (isset($rates[$code]) || $code == Mage::app()->getStore()->getBaseCurrency()) {
+ if (isset($rates[$code]) || $code == Mage::app()->getStore()->getBaseCurrencyCode()) {
$codes[] = $code;
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php
index 3ff93f4a6c..52948e3e41 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Address.php
@@ -88,6 +88,11 @@ protected function _prepareForm()
)
->setEntityAttribute($attribute);
+ if ('street' === $element->getName()) {
+ $lines = Mage::getStoreConfig('customer/address/street_lines', $this->getStoreId());
+ $element->setLineCount($lines);
+ }
+
if ($inputType == 'select' || $inputType == 'multiselect') {
$element->setValues($attribute->getFrontend()->getSelectOptions());
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php
index b00c608e44..c581a0e18b 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php
@@ -122,7 +122,12 @@ public function displayTotalsIncludeTax()
public function getSubtotal()
{
- $address = $this->getQuote()->getShippingAddress();
+ if ($this->getQuote()->isVirtual()) {
+ $address = $this->getQuote()->getBillingAddress();
+ }
+ else {
+ $address = $this->getQuote()->getShippingAddress();
+ }
if ($this->displayTotalsIncludeTax()) {
if ($address->getSubtotalInclTax()) {
return $address->getSubtotalInclTax();
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 4fe3518fbb..27a386819c 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
@@ -59,30 +59,27 @@ protected function _prepareLayout()
$this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
'label' => Mage::helper('sales')->__('Refund'),
'class' => 'save submit-button',
- 'onclick' => 'submitCreditMemo()',
- ))
- );
- }
-
- if ($this->getCreditmemo()->canRefund()) {
- $this->setChild(
- 'submit_offline',
- $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
- 'label' => Mage::helper('sales')->__('Refund Offline'),
- 'class' => 'save submit-button',
- 'onclick' => 'submitCreditMemoOffline()',
+ 'onclick' => 'disableElements(\'submit-button\');submitCreditMemo()',
))
);
}
+ $this->setChild(
+ 'submit_offline',
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
+ 'label' => Mage::helper('sales')->__('Refund Offline'),
+ 'class' => 'save submit-button',
+ 'onclick' => 'disableElements(\'submit-button\');submitCreditMemoOffline()',
+ ))
+ );
}
else {
$this->setChild(
'submit_button',
$this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
- 'label' => Mage::helper('sales')->__('Refund'),
+ 'label' => Mage::helper('sales')->__('Refund Offline'),
'class' => 'save submit-button',
- 'onclick' => 'editForm.submit()',
+ 'onclick' => 'disableElements(\'submit-button\');editForm.submit()',
))
);
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php
index fbe59d7d97..4e287c00d8 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php
@@ -70,7 +70,7 @@ protected function _beforeToHtml()
$this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
'label' => Mage::helper('sales')->__('%s', $_submitLabel),
'class' => 'save submit-button' . $_submitButtonClass,
- 'onclick' => '$(\'edit_form\').submit()',
+ 'onclick' => 'disableElements(\'submit-button\');$(\'edit_form\').submit()',
'disabled' => $this->_disableSubmitButton
))
);
@@ -184,12 +184,31 @@ public function canEditQty()
return true;
}
+ /**
+ * Check if capture operation is allowed in ACL
+ * @return bool
+ */
+ public function isCaptureAllowed()
+ {
+ return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/capture');
+ }
+
+ /**
+ * Check if invoice can be captured
+ * @return bool
+ */
public function canCapture()
{
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/capture')) {
- return $this->getInvoice()->canCapture();
- }
- return false;
+ return $this->getInvoice()->canCapture();
+ }
+
+ /**
+ * Check if gateway is associated with invoice order
+ * @return bool
+ */
+ public function isGatewayUsed()
+ {
+ return $this->getInvoice()->getOrder()->getPayment()->getMethodInstance()->isGateway();
}
public function canSendInvoiceEmail()
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Payment.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Payment.php
index be9c7c8f0c..332d6983e2 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Payment.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Payment.php
@@ -48,9 +48,6 @@ protected function _beforeToHtml()
public function setPayment($payment)
{
$paymentInfoBlock = Mage::helper('payment')->getInfoBlock($payment);
- if ($payment->getMethod() == 'ccsave') {
- $paymentInfoBlock->setTemplate('payment/info/ccsave.phtml');
- }
$this->setChild('info', $paymentInfoBlock);
$this->setData('payment', $payment);
return $this;
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 6036a9b9b5..ab33987c4c 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
@@ -74,7 +74,7 @@ protected function _beforeToHtml()
$this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
'label' => Mage::helper('sales')->__('Submit Shipment'),
'class' => 'save submit-button',
- 'onclick' => '$(\'edit_form\').submit()',
+ 'onclick' => 'disableElements(\'submit-button\');$(\'edit_form\').submit()',
))
);
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 222c28a96e..4530939f6c 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,9 +199,6 @@ 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 956b42329a..98521ca3bf 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,9 +93,6 @@ 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/Convert/Gui/Edit/Tab/View.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php
index 8b5dd6f4dc..0b8dc38128 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php
@@ -40,13 +40,16 @@ public function initForm()
$model = Mage::registry('current_convert_profile');
- $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('View Actions XML')));
+ $fieldset = $form->addFieldset('base_fieldset', array(
+ 'legend'=>Mage::helper('adminhtml')->__('View Actions XML'),
+ 'class'=>'fieldset-wide'
+ ));
$fieldset->addField('actions_xml', 'textarea', array(
'name' => 'actions_xml_view',
'label' => Mage::helper('adminhtml')->__('Actions XML'),
'title' => Mage::helper('adminhtml')->__('Actions XML'),
- 'style' => 'width:500px; height:400px',
+ 'style' => 'height:30em',
'readonly' => 'readonly',
));
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php
index bf89dbf0ef..8957345c21 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php
@@ -40,7 +40,10 @@ public function initForm()
$model = Mage::registry('current_convert_profile');
- $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('General Information')));
+ $fieldset = $form->addFieldset('base_fieldset', array(
+ 'legend'=>Mage::helper('adminhtml')->__('General Information'),
+ 'class'=>'fieldset-wide'
+ ));
$fieldset->addField('name', 'text', array(
'name' => 'name',
@@ -53,7 +56,7 @@ public function initForm()
'name' => 'actions_xml',
'label' => Mage::helper('adminhtml')->__('Actions XML'),
'title' => Mage::helper('adminhtml')->__('Actions XML'),
- 'style' => 'width:500px; height:400px',
+ 'style' => 'height:30em',
'required' => true,
));
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php
index 28f9cff3c1..306d5ab121 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php
@@ -86,6 +86,7 @@ public function getImportedFiles()
$files[] = $entry;
}
}
+ sort($files);
$dir->close();
return $files;
}
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 13d650823c..d7908d73c5 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
@@ -128,7 +128,10 @@ protected function _toHtml()
if ($batchModel->getId()) {
if ($batchModel->getAdapter()) {
$numberOfRecords = $profile->getData('gui_data/import/number_of_records');
- $numberOfRecords = $numberOfRecords ? $numberOfRecords : 1;
+ if (!$numberOfRecords) {
+ $batchParams = $batchModel->getParams();
+ $numberOfRecords = isset($batchParams['number_of_records']) ? $batchParams['number_of_records'] : 1;
+ }
$showFinished = false;
$batchImportModel = $batchModel->getBatchImportModel();
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php
index b77bcb2262..392a3224be 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php
@@ -56,7 +56,10 @@ protected function _prepareForm()
'method' => 'post'
));
- $fieldset = $form->addFieldset('base', array());
+ $fieldset = $form->addFieldset('base', array(
+ 'legend'=>Mage::helper('adminhtml')->__('Variable'),
+ 'class'=>'fieldset-wide'
+ ));
$fieldset->addField('code', 'text', array(
'name' => 'code',
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Grid.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Grid.php
index b1d6fd4a4d..f588bd3610 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Grid.php
@@ -68,19 +68,17 @@ protected function _prepareColumns()
{
$this->addColumn('variable_id', array(
'header' => Mage::helper('adminhtml')->__('Variable ID'),
- 'align' => 'left',
+ 'width' => '1',
'index' => 'variable_id',
));
$this->addColumn('code', array(
'header' => Mage::helper('adminhtml')->__('Variable Code'),
- 'align' => 'center',
'index' => 'code',
));
$this->addColumn('name', array(
'header' => Mage::helper('adminhtml')->__('Name'),
- 'align' => 'left',
'index' => 'name',
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Form.php b/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Form.php
index 1b784247a6..8629746f12 100644
--- a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Form.php
+++ b/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Form.php
@@ -159,7 +159,8 @@ protected function _prepareForm()
array(
'name' => 'zip_from',
'label' => Mage::helper('tax')->__('Range from'),
- 'value' => $rateObject->getZipFrom()
+ 'value' => $rateObject->getZipFrom(),
+ 'required' => true
)
);
@@ -167,7 +168,8 @@ protected function _prepareForm()
array(
'name' => 'zip_to',
'label' => Mage::helper('tax')->__('Range to'),
- 'value' => $rateObject->getZipTo()
+ 'value' => $rateObject->getZipTo(),
+ 'required' => true
)
);
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
index 840abec539..e879e992e6 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
@@ -855,7 +855,7 @@ protected function _getExportTotals()
$row = array();
foreach ($this->_columns as $column) {
if (!$column->getIsSystem()) {
- $row[] = $column->getRowFieldExport($totals);
+ $row[] = ($column->hasTotalsLabel()) ? $column->getTotalsLabel() : $column->getRowFieldExport($totals);
}
}
return $row;
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
index 7345984f8e..608c65617d 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
@@ -82,6 +82,9 @@ public function getCssClass()
if ($this->hasData('column_css_class')) {
$this->_cssClass .= ' '. $this->getData('column_css_class');
}
+ if ($this->getEditable()) {
+ $this->_cssClass .= ' editable';
+ }
}
return $this->_cssClass;
@@ -110,9 +113,6 @@ public function getHeaderHtmlProperty()
if ($class = $this->getHeaderCssClass()) {
$str.= ' class="'.$class.'"';
}
- if ($this->getEditable()) {
- $str.= ' colspan="2"';
- }
return $str;
}
@@ -126,6 +126,9 @@ public function getHeaderHtmlProperty()
public function getRowField(Varien_Object $row)
{
$renderedValue = $this->getRenderer()->render($row);
+ if ($this->getHtmlDecorators()) {
+ $renderedValue = $this->_applyDecorators($renderedValue, $this->getHtmlDecorators());
+ }
/*
* if column has determined callback for framing call
@@ -167,6 +170,34 @@ public function getRowFieldExport(Varien_Object $row)
return $renderedValue;
}
+ /**
+ * Decorate rendered cell value
+ *
+ * @param string $value
+ * @param array|string $decorators
+ * @return string
+ */
+ protected function &_applyDecorators($value, $decorators)
+ {
+ if (!is_array($decorators)) {
+ if (is_string($decorators)) {
+ $decorators = explode(' ', $decorators);
+ }
+ }
+ if ((!is_array($decorators)) || empty($decorators)) {
+ return $value;
+ }
+ switch (array_shift($decorators)) {
+ case 'nobr':
+ $value = '' . $value . ' ';
+ break;
+ }
+ if (!empty($decorators)) {
+ return $this->_applyDecorators($value, $decorators);
+ }
+ return $value;
+ }
+
public function setRenderer($renderer)
{
$this->_renderer = $renderer;
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php
index e82455fef2..36dae00f53 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php
@@ -52,7 +52,7 @@ public function getHtml()
$value = $this->getValue();
foreach ($this->_getOptions() as $option){
$selected = ( ($option['value'] == $value && (!is_null($value))) ? ' selected="selected"' : '' );
- $html.= ''.$option['label'].' ';
+ $html.= ''.$this->htmlEscape($option['label']).' ';
}
$html.='';
return $html;
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php
index da8be1b477..73fe5ed14d 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php
@@ -58,8 +58,9 @@ public function render(Varien_Object $row)
{
if ($this->getColumn()->getEditable()) {
$value = $this->_getValue($row);
- return $value . ($this->getColumn()->getEditOnly() ? '' : ($value != '' ? '' : ' ') . '')
- . $this->_getInputValueElement($row);
+ return $value
+ . ($this->getColumn()->getEditOnly() ? '' : ($value != '' ? '' : ' '))
+ . $this->_getInputValueElement($row);
}
return $this->_getValue($row);
}
@@ -78,7 +79,12 @@ public function renderExport(Varien_Object $row)
protected function _getValue(Varien_Object $row)
{
if ($getter = $this->getColumn()->getGetter()) {
- return $row->$getter();
+ if (is_string($getter)) {
+ return $row->$getter();
+ } elseif (is_callable($getter)) {
+ return call_user_func($getter, $row);
+ }
+ return '';
}
return $row->getData($this->getColumn()->getIndex());
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php
index 45285d0c4d..9632353b20 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php
@@ -57,9 +57,10 @@ public function render(Varien_Object $row)
}
$data = floatval($data) * $this->_getRate($row);
+ $sign = (bool)(int)$this->getColumn()->getShowNumberSign() && ($data > 0) ? '+' : '';
$data = sprintf("%f", $data);
- $data =Mage::app()->getLocale()->currency($currency_code)->toCurrency($data);
- return $data;
+ $data = Mage::app()->getLocale()->currency($currency_code)->toCurrency($data);
+ return $sign . $data;
}
return $this->getColumn()->getDefault();
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php
index a6e11b8f10..161483e849 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php
@@ -71,7 +71,7 @@ protected function _getFormat()
*/
public function render(Varien_Object $row)
{
- if ($data = $row->getData($this->getColumn()->getIndex())) {
+ if ($data = $this->_getValue($row)) {
$format = $this->_getFormat();
try {
$data = Mage::app()->getLocale()->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
@@ -81,7 +81,6 @@ public function render(Varien_Object $row)
$data = Mage::app()->getLocale()->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
}
return $data;
-
}
return $this->getColumn()->getDefault();
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php
index 9addf0d8c6..047f0304ae 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Number.php
@@ -41,7 +41,11 @@ protected function _getValue(Varien_Object $row)
$data = parent::_getValue($row);
if (!is_null($data)) {
$value = $data * 1;
- return $value ? $value: '0'; // fixed for showing zero in grid
+ $sign = (bool)(int)$this->getColumn()->getShowNumberSign() && ($value > 0) ? '+' : '';
+ if ($sign) {
+ $value = $sign . $value;
+ }
+ return $value ? $value : '0'; // fixed for showing zero in grid
}
return $this->getColumn()->getDefault();
}
diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php
index 1d758b383f..c64dacad77 100644
--- a/app/code/core/Mage/Adminhtml/Controller/Action.php
+++ b/app/code/core/Mage/Adminhtml/Controller/Action.php
@@ -434,32 +434,4 @@ protected function _validateSecretKey()
}
return true;
}
-
- /**
- * Convert dates in array from localized to internal format
- *
- * @param array $array
- * @param array $dateFields
- * @return array
- */
- protected function _filterDates($array, $dateFields)
- {
- if (empty($dateFields)) {
- return $array;
- }
- $filterInput = new Zend_Filter_LocalizedToNormalized(array(
- 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
- ));
- $filterInternal = new Zend_Filter_NormalizedToLocalized(array(
- 'date_format' => Varien_Date::DATE_INTERNAL_FORMAT
- ));
-
- foreach ($dateFields as $dateField) {
- if (array_key_exists($dateField, $array) && !empty($dateField)) {
- $array[$dateField] = $filterInput->filter($array[$dateField]);
- $array[$dateField] = $filterInternal->filter($array[$dateField]);
- }
- }
- return $array;
- }
}
diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
index a864f7e553..d735933e81 100644
--- a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
+++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
@@ -70,6 +70,8 @@ public function gridAction()
*/
public function indexAction()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Invoices'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/sales_invoice'))
->renderLayout();
diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
index 4fa6728bf9..ca76843fe9 100644
--- a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
+++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
@@ -59,6 +59,8 @@ protected function _initAction()
*/
public function indexAction()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Shipments'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/sales_shipment'))
->renderLayout();
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 31390dfce5..05a8be3332 100644
--- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php
+++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php
@@ -479,11 +479,9 @@ public function moveQuoteItem($item, $moveTo, $qty)
public function applySidebarData($data)
{
- if (isset($data['add'])) {
- foreach ($data['add'] as $productId => $qty) {
- $this->addProduct($productId, $qty);
- }
- }
+ // skip item duplicates based on info_buyRequest option
+ $infoBuyRequests = array();
+
if (isset($data['reorder'])) {
foreach ($data['reorder'] as $orderItemId=>$value) {
$orderItem = Mage::getModel('sales/order_item')->load($orderItemId);
@@ -491,16 +489,28 @@ public function applySidebarData($data)
if (is_string($item)) {
Mage::throwException($item);
}
+ $infobuyRequest = $item->getOptionByCode('info_buyRequest');
+ if ($infobuyRequest !== null) {
+ $infoBuyRequests[] = $infobuyRequest->getValue();
+ }
}
}
if (isset($data['cartItem'])) {
foreach ($data['cartItem'] as $itemId => $qty) {
if ($item = $this->getCustomerCart()->getItemById($itemId)) {
- $this->moveQuoteItem($item, 'order', $qty);
+ $infobuyRequest = $item->getOptionByCode('info_buyRequest');
+ if ($infobuyRequest === null || !in_array($infobuyRequest->getValue(), $infoBuyRequests)) {
+ $this->moveQuoteItem($item, 'order', $qty);
+ }
// $this->removeItem($itemId, 'cart');
}
}
}
+ if (isset($data['add'])) {
+ foreach ($data['add'] as $productId => $qty) {
+ $this->addProduct($productId, $qty);
+ }
+ }
if (isset($data['remove'])) {
foreach ($data['remove'] as $itemId => $from) {
$this->removeItem($itemId, $from);
@@ -921,12 +931,11 @@ public function resetShippingMethod()
}
/**
- * Collect shipping dates for wuote shipping address
+ * Collect shipping data for quote shipping address
*/
public function collectShippingRates()
{
$this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
- $this->getQuote()->getShippingAddress()->collectShippingRates();
$this->collectRates();
return $this;
}
@@ -997,6 +1006,11 @@ public function importPostData($data)
if (isset($data['comment'])) {
$this->getQuote()->addData($data['comment']);
+ if (empty($data['comment']['customer_note_notify'])) {
+ $this->getQuote()->setCustomerNoteNotify(false);
+ } else {
+ $this->getQuote()->setCustomerNoteNotify(true);
+ }
}
if (isset($data['billing_address'])) {
@@ -1018,7 +1032,6 @@ public function importPostData($data)
if (isset($data['coupon']['code'])) {
$this->applyCoupon($data['coupon']['code']);
}
-
return $this;
}
@@ -1032,37 +1045,56 @@ public function _prepareCustomer()
return $this;
}
- $customer = $this->getSession()->getCustomer();
- $store = $this->getSession()->getStore();
+ $customer = $this->getSession()->getCustomer();
+ $store = $this->getSession()->getStore();
+ $billingAddress = null;
+ $shippingAddress = null;
+
+ $customer->addData($this->_getData('account'));
if ($customer->getId()) {
- if ($customer->isInStore($store)) {
- $customer->addData($this->getData('account'));
- } else {
- $customer->setId(null);
- $customer->setStore($this->getSession()->getStore());
- $customer->addData($this->getData('account'));
+ if (!$customer->isInStore($store)) {
+ $customer->setId(null)
+ ->setStore($store)
+ ->setDefaultBilling(null)
+ ->setDefaultShipping(null)
+ ->setPassword($customer->generatePassword());
}
if ($this->getBillingAddress()->getSaveInAddressBook()) {
$billingAddress = $this->getBillingAddress()->exportCustomerAddress();
- if ($this->getBillingAddress()->getCustomerAddressId()) {
- $billingAddress->setId($this->getBillingAddress()->getCustomerAddressId());
+ $customerAddressId = $this->getBillingAddress()->getCustomerAddressId();
+ if ($customerAddressId && $customer->getId()) {
+ $customer->getAddressItemById($customerAddressId)->addData($billingAddress->getData());
+ } else {
+ $customer->addAddress($billingAddress);
}
- $customer->addAddress($billingAddress);
}
- if ($this->getShippingAddress()->getSaveInAddressBook()) {
+ if (!$this->getQuote()->isVirtual() && $this->getShippingAddress()->getSaveInAddressBook()) {
$shippingAddress = $this->getShippingAddress()->exportCustomerAddress();
- if ($this->getShippingAddress()->getCustomerAddressId()) {
- $shippingAddress->setId($this->getShippingAddress()->getCustomerAddressId());
+ $customerAddressId = $this->getShippingAddress()->getCustomerAddressId();
+ if ($customerAddressId && $customer->getId()) {
+ $customer->getAddressItemById($customerAddressId)->addData($shippingAddress->getData());
+ } elseif ($billingAddress !== null && $this->getBillingAddress()->getCustomerAddressId() == $customerAddressId) {
+ $billingAddress->setIsDefaultShipping(true);
+ } else {
+ $customer->addAddress($shippingAddress);
+ }
+ }
+
+ if (is_null($customer->getDefaultBilling()) && $billingAddress) {
+ $billingAddress->setIsDefaultBilling(true);
+ }
+ if (is_null($customer->getDefaultShipping())) {
+ if ($this->getShippingAddress()->getSameAsBilling() && $billingAddress) {
+ $billingAddress->setIsDefaultShipping(true);
+ } elseif ($shippingAddress) {
+ $shippingAddress->setIsDefaultShipping(true);
}
- $customer->addAddress($shippingAddress);
}
} else {
$customer->addData($this->getBillingAddress()->exportCustomerAddress()->getData())
- ->addData($this->getData('account'))
->setPassword($customer->generatePassword())
- ->setWebsiteId($store->getWebsiteId())
- ->setStoreId($store->getId())
+ ->setStore($store)
->setEmail($this->_getNewCustomerEmail($customer));
$customerBilling = $this->getBillingAddress()->exportCustomerAddress();
@@ -1070,16 +1102,26 @@ public function _prepareCustomer()
$customer->addAddress($customerBilling);
$shipping = $this->getShippingAddress();
- if (!$shipping->getSameAsBilling()) {
+ if (!$this->getQuote()->isVirtual() && !$shipping->getSameAsBilling()) {
$customerShipping = $shipping->exportCustomerAddress();
$customerShipping->setIsDefaultShipping(true);
$customer->addAddress($customerShipping);
+ } else {
+ $customerBilling->setIsDefaultShipping(true);
}
}
$quote->setCustomer($customer);
if (!$customer->getId()) {
$quote->setCustomerId(true);
}
+
+ // we should not change account data for existing customer, so restore it
+ if ($customer->getId() && is_array($this->_getData('account'))) {
+ foreach($this->_getData('account') as $key => $value) {
+ $customer->setData($key, $customer->getOrigData($key));
+ }
+ }
+
return $this;
}
@@ -1116,6 +1158,10 @@ public function createOrder()
$this->_prepareCustomer();
$this->_prepareQuoteItems();
+ if (! $quote->getCustomer()->getId() || ! $quote->getCustomer()->isInStore($this->getSession()->getStore())) {
+ $quote->getCustomer()->sendNewAccountEmail('registered', '', $quote->getStoreId());
+ }
+
$service = Mage::getModel('sales/service_quote', $quote);
if ($this->getSession()->getOrder()->getId()) {
$oldOrder = $this->getSession()->getOrder();
@@ -1142,10 +1188,6 @@ public function createOrder()
$order->save();
}
- if ($quote->getCustomerId()) {
- $quote->getCustomer()->sendNewAccountEmail();
- }
-
if ($this->getSendConfirmation()) {
$order->sendNewOrderEmail();
}
diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php
index 360d65ff97..355f9935d7 100644
--- a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php
+++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php
@@ -50,4 +50,29 @@ protected function _beforeSave()
$this->setValue($value);
return $this;
}
+
+ /**
+ * Clean compiled JS/CSS when updating base url configuration settings
+ */
+ protected function _afterSave()
+ {
+ $unsecureUrl = $this->getData('groups/unsecure/fields/base_url/value');
+ $secureUrl = $this->getData('groups/secure/fields/base_url/value');
+
+ $oldUnsecureUrl = Mage::getConfig()->getNode(
+ Mage_Core_Model_Url::XML_PATH_UNSECURE_URL,
+ $this->getScope(),
+ $this->getScopeId()
+ );
+
+ $oldSecureUrl = Mage::getConfig()->getNode(
+ Mage_Core_Model_Url::XML_PATH_SECURE_URL,
+ $this->getScope(),
+ $this->getScopeId()
+ );
+
+ if ($unsecureUrl != $oldUnsecureUrl || $secureUrl != $oldSecureUrl) {
+ Mage::getModel('core/design_package')->cleanMergedJsCss();
+ }
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php
index ec3f5046c3..27a79196df 100644
--- a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php
+++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php
@@ -48,11 +48,13 @@ public function toOptionArray()
protected function _createOptions(&$optionArray, $menuNode)
{
+ $nonEscapableNbspChar = html_entity_decode(' ', ENT_NOQUOTES, 'UTF-8');
+
foreach ($menuNode as $menu) {
if (!empty($menu['url'])) {
$optionArray[] = array(
- 'label' => str_repeat(' ', ($menu['level'] * 4)) . $menu['label'],
+ 'label' => str_repeat($nonEscapableNbspChar, ($menu['level'] * 4)) . $menu['label'],
'value' => $menu['path'],
);
@@ -65,7 +67,7 @@ protected function _createOptions(&$optionArray, $menuNode)
$this->_createOptions($children, $menu['children']);
$optionArray[] = array(
- 'label' => str_repeat(' ', ($menu['level'] * 4)) . $menu['label'],
+ 'label' => str_repeat($nonEscapableNbspChar, ($menu['level'] * 4)) . $menu['label'],
'value' => $children,
);
}
diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Shipping/Allowedmethods.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Shipping/Allowedmethods.php
index f5e444fbe4..64c1941cf2 100644
--- a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Shipping/Allowedmethods.php
+++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Shipping/Allowedmethods.php
@@ -24,6 +24,9 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+/**
+ * @deprecated after 1.4.0.0-rc1
+ */
class Mage_Adminhtml_Model_System_Config_Source_Shipping_Allowedmethods
extends Mage_Adminhtml_Model_System_Config_Source_Shipping_Allmethods
{
diff --git a/app/code/core/Mage/Adminhtml/Model/System/Store.php b/app/code/core/Mage/Adminhtml/Model/System/Store.php
index 63110167bc..5f4969efe4 100644
--- a/app/code/core/Mage/Adminhtml/Model/System/Store.php
+++ b/app/code/core/Mage/Adminhtml/Model/System/Store.php
@@ -136,6 +136,8 @@ public function getStoreValuesForForm($empty = false, $all = false)
);
}
+ $nonEscapableNbspChar = html_entity_decode(' ', ENT_NOQUOTES, 'UTF-8');
+
foreach ($this->_websiteCollection as $website) {
$websiteShow = false;
foreach ($this->_groupCollection as $group) {
@@ -159,13 +161,13 @@ public function getStoreValuesForForm($empty = false, $all = false)
$values = array();
}
$values[] = array(
- 'label' => ' ' . $store->getName(),
+ 'label' => str_repeat($nonEscapableNbspChar, 4) . $store->getName(),
'value' => $store->getId()
);
}
if ($groupShow) {
$options[] = array(
- 'label' => ' ' . $group->getName(),
+ 'label' => str_repeat($nonEscapableNbspChar, 4) . $group->getName(),
'value' => $values
);
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php
index 39b0869efb..ff5bbc6db5 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php
@@ -37,7 +37,7 @@ class Mage_Adminhtml_Api_RoleController extends Mage_Adminhtml_Controller_Action
protected function _initAction()
{
$this->loadLayout();
- $this->_setActiveMenu('api/roles');
+ $this->_setActiveMenu('system/services/roles');
$this->_addBreadcrumb($this->__('Web services'), $this->__('Web services'));
$this->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions'));
$this->_addBreadcrumb($this->__('Roles'), $this->__('Roles'));
@@ -46,6 +46,10 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Web Services'))
+ ->_title($this->__('Roles'));
+
$this->_initAction();
$this->_addContent($this->getLayout()->createBlock('adminhtml/api_roles'));
@@ -64,15 +68,21 @@ public function roleGridAction()
public function editRoleAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Web Services'))
+ ->_title($this->__('Roles'));
+
$this->_initAction();
$roleId = $this->getRequest()->getParam('rid');
if( intval($roleId) > 0 ) {
$breadCrumb = $this->__('Edit Role');
$breadCrumbTitle = $this->__('Edit Role');
+ $this->_title($this->__('Edit Role'));
} else {
$breadCrumb = $this->__('Add new Role');
$breadCrumbTitle = $this->__('Add new Role');
+ $this->_title($this->__('New Role'));
}
$this->_addBreadcrumb($breadCrumb, $breadCrumbTitle);
@@ -122,6 +132,10 @@ public function saveRoleAction()
parse_str($roleUsers, $roleUsers);
$roleUsers = array_keys($roleUsers);
+ $oldRoleUsers = $this->getRequest()->getParam('in_role_user_old');
+ parse_str($oldRoleUsers, $oldRoleUsers);
+ $oldRoleUsers = array_keys($oldRoleUsers);
+
$isAll = $this->getRequest()->getParam('all');
if ($isAll) {
$resource = array("all");
@@ -139,17 +153,14 @@ public function saveRoleAction()
->setResources($resource)
->saveRel();
- $oldRoleUsers = Mage::getModel("api/roles")->setId($role->getId())->getRoleUsers($role);
- if ( sizeof($oldRoleUsers) > 0 ) {
- foreach($oldRoleUsers as $oUid) {
- $this->_deleteUserFromRole($oUid, $role->getId());
- }
+ foreach($oldRoleUsers as $oUid) {
+ $this->_deleteUserFromRole($oUid, $role->getId());
}
- if ( $roleUsers ) {
- foreach ($roleUsers as $nRuid) {
- $this->_addUserToRole($nRuid, $role->getId());
- }
+
+ foreach ($roleUsers as $nRuid) {
+ $this->_addUserToRole($nRuid, $role->getId());
}
+
$rid = $role->getId();
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Role successfully saved.'));
} catch (Exception $e) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php
index ebfa6a9485..3ee7ad4233 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php
@@ -29,7 +29,7 @@ class Mage_Adminhtml_Api_UserController extends Mage_Adminhtml_Controller_Action
protected function _initAction()
{
$this->loadLayout()
- ->_setActiveMenu('api/users')
+ ->_setActiveMenu('system/services/users')
->_addBreadcrumb($this->__('Web Services'), $this->__('Web Services'))
->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions'))
->_addBreadcrumb($this->__('Users'), $this->__('Users'))
@@ -39,6 +39,10 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Web Services'))
+ ->_title($this->__('Users'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/api_user'))
->renderLayout();
@@ -51,6 +55,10 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Web Services'))
+ ->_title($this->__('Users'));
+
$id = $this->getRequest()->getParam('user_id');
$model = Mage::getModel('api/user');
@@ -62,6 +70,9 @@ public function editAction()
return;
}
}
+
+ $this->_title($model->getId() ? $model->getName() : $this->__('New User'));
+
// Restore previously entered form data from session
$data = Mage::getSingleton('adminhtml/session')->getUserData(true);
if (!empty($data)) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/CacheController.php
index e8a2d4b5b4..764761af9a 100644
--- a/app/code/core/Mage/Adminhtml/controllers/CacheController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/CacheController.php
@@ -41,6 +41,8 @@ protected function _getSession()
*/
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Cache Management'));
+
$this->loadLayout()
->_setActiveMenu('system/cache')
->renderLayout();
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php
index 7f2abc74cf..1d31886fc1 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php
@@ -42,6 +42,10 @@ class Mage_Adminhtml_Catalog_CategoryController extends Mage_Adminhtml_Controlle
*/
protected function _initCategory($getRootInstead = false)
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Categories'))
+ ->_title($this->__('Manage Categories'));
+
$categoryId = (int) $this->getRequest()->getParam('id',false);
$storeId = (int) $this->getRequest()->getParam('store');
$category = Mage::getModel('catalog/category');
@@ -85,6 +89,7 @@ public function indexAction()
*/
public function addAction()
{
+ Mage::getSingleton('admin/session')->unsActiveTabId();
$this->_forward('edit');
}
@@ -133,6 +138,9 @@ public function editAction()
if (!($category = $this->_initCategory(true))) {
return;
}
+
+ $this->_title($categoryId ? $category->getName() : $this->__('New Category'));
+
/**
* Check if we have data in session (if duering category save was exceprion)
*/
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php
index 3842ddfc97..29cfa30fea 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php
@@ -142,7 +142,7 @@ public function saveAction()
));
$this->_getSession()->addNotice(
- $this->__('Please refresh "Catalog Rewrites" and "Layered Navigation Indices" in System -> Cache Management ', $this->getUrl('adminhtml/system_cache'))
+ $this->__('Please refresh "Catalog Url Rewrites" and "Product Attributes" in System -> Index Management ', $this->getUrl('adminhtml/process/list'))
);
}
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 b11c690ef7..1a289f350e 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
@@ -45,6 +45,10 @@ public function preDispatch()
protected function _initAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Attributes'))
+ ->_title($this->__('Manage Attributes'));
+
if($this->getRequest()->getParam('popup')) {
$this->loadLayout('popup');
} else {
@@ -100,11 +104,14 @@ public function editAction()
Mage::register('entity_attribute', $model);
- $this->_initAction()
- ->_addBreadcrumb($id ? Mage::helper('catalog')->__('Edit Product Attribute') : Mage::helper('catalog')->__('New Product Attribute'), $id ? Mage::helper('catalog')->__('Edit Product Attribute') : Mage::helper('catalog')->__('New Product Attribute'))
- ->_addContent($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit')->setData('action', $this->getUrl('*/catalog_product_attribute/save')))
- ->_addLeft($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit_tabs'))
- ->_addJs(
+ $this->_initAction();
+
+ $this->_title($id ? $model->getName() : $this->__('New Attribute'));
+
+ $this->_addBreadcrumb($id ? Mage::helper('catalog')->__('Edit Product Attribute') : Mage::helper('catalog')->__('New Product Attribute'), $id ? Mage::helper('catalog')->__('Edit Product Attribute') : Mage::helper('catalog')->__('New Product Attribute'))
+ ->_addContent($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit')->setData('action', $this->getUrl('*/catalog_product_attribute/save')))
+ ->_addLeft($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit_tabs'))
+ ->_addJs(
$this->getLayout()->createBlock('adminhtml/template')
->setIsPopup((bool)$this->getRequest()->getParam('popup'))
->setTemplate('catalog/product/attribute/js.phtml')
@@ -143,6 +150,12 @@ public function saveAction()
$model->load($id);
+ if (!$model->getId()) {
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('This Attribute no longer exists'));
+ $this->_redirect('*/*/');
+ return;
+ }
+
// entity type check
if ($model->getEntityTypeId() != $this->_entityTypeId) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('You cannot update this attribute'));
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
index 6f274b6393..9ff7b37e1c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
@@ -39,6 +39,7 @@ public function uploadAction()
try {
$uploader = new Varien_File_Uploader('image');
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
+ $uploader->addValidateCallback('catalog_product_image', Mage::helper('catalog/image'), 'validateUploadFile');
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$result = $uploader->save(
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
index 2bdd28e827..8b50d32a34 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
@@ -43,6 +43,12 @@ class Mage_Adminhtml_Catalog_Product_ReviewController extends Mage_Adminhtml_Con
public function indexAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Reviews and Ratings'))
+ ->_title($this->__('Customer Reviews'));
+
+ $this->_title($this->__('All Reviews'));
+
if ($this->getRequest()->getParam('ajax')) {
return $this->_forward('reviewGrid');
}
@@ -57,6 +63,12 @@ public function indexAction()
public function pendingAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Reviews and Ratings'))
+ ->_title($this->__('Customer Reviews'));
+
+ $this->_title($this->__('Pending Reviews'));
+
if ($this->getRequest()->getParam('ajax')) {
Mage::register('usePendingFilter', true);
return $this->_forward('reviewGrid');
@@ -73,6 +85,12 @@ public function pendingAction()
public function editAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Reviews and Ratings'))
+ ->_title($this->__('Customer Reviews'));
+
+ $this->_title($this->__('Edit Review'));
+
$this->loadLayout();
$this->_setActiveMenu('catalog/review');
@@ -83,6 +101,12 @@ public function editAction()
public function newAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Reviews and Ratings'))
+ ->_title($this->__('Customer Reviews'));
+
+ $this->_title($this->__('New Review'));
+
$this->loadLayout();
$this->_setActiveMenu('catalog/review');
@@ -128,7 +152,7 @@ public function saveAction()
$review->aggregate();
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('catalog')->__('Review was deleted successfully'));
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('catalog')->__('Review has been successfully saved'));
} catch (Exception $e){
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php
index 65ff069173..909ec2171d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php
@@ -36,6 +36,10 @@ class Mage_Adminhtml_Catalog_Product_SetController extends Mage_Adminhtml_Contro
{
public function indexAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Attributes'))
+ ->_title($this->__('Manage Attribute Sets'));
+
$this->_setTypeId();
$this->loadLayout();
@@ -52,6 +56,10 @@ public function indexAction()
public function editAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Attributes'))
+ ->_title($this->__('Manage Attribute Sets'));
+
$this->_setTypeId();
$attributeSet = Mage::getModel('eav/entity_attribute_set')
->load($this->getRequest()->getParam('id'));
@@ -61,6 +69,8 @@ public function editAction()
return;
}
+ $this->_title($attributeSet->getId() ? $attributeSet->getAttributeSetName() : $this->__('New Set'));
+
Mage::register('current_attribute_set', $attributeSet);
$this->loadLayout();
@@ -150,6 +160,11 @@ public function saveAction()
public function addAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Attributes'))
+ ->_title($this->__('Manage Attribute Sets'))
+ ->_title($this->__('New Set'));
+
$this->_setTypeId();
$this->loadLayout();
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
index cac44a7dae..e57c9df8fa 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
@@ -53,6 +53,9 @@ protected function _construct()
*/
protected function _initProduct()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Manage Products'));
+
$productId = (int) $this->getRequest()->getParam('id');
$product = Mage::getModel('catalog/product')
->setStoreId($this->getRequest()->getParam('store', 0));
@@ -159,6 +162,9 @@ protected function _outputBlocks()
*/
public function indexAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Manage Products'));
+
$this->loadLayout();
$this->_setActiveMenu('catalog/products');
$this->renderLayout();
@@ -171,6 +177,8 @@ public function newAction()
{
$product = $this->_initProduct();
+ $this->_title($this->__('New Product'));
+
Mage::dispatchEvent('catalog_product_new_action', array('product' => $product));
if ($this->getRequest()->getParam('popup')) {
@@ -199,7 +207,17 @@ public function newAction()
*/
public function editAction()
{
+ $productId = (int) $this->getRequest()->getParam('id');
$product = $this->_initProduct();
+
+ if ($productId && !$product->getId()) {
+ $this->_getSession()->addError(Mage::helper('catalog')->__('This Product no longer exists'));
+ $this->_redirect('*/*/');
+ return;
+ }
+
+ $this->_title(sprintf('#%s', $product->getName() ? $product->getName() : $product->getSku()));
+
Mage::dispatchEvent('catalog_product_edit_action', array('product' => $product));
$_additionalLayoutPart = '';
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php
index f6260bec24..af44197499 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php
@@ -38,6 +38,8 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('Catalog'))->_title($this->__('Search Terms'));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog'))
->_addContent($this->getLayout()->createBlock('adminhtml/catalog_search'))
@@ -51,6 +53,8 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('Catalog'))->_title($this->__('Search Terms'));
+
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('catalogsearch/query');
@@ -76,6 +80,8 @@ public function editAction()
$this->_initAction();
+ $this->_title($id ? $model->getQueryText() : $this->__('New Search'));
+
$this->getLayout()->getBlock('head')->setCanLoadRulesJs(true);
$this
diff --git a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
index 313a20a58d..925bcb7549 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
@@ -35,6 +35,8 @@ class Mage_Adminhtml_Checkout_AgreementController extends Mage_Adminhtml_Control
{
public function indexAction()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Terms and Conditions'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/checkout_agreement'))
->renderLayout();
@@ -48,6 +50,8 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Terms and Conditions'));
+
$id = $this->getRequest()->getParam('id');
$agreementModel = Mage::getModel('checkout/agreement');
$hlp = Mage::helper('checkout');
@@ -60,6 +64,8 @@ public function editAction()
}
}
+ $this->_title($agreementModel->getId() ? $agreementModel->getName() : $this->__('New Condition'));
+
$data = Mage::getSingleton('adminhtml/session')->getAgreementData(true);
if (!empty($data)) {
$agreementModel->setData($data);
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php
index fbfe81c5ae..ccf36c596b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php
@@ -55,6 +55,8 @@ protected function _initAction()
*/
public function indexAction()
{
+ $this->_title($this->__('CMS'))->_title($this->__('Static Blocks'));
+
$this->_initAction();
$this->renderLayout();
}
@@ -73,6 +75,8 @@ public function newAction()
*/
public function editAction()
{
+ $this->_title($this->__('CMS'))->_title($this->__('Static Blocks'));
+
// 1. Get ID and create model
$id = $this->getRequest()->getParam('block_id');
$model = Mage::getModel('cms/block');
@@ -87,6 +91,8 @@ public function editAction()
}
}
+ $this->_title($model->getId() ? $model->getTitle() : $this->__('New Block'));
+
// 3. Set entered data if was error when we do save
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (! empty($data)) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
index 465d3974e9..8faadfa848 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
@@ -56,6 +56,10 @@ protected function _initAction()
*/
public function indexAction()
{
+ $this->_title($this->__('CMS'))
+ ->_title($this->__('Pages'))
+ ->_title($this->__('Manage Content'));
+
$this->_initAction();
$this->renderLayout();
}
@@ -74,6 +78,10 @@ public function newAction()
*/
public function editAction()
{
+ $this->_title($this->__('CMS'))
+ ->_title($this->__('Pages'))
+ ->_title($this->__('Manage Content'));
+
// 1. Get ID and create model
$id = $this->getRequest()->getParam('page_id');
$model = Mage::getModel('cms/page');
@@ -88,6 +96,8 @@ public function editAction()
}
}
+ $this->_title($model->getId() ? $model->getTitle() : $this->__('New Page'));
+
// 3. Set entered data if was error when we do save
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (! empty($data)) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php
index 1c03e6f83c..5779680e5d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php
@@ -35,6 +35,8 @@ class Mage_Adminhtml_Customer_GroupController extends Mage_Adminhtml_Controller_
{
protected function _initGroup()
{
+ $this->_title($this->__('Customers'))->_title($this->__('Customer Groups'));
+
Mage::register('current_group', Mage::getModel('customer/group'));
$groupId = $this->getRequest()->getParam('id');
if (!is_null($groupId)) {
@@ -47,6 +49,8 @@ protected function _initGroup()
*/
public function indexAction()
{
+ $this->_title($this->__('Customers'))->_title($this->__('Customer Groups'));
+
$this->loadLayout();
$this->_setActiveMenu('customer/group');
$this->_addBreadcrumb(Mage::helper('customer')->__('Customers'), Mage::helper('customer')->__('Customers'));
@@ -65,12 +69,16 @@ public function newAction()
$this->_addBreadcrumb(Mage::helper('customer')->__('Customers'), Mage::helper('customer')->__('Customers'));
$this->_addBreadcrumb(Mage::helper('customer')->__('Customer Groups'), Mage::helper('customer')->__('Customer Groups'), $this->getUrl('*/customer_group'));
- if (!is_null(Mage::registry('current_group')->getId())) {
+ $currentGroup = Mage::registry('current_group');
+
+ if (!is_null($currentGroup->getId())) {
$this->_addBreadcrumb(Mage::helper('customer')->__('Edit Group'), Mage::helper('customer')->__('Edit Customer Groups'));
} else {
$this->_addBreadcrumb(Mage::helper('customer')->__('New Group'), Mage::helper('customer')->__('New Customer Groups'));
}
+ $this->_title($currentGroup->getId() ? $currentGroup->getCode() : $this->__('New Group'));
+
$this->getLayout()->getBlock('content')
->append($this->getLayout()->createBlock('adminhtml/customer_group_edit', 'group')
->setEditMode((bool)Mage::registry('current_group')->getId()));
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php
index 37e8277608..06919f12c2 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php
@@ -28,6 +28,8 @@ class Mage_Adminhtml_Customer_OnlineController extends Mage_Adminhtml_Controller
public function indexAction()
{
+ $this->_title($this->__('Customers'))->_title($this->__('Online Customers'));
+
if($this->getRequest()->getParam('ajax')) {
$this->_forward('grid');
return;
diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
index 50173792cc..ffe35e571b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
@@ -36,6 +36,8 @@ class Mage_Adminhtml_CustomerController extends Mage_Adminhtml_Controller_Action
protected function _initCustomer($idFieldName = 'id')
{
+ $this->_title($this->__('Customers'))->_title($this->__('Manage Customers'));
+
$customerId = (int) $this->getRequest()->getParam($idFieldName);
$customer = Mage::getModel('customer/customer');
@@ -52,6 +54,8 @@ protected function _initCustomer($idFieldName = 'id')
*/
public function indexAction()
{
+ $this->_title($this->__('Customers'))->_title($this->__('Manage Customers'));
+
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
@@ -109,6 +113,8 @@ public function editAction()
}
}
+ $this->_title($customer->getId() ? $customer->getName() : $this->__('New Customer'));
+
/**
* Set active menu item
*/
@@ -151,10 +157,11 @@ public function deleteAction()
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
+ $data = $this->_filterPostData($data);
$redirectBack = $this->getRequest()->getParam('back', false);
$this->_initCustomer('customer_id');
+ /** @var Mage_Customer_Model_Customer */
$customer = Mage::registry('current_customer');
-
// Prepare customer saving data
if (isset($data['account'])) {
if (isset($data['account']['email'])) {
@@ -162,25 +169,33 @@ public function saveAction()
}
$customer->addData($data['account']);
}
+ // unset template data
+ if (isset($data['address']['_template_'])) {
+ unset($data['address']['_template_']);
+ }
- if (isset($data['address'])) {
- // unset template data
- if (isset($data['address']['_template_'])) {
- unset($data['address']['_template_']);
- }
+ $modifiedAddresses = array();
+ if (! empty($data['address'])) {
foreach ($data['address'] as $index => $addressData) {
- $address = Mage::getModel('customer/address');
- $address->setData($addressData);
-
- if ($addressId = (int) $index) {
- $address->setId($addressId);
+ if (($address = $customer->getAddressItemById($index))) {
+ $addressId = $index;
+ $modifiedAddresses[] = $index;
+ } else {
+ $address = Mage::getModel('customer/address');
+ $addressId = null;
+ $customer->addAddress($address);
}
- /**
- * We need set post_index for detect default addresses
- */
- $address->setPostIndex($index);
- $customer->addAddress($address);
+
+ $address->setData($addressData)
+ ->setId($addressId)
+ ->setPostIndex($index); // We need set post_index for detect default addresses
+ }
+ }
+ // not modified customer addresses mark for delete
+ foreach ($customer->getAddressesCollection() as $customerAddress) {
+ if ($customerAddress->getId() && ! in_array($customerAddress->getId(), $modifiedAddresses)) {
+ $customerAddress->setData('_deleted', true);
}
}
@@ -581,4 +596,16 @@ protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
}
+
+ /**
+ * Filtering posted data. Converting localized data if needed
+ *
+ * @param array
+ * @return array
+ */
+ protected function _filterPostData($data)
+ {
+ $data['account'] = $this->_filterDates($data['account'], array('dob'));
+ return $data;
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php
index baf09b23d0..d211de0f91 100644
--- a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php
@@ -35,6 +35,8 @@ class Mage_Adminhtml_DashboardController extends Mage_Adminhtml_Controller_Actio
{
public function indexAction()
{
+ $this->_title($this->__('Dashboard'));
+
$this->loadLayout();
$this->_setActiveMenu('dashboard');
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Dashboard'), Mage::helper('adminhtml')->__('Dashboard'));
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php
index 138f1be4f8..1041cb49e2 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php
@@ -35,6 +35,8 @@ class Mage_Adminhtml_Newsletter_ProblemController extends Mage_Adminhtml_Control
{
public function indexAction()
{
+ $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter Problems'));
+
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
index 576e908772..65077f9238 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
@@ -38,6 +38,8 @@ class Mage_Adminhtml_Newsletter_QueueController extends Mage_Adminhtml_Controlle
*/
public function indexAction()
{
+ $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter Queue'));
+
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
@@ -152,16 +154,20 @@ public function sendingAction()
public function editAction()
{
+ $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter 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);
+ $queue = Mage::registry('current_queue')->load($id);
} elseif ($templateId) {
$template = Mage::getModel('newsletter/template')->load($templateId)->preprocess();
- Mage::registry('current_queue')->setTemplateId($template->getId());
+ $queue = Mage::registry('current_queue')->setTemplateId($template->getId());
}
+ $this->_title($this->__('Edit Queue'));
+
$this->loadLayout();
$this->_setActiveMenu('newsletter/queue');
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php
index 5258fda58b..dec15cab4f 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php
@@ -36,6 +36,8 @@ class Mage_Adminhtml_Newsletter_SubscriberController extends Mage_Adminhtml_Cont
public function indexAction()
{
+ $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter Subscribers'));
+
if ($this->getRequest()->getParam('ajax')) {
$this->_forward('grid');
return;
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
index 3517a1f5f0..315704f007 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
@@ -38,6 +38,8 @@ class Mage_Adminhtml_Newsletter_TemplateController extends Mage_Adminhtml_Contro
*/
public function indexAction ()
{
+ $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter Templates'));
+
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
@@ -76,6 +78,8 @@ public function newAction ()
*/
public function editAction ()
{
+ $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter Templates'));
+
$model = Mage::getModel('newsletter/template');
if ($id = $this->getRequest()->getParam('id')) {
$model->load($id);
@@ -95,6 +99,8 @@ public function editAction ()
$breadcrumbLabel = Mage::helper('newsletter')->__('Create Newsletter Template');
}
+ $this->_title($model->getId() ? $model->getTemplateCode() : $this->__('New Template'));
+
$this->_addBreadcrumb($breadcrumbLabel, $breadcrumbTitle);
// restore data
diff --git a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php
index d9b8907400..b224d6c688 100644
--- a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php
@@ -36,6 +36,8 @@ class Mage_Adminhtml_NotificationController extends Mage_Adminhtml_Controller_Ac
{
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Notifications'));
+
$this->loadLayout()
->_setActiveMenu('system/notification')
->_addBreadcrumb(Mage::helper('adminnotification')->__('Messages Inbox'), Mage::helper('adminhtml')->__('Messages Inbox'))
diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
index 53b645bf7a..a928e20c07 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
@@ -34,6 +34,11 @@
class Mage_Adminhtml_Permissions_RoleController extends Mage_Adminhtml_Controller_Action
{
+ /**
+ * Preparing layout for output
+ *
+ * @return Mage_Adminhtml_Permissions_RoleController
+ */
protected function _initAction()
{
$this->loadLayout();
@@ -44,25 +49,56 @@ protected function _initAction()
return $this;
}
+ /**
+ * Initialize role model by passed parameter in request
+ *
+ * @return Mage_Admin_Model_Roles
+ */
protected function _initRole($requestVariable = 'rid')
{
- Mage::register('current_role', Mage::getModel('admin/roles')->load($this->getRequest()->getParam($requestVariable)));
+ $this->_title($this->__('System'))
+ ->_title($this->__('Permissions'))
+ ->_title($this->__('Roles'));
+
+ $role = Mage::getModel('admin/roles')->load($this->getRequest()->getParam($requestVariable));
+ // preventing edit of relation role
+ if ($role->getId() && $role->getRoleType() != 'G') {
+ $role->unsetData($role->getIdFieldName());
+ }
+
+ Mage::register('current_role', $role);
return Mage::registry('current_role');
}
+ /**
+ * Show grid with roles existing in systems
+ *
+ */
public function indexAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Permissions'))
+ ->_title($this->__('Roles'));
+
$this->_initAction();
$this->renderLayout();
}
+ /**
+ * Action for ajax request from grid
+ *
+ */
public function roleGridAction()
{
$this->loadLayout();
$this->getResponse()->setBody($this->getLayout()->getBlock('adminhtml.permission.role.grid')->toHtml());
}
+ /**
+ * Edit role action
+ *
+ */
public function editRoleAction()
{
$role = $this->_initRole();
@@ -75,6 +111,9 @@ public function editRoleAction()
$breadCrumb = $this->__('Add new Role');
$breadCrumbTitle = $this->__('Add new Role');
}
+
+ $this->_title($role->getId() ? $role->getRoleName() : $this->__('New Role'));
+
$this->_addBreadcrumb($breadCrumb, $breadCrumbTitle);
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
@@ -89,6 +128,10 @@ public function editRoleAction()
$this->renderLayout();
}
+ /**
+ * Remove role action
+ *
+ */
public function deleteAction()
{
$rid = $this->getRequest()->getParam('rid', false);
@@ -112,6 +155,10 @@ public function deleteAction()
$this->_redirect("*/*/");
}
+ /**
+ * Role form submit action to save or create new role
+ *
+ */
public function saveRoleAction()
{
$rid = $this->getRequest()->getParam('role_id', false);
@@ -120,6 +167,10 @@ public function saveRoleAction()
parse_str($roleUsers, $roleUsers);
$roleUsers = array_keys($roleUsers);
+ $oldRoleUsers = $this->getRequest()->getParam('in_role_user_old');
+ parse_str($oldRoleUsers, $oldRoleUsers);
+ $oldRoleUsers = array_keys($oldRoleUsers);
+
$isAll = $this->getRequest()->getParam('all');
if ($isAll)
$resource = array("all");
@@ -143,17 +194,14 @@ public function saveRoleAction()
->setResources($resource)
->saveRel();
- $oldRoleUsers = Mage::getModel("admin/roles")->setId($role->getId())->getRoleUsers($role);
- if ( sizeof($oldRoleUsers) > 0 ) {
- foreach($oldRoleUsers as $oUid) {
- $this->_deleteUserFromRole($oUid, $role->getId());
- }
+ foreach($oldRoleUsers as $oUid) {
+ $this->_deleteUserFromRole($oUid, $role->getId());
}
- if ( $roleUsers ) {
- foreach ($roleUsers as $nRuid) {
- $this->_addUserToRole($nRuid, $role->getId());
- }
+
+ foreach ($roleUsers as $nRuid) {
+ $this->_addUserToRole($nRuid, $role->getId());
}
+
$rid = $role->getId();
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Role successfully saved.'));
} catch (Mage_Core_Exception $e) {
@@ -167,11 +215,22 @@ public function saveRoleAction()
return;
}
+ /**
+ * Action for ajax request from assigned users grid
+ *
+ */
public function editrolegridAction()
{
$this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/permissions_role_grid_user')->toHtml());
}
+ /**
+ * Remove user from role
+ *
+ * @param int $userId
+ * @param int $roleId
+ * @return bool
+ */
protected function _deleteUserFromRole($userId, $roleId)
{
try {
@@ -186,6 +245,13 @@ protected function _deleteUserFromRole($userId, $roleId)
return true;
}
+ /**
+ * Assign user to role
+ *
+ * @param int $userId
+ * @param int $roleId
+ * @return bool
+ */
protected function _addUserToRole($userId, $roleId)
{
$user = Mage::getModel("admin/user")->load($userId);
@@ -199,6 +265,11 @@ protected function _addUserToRole($userId, $roleId)
}
}
+ /**
+ * Acl checking
+ *
+ * @return bool
+ */
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('system/acl/roles');
diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php
index 5ef953386a..aa3561163d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php
@@ -39,6 +39,10 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Permissions'))
+ ->_title($this->__('Users'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/permissions_user'))
->renderLayout();
@@ -51,6 +55,10 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Permissions'))
+ ->_title($this->__('Users'));
+
$id = $this->getRequest()->getParam('user_id');
$model = Mage::getModel('admin/user');
@@ -62,6 +70,9 @@ public function editAction()
return;
}
}
+
+ $this->_title($model->getId() ? $model->getName() : $this->__('New User'));
+
// Restore previously entered form data from session
$data = Mage::getSingleton('adminhtml/session')->getUserData(true);
if (!empty($data)) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/core/Mage/Adminhtml/controllers/PollController.php
index 5e3b4b9fd3..d163ae4aa5 100644
--- a/app/code/core/Mage/Adminhtml/controllers/PollController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/PollController.php
@@ -36,6 +36,8 @@ class Mage_Adminhtml_PollController extends Mage_Adminhtml_Controller_Action
public function indexAction()
{
+ $this->_title($this->__('CMS'))->_title($this->__('Polls'));
+
$this->loadLayout();
$this->_setActiveMenu('cms/poll');
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Poll Manager'), Mage::helper('adminhtml')->__('Poll Manager'));
@@ -46,10 +48,13 @@ public function indexAction()
public function editAction()
{
+ $this->_title($this->__('CMS'))->_title($this->__('Polls'));
+
$pollId = $this->getRequest()->getParam('id');
$pollModel = Mage::getModel('poll/poll')->load($pollId);
if ($pollModel->getId() || $pollId == 0) {
+ $this->_title($pollModel->getId() ? $pollModel->getPollTitle() : $this->__('New Poll'));
Mage::register('poll_data', $pollModel);
diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
index f32c21594f..66bde880f5 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
@@ -37,6 +37,8 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('Promotions'))->_title($this->__('Catalog Price Rules'));
+
if (Mage::app()->loadCache('catalog_rules_dirty')) {
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('catalogrule')->__('There are rules that have been changed but not applied. Please, click Apply Rules in order to see immediate effect in catalog.'));
}
@@ -53,6 +55,8 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('Promotions'))->_title($this->__('Catalog Price Rules'));
+
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('catalogrule/rule');
@@ -65,6 +69,8 @@ public function editAction()
}
}
+ $this->_title($model->getRuleId() ? $model->getName() : $this->__('New Rule'));
+
// set entered data if was error when we do save
$data = Mage::getSingleton('adminhtml/session')->getPageData(true);
if (!empty($data)) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
index f63622f566..95a53be802 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
@@ -29,6 +29,8 @@ class Mage_Adminhtml_Promo_QuoteController extends Mage_Adminhtml_Controller_Act
{
protected function _initRule()
{
+ $this->_title($this->__('Promotions'))->_title($this->__('Shopping Cart Price Rules'));
+
Mage::register('current_promo_quote_rule', Mage::getModel('salesrule/rule'));
if ($id = (int) $this->getRequest()->getParam('id')) {
Mage::registry('current_promo_quote_rule')
@@ -47,6 +49,8 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('Promotions'))->_title($this->__('Shopping Cart Price Rules'));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('salesrule')->__('Catalog'), Mage::helper('salesrule')->__('Catalog'))
->renderLayout();
@@ -71,6 +75,8 @@ public function editAction()
}
}
+ $this->_title($model->getRuleId() ? $model->getName() : $this->__('New Rule'));
+
// set entered data if was error when we do save
$data = Mage::getSingleton('adminhtml/session')->getPageData(true);
if (!empty($data)) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/RatingController.php b/app/code/core/Mage/Adminhtml/controllers/RatingController.php
index 550df66f08..10accf8515 100644
--- a/app/code/core/Mage/Adminhtml/controllers/RatingController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/RatingController.php
@@ -51,6 +51,13 @@ public function editAction()
$this->_initEnityId();
$this->loadLayout();
+ $ratingModel = Mage::getModel('rating/rating');
+ if ($this->getRequest()->getParam('id')) {
+ $ratingModel->load($this->getRequest()->getParam('id'));
+ }
+
+ $this->_title($ratingModel->getId() ? $ratingModel->getRatingCode() : $this->__('New Rating'));
+
$this->_setActiveMenu('catalog/ratings');
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Ratings'), Mage::helper('adminhtml')->__('Manage Ratings'));
@@ -135,6 +142,10 @@ public function deleteAction()
protected function _initEnityId()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Reviews and Ratings'))
+ ->_title($this->__('Manage Ratings'));
+
Mage::register('entityId', Mage::getModel('rating/rating_entity')->getIdByCode('product'));
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php
index 086bac51e9..bb8dd543c9 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php
@@ -48,6 +48,10 @@ public function _initAction()
public function accountsAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Customers'))
+ ->_title($this->__('New Accounts'));
+
$this->_initAction()
->_setActiveMenu('report/customer/accounts')
->_addBreadcrumb(Mage::helper('adminhtml')->__('New Accounts'), Mage::helper('adminhtml')->__('New Accounts'))
@@ -81,6 +85,10 @@ public function exportAccountsExcelAction()
public function ordersAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Customers'))
+ ->_title($this->__('Customers by Number of Orders'));
+
$this->_initAction()
->_setActiveMenu('report/customer/orders')
->_addBreadcrumb(Mage::helper('reports')->__('Customers by number of orders'),
@@ -115,6 +123,10 @@ public function exportOrdersExcelAction()
public function totalsAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Customers'))
+ ->_title($this->__('Customers By Orders Total'));
+
$this->_initAction()
->_setActiveMenu('report/customer/totals')
->_addBreadcrumb(Mage::helper('reports')->__('Customers by orders total'),
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php
index d2fcc40b6b..5000a162a9 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php
@@ -56,6 +56,10 @@ public function _initAction()
*/
public function orderedAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Products'))
+ ->_title($this->__('Bestsellers'));
+
$this->_initAction()
->_setActiveMenu('report/product/ordered')
->_addBreadcrumb(Mage::helper('reports')->__('Bestsellers'), Mage::helper('reports')->__('Bestsellers'))
@@ -95,6 +99,10 @@ public function exportOrderedExcelAction()
*/
public function soldAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Products'))
+ ->_title($this->__('Products Ordered'));
+
$this->_initAction()
->_setActiveMenu('report/product/sold')
->_addBreadcrumb(Mage::helper('reports')->__('Products Ordered'), Mage::helper('reports')->__('Products Ordered'))
@@ -136,6 +144,10 @@ public function exportSoldExcelAction()
*/
public function viewedAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Products'))
+ ->_title($this->__('Most Viewed'));
+
$this->_initAction()
->_setActiveMenu('report/product/viewed')
->_addBreadcrumb(Mage::helper('reports')->__('Most viewed'), Mage::helper('reports')->__('Most viewed'))
@@ -175,6 +187,10 @@ public function exportViewedExcelAction()
*/
public function lowstockAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Products'))
+ ->_title($this->__('Low Stock'));
+
$this->_initAction()
->_setActiveMenu('report/product/lowstock')
->_addBreadcrumb(Mage::helper('reports')->__('Low stock'), Mage::helper('reports')->__('Low stock'))
@@ -216,6 +232,10 @@ public function exportLowstockExcelAction()
*/
public function downloadsAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Products'))
+ ->_title($this->__('Downloads'));
+
$this->_initAction()
->_setActiveMenu('report/product/downloads')
->_addBreadcrumb(Mage::helper('reports')->__('Downloads'), Mage::helper('reports')->__('Downloads'))
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php
index 7e2aac77ff..1d16a3097b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php
@@ -47,6 +47,10 @@ public function _initAction()
public function customerAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Reviews'))
+ ->_title($this->__('Customer Reviews'));
+
$this->_initAction()
->_setActiveMenu('report/review/customer')
->_addBreadcrumb(Mage::helper('reports')->__('Customers Report'), Mage::helper('reports')->__('Customers Report'))
@@ -80,6 +84,10 @@ public function exportCustomerExcelAction()
public function productAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Reviews'))
+ ->_title($this->__('Product Reviews'));
+
$this->_initAction()
->_setActiveMenu('report/review/product')
->_addBreadcrumb(Mage::helper('reports')->__('Products Report'), Mage::helper('reports')->__('Products Report'))
@@ -113,6 +121,11 @@ public function exportProductExcelAction()
public function productDetailAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Reviews'))
+ ->_title($this->__('Product Reviews'))
+ ->_title($this->__('Details'));
+
$this->_initAction()
->_setActiveMenu('report/review/productDetail')
->_addBreadcrumb(Mage::helper('reports')->__('Products Report'), Mage::helper('reports')->__('Products Report'))
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php
index 1a4cf8f98e..a99a0846dc 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php
@@ -63,6 +63,7 @@ public function _initReportAction($blocks)
foreach ($blocks as $block) {
if ($block) {
+ $block->setPeriodType($params->getData('period_type'));
$block->setFilterData($params);
}
}
@@ -72,6 +73,8 @@ public function _initReportAction($blocks)
public function salesAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Sales'));
+
$this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_ORDER_FLAG_CODE, 'sales');
$this->_initAction()
@@ -122,13 +125,15 @@ protected function _showLastExecutionTime($flagCode, $refreshCode)
{
$flag = Mage::getModel('reports/flag')->setReportFlagCode($flagCode)->loadSelf();
$updatedAt = ($flag->hasData())
- ? Mage::app()->getLocale()->storeDate(0, $flag->getLastUpdate(), true)
+ ? Mage::app()->getLocale()->storeDate(
+ 0, new Zend_Date($flag->getLastUpdate(), Varien_Date::DATETIME_INTERNAL_FORMAT), true
+ )
: 'undefined';
$refreshStatsLink = $this->getUrl('*/*/refreshstatistics');
$directRefreshLink = $this->getUrl('*/*/refreshRecent', array('code' => $refreshCode));
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('adminhtml')->__('This Report is not realtime. Last updated: %s. To refresh statistics right now, click here ', $updatedAt, $refreshStatsLink, $directRefreshLink));
+ Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('adminhtml')->__('Last updated: %s. To refresh last day\'s statistics , click here ', $updatedAt, $refreshStatsLink, $directRefreshLink));
return $this;
}
@@ -195,6 +200,8 @@ public function exportSalesExcelAction()
public function taxAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Tax'));
+
$this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_TAX_FLAG_CODE, 'tax');
$this->_initAction()
@@ -236,6 +243,8 @@ public function exportTaxExcelAction()
public function shippingAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Shipping'));
+
$this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_SHIPPING_FLAG_CODE, 'shipping');
$this->_initAction()
@@ -277,6 +286,8 @@ public function exportShippingExcelAction()
public function invoicedAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Total Invoiced'));
+
$this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_INVOICE_FLAG_CODE, 'invoiced');
$this->_initAction()
@@ -318,6 +329,8 @@ public function exportInvoicedExcelAction()
public function refundedAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Total Refunded'));
+
$this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_REFUNDED_FLAG_CODE, 'refunded');
$this->_initAction()
@@ -359,6 +372,8 @@ public function exportRefundedExcelAction()
public function couponsAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Coupons'));
+
$this->_showLastExecutionTime(Mage_Reports_Model_Flag::REPORT_COUPNS_FLAG_CODE, 'coupons');
$this->_initAction()
@@ -400,6 +415,8 @@ public function exportCouponsExcelAction()
public function refreshStatisticsAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Refresh Statistics'));
+
$this->_initAction()
->_setActiveMenu('report/sales/refreshstatistics')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Refresh Statistics'), Mage::helper('adminhtml')->__('Refresh Statistics'))
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php
index 7947501bcf..263aaabba0 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php
@@ -44,6 +44,10 @@ public function _initAction()
public function customerAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Shopping Cart'))
+ ->_title($this->__('Customer Shopping Carts'));
+
$this->_initAction()
->_setActiveMenu('report/shopcart/customer')
->_addBreadcrumb(Mage::helper('reports')->__('Customers Report'), Mage::helper('reports')->__('Customers Report'))
@@ -77,6 +81,10 @@ public function exportCustomerExcelAction()
public function productAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Shopping Cart'))
+ ->_title($this->__('Products in Carts'));
+
$this->_initAction()
->_setActiveMenu('report/shopcart/product')
->_addBreadcrumb(Mage::helper('reports')->__('Products Report'), Mage::helper('reports')->__('Products Report'))
@@ -110,6 +118,10 @@ public function exportProductExcelAction()
public function abandonedAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Shopping Cart'))
+ ->_title($this->__('Abandoned Carts'));
+
$this->_initAction()
->_setActiveMenu('report/shopcart/abandoned')
->_addBreadcrumb(Mage::helper('reports')->__('Abandoned carts'), Mage::helper('reports')->__('Abandoned carts'))
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php
index 2aaf911e57..e426c2cf00 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php
@@ -47,6 +47,10 @@ public function _initAction()
public function customerAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Tags'))
+ ->_title($this->__('Customers'));
+
$this->_initAction()
->_setActiveMenu('report/tag/customer')
->_addBreadcrumb(Mage::helper('reports')->__('Customers Report'), Mage::helper('reports')->__('Customers Report'))
@@ -80,6 +84,10 @@ public function exportCustomerExcelAction()
public function productAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Tags'))
+ ->_title($this->__('Products'));
+
$this->_initAction()
->_setActiveMenu('report/tag/product')
->_addBreadcrumb(Mage::helper('reports')->__('Poducts Report'), Mage::helper('reports')->__('Products Report'))
@@ -114,6 +122,10 @@ public function exportProductExcelAction()
public function popularAction()
{
+ $this->_title($this->__('Reports'))
+ ->_title($this->__('Tags'))
+ ->_title($this->__('Popular'));
+
$this->_initAction()
->_setActiveMenu('report/tag/popular')
->_addBreadcrumb(Mage::helper('reports')->__('Popular Tags'), Mage::helper('reports')->__('Popular Tags'))
diff --git a/app/code/core/Mage/Adminhtml/controllers/ReportController.php b/app/code/core/Mage/Adminhtml/controllers/ReportController.php
index a448fcec34..4caa55cca9 100644
--- a/app/code/core/Mage/Adminhtml/controllers/ReportController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/ReportController.php
@@ -77,6 +77,8 @@ public function exportWishlistExcelAction()
*/
public function searchAction()
{
+ $this->_title($this->__('Reports'))->_title($this->__('Search Terms'));
+
Mage::dispatchEvent('on_view_report', array('report' => 'search'));
$this->_initAction()
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/CreditmemoController.php
index e52acc6625..796f1424ca 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/CreditmemoController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/CreditmemoController.php
@@ -32,4 +32,13 @@
class Mage_Adminhtml_Sales_CreditmemoController extends Mage_Adminhtml_Controller_Sales_Creditmemo
{
+
+ /**
+ * Index page
+ */
+ public function indexAction() {
+ $this->_title($this->__('Sales'))->_title($this->__('Credit Memos'));
+
+ parent::indexAction();
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
index c32e208631..7917c3cbcd 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
@@ -251,6 +251,8 @@ protected function _processData()
if (!empty($data['coupon']['code'])) {
if ($this->_getQuote()->getCouponCode() !== $data['coupon']['code']) {
$this->_getSession()->addError($this->__('"%s" coupon code is not valid.', $data['coupon']['code']));
+ } else {
+ $this->_getSession()->addSuccess($this->__('Coupon code accepted.'));
}
}
@@ -262,6 +264,7 @@ protected function _processData()
*/
public function indexAction()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Orders'))->_title($this->__('New Order'));
$this->loadLayout();
$this->_initSession()
@@ -383,18 +386,19 @@ public function saveAction()
->createOrder();
$this->_getSession()->clear();
- $url = $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Order has been successfully created'));
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
}
catch (Mage_Core_Exception $e){
$message = $e->getMessage();
if( !empty($message) ) {
$this->_getSession()->addError($message);
}
- $url = $this->_redirect('*/*/');
+ $this->_redirect('*/*/');
}
catch (Exception $e){
$this->_getSession()->addException($e, $this->__('Order saving error: %s', $e->getMessage()));
- $url = $this->_redirect('*/*/');
+ $this->_redirect('*/*/');
}
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php
index 8a90df7ae9..c07bc76da2 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php
@@ -72,6 +72,8 @@ protected function _canCreditmemo($order)
*/
protected function _initCreditmemo($update = false)
{
+ $this->_title($this->__('Sales'))->_title($this->__('Credit Memos'));
+
$creditmemo = false;
if ($creditmemoId = $this->getRequest()->getParam('creditmemo_id')) {
$creditmemo = Mage::getModel('sales/order_creditmemo')->load($creditmemoId);
@@ -235,6 +237,12 @@ protected function _saveCreditmemo($creditmemo)
public function viewAction()
{
if ($creditmemo = $this->_initCreditmemo()) {
+ if ($creditmemo->getInvoice()) {
+ $this->_title($this->__("View Memo for #%s", $creditmemo->getInvoice()->getIncrementId()));
+ } else {
+ $this->_title($this->__("View Memo"));
+ }
+
$this->loadLayout();
$this->getLayout()->getBlock('sales_creditmemo_view')
->updateBackButtonUrl($this->getRequest()->getParam('come_from'));
@@ -263,6 +271,12 @@ public function startAction()
public function newAction()
{
if ($creditmemo = $this->_initCreditmemo()) {
+ if ($creditmemo->getInvoice()) {
+ $this->_title($this->__("New Memo for #%s", $creditmemo->getInvoice()->getIncrementId()));
+ } else {
+ $this->_title($this->__("New Memo"));
+ }
+
$commentText = Mage::getSingleton('adminhtml/session')->getCommentText(true);
$creditmemo->addData(array('commentText'=>$commentText));
@@ -322,8 +336,10 @@ public function saveAction()
$comment = '';
if (!empty($data['comment_text'])) {
- $comment = $data['comment_text'];
$creditmemo->addComment($data['comment_text'], isset($data['comment_customer_notify']));
+ if (isset($data['comment_customer_notify'])) {
+ $comment = $data['comment_text'];
+ }
}
if (isset($data['do_refund'])) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php
index 94bab48589..c1ee81f6eb 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php
@@ -61,4 +61,17 @@ public function startAction()
$this->_redirect('*/sales_order/');
}
}
+
+ /**
+ * Index page
+ */
+ public function indexAction()
+ {
+ $this->_title($this->__('Sales'))->_title($this->__('Orders'))->_title($this->__('Edit Order'));
+ $this->loadLayout();
+
+ $this->_initSession()
+ ->_setActiveMenu('sales/order')
+ ->renderLayout();
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php
index 3db7965021..b22465e792 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php
@@ -56,6 +56,8 @@ protected function _getItemQtys()
*/
protected function _initInvoice($update = false)
{
+ $this->_title($this->__('Sales'))->_title($this->__('Invoices'));
+
$invoice = false;
$itemsToInvoice = 0;
@@ -226,6 +228,8 @@ protected function _prepareShipment($invoice)
public function viewAction()
{
if ($invoice = $this->_initInvoice()) {
+ $this->_title(sprintf("#%s", $invoice->getIncrementId()));
+
$this->loadLayout()
->_setActiveMenu('sales/order');
$this->getLayout()->getBlock('sales_invoice_view')
@@ -255,6 +259,7 @@ public function startAction()
public function newAction()
{
if ($invoice = $this->_initInvoice()) {
+ $this->_title($this->__('New Invoice'));
$this->loadLayout()
->_setActiveMenu('sales/order')
->renderLayout();
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
index 9375011d57..d5b8662751 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
@@ -52,6 +52,8 @@ protected function _getItemQtys()
*/
protected function _initShipment()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Shipments'));
+
$shipment = false;
if ($shipmentId = $this->getRequest()->getParam('shipment_id')) {
$shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
@@ -142,6 +144,8 @@ protected function _saveShipment($shipment)
public function viewAction()
{
if ($shipment = $this->_initShipment()) {
+ $this->_title($this->__('View Shipment'));
+
$this->loadLayout();
$this->getLayout()->getBlock('sales_shipment_view')
->updateBackButtonUrl($this->getRequest()->getParam('come_from'));
@@ -170,6 +174,8 @@ public function startAction()
public function newAction()
{
if ($shipment = $this->_initShipment()) {
+ $this->_title($this->__('New Shipment'));
+
$this->loadLayout()
->_setActiveMenu('sales/order')
->renderLayout();
@@ -194,7 +200,9 @@ public function saveAction()
$comment = '';
if (!empty($data['comment_text'])) {
$shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']));
- $comment = $data['comment_text'];
+ if (isset($data['comment_customer_notify'])) {
+ $comment = $data['comment_text'];
+ }
}
if (!empty($data['send_email'])) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
index c3775cc852..25c85e1504 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
@@ -89,6 +89,8 @@ protected function _initOrder()
*/
public function indexAction()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Orders'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/sales_order'))
->renderLayout();
@@ -110,9 +112,14 @@ public function gridAction()
*/
public function viewAction()
{
+ $this->_title($this->__('Sales'))->_title($this->__('Orders'));
+
if ($order = $this->_initOrder()) {
- $this->_initAction()
- ->renderLayout();
+ $this->_initAction();
+
+ $this->_title(sprintf("#%s", $order->getRealOrderId()));
+
+ $this->renderLayout();
}
}
@@ -293,19 +300,26 @@ public function massCancelAction()
{
$orderIds = $this->getRequest()->getPost('order_ids', array());
$countCancelOrder = 0;
+ $countNonCancelOrder = 0;
foreach ($orderIds as $orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->canCancel()) {
$order->cancel()
->save();
$countCancelOrder++;
+ } else {
+ $countNonCancelOrder++;
}
}
- if ($countCancelOrder>0) {
- $this->_getSession()->addSuccess($this->__('%s order(s) successfully canceled', $countCancelOrder));
+ if ($countNonCancelOrder) {
+ if ($countCancelOrder) {
+ $this->_getSession()->addError($this->__('%s order(s) can not be canceled', $countNonCancelOrder));
+ } else {
+ $this->_getSession()->addError($this->__('Order(s) can not be canceled'));
+ }
}
- else {
- // selected orders is not available for cancel
+ if ($countCancelOrder) {
+ $this->_getSession()->addSuccess($this->__('%s order(s) successfully canceled', $countCancelOrder));
}
$this->_redirect('*/*/');
}
@@ -317,20 +331,28 @@ public function massHoldAction()
{
$orderIds = $this->getRequest()->getPost('order_ids', array());
$countHoldOrder = 0;
+ $countNonHoldOrder = 0;
foreach ($orderIds as $orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->canHold()) {
$order->hold()
->save();
$countHoldOrder++;
+ } else {
+ $countNonHoldOrder++;
}
}
- if ($countHoldOrder>0) {
- $this->_getSession()->addSuccess($this->__('%s order(s) successfully put on hold', $countHoldOrder));
+ if ($countNonHoldOrder) {
+ if ($countHoldOrder) {
+ $this->_getSession()->addError($this->__('%s order(s) not put on hold', $countNonHoldOrder));
+ } else {
+ $this->_getSession()->addError($this->__('No order(s) put on hold'));
+ }
}
- else {
- // selected orders is not available for hold
+ if ($countHoldOrder) {
+ $this->_getSession()->addSuccess($this->__('%s order(s) successfully put on hold', $countHoldOrder));
}
+
$this->_redirect('*/*/');
}
@@ -341,19 +363,27 @@ public function massUnholdAction()
{
$orderIds = $this->getRequest()->getPost('order_ids', array());
$countUnholdOrder = 0;
+ $countNonUnholdOrder = 0;
+
foreach ($orderIds as $orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->canUnhold()) {
$order->unhold()
->save();
$countUnholdOrder++;
+ } else {
+ $countNonUnholdOrder++;
}
}
- if ($countUnholdOrder>0) {
- $this->_getSession()->addSuccess($this->__('%s order(s) successfully released from holding status', $countUnholdOrder));
+ if ($countNonUnholdOrder) {
+ if ($countUnholdOrder) {
+ $this->_getSession()->addError($this->__('%s order(s) not released from holding status', $countNonUnholdOrder));
+ } else {
+ $this->_getSession()->addError($this->__('No order(s) released from holding status'));
+ }
}
- else {
- // selected orders is not available for hold
+ if ($countUnholdOrder) {
+ $this->_getSession()->addSuccess($this->__('%s order(s) successfully released from holding status', $countUnholdOrder));
}
$this->_redirect('*/*/');
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php
index dfbfbd4348..e81c562a65 100644
--- a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php
@@ -54,6 +54,8 @@ protected function _initAction()
*/
public function indexAction()
{
+ $this->_title($this->__('Catalog'))->_title($this->__('Google Sitemaps'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/sitemap'))
->renderLayout();
@@ -73,6 +75,8 @@ public function newAction()
*/
public function editAction()
{
+ $this->_title($this->__('Catalog'))->_title($this->__('Google Sitemaps'));
+
// 1. Get ID and create model
$id = $this->getRequest()->getParam('sitemap_id');
$model = Mage::getModel('sitemap/sitemap');
@@ -87,6 +91,8 @@ public function editAction()
}
}
+ $this->_title($model->getId() ? $model->getSitemapFilename() : $this->__('New Sitemap'));
+
// 3. Set entered data if was error when we do save
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (! empty($data)) {
diff --git a/app/code/core/Mage/Paybox/Block/Adminhtml/Cart/Type/Select.php b/app/code/core/Mage/Adminhtml/controllers/SurveyController.php
similarity index 62%
rename from app/code/core/Mage/Paybox/Block/Adminhtml/Cart/Type/Select.php
rename to app/code/core/Mage/Adminhtml/controllers/SurveyController.php
index 922240e9da..4d4147eb9c 100644
--- a/app/code/core/Mage/Paybox/Block/Adminhtml/Cart/Type/Select.php
+++ b/app/code/core/Mage/Adminhtml/controllers/SurveyController.php
@@ -19,38 +19,40 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Paybox
+ * @package Mage_Adminhtml
* @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)
*/
+
/**
- * Paybox Adminhtml Cart Type select
+ * Adminhtml Survey Action
*
* @category Mage
- * @package Mage_Paybox
+ * @package Mage_Adminhtml
* @author Magento Core Team
*/
-class Mage_Paybox_Block_Adminhtml_Cart_Type_Select extends Mage_Adminhtml_Block_Template
+class Mage_Adminhtml_SurveyController extends Mage_Adminhtml_Controller_Action
{
/**
- * Enter description here...
+ * Index Action
*
- * @return Mage_Paybox_Model_System
*/
- public function getModel()
- {
- return Mage::getModel('paybox/system');
- }
-
- public function getParentHtmlId()
+ public function indexAction()
{
- return substr($this->getDependHtmlId(), 0, strrpos($this->getDependHtmlId(), 'typecarte')) . 'typepaiement';
+ if ($this->getRequest()->getParam('isAjax', false)) {
+ Mage_AdminNotification_Model_Survey::saveSurveyViewed(true);
+ }
+ $this->getResponse()->setBody(Zend_Json::encode(array('survey_decision_saved' => 1)));
}
- public function getJsonCartTypes()
+ /**
+ * Check if user has enough privileges
+ *
+ * @return boolean
+ */
+ protected function _isAllowed()
{
- return $this->getModel()->getJsonCartTypes();
+ return Mage::getSingleton('admin/session')->isAllowed('all');
}
-
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php
index 62bb8d8b36..dfe92f54f2 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php
@@ -36,6 +36,8 @@ class Mage_Adminhtml_System_AccountController extends Mage_Adminhtml_Controller_
{
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('My Account'));
+
$this->loadLayout();
$this->_setActiveMenu('system/account');
$this->_addContent($this->getLayout()->createBlock('adminhtml/system_account_edit'));
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php
index 34691d837c..8c1d6d8714 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php
@@ -38,6 +38,8 @@ class Mage_Adminhtml_System_BackupController extends Mage_Adminhtml_Controller_A
*/
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Tools'))->_title($this->__('Backups'));
+
if($this->getRequest()->getParam('ajax')) {
$this->_forward('grid');
return;
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php
index c1e2991972..078295c86d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php
@@ -30,21 +30,10 @@
*
* @category Mage
* @package Mage_Adminhtml
- * @author Magento Core Team
+ * @author Magento Core Team
*/
class Mage_Adminhtml_System_ConfigController extends Mage_Adminhtml_Controller_Action
{
-
- /**
- * Enter description here...
- *
- */
- protected function _construct()
- {
- $this->setFlag('index', 'no-preDispatch', true);
- return parent::_construct();
- }
-
/**
* Enter description here...
*
@@ -60,6 +49,8 @@ public function indexAction()
*/
public function editAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Configuration'));
+
$current = $this->getRequest()->getParam('section');
$website = $this->getRequest()->getParam('website');
$store = $this->getRequest()->getParam('store');
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
index 1332bebd01..e85a454e16 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
@@ -40,6 +40,10 @@ class Mage_Adminhtml_System_Convert_GuiController extends Mage_Adminhtml_System_
*/
public function indexAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Import and Export'))
+ ->_title($this->__('Profiles'));
+
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
@@ -89,6 +93,8 @@ public function editAction()
$profile->addData($data);
}
+ $this->_title($profile->getId() ? $profile->getName() : $this->__('New Profile'));
+
$this->_setActiveMenu('system/convert');
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php
index f36fde5f1c..05d1724a54 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php
@@ -36,6 +36,10 @@ class Mage_Adminhtml_System_Convert_ProfileController extends Mage_Adminhtml_Con
protected function _initProfile($idFieldName = 'id')
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Import and Export'))
+ ->_title($this->__('Profiles'));
+
$profileId = (int) $this->getRequest()->getParam($idFieldName);
$profile = Mage::getModel('dataflow/profile');
@@ -58,6 +62,10 @@ protected function _initProfile($idFieldName = 'id')
*/
public function indexAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Import and Export'))
+ ->_title($this->__('Advanced Profiles'));
+
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
@@ -107,6 +115,8 @@ public function editAction()
$profile->addData($data);
}
+ $this->_title($profile->getId() ? $profile->getName() : $this->__('New Profile'));
+
$this->_setActiveMenu('system/convert');
$this->_addContent(
@@ -241,8 +251,8 @@ public function batchRunAction()
continue;
}
- $importData = $batchImportModel->getBatchData();
try {
+ $importData = $batchImportModel->getBatchData();
$adapter->saveRow($importData);
}
catch (Exception $e) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php
index dbfed97941..2b7153506e 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php
@@ -53,6 +53,8 @@ protected function _initCurrency()
*/
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Manage Currency Rates'));
+
$this->loadLayout();
$this->_setActiveMenu('system/currency');
$this->_addContent($this->getLayout()->createBlock('adminhtml/system_currency'));
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php
index 7267a9c2ca..c4e746b550 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php
@@ -29,6 +29,8 @@ class Mage_Adminhtml_System_DesignController extends Mage_Adminhtml_Controller_A
{
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Design'));
+
$this->loadLayout();
$this->_setActiveMenu('system');
$this->_addContent($this->getLayout()->createBlock('adminhtml/system_design'));
@@ -47,6 +49,8 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Design'));
+
$this->loadLayout();
$this->_setActiveMenu('system');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
@@ -58,6 +62,8 @@ public function editAction()
$design->load($id);
}
+ $this->_title($design->getId() ? $this->__('Edit Design Change') : $this->__('New Design Change'));
+
Mage::register('design', $design);
$this->_addContent($this->getLayout()->createBlock('adminhtml/system_design_edit'));
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
index c1cac2697c..25b3ef39cc 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
@@ -35,6 +35,8 @@ class Mage_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_Cont
{
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
+
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
@@ -80,6 +82,8 @@ public function editAction()
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('New Template'), Mage::helper('adminhtml')->__('New System Template'));
}
+ $this->_title($template->getId() ? $template->getTemplateCode() : $this->__('New Template'));
+
$this->_addContent($this->getLayout()->createBlock('adminhtml/system_email_template_edit', 'template_edit')
->setEditMode((bool)$this->getRequest()->getParam('id')));
$this->renderLayout();
@@ -198,6 +202,8 @@ public function defaultTemplateAction()
*/
protected function _initTemplate($idFieldName = 'template_id')
{
+ $this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
+
$id = (int)$this->getRequest()->getParam($idFieldName);
$model = Mage::getModel('adminhtml/email_template');
if ($id) {
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php
index 53332d3a5e..b22356f461 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php
@@ -52,6 +52,8 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Stores'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/system_store_store'))
->renderLayout();
@@ -92,6 +94,9 @@ public function editGroupAction()
public function editStoreAction()
{
+ $this->_title($this->__('System'))
+ ->_title($this->__('Stores'));
+
$session = $this->_getSession();
if ($session->getPostData()) {
Mage::register('store_post_data', $session->getPostData());
@@ -107,18 +112,21 @@ public function editStoreAction()
case 'website':
$itemId = $this->getRequest()->getParam('website_id', null);
$model = Mage::getModel('core/website');
+ $title = Mage::helper('core')->__("Website");
$notExists = Mage::helper('core')->__("Website doesn't exist");
$codeBase = Mage::helper('core')->__('Before modifying the website code please make sure that it is not used in index.php');
break;
case 'group':
$itemId = $this->getRequest()->getParam('group_id', null);
$model = Mage::getModel('core/store_group');
+ $title = Mage::helper('core')->__("Store");
$notExists = Mage::helper('core')->__("Store doesn't exist");
$codeBase = false;
break;
case 'store':
$itemId = $this->getRequest()->getParam('store_id', null);
$model = Mage::getModel('core/store');
+ $title = Mage::helper('core')->__("Store View");
$notExists = Mage::helper('core')->__("Store view doesn't exist");
$codeBase = Mage::helper('core')->__('Before modifying the store view code please make sure that it is not used in index.php');
break;
@@ -130,6 +138,13 @@ public function editStoreAction()
if ($model->getId() || Mage::registry('store_action') == 'add') {
Mage::register('store_data', $model);
+ if (Mage::registry('store_action') == 'add') {
+ $this->_title($this->__('New ') . $title);
+ }
+ else {
+ $this->_title($model->getName());
+ }
+
if (Mage::registry('store_action') == 'edit' && $codeBase && !$model->isReadOnly()) {
$this->_getSession()->addNotice($codeBase);
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php
index 0afc5cca91..5a013354c6 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php
@@ -53,6 +53,8 @@ protected function _initLayout()
*/
protected function _initVariable()
{
+ $this->_title($this->__('System'))->_title($this->__('Custom Variables'));
+
$variableId = $this->getRequest()->getParam('variable_id', null);
$storeId = $this->getRequest()->getParam('store', 0);
/* @var $emailVariable Mage_Core_Model_Variable */
@@ -71,6 +73,8 @@ protected function _initVariable()
*/
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Custom Variables'));
+
$this->_initLayout()
->_addContent($this->getLayout()->createBlock('adminhtml/system_variable'))
->renderLayout();
@@ -91,7 +95,10 @@ public function newAction()
*/
public function editAction()
{
- $this->_initVariable();
+ $variable = $this->_initVariable();
+
+ $this->_title($variable->getId() ? $variable->getCode() : $this->__('New Variable'));
+
$this->_initLayout()
->_addContent($this->getLayout()->createBlock('adminhtml/system_variable_edit'))
->_addJs($this->getLayout()->createBlock('core/template', '', array('template' => 'system/variable/js.phtml')))
diff --git a/app/code/core/Mage/Adminhtml/controllers/TagController.php b/app/code/core/Mage/Adminhtml/controllers/TagController.php
index b7841a3c0a..09ef665e18 100644
--- a/app/code/core/Mage/Adminhtml/controllers/TagController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/TagController.php
@@ -74,6 +74,10 @@ protected function _initTag()
*/
public function indexAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Tags'))
+ ->_title($this->__('All Tags'));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('adminhtml')->__('All Tags'), Mage::helper('adminhtml')->__('All Tags'))
->_setActiveMenu('catalog/tag/all')
@@ -116,6 +120,9 @@ public function newAction()
*/
public function editAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Tags'));
+
if (! (int) $this->getRequest()->getParam('store')) {
return $this->_redirect('*/*/*/', array('store' => Mage::app()->getAnyStoreView()->getId(), '_current' => true));
}
@@ -133,6 +140,8 @@ public function editAction()
$model->addData($data);
}
+ $this->_title($model->getId() ? $model->getName() : $this->__('New Tag'));
+
Mage::register('tag_tag', $model);
$this->_initAction()->renderLayout();
@@ -219,6 +228,10 @@ public function deleteAction()
*/
public function pendingAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Tags'))
+ ->_title($this->__('Pending Tags'));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('adminhtml')->__('Pending Tags'), Mage::helper('adminhtml')->__('Pending Tags'))
->_setActiveMenu('catalog/tag/pending')
@@ -232,6 +245,8 @@ public function pendingAction()
*/
public function assignedAction()
{
+ $this->_title($this->__('Tags'))->_title($this->__('Assigned'));
+
$this->_initTag();
$this->loadLayout();
$this->renderLayout();
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php
index 29e8aea8a3..bffcf5abe8 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php
@@ -40,6 +40,10 @@ class Mage_Adminhtml_Tax_Class_CustomerController extends Mage_Adminhtml_Control
*/
public function indexAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Customer Tax Classes'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/tax_class')->setClassType('CUSTOMER'))
->renderLayout();
@@ -60,6 +64,10 @@ public function newAction()
*/
public function editAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Customer Tax Classes'));
+
$classId = $this->getRequest()->getParam('id');
$model = Mage::getModel('tax/class');
if ($classId) {
@@ -71,6 +79,8 @@ public function editAction()
}
}
+ $this->_title($model->getId() ? $model->getClassName() : $this->__('New Class'));
+
$data = Mage::getSingleton('adminhtml/session')->getClassData(true);
if (!empty($data)) {
$model->setData($data);
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php
index 3129c0fc05..2d65635e4c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php
@@ -39,6 +39,10 @@ class Mage_Adminhtml_Tax_Class_ProductController extends Mage_Adminhtml_Controll
*/
public function indexAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Customer Tax Classes'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/tax_class')->setClassType('PRODUCT'))
->renderLayout();
@@ -59,6 +63,10 @@ public function newAction()
*/
public function editAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Customer Tax Classes'));
+
$classId = $this->getRequest()->getParam('id');
$model = Mage::getModel('tax/class');
if ($classId) {
@@ -70,6 +78,8 @@ public function editAction()
}
}
+ $this->_title($model->getId() ? $model->getClassName() : $this->__('New Class'));
+
$data = Mage::getSingleton('adminhtml/session')->getClassData(true);
if (!empty($data)) {
$model->setData($data);
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php
index 8b6862912d..c899f9d2b3 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php
@@ -40,6 +40,10 @@ class Mage_Adminhtml_Tax_RateController extends Mage_Adminhtml_Controller_Action
*/
public function indexAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Manage Tax Zones and Rates'));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('tax')->__('Manage Tax Rates'), Mage::helper('tax')->__('Manage Tax Rates'))
->_addContent(
@@ -59,6 +63,16 @@ public function addAction()
{
$rateModel = Mage::getSingleton('tax/calculation_rate')
->load(null);
+
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Manage Tax Zones and Rates'));
+
+ $this->_title($this->__('New Rate'));
+
+ //This line substitutes in the form the previously entered by the user values, if any of them were wrong.
+ $rateModel->setData(Mage::getSingleton('adminhtml/session')->getFormData(true));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('tax')->__('Manage Tax Rates'), Mage::helper('tax')->__('Manage Tax Rates'), $this->getUrl('*/tax_rate'))
->_addBreadcrumb(Mage::helper('tax')->__('New Tax Rate'), Mage::helper('tax')->__('New Tax Rate'))
@@ -80,7 +94,7 @@ public function saveAction()
$ratePost = $this->getRequest()->getPost();
if ($ratePost) {
- $rateId = $this->getRequest()->getParam('rate');
+ $rateId = $this->getRequest()->getParam('tax_calculation_rate_id');
if ($rateId) {
$rateModel = Mage::getSingleton('tax/calculation_rate')->load($rateId);
if (!$rateModel->getId()) {
@@ -98,6 +112,8 @@ public function saveAction()
return true;
}
catch (Mage_Core_Exception $e) {
+ //save entered by the user values in session, for re-rendering of form.
+ Mage::getSingleton('adminhtml/session')->setFormData($ratePost);
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
catch (Exception $e) {
@@ -117,6 +133,10 @@ public function saveAction()
*/
public function editAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Manage Tax Zones and Rates'));
+
$rateId = (int)$this->getRequest()->getParam('rate');
$rateModel = Mage::getSingleton('tax/calculation_rate')->load($rateId);
if (!$rateModel->getId()) {
@@ -124,6 +144,8 @@ public function editAction()
return ;
}
+ $this->_title(sprintf("%s", $rateModel->getCode()));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('tax')->__('Manage Tax Rates'), Mage::helper('tax')->__('Manage Tax Rates'), $this->getUrl('*/tax_rate'))
->_addBreadcrumb(Mage::helper('tax')->__('Edit Tax Rate'), Mage::helper('tax')->__('Edit Tax Rate'))
@@ -216,6 +238,12 @@ protected function _initAction()
*/
public function importExportAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Manage Tax Zones and Rates'));
+
+ $this->_title($this->__('Import and Export Tax Rates'));
+
$this->loadLayout()
->_setActiveMenu('sales/tax_importExport')
->_addContent($this->getLayout()->createBlock('adminhtml/tax_rate_importExport'))
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php
index 6fec735a5c..ef1b8a73ad 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php
@@ -35,6 +35,10 @@ class Mage_Adminhtml_Tax_RuleController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Manage Tax Rules'));
+
$this->_initAction()
->_addContent($this->getLayout()->createBlock('adminhtml/tax_rule'))
->renderLayout();
@@ -48,6 +52,10 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('Sales'))
+ ->_title($this->__('Tax'))
+ ->_title($this->__('Manage Tax Rules'));
+
$taxRuleId = $this->getRequest()->getParam('rule');
$ruleModel = Mage::getModel('tax/calculation_rule');
if ($taxRuleId) {
@@ -65,6 +73,8 @@ public function editAction()
$ruleModel->setData($data);
}
+ $this->_title($ruleModel->getId() ? sprintf("%s", $ruleModel->getCode()) : $this->__('New Rule'));
+
Mage::register('tax_rule', $ruleModel);
$this->_initAction()
diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php
index 0c51f26a1c..31cc531b36 100644
--- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php
@@ -40,6 +40,8 @@ class Mage_Adminhtml_UrlrewriteController extends Mage_Adminhtml_Controller_Acti
*/
protected function _initRegistry()
{
+ $this->_title($this->__('Rewrite Rules'));
+
// initialize urlrewrite, product and category models
Mage::register('current_urlrewrite', Mage::getModel('core/url_rewrite')
->load($this->getRequest()->getParam('id', 0))
@@ -79,6 +81,9 @@ public function indexAction()
public function editAction()
{
$this->_initRegistry();
+
+ $this->_title($this->__('URL Rewrite'));
+
$this->loadLayout();
$this->_setActiveMenu('catalog/urlrewrite');
$this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit'));
diff --git a/app/code/core/Mage/Adminhtml/etc/config.xml b/app/code/core/Mage/Adminhtml/etc/config.xml
index 3e470bf756..ee783d350b 100644
--- a/app/code/core/Mage/Adminhtml/etc/config.xml
+++ b/app/code/core/Mage/Adminhtml/etc/config.xml
@@ -95,6 +95,14 @@
+
+
+
+ admin/observer
+ actionPostDispatchAdmin
+
+
+
diff --git a/app/code/core/Mage/AmazonPayments/Block/Adminhtml/Shipping/Methods.php b/app/code/core/Mage/AmazonPayments/Block/Adminhtml/Shipping/Methods.php
deleted file mode 100644
index ed4e07e994..0000000000
--- a/app/code/core/Mage/AmazonPayments/Block/Adminhtml/Shipping/Methods.php
+++ /dev/null
@@ -1,103 +0,0 @@
-setElement($element);
-
- $html = '_getDisabled().'>';
- $html .= ''.$this->__(' Select shipping method').' ';
- foreach ($this->getShippingMethods() as $carrierCode=>$carrier) {
- $html .= '';
- foreach ($carrier['methods'] as $methodCode=>$method) {
- $code = $carrierCode.'/'.$methodCode;
- $html .= '_getSelected($code).' style="background:white;">'.$method['title'].' ';
- }
- $html .= ' ';
- }
- $html .= ' ';
-
- return $html;
- }
-
- protected function getShippingMethods()
- {
- if (!$this->hasData('shipping_methods')) {
- $website = $this->getRequest()->getParam('website');
- $store = $this->getRequest()->getParam('store');
-
- $storeId = null;
- if (!is_null($website)) {
- $storeId = Mage::getModel('core/website')->load($website, 'code')->getDefaultGroup()->getDefaultStoreId();
- } elseif (!is_null($store)) {
- $storeId = Mage::getModel('core/store')->load($store, 'code')->getId();
- }
-
- $methods = array();
- $carriers = Mage::getSingleton('shipping/config')->getActiveCarriers($storeId);
- foreach ($carriers as $carrierCode=>$carrierModel) {
- if (!$carrierModel->isActive()) {
- continue;
- }
- $carrierMethods = $carrierModel->getAllowedMethods();
- if (!$carrierMethods) {
- continue;
- }
- $carrierTitle = Mage::getStoreConfig('carriers/'.$carrierCode.'/title', $storeId);
- $methods[$carrierCode] = array(
- 'title' => $carrierTitle,
- 'methods' => array(),
- );
- foreach ($carrierMethods as $methodCode=>$methodTitle) {
- $methods[$carrierCode]['methods'][$methodCode] = array(
- 'title' => '['.$carrierCode.'] '.$methodTitle,
- );
- }
- }
- $this->setData('shipping_methods', $methods);
- }
- return $this->getData('shipping_methods');
- }
-
- protected function _getDisabled()
- {
- return $this->getElement()->getDisabled() ? ' disabled' : '';
- }
-
- protected function _getValue($key)
- {
- return $this->getElement()->getData('value/'.$key);
- }
-
- protected function _getSelected($value)
- {
- return $this->getElement()->getData('value/method') == $value ? 'selected="selected"' : '';
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Block/Cba/Form.php b/app/code/core/Mage/AmazonPayments/Block/Cba/Form.php
deleted file mode 100644
index b91b59c262..0000000000
--- a/app/code/core/Mage/AmazonPayments/Block/Cba/Form.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- */
-class Mage_AmazonPayments_Block_Cba_Form extends Mage_Payment_Block_Form
-{
-
- /**
- * Varien constructor
- */
- protected function _construct()
- {
- $this->setTemplate('amazonpayments/cba/form.phtml');
- parent::_construct();
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Block/Cba/Redirect.php b/app/code/core/Mage/AmazonPayments/Block/Cba/Redirect.php
deleted file mode 100644
index 4f4e1ca4b9..0000000000
--- a/app/code/core/Mage/AmazonPayments/Block/Cba/Redirect.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
- */
-class Mage_AmazonPayments_Block_Cba_Redirect extends Mage_Core_Block_Abstract
-{
- /**
- * Shopping cart form to CBA in case XML-based cart
- *
- * @return string
- */
- protected function _toHtml()
- {
- $cba = Mage::getModel('amazonpayments/payment_cba');
- /* @var $cba Mage_AmazonPayments_Model_Payment_Cba */
-
- $form = new Varien_Data_Form();
- $form->setAction($cba->getAmazonRedirectUrl())
- ->setId('amazonpayments_cba')
- ->setName('amazonpayments_cba')
- ->setMethod('POST')
- ->setUseContainer(true);
-
- $formFields = $cba->getCheckoutXmlFormFields();
- $values = '';
- $i = 1;
- foreach ($formFields as $field=>$value) {
- $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
- $values .= ($i++ > 1) ? '&' : '';
- $values .= "{$field}={$value}";
- }
- $html = '';
- $html.= $this->__('You will be redirected to Checkout by Amazon in a few seconds.');
- $html.= $form->toHtml();
- $html.= '';
- $html.= '';
-
- return $html;
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Block/Form.php b/app/code/core/Mage/AmazonPayments/Block/Form.php
deleted file mode 100644
index f09711c64f..0000000000
--- a/app/code/core/Mage/AmazonPayments/Block/Form.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- */
-class Mage_AmazonPayments_Block_Form extends Mage_Payment_Block_Form
-{
-
- /**
- * Varien constructor
- */
- protected function _construct()
- {
- $this->setTemplate('amazonpayments/form.phtml');
- parent::_construct();
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Block/Link/Shortcut.php b/app/code/core/Mage/AmazonPayments/Block/Link/Shortcut.php
deleted file mode 100644
index 49f3244a5d..0000000000
--- a/app/code/core/Mage/AmazonPayments/Block/Link/Shortcut.php
+++ /dev/null
@@ -1,90 +0,0 @@
-
- */
-class Mage_AmazonPayments_Block_Link_Shortcut extends Mage_Core_Block_Template
-{
- public function getCheckoutUrl()
- {
- #return $this->getUrl('amazonpayments/cba', array('_secure'=>true));
- return $this->getUrl('amazonpayments/cba/shortcut');
- }
-
- public function getImageUrl()
- {
- return Mage::getStoreConfig('payment/amazonpayments_cba/button_url');
- #return 'http://g-ecx.images-amazon.com/images/G/01/cba/images/buttons/btn_Chkout-orange-large.gif';
- }
-
- public function _toHtml()
- {
- if (Mage::getStoreConfigFlag('payment/amazonpayments_cba/active')
- && Mage::getSingleton('checkout/session')->getQuote()->validateMinimumAmount()) {
- return parent::_toHtml();
- }
-
- return '';
- }
-
- public function getCbaOneClickJsUrl()
- {
- if (Mage::getStoreConfigFlag('payment/amazonpayments_cba/sandbox_flag')) {
- $url = 'https://images-na.ssl-images-amazon.com/images/G/01/cba/js/widget/sandbox/widget.js';
- } else {
- $url = 'https://images-na.ssl-images-amazon.com/images/G/01/cba/js/widget/widget.js';
- }
- return $url;
- }
-
- public function getCbaStylesheetUrl()
- {
- $url = 'https://images-na.ssl-images-amazon.com/images/G/01/cba/styles/one-click.css';
- return $url;
- }
-
- public function getCbaJquerySetupUrl()
- {
- $url = 'https://images-na.ssl-images-amazon.com/images/G/01/cba/js/jquery.js';
- return $url;
- }
-
- /**
- * Return true if 1-Click is enabled
- *
- * @return boolean
- */
- public function getIsOneClickEnabled()
- {
- return Mage::getStoreConfigFlag('payment/amazonpayments_cba/use_oneclick');
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Abstract.php b/app/code/core/Mage/AmazonPayments/Model/Api/Abstract.php
deleted file mode 100644
index ec0ae3bcd9..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Abstract.php
+++ /dev/null
@@ -1,157 +0,0 @@
-
- */
-abstract class Mage_AmazonPayments_Model_Api_Abstract extends Varien_Object
-{
- /*
- * payment actions
- */
- const PAYMENT_TYPE_AUTH = 'Authorization';
- const USER_ACTION_COMMIT = 'commit';
-
- /*
- * signature generation algorithm name
- */
- protected static $HMAC_SHA1_ALGORITHM = 'sha1';
-
- /*
- * payment module code
- */
- protected $paymentCode;
-
- /**
- * Set payment module code
- *
- * @return string
- */
- public function setPaymentCode($paymentCode)
- {
- if(is_null($this->paymentCode)) {
- $this->paymentCode = $paymentCode;
- $this->setData(Mage::getStoreConfig('payment/' . $paymentCode));
- }
- }
-
- /**
- * Return payment url
- *
- * @return string
- */
- public function getPayServiceUrl()
- {
- if ($this->getSandboxFlag()) {
- return $this->getData('sandbox_pay_service_url');
- }
- return $this->getData('pay_service_url');
- }
-
- /**
- * Get value from the payment module config
- *
- * @param string $kay
- * @param string $default
- * @return string
- */
- public function getConfigData($key, $default = false)
- {
- if (!$this->hasData($key)) {
- $value = Mage::getStoreConfig('payment/' . $paymentCode . '/' . $key);
- if (is_null($value) || false===$value) {
- $value = $default;
- }
- $this->setData($key, $value);
- }
- return $this->getData($key);
- }
-
- /**
- * Check signed params
- *
- * @param array $params
- * @return bool
- */
- public function checkSignParams($params)
- {
- if (is_array($params) && isset($params[$this->getRequestSignatureParamName()])) {
- $paramSignature = $params[$this->getRequestSignatureParamName()];
- unset($params[$this->getRequestSignatureParamName()]);
- $generateSignature = $this->_getSignatureForArray($params, $this->getSecretKey());
- return $paramSignature == $generateSignature;
- }
-
- return false;
- }
-
- /**
- * Add signature param to params array
- *
- * @param array $params
- * @return array
- */
- public function signParams($params)
- {
- $signature = $this->_getSignatureForArray($params, $this->getSecretKey());
- $params[$this->getRequestSignatureParamName()] = $signature;
- return $params;
- }
-
- /**
- * Return signature for array
- *
- * @param array $array
- * @param string $secretKey
- * @return array
- */
- protected function _getSignatureForArray($array, $secretKey)
- {
- uksort($array, 'strcasecmp');
- $tmpString = '';
- foreach ($array as $paramName => $paramValue) {
- $tmpString = $tmpString . $paramName . $paramValue;
- }
- return $this->_getSignatureForString($tmpString, $secretKey);
- }
-
- /**
- * Return signature for string
- *
- * @param string $string
- * @param string $secretKey
- * @return string
- */
- protected function _getSignatureForString($string, $secretKey)
- {
- $rawHmac = hash_hmac(self::$HMAC_SHA1_ALGORITHM, $string, $secretKey, true);
- return base64_encode($rawHmac);
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp.php
deleted file mode 100644
index 610b138160..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp.php
+++ /dev/null
@@ -1,217 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp extends Mage_AmazonPayments_Model_Api_Asp_Abstract
-{
- /**
- * collect shipping address to IPN notification request
- */
- protected $_collectShippingAddress = 0;
-
- /**
- * IPN notification request model path
- */
- protected $_ipnRequest = 'amazonpayments/api_asp_ipn_request';
-
- /**
- * FPS model path
- */
- protected $_fpsModel = 'amazonpayments/api_asp_fps';
-
- /**
- * Get singleton with AmazonPayments ASP API FPS Model
- *
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps
- */
- protected function _getFps()
- {
- return Mage::getSingleton($this->_fpsModel)->setStoreId($this->getStoreId());
- }
-
- /**
- * Get singleton with AmazonPayments ASP IPN notification request Model
- *
- * @return Mage_AmazonPayments_Model_Api_Asp_Ipn_Request
- */
- protected function _getIpnRequest()
- {
- return Mage::getSingleton($this->_ipnRequest);
- }
-
-
- /**
- * Return Amazon Simple Pay payment url
- *
- * @return string
- */
- public function getPayUrl ()
- {
- if ($this->_isSandbox()) {
- return $this->_getConfig('pay_service_url_sandbox');
- }
- return $this->_getConfig('pay_service_url');
- }
-
- /**
- * Return Amazon Simple Pay payment params
- *
- * @param string $referenceId
- * @param string $amountValue
- * @param string $currencyCode
- * @param string $abandonUrl
- * @param string $returnUrl
- * @param string $ipnUrl
- * @return array
- */
- public function getPayParams($referenceId, $amountValue, $currencyCode, $abandonUrl, $returnUrl, $ipnUrl)
- {
- $amount = Mage::getSingleton('amazonpayments/api_asp_amount')
- ->setValue($amountValue)
- ->setCurrencyCode($currencyCode);
-
- $requestParams = array();
- $requestParams['referenceId'] = $referenceId;
- $requestParams['amount'] = $amount->toString();
- $requestParams['description'] = $this->_getConfig('pay_description');
-
- $requestParams['accessKey'] = $this->_getConfig('access_key');
- $requestParams['processImmediate'] = $this->_getConfig('pay_process_immediate');
- $requestParams['immediateReturn'] = $this->_getConfig('pay_immediate_return');
- $requestParams['collectShippingAddress'] = $this->_collectShippingAddress;
- $requestParams['abandonUrl'] = $abandonUrl;
- $requestParams['returnUrl'] = $returnUrl;
- $requestParams['ipnUrl'] = $ipnUrl;
-
- $signature = $this->_getSignatureForArray($requestParams, $this->_getConfig('secret_key'));
- $requestParams['signature'] = $signature;
-
- return $requestParams;
- }
-
- /**
- * process notification request
- *
- * @param array $requestParams
- * @return Mage_AmazonPayments_Model_Api_Asp_Ipn_Request
- */
- public function processNotification($requestParams)
- {
- $requestSignature = false;
-
- if (isset($requestParams['signature'])) {
- $requestSignature = $requestParams['signature'];
- unset($requestParams['signature']);
- }
-
- $originalSignature = $this->_getSignatureForArray($requestParams, $this->_getConfig('secret_key'));
- if ($requestSignature != $originalSignature) {
- Mage::throwException(Mage::helper('amazonpayments')->__('Request signed an incorrect or missing signature'));
- }
-
- $ipnRequest = $this->_getIpnRequest();
-
- if(!$ipnRequest->init($requestParams)) {
- Mage::throwException(Mage::helper('amazonpayments')->__('Request is not a valid IPN request'));
- }
-
- return $ipnRequest;
- }
-
- /**
- * cancel payment through FPS api
- *
- * @param string $transactionId
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- public function cancel($transactionId)
- {
- $fps = $this->_getFps();
-
- $request = $fps->getRequest(Mage_AmazonPayments_Model_Api_Asp_Fps::ACTION_CODE_CANCEL)
- ->setTransactionId($transactionId)
- ->setDescription($this->_getConfig('cancel_description'));
-
- $response = $fps->process($request);
- return $response;
- }
-
- /**
- * capture payment through FPS api
- *
- * @param string $transactionId
- * @param string $amount
- * @param string $currencyCode
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- public function capture($transactionId, $amount, $currencyCode)
- {
- $fps = $this->_getFps();
- $amount = $this->_getAmount()
- ->setValue($amount)
- ->setCurrencyCode($currencyCode);
-
- $request = $fps->getRequest(Mage_AmazonPayments_Model_Api_Asp_Fps::ACTION_CODE_SETTLE)
- ->setTransactionId($transactionId)
- ->setAmount($amount);
-
- $response = $fps->process($request);
- return $response;
- }
-
- /**
- * capture payment through FPS api
- *
- * @param string $transactionId
- * @param string $amount
- * @param string $currencyCode
- * @param string $referenceId
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- public function refund($transactionId, $amount, $currencyCode, $referenceId)
- {
- $fps = $this->_getFps();
-
- $amount = $this->_getAmount()
- ->setValue($amount)
- ->setCurrencyCode($currencyCode);
-
- $request = $fps->getRequest(Mage_AmazonPayments_Model_Api_Asp_Fps::ACTION_CODE_REFUND)
- ->setTransactionId($transactionId)
- ->setReferenceId($referenceId)
- ->setAmount($amount)
- ->setDescription($this->_getConfig('refund_description'));
-
- $response = $fps->process($request);
- return $response;
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Abstract.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Abstract.php
deleted file mode 100644
index 538b9d518c..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Abstract.php
+++ /dev/null
@@ -1,109 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Abstract extends Mage_AmazonPayments_Model_Api_Abstract
-{
- /**
- * payment actions
- */
- const PAY_ACTION_SETTLE = 0;
- const PAY_ACTION_SETTLE_CAPTURE = 1;
-
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Abstract
- */
- protected $paymentCode = 'amazonpayments_asp';
-
- /**
- * Amount model path
- */
- protected $_amountModel = 'amazonpayments/api_asp_amount';
-
- /**
- * Store id for current operation
- */
- protected $_storeId = null;
-
- /**
- * Set store id for current operation
- *
- * @param $id string
- * @return Mage_AmazonPayments_Model_Api_Asp_Abstract
- */
- public function setStoreId($id)
- {
- $this->_storeId = $id;
- return $this;
- }
-
- /**
- * Get store id for current operation
- *
- * @return string
- */
- public function getStoreId()
- {
- return $this->_storeId;
- }
-
- /**
- * Get singleton with AmazonPayments ASP Amount Model
- *
- * @return Mage_AmazonPayments_Model_Api_Asp_Amount
- */
- protected function _getAmount()
- {
- return Mage::getSingleton($this->_amountModel);
- }
-
- /**
- * Return sandbox mode flag
- *
- * @return bool
- */
- protected function _isSandbox()
- {
- return $this->_getConfig('is_sandbox');
- }
-
- /**
- * Get value from the module config
- *
- * @param string $path
- * @return string
- */
- protected function _getConfig($path)
- {
- return Mage::getStoreConfig('payment/' . $this->paymentCode . '/' . $path, $this->getStoreId());
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Amount.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Amount.php
deleted file mode 100644
index c75973857e..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Amount.php
+++ /dev/null
@@ -1,139 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Amount
-{
- /*
- * Amount value
- */
- private $_value;
-
- /*
- * Amount currency code
- */
- private $_currencyCode;
-
- /*
- * Template union amount
- */
- protected $_amountStringTemplate = "/^([A-Z]{3})\s([0-9]{1,}|[0-9]{1,}[.][0-9]{1,})$/";
-
- /*
- * Template amount value
- */
- protected $_valueStringTemplate = "/^([0-9]{1,}|[0-9]{1,}[.][0-9]{1,})$/";
-
- /*
- * Template amount currency code
- */
- protected $_currencyCodeStringTemplate = "/^([A-Z]{3})$/";
-
- /**
- * Init object
- *
- * @param string $amount - union amount
- * @return Mage_AmazonPayments_Model_Api_Asp_Amount
- */
- public function init($amount)
- {
- $tmpArr = array();
- if (!preg_match($this->_amountStringTemplate, $amount, $tmpArr)) {
- return false;
- }
- $this->_value = $tmpArr[2];
- $this->_currencyCode = $tmpArr[1];
- return $this;
- }
-
- /**
- * Set amount value
- *
- * @param string $value
- * @return Mage_AmazonPayments_Model_Api_Asp_Amount
- */
- public function setValue($value)
- {
- $tmpArr = array();
- if (!preg_match($this->_valueStringTemplate, $value, $tmpArr)) {
- return false;
- }
- $this->_value = $tmpArr[1];
- return $this;
- }
-
- /**
- * Set amount currency code
- *
- * @param string $currencyCode
- * @return Mage_AmazonPayments_Model_Api_Asp_Amount
- */
- public function setCurrencyCode($currencyCode)
- {
- $tmpArr = array();
- if (!preg_match($this->_currencyCodeStringTemplate, $currencyCode, $tmpArr)) {
- return false;
- }
- $this->_currencyCode = $tmpArr[1];
- return $this;
- }
-
- /**
- * Get amount value
- *
- * @return string
- */
- public function getValue()
- {
- return $this->_value;
- }
-
- /**
- * Get amount currency code
- *
- * @return string
- */
- public function getCurrencyCode()
- {
- return $this->_currencyCode;
- }
-
- /**
- * Return union amount string
- *
- * @return string
- */
- public function toString()
- {
- return $this->getCurrencyCode() . ' ' . $this->getValue();
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps.php
deleted file mode 100644
index 3e67d10a1e..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps.php
+++ /dev/null
@@ -1,217 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps extends Mage_AmazonPayments_Model_Api_Asp_Abstract
-{
- /*
- * Amazon FPS version protocol
- */
- const SERVICE_VERSION = '2008-09-17';
-
- /*
- * FPS action codes
- */
- const ACTION_CODE_CANCEL = 'Cancel';
- const ACTION_CODE_SETTLE = 'Settle';
- const ACTION_CODE_REFUND = 'Refund';
-
- /*
- * Exeption identifiers
- */
- const EXCEPTION_INVALID_ACTION_CODE = 10031;
- const EXCEPTION_INVALID_REQUEST = 10031;
- const EXCEPTION_INVALID_RESPONSE = 10032;
-
- /**
- * Return FPS request model
- *
- * @param string $actionCode
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- */
- public function getRequest($actionCode)
- {
- switch ($actionCode) {
- case self::ACTION_CODE_CANCEL:
- $requestModelPath = 'amazonpayments/api_asp_fps_request_cancel';
- break;
- case self::ACTION_CODE_SETTLE:
- $requestModelPath = 'amazonpayments/api_asp_fps_request_settle';
- break;
- case self::ACTION_CODE_REFUND:
- $requestModelPath = 'amazonpayments/api_asp_fps_request_refund';
- break;
- default: $this->_throwExeptionInvalidActionCode();
- }
-
- return Mage::getSingleton($requestModelPath)->init($actionCode);
- }
-
- /**
- * Return FPS response model for response body
- *
- * @param string $requestActionCode
- * @param string $responseBody
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- protected function _getResponse($requestActionCode, $responseBody)
- {
- switch ($requestActionCode) {
- case self::ACTION_CODE_CANCEL:
- $responseModelPath = 'amazonpayments/api_asp_fps_response_cancel';
- break;
- case self::ACTION_CODE_SETTLE:
- $responseModelPath = 'amazonpayments/api_asp_fps_response_settle';
- break;
- case self::ACTION_CODE_REFUND:
- $responseModelPath = 'amazonpayments/api_asp_fps_response_refund';
- break;
- default: $this->_throwExeptionInvalidActionCode();
- }
-
- $actionResponse = Mage::getSingleton($responseModelPath);
- if ($actionResponse->init($responseBody)) {
- return $actionResponse;
- }
-
- $errorResponse = Mage::getSingleton('amazonpayments/api_asp_fps_response_error');
- if ($errorResponse->init($responseBody)) {
- return $errorResponse;
- }
-
- throw new Exception(
- Mage::helper('amazonpayments')->__('Response body is not valid FPS respons'),
- self::EXCEPTION_INVALID_RESPONSE
- );
- }
-
- /**
- * Process FPS request
- *
- * @param object Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract $request
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- public function process($request)
- {
- if (!$request->isValid()) {
- throw new Exception(
- Mage::helper('amazonpayments')->__('Invalid request'),
- self::EXCEPTION_INVALID_REQUEST
- );
- }
-
- $request = $this->_addRequiredParameters($request);
- $request = $this->_signRequest($request);
-
- $responseBody = $this->_call($this->_getServiceUrl(), $request->getData());
- return $this->_getResponse($request->getActionCode(), $responseBody);
- }
-
- /**
- * Return Amazon FPS service url
- *
- * @return string
- */
- protected function _getServiceUrl()
- {
- if ($this->_isSandbox()) {
- return $this->_getConfig('fps_service_url_sandbox');
- }
- return $this->_getConfig('fps_service_url');
- }
-
- /**
- * Add required params to FPS request
- *
- * @param object Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- */
- protected function _addRequiredParameters($request)
- {
- return $request->setData('AWSAccessKeyId', $this->_getConfig('access_key'))
- ->setData('Timestamp', gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()))
- ->setData('Version', self::SERVICE_VERSION)
- ->setData('SignatureVersion', '1');
- }
-
- /**
- * Add signature param to FPS request
- *
- * @param object Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- */
- protected function _signRequest($request)
- {
- $signature = $this->_getSignatureForArray($request->getData(), $this->_getConfig('secret_key'));
- return $request->setData('Signature', $signature);
- }
-
- /**
- * Send request to Amazon FPS service and return response body
- *
- * @param string $serviceUrl
- * @param array $params
- * @return Varien_Simplexml_Element
- */
- protected function _call($serviceUrl, $params)
- {
- $tmpArray = array();
- foreach ($params as $kay => $value) {
- $tmpArray[] = $kay . '=' . urlencode($value);
- }
- $requestBody = implode('&', $tmpArray);
-
- $http = new Varien_Http_Adapter_Curl();
- $http->setConfig(array('timeout' => 30));
- $http->write(Zend_Http_Client::POST, $serviceUrl, '1.1', array(), $requestBody);
-
- $responseBody = $http->read();
- $responseBody = preg_split('/^\r?$/m', $responseBody, 2);
- $responseBody = trim($responseBody[1]);
-
- $responseBody = new Varien_Simplexml_Element($responseBody);
-
- $http->close();
- return $responseBody;
- }
-
- /**
- * Throw exeption: Invalid action code
- */
- protected function _throwExeptionInvalidActionCode()
- {
- throw new Exception(
- Mage::helper('amazonpayments')->__('Invalid action code'),
- self::EXCEPTION_INVALID_ACTION_CODE
- );
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Abstract.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Abstract.php
deleted file mode 100644
index c15a596686..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Abstract.php
+++ /dev/null
@@ -1,86 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract extends Varien_Object
-{
- /*
- * Request action code
- */
- private $_actionCode;
-
- /**
- * Init object
- *
- * @param string $actionCode
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- */
- public function init($actionCode)
- {
- if (is_null($this->_actionCode)) {
- $this->_actionCode = $actionCode;
- $this->initDefaultParams();
- }
- return $this;
- }
-
- /**
- * Init default request params
- */
- protected function initDefaultParams()
- {
- $this->setData('Action', $this->getActionCode());
- }
-
- /**
- * Return request action code
- *
- * @return string
- */
- public function getActionCode()
- {
- return $this->_actionCode;
- }
-
- /**
- * Validation request params
- *
- * @return bool
- */
- public function isValid()
- {
- if (!$this->getData('Action')) {
- return false;
- }
- return true;
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Cancel.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Cancel.php
deleted file mode 100644
index 95e2107e7c..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Cancel.php
+++ /dev/null
@@ -1,68 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Cancel extends Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
-{
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- */
- public function isValid()
- {
- if (!$this->getData('TransactionId')) {
- return false;
- }
- return parent::isValid();
- }
-
- /**
- * Set request TransactionId
- *
- * @param string $transactionId
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Cancel
- */
- public function setTransactionId($transactionId)
- {
- return $this->setData('TransactionId', $transactionId);
- }
-
- /**
- * Set request Description
- *
- * @param string $description
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Cancel
- */
- public function setDescription($description)
- {
- return $this->setData('Description', $description);
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Refund.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Refund.php
deleted file mode 100644
index 1dafbd5bb3..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Refund.php
+++ /dev/null
@@ -1,92 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Refund extends Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
-{
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- */
- public function isValid()
- {
- if (!$this->getData('TransactionId') ||
- !$this->getData('CallerReference')) {
- return false;
- }
- return parent::isValid();
- }
-
- /**
- * Set request transactionId
- *
- * @param string $transactionId
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Refund
- */
- public function setTransactionId($transactionId)
- {
- return $this->setData('TransactionId', $transactionId);
- }
-
- /**
- * Set request referenceId
- *
- * @param string $referenceId
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Refund
- */
- public function setReferenceId($referenceId)
- {
- return $this->setData('CallerReference', $referenceId);
- }
-
- /**
- * Set request description
- *
- * @param string $description
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Refund
- */
- public function setDescription($description)
- {
- return $this->setData('CallerDescription', $description);
- }
-
- /**
- * Set request amount
- *
- * @param Mage_AmazonPayments_Model_Api_Asp_Amount $amount
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Refund
- */
- public function setAmount($amount)
- {
- return $this->setData('RefundAmount.Value', $amount->getValue())
- ->setData('RefundAmount.CurrencyCode', $amount->getCurrencyCode());
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Settle.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Settle.php
deleted file mode 100644
index 1031c32045..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Request/Settle.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Settle extends Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
-{
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Abstract
- */
- public function isValid()
- {
- if (!$this->getData('ReserveTransactionId')) {
- return false;
- }
- return parent::isValid();
- }
-
- /**
- * Set request transactionId
- *
- * @param string $transactionId
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Settle
- */
- public function setTransactionId($transactionId)
- {
- return $this->setData('ReserveTransactionId', $transactionId);
- }
-
- /**
- * Set request amount
- *
- * @param Mage_AmazonPayments_Model_Api_Asp_Amount $amount
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Request_Settle
- */
- public function setAmount($amount)
- {
- return $this->setData('TransactionAmount.Value', $amount->getValue())
- ->setData('TransactionAmount.CurrencyCode', $amount->getCurrencyCode());
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Abstract.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Abstract.php
deleted file mode 100644
index 4dc7a2e7e9..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Abstract.php
+++ /dev/null
@@ -1,107 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract extends Varien_Object
-{
- /*
- * Response statuses
- */
- const STATUS_CANCELLED = 'Cancelled';
- const STATUS_FAILURE = 'Failure';
- const STATUS_PENDING = 'Pending';
- const STATUS_RESERVED = 'Reserved';
- const STATUS_SUCCESS = 'Success';
- const STATUS_ERROR = 'Error';
-
- /**
- * Init object
- *
- * @param Varien_Simplexml_Element $responseBody
- * @return Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- public function init($responseBody)
- {
- if (!$this->parse($responseBody)) {
- return false;
- }
- return $this;
- }
-
- /**
- * Parse response body
- *
- * @param Varien_Simplexml_Element $responseBody
- * @return bool
- */
- protected function parse($responseBody)
- {
- $responseId = (string)$responseBody->ResponseMetadata->RequestId;
- if($responseId == '') {
- return false;
- }
- $this->setData('Id', $responseId);
-
- if (!$status = $this->getData('Status')) {
- return false;
- }
- if ($status != self::STATUS_CANCELLED &&
- $status != self::STATUS_FAILURE &&
- $status != self::STATUS_PENDING &&
- $status != self::STATUS_RESERVED &&
- $status != self::STATUS_SUCCESS) {
- return false;
- }
- return true;
- }
-
- /**
- * Return status of respons
- *
- * @return string
- */
- public function getStatus()
- {
- return $this->getData('Status');
- }
-
- /**
- * Return response ID
- *
- * @return string
- */
- public function getId()
- {
- return $this->getData('Id');
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Cancel.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Cancel.php
deleted file mode 100644
index 6b8f1c15a7..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Cancel.php
+++ /dev/null
@@ -1,67 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Cancel extends Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
-{
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- protected function parse($responseBody)
- {
- if ($responseBody->getName() != 'CancelResponse') {
- return false;
- }
-
- $transactionId = (string)$responseBody->CancelResult->TransactionId;
- $transactionStatus = (string)$responseBody->CancelResult->TransactionStatus;
-
- if($transactionId == '' || $transactionStatus == '') {
- return false;
- }
-
- $this->setData('TransactionId', $transactionId);
- $this->setData('Status', $transactionStatus);
-
- return parent::parse($responseBody);
- }
-
- /**
- * Return response TransactionId
- *
- * @return string
- */
- public function getTransactionId()
- {
- return $this->getData('TransactionId');
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Error.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Error.php
deleted file mode 100644
index df77e46fff..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Error.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Error extends Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
-{
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- protected function parse($responseBody)
- {
- if ($responseBody->getName() != 'Response') {
- return false;
- }
-
- $code = (string)$responseBody->Errors->Error->Code;
- $message = (string)$responseBody->Errors->Error->Message;
- $responseId = (string)$responseBody->RequestID;
-
- if($code == '' || $message == '' || $responseId == '') {
- return false;
- }
-
- $this->setData('Id', $responseId);
- $this->setData('Status', parent::STATUS_ERROR);
- $this->setData('Code', $code);
- $this->setData('Message', $message);
- return true;
- }
-
- /**
- * Return response Code
- *
- * @return string
- */
- public function getCode()
- {
- return $this->getData('Code');
- }
-
- /**
- * Return response Message
- *
- * @return string
- */
- public function getMessage()
- {
- return $this->getData('Message');
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Refund.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Refund.php
deleted file mode 100644
index 96cb6807c4..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Refund.php
+++ /dev/null
@@ -1,67 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Refund extends Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
-{
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- protected function parse($responseBody)
- {
- if ($responseBody->getName() != 'RefundResponse') {
- return false;
- }
-
- $transactionId = (string)$responseBody->RefundResult->TransactionId;
- $transactionStatus = (string)$responseBody->RefundResult->TransactionStatus;
-
- if($transactionId == '' || $transactionStatus == '') {
- return false;
- }
-
- $this->setData('TransactionId', $transactionId);
- $this->setData('Status', $transactionStatus);
-
- return parent::parse($responseBody);
- }
-
- /**
- * Return response TransactionId
- *
- * @return string
- */
- public function getTransactionId()
- {
- return $this->getData('TransactionId');
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Settle.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Settle.php
deleted file mode 100644
index 37ab8772fc..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Fps/Response/Settle.php
+++ /dev/null
@@ -1,68 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Settle extends Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
-{
- /**
- * rewrited for Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract
- */
- protected function parse($responseBody)
- {
- if ($responseBody->getName() != 'SettleResponse') {
- return false;
- }
-
- $transactionId = (string)$responseBody->SettleResult->TransactionId;
- $transactionStatus = (string)$responseBody->SettleResult->TransactionStatus;
-
- if($transactionId == '' || $transactionStatus == '') {
- return false;
- }
-
- $this->setData('TransactionId', $transactionId);
- $this->setData('Status', $transactionStatus);
-
- return parent::parse($responseBody);
- }
-
- /**
- * Return response TransactionId
- *
- * @return string
- */
- public function getTransactionId()
- {
- return $this->getData('TransactionId');
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Ipn/Request.php b/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Ipn/Request.php
deleted file mode 100644
index 8899d96cf0..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Asp/Ipn/Request.php
+++ /dev/null
@@ -1,215 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Asp_Ipn_Request extends Varien_Object
-{
- /*
- * Status request
- */
- const STATUS_CANCEL_CUSTOMER = 'A';
- const STATUS_CANCEL_TRANSACTION = 'CANCELLED';
- const STATUS_RESERVE_SUCCESSFUL = 'PR';
- const STATUS_PAYMENT_INITIATED = 'PI';
- const STATUS_PAYMENT_SUCCESSFUL = 'PS';
- const STATUS_PAYMENT_FAILED = 'PF';
- const STATUS_REFUND_SUCCESSFUL = 'RS';
- const STATUS_REFUND_FAILED = 'RF';
- const STATUS_SYSTEM_ERROR = 'SE';
-
- /*
- * Request params
- */
- private $requestParams;
-
- /**
- * Init object
- *
- * @param array $requestParams
- * @return Mage_AmazonPayments_Model_Api_Asp_Ipn_Request
- */
- public function init($requestParams)
- {
- if (!$this->_validateRequestParams($requestParams)) {
- return false;
- }
- $this->requestParams = $requestParams;
- $this->_setRequestParamsToData($this->_convertRequestParams($requestParams));
- return $this;
- }
-
- /**
- * Validate request params
- *
- * @param array $requestParams
- * @return bool
- */
- private function _validateRequestParams($requestParams)
- {
- if (!isset($requestParams['transactionAmount']) ||
- !isset($requestParams['transactionDate']) ||
- !isset($requestParams['status'])) {
- return false;
- }
-
- $statusCode = $requestParams['status'];
- if ($statusCode != self::STATUS_CANCEL_CUSTOMER &&
- $statusCode != self::STATUS_CANCEL_TRANSACTION &&
- $statusCode != self::STATUS_RESERVE_SUCCESSFUL &&
- $statusCode != self::STATUS_PAYMENT_INITIATED &&
- $statusCode != self::STATUS_PAYMENT_SUCCESSFUL &&
- $statusCode != self::STATUS_PAYMENT_FAILED &&
- $statusCode != self::STATUS_REFUND_SUCCESSFUL &&
- $statusCode != self::STATUS_REFUND_FAILED &&
- $statusCode != self::STATUS_SYSTEM_ERROR) {
- return false;
- }
-
- if ($statusCode != self::STATUS_CANCEL_TRANSACTION &&
- !isset($requestParams['referenceId'])){
- return false;
- }
-
- if (($statusCode == self::STATUS_RESERVE_SUCCESSFUL ||
- $statusCode == self::STATUS_PAYMENT_SUCCESSFUL ||
- $statusCode == self::STATUS_REFUND_SUCCESSFUL) &&
- !isset($requestParams['transactionId'])) {
- return false;
- }
-
- if (!$this->_convertAmount($requestParams['transactionAmount'])) {
- return false;
- }
-
- if ($requestParams['status'] == self::STATUS_REFUND_SUCCESSFUL ||
- $requestParams['status'] == self::STATUS_REFUND_FAILED) {
- if (!$this->_convertReferenceId($requestParams['referenceId'])) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * convert request params
- *
- * @param array $requestParams
- * @return array
- */
- private function _convertRequestParams($requestParams)
- {
- $_tmpResultArray = $this->_convertAmount($requestParams['transactionAmount']);
- unset($requestParams['transactionAmount']);
- $requestParams = array_merge($requestParams, $_tmpResultArray);
-
- if ($requestParams['status'] == self::STATUS_REFUND_SUCCESSFUL ||
- $requestParams['status'] == self::STATUS_REFUND_FAILED) {
- $requestParams['referenceId'] = $this->_convertReferenceId($requestParams['referenceId']);
- }
-
- $requestParams['transactionDate'] = $this->_convertTransactionDate($requestParams['transactionDate']);
-
- return $requestParams;
- }
-
-
- /**
- * convert union amount string to amount value and amount currency code
- *
- * @param string $requestAmount
- * @return Mage_AmazonPayments_Model_Api_Asp_Amount
- */
- private function _convertAmount($requestAmount)
- {
- $amount = Mage::getSingleton('amazonpayments/api_asp_amount');
- if (!$amount->init($requestAmount)) {
- return false;
- }
-
- $resultArray = array();
- $resultArray['amount'] = $amount->getValue();
- $resultArray['currencyCode'] = $amount->getCurrencyCode();
- return $resultArray;
- }
-
- /**
- * convert peferenceId request param
- *
- * @param string $referenceId
- * @return string
- */
- private function _convertReferenceId($referenceId)
- {
- $tmpArr = array();
- if (!preg_match("/^Refund\sfor\s([0-9]{9})$/", $referenceId, $tmpArr)) {
- return false;
- }
- return $tmpArr[1];
- }
-
- /**
- * convert TransactionDate request param
- *
- * @param string $transactionDate
- * @return string
- */
- private function _convertTransactionDate($transactionDate)
- {
- return Mage::app()->getLocale()->date($transactionDate);
- }
-
- /**
- * set request params to object date
- *
- * @param array $requestParams
- */
- private function _setRequestParamsToData($requestParams)
- {
- foreach ($requestParams as $kay => $value) {
- $setMethodName = 'set' . ucfirst($kay);
- $this->$setMethodName($value);
- }
- }
-
- /**
- * rewrited for Varien_Object
- */
- public function toString($format='')
- {
- $resultString = '';
- foreach($this->getData() as $kay => $value){
- $resultString .= "[$kay] = $value ";
- }
- return $resultString;
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Cba.php b/app/code/core/Mage/AmazonPayments/Model/Api/Cba.php
deleted file mode 100644
index 73deced0a9..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Cba.php
+++ /dev/null
@@ -1,1007 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Cba extends Mage_AmazonPayments_Model_Api_Abstract
-{
- protected static $HMAC_SHA1_ALGORITHM = "sha1";
- protected $_paymentCode = 'amazonpayments_cba';
-
- protected $_carriers;
- protected $_address;
-
- const STANDARD_SHIPMENT_RATE = 'Standard';
- const EXPEDITED_SHIPMENT_RATE = 'Expedited';
- const ONEDAY_SHIPMENT_RATE = 'OneDay';
- const TWODAY_SHIPMENT_RATE = 'TwoDay';
-
- protected $_shippingRates = array(
- self::STANDARD_SHIPMENT_RATE,
- self::EXPEDITED_SHIPMENT_RATE,
- self::ONEDAY_SHIPMENT_RATE,
- self::TWODAY_SHIPMENT_RATE,
- );
-
- protected $_configShippingRates = null;
-
- /**
- * Return Merchant Id from config
- *
- * @return string
- */
- public function getMerchantId()
- {
- return Mage::getStoreConfig('payment/amazonpayments_cba/merchant_id');
- }
-
- /**
- * Return action url for CBA Cart form to Amazon
- *
- * @return unknown
- */
- public function getAmazonRedirectUrl()
- {
- #$_url = $this->getCbaPaymentUrl();
- $_url = $this->getPayServiceUrl();
- $_merchantId = Mage::getStoreConfig('payment/amazonpayments_cba/merchant_id');
- return $_url.$_merchantId;
- }
-
- public function getConfigShippingRates()
- {
- if (is_null($this->_configShippingRates)) {
- $this->_configShippingRates = array();
- foreach ($this->_shippingRates as $_rate) {
- $_carrier = unserialize(Mage::getStoreConfig('payment/amazonpayments_cba/' . strtolower($_rate) . '_rate'));
- if ($_carrier['method'] && $_carrier['method'] != 'None') {
- $_carrierInfo = explode('/', $_carrier['method']);
- $this->_configShippingRates[$_rate] = array(
- 'carrier' => $_carrierInfo[0],
- 'method' => $_carrierInfo[1]
- );
- }
- }
- }
- return $this->_configShippingRates;
- }
-
- /**
- * Computes RFC 2104-compliant HMAC signature.
- *
- * @param data Array
- * The data to be signed.
- * @param key String
- * The signing key, a.k.a. the AWS secret key.
- * @return The base64-encoded RFC 2104-compliant HMAC signature.
- */
- public function calculateSignature($data, $secretKey)
- {
- $stringData = '';
- if (is_array($data)) {
- ksort($data);
- foreach ($data as $key => $value) {
- $stringData .= $key.'='.rawurlencode($value).'&';
- }
- } elseif (is_string($data)) {
- $stringData = $data;
- } else {
- $stringData = $data;
- }
-
- // compute the hmac on input data bytes, make sure to set returning raw hmac to be true
- $rawHmac = hash_hmac(self::$HMAC_SHA1_ALGORITHM, $stringData, $secretKey, true);
-
- // base64-encode the raw hmac
- return base64_encode($rawHmac);
- }
-
- /**
- * Format amount value (2 digits after the decimal point)
- *
- * @param float $amount
- * @return float
- */
- public function formatAmount($amount)
- {
- return Mage::helper('amazonpayments')->formatAmount($amount);
- }
-
- /**
- * Build XML-based Cart for Checkout by Amazon
- *
- * @param Mage_Sales_Model_Quote
- * @return string
- */
- public function getXmlCart(Mage_Sales_Model_Quote $quote)
- {
- $_xml = ''."\n"
- .''."\n";
- if (!$quote->hasItems()) {
- return false;
- }
- $_xml .= " {$quote->getId()} \n"; // Returning parametr
- # ." ";
-
- $_xml .= " \n"
- ." \n";
-
- foreach ($quote->getAllVisibleItems() as $_item) {
- $_xml .= " - \n"
- ."
{$_item->getSku()}/{$_item->getId()} \n"
- ." {$this->getMerchantId()} \n"
- ." {$_item->getName()} \n"
- ." \n"
- ." {$this->formatAmount($_item->getPrice())} \n"
- ." {$quote->getBaseCurrencyCode()} \n"
- ." \n"
- ." {$_item->getQty()} \n"
- ." \n"
- ." {$this->formatAmount($_item->getWeight())} \n"
- ." lb \n"
- ." \n";
- $_xml .= " \n";
-
- }
- $_xml .= " \n"
- ." cart-total-discount \n"
- ." \n";
-
- $_xml .= " A2ZZYWSJ0WMID8MAGENTO \n"
- ." Varien \n";
- $_xml .= " \n"
- ." true \n"
- ." true \n"
- ." true \n"
- ." ".Mage::getUrl('amazonpayments/cba/callback', array('_secure' => true))." \n"
- ." true \n"
- ." \n";
-
- $_xml .= " \n";
- return $_xml;
-
- }
-
- /**
- * Retreive checkout tax tables xml
- *
- * @param Mage_Sales_Model_Quote $quote
- * @return string
- */
- protected function _getCheckoutTaxXml(Mage_Sales_Model_Quote $quote)
- {
- $xml = '';
-
- // shipping tax table (used as default, because we have no ability to specify shipping tax table)
- //$xml .= $this->_getTaxTablesXml($quote, $this->_getShippingTaxRules($quote), true);
- // removed because of no ability to use default tax table as shipping tax table
-
- $xml .= "\n";
-
- // item tax tables
- $xml .= $this->_getTaxTablesXml($quote, $this->_getTaxRules($quote));
-
- // empty tax table for products without tax class
- $xml .= " \n"
- ." none \n"
- ." \n"
- ." \n"
- ." 0 \n"
- ." WorldAll \n"
- ." \n"
- ." \n"
- ." \n";
-
- $xml .= " \n";
-
-
- return $xml;
- }
-
- /**
- * Retreive specified tax rates xml
- *
- * @param Mage_Sales_Model_Quote $quote
- * @param array $rates
- * @param string $type
- * @param mixed $addTo
- * @return string
- */
- protected function _getTaxTablesXml($quote, $rules, $isShipping = false, $addTo = null)
- {
- $xml = '';
- if ($isShipping) {
- $isShippingTaxed = 'true';
- $taxTableTag = 'DefaultTaxTable';
- } else {
- $isShippingTaxed = 'false';
- $taxTableTag = 'TaxTable';
- }
-
- if (is_array($rules)) {
- if ($addTo) {
- $_tables = $addTo->addChild('TaxTables');
- }
-
- foreach ($rules as $group=>$taxRates) {
- $isShippingTaxed = ($isShipping ? 'true' : 'false');
- if ($isShipping) {
- $tableName = 'default-tax-table';
- } else {
- $tableName = "tax_{$group}";
- if ($group == $this->_getShippingTaxClassId($quote)) {
- $isShippingTaxed = 'true';
- }
- }
- if ($addTo) {
- // $_tables = $addTo->addChild('TaxTables');
- $_table = $_tables->addChild($taxTableTag);
- $_table->addChild('TaxTableId', $tableName);
- $_rules = $_table->addChild('TaxRules');
- } else {
- $xml .= " <{$taxTableTag}>\n";
- $xml .= " {$tableName} \n";
- $xml .= " \n";
- }
-
- if (is_array($taxRates)) {
- foreach ($taxRates as $rate) {
- if ($addTo) {
- $_rule = $_rules->addChild('TaxRule');
- $_rule->addChild('Rate', $rate['value']);
- $_rule->addChild('IsShippingTaxed', $isShippingTaxed);
- } else {
- $xml .= " \n";
- $xml .= " {$rate['value']} \n";
- $xml .= " {$isShippingTaxed} \n";
- }
-
- if ($rate['country']==='US') {
- if (!empty($rate['postcode']) && $rate['postcode']!=='*') {
- if ($addTo) {
- $_rule->addChild('USZipRegion', $rate['postcode']);
- } else {
- $xml .= " {$rate['postcode']} \n";
- }
- } else if (!empty($rate['state']) && $rate['state']!=='*') {
- if ($addTo) {
- $_rule->addChild('USStateRegion', $rate['state']);
- } else {
- $xml .= " {$rate['state']} \n";
- }
- } else {
- if ($addTo) {
- $_rule->addChild('PredefinedRegion', 'USAll');
- } else {
- $xml .= " USAll \n";
- }
- }
- } else {
- if ($addTo) {
- $_region = $_rule->addChild('WorldRegion');
- $_region->addChild('CountryCode', $rate['country']);
- if (!empty($rate['postcode']) && $rate['postcode']!=='*') {
- $_region->addChild('PostalRegion', $rate['postcode']);
- }
- } else {
- $xml .= " \n";
- $xml .= " {$rate['country']} \n";
- if (!empty($rate['postcode']) && $rate['postcode']!=='*') {
- $xml .= " {$rate['postcode']} \n";
- }
- $xml .= " \n";
- }
- }
-
- $xml .= " \n";
- }
- } else {
- $taxRate = $taxRates/100;
- if ($addTo) {
- $_rule = $_rules->addChild('TaxRule');
- $_rule->addChild('Rate', $taxRate);
- $_rule->addChild('IsShippingTaxed', $isShippingTaxed);
- $_rule->addChild('PredefinedRegion', 'WorldAll');
- } else {
- $xml .= " \n";
- $xml .= " {$taxRate} \n";
- $xml .= " {$isShippingTaxed} \n";
- $xml .= " WorldAll \n";
- $xml .= " \n";
- }
- }
-
- $xml .= " \n";
- $xml .= " {$taxTableTag}>\n";
- }
-
- } else {
- if (is_numeric($rules)) {
- $taxRate = $rules/100;
-
- if ($addTo) {
- $_table = $addTo->addChild($taxTableTag);
- $_rules = $_table->addChild('TaxRules');
- $_rule = $_rules->addChild('TaxRule');
- $_rule->addChild('Rate', $taxRate);
- $_rule->addChild('IsShippingTaxed', $isShippingTaxed);
- $_rule->addChild('PredefinedRegion', 'WorldAll');
- } else {
- $xml .= " <{$taxTableTag}>\n";
- $xml .= " \n";
- $xml .= " \n";
- $xml .= " {$taxRate} \n";
- $xml .= " {$isShippingTaxed} \n";
- $xml .= " WorldAll \n";
- $xml .= " \n";
- $xml .= " \n";
- $xml .= " {$taxTableTag}>\n";
- }
- }
- }
-
- if ($addTo) {
- return $addTo;
- }
-
- return $xml;
- }
-
-
- /**
- * Retreive tax rules applicable to quote items
- *
- * @param Mage_Sales_Model_Quote $quote
- * @return array
- */
- protected function _getTaxRules(Mage_Sales_Model_Quote $quote)
- {
- $customerTaxClass = $this->_getCustomerTaxClass($quote);
- if (Mage::helper('tax')->getTaxBasedOn() == 'origin') {
- $request = Mage::getSingleton('tax/calculation')->getRateRequest();
- return Mage::getSingleton('tax/calculation')->getRatesForAllProductTaxClasses($request->setCustomerClassId($customerTaxClass));
- } else {
- $customerRules = Mage::getSingleton('tax/calculation')->getRatesByCustomerTaxClass($customerTaxClass);
- $rules = array();
- foreach ($customerRules as $rule) {
- $rules[$rule['product_class']][] = $rule;
- }
- return $rules;
- }
- }
-
- /**
- * Retreive tax rules applicable to shipping
- *
- * @param Mage_Sales_Model_Quote $quote
- * @return array
- */
- protected function _getShippingTaxRules(Mage_Sales_Model_Quote $quote)
- {
- $customerTaxClass = $this->_getCustomerTaxClass($quote);
- if ($shippingTaxClass = $this->_getShippingTaxClassId($quote)) {
- if (Mage::helper('tax')->getTaxBasedOn() == 'origin') {
- $request = Mage::getSingleton('tax/calculation')->getRateRequest();
- $request
- ->setCustomerClassId($customerTaxClass)
- ->setProductClassId($shippingTaxClass);
-
- return Mage::getSingleton('tax/calculation')->getRate($request);
- }
- $customerRules = Mage::getSingleton('tax/calculation')->getRatesByCustomerAndProductTaxClasses($customerTaxClass, $shippingTaxClass);
- $rules = array();
- foreach ($customerRules as $rule) {
- $rules[$rule['product_class']][] = $rule;
- }
- return $rules;
- } else {
- return array();
- }
- }
-
- /**
- * Retreive shipping tax class
- *
- * @param Mage_Sales_Model_Quote $quote
- * @return int
- */
- protected function _getShippingTaxClassId(Mage_Sales_Model_Quote $quote)
- {
- return Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $quote->getStoreId());
- }
-
- /**
- * Retreive customer tax class from quote
- *
- * @param Mage_Sales_Model_Quote $quote
- * @return int
- */
- protected function _getCustomerTaxClass(Mage_Sales_Model_Quote $quote)
- {
- $customerGroup = $quote->getCustomerGroupId();
- if (!$customerGroup) {
- $customerGroup = Mage::getStoreConfig('customer/create_account/default_group', $quote->getStoreId());
- }
- return Mage::getModel('customer/group')->load($customerGroup)->getTaxClassId();
- }
-
- /**
- * Handle Callback from CBA and calculate Shipping, Taxes in case XML-based shopping cart
- *
- */
- public function handleXmlCallback($xmlRequest, $session)
- {
- $_address = $this->_parseRequestAddress($xmlRequest);
-
- #$quoteId = $session->getAmazonQuoteId();
- $quoteId = $_address['ClientRequestId'];
- $quote = Mage::getModel('sales/quote')->load($quoteId);
-
- $baseCurrency = $session->getQuote()->getBaseCurrencyCode();
- $currency = Mage::app()->getStore($session->getQuote()->getStoreId())->getBaseCurrency();
-
- $billingAddress = $quote->getBillingAddress();
- $address = $quote->getShippingAddress();
-
- $this->_address = $_address;
-
- $regionModel = Mage::getModel('directory/region')->loadByCode($_address['regionCode'], $_address['countryCode']);
- $_regionId = $regionModel->getId();
-
- $address->setCountryId($_address['countryCode'])
- ->setRegion($_address['regionCode'])
- ->setRegionId($_regionId)
- ->setCity($_address['city'])
- ->setStreet($_address['street'])
- ->setPostcode($_address['postCode']);
- $billingAddress->setCountryId($_address['countryCode'])
- ->setRegion($_address['regionCode'])
- ->setRegionId($_regionId)
- ->setCity($_address['city'])
- ->setStreet($_address['street'])
- ->setPostcode($_address['postCode']);
-
- $quote->setBillingAddress($billingAddress);
- $quote->setShippingAddress($address);
- $quote->save();
-
- $address->setCollectShippingRates(true)->collectShippingRates();
-
- $errors = array();
- $_carriers = array();
- foreach ($this->getConfigShippingRates() as $_cfgRate) {
- if ($carrier = Mage::getStoreConfig('carriers/' . $_cfgRate['carrier'], $this->getStoreId())) {
- if (isset($carrier['title']) && $carrier['active'] && !in_array($_cfgRate['carrier'], $_carriers)) {
- $_carriers[] = $_cfgRate['carrier'];
- }
- }
- }
-
- $result = Mage::getModel('shipping/shipping')
- ->collectRatesByAddress($address, $_carriers)
- ->getResult();
- $rateCodes = array();
- foreach ($this->getConfigShippingRates() as $_cfgRateLevel => $_cfgRate) {
- if ($rates = $result->getRatesByCarrier($_cfgRate['carrier'])) {
- foreach ($rates as $rate) {
- if (!$rate instanceof Mage_Shipping_Model_Rate_Result_Error && $rate->getMethod() == $_cfgRate['method']) {
- if ($address->getFreeShipping()) {
- $price = 0;
- } else {
- $price = $rate->getPrice();
- }
- if ($price) {
- $price = Mage::helper('tax')->getShippingPrice($price, true, $address);
- }
- $this->_carriers[] = array(
- 'service_level' => $_cfgRateLevel,
- 'code' => $rate->getCarrier() . '_' . $rate->getMethod(),
- 'price' => $price,
- 'currency' => $currency['currency_code'],
- 'description' => $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle() . ' (Amazon ' . $_cfgRateLevel . ' Service Level)'
- );
- }
- }
- }
- }
-
- if ($_extShippingInfo = unserialize($quote->getExtShippingInfo())) {
- $_extShippingInfo = array_merge($_extShippingInfo, array('amazon_service_level' => $this->_carriers));
- } else {
- $_extShippingInfo = array('amazon_service_level' => $this->_carriers);
- }
- $quote->setExtShippingInfo(serialize($_extShippingInfo));
-
- $_items = $this->_parseRequestItems($xmlRequest);
- $xml = $this->_generateXmlResponse($quote, $_items);
-
- $session->getQuote()
- ->setForcedCurrency($currency)
- ->collectTotals()
- ->save();
- $quote->save();
- return $xml;
- }
-
- /**
- * Parse request from Amazon and return order details
- *
- * @param string xml
- */
- public function parseOrder($xmlData)
- {
- $parsedOrder = array();
- if (strlen(trim($xmlData)) > 0) {
- $xml = simplexml_load_string($xmlData, 'Varien_Simplexml_Element');
- $parsedOrder = array(
- 'NotificationReferenceId' => (string) $xml->descend("NotificationReferenceId"),
- 'amazonOrderID' => (string) $xml->descend("ProcessedOrder/AmazonOrderID"),
- 'orderDate' => (string) $xml->descend("ProcessedOrder/OrderDate"),
- 'orderChannel' => (string) $xml->descend("ProcessedOrder/OrderChannel"),
- 'buyerName' => (string) $xml->descend("ProcessedOrder/BuyerInfo/BuyerName"),
- 'buyerEmailAddress' => (string) $xml->descend("ProcessedOrder/BuyerInfo/BuyerEmailAddress"),
- 'ShippingLevel' => (string) $xml->descend("ProcessedOrder/ShippingServiceLevel"),
- 'shippingAddress' => array(
- 'name' => (string) $xml->descend("ProcessedOrder/ShippingAddress/Name"),
- 'street' => (string) $xml->descend("ProcessedOrder/ShippingAddress/AddressFieldOne"),
- 'city' => (string) $xml->descend("ProcessedOrder/ShippingAddress/City"),
- 'regionCode' => (string) $xml->descend("ProcessedOrder/ShippingAddress/State"),
- 'postCode' => (string) $xml->descend("ProcessedOrder/ShippingAddress/PostalCode"),
- 'countryCode' => (string) $xml->descend("ProcessedOrder/ShippingAddress/CountryCode"),
- ),
- 'items' => array(),
- );
-
- $_total = $_shipping = $_tax = $_shippingTax = $_subtotalPromo = $_shippingPromo = $_subtotal = 0;
- $_itemsCount = $_itemsQty = 0;
- foreach ($xml->descend("ProcessedOrder/ProcessedOrderItems/ProcessedOrderItem") as $_item) {
- $parsedOrder['ClientRequestId'] = (string) $_item->ClientRequestId;
- $_compositeSku = explode('/', (string) $_item->SKU);
- $_sku = '';
- if (isset($_compositeSku[0])) {
- $_sku = $_compositeSku[0];
- }
- $_itemId = '';
- if ($_compositeSku[1]) {
- $_itemId = $_compositeSku[1];
- }
- $_itemQty = (string) $_item->Quantity;
- $_itemsQty += $_itemQty;
- $_itemsCount++;
- $parsedOrder['items'][$_itemId] = array(
- 'AmazonOrderItemCode' => (string) $_item->AmazonOrderItemCode,
- 'sku' => $_sku,
- 'title' => (string) $_item->Title,
- 'price' => array(
- 'amount' => (string) $_item->Price->Amount,
- 'currencyCode' => (string) $_item->Price->CurrencyCode,
- ),
- 'qty' => $_itemQty,
- 'weight' => array(
- 'amount' => (string) $_item->Weight->Amount,
- 'unit' => (string) $_item->Weight->Unit,
- ),
- );
- $_itemSubtotal = 0;
- foreach ($_item->ItemCharges->Component as $_component) {
- switch ((string) $_component->Type) {
- case 'Principal':
- $_itemSubtotal += (string) $_component->Charge->Amount;
- $parsedOrder['items'][$_itemId]['subtotal'] = $_itemSubtotal;
- break;
- case 'Shipping':
- $_shipping += (string) $_component->Charge->Amount;
- $parsedOrder['items'][$_itemId]['shipping'] = (string) $_component->Charge->Amount;
- break;
- case 'Tax':
- $_tax += (string) $_component->Charge->Amount;
- $parsedOrder['items'][$_itemId]['tax'] = (string) $_component->Charge->Amount;
- break;
- case 'ShippingTax':
- $_shippingTax += (string) $_component->Charge->Amount;
- $parsedOrder['items'][$_itemId]['shipping_tax'] = (string) $_component->Charge->Amount;
- break;
- case 'PrincipalPromo':
- $_subtotalPromo += (string) $_component->Charge->Amount;
- $parsedOrder['items'][$_itemId]['principal_promo'] = (string) $_component->Charge->Amount;
- break;
- case 'ShippingPromo':
- $_shippingPromo += (string) $_component->Charge->Amount;
- $parsedOrder['items'][$_itemId]['shipping_promo'] = (string) $_component->Charge->Amount;
- break;
- }
- }
- $_subtotal += $_itemSubtotal;
- }
-
- $parsedOrder['itemsCount'] = $_itemsCount;
- $parsedOrder['itemsQty'] = $_itemsQty;
-
- $parsedOrder['subtotal'] = $_subtotal;
- $parsedOrder['shippingAmount'] = $_shipping;
- $parsedOrder['tax'] = $_tax + $_shippingTax;
- $parsedOrder['shippingTax'] = $_shippingTax;
- $parsedOrder['discount'] = $_subtotalPromo + $_shippingPromo;
- $parsedOrder['discountShipping'] = $_shippingPromo;
-
- $parsedOrder['total'] = $_subtotal + $_shipping + $_tax + $_shippingTax - abs($_subtotalPromo) - abs($_shippingPromo);
- }
- return $parsedOrder;
- }
-
- /**
- * Parsing xml notification for amazon order id
- *
- * @param string $xmlData
- * @return array
- */
- public function parseOrderReadyToShipNotification($xmlData)
- {
- $readyToShipData = array();
- if (strlen(trim($xmlData))) {
- $xml = simplexml_load_string($xmlData, 'Varien_Simplexml_Element');
- $aOrderId = (string) $xml->descend('ProcessedOrder/AmazonOrderID');
- $readyToShipData['amazon_order_id'] = $aOrderId;
- $readyToShipData['items'] = array();
- foreach ($xml->descend('ProcessedOrder/ProcessedOrderItems/ProcessedOrderItem') as $item) {
- $readyToShipData['items'][(string)$item->AmazonOrderItemCode] = (string)$item->Quantity;
- }
- }
- return $readyToShipData;
- }
-
- public function parseCancelNotification($xmlData)
- {
- $cancelData = array();
- if (strlen(trim($xmlData))) {
- $xml = simplexml_load_string($xmlData, 'Varien_Simplexml_Element');
- $aOrderId = (string) $xml->descend('ProcessedOrder/AmazonOrderID');
- $cancelData['amazon_order_id'] = $aOrderId;
- }
- return $cancelData;
- }
-
- /**
- * Return address from Amazon request
- *
- * @param array $responseArr
- */
- protected function _parseRequestAddress($xmlResponse)
- {
- $address = array();
- if (strlen(trim($xmlResponse)) > 0) {
- $xml = simplexml_load_string($xmlResponse, 'Varien_Simplexml_Element');
-
- $address = array(
- 'addressId' => (string) $xml->descend("CallbackOrders/CallbackOrder/Address/AddressId"),
- 'regionCode' => (string) $xml->descend("CallbackOrders/CallbackOrder/Address/State"),
- 'countryCode' => (string) $xml->descend("CallbackOrders/CallbackOrder/Address/CountryCode"),
- 'city' => (string) $xml->descend("CallbackOrders/CallbackOrder/Address/City"),
- 'street' => (string) $xml->descend("CallbackOrders/CallbackOrder/Address/AddressFieldOne"),
- 'postCode' => (string) $xml->descend("CallbackOrders/CallbackOrder/Address/PostalCode"),
- 'ClientRequestId' => (string) $xml->descend("ClientRequestId"),
- );
- } else {
- $address = array(
- 'addressId' => '',
- 'regionCode' => '',
- 'countryCode' => '',
- 'city' => '',
- 'street' => '',
- 'postCode' => '',
- );
- }
- return $address;
- }
-
- /**
- * Return items SKUs from Amazon request
- *
- * @param array $responseArr
- */
- protected function _parseRequestItems($xmlResponse)
- {
- $items = array();
- if (strlen(trim($xmlResponse)) > 0) {
- $xml = simplexml_load_string($xmlResponse, 'Varien_Simplexml_Element');
- $itemsXml = $xml->descend("Cart/Items");
- foreach ($itemsXml->Item as $_item) {
- $sku = '';
- $compositeSku = explode('/', (string)$_item->SKU);
- if (isset($compositeSku[0])) {
- $sku = $compositeSku[0];
- }
- $items[(string)$_item->SKU] = $sku;
- }
- } else {
- return false;
- }
- return $items;
- }
-
- /**
- * Generate XML Responce for Amazon with Shipping, Taxes, Promotions
- *
- * @return string xml
- */
- protected function _generateXmlResponse($quote, $items = array())
- {
-
- $_xmlString = <<
-
-
-XML;
-
- $xml = new SimpleXMLElement($_xmlString);
-
- if (count($this->_carriers) > 0) {
- $_xmlResponse = $xml->addChild('Response');
- $_xmlCallbackOrders = $_xmlResponse->addChild('CallbackOrders');
- $_xmlCallbackOrder = $_xmlCallbackOrders->addChild('CallbackOrder');
-
- $_xmlAddress = $_xmlCallbackOrder->addChild('Address');
- $_xmlAddressId = $_xmlAddress->addChild('AddressId', $this->_address['addressId']);
-
- $_xmlCallbackOrderItems = $_xmlCallbackOrder->addChild('CallbackOrderItems');
- foreach ($items as $_itemSku) {
- $_quoteItem = null;
- foreach ($quote->getAllItems() as $_item) {
- if ($_item->getSku() == $_itemSku) {
- $_quoteItem = $_item;
- break;
- }
- }
- if (is_null($_quoteItem)) {
- Mage::throwException($this->__('Item specified in callback request XML was not found in quote.'));
- }
-
- $_xmlCallbackOrderItem = $_xmlCallbackOrderItems->addChild('CallbackOrderItem');
- $_xmlCallbackOrderItem->addChild('SKU', $_itemSku . '/' . $_quoteItem->getId());
- $_xmlCallbackOrderItem->addChild('TaxTableId', 'tax_'.$_quoteItem->getTaxClassId());
-
-
-
- $_xmlShippingMethodIds = $_xmlCallbackOrderItem->addChild('ShippingMethodIds');
- foreach ($this->_carriers as $_carrier) {
- $_xmlShippingMethodIds->addChild('ShippingMethodId', $_carrier['code']);
- }
- }
-
- $this->_appendTaxTables($xml, $quote, $this->_getTaxRules($quote));
- $this->_appendDiscounts($xml, $quote);
-
- $_xmlShippingMethods = $xml->addChild('ShippingMethods');
- foreach ($this->_carriers as $_carrier) {
- $_xmlShippingMethod = $_xmlShippingMethods->addChild('ShippingMethod');
-
- $_xmlShippingMethod->addChild('ShippingMethodId', $_carrier['code']);
- $_xmlShippingMethod->addChild('ServiceLevel', $_carrier['service_level']);
-
- $_xmlShippingMethodRate = $_xmlShippingMethod->addChild('Rate');
- // Posible values: ShipmentBased | WeightBased | ItemQuantityBased
- $_xmlShippingMethodRateItem = $_xmlShippingMethodRate->addChild('ShipmentBased');
- $_xmlShippingMethodRateItem->addChild('Amount', $_carrier['price']);
- $_xmlShippingMethodRateItem->addChild('CurrencyCode', $_carrier['currency']);
-
- $_xmlShippingMethodIncludedRegions = $_xmlShippingMethod->addChild('IncludedRegions');
- $_xmlShippingMethodIncludedRegions->addChild('PredefinedRegion', 'WorldAll');
- }
- $xml->addChild('CartPromotionId', 'cart-total-discount');
- }
-
- return $xml;
- }
-
- protected function _appendTaxTables($xml, $quote, $rules, $isShipping = false)
- {
- return $this->_getTaxTablesXml($quote, $rules, $isShipping, $xml);
- }
-
- protected function _appendDiscounts($xml, $quote)
- {
- $totalDiscount = $quote->getShippingAddress()->getBaseDiscountAmount() + $quote->getBillingAddress()->getBaseDiscountAmount();
- $discountAmount = ($totalDiscount ? $totalDiscount : 0);
-
- $_promotions = $xml->addChild('Promotions');
- $_promotion = $_promotions->addChild('Promotion');
- $_promotion->addChild('PromotionId', 'cart-total-discount');
- $_promotion->addChild('Description', 'Discount');
- $_benefit = $_promotion->addChild('Benefit');
- $_fad = $_benefit->addChild('FixedAmountDiscount');
- $_fad->addChild('Amount', $discountAmount);
- $_fad->addChild('CurrencyCode', $quote->getBaseCurrencyCode());
-
- return $xml;
- }
-
- /**
- * Generate XML with error message in case Calculation Callbacks error
- *
- * @param Exception $e
- */
- public function callbackXmlError(Exception $e)
- {
- // Posible error codes: INVALID_SHIPPING_ADDRESS | INTERNAL_SERVER_ERROR | SERVICE_UNAVAILABLE
- $xmlErrorString = ''."\n"
- .''."\n"
- .' '."\n"
- .' '."\n"
- .' INTERNAL_SERVER_ERROR
'."\n"
- .' [MESSAGE] '."\n"
- .' '."\n"
- .' '."\n"
- .' ';
- $_errorMsg = $e->getMessage();
- $_errorMessage = "{$_errorMsg}\n\n"
- ."code: {$e->getCode()}\n\n"
- ."file: {$e->getFile()}\n\n"
- ."line: {$e->getLine()}\n\n"
- ."trac: {$e->getTraceAsString()}\n\n";
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setResponseBody($_errorMessage)
- ->setRequestBody(time() .' - error callback response')
- ->save();
- }
-
- if ($_errorMsg = $e->getMessage() && 0) {
- $xmlErrorString = str_replace('[MESSAGE]', $_errorMsg, $xmlErrorString);
- } else {
- $xmlErrorString = str_replace('[MESSAGE]', 'Error', $xmlErrorString);
- }
- $xml = new SimpleXMLElement($xmlErrorString);
- return $xml;
- }
-
- /**
- * Get order amazon api
- *
- * @return Mage_AmazonPayments_Model_Api_Cba_Document
- */
- public function getDocumentApi()
- {
- if (is_null($this->getData('document_api'))) {
- $_documentApi = Mage::getModel('amazonpayments/api_cba_document')
- ->setWsdlUri('https://merchant-api.amazon.com/gateway/merchant-interface-mime/')
- ->setMerchantInfo(array(
- 'merchantIdentifier' => Mage::getStoreConfig('payment/amazonpayments_cba/merchant_tocken'),
- 'merchantName' => Mage::getStoreConfig('payment/amazonpayments_cba/merchant_name'),
- ))
- ->init(
- Mage::getStoreConfig('payment/amazonpayments_cba/merchant_login'),
- Mage::getStoreConfig('payment/amazonpayments_cba/merchant_pass')
- );
- $this->setData('document_api', $_documentApi);
- }
- return $this->getData('document_api');
- }
-
- /**
- * Associate Magento real order id with Amazon order id
- *
- * @param Mage_Sales_Model_Order $order
- * @return Mage_AmazonPayments_Model_Api_Cba
- */
- public function syncOrder($order)
- {
- if ($order->getId()) {
- $this->getDocumentApi()->sendAcknowledgement($order);
- }
- return $this;
- }
-
- /**
- * Cancel order
- *
- * @param Mage_Sales_Model_Order $order
- * @return Mage_AmazonPayments_Model_Api_Cba
- */
- public function cancel($order)
- {
- $this->getDocumentApi()->cancel($order);
- return $this;
- }
-
- /**
- * Refund order
- *
- * @param Mage_Sales_Model_Order_Payment $payment
- * @param float $amount
- * @return Mage_AmazonPayments_Model_Api_Cba
- */
- public function refund($payment, $amount)
- {
- $this->getDocumentApi()->refund($payment, $amount);
- return $this;
- }
-
- /**
- * Confirm crating of shipment
- *
- * @param Mage_Sales_Model_Order_Shipment $shipment
- * @return Mage_AmazonPayments_Model_Api_Cba
- */
- public function confirmShipment($shipment)
- {
- $items = array();
- foreach ($shipment->getAllItems() as $item) {
- /* @var $item Mage_Sales_Model_Order_Shipment_Item */
- if ($item->getOrderItem()->getParentItemId()) {
- continue;
- }
- $items[] = array(
- 'id' => $item->getOrderItem()->getExtOrderItemId(),
- 'qty' => $item->getQty()
- );
- }
-
- $carrierName = '';
- $shippingMethod = '';
- $trackNumber = '';
- /**
- * Magento track numbers is not connected with items.
- * Get only first track number
- */
- foreach ($shipment->getAllTracks() as $track) {
- $carrierName = $track->getTitle();
- $trackNumber = $track->getNumber();
- break;
- }
- if (preg_match("/\((.+)\)/", $shipment->getOrder()->getShippingDescription(), $_result)) {
- $shippingMethod = $_result[1];
- }
-
- $this->getDocumentApi()->confirmShipment(
- $shipment->getOrder()->getExtOrderId(),
- $carrierName,
- $shippingMethod,
- $items,
- $trackNumber
- );
- $shipment->addComment(
- Mage::helper('amazonpayments')->__('Shipment was created with Checkout by Amazon.')
- );
- return $this;
- }
-
- /**
- * Send shipping track number
- *
- * @param Mage_Sales_Model_Order $order
- * @param Mage_Sales_Model_Order_Shipment_Track $track
- * @param Mage_AmazonPayments_Model_Api_Cba
- */
- public function sendTrackingNumber($order, $track)
- {
-// $this->getDocumentApi()->sendTrackNumber($order, $carrierCode, $carrierMethod, $trackNumber);
- return $this;
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Cba/Document.php b/app/code/core/Mage/AmazonPayments/Model/Api/Cba/Document.php
deleted file mode 100644
index d43eabc10f..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Cba/Document.php
+++ /dev/null
@@ -1,476 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Cba_Document extends Varien_Object
-{
- const MESSAGE_TYPE_ADJUSTMENT = '_POST_PAYMENT_ADJUSTMENT_DATA_';
- const MESSAGE_TYPE_FULFILLMENT = '_POST_ORDER_FULFILLMENT_DATA_';
- const MESSAGE_TYPE_ACKNOWLEDGEMENT = '_POST_ORDER_ACKNOWLEDGEMENT_DATA_';
-
- protected $_wsdlUri = null;
- protected $_merchantInfo = array();
- protected $_client = null;
- protected $_result = null;
- protected $_proccessFailed = false;
- protected $_options = array(
- 'trace' => true,
- 'timeout' => '20',
- );
-
- protected function _construct()
- {
- parent::_construct();
- }
-
- /**
- * Set Wsdl uri
- *
- * @param string $wsdlUri
- * @return Mage_AmazonPayments_Model_Api_Cba_Document
- */
- public function setWsdlUri($wsdlUri)
- {
- $this->_wsdlUri = $wsdlUri;
- return $this;
- }
-
- /**
- * Return Wsdl Uri
- *
- * @return string
- */
- public function getWsdlUri()
- {
- return $this->_wsdlUri;
- }
-
- /**
- * Set merchant info
- *
- * @param array $merchantInfo
- * @return Mage_AmazonPayments_Model_Api_Cba_Document
- */
- public function setMerchantInfo(array $merchantInfo = array())
- {
- $this->_merchantInfo = $merchantInfo;
- return $this;
- }
-
- /**
- * Return merchant info
- *
- * @return array
- */
- public function getMerchantInfo()
- {
- return $this->_merchantInfo;
- }
-
- /**
- * Return merchant identifier
- *
- * @return string
- */
- public function getMerchantIdentifier()
- {
- if (array_key_exists('merchantIdentifier', $this->_merchantInfo)) {
- return $this->_merchantInfo['merchantIdentifier'];
- }
- return null;
- }
-
- /**
- * Return Soap object
- *
- * @return SOAP_Client
- */
- public function getClient()
- {
- return $this->_client;
- }
-
- /**
- * Initialize Soap Client object and authorize
- *
- * @param string $login
- * @param string $password
- * @return Mage_AmazonPayments_Model_Api_Cba_Document
- */
- public function init($login, $password)
- {
- if ($this->getWsdlUri()) {
- $this->_client = null;
- $auth = array('user' => $login, 'pass' => $password);
- try {
- set_include_path(
- BP . DS . 'lib' . DS . 'PEAR' . PS . get_include_path()
- );
- require_once 'SOAP/Client.php';
- $this->_client = new SOAP_Client($this->getWsdlUri(), true, false, $auth, false);
- } catch (Exception $e) {
- Zend_Debug::dump($e->getMessage());
- }
- }
- return $this;
- }
-
- /**
- * Create soap attachment (MIME encoding)
- *
- * @param string $document
- * @return string
- */
- protected function _createAttachment($document)
- {
- require_once 'SOAP/Value.php';
- $attachment = new SOAP_Attachment('doc', 'application/binary', null, $document);
- $attachment->options['attachment']['encoding'] = '8bit';
- $this->_options['attachments'] = 'Mime';
- return $attachment;
- }
-
- /**
- * Proccess request and setting result
- *
- * @param string $method
- * @param array $params
- * @return Mage_AmazonPayments_Model_Api_Cba_Document
- */
- protected function _proccessRequest($method, $params)
- {
- if ($this->getClient()) {
- $this->_result = null;
- $this->_proccessFailed = false;
- try {
- $this->_result = $this->getClient()
- ->call($method, $params, $this->_options);
- } catch (Exception $e) {
- $this->_proccessFailed = true;
- }
- }
- return $this;
- }
-
- /**
- * Format amount value (2 digits after the decimal point)
- *
- * @param float $amount
- * @return float
- */
- public function formatAmount($amount)
- {
- return Mage::helper('amazonpayments')->formatAmount($amount);
- }
-
- /**
- * Get order info
- *
- * @param string $aOrderId Amazon order id
- * @return Varien_Simplexml_Element
- */
- public function getDocument($aOrderId)
- {
- $params = array(
- 'merchant' => $this->getMerchantInfo(),
- 'documentIdentifier' => $aOrderId
- );
- $this->_proccessRequest('getDocument', $params);
-
- require_once 'Mail/mimeDecode.php';
- $decoder = new Mail_mimeDecode($this->getClient()->xml);
- $decoder->decode(array(
- 'include_bodies' => true,
- 'decode_bodies' => true,
- 'decode_headers' => true,
- ));
- $xml = $decoder->_body;
-
- // remove the ending mime boundary
- $boundaryIndex = strripos($xml, '--xxx-WASP-CPP-MIME-Boundary-xxx');
- if (!($boundaryIndex === false)) {
- $xml = substr($xml, 0, $boundaryIndex);
- }
-
- return simplexml_load_string($xml, 'Varien_Simplexml_Element');
- }
-
- /**
- * Get pending orders
- *
- * @return array
- */
- public function getPendingDocuments()
- {
- $params = array(
- 'merchant' => $this->getMerchantInfo(),
- 'messageType' => '_GET_ORDERS_DATA_'
- );
- $this->_proccessRequest('getAllPendingDocumentInfo', $params);
- if (!is_array($this->_result)) {
- $this->_result = array($this->_result);
- }
- return $this->_result;
- }
-
- /**
- * Associate Magento real order id with Amazon order id
- *
- * @param Mage_Sales_Model_Order $order
- * @return string
- */
- public function sendAcknowledgement($order)
- {
- $_document = '
-
-
- 1.01
- ' . $this->getMerchantIdentifier() . '
-
- OrderAcknowledgement
-
- 1
- Update
-
- ' . $order->getExtOrderId() . '
- ' . $order->getRealOrderId() . '
- Success
-
-
- ';
-
- $params = array(
- 'merchant' => $this->getMerchantInfo(),
- 'messageType' => self::MESSAGE_TYPE_ACKNOWLEDGEMENT,
- 'doc' => $this->_createAttachment($_document)
- );
-
- $this->_proccessRequest('postDocument', $params);
- return $this->_result;
- }
-
- /**
- * Cancel order
- *
- * @param Mage_Sales_Model_Order $order
- * @return string Amazon Transaction Id
- */
- public function cancel($order)
- {
- $_document = '
-
-
- 1.01
- ' . $this->getMerchantIdentifier() . '
-
- OrderAcknowledgement
-
- 1
- Update
-
- ' . $order->getExtOrderId() . '
- Failure
-
-
- ';
-
- $params = array(
- 'merchant' => $this->getMerchantInfo(),
- 'messageType' => self::MESSAGE_TYPE_ACKNOWLEDGEMENT,
- 'doc' => $this->_createAttachment($_document)
- );
-
- $this->_proccessRequest('postDocument', $params);
- return $this->_result;
- }
-
- /**
- * Refund order
- *
- * @param Mage_Sales_Model_Order_Payment $payment
- * @param float $amount
- * @return string Amazon Transaction Id
- */
- public function refund($payment, $amount)
- {
- $_document = '
-
-
- 1.01
- ' . $this->getMerchantIdentifier() . '
-
- OrderAdjustment ';
-
- $_shippingAmount = $payment->getCreditmemo()->getShippingAmount();
- $_messageId = 1;
- foreach ($payment->getCreditmemo()->getAllItems() as $item) {
- /* @var $item Mage_Sales_Model_Order_Creditmemo_Item */
- if ($item->getOrderItem()->getParentItemId()) {
- continue;
- }
-
- $shipping = 0;
- $amazon_amounts = unserialize($item->getOrderItem()->getProductOptionByCode('amazon_amounts'));
- if ($amazon_amounts['shipping'] > $_shippingAmount) {
- $shipping = $_shippingAmount;
- } else {
- $shipping = $amazon_amounts['shipping'];
- }
- $_shippingAmount -= $shipping;
-
- $_document .= '
- ' . $_messageId . '
-
- ' . $payment->getOrder()->getExtOrderId() . '
-
- '. $item->getOrderItem()->getExtOrderItemId() . '
- GeneralAdjustment
-
-
- Principal
- ' . $this->formatAmount($item->getBaseRowTotal()) . '
-
-
- Tax
- ' . $this->formatAmount($item->getBaseTaxAmount()) . '
- '
- .'
- Shipping
- ' . $this->formatAmount($shipping) . '
- '
- .' ';
- $_document .= '
-
- ';
- $_messageId++;
- }
-
- $_document .= ' ';
- $params = array(
- 'merchant' => $this->getMerchantInfo(),
- 'messageType' => self::MESSAGE_TYPE_ADJUSTMENT,
- 'doc' => $this->_createAttachment($_document)
- );
- $this->_proccessRequest('postDocument', $params);
- return $this->_result;
- }
-
- /**
- * Confirm creating of shipment
- *
- * @param string $aOrderId
- * @param string $carrierName
- * @param string $shippingMethod
- * @param array $items
- * @param string $trackNumber
- * @return string Amazon Transaction Id
- */
- public function confirmShipment($aOrderId, $carrierName, $shippingMethod, $items, $trackNumber = '')
- {
- $fulfillmentDate = gmdate('Y-m-d\TH:i:s');
- $_document = '
-
-
- 1.01
- ' . $this->getMerchantIdentifier() . '
-
- OrderFulfillment
-
- 1
-
- ' . $aOrderId . '
- ' . $fulfillmentDate . '
-
- ' . strtoupper($carrierName) . '
- ' . $shippingMethod . '
- ' . $trackNumber .'
- ';
- foreach ($items as $item) {
- $_document .= '-
-
' . $item['id'] . '
- ' . $item['qty'] . '
- ';
- }
- $_document .= '
-
- ';
- $params = array(
- 'merchant' => $this->getMerchantInfo(),
- 'messageType' => self::MESSAGE_TYPE_FULFILLMENT,
- 'doc' => $this->_createAttachment($_document)
- );
- $this->_proccessRequest('postDocument', $params);
- return $this->_result;
- }
-
- /**
- * Send Tracking Number
- *
- * @param Mage_Sales_Model_Order $order
- * @param string $carrierCode
- * @param string $carrierMethod
- * @param string $trackNumber
- * @return string Amazon Transaction Id
- */
- public function sendTrackNumber($order, $carrierCode, $carrierMethod, $trackNumber)
- {
- $fulfillmentDate = gmdate('Y-m-d\TH:i:s');
- $_document = '
-
-
- 1.01
- ' . $this->getMerchantIdentifier() . '
-
- OrderFulfillment ';
- $_document .= '
- 1
-
- ' . $order->getExtOrderId() . '
- ' . $fulfillmentDate . '
-
- ' . $carrierCode . '
- ' . $carrierMethod . '
- ' . $trackNumber .'
-
-
- ';
- $_document .= ' ';
- $params = array(
- 'merchant' => $this->getMerchantInfo(),
- 'messageType' => self::MESSAGE_TYPE_FULFILLMENT,
- 'doc' => $this->_createAttachment($_document)
- );
- $this->_proccessRequest('postDocument', $params);
- return $this->_result;
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Api/Debug.php b/app/code/core/Mage/AmazonPayments/Model/Api/Debug.php
deleted file mode 100644
index 5835c511a8..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Api/Debug.php
+++ /dev/null
@@ -1,44 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- /**
- * Model initialization
- *
- */
- protected function _construct()
- {
- $this->_init('amazonpayments/api_debug');
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/AmazonPayments/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index 2ac7a9d44c..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-
-class Mage_AmazonPayments_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- /**
- * Resource model initialization
- */
- protected function _construct()
- {
- $this->_init('amazonpayments/api_debug', 'transaction_id');
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/AmazonPayments/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index 8052e0dc56..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- /**
- * Collection constructor
- *
- */
- protected function _construct()
- {
- $this->_init('amazonpayments/api_debug');
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Mysql4/Setup.php b/app/code/core/Mage/AmazonPayments/Model/Mysql4/Setup.php
deleted file mode 100644
index cf2ded6fb8..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,31 +0,0 @@
-getEvent()->getShipment();
- if ($shipment->getOrder()->getPayment()->getMethod() != 'amazonpayments_cba') {
- return;
- }
-
- Mage::getModel('amazonpayments/api_cba')
- ->confirmShipment($shipment);
- }
-
- public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
- {
- $track = $observer->getEvent()->getTrack();
- $order = $track->getShipment()->getOrder();
- /* @var $order Mage_Sales_Model_Order */
- if ($order->getPayment()->getMethod() != 'amazonpayments_cba') {
- return;
- }
- Mage::getModel('amazonpayments/api_cba')
- ->sendTrackingNumber($order, $track);
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Payment.php b/app/code/core/Mage/AmazonPayments/Model/Payment.php
deleted file mode 100644
index 29416b0265..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Payment.php
+++ /dev/null
@@ -1,54 +0,0 @@
-getRedirectUrl();
- }
-
- public function getRedirectUrl()
- {
- #Mage::exception($this, 'worldpay');
- #throw new Exception('qwe')
- die('test2');
- $_url = Mage::getUrl('amazonepayments/redirect');
- echo "url: {$_url} ";
- return $_url;
- }
-}
\ No newline at end of file
diff --git a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp.php b/app/code/core/Mage/AmazonPayments/Model/Payment/Asp.php
deleted file mode 100644
index fe6667db61..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp.php
+++ /dev/null
@@ -1,435 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Payment_Asp extends Mage_Payment_Model_Method_Abstract
-{
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- protected $_isGateway = false;
- protected $_canAuthorize = false;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = true;
- protected $_canVoid = true;
- protected $_canUseInternal = false;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = false;
- protected $_isInitializeNeeded = true;
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- protected $_formBlockType = 'amazonpayments/asp_form';
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- protected $_code = 'amazonpayments_asp';
-
- /**
- * current order
- */
- protected $_order;
-
- /**
- * Get value from the module config
- *
- * @param string $path
- * @return string
- */
- public function getConfig($path)
- {
- return Mage::getStoreConfig('payment/' . $this->_code . '/' . $path);
- }
-
-
- /**
- * Get singleton with AmazonPayments ASP API Model
- *
- * @return Mage_AmazonPayments_Model_Api_Asp
- */
- public function getApi()
- {
- return Mage::getSingleton('amazonpayments/api_asp');
- }
-
- /**
- * Get singleton with AmazonPayments ASP Notification Model
- *
- * @return Mage_AmazonPayments_Model_Payment_Asp_Notification
- */
- public function getNotification()
- {
- return Mage::getSingleton('amazonpayments/payment_asp_notification');
- }
-
- /**
- * Set model of current order
- *
- * @param Mage_Sales_Model_Order $order
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- public function setOrder($order)
- {
- $this->_order = $order;
- return $this;
- }
-
- /**
- * Get model of current order
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder()
- {
- if (!$this->_order) {
- $paymentInfo = $this->getInfoInstance();
- $this->_order = Mage::getModel('sales/order')->loadByIncrementId(
- $paymentInfo->getOrder()->getRealOrderId()
- );
- }
- return $this->_order;
- }
-
- /**
- * Add item in to log storage
- *
- * @param string $request
- * @param string $response
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- protected function _log($request, $response = '')
- {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setRequestBody($request)
- ->setResponseBody($response)
- ->save();
- return $this;
- }
-
- /**
- * Send mail
- *
- * @param string $template
- * @param array $variables
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- protected function _mail($template, array $variables = array())
- {
- $mailTemplate = Mage::getModel('core/email_template');
- $mailTemplate->setDesignConfig(array('area' => 'frontend'))
- ->sendTransactional(
- $this->getConfig($template),
- $this->getConfig('email_sender_identity'),
- $this->getConfig('report_email'),
- null,
- $variables
- );
- return $this;
- }
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- public function getOrderPlaceRedirectUrl()
- {
- return Mage::getUrl('amazonpayments/asp/pay');
- }
-
- /**
- * Return Amazon Simple Pay payment url
- *
- * @return string
- */
- public function getPayRedirectUrl()
- {
- return $this->getApi()->getPayUrl();
- }
-
- /**
- * Return choice method description
- *
- * @return string
- */
- public function getChoiceMethodDescription()
- {
- return $this->getConfig('choice_method_description');
- }
-
- /**
- * Return redirect message
- *
- * @return string
- */
- public function getRedirectMessage()
- {
- return $this->getConfig('redirect_message');
- }
-
- /**
- * Return pay params for current order
- *
- * @return array
- */
- public function getPayRedirectParams()
- {
- $orderId = $this->getOrder()->getRealOrderId();
- $amount = Mage::app()->getStore()->roundPrice($this->getOrder()->getBaseGrandTotal());
- $currencyCode = $this->getOrder()->getBaseCurrencyCode();
-
- $urlModel = Mage::getModel('core/url')
- ->setUseSession(false);
-
- return $this->getApi()->getPayParams(
- $orderId,
- $amount,
- $currencyCode,
- $urlModel->getUrl('amazonpayments/asp/returnCancel'),
- $urlModel->getUrl('amazonpayments/asp/returnSuccess'),
- $urlModel->getUrl('amazonpayments/asp/notification')
- );
- }
-
- /**
- * When a customer redirect to Amazon Simple Pay site
- *
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- public function processEventRedirect()
- {
- $this->getOrder()->addStatusToHistory(
- $this->getOrder()->getStatus(),
- Mage::helper('amazonpayments')->__('Customer was redirected to Amazon Simple Pay site')
- )->save();
- return $this;
- }
-
- /**
- * When a customer successfully returned from Amazon Simple Pay site
- *
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- public function processEventReturnSuccess()
- {
- $this->getOrder()->sendNewOrderEmail();
- $this->getOrder()->addStatusToHistory(
- $this->getOrder()->getStatus(),
- Mage::helper('amazonpayments')->__('Customer successfully returned from Amazon Simple Pay site')
- )->save();
- return $this;
- }
-
- /**
- * Customer canceled payment and successfully returned from Amazon Simple Pay site
- *
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- public function processEventReturnCancel()
- {
- $this->getOrder()->addStatusToHistory(
- $this->getOrder()->getStatus(),
- Mage::helper('amazonpayments')->__('Customer canceled payment and successfully returned from Amazon Simple Pay site')
- )->save();
- return $this;
- }
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- public function initialize($paymentAction, $stateObject)
- {
- $state = Mage_Sales_Model_Order::STATE_NEW;
- $stateObject->setState($state);
- $stateObject->setStatus(Mage::getSingleton('sales/order_config')->getStateDefaultStatus($state));
- $stateObject->setIsNotified(false);
- return $this;
- }
-
- /**
- * process Amazon Simple Pay notification request
- *
- * @param array $requestParams
- * @return bool
- */
- public function processNotification($requestParams)
- {
- if ($this->getConfig('debug_log')) {
- $this->_log('DEBUG ASP notification: ' . print_r($requestParams, 1));
- }
-
- try {
- $this->getNotification()->setPayment($this)->process($requestParams);
- } catch(Exception $e) {
- if ($this->getConfig('error_log')) {
- $this->_log('ERROR ASP notification: ' . print_r($requestParams, 1), $e->getMessage());
- }
-
- if ($this->getConfig('report_error_to_email')) {
- $variables = array();
- $variables['request'] = print_r($requestParams, 1);
- $variables['error'] = $e->getMessage();
- $this->_mail('email_template_notification_error', $variables);
- }
-
- return false;
- }
-
- return true;
- }
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- public function capture(Varien_Object $payment, $amount)
- {
- if (is_null($payment->getCcTransId())) {
- Mage::throwException(
- Mage::helper('amazonpayments')->__('Order was not captured online. Authorization confirmation is required.')
- );
- }
- return $this;
- }
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- public function processInvoice($invoice, $payment)
- {
- if (!is_null($payment->getCcTransId()) &&
- is_null($payment->getLastTransId()) &&
- is_null($invoice->getTransactionId())) {
-
- $amount = Mage::app()->getStore()->roundPrice($invoice->getBaseGrandTotal());
- $currencyCode = $payment->getOrder()->getBaseCurrencyCode();
- $transactionId = $payment->getCcTransId();
- $response = $this->getApi()
- ->setStoreId($payment->getOrder()->getStoreId())
- ->capture($transactionId, $amount, $currencyCode);
-
- if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_ERROR) {
- Mage::throwException(
- Mage::helper('amazonpayments')->__('Order was not captured. Amazon Simple Pay service error: [%s] %s', $response->getCode(), $response->getMessage())
- );
- }
-
- if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_SUCCESS ||
- $response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_PENDING) {
-
- $payment->setForcedState(Mage_Sales_Model_Order_Invoice::STATE_OPEN);
- $payment->setLastTransId($response->getTransactionId());
-
- $invoice->setTransactionId($response->getTransactionId());
- $invoice->addComment(Mage::helper('amazonpayments')->__('Invoice was created (online capture). Waiting for capture confirmation from Amazon Simple Pay service.'));
-
- $payment->getOrder()->addStatusToHistory(
- $payment->getOrder()->getStatus(),
- Mage::helper('amazonpayments')->__('Payment was captured online with Amazon Simple Pay service. Invoice was created. Waiting for capture confirmation from payment service.')
- );
-
- }
- }
- return $this;
- }
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- public function processCreditmemo($creditmemo, $payment)
- {
-
- $transactionId = $creditmemo->getInvoice()->getTransactionId();
-
- if (!is_null($transactionId) &&
- is_null($creditmemo->getTransactionId())) {
-
- $amount = Mage::app()->getStore()->roundPrice($creditmemo->getBaseGrandTotal());
- $currencyCode = $payment->getOrder()->getBaseCurrencyCode();
- $referenseID = $creditmemo->getInvoice()->getIncrementId();
- $response = $this->getApi()
- ->setStoreId($payment->getOrder()->getStoreId())
- ->refund($transactionId, $amount, $currencyCode, $referenseID);
-
- if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_ERROR) {
- Mage::throwException(
- Mage::helper('amazonpayments')->__('Invoice was not refunded. Amazon Simple Pay service error: [%s] %s', $response->getCode(), $response->getMessage())
- );
- }
-
- if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_SUCCESS ||
- $response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_PENDING) {
-
- $creditmemo->setTransactionId($response->getTransactionId());
- $creditmemo->addComment(Mage::helper('amazonpayments')->__('Payment refunded online. Waiting for refund confirmation from Amazon Simple Pay service.'));
- $creditmemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN);
-
- $payment->getOrder()->addStatusToHistory(
- $payment->getOrder()->getStatus(),
- Mage::helper('amazonpayments')->__('Payment refunded online with Amazon Simple Pay service. Creditmemo was created. Waiting for refund confirmation from Amazon Simple Pay service.')
- );
- }
- }
- return $this;
- }
-
- /**
- * rewrited for Mage_Payment_Model_Method_Abstract
- */
- public function cancel(Varien_Object $payment)
- {
- if (!is_null($payment->getCcTransId()) &&
- is_null($payment->getLastTransId())) {
-
- $transactionId = $payment->getCcTransId();
- $response = $this->getApi()
- ->setStoreId($payment->getOrder()->getStoreId())
- ->cancel($transactionId);
-
- if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_ERROR) {
- Mage::throwException(
- Mage::helper('amazonpayments')->__('Order was not cancelled. Amazon Simple Pay service error: [%s] %s', $response->getCode(), $response->getMessage())
- );
- }
-
- if ($response->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Fps_Response_Abstract::STATUS_CANCELLED) {
- $payment->getOrder()->setState(
- Mage_Sales_Model_Order::STATE_CANCELED,
- true,
- Mage::helper('amazonpayments')->__('Payment authorization cancelled with Amazon Simple Pay service.'),
- $notified = false
- );
- }
- }
- return $this;
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Abstract.php b/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Abstract.php
deleted file mode 100644
index 2bc0cbdf1b..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Abstract.php
+++ /dev/null
@@ -1,30 +0,0 @@
-getApi()->getFps()->refund($reserveTransactionId, $callerReference);
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Notification.php b/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Notification.php
deleted file mode 100644
index b0fcd369cd..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Notification.php
+++ /dev/null
@@ -1,544 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Payment_Asp_Notification extends Varien_Object
-{
- /*
- * payment Model
- */
- protected $_payment;
-
- /**
- * Set payment Model
- *
- * @param Mage_AmazonPayments_Model_Payment_Asp $payment
- * @return Mage_AmazonPayments_Model_Payment_Asp_Notification
- */
- public function setPayment($payment)
- {
- $this->_payment = $payment;
- return $this;
- }
-
- /**
- * Get payment Model
- *
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- public function getPayment()
- {
- return $this->_payment;
- }
-
- /**
- * process notification request
- *
- * @param array $requestParams
- */
- public function process($requestParams)
- {
- $request = $this->getPayment()->getApi()->processNotification($requestParams);
-
- if ($request->getStatus() == Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_CANCEL_TRANSACTION) {
- return true;
- }
-
- $order = $this->_getRequestOrder($request);
- switch ($request->getStatus()) {
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_CANCEL_CUSTOMER:
- $this->_processCancel($request, $order);
- break;
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_RESERVE_SUCCESSFUL:
- $this->_processReserveSuccess($request, $order);
- break;
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_PAYMENT_INITIATED:
- $this->_processPaymetInitiated($request, $order);
- break;
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_PAYMENT_SUCCESSFUL:
- $this->_processPaymentSuccessful($request, $order);
- break;
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_PAYMENT_FAILED:
- $this->_processPaymentFailed($request, $order);
- break;
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_REFUND_SUCCESSFUL:
- $this->_processRefundSuccessful($request, $order);
- break;
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_REFUND_FAILED:
- $this->_processRefundFailed($request, $order);
- break;
- case Mage_AmazonPayments_Model_Api_Asp_Ipn_Request::STATUS_SYSTEM_ERROR:
- $this->_processSystemError($request, $order);
- break;
- }
- }
-
- /**
- * When a customer cancel payment
- */
- protected function _processCancel($request, $order)
- {
- if ($order->isCanceled()) {
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed cancelation.')
- )->save();
- return true;
- }
-
- if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed cancelation.')
- )->cancel()->save();
- return true;
- }
-
- $this->_errorViolationSequenceStates($request, $order);
- }
-
- /**
- * When a authorize payment
- */
- protected function _processReserveSuccess($request, $order)
- {
- if ($order->getState() != Mage_Sales_Model_Order::STATE_NEW) {
- $this->_errorViolationSequenceStates($request, $order);
- }
-
- $order->getPayment()->setCcTransId($request->getTransactionId());
-
- $order->setState(
- Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
- 'pending_amazon_asp',
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed amount authorization.'),
- $notified = false
- )->save();
-
- return true;
- }
-
- /**
- * When a initiation capture payment
- */
- protected function _processPaymetInitiated($request, $order)
- {
- if ($order->getState() != Mage_Sales_Model_Order::STATE_NEW &&
- $order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
- $this->_errorViolationSequenceStates($request, $order);
- }
-
- $order->setState(
- Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
- 'pending_amazon_asp',
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed capture initiation.'),
- $notified = false
- )->save();
-
- return true;
- }
-
- /**
- * When a capture payment
- */
- protected function _processPaymentSuccessful($request, $order)
- {
- if ($order->getState() != Mage_Sales_Model_Order::STATE_NEW &&
- $order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT &&
- $order->getState() != Mage_Sales_Model_Order::STATE_PROCESSING &&
- $order->getState() != Mage_Sales_Model_Order::STATE_COMPLETE) {
- $this->_errorViolationSequenceStates($request, $order);
- }
-
- if (!$invoice = $this->_getOrderInvoice($order)) {
-
- $orderAmount = Mage::app()->getStore()->roundPrice($order->getBaseGrandTotal());
- $requestAmount = Mage::app()->getStore()->roundPrice($request->getAmount());
- if ($orderAmount != $requestAmount) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service capture confirmation error: confirmation request amount not equal to the amount of order.'),
- $request,
- $order
- );
- }
-
- $invoice = $order->prepareInvoice();
- $invoice->register()->pay();
- $invoice->addComment(Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed payment capture. Invoice created automatically.'));
- $invoice->setTransactionId($request->getTransactionId());
-
- $order->getPayment()->setLastTransId($request->getTransactionId());
- $order->setState(
- Mage_Sales_Model_Order::STATE_PROCESSING,
- true,
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed payment capture. Invoice %s was automatically created after confirmation.', $invoice->getIncrementId()),
- $notified = true
- );
-
- $transactionSave = Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
-
- } else {
-
- if ($invoice->getTransactionId() != $request->getTransactionId()) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service capture confirmation error: existing transaction ID doesn\'t match transaction ID in the confirmation request.'),
- $request,
- $order
- );
- }
-
- $invoiceAmount = Mage::app()->getStore()->roundPrice($invoice->getGrandTotal());
- $requestAmount = Mage::app()->getStore()->roundPrice($request->getAmount());
- if ($invoiceAmount != $requestAmount) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service capture confirmation error: amount in the existing invoice doensn\'t match the amount in confirmation request.'),
- $request,
- $order
- );
- }
-
- $msg = '';
-
- switch ($invoice->getState())
- {
- case Mage_Sales_Model_Order_Invoice::STATE_OPEN:
- $invoice->addComment(Mage::helper('amazonpayments')->__('Amazon Simple Pay service capture confirmation. Invoice was captured automatically.'));
- $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
- $msg = $msg . Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed capture for invoice %s. Invoice automatically captured.', $invoice->getIncrementId());
- break;
-
- case Mage_Sales_Model_Order_Invoice::STATE_PAID:
- $invoice->addComment(Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed capture'));
- $msg = $msg . Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed capture for invoice %s', $invoice->getIncrementId());
- break;
- }
-
- $order->getPayment()->setLastTransId($request->getTransactionId());
- $order->setState(
- Mage_Sales_Model_Order::STATE_PROCESSING,
- true,
- $msg,
- $notified = true
- );
-
- $transactionSave = Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($order)
- ->save();
-
- }
-
- return true;
- }
-
- /**
- * When a failed capture payment
- */
- protected function _processPaymentFailed($request, $order)
- {
- if ($order->getState() != Mage_Sales_Model_Order::STATE_NEW &&
- $order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
- $this->_errorViolationSequenceStates($request, $order);
- }
-
- $order->setState(
- Mage_Sales_Model_Order::STATE_CANCELED,
- true,
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service payment confirmation failed'),
- $notified = false
- )->save();
-
- return true;
- }
-
- /**
- * When a refund payment
- */
- protected function _processRefundSuccessful($request, $order)
- {
- if ($order->getState() != Mage_Sales_Model_Order::STATE_PROCESSING &&
- $order->getState() != Mage_Sales_Model_Order::STATE_CLOSED &&
- $order->getState() != Mage_Sales_Model_Order::STATE_COMPLETE) {
- $this->_errorViolationSequenceStates($request, $order);
- }
-
- if (!$creditmemo = $this->_getOrderCreditmemo($order)) {
-
- $orderAmount = Mage::app()->getStore()->roundPrice($order->getBaseGrandTotal());
- $requestAmount = Mage::app()->getStore()->roundPrice($request->getAmount());
- if ($orderAmount != $requestAmount || $order->getBaseTotalRefunded() > 0) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service refund confirmation error: confirmation request amount doesn\'t match the order amount.'),
- $request,
- $order
- );
- }
-
- if ($creditmemo = $this->_initCreditmemo($order)) {
- $creditmemo->setTransactionId($request->getTransactionId());
- $creditmemo->addComment(Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed payment refund. Creditmemo %s was automatically created after confirmation.', $creditmemo->getIncrementId()));
- $creditmemo->register();
-
- $transactionSave = Mage::getModel('core/resource_transaction')
- ->addObject($creditmemo)
- ->addObject($creditmemo->getOrder());
- if ($creditmemo->getInvoice()) {
- $transactionSave->addObject($creditmemo->getInvoice());
- }
-
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed payment refund. Credit memo created automatically.', $creditmemo->getIncrementId())
- );
-
- $transactionSave->save();
- }
-
- } else {
-
- if ($creditmemo->getTransactionId() != $request->getTransactionId()) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service refund confirmation error: transaction ID in the existing creditmemo doesn\'t match the transaction ID in the confirmation request.'),
- $request,
- $order
- );
- }
-
- $creditmemoAmount = Mage::app()->getStore()->roundPrice($creditmemo->getBaseGrandTotal());
- $requestAmount = Mage::app()->getStore()->roundPrice($request->getAmount());
- if ($creditmemoAmount != $requestAmount) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service refund confirmation error: amount in the existing creditmemo doensn\'t match the amount in confirmation request.'),
- $request,
- $order
- );
- }
-
- $msg = '';
-
- switch ($creditmemo->getState())
- {
- case Mage_Sales_Model_Order_Creditmemo::STATE_OPEN:
- $creditmemo->addComment(Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed refund. Creditmemo processed automatically.'));
- $creditmemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED);
- $msg = $msg . Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed refunded creditmemo %s. Creditmemo processed automatically.', $creditmemo->getIncrementId());
- break;
-
- case Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED:
- $creditmemo->addComment(Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed refund.'));
- $msg = $msg . Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed refund for creditmemo %s.', $creditmemo->getIncrementId());
- break;
- }
-
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmed payment refund. Credit memo created automatically.', $creditmemo->getIncrementId())
- );
-
- $transactionSave = Mage::getModel('core/resource_transaction')
- ->addObject($creditmemo)
- ->addObject($order)
- ->save();
-
- }
-
- return true;
- }
-
- /**
- * When a failed refund payment
- */
- protected function _processRefundFailed($request, $order)
- {
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service payment confirmation failed')
- )->save();
- return true;
- }
-
- /**
- * When a Amazon Simple Pay system error
- */
- protected function _processSystemError($request, $order)
- {
- $order->setState(
- Mage_Sales_Model_Order::STATE_CANCELED,
- true,
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service is not available. Payment was not processed.'),
- $notified = false
- )->save();
-
- return true;
- }
-
- /**
- * Return order model for current request
- *
- * @param array $request
- * @return Mage_Sales_Model_Order
- */
- protected function _getRequestOrder($request)
- {
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($request->getReferenceId());
-
- if ($order->isEmpty()) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmation error: order specified in the IPN request can not be found'),
- $request
- );
- }
-
- if ($order->getPayment()->getMethodInstance()->getCode() != $this->getPayment()->getCode()) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmation error: payment method in the order is not Amazon Simple Pay'),
- $request
- );
- }
-
- if ($order->getBaseCurrency()->getCurrencyCode() != $request->getCurrencyCode()) {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmation error: order currency does not match the currency of the IPN request'),
- $request
- );
- }
-
- return $order;
- }
-
- /**
- * Return invoice model for current order
- *
- * @param Mage_Sales_Model_Order $order
- * @return Mage_Sales_Model_Order_Invoice
- */
- protected function _getOrderInvoice($order)
- {
- foreach ($order->getInvoiceCollection() as $orderInvoice) {
- if ($orderInvoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_PAID ||
- $orderInvoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_OPEN) {
- return $orderInvoice->load($orderInvoice->getId());
- }
- }
-
- return false;
- }
-
- /**
- * Create and return creditmemo for current order
- *
- * @param Mage_Sales_Model_Order $order
- * @return Mage_Sales_Model_Order_Creditmemo
- */
- protected function _initCreditMemo($order)
- {
- $invoice = $this->_getOrderInvoice($order);
-
- if (!$invoice) {
- return false;
- }
-
- $convertor = Mage::getModel('sales/convert_order');
- $creditmemo = $convertor->toCreditmemo($order)->setInvoice($invoice);
-
- foreach ($invoice->getAllItems() as $invoiceItem) {
- $orderItem = $invoiceItem->getOrderItem();
- $item = $convertor->itemToCreditmemoItem($orderItem);
- $item->setQty($orderItem->getQtyToRefund());
- $creditmemo->addItem($item);
- }
-
- $creditmemo->setShippingAmount($invoice->getShippingAmount());
- $creditmemo->collectTotals();
- Mage::register('current_creditmemo', $creditmemo);
-
- return $creditmemo;
- }
-
- /**
- * Return creditmemo model for current order
- *
- * @param Mage_Sales_Model_Order $order
- * @return Mage_Sales_Model_Order_Creditmemo
- */
- protected function _getOrderCreditmemo($order)
- {
- foreach ($order->getCreditmemosCollection() as $orderCreditmemo) {
- if ($orderCreditmemo->getState() == Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED ||
- $orderCreditmemo->getState() == Mage_Sales_Model_Order_Creditmemo::STATE_OPEN) {
- return $orderCreditmemo->load($orderCreditmemo->getId());
- }
- }
-
- return false;
- }
-
- /**
- * Process error: order states sequence violation
- *
- * @param array $request
- * @param Mage_Sales_Model_Order $order
- */
- protected function _errorViolationSequenceStates($request, $order)
- {
- $this->_error(
- Mage::helper('amazonpayments')->__('Amazon Simple Pay service confirmation error: order states sequence violation'),
- $request,
- $order
- );
- }
-
- /**
- * Process error
- *
- * @param string $comment
- * @param array $request
- * @param Mage_Sales_Model_Order $order
- */
- protected function _error($comment, $request, $order = null)
- {
- $message = $comment . Mage::helper('amazonpayments')->__(' Trace confirmation request: %s', $request->toString());
-
- if (!is_null($order)) {
- $order->addStatusToHistory(
- $order->getStatus(),
- $message
- )->save();
- }
-
- Mage::throwException($comment);
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Source/PaymentAction.php b/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Source/PaymentAction.php
deleted file mode 100644
index 96104926e3..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Payment/Asp/Source/PaymentAction.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Payment_Asp_Source_PaymentAction
-{
- public function toOptionArray()
- {
- return array(
- array(
- 'value' => Mage_AmazonPayments_Model_Api_Asp_Abstract::PAY_ACTION_SETTLE,
- 'label' => Mage::helper('amazonpayments')->__('Authorize Only')
- ),
- array(
- 'value' => Mage_AmazonPayments_Model_Api_Asp_Abstract::PAY_ACTION_SETTLE_CAPTURE,
- 'label' => Mage::helper('amazonpayments')->__('Authorize and Capture')
- ),
- );
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Payment/Cba.php b/app/code/core/Mage/AmazonPayments/Model/Payment/Cba.php
deleted file mode 100644
index fc60f1021c..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Payment/Cba.php
+++ /dev/null
@@ -1,598 +0,0 @@
-_api) {
- $this->_api = Mage::getSingleton('amazonpayments/api_cba');
- $this->_api->setPaymentCode($this->getCode());
- }
- return $this->_api;
- }
-
- /**
- * Get AmazonPayments session namespace
- *
- * @return Mage_AmazonPayments_Model_Session
- */
- public function getSession()
- {
- return Mage::getSingleton('amazonpayments/session');
- }
-
- /**
- * Retrieve redirect url
- *
- * @return string
- */
- public function getRedirectUrl()
- {
- return Mage::getUrl('amazonpayments/cba/redirect');
- }
-
- /**
- * Retrieve redirect to Amazon CBA url
- *
- * @return string
- */
- public function getAmazonRedirectUrl()
- {
- return $this->getApi()->getAmazonRedirectUrl();
- }
-
- /**
- * Authorize
- *
- * @param Varien_Object $orderPayment
- * @return Mage_Payment_Model_Abstract
- */
- public function authorize(Varien_Object $payment, $amount)
- {
- parent::authorize($payment, $amount);
- return $this;
- }
-
- /**
- * Capture payment
- *
- * @param Varien_Object $orderPayment
- * @return Mage_Payment_Model_Abstract
- */
- public function capture(Varien_Object $payment, $amount)
- {
- parent::capture($payment, $amount);
- return $this;
- }
-
- public function processInvoice($invoice, $payment)
- {
- parent::processInvoice($invoice, $payment);
- $invoice->addComment(
- Mage::helper('amazonpayments')->__('Invoice was created with Checkout by Amazon.')
- );
- return $this;
- }
-
- public function cancel(Varien_Object $payment)
- {
- if ($this->_skipProccessDocument) {
- return $this;
- }
- $this->getApi()->cancel($payment->getOrder());
- $payment->getOrder()->addStatusToHistory(
- $payment->getOrder()->getStatus(),
- Mage::helper('amazonpayments')->__('Order was canceled with Checkout by Amazon.')
- );
- return $this;
- }
-
- /**
- * Refund order
- *
- * @param Varien_Object $payment
- * @return Mage_AmazonPayments_Model_Payment_Cba
- */
- public function refund(Varien_Object $payment, $amount)
- {
- if ($this->_skipProccessDocument) {
- return $this;
- }
- $this->getApi()->refund($payment, $amount);
- $payment->getCreditmemo()->addComment(
- Mage::helper('amazonpayments')->__('Refund was created with Checkout by Amazon.')
- );
- return $this;
- }
-
- /**
- * Handle Callback from CBA and calculate Shipping, Taxes in case XML-based shopping cart
- *
- */
- public function handleCallback($_request)
- {
- $response = '';
-
- if (!empty($_request['order-calculations-request'])) {
- $xmlRequest = urldecode($_request['order-calculations-request']);
-
- $session = $this->getCheckout();
- $xml = $this->getApi()->handleXmlCallback($xmlRequest, $session);
-
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setRequestBody(print_r($_request, 1))
- ->setResponseBody(time().' - request callback')
- ->save();
- }
-
- if ($xml) {
- $xmlText = $xml->asXML();
- $response .= 'order-calculations-response='.urlencode($xmlText);
- #$response .= 'order-calculations-response='.base64_encode($xmlText);
-
- $secretKeyID = Mage::getStoreConfig('payment/amazonpayments_cba/secretkey_id');
-
- $_signature = $this->getApi()->calculateSignature($xmlText, $secretKeyID);
-
- if ($_signature) {
- $response .= '&Signature='.urlencode($_signature);
- #$response .= '&Signature='.$_signature;
- }
- $response .= '&aws-access-key-id='.urlencode(Mage::getStoreConfig('payment/amazonpayments_cba/accesskey_id'));
-
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setResponseBody($response)
- ->setRequestBody(time() .' - response calllback')
- ->save();
- }
- }
- } else {
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setRequestBody(print_r($_request, 1))
- ->setResponseBody(time().' - error request callback')
- ->save();
- }
- }
- return $response;
- }
-
- public function handleNotification($_request)
- {
- if (!empty($_request) && !empty($_request['NotificationData']) && !empty($_request['NotificationType'])) {
- /**
- * Debug
- */
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setRequestBody(print_r($_request, 1))
- ->setResponseBody(time().' - Notification: '. $_request['NotificationType'])
- ->save();
- }
- switch ($_request['NotificationType']) {
- case 'NewOrderNotification':
- $newOrderDetails = $this->getApi()->parseOrder($_request['NotificationData']);
- $this->_createNewOrder($newOrderDetails);
- break;
- case 'OrderReadyToShipNotification':
- $orderReadyToShipDetails = $this->getApi()->parseOrder($_request['NotificationData']);
- $this->_proccessOrder($orderReadyToShipDetails);
- break;
- case 'OrderCancelledNotification':
- $cancelDetails = $this->getApi()->parseCancelNotification($_request['NotificationData']);
- $this->_skipProccessDocument = true;
- $this->_cancelOrder($cancelDetails);
- $this->_skipProccessDocument = false;
- break;
- default:
- // Unknown notification type
- }
- } else {
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setRequestBody(print_r($_request, 1))
- ->setResponseBody(time().' - error request callback')
- ->save();
- }
- }
- return $this;
- }
-
- /**
- * Create new order by data from Amazon NewOrderNotification
- *
- * @param array $newOrderDetails
- */
- protected function _createNewOrder(array $newOrderDetails)
- {
- /* @var $order Mage_Sales_Model_Order */
- if (array_key_exists('amazonOrderID', $newOrderDetails)) {
- $_order = Mage::getModel('sales/order')
- ->loadByAttribute('ext_order_id', $newOrderDetails['amazonOrderID']);
- if ($_order->getId()) {
- /**
- * associate real order id with Amazon order
- */
- $this->getApi()->syncOrder($_order);
- $_order = null;
- return $this;
- }
- $_order = null;
- }
- $session = $this->getCheckout();
-
- #$quoteId = $session->getAmazonQuoteId();
-
- $quoteId = $newOrderDetails['ClientRequestId'];
- $quote = Mage::getModel('sales/quote')->load($quoteId);
-
- $baseCurrency = $session->getQuote()->getBaseCurrencyCode();
- $currency = Mage::app()->getStore($session->getQuote()->getStoreId())->getBaseCurrency();
-
- $shipping = $quote->getShippingAddress();
- $billing = $quote->getBillingAddress();
-
- $_address = $newOrderDetails['shippingAddress'];
- $this->_address = $_address;
-
- $regionModel = Mage::getModel('directory/region')->loadByCode($_address['regionCode'], $_address['countryCode']);
- $_regionId = $regionModel->getId();
-
- $sName = explode(' ', $newOrderDetails['shippingAddress']['name']);
- $sFirstname = isset($sName[0])?$sName[0]:'';
- $sLastname = isset($sName[1])?$sName[1]:'';
-
- $bName = explode(' ', $newOrderDetails['buyerName']);
- $bFirstname = isset($bName[0])?$bName[0]:'';
- $bLastname = isset($bName[1])?$bName[1]:'';
-
- $shipping->setCountryId($_address['countryCode'])
- ->setRegion($_address['regionCode'])
- ->setRegionId($_regionId)
- ->setCity($_address['city'])
- ->setStreet($_address['street'])
- ->setPostcode($_address['postCode'])
- ->setTaxAmount($newOrderDetails['tax'])
- ->setBaseTaxAmount($newOrderDetails['tax'])
- ->setShippingAmount($newOrderDetails['shippingAmount'])
- ->setBaseShippingAmount($newOrderDetails['shippingAmount'])
- ->setShippingTaxAmount($newOrderDetails['shippingTax'])
- ->setBaseShippingTaxAmount($newOrderDetails['shippingTax'])
- ->setDiscountAmount($newOrderDetails['discount'])
- ->setBaseDiscountAmount($newOrderDetails['discount'])
- ->setSubtotal($newOrderDetails['subtotal'])
- ->setBaseSubtotal($newOrderDetails['subtotal'])
- ->setGrandTotal($newOrderDetails['total'])
- ->setBaseGrandTotal($newOrderDetails['total'])
- ->setFirstname($sFirstname)
- ->setLastname($sLastname);
-
- $_shippingDesc = '';
- $_shippingServices = unserialize($quote->getExtShippingInfo());
- if (is_array($_shippingServices) && array_key_exists('amazon_service_level', $_shippingServices)) {
- foreach ($_shippingServices['amazon_service_level'] as $_level) {
- if ($_level['service_level'] == $newOrderDetails['ShippingLevel']) {
- $shipping->setShippingMethod($_level['code']);
- $_shippingDesc = $_level['description'];
- }
- }
- }
-
- $billing->setCountryId($_address['countryCode'])
- ->setRegion($_address['regionCode'])
- ->setRegionId($_regionId)
- ->setCity($_address['city'])
- ->setStreet($_address['street'])
- ->setPostcode($_address['postCode'])
- ->setTaxAmount($newOrderDetails['tax'])
- ->setBaseTaxAmount($newOrderDetails['tax'])
- ->setShippingAmount($newOrderDetails['shippingAmount'])
- ->setBaseShippingAmount($newOrderDetails['shippingAmount'])
- ->setShippingTaxAmount($newOrderDetails['shippingTax'])
- ->setBaseShippingTaxAmount($newOrderDetails['shippingTax'])
- ->setDiscountAmount($newOrderDetails['discount'])
- ->setBaseDiscountAmount($newOrderDetails['discount'])
- ->setSubtotal($newOrderDetails['subtotal'])
- ->setBaseSubtotal($newOrderDetails['subtotal'])
- ->setGrandTotal($newOrderDetails['total'])
- ->setBaseGrandTotal($newOrderDetails['total'])
- ->setFirstname($bFirstname)
- ->setLastname($bLastname);
-
- $quote->setBillingAddress($billing);
- $quote->setShippingAddress($shipping);
-
- $billing = $quote->getBillingAddress();
- $shipping = $quote->getShippingAddress();
-
- $convertQuote = Mage::getModel('sales/convert_quote');
- /* @var $convertQuote Mage_Sales_Model_Convert_Quote */
- $order = Mage::getModel('sales/order');
- /* @var $order Mage_Sales_Model_Order */
-
- $order = $convertQuote->addressToOrder($billing);
-
- // add payment information to order
- $order->setBillingAddress($convertQuote->addressToOrderAddress($billing))
- ->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
-
- $order->setShippingMethod($shipping->getShippingMethod())
- ->setShippingDescription($_shippingDesc)
- ->setForcedDoShipmentWithInvoice(true);
-
- $order->setPayment($convertQuote->paymentToOrderPayment($quote->getPayment()));
-
- /**
- * Amazon Order Id
- */
- $order->setExtOrderId($newOrderDetails['amazonOrderID']);
-
- // add items to order
- foreach ($quote->getAllItems() as $item) {
- /* @var $item Mage_Sales_Model_Quote_Item */
- $order->addItem($convertQuote->itemToOrderItem($item));
- /* @var $orderItem Mage_Sales_Model_Order_Item */
- $orderItem = $order->getItemByQuoteItemId($item->getId());
- $orderItem->setExtOrderItemId($newOrderDetails['items'][$item->getId()]['AmazonOrderItemCode']);
- $orderItemOptions = $orderItem->getProductOptions();
- $orderItemOptions['amazon_amounts'] = serialize(array(
- 'shipping' => $newOrderDetails['items'][$item->getId()]['shipping'],
- 'tax' => $newOrderDetails['items'][$item->getId()]['tax'],
- 'shipping_tax' => $newOrderDetails['items'][$item->getId()]['shipping_tax'],
- 'principal_promo' => $newOrderDetails['items'][$item->getId()]['principal_promo'],
- 'shipping_promo' => $newOrderDetails['items'][$item->getId()]['shipping_promo']
- ));
- $orderItem->setProductOptions($orderItemOptions);
- $orderItem->setLockedDoInvoice(true)
- ->setLockedDoShip(true);
- }
-
- $order->place();
-
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('New Order Notification received from Checkout by Amazon service.')
- );
-
- $customer = $quote->getCustomer();
- if ($customer && $customer->getId()) {
- $order->setCustomerId($customer->getId())
- ->setCustomerEmail($customer->getEmail())
- ->setCustomerPrefix($customer->getPrefix())
- ->setCustomerFirstname($customer->getFirstname())
- ->setCustomerMiddlename($customer->getMiddlename())
- ->setCustomerLastname($customer->getLastname())
- ->setCustomerSuffix($customer->getSuffix())
- ->setCustomerGroupId($customer->getGroupId())
- ->setCustomerTaxClassId($customer->getTaxClassId());
- } else {
- $quote->setCustomerEmail($newOrderDetails['buyerEmailAddress'])
- ->setCustomerIsGuest(true)
- ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
- }
-
- $order->save();
-
- $quote->setIsActive(false);
- $quote->save();
-
- $orderId = $order->getIncrementId();
- $this->getCheckout()->setLastQuoteId($quote->getId());
- $this->getCheckout()->setLastSuccessQuoteId($quote->getId());
- $this->getCheckout()->setLastOrderId($order->getId());
- $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
-
- $order->sendNewOrderEmail();
- /**
- * associate real order id with Amazon order
- */
- $this->getApi()->syncOrder($order);
- return $this;
- }
-
- /**
- * Proccess existing order
- *
- * @param array $amazonOrderDetails
- * @return boolean
- */
- protected function _proccessOrder($amazonOrderDetails)
- {
- if (array_key_exists('amazon_order_id', $amazonOrderDetails)) {
- $order = Mage::getModel('sales/order')
- ->loadByAttribute('ext_order_id', $amazonOrderDetails['amazon_order_id']);
- /* @var $order Mage_Sales_Model_Order */
- if ($order->getId()) {
- /* @var $item Mage_Sales_Model_Order_Item */
- foreach ($order->getAllVisibleItems() as $item) {
- if (array_key_exists($item->getExtOrderItemId(), $amazonOrderDetails['items'])) {
- $item->setLockedDoInvoice(false)
- ->setLockedDoShip(false)
- ->save();
- }
- }
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('Order Ready To Ship Notification received form Checkout by Amazon service.')
- )->save();
- }
- }
- return true;
- }
-
- /**
- * Cancel the order
- *
- * @param array $amazonOrderDetails
- * @return boolean
- */
- protected function _cancelOrder($cancelDetails)
- {
- if (array_key_exists('amazon_order_id', $cancelDetails)) {
- $order = Mage::getModel('sales/order')
- ->loadByAttribute('ext_order_id', $cancelDetails['amazon_order_id']);
- /* @var $order Mage_Sales_Model_Order */
- if ($order->getId()) {
- try {
- $order->cancel()
- ->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('amazonpayments')->__('Cancel Order Notification received from Checkout by Amazon service.')
- )->save();
- } catch (Exception $e) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Return xml with error
- *
- * @param Exception $e
- * @return string
- */
-
- public function callbackXmlError(Exception $e)
- {
- $_xml = $this->getApi()->callbackXmlError($e);
- $secretKeyID = Mage::getStoreConfig('payment/amazonpayments_cba/secretkey_id');
- $_signature = $this->getApi()->calculateSignature($_xml->asXml(), $secretKeyID);
-
- $response = 'order-calculations-response='.urlencode($_xml->asXML())
- .'&Signature='.urlencode($_signature)
- .'&aws-access-key-id='.urlencode(Mage::getStoreConfig('payment/amazonpayments_cba/accesskey_id'));
- return $response;
- }
-
- /**
- * Prepare fields for XML-based signed cart form for CBA
- *
- * @return array
- */
- public function getCheckoutXmlFormFields()
- {
- $secretKeyID = Mage::getStoreConfig('payment/amazonpayments_cba/secretkey_id');
- $_quote = $this->getCheckout()->getQuote();
-
- $xml = $this->getApi()->getXmlCart($_quote);
-
- $xmlCart = array('order-input' =>
- "type:merchant-signed-order/aws-accesskey/1;"
- ."order:".base64_encode($xml).";"
- ."signature:{$this->getApi()->calculateSignature($xml, $secretKeyID)};"
- ."aws-access-key-id:".Mage::getStoreConfig('payment/amazonpayments_cba/accesskey_id')
- );
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setResponseBody(print_r($xmlCart, 1)."\norder:".$xml)
- ->setRequestBody(time() .' - xml cart')
- ->save();
- }
- return $xmlCart;
- }
-
- /**
- * Return CBA order details in case Html-based shopping cart commited to Amazon
- *
- */
- public function returnAmazon()
- {
- $_request = Mage::app()->getRequest()->getParams();
- #$_amazonOrderId = Mage::app()->getRequest()->getParam('amznPmtsOrderIds');
- #$_quoteId = Mage::app()->getRequest()->getParam('amznPmtsReqId');
-
- if ($this->getDebug()) {
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setRequestBody(print_r($_request, 1))
- ->setResponseBody(time().' - success')
- ->save();
- }
- }
-
- /**
- * Rewrite standard logic
- *
- * @return bool
- */
- public function isInitializeNeeded()
- {
- return false;
- }
-
- /**
- * Get debug flag
- *
- * @return string
- */
- public function getDebug()
- {
- return Mage::getStoreConfig('payment/' . $this->getCode() . '/debug_flag');
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/Model/Session.php b/app/code/core/Mage/AmazonPayments/Model/Session.php
deleted file mode 100644
index 852930cb83..0000000000
--- a/app/code/core/Mage/AmazonPayments/Model/Session.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-class Mage_AmazonPayments_Model_Session extends Mage_Core_Model_Session_Abstract
-{
- public function __construct()
- {
- $this->init('amazonpayments');
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/controllers/AspController.php b/app/code/core/Mage/AmazonPayments/controllers/AspController.php
deleted file mode 100644
index cf5d9c5015..0000000000
--- a/app/code/core/Mage/AmazonPayments/controllers/AspController.php
+++ /dev/null
@@ -1,155 +0,0 @@
-
- */
-class Mage_AmazonPayments_AspController extends Mage_Core_Controller_Front_Action
-{
- /**
- * Get singleton with payment model AmazonPayments ASP
- *
- * @return Mage_AmazonPayments_Model_Payment_Asp
- */
- public function getPayment()
- {
- return Mage::getSingleton('amazonpayments/payment_asp');
- }
-
- /**
- * Get singleton with model checkout session
- *
- * @return Mage_Checkout_Model_Session
- */
- public function getSession()
- {
- return Mage::getSingleton('checkout/session');
- }
-
- /**
- * When a customer press "Place Order" button on Checkout/Review page
- * Redirect customer to Amazon Simple Pay payment interface
- *
- */
- public function payAction()
- {
- $session = $this->getSession();
- $quoteId = $session->getQuoteId();
- $lastRealOrderId = $session->getLastRealOrderId();
- if (is_null($quoteId) || is_null($lastRealOrderId)){
- $this->_redirect('checkout/cart/');
- } else {
- $session->setAmazonAspQuoteId($quoteId);
- $session->setAmazonAspLastRealOrderId($lastRealOrderId);
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($lastRealOrderId);
-
- $payment = $this->getPayment();
- $payment->setOrder($order);
- $payment->processEventRedirect();
-
- Mage::register('amazonpayments_payment_asp', $payment);
- $this->loadLayout();
- $this->renderLayout();
-
- $quote = $session->getQuote();
- $quote->setIsActive(false);
- $quote->save();
-
- $session->setQuoteId(null);
- $session->setLastRealOrderId(null);
- }
- }
-
- /**
- * When a customer successfully returned from Amazon Simple Pay site
- * Redirect customer to Checkout/Success page
- *
- */
- public function returnSuccessAction()
- {
- $session = $this->getSession();
-
- $orderId = $session->getAmazonAspLastRealOrderId();
- $quoteId = $session->getAmazonAspQuoteId(true);
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($orderId);
-
- if ($order->isEmpty()) { return false;
- }
-
- $payment = $this->getPayment();
- $payment->setOrder($order);
- $payment->processEventReturnSuccess();
-
- $session->setQuoteId($quoteId);
- $session->getQuote()->setIsActive(false)->save();
- $session->setLastRealOrderId($orderId);
-
- $this->_redirect('checkout/onepage/success');
- }
-
- /**
- * Customer canceled payment and successfully returned from Amazon Simple Pay site
- * Redirect customer to Shopping Cart page
- *
- */
- public function returnCancelAction()
- {
- $session = $this->getSession();
- $session->setQuoteId($session->getAmazonAspQuoteId(true));
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($session->getAmazonAspLastRealOrderId());
-
- if ($order->isEmpty()) {
- return false;
- }
-
- $payment = $this->getPayment();
- $payment->setOrder($order);
- $payment->processEventReturnCancel();
-
- $this->_redirect('checkout/cart/');
- }
-
- /**
- * Amazon Simple Pay service send notification
- *
- */
- public function notificationAction()
- {
- if (!$this->getPayment()->processNotification($this->getRequest()->getParams())) {
- $this->_forward('noRoute');
- }
- }
-}
diff --git a/app/code/core/Mage/AmazonPayments/controllers/CbaController.php b/app/code/core/Mage/AmazonPayments/controllers/CbaController.php
deleted file mode 100644
index a3e94833b9..0000000000
--- a/app/code/core/Mage/AmazonPayments/controllers/CbaController.php
+++ /dev/null
@@ -1,167 +0,0 @@
-getCba()->isAvailable()) {
- $this->_redirect('checkout/cart/');
- }
- $session = $this->getCheckout();
- if ($quoteId = $this->getCheckout()->getQuoteId()) {
- $quote = Mage::getModel('sales/quote')->load($quoteId);
-
- /** @var $quote Mage_Sales_Model_Quote */
- if ($quote->hasItems()) {
- $session->setAmazonQuoteId($quoteId);
-
- $quote->getPayment()->setMethod($this->getCba()->getCode());
- $quote->setIsActive(false);
- $quote->save();
-
- $this->getResponse()->setBody($this->getLayout()->createBlock('amazonpayments/cba_redirect')->toHtml());
-
- if ($session->hasData('quote_id_'.Mage::app()->getStore()->getWebsiteId())) {
- $session->unsetData('quote_id_'.Mage::app()->getStore()->getWebsiteId());
- }
- } else {
- $this->_redirect('checkout/cart/');
- }
- } else {
- $this->_redirect('checkout/cart/');
- }
- }
-
- /**
- * When a customer has checkout on Amazon and return with Successful payment
- *
- */
- public function successAction()
- {
- #$amazonOrderID = Mage::app()->getRequest()->getParam('amznPmtsOrderIds');
- #$referenceId = Mage::app()->getRequest()->getParam('amznPmtsOrderIds');
-
- $this->getCba()->returnAmazon();
-
- $this->loadLayout();
- #$this->_initLayoutMessages('amazonpayments/session');
- $this->renderLayout();
- }
-
- /**
- * When Amazon return callback request for calculation shipping, taxes and etc.
- *
- */
- public function callbackAction()
- {
- $response = '';
- $session = $this->getCheckout();
-
- $_request = Mage::app()->getRequest()->getParams();
-
- try {
- if ($_request) {
- $response = $this->getCba()->handleCallback($_request);
- } else {
- $e = new Exception('Inavlid Shipping Address');
- }
- }
- catch (Exception $e) {
- // Return Xml with Error
- $response = $this->getCba()->callbackXmlError($e);
- }
- echo $response;
- exit(0);
- }
-
- public function notificationAction()
- {
- $response = '';
- $session = $this->getCheckout();
-
- $_request = Mage::app()->getRequest()->getParams();
-
- try {
- $this->getCba()
- ->handleNotification($_request);
- }
- catch (Exception $e) {
- // Return Xml with Error
- $response = $this->getCba()->callbackXmlError($e);
- }
- $this->getResponse()
- ->setHttpResponseCode(200);
- }
-
- /**
- * When a customer has checkout on Amazon and return with Cancel
- *
- */
- public function cancelAction()
- {
- $session = $this->getCheckout();
- if ($quoteId = $session->getAmazonQuoteId()) {
- $quote = Mage::getModel('sales/quote')->load($quoteId);
- $quote->setIsActive(true);
- $quote->save();
- $session->setQuoteId($quoteId);
- }
- if ($this->getCba()->getDebug()) {
- $_request = Mage::app()->getRequest()->getParams();
- $debug = Mage::getModel('amazonpayments/api_debug')
- ->setResponseBody(print_r($_request, 1))
- ->setRequestBody(time() .' - cancel')
- ->save();
- }
- $this->_redirect('checkout/cart/');
- }
-
-}
diff --git a/app/code/core/Mage/AmazonPayments/etc/config.xml b/app/code/core/Mage/AmazonPayments/etc/config.xml
deleted file mode 100644
index f09c7b187d..0000000000
--- a/app/code/core/Mage/AmazonPayments/etc/config.xml
+++ /dev/null
@@ -1,227 +0,0 @@
-
-
-
-
-
- 0.1.2
-
-
-
-
-
- Mage_AmazonPayments_Model
- amazonpayments_mysql4
-
-
- Mage_AmazonPayments_Model_Mysql4
-
-
-
-
-
-
-
- Mage_AmazonPayments_Helper
-
-
-
-
-
- Mage_AmazonPayments
- Mage_AmazonPayments_Model_Mysql4_Setup
-
-
-
-
- Mage_AmazonPayments_Block
-
-
-
-
- Pending Amazon Simple Pay
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Amazon Simple Pay notification error
- amazonpayments_asp_notification_error.html
- html
-
-
-
-
-
-
-
-
-
-
-
- Mage_AmazonPayments.csv
-
-
-
-
-
-
- standard
-
- Mage_AmazonPayments
- amazonpayments
-
-
-
-
-
-
- amazonpayments.xml
-
-
-
-
-
-
-
-
-
-
- Mage_AmazonPayments.csv
-
-
-
-
-
-
-
-
- model
- amazonpayments/observer
- confirmShipment
-
-
-
-
-
-
- model
- amazonpayments/observer
- salesOrderShipmentTrackSaveAfter
-
-
-
-
-
-
-
-
-
-
- 0
- amazonpayments/payment_cba
- Checkout by Amazon
- pending
- 0
- Authorization
-
-
- 1
-
-
- https://payments.amazon.com/checkout/
- https://payments-sandbox.amazon.com/checkout/
- http://g-ecx.images-amazon.com/images/G/01/cba/images/buttons/btn_Chkout-orange-medium.gif
- https://merchant-api.amazon.com/gateway/merchant-interface-mime/
- 1
- 0
-
-
-
-
- amazonpayments/payment_asp
- Amazon Simple Pay
- 0
-
- 1
-
-
-
- https://authorize.payments.amazon.com/pba/paypipeline
- https://authorize.payments-sandbox.amazon.com/pba/paypipeline
-
- Your billing address will be ignored and you will be redirected to Amazon Simple Pay website.
- You will be redirected to Amazon Simple Pay in a few seconds.
- MAGENTO ASP PAYMENT
- MAGENTO ASP REFUND
- MAGENTO ASP CANCEL
-
- 1
- 0
-
- 1
-
- https://fps.amazonaws.com
- https://fps.sandbox.amazonaws.com/
-
- general
- payment_amazonpayments_asp_email_template_notification_error
- 0
-
- 0
- 0
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/AmazonPayments/etc/system.xml b/app/code/core/Mage/AmazonPayments/etc/system.xml
deleted file mode 100644
index 2878ba5a15..0000000000
--- a/app/code/core/Mage/AmazonPayments/etc/system.xml
+++ /dev/null
@@ -1,443 +0,0 @@
-
-
-
-
-
-
-
- Checkout by Amazon
-
-
-
-
Signing up with Checkout by Amazon
-
To configure Checkout by Amazon™ you will need to enter your Checkout by Amazon™ Merchant ID, Access Key ID, and Secret Access Key.
-
If you do not already have a Checkout by Amazon™ account, click here to create one now. Sign-Up
-
To locate your Merchant ID, sign in to your Seller Central Checkout by Amazon™ account and click Settings > Checkout Pipeline Settings.
-
To locate your Access Key ID and Secret Access Key, sign in to your Seller Central Checkout by Amazon™ account and click Integration > AWS Key. Click the link to read the Amazon Web Services Customer Agreement, and then click the check box, if you are setting up a new Access Key ID.
-
To enable XML Order Reports click Settings > Checkout Pipeline Settings , and then clicking Edit under the Order Report Settings section. Select Order Report Type as XML to get XML Order Reports using SOAP APIs. Configure your downloads for hourly.
-
For additional information on setting up your Checkout by Amazon account, Click Here - FAQ.
-
Signup for Checkout by Amazon
-
-
-]]>
- text
- 601
- 1
- 1
- 1
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- Enable
- select
- adminhtml/system_config_source_yesno
- 10
- 1
- 1
- 0
-
-
- Sandbox
- select
- adminhtml/system_config_source_yesno
- 12
- 1
- 1
- 0
-
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 14
- 1
- 1
- 0
-
-
- Merchant ID
- text
- 20
- 1
- 1
- 0
-
-
- Merchant Name
- text
- 21
- 1
- 1
- 0
-
-
- Access Key ID
- text
- 30
- 1
- 1
- 0
-
-
- Secret Key ID
- text
- 40
- 1
- 1
- 0
-
-
- Merchant Token
- text
- 45
- 1
- 1
- 0
-
-
- Merchant Login
- text
- 50
- 1
- 1
- 0
-
-
- Merchant Password
- text
- 55
- 1
- 1
- 0
-
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_new
- 70
- 1
- 1
- 0
-
-
- Use Callback Api
- select
- adminhtml/system_config_source_yesno
- 91
- 0
- 0
- 0
-
-
- Standard Rate
- select
- amazonpayments/adminhtml_shipping_methods
- adminhtml/system_config_backend_serialized
- 100
- 1
- 1
- 0
-
-
- Expedited Rate
- select
- amazonpayments/adminhtml_shipping_methods
- adminhtml/system_config_backend_serialized
- 110
- 1
- 1
- 0
-
-
- OneDay Rate
- select
- amazonpayments/adminhtml_shipping_methods
- adminhtml/system_config_backend_serialized
- 120
- 1
- 1
- 0
-
-
- TwoDay Rate
- select
- amazonpayments/adminhtml_shipping_methods
- adminhtml/system_config_backend_serialized
- 130
- 1
- 1
- 0
-
-
-
-
- Amazon Simple Pay
-
-
-
-
Signing up with Amazon Simple Pay
-
To configure your Amazon Alternate Payment Method (Amazon Simple Pay), you will need to enter your Amazon Web Services Access Key ID, and Secret Access Key.
-
If you do not already have an Amazon Payments Business account, click here to create one now. Sign-Up.
-
To locate your Amazon Web Services Access Key ID and Secret Key ID, sign in to your AWS account and click Your Account > Access Identifiers. Don't have an AWS account? Log in to aws.amazon.com and setup an AWS account.
-
For additional information on setting up your Amazon Simple Pay, Click Here - FAQ.
-
Signup for Amazon Simple Pay
-
-
-]]>
- text
- 601
- 1
- 1
- 1
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- Enable
- select
- adminhtml/system_config_source_yesno
- 9
- 1
- 1
- 0
-
-
- Sandbox
- select
- adminhtml/system_config_source_yesno
- 10
- 1
- 1
- 0
-
-
- Payment action
- select
-
- amazonpayments/payment_asp_source_paymentAction
- 11
- 1
- 1
- 0
-
-
- Access key
- text
- 12
- 1
- 1
- 0
-
-
- Secret key
- text
- 13
- 1
- 1
- 0
-
-
- Payment service URI
- text
- 15
- 0
- 0
- 0
-
-
- Payment sandbox service URI
- text
- 16
- 0
- 0
- 0
-
-
- Immediate return
- select
- adminhtml/system_config_source_yesno
- 19
- 1
- 1
- 0
- Automatically redirect after payment to success page
-
-
- FPS service URI
- text
- 21
- 0
- 0
- 0
-
-
- FPS sandbox service URI
- text
- 22
- 0
- 0
- 0
-
-
-
- Method Choice Checkout Message
- text
- 30
- 1
- 1
- 1
-
-
- Redirect Message
- text
- 31
- 1
- 1
- 1
-
-
- Payment description
- text
- 32
- 1
- 1
- 1
-
-
- Refund description
- text
- 33
- 1
- 1
- 1
-
-
- Payment description
- text
- 34
- 1
- 1
- 1
-
-
- Cancel description
- text
- 35
- 1
- 1
- 1
-
-
- Report email
- text
- 36
- 1
- 1
- 0
-
-
- Email Sender
- select
- adminhtml/system_config_source_email_identity
- 37
- 1
- 1
- 0
-
-
- Notification error transactional email
- select
- adminhtml/system_config_source_email_template
- 38
- 1
- 1
- 1
-
-
- Report error to email
- select
- adminhtml/system_config_source_yesno
- 39
- 1
- 1
- 0
-
-
- Error log
- select
- adminhtml/system_config_source_yesno
- 40
- 1
- 1
- 0
-
-
- Debug log
- select
- adminhtml/system_config_source_yesno
- 41
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-install-0.1.2.php b/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-install-0.1.2.php
deleted file mode 100644
index 49ac50490a..0000000000
--- a/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-install-0.1.2.php
+++ /dev/null
@@ -1,45 +0,0 @@
-startSetup();
-
-$installer->run("
-CREATE TABLE `{$this->getTable('amazonpayments_api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `transaction_id` varchar(255) NOT NULL default '',
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-0.1.0-0.1.1.php b/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-0.1.0-0.1.1.php
deleted file mode 100644
index 49ac50490a..0000000000
--- a/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-0.1.0-0.1.1.php
+++ /dev/null
@@ -1,45 +0,0 @@
-startSetup();
-
-$installer->run("
-CREATE TABLE `{$this->getTable('amazonpayments_api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `transaction_id` varchar(255) NOT NULL default '',
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-0.1.1-0.1.2.php b/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-0.1.1-0.1.2.php
deleted file mode 100644
index 5852a8d0ff..0000000000
--- a/app/code/core/Mage/AmazonPayments/sql/amazonpayments_setup/mysql4-upgrade-0.1.1-0.1.2.php
+++ /dev/null
@@ -1,45 +0,0 @@
-startSetup();
-
-$installer->run("
-CREATE TABLE IF NOT EXISTS `{$this->getTable('amazonpayments_api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `transaction_id` varchar(255) NOT NULL default '',
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Price.php b/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Price.php
index 314a3536aa..ba098363c2 100644
--- a/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Price.php
+++ b/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Price.php
@@ -315,7 +315,7 @@ protected function _calculateBundleOptionPrice()
$this->_prepareDefaultFinalPriceTable();
- $minPrice = new Zend_Db_Expr("IF(SUM(io.min_price) = 0, SUM(io.alt_price), SUM(io.min_price)) + i.price");
+ $minPrice = new Zend_Db_Expr("IF(SUM(io.min_price) = 0, MIN(io.alt_price), SUM(io.min_price)) + i.price");
$maxPrice = new Zend_Db_Expr("SUM(io.max_price) + i.price");
$tierPrice = new Zend_Db_Expr("IF(i.tier_percent IS NOT NULL, IF(SUM(io.tier_price) = 0, "
. "SUM(io.alt_tier_price), SUM(io.tier_price)) + i.tier_price, NULL)");
@@ -444,16 +444,6 @@ protected function _prepareBundlePrice($entityIds = null)
return $this;
}
- /**
- * Retrieve table name for product tier price index
- *
- * @return string
- */
- protected function _getTierPriceIndexTable()
- {
- return $this->getIdxTable($this->getValueTable('catalog/product', 'tier_price'));
- }
-
/**
* Prepare percentage tier price for bundle products
*
diff --git a/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Stock.php b/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Stock.php
index 5c45e6b94d..e2dab72c3d 100644
--- a/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Stock.php
+++ b/app/code/core/Mage/Bundle/Model/Mysql4/Indexer/Stock.php
@@ -101,7 +101,6 @@ protected function _prepareBundleOptionStockData($entityIds = null, $usePrimaryT
'e.entity_id = bs.product_id',
array())
->where('cw.website_id != 0')
- ->where('bo.required = ?', 1)
->group(array('bo.parent_id', 'cw.website_id', 'cis.stock_id', 'bo.option_id'))
->columns(array(
'option_id' => 'bo.option_id',
@@ -112,9 +111,19 @@ protected function _prepareBundleOptionStockData($entityIds = null, $usePrimaryT
$select->where('bo.parent_id IN(?)', $entityIds);
}
+ // clone select for bundle product without required bundle options
+ $selectNonRequired = clone $select;
+
+ $select->where('bo.required = ?', 1);
+ $selectNonRequired->where('bo.required = ?', 0)
+ ->having('`status` = 1');
+
$query = $select->insertFromSelect($this->_getBundleOptionTable());
$adapter->query($query);
+ $query = $selectNonRequired->insertFromSelect($this->_getBundleOptionTable());
+ $adapter->query($query);
+
return $this;
}
diff --git a/app/code/core/Mage/Bundle/Model/Product/Price.php b/app/code/core/Mage/Bundle/Model/Product/Price.php
index 1084ca067f..28def09259 100644
--- a/app/code/core/Mage/Bundle/Model/Product/Price.php
+++ b/app/code/core/Mage/Bundle/Model/Product/Price.php
@@ -146,6 +146,7 @@ public function getPrices($product, $which = null)
}
$options = $this->getOptions($product);
+ $minPriceFounded = false;
if ($options) {
foreach ($options as $option) {
@@ -174,8 +175,12 @@ public function getPrices($product, $which = null)
}
if (count($selectionMinimalPrices)) {
+ $selMinPrice = min($selectionMinimalPrices);
if ($option->getRequired()) {
- $minimalPrice += min($selectionMinimalPrices);
+ $minimalPrice += $selMinPrice;
+ $minPriceFounded = true;
+ } elseif (true !== $minPriceFounded) {
+ $minPriceFounded = false === $minPriceFounded ? $selMinPrice : min($minPriceFounded, $selMinPrice);
}
if ($option->isMultiSelection()) {
@@ -187,6 +192,10 @@ public function getPrices($product, $which = null)
}
}
}
+ // condition is TRUE when all product options are NOT required
+ if (! is_bool($minPriceFounded)) {
+ $minimalPrice = $minPriceFounded;
+ }
if ($product->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
$minimalPrice = $this->_applySpecialPrice($product, $minimalPrice);
diff --git a/app/code/core/Mage/Catalog/Block/Category/View.php b/app/code/core/Mage/Catalog/Block/Category/View.php
index f12ac57b14..8379330934 100644
--- a/app/code/core/Mage/Catalog/Block/Category/View.php
+++ b/app/code/core/Mage/Catalog/Block/Category/View.php
@@ -40,15 +40,19 @@ protected function _prepareLayout()
$this->getLayout()->createBlock('catalog/breadcrumbs');
if ($headBlock = $this->getLayout()->getBlock('head')) {
- if ($title = $this->getCurrentCategory()->getMetaTitle()) {
+ $category = $this->getCurrentCategory();
+ if ($title = $category->getMetaTitle()) {
$headBlock->setTitle($title);
}
- if ($description = $this->getCurrentCategory()->getMetaDescription()) {
+ if ($description = $category->getMetaDescription()) {
$headBlock->setDescription($description);
}
- if ($keywords = $this->getCurrentCategory()->getMetaKeywords()) {
+ if ($keywords = $category->getMetaKeywords()) {
$headBlock->setKeywords($keywords);
}
+ if ($this->helper('catalog/category')->canUseCanonicalTag()) {
+ $headBlock->addLinkRel('canonical', $category->getUrl());
+ }
/*
want to show rss feed in the url
*/
@@ -105,18 +109,43 @@ public function getCmsBlockHtml()
return $this->getData('cms_block_html');
}
+ /**
+ * Check if category display mode is "Products Only"
+ * @return bool
+ */
public function isProductMode()
{
return $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PRODUCT;
}
+ /**
+ * Check if category display mode is "Static Block and Products"
+ * @return bool
+ */
public function isMixedMode()
{
return $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_MIXED;
}
+ /**
+ * Check if category display mode is "Static Block Only"
+ * For anchor category with applied filter Static Block Only mode not allowed
+ *
+ * @return bool
+ */
public function isContentMode()
{
- return $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PAGE;
+ $category = $this->getCurrentCategory();
+ $res = false;
+ if ($category->getDisplayMode()==Mage_Catalog_Model_Category::DM_PAGE) {
+ $res = true;
+ if ($category->getIsAnchor()) {
+ $state = Mage::getSingleton('catalog/layer')->getState();
+ if ($state && $state->getFilters()) {
+ $res = false;
+ }
+ }
+ }
+ return $res;
}
}
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 d25f4ec9f9..bd59edbf10 100644
--- a/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
+++ b/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
@@ -139,6 +139,11 @@ class Mage_Catalog_Block_Product_List_Toolbar extends Mage_Core_Block_Template
*/
protected $_defaultAvailableLimit = array(10=>10,20=>20,50=>50);
+ /**
+ * @var bool $_paramsMemorizeAllowed
+ */
+ protected $_paramsMemorizeAllowed = true;
+
/**
* Retrieve Catalog Config object
*
@@ -182,6 +187,31 @@ protected function _construct()
$this->setTemplate('catalog/product/list/toolbar.phtml');
}
+ /**
+ * Disable list state params memorizing
+ */
+ public function disableParamsMemorizing()
+ {
+ $this->_paramsMemorizeAllowed = false;
+ return $this;
+ }
+
+ /**
+ * Memorize parameter value for session
+ *
+ * @param string $param parameter name
+ * @param mixed $value parameter value
+ * @return Mage_Catalog_Block_Product_List_Toolbar
+ */
+ protected function _memorizeParam($param, $value)
+ {
+ $session = Mage::getSingleton('catalog/session');
+ if ($this->_paramsMemorizeAllowed && !$session->getParamsMemorizeDisabled()) {
+ $session->setData($param, $value);
+ }
+ return $this;
+ }
+
/**
* Set collection to pager
*
@@ -279,32 +309,40 @@ public function getCurrentPage()
}
/**
- * Retrieve current order field
+ * Get grit products sort order field
*
* @return string
*/
public function getCurrentOrder()
{
+ $order = $this->_getData('_current_grid_order');
+ if ($order) {
+ return $order;
+ }
+
$orders = $this->getAvailableOrders();
+ $defaultOrder = $this->_orderField;
+
+ if (!isset($orders[$defaultOrder])) {
+ $keys = array_keys($orders);
+ $defaultOrder = $keys[0];
+ }
+
$order = $this->getRequest()->getParam($this->getOrderVarName());
if ($order && isset($orders[$order])) {
- Mage::getSingleton('catalog/session')->setSortOrder($order);
- }
- else {
+ if ($order == $defaultOrder) {
+ Mage::getSingleton('catalog/session')->unsSortOrder();
+ } else {
+ $this->_memorizeParam('sort_order', $order);
+ }
+ } else {
$order = Mage::getSingleton('catalog/session')->getSortOrder();
}
-
// validate session value
- if (!isset($orders[$order])) {
- $order = $this->_orderField;
+ if (!$order || !isset($orders[$order])) {
+ $order = $defaultOrder;
}
-
- // validate has order value
- if (!isset($orders[$order])) {
- $keys = array_keys($orders);
- $order = $keys[0];
- }
-
+ $this->setData('_current_grid_order', $order);
return $order;
}
@@ -315,20 +353,27 @@ public function getCurrentOrder()
*/
public function getCurrentDirection()
{
+ $dir = $this->_getData('_current_grid_direction');
+ if ($dir) {
+ 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 {
+ if ($dir == $this->_direction) {
+ Mage::getSingleton('catalog/session')->unsSortDirection();
+ } else {
+ $this->_memorizeParam('sort_direction', $dir);
+ }
+ } else {
$dir = Mage::getSingleton('catalog/session')->getSortDirection();
}
-
// validate direction
if (!$dir || !in_array($dir, $directions)) {
$dir = $this->_direction;
}
-
+ $this->setData('_current_grid_direction', $dir);
return $dir;
}
@@ -461,18 +506,28 @@ public function getPagerUrl($params=array())
*/
public function getCurrentMode()
{
+ $mode = $this->_getData('_current_grid_mode');
+ if ($mode) {
+ return $mode;
+ }
+ $modes = array_keys($this->_availableMode);
+ $defaultMode = current($modes);
$mode = $this->getRequest()->getParam($this->getModeVarName());
if ($mode) {
- Mage::getSingleton('catalog/session')->setDisplayMode($mode);
+ if ($mode == $defaultMode) {
+ Mage::getSingleton('catalog/session')->unsDisplayMode();
+ } else {
+ $this->_memorizeParam('display_mode', $mode);
+ }
} else {
$mode = Mage::getSingleton('catalog/session')->getDisplayMode();
}
- if ($mode && isset($this->_availableMode[$mode])) {
- return $mode;
+ if (!$mode || !isset($this->_availableMode[$mode])) {
+ $mode = $defaultMode;
}
- $modes = array_keys($this->_availableMode);
- return current($modes);
+ $this->setData('_current_grid_mode', $mode);
+ return $mode;
}
/**
@@ -661,31 +716,40 @@ protected function _getAvailableLimit($mode)
}
/**
- * Retrieve current limit per page
+ * Get specified products limit display per page
*
* @return string
*/
public function getLimit()
{
+ $limit = $this->_getData('_current_limit');
+ if ($limit) {
+ return $limit;
+ }
+
$limits = $this->getAvailableLimit();
- $limit = $this->getRequest()->getParam($this->getLimitVarName());
+ $defaultLimit = $this->getDefaultPerPageValue();
+ if (!$defaultLimit || !isset($limits[$defaultLimit])) {
+ $keys = array_keys($limits);
+ $defaultLimit = $keys[0];
+ }
+ $limit = $this->getRequest()->getParam($this->getLimitVarName());
if ($limit && isset($limits[$limit])) {
- Mage::getSingleton('catalog/session')->setLimitPage($limit);
+ if ($limit == $defaultLimit) {
+ Mage::getSingleton('catalog/session')->unsLimitPage();
+ } else {
+ $this->_memorizeParam('limit_page', $limit);
+ }
} else {
$limit = Mage::getSingleton('catalog/session')->getLimitPage();
}
- if (isset($limits[$limit])) {
- return $limit;
- }
- if ($limit = $this->getDefaultPerPageValue()) {
- if (isset($limits[$limit])) {
- return $limit;
- }
+ if (!$limit || !isset($limits[$limit])) {
+ $limit = $defaultLimit;
}
- $limits = array_keys($limits);
- return $limits[0];
+ $this->setData('_current_limit', $limit);
+ return $limit;
}
/**
diff --git a/app/code/core/Mage/Catalog/Block/Product/View.php b/app/code/core/Mage/Catalog/Block/Product/View.php
index 230bc7613d..572bd38341 100644
--- a/app/code/core/Mage/Catalog/Block/Product/View.php
+++ b/app/code/core/Mage/Catalog/Block/Product/View.php
@@ -44,22 +44,27 @@ protected function _prepareLayout()
$this->getLayout()->createBlock('catalog/breadcrumbs');
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
- $title = $this->getProduct()->getMetaTitle();
+ $product = $this->getProduct();
+ $title = $product->getMetaTitle();
if ($title) {
$headBlock->setTitle($title);
}
- $keyword = $this->getProduct()->getMetaKeyword();
+ $keyword = $product->getMetaKeyword();
$currentCategory = Mage::registry('current_category');
if ($keyword) {
$headBlock->setKeywords($keyword);
} elseif($currentCategory) {
- $headBlock->setKeywords($this->getProduct()->getName());
+ $headBlock->setKeywords($product->getName());
}
- $description = $this->getProduct()->getMetaDescription();
+ $description = $product->getMetaDescription();
if ($description) {
$headBlock->setDescription( ($description) );
} else {
- $headBlock->setDescription( $this->getProduct()->getDescription() );
+ $headBlock->setDescription($product->getDescription());
+ }
+ if ($this->helper('catalog/product')->canUseCanonicalTag()) {
+ $params = array('_ignore_category'=>true);
+ $headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params));
}
}
diff --git a/app/code/core/Mage/Catalog/Helper/Category.php b/app/code/core/Mage/Catalog/Helper/Category.php
index 2df19c9fdf..f28002605b 100644
--- a/app/code/core/Mage/Catalog/Helper/Category.php
+++ b/app/code/core/Mage/Catalog/Helper/Category.php
@@ -33,7 +33,9 @@
*/
class Mage_Catalog_Helper_Category extends Mage_Core_Helper_Abstract
{
- const XML_PATH_CATEGORY_URL_SUFFIX = 'catalog/seo/category_url_suffix';
+ const XML_PATH_CATEGORY_URL_SUFFIX = 'catalog/seo/category_url_suffix';
+ const XML_PATH_USE_CATEGORY_CANONICAL_TAG = 'catalog/seo/category_canonical_tag';
+
/**
* Store categories cache
@@ -169,4 +171,15 @@ public function getCategoryUrlPath($urlPath, $slash = false, $storeId = null)
return preg_replace($regexp, $replace, $urlPath);
}
+
+ /**
+ * Check if can be used for category
+ *
+ * @param $store
+ * @return bool
+ */
+ public function canUseCanonicalTag($store = null)
+ {
+ return Mage::getStoreConfig(self::XML_PATH_USE_CATEGORY_CANONICAL_TAG, $store);
+ }
}
diff --git a/app/code/core/Mage/Catalog/Helper/Image.php b/app/code/core/Mage/Catalog/Helper/Image.php
index fc4e4ce3cc..dab13ffee5 100644
--- a/app/code/core/Mage/Catalog/Helper/Image.php
+++ b/app/code/core/Mage/Catalog/Helper/Image.php
@@ -483,4 +483,19 @@ public function getOriginalSizeArray()
$this->getOriginalHeight()
);
}
+
+ /**
+ * Check - is this file an image
+ *
+ * @param string $filePath
+ * @return bool
+ * @throw Mage_Core_Exception
+ */
+ public function validateUploadFile($filePath) {
+ if (!getimagesize($filePath)) {
+ Mage::throwException($this->__('Disallowed file type.'));
+ }
+ return true;
+ }
+
}
diff --git a/app/code/core/Mage/Catalog/Helper/Output.php b/app/code/core/Mage/Catalog/Helper/Output.php
index a610481f2d..ea77353984 100644
--- a/app/code/core/Mage/Catalog/Helper/Output.php
+++ b/app/code/core/Mage/Catalog/Helper/Output.php
@@ -100,6 +100,13 @@ public function process($method, $result, $params)
*/
public function productAttribute($product, $attributeHtml, $attributeName)
{
+ $attributes = $product->getAttributes();
+ $attribute = (isset($attributes[$attributeName])) ? $attributes[$attributeName] : null;
+
+ if ($attribute && ($attribute->getFrontendInput() != 'media_image')
+ && (!$attribute->getIsHtmlAllowedOnFront() && !$attribute->getIsWysiwygEnabled())) {
+ $attributeHtml = $this->htmlEscape($attributeHtml);
+ }
$attributeHtml = $this->process('productAttribute', $attributeHtml, array(
'product' => $product,
'attribute' => $attributeName
@@ -117,6 +124,12 @@ public function productAttribute($product, $attributeHtml, $attributeName)
*/
public function categoryAttribute($category, $attributeHtml, $attributeName)
{
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_category', $attributeName);
+
+ if ($attribute && ($attribute->getFrontendInput() != 'image')
+ && (!$attribute->getIsHtmlAllowedOnFront() && !$attribute->getIsWysiwygEnabled())) {
+ $attributeHtml = $this->htmlEscape($attributeHtml);
+ }
$attributeHtml = $this->process('categoryAttribute', $attributeHtml, array(
'category' => $category,
'attribute' => $attributeName
diff --git a/app/code/core/Mage/Catalog/Helper/Product.php b/app/code/core/Mage/Catalog/Helper/Product.php
index eacb41e216..a41930c8bc 100644
--- a/app/code/core/Mage/Catalog/Helper/Product.php
+++ b/app/code/core/Mage/Catalog/Helper/Product.php
@@ -31,8 +31,9 @@
*/
class Mage_Catalog_Helper_Product extends Mage_Core_Helper_Url
{
- const XML_PATH_PRODUCT_URL_SUFFIX = 'catalog/seo/product_url_suffix';
- const XML_PATH_PRODUCT_URL_USE_CATEGORY = 'catalog/seo/product_use_categories';
+ const XML_PATH_PRODUCT_URL_SUFFIX = 'catalog/seo/product_url_suffix';
+ const XML_PATH_PRODUCT_URL_USE_CATEGORY = 'catalog/seo/product_use_categories';
+ const XML_PATH_USE_PRODUCT_CANONICAL_TAG = 'catalog/seo/product_canonical_tag';
/**
* Cache for product rewrite suffix
@@ -187,4 +188,15 @@ public function getProductUrlSuffix($storeId = null)
}
return $this->_productUrlSuffix[$storeId];
}
+
+ /**
+ * Check if can be used for product
+ *
+ * @param $store
+ * @return bool
+ */
+ public function canUseCanonicalTag($store = null)
+ {
+ return Mage::getStoreConfig(self::XML_PATH_USE_PRODUCT_CANONICAL_TAG, $store);
+ }
}
diff --git a/app/code/core/Mage/Catalog/Model/Category/Indexer/Flat.php b/app/code/core/Mage/Catalog/Model/Category/Indexer/Flat.php
index f13f15364d..d40f71770d 100644
--- a/app/code/core/Mage/Catalog/Model/Category/Indexer/Flat.php
+++ b/app/code/core/Mage/Catalog/Model/Category/Indexer/Flat.php
@@ -110,7 +110,7 @@ public function matchEvent(Mage_Index_Model_Event $event)
} else if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
/* @var $store Mage_Core_Model_Store */
$store = $event->getDataObject();
- if ($store->isObjectNew() || $store->dataHasChangedFor('group_id')) {
+ if ($store->isObjectNew() || $store->dataHasChangedFor('group_id') || $store->dataHasChangedFor('root_catefory_id')) {
$result = true;
} else {
$result = false;
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php
index 40006117ee..85909002f9 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Price.php
@@ -78,8 +78,9 @@ public function afterSave($object)
/**
* Orig value is only for existing objects
*/
- $origValue= $object->getOrigData($this->getAttribute()->getAttributeCode());
- if ($object->getStoreId() != 0 || !$value || $origValue) {
+ $oridData = $object->getOrigData();
+ $origValueExist = $oridData && array_key_exists($this->getAttribute()->getAttributeCode(), $oridData);
+ if ($object->getStoreId() != 0 || !$value || $origValueExist) {
return $this;
}
diff --git a/app/code/core/Mage/Catalog/Model/Product/Image.php b/app/code/core/Mage/Catalog/Model/Product/Image.php
index 7ea630e7fa..be9af71f0f 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Image.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Image.php
@@ -288,6 +288,9 @@ public function setBaseFile($file)
}
else {
$baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default'));
+ if (!file_exists($baseDir . $file)) {
+ $baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default', '_package' => 'base'));
+ }
}
}
$this->_isBaseFilePlaceholder = true;
diff --git a/app/code/core/Mage/Catalog/Model/Product/Type.php b/app/code/core/Mage/Catalog/Model/Product/Type.php
index 55959d032c..9a8f00af9f 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Type.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Type.php
@@ -107,7 +107,7 @@ static public function getOptionArray()
{
$options = array();
foreach(self::getTypes() as $typeId=>$type) {
- $options[$typeId] = $type['label'];
+ $options[$typeId] = Mage::helper('catalog')->__($type['label']);
}
return $options;
diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Price.php b/app/code/core/Mage/Catalog/Model/Product/Type/Price.php
index addecdc629..eee4640a69 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Type/Price.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Type/Price.php
@@ -65,7 +65,7 @@ public function getFinalPrice($qty=null, $product)
$finalPrice = $this->_applySpecialPrice($product, $finalPrice);
$product->setFinalPrice($finalPrice);
- Mage::dispatchEvent('catalog_product_get_final_price', array('product'=>$product));
+ Mage::dispatchEvent('catalog_product_get_final_price', array('product'=>$product, 'qty' => $qty));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
diff --git a/app/code/core/Mage/Catalog/Model/Product/Url.php b/app/code/core/Mage/Catalog/Model/Product/Url.php
index 6cec32cb1f..f30ee5f72b 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Url.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Url.php
@@ -175,8 +175,13 @@ public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
$routeParams = $params;
$storeId = $product->getStoreId();
- $categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId()
- ? $product->getCategoryId() : null;
+ if (isset($params['_ignore_category'])) {
+ unset($params['_ignore_category']);
+ $categoryId = null;
+ } else {
+ $categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId()
+ ? $product->getCategoryId() : null;
+ }
if ($product->hasUrlDataObject()) {
$requestPath = $product->getUrlDataObject()->getUrlRewrite();
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Abstract.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Abstract.php
index 324a86a50d..0e87172f0d 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Abstract.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Abstract.php
@@ -33,6 +33,12 @@
*/
abstract class Mage_Catalog_Model_Resource_Eav_Mysql4_Abstract extends Mage_Eav_Model_Entity_Abstract
{
+ /**
+ * Store firstly set attributes to filter selected attributes when used specific store_id
+ *
+ * @var array
+ */
+ protected $_attributes = array();
/**
* Redeclare attribute model
*
@@ -79,40 +85,27 @@ protected function _getLoadAttributesSelect($object, $table)
*/
if (Mage::app()->isSingleStoreMode()) {
$storeId = Mage::app()->getStore(true)->getId();
- } else {
+ }
+ else {
$storeId = $object->getStoreId();
}
$setId = $object->getAttributeSetId();
+ $storeIds = array($this->getDefaultStoreId());
+ if ($storeId != $this->getDefaultStoreId()) {
+ $storeIds[] = $storeId;
+ }
$select = $this->_read->select()
- ->from(array('default' => $table))
- ->where('default.'.$this->getEntityIdField().'=?', $object->getId())
- ->where('default.store_id=?', $this->getDefaultStoreId());
+ ->from(array('attr_table' => $table))
+ ->where('attr_table.'.$this->getEntityIdField().'=?', $object->getId())
+ ->where('attr_table.store_id IN (?)', $storeIds);
if ($setId) {
$select->join(
array('set_table' => $this->getTable('eav/entity_attribute')),
- 'default.attribute_id=set_table.attribute_id AND '
- . 'set_table.attribute_set_id=' . intval($setId),
+ 'attr_table.attribute_id=set_table.attribute_id AND set_table.attribute_set_id=' . intval($setId),
array()
);
}
-
- if ($storeId != $this->getDefaultStoreId()) {
- $joinCondition = join(' AND ', array(
- 'main.attribute_id=default.attribute_id',
- $this->_read->quoteInto('main.store_id=?', intval($storeId)),
- $this->_read->quoteInto('main.'.$this->getEntityIdField() . '=?', $object->getId())
- ));
- $select->joinLeft(
- array('main' => $table),
- $joinCondition,
- array(
- 'store_value_id' => 'value_id',
- 'store_value' => 'value'
- )
- );
- }
-
return $select;
}
@@ -128,14 +121,21 @@ protected function _setAttribteValue($object, $valueRow)
$attribute = $this->getAttribute($valueRow['attribute_id']);
if ($attribute) {
$attributeCode = $attribute->getAttributeCode();
- if (!empty($valueRow['store_value_id'])) {
- $value = $valueRow['store_value'];
- $valueId = $valueRow['store_value_id'];
- $object->setAttributeDefaultValue($attributeCode, $valueRow['value']);
- } else {
- $value = $valueRow['value'];
- $valueId = $valueRow['value_id'];
+ if (isset($this->_attributes[$valueRow['attribute_id']])) {
+ if ($valueRow['store_id'] == $this->getDefaultStoreId()) {
+ $object->setAttributeDefaultValue($attributeCode, $valueRow['value']);
+ }
+ else {
+ $object->setAttributeDefaultValue($attributeCode, $this->_attributes[$valueRow['attribute_id']]['value']);
+ }
}
+ else {
+ $this->_attributes[$valueRow['attribute_id']] = $valueRow;
+ }
+
+ $value = $valueRow['value'];
+ $valueId = $valueRow['value_id'];
+
$object->setData($attributeCode, $value);
$attribute->getBackend()->setValueId($valueId);
}
@@ -187,7 +187,7 @@ protected function _saveAttributeValue($object, $attribute, $value)
/**
* Update attribute value for website
*/
- $storeIds = $object->getWebsiteStoreIds();
+ $storeIds = Mage::app()->getStore($storeId)->getWebsite()->getStoreIds(true);
foreach ($storeIds as $storeId) {
$bind['store_id'] = $storeId;
$this->_attributeValuesToSave[$table][] = $bind;
@@ -536,13 +536,12 @@ protected function _prepareValueForSave($value, Mage_Eav_Model_Entity_Attribute_
*/
public function getAttributeRawValue($entityId, $attribute, $store)
{
- $result = '';
- $attribute = $this->getAttribute($attribute);
/* @var $attribute Mage_Catalog_Model_Entity_Attribute */
+ $attribute = $this->getAttribute($attribute);
if ($attribute) {
/* @var $select Zend_Db_Select */
$select = $this->_read->select();
-
+ $attributeCode = $attribute->getAttributeCode();
$attrTable = $attribute->getBackend()->getTable();
$isStatic = $attribute->getBackend()->isStatic();
$attrField = $isStatic ? $attributeCode : 'value';
@@ -573,4 +572,18 @@ public function getAttributeRawValue($entityId, $attribute, $store)
return false;
}
+
+ /**
+ * Reset firstly loaded attributes
+ *
+ * @param Varien_Object $object
+ * @param integer $entityId
+ * @param array|null $attributes
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Abstract
+ */
+ public function load($object, $entityId, $attributes=array())
+ {
+ $this->_attributes = array();
+ return parent::load($object, $entityId, $attributes);
+ }
}
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Indexer/Product.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Indexer/Product.php
index d8d5d870ed..eb0fb43926 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Indexer/Product.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Indexer/Product.php
@@ -241,7 +241,7 @@ protected function _refreshDirectRelations($categoryIds=null, $productIds=null)
->joinInner(array('rc' => $this->_categoryTable), 'rc.entity_id=g.root_category_id', array())
->joinInner(
array('ce'=>$this->_categoryTable),
- 'ce.entity_id=cp.category_id AND ce.path LIKE CONCAT(rc.path, \'/%\')',
+ 'ce.entity_id=cp.category_id AND (ce.path LIKE CONCAT(rc.path, \'/%\') OR ce.entity_id=rc.entity_id)',
array())
->joinLeft(
array('dv'=>$visibilityInfo['table']),
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Tree.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Tree.php
index 4f32918fa2..dbe84f7c32 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Tree.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Category/Tree.php
@@ -74,7 +74,7 @@ public function __construct()
$resource = Mage::getSingleton('core/resource');
parent::__construct(
- $resource->getConnection('catalog_read'),
+ $resource->getConnection('catalog_write'),
$resource->getTableName('catalog/category'),
array(
Varien_Data_Tree_Dbp::ID_FIELD => 'entity_id',
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php
index 9e20f520de..903d9c951d 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php
@@ -651,6 +651,41 @@ public function getAttributeValueCount($attribute)
return $res;
}
+ /**
+ * Return all attribute values as array in form:
+ * array(
+ * [entity_id_1] => array(
+ * [store_id_1] => store_value_1,
+ * [store_id_2] => store_value_2,
+ * ...
+ * [store_id_n] => store_value_n
+ * ),
+ * ...
+ * )
+ *
+ * @param string $attribute attribute code
+ * @return array
+ */
+ public function getAllAttributeValues($attribute)
+ {
+ /** @var Zend_Db_Select */
+ $select = clone $this->getSelect();
+ $attribute = $this->getEntity()->getAttribute($attribute);
+
+ $select->reset()
+ ->from($attribute->getBackend()->getTable(), array('entity_id', 'store_id', 'value'))
+ ->where('attribute_id = ?', $attribute->getId(), Zend_Db::INT_TYPE);
+
+ $data = $this->getConnection()->fetchAll($select);
+ $res = array();
+
+ foreach ($data as $row) {
+ $res[$row['entity_id']][$row['store_id']] = $row['value'];
+ }
+
+ return $res;
+ }
+
/**
* Get SQL for get record count
*
@@ -753,7 +788,7 @@ public function addCountToCategories($categoryCollection)
$anchorStmt = clone $select;
$anchorStmt->limit(); //reset limits
$anchorStmt->where('count_table.category_id in (?)', $isAnchor);
- $productCounts += $this->getConnection()->fetchPairs($anchorStmt, array('category_id'=>'product_count'));
+ $productCounts += $this->getConnection()->fetchPairs($anchorStmt);
$anchorStmt = null;
}
if ($isNotAnchor) {
@@ -761,7 +796,7 @@ public function addCountToCategories($categoryCollection)
$notAnchorStmt->limit(); //reset limits
$notAnchorStmt->where('count_table.category_id in (?)', $isNotAnchor);
$notAnchorStmt->where('count_table.is_parent=1');
- $productCounts += $this->getConnection()->fetchPairs($notAnchorStmt, array('category_id'=>'product_count'));
+ $productCounts += $this->getConnection()->fetchPairs($notAnchorStmt);
$notAnchorStmt = null;
}
$select = null;
@@ -1080,7 +1115,24 @@ public function addAttributeToFilter($attribute, $condition=null, $joinType='inn
$this->_allIdsCache = null;
if (is_string($attribute) && $attribute == 'is_saleable') {
- $this->getSelect()->where($this->_getConditionSql('(IF(manage_stock, is_in_stock, 1))', $condition));
+ $isStockManagedInConfig = (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
+ $inventoryTable = $this->getTable('cataloginventory_stock_item');
+ $this->getSelect()->where(
+ $this->_getConditionSql(
+ "(
+ IF(
+ IF(
+ $inventoryTable.use_config_manage_stock,
+ $isStockManagedInConfig,
+ $inventoryTable.manage_stock
+ ),
+ $inventoryTable.is_in_stock,
+ 1
+ )
+ )",
+ $condition
+ )
+ );
return $this;
}
else {
@@ -1217,6 +1269,11 @@ public function addAttributeToSort($attribute, $dir='asc')
return $this;
}
+ if($attribute == 'is_saleable'){
+ $this->getSelect()->order("is_saleable " . $dir);
+ return $this;
+ }
+
if ($this->isEnabledFlat()) {
$column = $this->getEntity()->getAttributeSortColumn($attribute);
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Compare/Item/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Compare/Item/Collection.php
index ca9489a317..00cc0d942e 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Compare/Item/Collection.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Compare/Item/Collection.php
@@ -218,11 +218,12 @@ protected function _getAttributeIdsBySetIds(array $setIds)
/**
* Retrieve Merged comparable attributes for compared product items
*
- * @return this
+ * @return array
*/
public function getComparableAttributes()
{
if (is_null($this->_comparableAttributes)) {
+ $this->_comparableAttributes = array();
$setIds = $this->_getAttributeSetIds();
if ($setIds) {
$attributeIds = $this->_getAttributeIdsBySetIds($setIds);
@@ -253,9 +254,6 @@ public function getComparableAttributes()
unset($attributesData);
}
}
- else {
- $this->_comparableAttributes = array();
- }
}
return $this->_comparableAttributes;
}
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php
index 6a83c567a7..ab0019d5ae 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php
@@ -369,7 +369,7 @@ public function reindexAll()
*/
protected function _getTierPriceIndexTable()
{
- return $this->getIdxTable($this->getValueTable('catalog/product', 'tier_price'));
+ return $this->getTable('catalog/product_index_tier_price');
}
/**
@@ -382,19 +382,7 @@ protected function _prepareTierPriceIndex($entityIds = null)
{
$write = $this->_getWriteAdapter();
$table = $this->_getTierPriceIndexTable();
-
- $query = sprintf('DROP TABLE IF EXISTS %s', $write->quoteIdentifier($table));
- $write->query($query);
-
- $query = sprintf('CREATE TABLE %s ('
- . ' `entity_id` INT(10) UNSIGNED NOT NULL,'
- . ' `customer_group_id` SMALLINT(5) UNSIGNED NOT NULL,'
- . ' `website_id` SMALLINT(5) UNSIGNED NOT NULL,'
- . ' `min_price` DECIMAL(12,4) DEFAULT NULL,'
- . ' PRIMARY KEY (`entity_id`,`customer_group_id`,`website_id`)'
- . ') ENGINE=INNODB DEFAULT CHARSET=utf8',
- $write->quoteIdentifier($table));
- $write->query($query);
+ $write->delete($table);
$select = $write->select()
->from(
@@ -463,7 +451,7 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null)
*/
protected function _getWebsiteDateTable()
{
- return $this->getIdxTable($this->getValueTable('core/website', 'date'));
+ return $this->getTable('catalog/product_index_website');
}
/**
@@ -475,26 +463,25 @@ protected function _prepareWebsiteDateTable()
{
$write = $this->_getWriteAdapter();
$table = $this->_getWebsiteDateTable();
+ $write->delete($table);
- $query = sprintf('DROP TABLE IF EXISTS %s', $write->quoteIdentifier($table));
- $write->query($query);
+ $baseCurrency = Mage::app()->getBaseCurrencyCode();
- $query = sprintf('CREATE TABLE %s ('
- . ' `website_id` SMALLINT(5) UNSIGNED NOT NULL,'
- . ' `date` DATE DEFAULT NULL,'
- . ' `rate` FLOAT(12, 4) UNSIGNED DEFAULT 1,'
- . ' PRIMARY KEY (`website_id`),'
- . ' KEY `IDX_DATE` (`date`)'
- . ') ENGINE=INNODB DEFAULT CHARSET=utf8',
- $write->quoteIdentifier($table));
- $write->query($query);
+ $select = $write->select()
+ ->from(
+ array('cw' => $this->getTable('core/website')),
+ array('website_id'))
+ ->join(
+ array('csg' => $this->getTable('core/store_group')),
+ 'cw.default_group_id = csg.group_id',
+ array('store_id' => 'default_store_id'))
+ ->where('cw.website_id != 0');
- $baseCurrency = Mage::app()->getBaseCurrencyCode();
$data = array();
- /* @var $coreDate Mage_Core_Model_Date */
- $websites = Mage::app()->getWebsites(false);
- foreach ($websites as $website) {
+ foreach ($write->fetchAll($select) as $item) {
/* @var $website Mage_Core_Model_Website */
+ $website = Mage::app()->getWebsite($item['website_id']);
+
if ($website->getBaseCurrencyCode() != $baseCurrency) {
$rate = Mage::getModel('directory/currency')
->load($baseCurrency)
@@ -505,7 +492,9 @@ protected function _prepareWebsiteDateTable()
} else {
$rate = 1;
}
- $store = $website->getDefaultStore();
+
+ /* @var $store Mage_Core_Model_Store */
+ $store = Mage::app()->getStore($item['store_id']);
if ($store) {
$timestamp = Mage::app()->getLocale()->storeTimeStamp($store);
$data[] = array(
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Default.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Default.php
index deec5dc292..ed4258aa6f 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Default.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Default.php
@@ -186,7 +186,7 @@ protected function _prepareDefaultFinalPriceTable()
*/
protected function _getWebsiteDateTable()
{
- return $this->getIdxTable($this->getValueTable('core/website', 'date'));
+ return $this->getTable('catalog/product_index_website');
}
/**
@@ -247,8 +247,8 @@ protected function _prepareFinalPriceData($entityIds = null)
$curentDate = new Zend_Db_Expr('cwd.date');
$finalPrice = new Zend_Db_Expr("IF(IF({$specialFrom} IS NULL, 1, "
- . "IF({$specialFrom} <= {$curentDate}, 1, 0)) > 0 AND IF({$specialTo} IS NULL, 1, "
- . "IF({$specialTo} >= {$curentDate}, 1, 0)) > 0 AND {$specialPrice} < {$price}, "
+ . "IF(DATE({$specialFrom}) <= {$curentDate}, 1, 0)) > 0 AND IF({$specialTo} IS NULL, 1, "
+ . "IF(DATE({$specialTo}) >= {$curentDate}, 1, 0)) > 0 AND {$specialPrice} < {$price}, "
. "{$specialPrice}, {$price})");
$select->columns(array(
'orig_price' => $price,
@@ -567,7 +567,7 @@ protected function _movePriceDataToIndexTable()
*/
protected function _getTierPriceIndexTable()
{
- return $this->getIdxTable($this->getValueTable('catalog/product', 'tier_price'));
+ return $this->getTable('catalog/product_index_tier_price');
}
/**
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php
index 06f76b21f9..e1f509a1ef 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php
@@ -763,7 +763,6 @@ public function getProductIdsByCategory($category)
protected function _getProducts($productIds = null, $storeId, $entityId = 0, &$lastEntityId)
{
$products = array();
-
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
if (!is_null($productIds)) {
if (!is_array($productIds)) {
@@ -803,10 +802,11 @@ protected function _getProducts($productIds = null, $storeId, $entityId = 0, &$l
$this->getTable('catalog/category_product'),
array('product_id', 'category_id'))
->where('product_id IN(?)', array_keys($products));
- $categories = $this->_getReadAdapter()->fetchPairs($select);
- foreach ($categories as $productId => $categoryId) {
+ $categories = $this->_getReadAdapter()->fetchAll($select);
+ foreach ($categories as $category) {
+ $productId = $category['product_id'];
$categoryIds = $products[$productId]->getCategoryIds();
- $categoryIds[] = $categoryId;
+ $categoryIds[] = $category['category_id'];
$products[$productId]->setCategoryIds($categoryIds);
}
@@ -896,6 +896,28 @@ public function clearCategoryProduct($storeId)
return $this;
}
+
+ /**
+ * Remove unused rewrites for product
+ *
+ * @param int $productId Product entity Id
+ * @param int $storeId Store Id for rewrites
+ * @param array $excludeCategoryIds Array of category Ids that should be skipped
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Url
+ */
+ public function clearProductRewrites($productId, $storeId, $excludeCategoryIds = array())
+ {
+ $adapter = $this->_getWriteAdapter();
+ $where = $adapter->quoteInto('product_id=?', $productId);
+ $where.= $adapter->quoteInto(' AND store_id=?', $storeId);
+ $where.= ' AND category_id IS NOT NULL';
+ if (!empty($excludeCategoryIds)) {
+ $where.= $adapter->quoteInto(' AND category_id NOT IN (?)', $excludeCategoryIds);
+ }
+ $adapter->delete($this->getMainTable(), $where);
+
+ return $this;
+ }
/**
* Delete rewrites for associated to category products
diff --git a/app/code/core/Mage/Catalog/Model/Url.php b/app/code/core/Mage/Catalog/Model/Url.php
index bc482710d1..a41a196b45 100644
--- a/app/code/core/Mage/Catalog/Model/Url.php
+++ b/app/code/core/Mage/Catalog/Model/Url.php
@@ -373,6 +373,8 @@ public function refreshProductRewrite($productId, $storeId = null)
$this->_refreshProductRewrite($product, $category);
}
+ $this->getResource()->clearProductRewrites($productId, $storeId, array_keys($categories));
+
unset($categories);
unset($product);
diff --git a/app/code/core/Mage/Catalog/controllers/Product/CompareController.php b/app/code/core/Mage/Catalog/controllers/Product/CompareController.php
index 1b6bf5710e..72dd04f0a5 100644
--- a/app/code/core/Mage/Catalog/controllers/Product/CompareController.php
+++ b/app/code/core/Mage/Catalog/controllers/Product/CompareController.php
@@ -75,7 +75,7 @@ public function addAction()
if ($product->getId()/* && !$product->isSuper()*/) {
Mage::getSingleton('catalog/product_compare_list')->addProduct($product);
Mage::getSingleton('catalog/session')->addSuccess(
- $this->__('Product %s successfully added to compare list', $product->getName())
+ $this->__('Product %s successfully added to compare list', Mage::helper('core')->htmlEscape($product->getName()))
);
Mage::dispatchEvent('catalog_product_compare_add_product', array('product'=>$product));
}
diff --git a/app/code/core/Mage/Catalog/etc/config.xml b/app/code/core/Mage/Catalog/etc/config.xml
index f5dcd07378..1c4d133b23 100644
--- a/app/code/core/Mage/Catalog/etc/config.xml
+++ b/app/code/core/Mage/Catalog/etc/config.xml
@@ -28,7 +28,7 @@
- 1.4.0.0.18
+ 1.4.0.0.21
@@ -193,6 +193,8 @@
catalog_product_index_eav
catalog_product_index_eav_decimal
catalog_product_index_price
+ catalog_product_index_tier_price
+ catalog_product_index_website
@@ -651,6 +653,8 @@
.html
1
-
+ 0
+ 0
m,d,y
diff --git a/app/code/core/Mage/Catalog/etc/system.xml b/app/code/core/Mage/Catalog/etc/system.xml
index 6ea2aefed1..c7e8a30a03 100644
--- a/app/code/core/Mage/Catalog/etc/system.xml
+++ b/app/code/core/Mage/Catalog/etc/system.xml
@@ -236,6 +236,24 @@
1
1
+
+ Use Canonical Link Meta Tag For Categories
+ select
+ adminhtml/system_config_source_yesno
+ 6
+ 1
+ 1
+ 1
+
+
+ Use Canonical Link Meta Tag For Products
+ select
+ adminhtml/system_config_source_yesno
+ 7
+ 1
+ 1
+ 1
+
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.5-0.8.6.php b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.18-1.4.0.0.19.php
similarity index 76%
rename from app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.5-0.8.6.php
rename to app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.18-1.4.0.0.19.php
index 76be88fd4b..bdc810578b 100644
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.5-0.8.6.php
+++ b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.18-1.4.0.0.19.php
@@ -19,19 +19,18 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Oscommerce
+ * @package Mage_Catalog
* @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)
*/
+/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
$installer = $this;
-/* @var $installer Mage_Core_Model_Resource_Setup */
-$installer->startSetup();
+$table = $this->getTable('catalog/category_product');
-$installer->run("
-
-insert into `{$this->getTable('oscommerce_import_type')}`(`type_code`,`type_name`) values ('root_category', 'Root Category');
-");
+/**
+ * Remove data duplicates
+ */
+$installer->getConnection()->changeColumn($table, 'position', 'position', "INT( 10 ) NOT NULL DEFAULT '0'");
-$installer->endSetup();
diff --git a/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.19-1.4.0.0.20.php b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.19-1.4.0.0.20.php
new file mode 100644
index 0000000000..ac1242ea86
--- /dev/null
+++ b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.19-1.4.0.0.20.php
@@ -0,0 +1,58 @@
+run("
+-- Removing old index tables if exists
+DROP TABLE IF EXISTS `{$installer->getTable('catalog/product')}_tier_price_idx`;
+DROP TABLE IF EXISTS `{$installer->getTable('core/website')}_date_idx`;
+
+CREATE TABLE IF NOT EXISTS `{$installer->getTable('catalog/product_index_tier_price')}` (
+ `entity_id` INT(10) UNSIGNED NOT NULL,
+ `customer_group_id` SMALLINT(5) UNSIGNED NOT NULL,
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL,
+ `min_price` DECIMAL(12,4) DEFAULT NULL,
+ PRIMARY KEY (`entity_id`,`customer_group_id`,`website_id`),
+ CONSTRAINT `FK_CATALOG_PRODUCT_INDEX_TIER_PRICE_ENTITY` FOREIGN KEY (`entity_id`)
+ REFERENCES `{$this->getTable('catalog/product')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_CATALOG_PRODUCT_INDEX_TIER_PRICE_CUSTOMER` FOREIGN KEY (`customer_group_id`)
+ REFERENCES `{$this->getTable('customer/customer_group')}` (`customer_group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_CATALOG_PRODUCT_INDEX_TIER_PRICE_WEBSITE` FOREIGN KEY (`website_id`)
+ REFERENCES `{$this->getTable('core/website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `{$installer->getTable('catalog/product_index_website')}` (
+ `website_id` SMALLINT(5) UNSIGNED NOT NULL,
+ `date` DATE DEFAULT NULL,
+ `rate` FLOAT(12, 4) UNSIGNED DEFAULT 1,
+ PRIMARY KEY (`website_id`),
+ KEY `IDX_DATE` (`date`),
+ CONSTRAINT `FK_CATALOG_PRODUCT_INDEX_WEBSITE` FOREIGN KEY (`website_id`)
+ REFERENCES `{$this->getTable('core/website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+");
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.9-0.8.10.php b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.20-1.4.0.0.21.php
similarity index 76%
rename from app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.9-0.8.10.php
rename to app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.20-1.4.0.0.21.php
index 9612da29d1..14eda31d53 100644
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.9-0.8.10.php
+++ b/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.20-1.4.0.0.21.php
@@ -19,20 +19,17 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Oscommerce
+ * @package Mage_Catalog
* @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)
*/
+/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
$installer = $this;
-/* @var $installer Mage_Core_Model_Resource_Setup */
-$installer->startSetup();
+$table = $this->getTable('catalog/category_product_index');
-$installer->run("
-
-ALTER TABLE `{$this->getTable('oscommerce_import')}` ADD send_subscription BOOL NOT NULL DEFAULT '0';
-
-");
-
-$installer->endSetup();
+/**
+ * Remove data duplicates
+ */
+$installer->getConnection()->changeColumn($table, 'position', 'position', "INT( 10 ) NOT NULL DEFAULT '0'");
diff --git a/app/code/core/Mage/CatalogIndex/Model/Mysql4/Aggregation.php b/app/code/core/Mage/CatalogIndex/Model/Mysql4/Aggregation.php
index eba7be0dc2..c58aab2c74 100644
--- a/app/code/core/Mage/CatalogIndex/Model/Mysql4/Aggregation.php
+++ b/app/code/core/Mage/CatalogIndex/Model/Mysql4/Aggregation.php
@@ -74,6 +74,8 @@ public function saveCacheData($data, $key, $tags, $storeId)
{
$data = serialize($data);
$tags = $this->_getTagIds($tags);
+
+ /*
$select = $this->_getWriteAdapter()->select()
->from(array('a'=>$this->getMainTable()), $this->getIdFieldName())
->where('a.store_id=?', $storeId)
@@ -95,6 +97,17 @@ public function saveCacheData($data, $key, $tags, $storeId)
));
$id = $this->_getWriteAdapter()->lastInsertId();
}
+ */
+
+ $this->_getWriteAdapter()->insertOnDuplicate($this->getMainTable(), array(
+ 'store_id' => $storeId,
+ 'created_at'=> $this->formatDate(time()),
+ 'key' => $key,
+ 'data' => $data
+ ), array('created_at', 'data'));
+
+ $id = $this->_getWriteAdapter()->lastInsertId();
+
$this->_saveTagRelations($id, $tags);
return $this;
}
diff --git a/app/code/core/Mage/CatalogInventory/Model/Mysql4/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Mysql4/Stock/Item.php
index bfb1f0088a..044e279de0 100644
--- a/app/code/core/Mage/CatalogInventory/Model/Mysql4/Stock/Item.php
+++ b/app/code/core/Mage/CatalogInventory/Model/Mysql4/Stock/Item.php
@@ -79,10 +79,23 @@ protected function _getLoadSelect($field, $value, $object)
public function addCatalogInventoryToProductCollection($productCollection)
{
$isStockManagedInConfig = (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
+ $inventoryTable = $this->getTable('cataloginventory/stock_item');
$productCollection->joinTable('cataloginventory/stock_item',
'product_id=entity_id',
array(
- 'is_saleable' => new Zend_Db_Expr('(IF(IF(use_config_manage_stock, ' . $isStockManagedInConfig . ', manage_stock), is_in_stock, 1))'),
+ 'is_saleable' => new Zend_Db_Expr(
+ "(
+ IF(
+ IF(
+ $inventoryTable.use_config_manage_stock,
+ $isStockManagedInConfig,
+ $inventoryTable.manage_stock
+ ),
+ $inventoryTable.is_in_stock,
+ 1
+ )
+ )"
+ ),
'inventory_in_stock' => 'is_in_stock'
),
null, 'left');
diff --git a/app/code/core/Mage/CatalogRule/Model/Rule.php b/app/code/core/Mage/CatalogRule/Model/Rule.php
index 24b5ddfc1f..d5067a78b8 100644
--- a/app/code/core/Mage/CatalogRule/Model/Rule.php
+++ b/app/code/core/Mage/CatalogRule/Model/Rule.php
@@ -48,7 +48,7 @@ class Mage_CatalogRule_Model_Rule extends Mage_Rule_Model_Rule
*
* @var array
*/
- protected $_productIds = array();
+ protected $_productIds;
protected $_now;
@@ -138,26 +138,28 @@ protected function _afterSave()
*/
public function getMatchingProductIds()
{
- if (empty($this->_productIds)) {
- $productCollection = Mage::getResourceModel('catalog/product_collection');
+ if (is_null($this->_productIds)) {
+ $this->_productIds = array();
+ $this->setCollectedAttributes(array());
$websiteIds = explode(',', $this->getWebsiteIds());
- if (!empty($websiteIds)) {
- $productCollection->addWebsiteFilter($websiteIds);
- }
- $this->setCollectedAttributes(array());
- $this->getConditions()->collectValidatedAttributes($productCollection);
+ if ($websiteIds) {
+ $productCollection = Mage::getResourceModel('catalog/product_collection');
- $this->_productIds = array();
- Mage::getSingleton('core/resource_iterator')->walk(
- $productCollection->getSelect(),
- array(array($this, 'callbackValidateProduct')),
- array(
- 'attributes'=>$this->getCollectedAttributes(),
- 'product'=>Mage::getModel('catalog/product'),
- )
- );
+ $productCollection->addWebsiteFilter($websiteIds);
+ $this->getConditions()->collectValidatedAttributes($productCollection);
+
+ Mage::getSingleton('core/resource_iterator')->walk(
+ $productCollection->getSelect(),
+ array(array($this, 'callbackValidateProduct')),
+ array(
+ 'attributes' => $this->getCollectedAttributes(),
+ 'product' => Mage::getModel('catalog/product'),
+ )
+ );
+ }
}
+
return $this->_productIds;
}
@@ -169,7 +171,9 @@ public function getMatchingProductIds()
*/
public function callbackValidateProduct($args)
{
- $product = $args['product']->setData($args['row']);
+ $product = clone $args['product'];
+ $product->setData($args['row']);
+
if ($this->getConditions()->validate($product)) {
$this->_productIds[] = $product->getId();
}
diff --git a/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php b/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php
index 5241cdabf1..b161a708d5 100644
--- a/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php
+++ b/app/code/core/Mage/CatalogRule/Model/Rule/Condition/Product.php
@@ -27,6 +27,24 @@
class Mage_CatalogRule_Model_Rule_Condition_Product extends Mage_Rule_Model_Condition_Abstract
{
+ /**
+ * All attribute values as array in form:
+ * array(
+ * [entity_id_1] => array(
+ * [store_id_1] => store_value_1,
+ * [store_id_2] => store_value_2,
+ * ...
+ * [store_id_n] => store_value_n
+ * ),
+ * ...
+ * )
+ *
+ * Will be set only for not global scope attribute
+ *
+ * @var array
+ */
+ protected $_entityAttributeValues = null;
+
/**
* Attribute data key that indicates whether it should be used for rules
*
@@ -200,15 +218,18 @@ public function getAttributeElement()
*/
public function collectValidatedAttributes($productCollection)
{
- if ($this->getAttribute() == 'category_ids') {
- return $this;
+ $attribute = $this->getAttribute();
+ if ('category_ids' != $attribute) {
+ if ($this->getAttributeObject()->isScopeGlobal()) {
+ $attributes = $this->getRule()->getCollectedAttributes();
+ $attributes[$attribute] = true;
+ $this->getRule()->setCollectedAttributes($attributes);
+ $productCollection->addAttributeToSelect($attribute, 'left');
+ } else {
+ $this->_entityAttributeValues = $productCollection->getAllAttributeValues($attribute);
+ }
}
- $attributes = $this->getRule()->getCollectedAttributes();
- $attributes[$this->getAttribute()] = true;
- $this->getRule()->setCollectedAttributes($attributes);
-
- $productCollection->addAttributeToSelect($this->getAttribute(), 'left');
return $this;
}
@@ -354,27 +375,47 @@ public function loadArray($arr)
*/
public function validate(Varien_Object $object)
{
- if ($this->getAttribute() == 'category_ids') {
+ $attrCode = $this->getAttribute();
+
+ if ('category_ids' == $attrCode) {
return $this->validateAttribute($object->getAvailableInCategories());
- }
+ } elseif (! isset($this->_entityAttributeValues[$object->getId()])) {
+ $attr = $object->getResource()->getAttribute($attrCode);
- $attr = $object->getResource()->getAttribute($this->getAttribute());
- if ($attr && $attr->getBackendType()=='datetime' && !is_int($this->getValue())) {
- $this->setValue(strtotime($this->getValue()));
- $value = strtotime($object->getData($this->getAttribute()));
- return $this->validateAttribute($value);
- }
+ if ($attr && $attr->getBackendType() == 'datetime' && ! is_int($this->getValue())) {
+ $this->setValue(strtotime($this->getValue()));
+ $value = strtotime($object->getData($attrCode));
+ return $this->validateAttribute($value);
+ }
- if ($attr && $attr->getFrontendInput() == 'multiselect') {
- $value = $object->getData($this->getAttribute());
- if (!strlen($value)) {
- $value = array();
+ if ($attr && $attr->getFrontendInput() == 'multiselect') {
+ $value = $object->getData($attrCode);
+ $value = strlen($value) ? explode(',', $value) : array();
+ return $this->validateAttribute($value);
+ }
+
+ return parent::validate($object);
+ } else {
+ $result = false; // any valid value will set it to TRUE
+ $oldAttrValue = $object->hasData($attrCode) ? $object->getData($attrCode) : null; // remember old attribute state
+
+ foreach ($this->_entityAttributeValues[$object->getId()] as $storeId => $value) {
+ $object->setData($attrCode, $value);
+
+ $result |= parent::validate($object);
+
+ if ($result) {
+ break;
+ }
+ }
+
+ if (is_null($oldAttrValue)) {
+ $object->unsetData($attrCode);
} else {
- $value = explode(',', $value);
+ $object->setData($attrCode, $oldAttrValue);
}
- return $this->validateAttribute($value);
- }
- return parent::validate($object);
+ return (bool) $result;
+ }
}
}
diff --git a/app/code/core/Mage/CatalogSearch/Helper/Data.php b/app/code/core/Mage/CatalogSearch/Helper/Data.php
index 2f05d5f3ff..16daf7e515 100644
--- a/app/code/core/Mage/CatalogSearch/Helper/Data.php
+++ b/app/code/core/Mage/CatalogSearch/Helper/Data.php
@@ -140,7 +140,7 @@ public function getQueryText()
*/
public function getEscapedQueryText()
{
- return $this->getQueryText();
+ return $this->htmlEscape($this->getQueryText());
}
/**
diff --git a/app/code/core/Mage/AmazonPayments/Block/Asp/Redirect.php b/app/code/core/Mage/Centinel/Block/Adminhtml/Validation.php
similarity index 54%
rename from app/code/core/Mage/AmazonPayments/Block/Asp/Redirect.php
rename to app/code/core/Mage/Centinel/Block/Adminhtml/Validation.php
index 5569b37011..60f0cbf1b3 100644
--- a/app/code/core/Mage/AmazonPayments/Block/Asp/Redirect.php
+++ b/app/code/core/Mage/Centinel/Block/Adminhtml/Validation.php
@@ -19,59 +19,57 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_AmazonPayments
+ * @package Mage_Centinel
* @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)
*/
/**
- * AmazonPayments Form Block
- *
- * @category Mage
- * @package Mage_AmazonPayments
- * @author Magento Core Team
+ * Adminhtml sales order create validation card block
*/
-class Mage_AmazonPayments_Block_Asp_Redirect extends Mage_Core_Block_Template
+class Mage_Centinel_Block_Adminhtml_Validation extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract
{
-
/**
- * Return Amazon Simple Pay payment model
- *
- * @return Mage_AmazonPayments_Model_Payment_Asp
+ * construct
*/
- public function getPayment()
+ public function __construct()
{
- return Mage::registry('amazonpayments_payment_asp');
+ parent::__construct();
+ $this->setId('sales_order_create_validation_card');
}
/**
- * Return Amazon Simple Pay payment url
+ * Return text for block`s header
*
* @return string
*/
- public function getRedirectUrl()
+ public function getHeaderText()
{
- return $this->getPayment()->getPayRedirectUrl();
+ return Mage::helper('centinel')->__('3D Secure Card Validation');
}
/**
- * Return pay params for current order
+ * Return css class name for header block
*
- * @return array
+ * @return string
*/
- public function getRedirectParams()
+ public function getHeaderCssClass()
{
- return $this->getPayment()->getPayRedirectParams();
+ return 'head-payment-method';
}
/**
- * Return redirect message
+ * Prepare html output
*
* @return string
*/
- public function getRedirectMessage()
+ protected function _toHtml()
{
- return $this->getPayment()->getRedirectMessage();
+ $payment = $this->getQuote()->getPayment();
+ if (!$payment->getMethod() || !$payment->getMethodInstance() || !$payment->getMethodInstance()->getIsCentinelValidationEnabled()) {
+ return '';
+ }
+ return parent::_toHtml();
}
-
}
+
diff --git a/app/code/core/Mage/AmazonPayments/Block/Asp/Shortcut.php b/app/code/core/Mage/Centinel/Block/Adminhtml/Validation/Form.php
similarity index 56%
rename from app/code/core/Mage/AmazonPayments/Block/Asp/Shortcut.php
rename to app/code/core/Mage/Centinel/Block/Adminhtml/Validation/Form.php
index 4383a3b138..2479b86da0 100644
--- a/app/code/core/Mage/AmazonPayments/Block/Asp/Shortcut.php
+++ b/app/code/core/Mage/Centinel/Block/Adminhtml/Validation/Form.php
@@ -19,37 +19,37 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_AmazonPayments
+ * @package Mage_Centinel
* @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)
*/
/**
- * Paypal shortcut link
+ * Adminhtml sales order create validation card block
*
* @category Mage
- * @package Mage_Paypal
+ * @package Mage_Centinel
* @author Magento Core Team
*/
-class Mage_AmazonPayments_Block_Asp_Shortcut extends Mage_Core_Block_Template
-{
- public function getCheckoutUrl()
- {
- return $this->getUrl('amazonpayments/asp/checkout');
- }
- public function getButtonImageUrl()
- {
- return Mage::getStoreConfig('payment/amazonpayments_asp/pay_now_button_image_url');
- }
-
- public function _toHtml()
+class Mage_Centinel_Block_Adminhtml_Validation_Form extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract
+{
+ /**
+ * Prepare validation and template parameters
+ */
+ protected function _toHtml()
{
- if (Mage::getStoreConfigFlag('payment/amazonpayments_asp/active')
- && Mage::getSingleton('checkout/session')->getQuote()->validateMinimumAmount()) {
- return parent::_toHtml();
+ $payment = $this->getQuote()->getPayment();
+ if ($payment && $method = $payment->getMethodInstance()) {
+ if ($method->getIsCentinelValidationEnabled() && $centinel = $method->getCentinelValidator()) {
+ $this->setFrameUrl($centinel->getValidatePaymentDataUrl())
+ ->setContainerId('centinel_authenticate_iframe')
+ ->setMethodCode($method->getCode())
+ ;
+ return parent::_toHtml();
+ }
}
-
return '';
}
}
+
diff --git a/app/code/core/Mage/Paybox/Block/Direct/Info.php b/app/code/core/Mage/Centinel/Block/Authentication.php
similarity index 60%
rename from app/code/core/Mage/Paybox/Block/Direct/Info.php
rename to app/code/core/Mage/Centinel/Block/Authentication.php
index 0a375e1bb9..c75363ab40 100644
--- a/app/code/core/Mage/Paybox/Block/Direct/Info.php
+++ b/app/code/core/Mage/Centinel/Block/Authentication.php
@@ -19,30 +19,32 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Paybox
+ * @package Mage_Centinel
* @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)
*/
/**
- * Paybox Direct Info Block
- *
- * @category Mage
- * @package Mage_Paybox
- * @author Magento Core Team
+ * Centinel validation frame
*/
-class Mage_Paybox_Block_Direct_Info extends Mage_Payment_Block_Info_Cc
+class Mage_Centinel_Block_Authentication extends Mage_Core_Block_Template
{
- protected function _construct()
+ /**
+ * Check whether authentication is required and prepare some template data
+ *
+ * @return string
+ */
+ protected function _toHtml()
{
- parent::_construct();
- $this->setTemplate('paybox/direct/info.phtml');
+ $method = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance();
+ if (!$method->getIsCentinelValidationEnabled()) {
+ return '';
+ }
+ $centinel = $method->getCentinelValidator();
+ if ($centinel && $centinel->shouldAuthenticate()) {
+ $this->setFrameUrl($centinel->getAuthenticationStartUrl());
+ return parent::_toHtml();
+ }
+ return '';
}
-
- public function toPdf()
- {
- $this->setTemplate('paybox/direct/pdf/info.phtml');
- return $this->toHtml();
- }
-
}
diff --git a/app/code/core/Mage/AmazonPayments/Helper/Data.php b/app/code/core/Mage/Centinel/Block/Authentication/Complete.php
similarity index 67%
rename from app/code/core/Mage/AmazonPayments/Helper/Data.php
rename to app/code/core/Mage/Centinel/Block/Authentication/Complete.php
index 4a9417826e..e67227e6bb 100644
--- a/app/code/core/Mage/AmazonPayments/Helper/Data.php
+++ b/app/code/core/Mage/Centinel/Block/Authentication/Complete.php
@@ -19,28 +19,30 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_AmazonPayments
+ * @package Mage_Centinel
* @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)
*/
+
/**
- * Amazon Checlout Data Helper
- *
- * @category Mage
- * @package Mage_AmazonPayments
- * @author Magento Core Team
+ * Centinel validation form lookup
*/
-class Mage_AmazonPayments_Helper_Data extends Mage_Core_Helper_Abstract
+class Mage_Centinel_Block_Authentication_Complete extends Mage_Core_Block_Template
{
/**
- * Format amount value (2 digits after the decimal point)
+ * Prepare authentication result params and render
*
- * @param float $amount
- * @return float
+ * @return string
*/
- public function formatAmount($amount)
+ protected function _toHtml()
{
- return round($amount, 2);
+ $validator = Mage::registry('centinel_validator');
+ if (!$validator) {
+ return '';
+ }
+ $this->setIsSuccess($validator->isAuthenticateSuccessful());
+ return parent::_toHtml();
}
}
+
diff --git a/app/code/core/Mage/AmazonPayments/Block/Cba/Success.php b/app/code/core/Mage/Centinel/Block/Authentication/Start.php
similarity index 66%
rename from app/code/core/Mage/AmazonPayments/Block/Cba/Success.php
rename to app/code/core/Mage/Centinel/Block/Authentication/Start.php
index 2554fb618d..218edb4fb0 100644
--- a/app/code/core/Mage/AmazonPayments/Block/Cba/Success.php
+++ b/app/code/core/Mage/Centinel/Block/Authentication/Start.php
@@ -19,32 +19,30 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_AmazonPayments
+ * @package Mage_Centinel
* @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)
*/
+
/**
- * Amazon Payments Checkout by Amazon Success Block
- *
- * @category Mage
- * @package Mage_AmazonPayments
- * @author Magento Core Team
+ * Authentication start/redirect form
*/
-class Mage_AmazonPayments_Block_Cba_Success extends Mage_Core_Block_Abstract
+class Mage_Centinel_Block_Authentication_Start extends Mage_Core_Block_Template
{
/**
- * Success page
+ * Prepare form parameters and render
*
* @return string
*/
protected function _toHtml()
{
- echo "{$this->__('Thank you for your purchase!') }
\n";
- echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress. ');
-
-
+ $validator = Mage::registry('centinel_validator');
+ if ($validator && $validator->shouldAuthenticate()) {
+ $this->setData($validator->getAuthenticateStartData());
+ return parent::_toHtml();
+ }
return '';
}
-
}
+
diff --git a/app/code/core/Mage/Ogone/Block/Info.php b/app/code/core/Mage/Centinel/Block/Logo.php
similarity index 76%
rename from app/code/core/Mage/Ogone/Block/Info.php
rename to app/code/core/Mage/Centinel/Block/Logo.php
index 6a40dfbea4..7b66acbe6b 100644
--- a/app/code/core/Mage/Ogone/Block/Info.php
+++ b/app/code/core/Mage/Centinel/Block/Logo.php
@@ -19,23 +19,29 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Ogone
+ * @package Mage_Centinel
* @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)
*/
/**
- * Ogone payment iformation block
+ * Centinel payment form logo block
*/
-class Mage_Ogone_Block_Info extends Mage_Payment_Block_Info_Cc
+class Mage_Centinel_Block_Logo extends Mage_Core_Block_Template
{
+ protected function _construct()
+ {
+ parent::_construct();
+ $this->setTemplate('centinel/logo.phtml');
+ }
+
/**
- * Init ogone payment information block to use on admin area
+ * Return code of payment method
*
+ * @return string
*/
- protected function _construct()
+ public function getCode()
{
- parent::_construct();
- $this->setTemplate('ogone/info.phtml');
+ return $this->getMethod()->getCode();
}
}
diff --git a/app/code/core/Mage/Centinel/Helper/Data.php b/app/code/core/Mage/Centinel/Helper/Data.php
new file mode 100644
index 0000000000..0783c6ad7b
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Helper/Data.php
@@ -0,0 +1,181 @@
+
+ */
+class Mage_Centinel_Helper_Data extends Mage_Core_Helper_Abstract
+{
+ /**
+ * Return label for cmpi field
+ *
+ * @param string $fieldName
+ * @return string
+ */
+ public function getCmpiLabel($fieldName)
+ {
+ switch ($fieldName) {
+ case Mage_Centinel_Model_Service::CMPI_PARES:
+ return $this->__('3D Secure Verification Result');
+ case Mage_Centinel_Model_Service::CMPI_ENROLLED:
+ return $this->__('3D Secure Cardholder Validation');
+ case Mage_Centinel_Model_Service::CMPI_ECI:
+ return $this->__('3D Secure Electronic Commerce Indicator');
+ case Mage_Centinel_Model_Service::CMPI_CAVV:
+ return $this->__('3D Secure CAVV');
+ case Mage_Centinel_Model_Service::CMPI_XID:
+ return $this->__('3D Secure XID');
+ }
+ return '';
+ }
+
+ /**
+ * Return value for cmpi field
+ *
+ * @param string $fieldName
+ * @param string $value
+ * @return string
+ */
+ public function getCmpiValue($fieldName, $value)
+ {
+ switch ($fieldName) {
+ case Mage_Centinel_Model_Service::CMPI_PARES:
+ return $this->_getCmpiParesValue($value);
+ case Mage_Centinel_Model_Service::CMPI_ENROLLED:
+ return $this->_getCmpiEnrolledValue($value);
+ case Mage_Centinel_Model_Service::CMPI_ECI:
+ return $this->_getCmpiEciValue($value);
+ case Mage_Centinel_Model_Service::CMPI_CAVV: // break intentionally omitted
+ case Mage_Centinel_Model_Service::CMPI_XID:
+ return $value;
+ }
+ return '';
+ }
+
+ /**
+ * Return text value for cmpi eci flag field
+ *
+ * @param string $value
+ * @return string
+ */
+ private function _getCmpiEciValue($value)
+ {
+ switch ($value) {
+ case '01':
+ case '07':
+ return $this->__('Merchant Liability');
+ case '02':
+ case '05':
+ case '06':
+ return $this->__('Card Issuer Liability');
+ default:
+ return $value;
+ }
+ }
+
+ /**
+ * Return text value for cmpi enrolled field
+ *
+ * @param string $value
+ * @return string
+ */
+ private function _getCmpiEnrolledValue($value)
+ {
+ switch ($value) {
+ case 'Y':
+ return $this->__('Enrolled');
+ case 'U':
+ return $this->__('Enrolled but Authentication Unavailable');
+ case 'N': // break intentionally omitted
+ default:
+ return $this->__('Not Enrolled');
+ }
+ }
+
+ /**
+ * Return text value for cmpi pares field
+ *
+ * @param string $value
+ * @return string
+ */
+ private function _getCmpiParesValue($value)
+ {
+ switch ($value) {
+ case 'Y':
+ return $this->__('Successful');
+ case 'N':
+ return $this->__('Failed');
+ case 'U':
+ return $this->__('Unable to complete');
+ case 'A':
+ return $this->__('Successful attempt');
+ default:
+ return $value;
+ }
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param unknown_type $method
+ * @return unknown
+ */
+ public function getMethodFormBlock($method)
+ {
+ $blockType = 'centinel/logo';
+ if ($this->getLayout()) {
+ $block = $this->getLayout()->createBlock($blockType);
+ }
+ else {
+ $className = Mage::getConfig()->getBlockClassName($blockType);
+ $block = new $className;
+ }
+ $block->setMethod($method);
+ return $block;
+ }
+
+ /**
+ * Return url of page about visa verification
+ *
+ * @return string
+ */
+ public function getVisaLearnMorePageUrl()
+ {
+ return 'https://usa.visa.com/personal/security/vbv/index.html?ep=v_sym_verifiedbyvisa';
+ }
+
+ /**
+ * Return url of page about mastercard verification
+ *
+ * @return string
+ */
+ public function getMastercardLearnMorePageUrl()
+ {
+ return 'http://www.mastercardbusiness.com/mcbiz/index.jsp?template=/orphans&content=securecodepopup';
+ }
+}
diff --git a/app/code/core/Mage/Centinel/Model/Api.php b/app/code/core/Mage/Centinel/Model/Api.php
new file mode 100644
index 0000000000..6f11457987
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Model/Api.php
@@ -0,0 +1,231 @@
+ '784', 'AFN' => '971',
+ 'ALL' => '008', 'AMD' => '051', 'ANG' => '532', 'AOA' => '973', 'ARS' => '032', 'AUD' => '036', 'AWG' => '533',
+ 'AZN' => '944', 'BAM' => '977', 'BBD' => '052', 'BDT' => '050', 'BGN' => '975', 'BHD' => '048', 'BIF' => '108',
+ 'BMD' => '060', 'BND' => '096', 'BOB' => '068', 'BOV' => '984', 'BRL' => '986', 'BSD' => '044', 'BTN' => '064',
+ 'BWP' => '072', 'BYR' => '974', 'BZD' => '084', 'CAD' => '124', 'CDF' => '976', 'CHE' => '947', 'CHF' => '756',
+ 'CHW' => '948', 'CLF' => '990', 'CLP' => '152', 'CNY' => '156', 'COP' => '170', 'COU' => '970', 'CRC' => '188',
+ 'CUC' => '931', 'CUP' => '192', 'CVE' => '132', 'CZK' => '203', 'DJF' => '262', 'DKK' => '208', 'DOP' => '214',
+ 'DZD' => '012', 'EEK' => '233', 'EGP' => '818', 'ERN' => '232', 'ETB' => '230', 'EUR' => '978', 'FJD' => '242',
+ 'FKP' => '238', 'GBP' => '826', 'GEL' => '981', 'GHS' => '936', 'GIP' => '292', 'GMD' => '270', 'GNF' => '324',
+ 'GTQ' => '320', 'GYD' => '328', 'HKD' => '344', 'HNL' => '340', 'HRK' => '191', 'HTG' => '332', 'HUF' => '348',
+ 'IDR' => '360', 'ILS' => '376', 'INR' => '356', 'IQD' => '368', 'IRR' => '364', 'ISK' => '352', 'JMD' => '388',
+ 'JOD' => '400', 'JPY' => '392', 'KES' => '404', 'KGS' => '417', 'KHR' => '116', 'KMF' => '174', 'KPW' => '408',
+ 'KRW' => '410', 'KWD' => '414', 'KYD' => '136', 'KZT' => '398', 'LAK' => '418', 'LBP' => '422', 'LKR' => '144',
+ 'LRD' => '430', 'LSL' => '426', 'LTL' => '440', 'LVL' => '428', 'LYD' => '434', 'MAD' => '504', 'MDL' => '498',
+ 'MGA' => '969', 'MKD' => '807', 'MMK' => '104', 'MNT' => '496', 'MOP' => '446', 'MRO' => '478', 'MUR' => '480',
+ 'MVR' => '462', 'MWK' => '454', 'MXN' => '484', 'MXV' => '979', 'MYR' => '458', 'MZN' => '943', 'NAD' => '516',
+ 'NGN' => '566', 'NIO' => '558', 'NOK' => '578', 'NPR' => '524', 'NZD' => '554', 'OMR' => '512', 'PAB' => '590',
+ 'PEN' => '604', 'PGK' => '598', 'PHP' => '608', 'PKR' => '586', 'PLN' => '985', 'PYG' => '600', 'QAR' => '634',
+ 'RON' => '946', 'RSD' => '941', 'RUB' => '643', 'RWF' => '646', 'SAR' => '682', 'SBD' => '090', 'SCR' => '690',
+ 'SDG' => '938', 'SEK' => '752', 'SGD' => '702', 'SHP' => '654', 'SLL' => '694', 'SOS' => '706', 'SRD' => '968',
+ 'STD' => '678', 'SYP' => '760', 'SZL' => '748', 'THB' => '764', 'TJS' => '972', 'TMT' => '934', 'TND' => '788',
+ 'TOP' => '776', 'TRY' => '949', 'TTD' => '780', 'TWD' => '901', 'TZS' => '834', 'UAH' => '980', 'UGX' => '800',
+ 'USD' => '840', 'USN' => '997', 'USS' => '998', 'UYU' => '858', 'UZS' => '860', 'VEF' => '937', 'VND' => '704',
+ 'VUV' => '548', 'WST' => '882', 'XAF' => '950', 'XAG' => '961', 'XAU' => '959', 'XBA' => '955', 'XBB' => '956',
+ 'XBC' => '957', 'XBD' => '958', 'XCD' => '951', 'XDR' => '960', 'XOF' => '952', 'XPD' => '964', 'XPF' => '953',
+ 'XPT' => '962', 'XTS' => '963', 'XXX' => '999', 'YER' => '886', 'ZAR' => '710', 'ZMK' => '894', 'ZWL' => '932',
+ );
+
+ /**
+ * Centinel validation client
+ *
+ * @var CentinelClient
+ */
+ protected $_clientInstance = null;
+
+ /**
+ * Return Centinel thin client object
+ *
+ * @return CentinelClient
+ */
+ protected function _getClientInstance()
+ {
+ if (empty($this->_clientInstance)) {
+ $this->_clientInstance = new CentinelClient();
+ }
+ return $this->_clientInstance;
+ }
+
+ /**
+ * Return Centinel Api version
+ *
+ * @return string
+ */
+ protected function _getVersion()
+ {
+ return '1.7';
+ }
+
+ /**
+ * Return transaction type. according centinel documetation it should be "C"
+ *
+ * @return "C"
+ */
+ protected function _getTransactionType()
+ {
+ return 'C';
+ }
+
+ /**
+ * Return Timeout Connect
+ *
+ * @return int
+ */
+ protected function _getTimeoutConnect()
+ {
+ return 100;
+ }
+
+ /**
+ * Return Timeout Read
+ *
+ * @return int
+ */
+ protected function _getTimeoutRead()
+ {
+ return 100;
+ }
+
+ /**
+ * Call centinel api methods by given method name and data
+ *
+ * @param $method string
+ * @param $data array
+ *
+ * @return CentinelClient
+ */
+ protected function _call($method, $data)
+ {
+ $client = $this->_getClientInstance();
+ $request = array_merge(array(
+ 'MsgType' => $method,
+ 'Version' => $this->_getVersion(),
+ 'ProcessorId' => $this->getProcessorId(),
+ 'MerchantId' => $this->getMerchantId(),
+ 'TransactionPwd' => $this->getTransactionPwd(),
+ 'TransactionType' => $this->_getTransactionType(),
+ ), $data);
+ foreach($request as $key => $val) {
+ $client->add($key, $val);
+ }
+ $client->sendHttp($this->_getApiEndpointUrl(), $this->_getTimeoutConnect(), $this->_getTimeoutRead());
+ return $client;
+ }
+
+ /**
+ * Getter for API call URL
+ *
+ * @return string
+ * @throws Exception
+ */
+ protected function _getApiEndpointUrl()
+ {
+ if ($this->getIsTestMode()) {
+ return 'https://centineltest.cardinalcommerce.com/maps/txns.asp';
+ }
+ $url = $this->getApiEndpointUrl();
+ if (!$url) {
+ throw new Exception('Centinel API endpoint URL is not configured properly.');
+ }
+ return $url;
+ }
+
+ /**
+ * Call centinel api lookup method
+ *
+ * @return Mage_Centinel_Model_Api
+ */
+ public function callLookup($data)
+ {
+ $result = new Varien_Object();
+
+ $month = strlen($data->getCardExpMonth()) == 1 ? '0' . $data->getCardExpMonth() : $data->getCardExpMonth();
+ $currencyCode = $data->getCurrencyCode();
+ $currencyNumber = isset(self::$_iso4217Currencies[$currencyCode]) ? self::$_iso4217Currencies[$currencyCode] : '';
+ if (!$currencyNumber) {
+ return $result->setErrorNo(1)->setErrorDesc(
+ Mage::helper('payment')->__('Not supported currency code %s.', $currencyCode)
+ );
+ }
+
+ $clientResponse = $this->_call('cmpi_lookup', array(
+ 'Amount' => round($data->getAmount() * 100),
+ 'CurrencyCode' => $currencyNumber,
+ 'CardNumber' => $data->getCardNumber(),
+ 'CardExpMonth'=> $month,
+ 'CardExpYear' => $data->getCardExpYear(),
+ 'OrderNumber' => $data->getOrderNumber()
+ ));
+
+ $result->setErrorNo($clientResponse->getValue('ErrorNo'));
+ $result->setErrorDesc($clientResponse->getValue('ErrorDesc'));
+ $result->setTransactionId($clientResponse->getValue('TransactionId'));
+ $result->setEnrolled($clientResponse->getValue('Enrolled'));
+ $result->setAcsUrl($clientResponse->getValue('ACSUrl'));
+ $result->setPayload($clientResponse->getValue('Payload'));
+ $result->setEciFlag($clientResponse->getValue('EciFlag'));
+ return $result;
+ }
+
+ /**
+ * Call centinel api authentication method
+ *
+ * @return Mage_Centinel_Model_Api
+ */
+ public function callAuthentication($data)
+ {
+ $result = new Varien_Object();
+
+ $clientResponse = $this->_call('cmpi_authenticate', array(
+ 'TransactionId' => $data->getTransactionId(),
+ 'PAResPayload' => $data->getPaResPayload(),
+ ));
+
+ $result->setErrorNo($clientResponse->getValue('ErrorNo'));
+ $result->setErrorDesc($clientResponse->getValue('ErrorDesc'));
+ $result->setPaResStatus($clientResponse->getValue('PAResStatus'));
+ $result->setSignatureVerification($clientResponse->getValue('SignatureVerification'));
+ $result->setCavv($clientResponse->getValue('Cavv'));
+ $result->setEciFlag($clientResponse->getValue('EciFlag'));
+ $result->setXid($clientResponse->getValue('Xid'));
+ return $result;
+ }
+}
+
diff --git a/app/code/core/Mage/Centinel/Model/Config.php b/app/code/core/Mage/Centinel/Model/Config.php
new file mode 100644
index 0000000000..e1c189299c
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Model/Config.php
@@ -0,0 +1,140 @@
+_store = $store;
+ return $this;
+ }
+
+ /**
+ * Return store
+ *
+ * @return int|Mage_Core_Model_Store
+ */
+ public function getStore()
+ {
+ return $this->_store;
+ }
+
+ /**
+ * Return validation state class for card with type $cardType
+ *
+ * @param string $cardType
+ * @return string
+ */
+ public function getStateModelClass($cardType)
+ {
+ $node = Mage::getConfig()->getNode($this->_cardTypesConfigPath . '/' . $cardType . '/validator/centinel/state');
+ if (!$node) {
+ return false;
+ }
+ return $node->asArray();
+ }
+
+ /**
+ * Return centinel processorId
+ *
+ * @return string
+ */
+ public function getProcessorId()
+ {
+ return $this->_getServiceConfigValue('processor_id');
+ }
+
+ /**
+ * Return centinel merchantId
+ *
+ * @return string
+ */
+ public function getMerchantId()
+ {
+ return $this->_getServiceConfigValue('merchant_id');
+ }
+
+ /**
+ * Return centinel transactionPwd
+ *
+ * @return string
+ */
+ public function getTransactionPwd()
+ {
+ return Mage::helper('core')->decrypt($this->_getServiceConfigValue('password'));
+ }
+
+ /**
+ * Return flag - is centinel mode test
+ *
+ * @return bool
+ */
+ public function getIsTestMode()
+ {
+ return (bool)(int)$this->_getServiceConfigValue('test_mode');
+ }
+
+ /**
+ * Return value of node of centinel config section
+ *
+ * @param string $key
+ * @return string
+ */
+ private function _getServiceConfigValue($key)
+ {
+ return Mage::getStoreConfig($this->_serviceConfigPath . '/' . $key, $this->getStore());
+ }
+}
diff --git a/app/code/core/Mage/Centinel/Model/Observer.php b/app/code/core/Mage/Centinel/Model/Observer.php
new file mode 100644
index 0000000000..b2237e0ee9
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Model/Observer.php
@@ -0,0 +1,105 @@
+
+ */
+class Mage_Centinel_Model_Observer extends Varien_Object
+{
+ /**
+ * Set cmpi data to payment
+ *
+ * @param Varien_Object $observer
+ * @return Mage_Centinel_Model_Observer
+ */
+ public function salesEventConvertQuoteToOrder($observer)
+ {
+ $payment = $observer->getEvent()->getQuote()->getPayment();
+
+ if ($payment->getMethodInstance()->getIsCentinelValidationEnabled()) {
+ $to = array($payment, 'setAdditionalInformation');
+ $payment->getMethodInstance()->getCentinelValidator()->exportCmpiData($to);
+ }
+ return $this;
+ }
+
+ /**
+ * Add cmpi data to info block
+ *
+ * @param Varien_Object $observer
+ * @return Mage_Centinel_Model_Observer
+ */
+ public function paymentInfoBlockPrepareSpecificInformation($observer)
+ {
+ if ($observer->getEvent()->getBlock()->getIsSecureMode()) {
+ return;
+ }
+
+ $payment = $observer->getEvent()->getPayment();
+ $transport = $observer->getEvent()->getTransport();
+ $helper = Mage::helper('centinel');
+
+ $info = array(
+ Mage_Centinel_Model_Service::CMPI_PARES,
+ Mage_Centinel_Model_Service::CMPI_ENROLLED,
+ Mage_Centinel_Model_Service::CMPI_ECI,
+ Mage_Centinel_Model_Service::CMPI_CAVV,
+ Mage_Centinel_Model_Service::CMPI_XID
+ );
+ foreach ($info as $key) {
+ if ($value = $payment->getAdditionalInformation($key)) {
+ $transport->setData($helper->getCmpiLabel($key), $helper->getCmpiValue($key, $value));
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Add centinel logo block into payment form
+ *
+ * @param Varien_Object $observer
+ * @return Mage_Centinel_Model_Observer
+ */
+ public function paymentFormBlockToHtmlBefore($observer)
+ {
+ $paymentFormBlock = $observer->getEvent()->getBlock();
+ $method = $paymentFormBlock->getMethod();
+
+ if ($method && $method->getIsCentinelValidationEnabled()) {
+ $paymentFormBlock->setChild(
+ 'payment.method.'.$method->getCode().'centinel.logo',
+ Mage::helper('centinel')->getMethodFormBlock($method)
+ );
+ }
+ return $this;
+ }
+}
+
diff --git a/app/code/core/Mage/Centinel/Model/Service.php b/app/code/core/Mage/Centinel/Model/Service.php
new file mode 100644
index 0000000000..b393b0c2b5
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Model/Service.php
@@ -0,0 +1,381 @@
+ self::CMPI_ENROLLED,
+ 'lookup_eci_flag' => self::CMPI_ECI,
+ 'authenticate_pa_res_status' => self::CMPI_PARES,
+ 'authenticate_cavv' => self::CMPI_CAVV,
+ 'authenticate_eci_flag' => self::CMPI_ECI,
+ 'authenticate_xid' => self::CMPI_XID,
+ );
+
+ /**
+ * Validation api model
+ *
+ * @var Mage_Centinel_Model_Api
+ */
+ protected $_api;
+
+ /**
+ * Validation state model
+ *
+ * @var Mage_Centinel_Model_StateAbstract
+ */
+ protected $_validationState;
+
+ /**
+ * Return validation session object
+ *
+ * @return Mage_Centinel_Model_Session
+ */
+ protected function _getSession()
+ {
+ return Mage::getSingleton('centinel/session');
+ }
+
+ /**
+ * Return value from section of centinel config
+ *
+ * @param string $path
+ * @return string
+ */
+ protected function _getConfig()
+ {
+ $config = Mage::getSingleton('centinel/config');
+ return $config->setStore($this->getStore());
+ }
+
+ /**
+ * Generate checksum from all passed parameters
+ *
+ * @param string $cardType
+ * @param string $cardNumber
+ * @param string $cardExpMonth
+ * @param string $cardExpYear
+ * @param double $amount
+ * @param string $currencyCode
+ * @return string
+ */
+ protected function _generateChecksum($paymentMethodCode, $cardType, $cardNumber, $cardExpMonth, $cardExpYear, $amount, $currencyCode)
+ {
+ return md5(implode(func_get_args(), '_'));
+ }
+
+ /**
+ * Unified validation/authentication URL getter
+ *
+ * @param string $suffix
+ * @param bool $current
+ * @return string
+ */
+ private function _getUrl($suffix, $current = false)
+ {
+ $params = array(
+ '_secure' => true,
+ '_current' => $current,
+ 'form_key' => Mage::getSingleton('core/session')->getFormKey()
+ );
+ if (Mage::app()->getStore()->isAdmin()) {
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/centinel_index/' . $suffix, $params);
+ } else {
+ return Mage::getUrl('centinel/index/' . $suffix, $params);
+ }
+ }
+
+ /**
+ * Return validation api model
+ *
+ * @return Mage_Centinel_Model_Api
+ */
+ protected function _getApi()
+ {
+ if (!is_null($this->_api)) {
+ return $this->_api;
+ }
+
+ $this->_api = Mage::getSingleton('centinel/api');
+ $config = $this->_getConfig();
+ $this->_api
+ ->setProcessorId($config->getProcessorId())
+ ->setMerchantId($config->getMerchantId())
+ ->setTransactionPwd($config->getTransactionPwd())
+ ->setIsTestMode($config->getIsTestMode())
+ ->setApiEndpointUrl($this->getCustomApiEndpointUrl());
+ return $this->_api;
+ }
+
+ /**
+ * Create and return validation state model for card type
+ *
+ * @param string $cardType
+ * @return Mage_Centinel_Model_StateAbstract
+ */
+ protected function _getValidationStateModel($cardType)
+ {
+ if ($modelClass = $this->_getConfig()->getStateModelClass($cardType)) {
+ return Mage::getModel($modelClass);
+ }
+ return false;
+ }
+
+ /**
+ * Return validation state model
+ *
+ * @param string $cardType
+ * @return Mage_Centinel_Model_StateAbstract
+ */
+ protected function _getValidationState($cardType = null)
+ {
+ $type = $cardType ? $cardType : $this->_getSession()->getData('card_type');
+ if (!$this->_validationState && $type) {
+ $model = $this->_getValidationStateModel($type);
+ if (!$model) {
+ return false;
+ }
+ $model->setDataStorage($this->_getSession());
+ $this->_validationState = $model;
+ }
+ return $this->_validationState;
+ }
+
+ /**
+ * Drop validation state model
+ *
+ */
+ protected function _resetValidationState()
+ {
+ $this->_getSession()->setData(array());
+ $this->_validationState = false;
+ }
+
+ /**
+ * Drop old and init new validation state model
+ *
+ * @param string $cardType
+ * @param string $dataChecksum
+ * @return Mage_Centinel_Model_StateAbstract
+ */
+ protected function _initValidationState($cardType, $dataChecksum)
+ {
+ $this->_resetValidationState();
+ $state = $this->_getValidationStateModel($cardType);
+ $state->setDataStorage($this->_getSession())
+ ->setCardType($cardType)
+ ->setChecksum($dataChecksum)
+ ->setIsModeStrict($this->getIsModeStrict());
+ return $this->_getValidationState();
+ }
+
+ /**
+ * Process lookup validation and init new validation state model
+ *
+ * @param Varien_Object $data
+ */
+ public function lookup($data)
+ {
+ $newChecksum = $this->_generateChecksum(
+ $data->getPaymentMethodCode(),
+ $data->getCardType(),
+ $data->getCardNumber(),
+ $data->getCardExpMonth(),
+ $data->getCardExpYear(),
+ $data->getAmount(),
+ $data->getCurrencyCode()
+ );
+
+ $validationState = $this->_initValidationState($data->getCardType(), $newChecksum);
+
+ $api = $this->_getApi();
+ $result = $api->callLookup($data);
+ $validationState->setLookupResult($result);
+ }
+
+ /**
+ * Process authenticate validation
+ *
+ * @param Varien_Object $data
+ */
+ public function authenticate($data)
+ {
+ $validationState = $this->_getValidationState();
+ if (!$validationState || $data->getTransactionId() != $validationState->getLookupTransactionId()) {
+ throw new Exception('Authentication impossible: transaction id or validation state is wrong.');
+ }
+
+ $api = $this->_getApi();
+ $result = $api->callAuthentication($data);
+ $validationState->setAuthenticateResult($result);
+ }
+
+ /**
+ * Validate payment data
+ *
+ * This check is performed on payment information submission, as well as on placing order.
+ * Workflow state is stored validation state model
+ *
+ * @param Varien_Object $data
+ * @throws Mage_Core_Exception
+ */
+ public function validate($data)
+ {
+ $newChecksum = $this->_generateChecksum(
+ $data->getPaymentMethodCode(),
+ $data->getCardType(),
+ $data->getCardNumber(),
+ $data->getCardExpMonth(),
+ $data->getCardExpYear(),
+ $data->getAmount(),
+ $data->getCurrencyCode()
+ );
+
+ $validationState = $this->_getValidationState($data->getCardType());
+ if (!$validationState) {
+ $this->_resetValidationState();
+ return;
+ }
+
+ // check whether is authenticated before placing order
+ if ($this->getIsPlaceOrder()) {
+ if ($validationState->getChecksum() != $newChecksum) {
+ Mage::throwException(Mage::helper('centinel')->__('Payment information error. Please start over.'));
+ }
+ if ($validationState->isAuthenticateSuccessful()) {
+ return;
+ }
+ Mage::throwException(Mage::helper('centinel')->__('Please verify the card with the issuer bank before placing the order.'));
+ } else {
+ if ($validationState->getChecksum() != $newChecksum) {
+ $this->lookup($data);
+ $validationState = $this->_getValidationState();
+ }
+ if ($validationState->isLookupSuccessful()) {
+ return;
+ }
+ Mage::throwException(Mage::helper('centinel')->__('This card has failed validation and cannot be used.'));
+ }
+ }
+
+ /**
+ * Return URL for authentication
+ *
+ * @return string
+ */
+ public function getAuthenticationStartUrl()
+ {
+ return $this->_getUrl('authenticationstart');
+ }
+
+ /**
+ * Return URL for validation
+ *
+ * @return string
+ */
+ public function getValidatePaymentDataUrl()
+ {
+ return $this->_getUrl('validatepaymentdata');
+ }
+
+ /**
+ * If authenticate is should return true
+ *
+ * @return bool
+ */
+ public function shouldAuthenticate()
+ {
+ $validationState = $this->_getValidationState();
+ return $validationState && $validationState->isAuthenticateAllowed();
+ }
+
+ /**
+ * Return data for start authentication (redirect customer to bank page)
+ *
+ * @return array
+ */
+ public function getAuthenticateStartData()
+ {
+ $validationState = $this->_getValidationState();
+ if (!$validationState && $this->shouldAuthenticate()) {
+ throw new Exception('Authentication impossible: validation state is wrong.');
+ }
+ $data = array(
+ 'acs_url' => $validationState->getLookupAcsUrl(),
+ 'pa_req' => $validationState->getLookupPayload(),
+ 'term_url' => $this->_getUrl('authenticationcomplete', true),
+ 'md' => $validationState->getLookupTransactionId()
+ );
+ return $data;
+ }
+
+ /**
+ * If authenticate is successful return true
+ *
+ * @return bool
+ */
+ public function isAuthenticateSuccessful()
+ {
+ $validationState = $this->_getValidationState();
+ return $validationState && $validationState->isAuthenticateSuccessful();
+ }
+
+ /**
+ * Export cmpi lookups and authentication information stored in session into array
+ *
+ * @param mixed $to
+ * @param array $map
+ * @return mixed $to
+ */
+ public function exportCmpiData($to, $map = false)
+ {
+ if (!$map) {
+ $map = $this->_cmpiMap;
+ }
+ if ($validationState = $this->_getValidationState()) {
+ $to = Varien_Object_Mapper::accumulateByMap($validationState, $to, $map);
+ }
+ return $to;
+ }
+}
+
diff --git a/app/code/core/Mage/Oscommerce/Model/Session.php b/app/code/core/Mage/Centinel/Model/Session.php
similarity index 83%
rename from app/code/core/Mage/Oscommerce/Model/Session.php
rename to app/code/core/Mage/Centinel/Model/Session.php
index be8be838a1..36bface825 100644
--- a/app/code/core/Mage/Oscommerce/Model/Session.php
+++ b/app/code/core/Mage/Centinel/Model/Session.php
@@ -19,21 +19,24 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Oscommerce
+ * @package Mage_Centinel
* @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)
*/
/**
*
- * Paypal transaction session namespace
+ * Payment centinel session model
*
* @author Magento Core Team
*/
-class Mage_Oscommerce_Model_Session extends Mage_Core_Model_Session_Abstract
+class Mage_Centinel_Model_Session extends Mage_Core_Model_Session_Abstract
{
+ /**
+ * constructor
+ */
public function __construct()
{
- $this->init('oscommerce');
+ $this->init('centinel_validator');
}
}
diff --git a/app/code/core/Mage/Centinel/Model/State/Mastercard.php b/app/code/core/Mage/Centinel/Model/State/Mastercard.php
new file mode 100644
index 0000000000..c4c882e3c4
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Model/State/Mastercard.php
@@ -0,0 +1,173 @@
+_isLookupStrictSuccessful()) {
+ return true;
+ } elseif (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Analyse lookup`s results. If it has require params for authenticate, return true
+ *
+ * @return bool
+ */
+ public function isAuthenticateAllowed()
+ {
+ return $this->_isLookupStrictSuccessful();
+ }
+
+ /**
+ * Analyse authenticate`s results. If authenticate is successful return true and false if it failure
+ * Result depends from flag self::getIsModeStrict()
+ *
+ * @return bool
+ */
+ public function isAuthenticateSuccessful()
+ {
+ $paResStatus = $this->getAuthenticatePaResStatus();
+ $eciFlag = $this->getAuthenticateEciFlag();
+ $xid = $this->getAuthenticateXid();
+ $cavv = $this->getAuthenticateCavv();
+ $errorNo = $this->getAuthenticateErrorNo();
+ $signatureVerification = $this->getAuthenticateSignatureVerification();
+
+ //Test cases 1-4, 10
+ if ($this->_isLookupStrictSuccessful()) {
+
+ if ($paResStatus == 'Y' && $eciFlag == '02' && $xid != '' && $cavv != '' && $errorNo == '') {
+ //Test case 1
+ if ($signatureVerification == 'Y') {
+ return true;
+ }
+ //Test case 2
+ if ($signatureVerification == 'N') {
+ return false;
+ }
+ }
+
+ //Test case 3
+ if ($paResStatus == 'N' && $signatureVerification == 'Y' && $eciFlag == '01' &&
+ $xid != '' && $cavv == '' && $errorNo == '') {
+ return false;
+ }
+
+ //Test case 4
+ if ($paResStatus == 'U' && $signatureVerification == 'Y' && $eciFlag == '01' &&
+ $xid != '' && $cavv == '' && $errorNo == '') {
+ if ($this->getIsModeStrict()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ //Test case 10
+ if ($paResStatus == '' && $signatureVerification == '' && $eciFlag == '01' &&
+ $xid == '' && $cavv == '' && $errorNo == '1050') {
+ if ($this->getIsModeStrict()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ }
+
+ //Test cases 5-9
+ if (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) {
+ if ($paResStatus == '' && $signatureVerification == '' && $eciFlag == '' &&
+ $xid == '' && $cavv == '' && $errorNo == '') {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Analyse lookup`s results. If lookup is strict successful return true
+ *
+ * @return bool
+ */
+ private function _isLookupStrictSuccessful()
+ {
+ //Test cases 1-4, 10
+ if ($this->getLookupEnrolled() == 'Y' &&
+ $this->getLookupAcsUrl() != '' &&
+ $this->getLookupPayload() != '' &&
+ $this->getLookupErrorNo() == '') {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Analyse lookup`s results. If lookup is soft successful return true
+ *
+ * @return bool
+ */
+ private function _isLookupSoftSuccessful()
+ {
+ $acsUrl = $this->getLookupAcsUrl();
+ $payload = $this->getLookupPayload();
+ $errorNo = $this->getLookupErrorNo();
+ $enrolled = $this->getLookupEnrolled();
+
+ //Test cases 6,7
+ if ($acsUrl == '' && $payload == '' && $errorNo == '' && ($enrolled == 'N' || $enrolled == 'U')) {
+ return true;
+ }
+
+ //Test case 5
+ if ($enrolled == '' && $acsUrl == '' && $payload == '' && $errorNo == 'Timeout number') {
+ return true;
+ }
+
+ //Test cases 8,9
+ if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001') {
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/app/code/core/Mage/Centinel/Model/State/Visa.php b/app/code/core/Mage/Centinel/Model/State/Visa.php
new file mode 100644
index 0000000000..5a7cb3a9fb
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Model/State/Visa.php
@@ -0,0 +1,184 @@
+_isLookupStrictSuccessful()) {
+ return true;
+ } elseif (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Analyse lookup`s results. If it has require params for authenticate, return true
+ *
+ * @return bool
+ */
+ public function isAuthenticateAllowed()
+ {
+ return $this->_isLookupStrictSuccessful();
+ }
+
+ /**
+ * Analyse authenticate`s results. If authenticate is successful return true and false if it failure
+ * Result depends from flag self::getIsModeStrict()
+ *
+ * @return bool
+ */
+ public function isAuthenticateSuccessful()
+ {
+ $paResStatus = $this->getAuthenticatePaResStatus();
+ $eciFlag = $this->getAuthenticateEciFlag();
+ $xid = $this->getAuthenticateXid();
+ $cavv = $this->getAuthenticateCavv();
+ $errorNo = $this->getAuthenticateErrorNo();
+ $signatureVerification = $this->getAuthenticateSignatureVerification();
+
+ //Test cases 1-5, 11
+ if ($this->_isLookupStrictSuccessful()) {
+
+ if ($paResStatus == 'Y' && $eciFlag == '05' && $xid != '' && $cavv != '' && $errorNo == '') {
+ //Test case 1
+ if ($signatureVerification == 'Y') {
+ return true;
+ }
+ //Test case 2
+ if ($signatureVerification == 'N') {
+ return false;
+ }
+ }
+
+ //Test case 3
+ if ($paResStatus == 'N' && $signatureVerification == 'Y' && $eciFlag == '07' &&
+ $xid != '' && $cavv == '' && $errorNo == '') {
+ return false;
+ }
+
+ //Test case 4
+ if ($paResStatus == 'A' && $signatureVerification == 'Y' && $eciFlag == '06' &&
+ $xid != '' && $cavv != '' && $errorNo == '') {
+ if ($this->getIsModeStrict()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ //Test case 5
+ if ($paResStatus == 'U' && $signatureVerification == 'Y' && $eciFlag == '07' &&
+ $xid != '' && $cavv == '' && $errorNo == '') {
+ if ($this->getIsModeStrict()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ //Test case 11
+ if ($paResStatus == '' && $signatureVerification == '' && $eciFlag == '07' &&
+ $xid == '' && $cavv == '' && $errorNo == '1050') {
+ if ($this->getIsModeStrict()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ }
+
+ //Test cases 6-10
+ if (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) {
+ if ($paResStatus == '' && $signatureVerification == '' && $eciFlag == '' &&
+ $xid == '' && $cavv == '' && $errorNo == '') {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Analyse lookup`s results. If lookup is strict successful return true
+ *
+ * @return bool
+ */
+ private function _isLookupStrictSuccessful()
+ {
+ //Test cases 1-5, 11
+ if ($this->getLookupEnrolled() == 'Y' &&
+ $this->getLookupAcsUrl() != '' &&
+ $this->getLookupPayload() != '' &&
+ $this->getLookupErrorNo() == '') {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Analyse lookup`s results. If lookup is soft successful return true
+ *
+ * @return bool
+ */
+ private function _isLookupSoftSuccessful()
+ {
+ $acsUrl = $this->getLookupAcsUrl();
+ $payload = $this->getLookupPayload();
+ $errorNo = $this->getLookupErrorNo();
+ $enrolled = $this->getLookupEnrolled();
+
+ //Test cases 7,8
+ if ($acsUrl == '' && $payload == '' && $errorNo == '' && ($enrolled == 'N' || $enrolled == 'U')) {
+ return true;
+ }
+
+ //Test case 6
+ if ($enrolled == '' && $acsUrl == '' && $payload == '' && $errorNo == 'Timeout number') {
+ return true;
+ }
+
+ //Test cases 9,10
+ if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001') {
+ return true;
+ }
+
+ return false;
+ }
+
+}
diff --git a/app/code/core/Mage/Centinel/Model/StateAbstract.php b/app/code/core/Mage/Centinel/Model/StateAbstract.php
new file mode 100644
index 0000000000..85a0e6cbbf
--- /dev/null
+++ b/app/code/core/Mage/Centinel/Model/StateAbstract.php
@@ -0,0 +1,147 @@
+_dataStorage = $dataStorageModel;
+ return $this;
+ }
+
+ /**
+ * Getter for storage data model
+ *
+ * @return Varien_Object
+ */
+ public function getDataStorage()
+ {
+ return $this->_dataStorage;
+ }
+
+ /**
+ * Retrieves data from the object
+ *
+ * If $key is empty will return all the data as an array
+ * Otherwise it will return value of the attribute specified by $key
+ *
+ * If $index is specified it will assume that attribute data is an array
+ * and retrieve corresponding member.
+ *
+ * @param string $key
+ * @param string|int $index
+ * @return mixed
+ */
+ public function getData($key='', $index=null)
+ {
+ return $this->getDataStorage()->getData($key, $index);
+ }
+
+ /**
+ * Overwrite data in the object.
+ *
+ * $key can be string or array.
+ * If $key is string, the attribute value will be overwritten by $value
+ *
+ * If $key is an array, it will overwrite all the data in the object.
+ *
+ * @param string|array $key
+ * @param mixed $value
+ * @return Mage_Centinel_Model_StateAbstract
+ */
+ public function setData($key, $value=null)
+ {
+ $this->getDataStorage()->setData($key, $value);
+ return $this;
+ }
+
+ /**
+ * Save lookup result in state model
+ *
+ * @param Varien_Object $result
+ * @return Mage_Centinel_Model_StateAbstract
+ */
+ public function setLookupResult($result)
+ {
+ foreach ($result->getData() as $key => $value) {
+ $this->setData('lookup_' . $key, $value);
+ }
+ return $this;
+ }
+
+ /**
+ * Save authenticate result in state model
+ *
+ * @param Varien_Object $result
+ * @return Mage_Centinel_Model_StateAbstract
+ */
+ public function setAuthenticateResult($result)
+ {
+ foreach ($result->getData() as $key => $value) {
+ $this->setData('authenticate_' . $key, $value);
+ }
+ return $this;
+ }
+
+ /**
+ * Analyse lookup`s results. If lookup is successful return true and false if it failure
+ * Result depends from flag self::getIsModeStrict()
+ *
+ * @return bool
+ */
+ abstract public function isLookupSuccessful();
+
+ /**
+ * Analyse lookup`s results. If it has require params for authenticate, return true
+ *
+ * @return bool
+ */
+ abstract public function isAuthenticateAllowed();
+
+ /**
+ * Analyse authenticate`s results. If authenticate is successful return true and false if it failure
+ * Result depends from flag self::getIsModeStrict()
+ *
+ * @return bool
+ */
+ abstract public function isAuthenticateSuccessful();
+}
diff --git a/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php b/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php
new file mode 100644
index 0000000000..a8b8ac19d2
--- /dev/null
+++ b/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php
@@ -0,0 +1,116 @@
+getRequest()->getParam('payment');
+ $validator = $this->_getValidator();
+ if (!$validator) {
+ throw new Exception('This payment method does not have centinel validation.');
+ }
+ $this->_getPayment()->importData($paymentData);
+ if ($validator->shouldAuthenticate()) {
+ $result['authenticationUrl'] = $validator->getAuthenticationStartUrl();
+ } else {
+ Mage::throwException(Mage::helper('centinel')->__('This card has failed validation, but it is possible to place the order.'));
+ }
+ } catch (Mage_Core_Exception $e) {
+ $result['message'] = $e->getMessage();
+ } catch (Exception $e) {
+ Mage::logException($e);
+ $result['message'] = Mage::helper('centinel')->__('Validation failed.');
+ }
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
+ }
+
+ /**
+ * Process autentication start action
+ *
+ */
+ public function authenticationStartAction()
+ {
+ if ($validator = $this->_getValidator()) {
+ Mage::register('centinel_validator', $validator);
+ }
+ $this->loadLayout()->renderLayout();
+ }
+
+ /**
+ * Process autentication complete action
+ *
+ */
+ public function authenticationCompleteAction()
+ {
+ if ($validator = $this->_getValidator()) {
+ $request = $this->getRequest();
+
+ $data = new Varien_Object();
+ $data->setTransactionId($request->getParam('MD'));
+ $data->setPaResPayload($request->getParam('PaRes'));
+
+ $validator->authenticate($data);
+ Mage::register('centinel_validator', $validator);
+ }
+ $this->loadLayout()->renderLayout();
+ }
+
+ /**
+ * Return payment model
+ *
+ * @return Mage_Sales_Model_Quote_Payment
+ */
+ private function _getPayment()
+ {
+ $model = Mage::getSingleton('adminhtml/sales_order_create');
+ return $model->getQuote()->getPayment();
+ }
+
+ /**
+ * Return Centinel validation model
+ *
+ * @return Mage_Centinel_Model_Service
+ */
+ private function _getValidator()
+ {
+ if ($this->_getPayment()->getMethodInstance()->getIsCentinelValidationEnabled()) {
+ return $this->_getPayment()->getMethodInstance()->getCentinelValidator();
+ }
+ return false;
+ }
+}
+
diff --git a/app/code/core/Mage/Centinel/controllers/IndexController.php b/app/code/core/Mage/Centinel/controllers/IndexController.php
new file mode 100644
index 0000000000..ced32316ec
--- /dev/null
+++ b/app/code/core/Mage/Centinel/controllers/IndexController.php
@@ -0,0 +1,87 @@
+_getValidator()) {
+ Mage::register('centinel_validator', $validator);
+ }
+ $this->loadLayout()->renderLayout();
+ }
+
+ /**
+ * Process autentication complete action
+ *
+ */
+ public function authenticationCompleteAction()
+ {
+ if ($validator = $this->_getValidator()) {
+ $request = $this->getRequest();
+
+ $data = new Varien_Object();
+ $data->setTransactionId($request->getParam('MD'));
+ $data->setPaResPayload($request->getParam('PaRes'));
+
+ $validator->authenticate($data);
+ Mage::register('centinel_validator', $validator);
+ }
+ $this->loadLayout()->renderLayout();
+ }
+
+ /**
+ * Return payment model
+ *
+ * @return Mage_Sales_Model_Quote_Payment
+ */
+ private function _getPayment()
+ {
+ return Mage::getSingleton('checkout/session')->getQuote()->getPayment();
+ }
+
+ /**
+ * Return Centinel validation model
+ *
+ * @return Mage_Centinel_Model_Service
+ */
+ private function _getValidator()
+ {
+ if ($this->_getPayment()->getMethodInstance()->getIsCentinelValidationEnabled()) {
+ return $this->_getPayment()->getMethodInstance()->getCentinelValidator();
+ }
+ return false;
+ }
+}
+
diff --git a/app/code/core/Mage/Centinel/etc/config.xml b/app/code/core/Mage/Centinel/etc/config.xml
new file mode 100644
index 0000000000..c22eed0556
--- /dev/null
+++ b/app/code/core/Mage/Centinel/etc/config.xml
@@ -0,0 +1,150 @@
+
+
+
+
+
+ 1.4.0.0.0
+
+
+
+
+
+
+
+ model
+ centinel/observer
+ salesEventConvertQuoteToOrder
+
+
+
+
+
+
+
+
+
+
+ Mage_Centinel.csv
+
+
+
+
+
+
+
+
+ model
+ centinel/observer
+ paymentFormBlockToHtmlBefore
+
+
+
+
+
+
+ standard
+
+ Mage_Centinel
+ centinel
+
+
+
+
+
+
+ centinel.xml
+
+
+
+
+ /centinel/
+
+
+
+
+
+
+
+ model
+ centinel/observer
+ paymentInfoBlockPrepareSpecificInformation
+
+
+
+
+
+
+
+
+ Mage_Centinel.csv
+
+
+
+
+
+
+
+ centinel.xml
+
+
+
+
+
+
+
+
+
+ Mage_Centinel_Adminhtml
+
+
+
+
+
+
+
+
+
+
+
+
+ centinel/state_visa
+
+
+
+
+
+
+ centinel/state_mastercard
+
+
+
+
+
+
+
+
diff --git a/app/code/core/Mage/Centinel/etc/system.xml b/app/code/core/Mage/Centinel/etc/system.xml
new file mode 100644
index 0000000000..d7dacbca05
--- /dev/null
+++ b/app/code/core/Mage/Centinel/etc/system.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+ Payment Services
+ sales
+ text
+ 450
+ 1
+ 1
+ 1
+
+
+ 3D Secure Credit Card Validation
+ text
+ 1
+ 1
+ 1
+ 0
+
+
+ Processor Id
+ text
+ 10
+ 1
+ 1
+ 0
+
+
+ Merchant Id
+ text
+ 20
+ 1
+ 1
+ 0
+
+
+ Password
+ obscure
+ adminhtml/system_config_backend_encrypted
+ 30
+ 1
+ 1
+ 0
+
+
+ Test Mode
+ Overrides API URL that may be specified by a Payment Method
+ select
+ adminhtml/system_config_source_yesno
+ 40
+ 1
+ 1
+ 0
+
+
+
+
+
+
+
diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php
index 0de57a651d..ac238a752b 100644
--- a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php
+++ b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php
@@ -33,6 +33,19 @@
*/
class Mage_Checkout_Block_Multishipping_Overview extends Mage_Sales_Block_Items_Abstract
{
+ /**
+ * Initialize default item renderer for row-level items output
+ */
+ protected function _construct()
+ {
+ parent::_construct();
+ $this->addItemRender(
+ $this->_getRowItemType('default'),
+ 'checkout/cart_item_renderer',
+ 'checkout/multishipping/overview/item.phtml'
+ );
+ }
+
/**
* Get multishipping checkout model
*
@@ -234,4 +247,58 @@ public function renderTotals($totals, $colspan=null)
. $this->getChild('totals')->setTotals($totals)->renderTotals('footer', $colspan);
return $totals;
}
+
+ /**
+ * Add renderer for row-level item output
+ *
+ * @param string $type Product type
+ * @param string $block Block type
+ * @param string $template Block template
+ * @return Mage_Checkout_Block_Multishipping_Overview
+ */
+ public function addRowItemRender($type, $block, $template)
+ {
+ $type = $this->_getRowItemType($type);
+ parent::addItemRender($this->_getRowItemType($type), $block, $template);
+ return $this;
+ }
+
+ /**
+ * Return row-level item html
+ *
+ * @param Varien_Object $item
+ * @return string
+ */
+ public function getRowItemHtml(Varien_Object $item)
+ {
+ $type = $this->_getItemType($item);
+ $block = $this->_getRowItemRenderer($type)
+ ->setItem($item);
+ $this->_prepareItem($block);
+ return $block->toHtml();
+ }
+
+ /**
+ * Retrieve renderer block for row-level item output
+ *
+ * @param string $type
+ * @return Mage_Core_Block_Abstract
+ */
+ public function _getRowItemRenderer($type)
+ {
+ $type = $this->_getRowItemType($type);
+ $type = isset($this->_itemRenders[$type]) ? $type : $this->_getRowItemType('default');
+ return parent::getItemRenderer($type);
+ }
+
+ /**
+ * Wrap row renderers into namespace by adding 'row_' suffix
+ *
+ * @param string $type Product type
+ * @return string
+ */
+ protected function _getRowItemType($type)
+ {
+ return 'row_' . $type;
+ }
}
diff --git a/app/code/core/Mage/Checkout/Model/Type/Abstract.php b/app/code/core/Mage/Checkout/Model/Type/Abstract.php
index 1f7dbd36d4..23f8cffcc2 100644
--- a/app/code/core/Mage/Checkout/Model/Type/Abstract.php
+++ b/app/code/core/Mage/Checkout/Model/Type/Abstract.php
@@ -150,6 +150,9 @@ protected function _createOrderFromAddress($address)
return $order;
}
+ /**
+ * @deprecated after 1.4.0.0-rc1
+ */
protected function _emailOrderConfirmation($email, $name, $order)
{
$mailer = Mage::getModel('core/email')
diff --git a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php
index 83f3475135..6e4b185087 100644
--- a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php
+++ b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php
@@ -158,6 +158,11 @@ public function removeAddressItem($addressId, $itemId)
$address->removeItem($item->getId());
}
+ /**
+ * Require shiping rate recollect
+ */
+ $address->setCollectShippingRates((boolean) $this->getCollectRatesFlag());
+
if (count($address->getAllItems()) == 0) {
$address->isDeleted(true);
}
@@ -374,6 +379,7 @@ public function setPaymentMethod($payment)
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Order
+ * @throws Mage_Checkout_Exception
*/
protected function _prepareOrder(Mage_Sales_Model_Quote_Address $address)
{
@@ -394,6 +400,9 @@ protected function _prepareOrder(Mage_Sales_Model_Quote_Address $address)
$order->setPayment($convertQuote->paymentToOrderPayment($quote->getPayment()));
foreach ($address->getAllItems() as $item) {
+ if (! $item->getQuoteItem()) {
+ throw new Mage_Checkout_Exception(Mage::helper('checkout')->__('Item not found or already ordered'));
+ }
$item->setProductType($item->getQuoteItem()->getProductType())
->setProductOptions($item->getQuoteItem()->getProduct()->getTypeInstance(true)->getOrderOptions($item->getQuoteItem()->getProduct()));
$orderItem = $convertQuote->itemToOrderItem($item);
diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php
index ffc9481f35..b914574a7e 100644
--- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php
+++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php
@@ -706,7 +706,7 @@ public function getLastOrderId()
$orderId = false;
if ($lastId) {
$order = Mage::getModel('sales/order');
- $order->load();
+ $order->load($lastId);
$orderId = $order->getIncrementId();
}
return $orderId;
diff --git a/app/code/core/Mage/Checkout/controllers/CartController.php b/app/code/core/Mage/Checkout/controllers/CartController.php
index 66b5448afb..5ed3c37f27 100644
--- a/app/code/core/Mage/Checkout/controllers/CartController.php
+++ b/app/code/core/Mage/Checkout/controllers/CartController.php
@@ -185,7 +185,7 @@ public function addAction()
Mage::dispatchEvent('checkout_cart_add_product_complete',
array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
- $message = $this->__('%s was successfully added to your shopping cart.', $product->getName());
+ $message = $this->__('%s was successfully added to your shopping cart.', Mage::helper('core')->htmlEscape($product->getName()));
if (!$this->_getSession()->getNoCartRedirect(true)) {
$this->_getSession()->addSuccess($message);
$this->_goBack();
@@ -263,6 +263,9 @@ public function updatePostAction()
}
}
$cart = $this->_getCart();
+ if (! $cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
+ $cart->getQuote()->setCustomerId(null);
+ }
$cart->updateItems($cartData)
->save();
}
diff --git a/app/code/core/Mage/Checkout/controllers/MultishippingController.php b/app/code/core/Mage/Checkout/controllers/MultishippingController.php
index 790bbae1b6..c3dee6f4ca 100644
--- a/app/code/core/Mage/Checkout/controllers/MultishippingController.php
+++ b/app/code/core/Mage/Checkout/controllers/MultishippingController.php
@@ -173,6 +173,11 @@ public function addressesAction()
$this->_redirect('*/multishipping_address/newShipping');
return;
}
+
+ $this->_getState()->unsCompleteStep(
+ Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
+ );
+
$this->_getState()->setActiveStep(
Mage_Checkout_Model_Type_Multishipping_State::STEP_SELECT_ADDRESSES
);
@@ -244,6 +249,7 @@ public function removeItemAction()
$itemId = $this->getRequest()->getParam('id');
$addressId = $this->getRequest()->getParam('address');
if ($addressId && $itemId) {
+ $this->_getCheckout()->setCollectRatesFlag(true);
$this->_getCheckout()->removeAddressItem($addressId, $itemId);
}
$this->_redirect('*/*/addresses');
@@ -460,6 +466,12 @@ public function overviewPostAction()
$this->_getCheckout()->getCheckoutSession()->setDisplaySuccess(true);
$this->_redirect('*/*/success');
}
+ catch (Mage_Checkout_Exception $e) {
+ Mage::helper('checkout')->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
+ $this->_getCheckout()->getCheckoutSession()->clear();
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
+ $this->_redirect('*/cart');
+ }
catch (Mage_Core_Exception $e){
Mage::helper('checkout')->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
Mage::getSingleton('checkout/session')->addError($e->getMessage());
diff --git a/app/code/core/Mage/Checkout/controllers/OnepageController.php b/app/code/core/Mage/Checkout/controllers/OnepageController.php
index 1593e081ea..246b93f7e4 100644
--- a/app/code/core/Mage/Checkout/controllers/OnepageController.php
+++ b/app/code/core/Mage/Checkout/controllers/OnepageController.php
@@ -39,11 +39,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action
public function preDispatch()
{
parent::preDispatch();
-
- if (!$this->_preDispatchValidateCustomer()) {
- return $this;
- }
-
+ $this->_preDispatchValidateCustomer();
return $this;
}
@@ -258,8 +254,13 @@ public function getAddressAction()
$addressId = $this->getRequest()->getParam('address', false);
if ($addressId) {
$address = $this->getOnepage()->getAddress($addressId);
- $this->getResponse()->setHeader('Content-type', 'application/x-json');
- $this->getResponse()->setBody($address->toJson());
+
+ if (Mage::getSingleton('customer/session')->getCustomer()->getId() == $address->getCustomerId()) {
+ $this->getResponse()->setHeader('Content-type', 'application/x-json');
+ $this->getResponse()->setBody($address->toJson());
+ } else {
+ $this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
+ }
}
}
@@ -287,8 +288,10 @@ public function saveBillingAction()
return;
}
if ($this->getRequest()->isPost()) {
- $data = $this->getRequest()->getPost('billing', array());
+ $postData = $this->getRequest()->getPost('billing', array());
+ $data = $this->_filterPostData($postData);
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
+
if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
@@ -492,4 +495,15 @@ public function saveOrderAction()
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
+ /**
+ * Filtering posted data. Converting localized data if needed
+ *
+ * @param array
+ * @return array
+ */
+ protected function _filterPostData($data)
+ {
+ $data = $this->_filterDates($data, array('dob'));
+ return $data;
+ }
}
diff --git a/app/code/core/Mage/Chronopay/Block/Form.php b/app/code/core/Mage/Chronopay/Block/Form.php
deleted file mode 100644
index 8d57f388b5..0000000000
--- a/app/code/core/Mage/Chronopay/Block/Form.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Chronopay_Block_Form extends Mage_Payment_Block_Form_Cc
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('chronopay/form.phtml');
- }
-
-}
diff --git a/app/code/core/Mage/Chronopay/Block/Info.php b/app/code/core/Mage/Chronopay/Block/Info.php
deleted file mode 100644
index 037984c7fd..0000000000
--- a/app/code/core/Mage/Chronopay/Block/Info.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
- */
-class Mage_Chronopay_Block_Info extends Mage_Payment_Block_Info_Cc
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('chronopay/info.phtml');
- }
-
- public function toPdf()
- {
- $this->setTemplate('chronopay/pdf/info.phtml');
- return $this->toHtml();
- }
-
-}
diff --git a/app/code/core/Mage/Chronopay/Block/Standard/Failure.php b/app/code/core/Mage/Chronopay/Block/Standard/Failure.php
deleted file mode 100644
index 9b62c7cee9..0000000000
--- a/app/code/core/Mage/Chronopay/Block/Standard/Failure.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
-*/
-
-class Mage_Chronopay_Block_Standard_Failure extends Mage_Core_Block_Template
-{
-}
diff --git a/app/code/core/Mage/Chronopay/Block/Standard/Form.php b/app/code/core/Mage/Chronopay/Block/Standard/Form.php
deleted file mode 100644
index 2226df7005..0000000000
--- a/app/code/core/Mage/Chronopay/Block/Standard/Form.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- */
-
-class Mage_Chronopay_Block_Standard_Form extends Mage_Payment_Block_Form
-{
- protected function _construct()
- {
- $this->setTemplate('chronopay/standard/form.phtml');
- parent::_construct();
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Block/Standard/Redirect.php b/app/code/core/Mage/Chronopay/Block/Standard/Redirect.php
deleted file mode 100644
index 46000837c4..0000000000
--- a/app/code/core/Mage/Chronopay/Block/Standard/Redirect.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
- */
-
-class Mage_Chronopay_Block_Standard_Redirect extends Mage_Core_Block_Abstract
-{
-
- protected function _toHtml()
- {
- $standard = Mage::getModel('chronopay/standard');
- $form = new Varien_Data_Form();
- $form->setAction($standard->getChronopayUrl())
- ->setId('chronopay_standard_checkout')
- ->setName('chronopay_standard_checkout')
- ->setMethod('POST')
- ->setUseContainer(true);
- foreach ($standard->setOrder($this->getOrder())->getStandardCheckoutFormFields() as $field => $value) {
- $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
- }
- $html = '';
- $html.= $this->__('You will be redirected to ChronoPay in a few seconds.');
- $html.= $form->toHtml();
- $html.= '';
- $html.= '';
-
- return $html;
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Helper/Data.php b/app/code/core/Mage/Chronopay/Helper/Data.php
deleted file mode 100644
index 9630876202..0000000000
--- a/app/code/core/Mage/Chronopay/Helper/Data.php
+++ /dev/null
@@ -1,38 +0,0 @@
-
- */
-class Mage_Chronopay_Helper_Data extends Mage_Core_Helper_Abstract
-{
-
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Api/Debug.php b/app/code/core/Mage/Chronopay/Model/Api/Debug.php
deleted file mode 100644
index b53494e2a2..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Api/Debug.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Chronopay_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('chronopay/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Config.php b/app/code/core/Mage/Chronopay/Model/Config.php
deleted file mode 100644
index 0a17a9f5ac..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Config.php
+++ /dev/null
@@ -1,126 +0,0 @@
-
- */
-
-class Mage_Chronopay_Model_Config extends Varien_Object
-{
- /**
- * Return config var
- *
- * @param string Var key
- * @param string Default value for non-existing key
- * @return mixed
- */
- public function getConfigData($key, $default=false)
- {
- if (!$this->hasData($key)) {
- $value = Mage::getStoreConfig('payment/chronopay_standard/'.$key);
- if (is_null($value) || false===$value) {
- $value = $default;
- }
- $this->setData($key, $value);
- }
- return $this->getData($key);
- }
-
- /**
- * Return Site ID registered in ChronoPay Admnin Panel
- *
- * @return string Site ID
- */
- public function getSiteId ()
- {
- return $this->getConfigData('site_id');
- }
-
- /**
- * Return Product ID (general type payments) registered in ChronoPay Admnin Panel
- *
- * @return string Product ID
- */
- public function getProductId ()
- {
- return $this->getConfigData('product_id');
- }
-
- /**
- * Return Store description sent to Chronopay
- *
- * @return string Description
- */
- public function getDescription ()
- {
- $description = $this->getConfigData('description');
- return $description;
- }
-
- /**
- * Return new order status
- *
- * @return string New order status
- */
- public function getNewOrderStatus ()
- {
- return $this->getConfigData('order_status');
- }
-
- /**
- * Return debug flag
- *
- * @return boolean Debug flag (0/1)
- */
- public function getDebug ()
- {
- return $this->getConfigData('debug_flag');
- }
-
- /**
- * Return accepted currency
- *
- * @return string Currenc
- */
- public function getCurrency ()
- {
- return $this->getConfigData('currency');
- }
-
- /**
- * Return client interface language
- *
- * @return string(2) Accepted language
- */
- public function getLanguage ()
- {
- return $this->getConfigData('language');
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Gateway.php b/app/code/core/Mage/Chronopay/Model/Gateway.php
deleted file mode 100644
index 9ac285488b..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Gateway.php
+++ /dev/null
@@ -1,336 +0,0 @@
-
- */
-
-class Mage_Chronopay_Model_Gateway extends Mage_Payment_Model_Method_Cc
-{
- const CGI_URL = 'https://secure.chronopay.com/gateway.cgi';
-
- const OPCODE_CHARGING = 1;
- const OPCODE_REFUND = 2;
- const OPCODE_AUTHORIZE = 4;
- const OPCODE_VOID_AUTHORIZE = 5;
- const OPCODE_CONFIRM_AUTHORIZE = 6;
- const OPCODE_CUSTOMER_FUND_TRANSFER = 8;
-
- protected $_code = 'chronopay_gateway';
-
- protected $_formBlockType = 'chronopay/form';
- protected $_infoBlockType = 'chronopay/info';
-
- /**
- * Availability options
- */
- protected $_isGateway = true;
- protected $_canAuthorize = true;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = true;
- protected $_canVoid = false;
- protected $_canUseInternal = true;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = true;
- protected $_canSaveCc = false;
-
- /**
- * Return ip address of customer
- *
- * @return string
- */
- protected function _getIp ()
- {
- return Mage::helper('core/http')->getRemoteAddr();
- }
-
- /**
- * Return shared secret key from config
- *
- * @return string
- */
- protected function _getSharedSecret ()
- {
- return $this->getConfigData('shared_secret');
- }
-
- public function authorize(Varien_Object $payment, $amount)
- {
- $payment->setAmount($amount);
- $payment->setOpcode(self::OPCODE_AUTHORIZE);
-
- $request = $this->_buildRequest($payment);
- $result = $this->_postRequest($request);
-
- if (!$result->getError()) {
- $payment->setStatus(self::STATUS_APPROVED);
- $payment->setCcTransId($result->getTransaction());
- } else {
- Mage::throwException($result->getError());
- }
-
- return $this;
- }
-
- public function capture(Varien_Object $payment, $amount)
- {
- $payment->setAmount($amount);
- if ($payment->getCcTransId()) {
- $this->setTransactionId($payment->getCcTransId());
- $payment->setOpcode(self::OPCODE_CONFIRM_AUTHORIZE);
- } else {
- $payment->setOpcode(self::OPCODE_CHARGING);
- }
-
- $request = $this->_buildRequest($payment);
- $result = $this->_postRequest($request);
-
- if (!$result->getError()) {
- $payment->setStatus(self::STATUS_APPROVED);
- $payment->setLastTransId($result->getTransaction());
- } else {
- Mage::throwException($result->getError());
- }
-
- return $this;
- }
-
- public function refund(Varien_Object $payment, $amount)
- {
- $payment->setAmount($amount);
- $payment->setOpcode(self::OPCODE_REFUND);
-
- $this->setTransactionId($payment->getRefundTransactionId());
-
- $request = $this->_buildRequest($payment);
- $result = $this->_postRequest($request);
-
- $payment->setStatus(self::STATUS_APPROVED);
- $payment->setLastTransId($result->getTransaction());
-
- return $this;
- }
-
- /**
- * Building request array
- *
- * @param Varien_Object
- * @return array
- */
- protected function _buildRequest(Varien_Object $payment)
- {
- $order = $payment->getOrder();
- $billing = $order->getBillingAddress();
- $streets = $billing->getStreet();
- $street = isset($streets[0]) && $streets[0] != ''
- ? $streets[0]
- : (isset($streets[1]) && $streets[1] != '' ? $streets[1] : '');
-
- $request = Mage::getModel('chronopay/gateway_request')
- ->setOpcode($payment->getOpcode())
- ->setProductId($this->getConfigData('product_id'));
-
- switch ($request->getOpcode()) {
- case self::OPCODE_CUSTOMER_FUND_TRANSFER :
- $request->setCustomer($order->getCustomerId())
- ->setAmount(sprintf('%.2f', $payment->getAmount()))
- ->setCurrency($order->getBaseCurrencyCode());
- break;
- case self::OPCODE_CHARGING :
- case self::OPCODE_REFUND :
- case self::OPCODE_AUTHORIZE :
- case self::OPCODE_VOID_AUTHORIZE :
- $request->setFname($billing->getFirstname())
- ->setLname($billing->getLastname())
- ->setCardholder($payment->getCcOwner())
- ->setZip($billing->getPostcode())
- ->setStreet($street)
- ->setCity($billing->getCity())
- ->setState($billing->getRegionModel()->getCode())
- ->setCountry($billing->getCountryModel()->getIso3Code())
- ->setEmail($order->getCustomerEmail())
- ->setPhone($billing->getTelephone())
- ->setIp($this->_getIp())
- ->setCardNo($payment->getCcNumber())
- ->setCvv($payment->getCcCid())
- ->setExpirey($payment->getCcExpYear())
- ->setExpirem(sprintf('%02d', $payment->getCcExpMonth()))
- ->setAmount(sprintf('%.2f', $payment->getAmount()))
- ->setCurrency($order->getBaseCurrencyCode());
- break;
- default :
- Mage::throwException(
- Mage::helper('chronopay')->__('Invalid operation code')
- );
- break;
- }
-
- $request->setShowTransactionId(1);
-
- if ($this->getTransactionId()) {
- $request->setTransaction($this->getTransactionId());
- }
-
-
- $hash = $this->_getHash($request);
- $request->setHash($hash);
- return $request;
- }
-
- /**
- * Send request to gateway
- *
- * @param Mage_Chronopay_Model_Gateway_Request
- * @return mixed
- */
- protected function _postRequest(Mage_Chronopay_Model_Gateway_Request $request)
- {
- $result = Mage::getModel('chronopay/gateway_result');
-
- $client = new Varien_Http_Client();
-
- $url = $this->getConfigData('cgi_url');
- $client->setUri($url ? $url : self::CGI_URL);
- $client->setConfig(array(
- 'maxredirects' => 0,
- 'timeout' => 30,
- ));
- $client->setParameterPost($request->getData());
- $client->setMethod(Zend_Http_Client::POST);
-
- if ($this->getConfigData('debug_flag')) {
- $debug = Mage::getModel('chronopay/api_debug')
- ->setRequestBody($client->getUri() . "\n" . print_r($request->getData(), 1))
- ->save();
- }
-
- try {
- $response = $client->request();
- $body = $response->getRawBody();
-
- if (preg_match('/(T\|(.+)\|[\r\n]{0,}){0,1}(Y\|(.+)?|\|)|(N\|(.+[\r\n]{0,}.+){0,})/', $body, $matches)) {
-
- $transactionId = $matches[2];
- $message = isset($matches[4])?trim($matches[4], '|'):'';
-
- if (isset($matches[5], $matches[6])) {
- $result->setError($matches[6]);
- Mage::throwException($matches[6]);
- }
-
- if ($message == 'Completed') {
- $result->setTransaction($request->getTransaction());
- }
-
- if (strlen($transactionId)) {
- $result->setTransaction($transactionId);
- }
-
- if (!$result->getTransaction()) {
- Mage::throwException(Mage::helper('chronopay')->__('Transaction ID is invalid'));
- }
- } else {
- Mage::throwException(Mage::helper('chronopay')->__('Invalid response format'));
- }
-
- if ($this->getConfigData('debug_flag')) {
- $debug->setResponseBody($body)->save();
- }
-
- } catch (Exception $e) {
- $result->setResponseCode(-1)
- ->setResponseReasonCode($e->getCode())
- ->setResponseReasonText($e->getMessage());
-
-
- $exceptionMsg = Mage::helper('chronopay')->__('Gateway request error: %s', $e->getMessage());
-
- if ($this->getConfigData('debug_flag')) {
- $debug->setResponseBody($body)->save();
- }
-
- Mage::throwException($exceptionMsg);
- }
- return $result;
- }
-
- /**
- * Generate MD5 hash for transaction checksum
- *
- * @param Mage_Chronopay_Model_Gateway_Request
- * @return string MD5
- */
- protected function _getHash(Mage_Chronopay_Model_Gateway_Request $request)
- {
- $hashArray = array(
- $this->_getSharedSecret(),
- $request->getOpcode(),
- $request->getProductId()
- );
-
- switch ($request->getOpcode()) {
- case self::OPCODE_CHARGING :
- case self::OPCODE_AUTHORIZE :
- $hashArray[] = $request->getFname();
- $hashArray[] = $request->getLname();
- $hashArray[] = $request->getStreet();
- $hashArray[] = $this->_getIp();
- $hashArray[] = $request->getCardNo();
- $hashArray[] = $request->getAmount();
- break;
-
- case self::OPCODE_VOID_AUTHORIZE :
- case self::OPCODE_CONFIRM_AUTHORIZE :
- $hashArray[] = $request->getTransaction();
- break;
-
- case self::OPCODE_REFUND :
- $hashArray[] = $request->getTransaction();
- $hashArray[] = $request->getAmount();
- break;
-
- case self::OPCODE_CUSTOMER_FUND_TRANSFER :
- $hashArray[] = $request->getCustomer();
- $hashArray[] = $request->getTransaction();
- $hashArray[] = $request->getAmount();
- break;
-
- default :
- Mage::throwException(
- Mage::helper('chronopay')->__('Invalid operation code')
- );
- break;
- }
-
- return md5(implode('', $hashArray));
- }
-
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Gateway/Request.php b/app/code/core/Mage/Chronopay/Model/Gateway/Request.php
deleted file mode 100644
index f67661262b..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Gateway/Request.php
+++ /dev/null
@@ -1,38 +0,0 @@
-
- */
-
-class Mage_Chronopay_Model_Gateway_Request extends Varien_Object
-{
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Gateway/Result.php b/app/code/core/Mage/Chronopay/Model/Gateway/Result.php
deleted file mode 100644
index ee4a9013b8..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Gateway/Result.php
+++ /dev/null
@@ -1,38 +0,0 @@
-
- */
-
-class Mage_Chronopay_Model_Gateway_Result extends Varien_Object
-{
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Chronopay/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index 6132be998d..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-
-class Mage_Chronopay_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('chronopay/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/Chronopay/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index a79637608a..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Chronopay_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('chronopay/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Mysql4/Setup.php b/app/code/core/Mage/Chronopay/Model/Mysql4/Setup.php
deleted file mode 100644
index 14df4f2b32..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-
-class Mage_Chronopay_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
-{
-
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Source/Cctype.php b/app/code/core/Mage/Chronopay/Model/Source/Cctype.php
deleted file mode 100644
index 7baf32ea85..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Source/Cctype.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Chronopay_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
-{
- public function getAllowedTypes()
- {
- return array('VI', 'MC', 'AE', 'DICL', 'JCB', 'ENR', 'SS', 'DI');
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Source/Language.php b/app/code/core/Mage/Chronopay/Model/Source/Language.php
deleted file mode 100644
index e8fee6f1dd..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Source/Language.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
- */
-
-class Mage_Chronopay_Model_Source_Language
-{
- public function toOptionArray()
- {
- return array(
- array('value' => 'EN', 'label' => Mage::helper('chronopay')->__('English')),
- array('value' => 'RU', 'label' => Mage::helper('chronopay')->__('Russian')),
- array('value' => 'NL', 'label' => Mage::helper('chronopay')->__('Dutch')),
- array('value' => 'DE', 'label' => Mage::helper('chronopay')->__('German')),
- );
- }
-}
-
-
-
diff --git a/app/code/core/Mage/Chronopay/Model/Source/PaymentAction.php b/app/code/core/Mage/Chronopay/Model/Source/PaymentAction.php
deleted file mode 100644
index d945684523..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Source/PaymentAction.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- */
-class Mage_Chronopay_Model_Source_PaymentAction
-{
- public function toOptionArray()
- {
- return array(
- array(
- 'value' => Mage_Chronopay_Model_Gateway::ACTION_AUTHORIZE,
- 'label' => Mage::helper('chronopay')->__('Authorize Only')
- ),
- array(
- 'value' => Mage_Chronopay_Model_Gateway::ACTION_AUTHORIZE_CAPTURE,
- 'label' => Mage::helper('chronopay')->__('Authorize and Capture')
- ),
- );
- }
-}
diff --git a/app/code/core/Mage/Chronopay/Model/Standard.php b/app/code/core/Mage/Chronopay/Model/Standard.php
deleted file mode 100644
index d6cfeb8ac9..0000000000
--- a/app/code/core/Mage/Chronopay/Model/Standard.php
+++ /dev/null
@@ -1,269 +0,0 @@
-
- */
-class Mage_Chronopay_Model_Standard extends Mage_Payment_Model_Method_Abstract
-{
- protected $_code = 'chronopay_standard';
- protected $_formBlockType = 'chronopay/standard_form';
-
- protected $_isGateway = false;
- protected $_canAuthorize = true;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = false;
- protected $_canVoid = false;
- protected $_canUseInternal = false;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = false;
-
- protected $_order = null;
-
-
- /**
- * Get Config model
- *
- * @return object Mage_Chronopay_Model_Config
- */
- public function getConfig()
- {
- return Mage::getSingleton('chronopay/config');
- }
-
- /**
- * Payment validation
- *
- * @param none
- * @return Mage_Chronopay_Model_Standard
- */
- public function validate()
- {
- parent::validate();
- $paymentInfo = $this->getInfoInstance();
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
- $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
- } else {
- $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
- }
- if ($currency_code != $this->getConfig()->getCurrency()) {
- Mage::throwException(Mage::helper('chronopay')->__('Selected currency code ('.$currency_code.') is not compatible with ChronoPay'));
- }
- return $this;
- }
-
- /**
- * Capture payment
- *
- * @param Varien_Object $orderPayment
- * @return Mage_Payment_Model_Abstract
- */
- public function capture (Varien_Object $payment, $amount)
- {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId());
-
- return $this;
- }
-
- /**
- * Returns Target URL
- *
- * @return string Target URL
- */
- public function getChronopayUrl ()
- {
- return 'https://secure.chronopay.com/index_shop.cgi';
- }
-
- /**
- * Return URL for Chronopay success response
- *
- * @return string URL
- */
- protected function getSuccessURL ()
- {
- return Mage::getUrl('chronopay/standard/success', array('_secure' => true));
- }
-
- /**
- * Return URL for Chronopay notification
- *
- * @return string Notification URL
- */
- protected function getNotificationURL ()
- {
- return Mage::getUrl('chronopay/standard/notify', array('_secure' => true));
- }
-
- /**
- * Return URL for Chronopay failure response
- *
- * @return string URL
- */
- protected function getFailureURL ()
- {
- return Mage::getUrl('chronopay/standard/failure', array('_secure' => true));
- }
-
- /**
- * Form block description
- *
- * @return object
- */
- public function createFormBlock($name)
- {
- $block = $this->getLayout()->createBlock('chronopay/form_standard', $name);
- $block->setMethod($this->_code);
- $block->setPayment($this->getPayment());
-
- return $block;
- }
-
- /**
- * Return Order Place Redirect URL
- *
- * @return string Order Redirect URL
- */
- public function getOrderPlaceRedirectUrl()
- {
- return Mage::getUrl('chronopay/standard/redirect');
- }
-
- /**
- * Return Standard Checkout Form Fields for request to Chronopay
- *
- * @return array Array of hidden form fields
- */
- public function getStandardCheckoutFormFields ()
- {
- $order = $this->getOrder();
- if (!($order instanceof Mage_Sales_Model_Order)) {
- Mage::throwException($this->_getHelper()->__('Cannot retrieve order object'));
- }
-
- $billingAddress = $order->getBillingAddress();
-
- $streets = $billingAddress->getStreet();
- $street = isset($streets[0]) && $streets[0] != ''
- ? $streets[0]
- : (isset($streets[1]) && $streets[1] != '' ? $streets[1] : '');
-
- if ($this->getConfig()->getDescription()) {
- $transDescription = $this->getConfig()->getDescription();
- } else {
- $transDescription = Mage::helper('chronopay')->__('Order #%s', $order->getRealOrderId());
- }
-
- if ($order->getCustomerEmail()) {
- $email = $order->getCustomerEmail();
- } elseif ($billingAddress->getEmail()) {
- $email = $billingAddress->getEmail();
- } else {
- $email = '';
- }
-
- $fields = array(
- 'product_id' => $this->getConfig()->getProductId(),
- 'product_name' => $transDescription,
- 'product_price' => $order->getBaseGrandTotal(),
- 'language' => $this->getConfig()->getLanguage(),
- 'f_name' => $billingAddress->getFirstname(),
- 's_name' => $billingAddress->getLastname(),
- 'street' => $street,
- 'city' => $billingAddress->getCity(),
- 'state' => $billingAddress->getRegionModel()->getCode(),
- 'zip' => $billingAddress->getPostcode(),
- 'country' => $billingAddress->getCountryModel()->getIso3Code(),
- 'phone' => $billingAddress->getTelephone(),
- 'email' => $email,
- 'cb_url' => $this->getNotificationURL(),
- 'cb_type' => 'P', // POST method used (G - GET method)
- 'decline_url' => $this->getFailureURL(),
- 'cs1' => Mage::helper('core')->encrypt($order->getRealOrderId())
- );
-
- if ($this->getConfig()->getDebug()) {
- $debug = Mage::getModel('chronopay/api_debug')
- ->setRequestBody($this->getChronopayUrl()."\n".print_r($fields,1))
- ->save();
- $fields['cs2'] = $debug->getId();
- }
-
- return $fields;
- }
-
- /**
- * Validate Response from ChronoPay
- *
- * @param array Post data returned from ChronoPay
- * @return mixed
- */
- public function validateResponse ($data)
- {
- $order = $this->getOrder();
-
- if (!($order instanceof Mage_Sales_Model_Order)) {
- Mage::throwException($this->_getHelper()->__('Cannot retrieve order object'));
- }
-
- try {
- $ok = is_array($data)
- && isset($data['transaction_type']) && $data['transaction_type'] != ''
- && isset($data['customer_id']) && $data['customer_id'] != ''
- && isset($data['site_id']) && $data['site_id'] != ''
- && isset($data['product_id']) && $data['product_id'] != '';
-
- if (!$ok) {
- throw new Exception('Cannot restore order or invalid order ID');
- }
-
- // validate site ID
- if ($this->getConfig()->getSiteId() != $data['site_id']) {
- throw new Exception('Invalid site ID');
- }
-
- // validate product ID
- if ($this->getConfig()->getProductId() != $data['product_id']) {
- throw new Exception('Invalid product ID');
- }
-
- // Successful transaction type
- if (!in_array($data['transaction_type'], array('initial', 'onetime'))) {
- throw new Exception('Transaction is not successful');
- }
-
- } catch (Exception $e) {
- return $e;
- }
- }
-}
diff --git a/app/code/core/Mage/Chronopay/controllers/StandardController.php b/app/code/core/Mage/Chronopay/controllers/StandardController.php
deleted file mode 100644
index 2c96139df3..0000000000
--- a/app/code/core/Mage/Chronopay/controllers/StandardController.php
+++ /dev/null
@@ -1,219 +0,0 @@
-
-*/
-class Mage_Chronopay_StandardController extends Mage_Core_Controller_Front_Action
-{
- /**
- * Order instance
- */
- protected $_order;
-
- /**
- * Return debug flag
- *
- * @return boolean
- */
- public function getDebug ()
- {
- return Mage::getSingleton('chronopay/config')->getDebug();
- }
-
- /**
- * Get order
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder ()
- {
- if ($this->_order == null) {
- $session = Mage::getSingleton('checkout/session');
- $this->_order = Mage::getModel('sales/order');
- $this->_order->loadByIncrementId($session->getLastRealOrderId());
- }
- return $this->_order;
- }
-
- /**
- * When a customer chooses Chronopay on Checkout/Payment page
- *
- */
- public function redirectAction()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setChronopayStandardQuoteId($session->getQuoteId());
-
- $order = $this->getOrder();
-
- if (!$order->getId()) {
- $this->norouteAction();
- return;
- }
-
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('chronopay')->__('Customer was redirected to Chronopay')
- );
- $order->save();
-
- $this->getResponse()
- ->setBody($this->getLayout()
- ->createBlock('chronopay/standard_redirect')
- ->setOrder($order)
- ->toHtml());
-
- $session->unsQuoteId();
- }
-
- /**
- * Success response from Chronopay
- */
- public function successAction()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setQuoteId($session->getChronopayStandardQuoteId());
- $session->unsChronopayStandardQuoteId();
-
- $order = $this->getOrder();
-
- if (!$order->getId()) {
- $this->norouteAction();
- return;
- }
-
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('chronopay')->__('Customer successfully returned from Chronopay')
- );
-
- $order->save();
- $this->_redirect('checkout/onepage/success');
- }
-
-
- /**
- * Notification Action from ChronoPay
- */
- public function notifyAction ()
- {
- $postData = $this->getRequest()->getPost();
-
- if (!count($postData)) {
- $this->norouteAction();
- return;
- }
-
- if ($this->getDebug()) {
- $debug = Mage::getModel('chronopay/api_debug');
- if (isset($postData['cs2']) && $postData['cs2'] > 0) {
- $debug->setId($postData['cs2']);
- }
- $debug->setResponseBody(print_r($postData,1))->save();
- }
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId(Mage::helper('core')->decrypt($postData['cs1']));
- if ($order->getId()) {
- $result = $order->getPayment()->getMethodInstance()->setOrder($order)->validateResponse($postData);
-
- if ($result instanceof Exception) {
- if ($order->getId()) {
- $order->addStatusToHistory(
- $order->getStatus(),
- $result->getMessage()
- );
- $order->cancel();
- }
- Mage::throwException($result->getMessage());
- return;
- }
-
- $order->sendNewOrderEmail();
-
- $order->getPayment()->getMethodInstance()->setTransactionId($postData['transaction_id']);
-
- if ($this->saveInvoice($order)) {
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
- }
- $order->save();
- }
- }
-
- /**
- * Save invoice for order
- *
- * @param Mage_Sales_Model_Order $order
- * @return boolean Can save invoice or not
- */
- protected function saveInvoice (Mage_Sales_Model_Order $order)
- {
- if ($order->canInvoice()) {
- $invoice = $order->prepareInvoice();
- $invoice->register()->capture();
- Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
- return true;
- }
-
- return false;
- }
-
- /**
- * Failure response from Chronopay
- */
- public function failureAction ()
- {
- $errorMsg = Mage::helper('chronopay')->__('There was an error occurred during paying process.');
-
- $order = $this->getOrder();
-
- if (!$order->getId()) {
- $this->norouteAction();
- return;
- }
-
- if ($order instanceof Mage_Sales_Model_Order && $order->getId()) {
- $order->addStatusToHistory($order->getStatus(), $errorMsg);
- $order->cancel();
- $order->save();
- }
-
- $this->loadLayout();
- $this->renderLayout();
-
- Mage::getSingleton('checkout/session')->unsLastRealOrderId();
- }
-
-}
diff --git a/app/code/core/Mage/Chronopay/etc/config.xml b/app/code/core/Mage/Chronopay/etc/config.xml
deleted file mode 100644
index 5d750b0560..0000000000
--- a/app/code/core/Mage/Chronopay/etc/config.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
-
-
- 0.1.0
-
-
-
-
-
- Mage_Chronopay_Model
- chronopay_mysql4
-
-
- Mage_Chronopay_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Chronopay
- Mage_Chronopay_Model_Mysql4_Setup
-
-
-
-
- Mage_Chronopay_Block
-
-
-
-
-
- DI
- Discover
- 60
-
-
- JCB
- JCB
- 61
-
-
- DICL
- Diners Club
- 62
-
-
- ENR
- enRoute
- 63
-
-
- SS
- Maestro/Solo
- 64
-
-
-
-
-
-
-
- /chronopay/standard
-
-
-
- standard
-
- Mage_Chronopay
- chronopay
-
-
-
-
-
-
-
- Mage_Chronopay.csv
-
-
-
-
-
-
-
- chronopay.xml
-
-
-
-
-
-
-
-
-
- Mage_Chronopay.csv
-
-
-
-
-
-
-
-
- chronopay/standard
- ChronoPay Standard
- 0
- O
-
-
- chronopay/gateway
- ChronoPay Gateway
- 0
- O
-
-
-
-
diff --git a/app/code/core/Mage/Chronopay/etc/system.xml b/app/code/core/Mage/Chronopay/etc/system.xml
deleted file mode 100644
index 31ca9c13b8..0000000000
--- a/app/code/core/Mage/Chronopay/etc/system.xml
+++ /dev/null
@@ -1,272 +0,0 @@
-
-
-
-
-
-
-
- ChronoPay Standard
- Please specify Access URL: {STORE_URL}/chronopay/standard/success in the ChronoPay Client Admin.
- text
- 251
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- Site ID
- text
- 3
- 1
- 1
- 0
-
-
- Product ID
- text
- 4
- 1
- 1
- 0
-
-
- Transaction Description
- Order number will be used if left empty
- text
- 5
- 1
- 1
- 0
-
-
- Accepted currency
- select
- adminhtml/system_config_source_currency
- 6
- 1
- 1
- 0
-
-
- Customer Interface language
- select
- chronopay/source_language
- 7
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 8
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 9
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 10
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 11
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 12
- 1
- 1
- 0
-
-
-
-
- ChronoPay Gateway
- text
- 251
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 0
- 1
- 1
- 0
-
-
- Title
- text
- 10
- 1
- 1
- 1
-
-
- Payment Action
- select
- chronopay/source_paymentAction
- 20
- 1
- 1
- 0
-
-
- CGI URL
- text
- 30
- 1
- 1
- 0
-
-
- Product ID
- text
- 40
- 1
- 1
- 0
-
-
- Shared Secret
- text
- 50
- 1
- 1
- 0
-
-
- Credit Card Types
- multiselect
- chronopay/source_cctype
- 60
- 1
- 1
- 0
-
-
- Accepted currency
- select
- adminhtml/system_config_source_currency
- 70
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 80
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 90
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 100
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 110
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 120
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Chronopay/sql/chronopay_setup/mysql4-install-0.1.0.php b/app/code/core/Mage/Chronopay/sql/chronopay_setup/mysql4-install-0.1.0.php
deleted file mode 100644
index 815695c343..0000000000
--- a/app/code/core/Mage/Chronopay/sql/chronopay_setup/mysql4-install-0.1.0.php
+++ /dev/null
@@ -1,45 +0,0 @@
-startSetup();
-
-$installer->run("
-CREATE TABLE `{$this->getTable('chronopay_api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Cms/Block/Widget/Page/Link.php b/app/code/core/Mage/Cms/Block/Widget/Page/Link.php
index c6659c79b5..965c384887 100644
--- a/app/code/core/Mage/Cms/Block/Widget/Page/Link.php
+++ b/app/code/core/Mage/Cms/Block/Widget/Page/Link.php
@@ -90,10 +90,11 @@ public function getTitle()
if ($this->getData('title') !== null) {
// compare to null used here bc user can specify blank title
$this->_title = $this->getData('title');
- } else if ($this->getData('href')) {
- $this->_title = Mage::getResourceSingleton('cms/page')->getCmsPageTitleByIdentifier($this->getData('href'));
} else if ($this->getData('page_id')) {
$this->_title = Mage::getResourceSingleton('cms/page')->getCmsPageTitleById($this->getData('page_id'));
+ } else if ($this->getData('href')) {
+ $this->_title = Mage::getResourceSingleton('cms/page')->setStore(Mage::app()->getStore())
+ ->getCmsPageTitleByIdentifier($this->getData('href'));
}
}
@@ -114,7 +115,8 @@ public function getAnchorText()
} else if ($this->getTitle()) {
$this->_anchorText = $this->getTitle();
} else if ($this->getData('href')) {
- $this->_anchorText = Mage::getResourceSingleton('cms/page')->getCmsPageTitleByIdentifier($this->getData('href'));
+ $this->_anchorText = Mage::getResourceSingleton('cms/page')->setStore(Mage::app()->getStore())
+ ->getCmsPageTitleByIdentifier($this->getData('href'));
} else if ($this->getData('page_id')) {
$this->_anchorText = Mage::getResourceSingleton('cms/page')->getCmsPageTitleById($this->getData('page_id'));
} else {
diff --git a/app/code/core/Mage/Cms/Model/Mysql4/Page.php b/app/code/core/Mage/Cms/Model/Mysql4/Page.php
index 7a68dc954c..a1404552d5 100644
--- a/app/code/core/Mage/Cms/Model/Mysql4/Page.php
+++ b/app/code/core/Mage/Cms/Model/Mysql4/Page.php
@@ -34,6 +34,13 @@
class Mage_Cms_Model_Mysql4_Page extends Mage_Core_Model_Mysql4_Abstract
{
+ /**
+ * Store model
+ *
+ * @var null|Mage_Core_Model_Store
+ */
+ protected $_store = null;
+
/**
* Initialize resource model
*/
@@ -142,7 +149,7 @@ protected function _getLoadSelect($field, $value, $object)
array('cps' => $this->getTable('cms/page_store')),
$this->getMainTable().'.page_id = `cps`.page_id'
)
- ->where('is_active=1 AND `cps`.store_id in (0, ?) ', $object->getStoreId())
+ ->where('is_active=1 AND `cps`.store_id in (' . Mage_Core_Model_App::ADMIN_STORE_ID . ', ?) ', $object->getStoreId())
->order('store_id DESC')
->limit(1);
}
@@ -164,7 +171,11 @@ public function getIsUniquePageToStores(Mage_Core_Model_Abstract $object)
if ($object->getId()) {
$select->where($this->getMainTable().'.page_id <> ?',$object->getId());
}
- $select->where('`cps`.store_id IN (?)', (array)$object->getData('stores'));
+ $stores = (array)$object->getData('stores');
+ if (Mage::app()->isSingleStoreMode()) {
+ $stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
+ }
+ $select->where('`cps`.store_id IN (?)', $stores);
if ($this->_getWriteAdapter()->fetchRow($select)) {
return false;
@@ -201,7 +212,7 @@ public function checkIdentifier($identifier, $storeId)
'main_table.page_id = `cps`.page_id'
)
->where('main_table.identifier=?', $identifier)
- ->where('main_table.is_active=1 AND `cps`.store_id in (0, ?) ', $storeId)
+ ->where('main_table.is_active=1 AND `cps`.store_id in (' . Mage_Core_Model_App::ADMIN_STORE_ID . ', ?) ', $storeId)
->order('store_id DESC');
return $this->_getReadAdapter()->fetchOne($select);
@@ -217,8 +228,13 @@ public function getCmsPageTitleByIdentifier($identifier)
{
$select = $this->_getReadAdapter()->select();
/* @var $select Zend_Db_Select */
+ $joinExpr = $this->_getReadAdapter()->quoteInto(
+ 'main_table.page_id = cps.page_id AND (cps.store_id = ' . Mage_Core_Model_App::ADMIN_STORE_ID . ' OR cps.store_id = ?)', $this->getStore()->getId()
+ );
$select->from(array('main_table' => $this->getMainTable()), 'title')
- ->where('main_table.identifier = ?', $identifier);
+ ->joinLeft(array('cps' => $this->getTable('cms/page_store')), $joinExpr ,array())
+ ->where('main_table.identifier = ?', $identifier)
+ ->order('cps.store_id DESC');
return $this->_getReadAdapter()->fetchOne($select);
}
@@ -265,4 +281,26 @@ public function lookupStoreIds($id)
->where("{$this->getIdFieldName()} = ?", $id)
);
}
+
+ /**
+ * Set store model
+ *
+ * @param Mage_Core_Model_Store $store
+ * @return Mage_Cms_Model_Mysql4_Page
+ */
+ public function setStore($store)
+ {
+ $this->_store = $store;
+ return $this;
+ }
+
+ /**
+ * Retrieve store model
+ *
+ * @return Mage_Core_Model_Store
+ */
+ public function getStore()
+ {
+ return Mage::app()->getStore($this->_store);
+ }
}
diff --git a/app/code/core/Mage/Cms/sql/cms_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Cms/sql/cms_setup/mysql4-install-0.7.0.php
index b7f84af9d7..9dbb738025 100644
--- a/app/code/core/Mage/Cms/sql/cms_setup/mysql4-install-0.7.0.php
+++ b/app/code/core/Mage/Cms/sql/cms_setup/mysql4-install-0.7.0.php
@@ -65,7 +65,7 @@
UNIQUE KEY `identifier` (`identifier`,`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='CMS pages';
-insert into {$this->getTable('cms_page')}(`page_id`,`title`,`root_template`,`meta_keywords`,`meta_description`,`identifier`,`content`,`creation_time`,`update_time`,`is_active`,`store_id`,`sort_order`) values (1,'404 Not Found 1','right_column','Page keywords','Page description','no-route','
Whoops, our bad... \r\n\r\nThe page you requested was not found, and we have a fine guess why. \r\n\r\n\r\nIf you typed the URL directly, please make sure the spelling is correct. \r\nIf you clicked on a link to get here, the link is outdated. \r\n \r\n \r\n \r\n\r\nWhat can you do? \r\nHave no fear, help is near! There are many ways you can get back on track with Magento Demo Store. \r\n\r\n\r\nGo back to the previous page. \r\nUse the search bar at the top of the page to search for your products. \r\nFollow these links to get you back on track!Store Home My Account \r\n
','2007-06-20 18:38:32','2007-08-26 19:11:13',1,0,0),(2,'Home page','right_column','','','home','Home Page \r\n','2007-08-23 10:03:25','2007-09-06 13:26:53',1,0,0),(3,'About Us','one_column','','','about-magento-demo-store','\r\n
About Magento Demo Store \r\n\r\n\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede.
\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.
\r\n
\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit.
\r\n
Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo.
\r\n
Maecenas ullamcorper, odio vel tempus egestas, dui orci faucibus orci, sit amet aliquet lectus dolor et quam. Pellentesque consequat luctus purus. Nunc et risus. Etiam a nibh. Phasellus dignissim metus eget nisi. Vestibulum sapien dolor, aliquet nec, porta ac, malesuada a, libero. Praesent feugiat purus eget est. Nulla facilisi. Vestibulum tincidunt sapien eu velit. Mauris purus. Maecenas eget mauris eu orci accumsan feugiat. Pellentesque eget velit. Nunc tincidunt.
\r\n
\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper
\r\n
Maecenas ullamcorper, odio vel tempus egestas, dui orci faucibus orci, sit amet aliquet lectus dolor et quam. Pellentesque consequat luctus purus.
\r\n
Nunc et risus. Etiam a nibh. Phasellus dignissim metus eget nisi.
\r\n
\r\n
To all of you, from all of us at Magento Demo Store - Thank you and Happy eCommerce!
\r\n
John Doe Some important guy
\r\n
','2007-08-30 14:01:18','2007-08-30 14:01:18',1,0,0),(4,'Customer Service','three_column','','','customer-service','\r\n
Customer Service \r\n\r\n\r\n\r\nShipping & Delivery \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nPrivacy & Security \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nReturns & Replacements \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nOrdering \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nPayment, Pricing & Promotions \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nViewing Orders \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nUpdating Account Information \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\n ','2007-08-30 14:02:20','2007-08-30 14:03:37',1,0,0);
+insert into {$this->getTable('cms_page')}(`page_id`,`title`,`root_template`,`meta_keywords`,`meta_description`,`identifier`,`content`,`creation_time`,`update_time`,`is_active`,`store_id`,`sort_order`) values (1,'404 Not Found 1','right_column','Page keywords','Page description','no-route','
Whoops, our bad... \r\n\r\nThe page you requested was not found, and we have a fine guess why. \r\n\r\n\r\nIf you typed the URL directly, please make sure the spelling is correct. \r\nIf you clicked on a link to get here, the link is outdated. \r\n \r\n \r\n\r\nWhat can you do? \r\nHave no fear, help is near! There are many ways you can get back on track with Magento Store. \r\n\r\n\r\nGo back to the previous page. \r\nUse the search bar at the top of the page to search for your products. \r\nFollow these links to get you back on track!Store Home | My Account \r\n','2007-06-20 18:38:32','2007-08-26 19:11:13',1,0,0),(2,'Home page','right_column','','','home','
Home Page \r\n','2007-08-23 10:03:25','2007-09-06 13:26:53',1,0,0),(3,'About Us','one_column','','','about-magento-demo-store','\r\n
About Magento Store \r\n\r\n\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede.
\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta.
\r\n
\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit.
\r\n
Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo.
\r\n
Maecenas ullamcorper, odio vel tempus egestas, dui orci faucibus orci, sit amet aliquet lectus dolor et quam. Pellentesque consequat luctus purus. Nunc et risus. Etiam a nibh. Phasellus dignissim metus eget nisi. Vestibulum sapien dolor, aliquet nec, porta ac, malesuada a, libero. Praesent feugiat purus eget est. Nulla facilisi. Vestibulum tincidunt sapien eu velit. Mauris purus. Maecenas eget mauris eu orci accumsan feugiat. Pellentesque eget velit. Nunc tincidunt.
\r\n
\r\n
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper
\r\n
Maecenas ullamcorper, odio vel tempus egestas, dui orci faucibus orci, sit amet aliquet lectus dolor et quam. Pellentesque consequat luctus purus.
\r\n
Nunc et risus. Etiam a nibh. Phasellus dignissim metus eget nisi.
\r\n
\r\n
To all of you, from all of us at Magento Store - Thank you and Happy eCommerce!
\r\n
John Doe Some important guy
\r\n
','2007-08-30 14:01:18','2007-08-30 14:01:18',1,0,0),(4,'Customer Service','three_column','','','customer-service','\r\n
Customer Service \r\n\r\n\r\n\r\nShipping & Delivery \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nPrivacy & Security \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nReturns & Replacements \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nOrdering \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nPayment, Pricing & Promotions \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nViewing Orders \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\nUpdating Account Information \r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi luctus. Duis lobortis. Nulla nec velit. Mauris pulvinar erat non massa. Suspendisse tortor turpis, porta nec, tempus vitae, iaculis semper, pede. Cras vel libero id lectus rhoncus porta. Suspendisse convallis felis ac enim. Vivamus tortor nisl, lobortis in, faucibus et, tempus at, dui. Nunc risus. Proin scelerisque augue. Nam ullamcorper. Phasellus id massa. Pellentesque nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc augue. Aenean sed justo non leo vehicula laoreet. Praesent ipsum libero, auctor ac, tempus nec, tempor nec, justo. \r\n ','2007-08-30 14:02:20','2007-08-30 14:03:37',1,0,0);
");
diff --git a/app/code/core/Mage/Cms/sql/cms_setup/mysql4-upgrade-0.7.7-0.7.8.php b/app/code/core/Mage/Cms/sql/cms_setup/mysql4-upgrade-0.7.7-0.7.8.php
index 89467854ee..48e4b3e15f 100644
--- a/app/code/core/Mage/Cms/sql/cms_setup/mysql4-upgrade-0.7.7-0.7.8.php
+++ b/app/code/core/Mage/Cms/sql/cms_setup/mysql4-upgrade-0.7.7-0.7.8.php
@@ -35,7 +35,7 @@
'title' => 'Enable Cookies',
'root_template' => 'one_column',
'identifier' => 'enable-cookies',
- 'content' => "\r\n
\r\n \r\n \r\n Please enable cookies in your web browser to continue. \r\n \r\n \r\n \r\n
\r\n
What are Cookies?\r\n
\r\n
Cookies are short pieces of data that are sent to your computer when you visit a website. On later visits, this data is then returned to that website. Cookies allow us to recognize you automatically whenever you visit our site so that we can personalize your experience and provide you with better service. We also use cookies (and similar browser data, such as Flash cookies) for fraud prevention and other purposes. If your web browser is set to refuse cookies from our website, you will not be able to complete a purchase or take advantage of certain features of our website, such as storing items in your Shopping Cart or receiving personalized recommendations. As a result, we strongly encourage you to configure your web browser to accept cookies from our website.
\r\n
Enabling Cookies \r\n
\r\n
Internet Explorer 7.x\r\n
\r\n \r\n Start Internet Explorer
\r\n \r\n \r\n Under the Tools menu, click Internet Options
\r\n
\r\n \r\n \r\n Click the Privacy tab
\r\n
\r\n \r\n \r\n Click the Advanced button
\r\n
\r\n \r\n \r\n Put a check mark in the box for Override Automatic Cookie Handling , put another check mark in the Always accept session cookies box
\r\n
\r\n \r\n \r\n Click OK
\r\n
\r\n \r\n \r\n Click OK
\r\n
\r\n \r\n \r\n Restart Internet Explore
\r\n \r\n \r\n
Back to Top
\r\n
Internet Explorer 6.x\r\n
\r\n \r\n Select Internet Options from the Tools menu
\r\n
\r\n \r\n \r\n Click on the Privacy tab
\r\n \r\n \r\n Click the Default button (or manually slide the bar down to Medium ) under Settings . Click OK
\r\n
\r\n \r\n \r\n
Back to Top
\r\n
Mozilla/Firefox\r\n
\r\n \r\n Click on the Tools -menu in Mozilla
\r\n \r\n \r\n Click on the Options... item in the menu - a new window open
\r\n \r\n \r\n Click on the Privacy selection in the left part of the window. (See image below)
\r\n
\r\n \r\n \r\n Expand the Cookies section
\r\n \r\n \r\n Check the Enable cookies and Accept cookies normally checkboxes
\r\n \r\n \r\n Save changes by clicking Ok .
\r\n \r\n \r\n
Back to Top
\r\n
Opera 7.x\r\n
\r\n \r\n Click on the Tools menu in Opera
\r\n \r\n \r\n Click on the Preferences... item in the menu - a new window open
\r\n \r\n \r\n Click on the Privacy selection near the bottom left of the window. (See image below)
\r\n
\r\n \r\n \r\n The Enable cookies checkbox must be checked, and Accept all cookies should be selected in the "Normal cookies " drop-down
\r\n \r\n \r\n Save changes by clicking Ok
\r\n \r\n \r\n
Back to Top
\r\n
\r\n",
+ 'content' => "\r\n
\r\n \r\n \r\n Please enable cookies in your web browser to continue. \r\n \r\n \r\n \r\n
\r\n
What are Cookies?\r\n
\r\n
Cookies are short pieces of data that are sent to your computer when you visit a website. On later visits, this data is then returned to that website. Cookies allow us to recognize you automatically whenever you visit our site so that we can personalize your experience and provide you with better service. We also use cookies (and similar browser data, such as Flash cookies) for fraud prevention and other purposes. If your web browser is set to refuse cookies from our website, you will not be able to complete a purchase or take advantage of certain features of our website, such as storing items in your Shopping Cart or receiving personalized recommendations. As a result, we strongly encourage you to configure your web browser to accept cookies from our website.
\r\n
Enabling Cookies \r\n
\r\n
Internet Explorer 7.x\r\n
\r\n \r\n Start Internet Explorer
\r\n \r\n \r\n Under the Tools menu, click Internet Options
\r\n
\r\n \r\n \r\n Click the Privacy tab
\r\n
\r\n \r\n \r\n Click the Advanced button
\r\n
\r\n \r\n \r\n Put a check mark in the box for Override Automatic Cookie Handling , put another check mark in the Always accept session cookies box
\r\n
\r\n \r\n \r\n Click OK
\r\n
\r\n \r\n \r\n Click OK
\r\n
\r\n \r\n \r\n Restart Internet Explore
\r\n \r\n \r\n
Back to Top
\r\n
Internet Explorer 6.x\r\n
\r\n \r\n Select Internet Options from the Tools menu
\r\n
\r\n \r\n \r\n Click on the Privacy tab
\r\n \r\n \r\n Click the Default button (or manually slide the bar down to Medium ) under Settings . Click OK
\r\n
\r\n \r\n \r\n
Back to Top
\r\n
Mozilla/Firefox\r\n
\r\n \r\n Click on the Tools -menu in Mozilla
\r\n \r\n \r\n Click on the Options... item in the menu - a new window open
\r\n \r\n \r\n Click on the Privacy selection in the left part of the window. (See image below)
\r\n
\r\n \r\n \r\n Expand the Cookies section
\r\n \r\n \r\n Check the Enable cookies and Accept cookies normally checkboxes
\r\n \r\n \r\n Save changes by clicking Ok .
\r\n \r\n \r\n
Back to Top
\r\n
Opera 7.x\r\n
\r\n \r\n Click on the Tools menu in Opera
\r\n \r\n \r\n Click on the Preferences... item in the menu - a new window open
\r\n \r\n \r\n Click on the Privacy selection near the bottom left of the window. (See image below)
\r\n
\r\n \r\n \r\n The Enable cookies checkbox must be checked, and Accept all cookies should be selected in the "Normal cookies " drop-down
\r\n \r\n \r\n Save changes by clicking Ok
\r\n \r\n \r\n
Back to Top
\r\n
\r\n",
'creation_time' => now(),
'update_time' => now(),
));
diff --git a/app/code/core/Mage/Compiler/controllers/ProcessController.php b/app/code/core/Mage/Compiler/controllers/ProcessController.php
index aa7fc6c6e2..cecf4d6ee6 100644
--- a/app/code/core/Mage/Compiler/controllers/ProcessController.php
+++ b/app/code/core/Mage/Compiler/controllers/ProcessController.php
@@ -54,6 +54,8 @@ protected function _getCompiler()
}
public function indexAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Tools'))->_title($this->__('Compilation'));
+
$this->loadLayout();
$this->_setActiveMenu('system/tools');
$this->renderLayout();
diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php
index 1fd9170edb..c7f711c6cb 100644
--- a/app/code/core/Mage/Core/Block/Abstract.php
+++ b/app/code/core/Mage/Core/Block/Abstract.php
@@ -955,14 +955,23 @@ protected function _saveCache($data)
return $this;
}
+ /**
+ * @deprecated after 1.4.0.0-rc1
+ * @see self::escapeHtml()
+ */
+ public function htmlEscape($data, $allowedTags = null)
+ {
+ return $this->escapeHtml($data, $allowedTags);
+ }
+
/**
* Escape html entities
*
* @param mixed $data
* @param array $allowedTags
- * @return mixed
+ * @return string
*/
- public function htmlEscape($data, $allowedTags = null)
+ public function escapeHtml($data, $allowedTags = null)
{
return $this->helper('core')->htmlEscape($data, $allowedTags);
}
diff --git a/app/code/core/Mage/Core/Block/Html/Select.php b/app/code/core/Mage/Core/Block/Html/Select.php
index 9a31ae95a5..430695b85c 100644
--- a/app/code/core/Mage/Core/Block/Html/Select.php
+++ b/app/code/core/Mage/Core/Block/Html/Select.php
@@ -148,7 +148,7 @@ protected function _toHtml()
protected function _optionToHtml($option, $selected=false)
{
$selectedHtml = $selected ? ' selected="selected"' : '';
- $html = ''.$option['label'].' ';
+ $html = ''.$this->htmlEscape($option['label']).' ';
return $html;
}
diff --git a/app/code/core/Mage/Core/Block/Template.php b/app/code/core/Mage/Core/Block/Template.php
index 79e4ec5574..bc7e32a7ed 100644
--- a/app/code/core/Mage/Core/Block/Template.php
+++ b/app/code/core/Mage/Core/Block/Template.php
@@ -185,7 +185,12 @@ public function fetchView($fileName)
}
}
- include $this->_viewDir.DS.$fileName;
+ try {
+ include $this->_viewDir . DS . $fileName;
+ } catch (Exception $e) {
+ ob_get_clean();
+ throw $e;
+ }
if ($this->getShowTemplateHints()) {
echo '';
diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php
index 29eb53e7ec..ce3719482b 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Action.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Action.php
@@ -893,4 +893,60 @@ protected function _renderTitles()
}
}
}
+
+ /**
+ * Convert dates in array from localized to internal format
+ *
+ * @param array $array
+ * @param array $dateFields
+ * @return array
+ */
+ protected function _filterDates($array, $dateFields)
+ {
+ if (empty($dateFields)) {
+ return $array;
+ }
+ $filterInput = new Zend_Filter_LocalizedToNormalized(array(
+ 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
+ ));
+ $filterInternal = new Zend_Filter_NormalizedToLocalized(array(
+ 'date_format' => Varien_Date::DATE_INTERNAL_FORMAT
+ ));
+
+ foreach ($dateFields as $dateField) {
+ if (array_key_exists($dateField, $array) && !empty($dateField)) {
+ $array[$dateField] = $filterInput->filter($array[$dateField]);
+ $array[$dateField] = $filterInternal->filter($array[$dateField]);
+ }
+ }
+ return $array;
+ }
+
+ /**
+ * Convert dates with time in array from localized to internal format
+ *
+ * @param array $array
+ * @param array $dateFields
+ * @return array
+ */
+ protected function _filterDateTime($array, $dateFields)
+ {
+ if (empty($dateFields)) {
+ return $array;
+ }
+ $filterInput = new Zend_Filter_LocalizedToNormalized(array(
+ 'date_format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
+ ));
+ $filterInternal = new Zend_Filter_NormalizedToLocalized(array(
+ 'date_format' => Varien_Date::DATETIME_INTERNAL_FORMAT
+ ));
+
+ foreach ($dateFields as $dateField) {
+ if (array_key_exists($dateField, $array) && !empty($dateField)) {
+ $array[$dateField] = $filterInput->filter($array[$dateField]);
+ $array[$dateField] = $filterInternal->filter($array[$dateField]);
+ }
+ }
+ return $array;
+ }
}
diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php
index 279b758c61..f1fbd86b0d 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Front.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Front.php
@@ -156,6 +156,10 @@ public function init()
public function dispatch()
{
$request = $this->getRequest();
+
+ // If pre-configured, check equality of base URL and requested URL
+ $this->_checkBaseUrl($request);
+
$request->setPathInfo()->setDispatched(false);
Varien_Profiler::start('mage::dispatch::db_url_rewrite');
@@ -280,4 +284,39 @@ protected function _processRewriteUrl($url)
}
return $url;
}
+
+ /**
+ * Auto-redirect to base url (without SID) if the requested url doesn't match it.
+ * By default this feature is enabled in configuration.
+ *
+ * @param Zend_Controller_Request_Http $request
+ */
+ protected function _checkBaseUrl($request)
+ {
+ if (!Mage::isInstalled() || $request->getPost()) {
+ return;
+ }
+ if (!Mage::getStoreConfigFlag('web/url/redirect_to_base')) {
+ return;
+ }
+
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, Mage::app()->getStore()->isCurrentlySecure());
+
+ if (!$baseUrl) {
+ return;
+ }
+
+ $uri = @parse_url($baseUrl);
+ $host = isset($uri['host']) ? $uri['host'] : '';
+ $path = isset($uri['path']) ? $uri['path'] : '';
+
+ $requestUri = $request->getRequestUri() ? $request->getRequestUri() : '/';
+ if ($host && $host != $request->getHttpHost() || $path && strpos($requestUri, $path) === false)
+ {
+ Mage::app()->getFrontController()->getResponse()
+ ->setRedirect($baseUrl)
+ ->sendResponse();
+ exit;
+ }
+ }
}
diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
index 166636f077..203f8a5f2a 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
@@ -71,11 +71,10 @@ public function collectRoutes($configArea, $useRouterName)
public function fetchDefault()
{
- $d = explode('/', Mage::getStoreConfig('web/default/front'));
$this->getFront()->setDefault(array(
- 'module' => !empty($d[0]) ? $d[0] : 'core',
- 'controller' => !empty($d[1]) ? $d[1] : 'index',
- 'action' => !empty($d[2]) ? $d[2] : 'index'
+ 'module' => 'core',
+ 'controller' => 'index',
+ 'action' => 'index'
));
}
@@ -102,6 +101,7 @@ protected function _afterModuleMatch()
return true;
}
+
public function match(Zend_Controller_Request_Http $request)
{
//checking before even try to find out that current module
@@ -113,14 +113,20 @@ public function match(Zend_Controller_Request_Http $request)
$this->fetchDefault();
$front = $this->getFront();
+ $path = trim($request->getPathInfo(), '/');
- $p = explode('/', trim($request->getPathInfo(), '/'));
+ if ($path) {
+ $p = explode('/', $path);
+ }
+ else {
+ $p = explode('/', Mage::getStoreConfig('web/default/front'));
+ }
// get module name
if ($request->getModuleName()) {
$module = $request->getModuleName();
} else {
- if(!empty($p[0])) {
+ if (!empty($p[0])) {
$module = $p[0];
} else {
$module = $this->getFront()->getDefault('module');
@@ -279,7 +285,7 @@ protected function _validateControllerClassName($realModule, $controller)
}
// include controller file if needed
- if (!$this->_inludeControllerClass($controllerFileName, $controllerClassName)) {
+ if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) {
return false;
}
@@ -288,13 +294,22 @@ protected function _validateControllerClassName($realModule, $controller)
/**
- * Including controller class if checking of existense class before include
+ * @deprecated
+ * @see _includeControllerClass()
+ */
+ protected function _inludeControllerClass($controllerFileName, $controllerClassName)
+ {
+ return $this->_includeControllerClass($controllerFileName, $controllerClassName);
+ }
+
+ /**
+ * Include the file containing controller class if this class is not defined yet
*
* @param string $controllerFileName
* @param string $controllerClassName
* @return bool
*/
- protected function _inludeControllerClass($controllerFileName, $controllerClassName)
+ protected function _includeControllerClass($controllerFileName, $controllerClassName)
{
if (!class_exists($controllerClassName, false)) {
if (!file_exists($controllerFileName)) {
diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php
index 91fed4eb77..e758fcafb6 100644
--- a/app/code/core/Mage/Core/Model/Config.php
+++ b/app/code/core/Mage/Core/Model/Config.php
@@ -338,7 +338,7 @@ public function isLocalConfigLoaded()
*/
public function loadDb()
{
- if ($this->_isLocalConfigLoaded) {
+ if ($this->_isLocalConfigLoaded && Mage::isInstalled()) {
Varien_Profiler::start('config/load-db');
$dbConf = $this->getResourceModel();
$dbConf->loadToXml($this);
diff --git a/app/code/core/Mage/Core/Model/Cookie.php b/app/code/core/Mage/Core/Model/Cookie.php
index 6aea3f4f25..aaffc82a9f 100644
--- a/app/code/core/Mage/Core/Model/Cookie.php
+++ b/app/code/core/Mage/Core/Model/Cookie.php
@@ -239,6 +239,28 @@ public function set($name, $value, $period = null, $path = null, $domain = null,
return $this;
}
+ /**
+ * Postpone cookie expiration time if cookie value defined
+ *
+ * @param string $name The cookie name
+ * @param int $period Lifetime period
+ * @param string $path
+ * @param string $domain
+ * @param int|bool $secure
+ * @return Mage_Core_Model_Cookie
+ */
+ public function renew($name, $period = null, $path = null, $domain = null, $secure = null, $httponly = null)
+ {
+ if (($period === null) && !$this->getLifetime()) {
+ return $this;
+ }
+ $value = $this->_getRequest()->getCookie($name, false);
+ if ($value !== false) {
+ $this->set($name, $value, $period, $path, $domain, $secure, $httponly);
+ }
+ return $this;
+ }
+
/**
* Retrieve cookie or false if not exists
*
diff --git a/app/code/core/Mage/Core/Model/Design/Package.php b/app/code/core/Mage/Core/Model/Design/Package.php
index eed89be349..db8f653778 100644
--- a/app/code/core/Mage/Core/Model/Design/Package.php
+++ b/app/code/core/Mage/Core/Model/Design/Package.php
@@ -302,6 +302,7 @@ public function getBaseDir(array $params)
public function getSkinBaseDir(array $params=array())
{
+ $params['_type'] = 'skin';
$this->updateParamDefaults($params);
$baseDir = (empty($params['_relative']) ? Mage::getBaseDir('skin').DS : '').
$params['_area'].DS.$params['_package'].DS.$params['_theme'];
@@ -310,6 +311,7 @@ public function getSkinBaseDir(array $params=array())
public function getLocaleBaseDir(array $params=array())
{
+ $params['_type'] = 'locale';
$this->updateParamDefaults($params);
$baseDir = (empty($params['_relative']) ? Mage::getBaseDir('design').DS : '').
$params['_area'].DS.$params['_package'].DS.$params['_theme'] . DS . 'locale' . DS .
@@ -319,6 +321,7 @@ public function getLocaleBaseDir(array $params=array())
public function getSkinBaseUrl(array $params=array())
{
+ $params['_type'] = 'skin';
$this->updateParamDefaults($params);
$baseUrl = Mage::getBaseUrl('skin', isset($params['_secure'])?(bool)$params['_secure']:null)
.$params['_area'].'/'.$params['_package'].'/'.$params['_theme'].'/';
diff --git a/app/code/core/Mage/Core/Model/Email/Template.php b/app/code/core/Mage/Core/Model/Email/Template.php
index 318e4d89d6..d99eaaeea1 100644
--- a/app/code/core/Mage/Core/Model/Email/Template.php
+++ b/app/code/core/Mage/Core/Model/Email/Template.php
@@ -638,10 +638,10 @@ protected function _beforeSave()
{
$code = $this->getTemplateCode();
if (empty($code)) {
- Mage::throwException(Mage::helper('core')->__('Template Code must be not empty'));
+ Mage::throwException(Mage::helper('core')->__('Template Name must be not empty'));
}
if($this->_getResource()->checkCodeUsage($this)) {
- Mage::throwException(Mage::helper('core')->__('Duplicate Of Template Code'));
+ Mage::throwException(Mage::helper('core')->__('Duplicate Of Template Name'));
}
return parent::_beforeSave();
}
diff --git a/app/code/core/Mage/Core/Model/Flag.php b/app/code/core/Mage/Core/Model/Flag.php
index 6626a343aa..9824aad600 100644
--- a/app/code/core/Mage/Core/Model/Flag.php
+++ b/app/code/core/Mage/Core/Model/Flag.php
@@ -43,10 +43,14 @@ class Mage_Core_Model_Flag extends Mage_Core_Model_Abstract
/**
* Init resource model
+ * Set flag_code if it is specified in arguments
*
*/
protected function _construct()
{
+ if ($this->hasData('flag_code')) {
+ $this->_flagCode = $this->getData('flag_code');
+ }
$this->_init('core/flag');
}
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php b/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php
index 2db160f3e7..52fe6d4356 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php
@@ -65,10 +65,7 @@ protected function _construct()
/**
* Load by template code from DB.
*
- * If $useSystem eq true, loading of system template
- *
- * @param int $templateId
- * @param boolean $useSystem
+ * @param string $templateCode
* @return array
*/
public function loadByCode($templateCode)
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Session.php b/app/code/core/Mage/Core/Model/Mysql4/Session.php
index 8adeaa7bf1..403759872b 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Session.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Session.php
@@ -69,7 +69,7 @@ class Mage_Core_Model_Mysql4_Session implements Zend_Session_SaveHandler_Interfa
* cleaning once in x calls
*/
protected $_automaticCleaningFactor = 50;
-
+
public function __construct()
{
$this->_sessionTable = Mage::getSingleton('core/resource')->getTableName('core/session');
@@ -85,8 +85,14 @@ public function __destruct()
public function getLifeTime()
{
if (is_null($this->_lifeTime)) {
- $this->_lifeTime = ini_get('session.gc_maxlifetime');
- if (!$this->_lifeTime) {
+ $configNode = Mage::app()->getStore()->isAdmin() ? 'admin/security/session_cookie_lifetime' : 'web/cookie/cookie_lifetime';
+ $this->_lifeTime = (int) Mage::getStoreConfig($configNode);
+
+ if ($this->_lifeTime < 60) {
+ $this->_lifeTime = ini_get('session.gc_maxlifetime');
+ }
+
+ if ($this->_lifeTime < 60) {
$this->_lifeTime = 3600;
}
}
diff --git a/app/code/core/Mage/Core/Model/Resource/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Abstract.php
index a1011e4d4f..44110593c6 100644
--- a/app/code/core/Mage/Core/Model/Resource/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Resource/Abstract.php
@@ -98,8 +98,9 @@ public function commit()
if ($this->_getWriteAdapter()->getTransactionLevel() === 0) {
$adapterKey = spl_object_hash($this->_getWriteAdapter());
if (isset(self::$_commitCallbacks[$adapterKey])) {
- foreach (self::$_commitCallbacks[$adapterKey] as $index => $callback) {
- unset(self::$_commitCallbacks[$adapterKey][$index]);
+ $callbacks = self::$_commitCallbacks[$adapterKey];
+ self::$_commitCallbacks[$adapterKey] = array();
+ foreach ($callbacks as $index => $callback) {
call_user_func($callback);
}
}
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 72bbcfadbc..072eb7dbea 100644
--- a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
+++ b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
@@ -66,21 +66,21 @@ public function start($sessionName=null)
}
break;
}
-
+ $cookie = $this->getCookie();
if (Mage::app()->getStore()->isAdmin()) {
$adminSessionLifetime = (int)Mage::getStoreConfig('admin/security/session_cookie_lifetime');
if ($adminSessionLifetime > 60) {
- $this->getCookie()->setLifetime($adminSessionLifetime);
+ $cookie->setLifetime($adminSessionLifetime);
}
}
// session cookie params
$cookieParams = array(
- 'lifetime' => $this->getCookie()->getLifetime(),
- 'path' => $this->getCookie()->getPath(),
- 'domain' => $this->getCookie()->getConfigDomain(),
- 'secure' => $this->getCookie()->isSecure(),
- 'httponly' => $this->getCookie()->getHttponly()
+ 'lifetime' => $cookie->getLifetime(),
+ 'path' => $cookie->getPath(),
+ 'domain' => $cookie->getConfigDomain(),
+ 'secure' => $cookie->isSecure(),
+ 'httponly' => $cookie->getHttponly()
);
if (!$cookieParams['httponly']) {
@@ -94,7 +94,7 @@ public function start($sessionName=null)
}
if (isset($cookieParams['domain'])) {
- $cookieParams['domain'] = $this->getCookie()->getDomain();
+ $cookieParams['domain'] = $cookie->getDomain();
}
call_user_func_array('session_set_cookie_params', $cookieParams);
@@ -107,13 +107,16 @@ public function start($sessionName=null)
$this->setSessionId();
Varien_Profiler::start(__METHOD__.'/start');
-
- if ($sessionCacheLimiter = Mage::getConfig()->getNode('global/session_cache_limiter')) {
+ $sessionCacheLimiter = Mage::getConfig()->getNode('global/session_cache_limiter');
+ if ($sessionCacheLimiter) {
session_cache_limiter((string)$sessionCacheLimiter);
}
session_start();
-
+ /**
+ * Renew cookie expiration time
+ */
+ $cookie->renew(session_name());
Varien_Profiler::stop(__METHOD__.'/start');
return $this;
@@ -131,29 +134,11 @@ public function getCookie()
/**
* Revalidate cookie
- *
+ * @deprecated after 1.4 cookie renew moved to session start method
* @return Mage_Core_Model_Session_Abstract_Varien
*/
public function revalidateCookie()
{
- if (!$this->getCookie()->getLifetime()) {
- return $this;
- }
- if (empty($_SESSION['_cookie_revalidate'])) {
- $time = time() + round($this->getCookie()->getLifetime() / 4);
- $_SESSION['_cookie_revalidate'] = $time;
- }
- else {
- if ($_SESSION['_cookie_revalidate'] < time()) {
- if (!headers_sent()) {
- $this->getCookie()->set(session_name(), session_id());
-
- $time = time() + round($this->getCookie()->getLifetime() / 4);
- $_SESSION['_cookie_revalidate'] = $time;
- }
- }
- }
-
return $this;
}
diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php
index 78bbef7deb..61c4d10540 100644
--- a/app/code/core/Mage/Core/Model/Url.php
+++ b/app/code/core/Mage/Core/Model/Url.php
@@ -683,12 +683,20 @@ public function setQuery($data)
return $this->setData('query', $data);
}
+ /**
+ * Get query params part of url
+ *
+ * @param bool $escape "&" escape flag
+ * @return string
+ */
public function getQuery($escape = false)
{
if (!$this->hasData('query')) {
$query = '';
- if (is_array($this->getQueryParams())) {
- $query = http_build_query($this->getQueryParams(), '', $escape ? '&' : '&');
+ $params = $this->getQueryParams();
+ if (is_array($params)) {
+ ksort($params);
+ $query = http_build_query($params, '', $escape ? '&' : '&');
}
$this->setData('query', $query);
}
diff --git a/app/code/core/Mage/Core/Model/Variable.php b/app/code/core/Mage/Core/Model/Variable.php
index d7cb42486b..4031d5412c 100644
--- a/app/code/core/Mage/Core/Model/Variable.php
+++ b/app/code/core/Mage/Core/Model/Variable.php
@@ -110,14 +110,14 @@ public function getValue($type = null)
*/
public function validate()
{
- if ($this->getCode() && $this->getName() && ($this->getHtmlValue() || $this->getUseDefaultValue())) {
+ if ($this->getCode() && $this->getName()) {
$variable = $this->getResource()->getVariableByCode($this->getCode());
if (!empty($variable) && $variable['variable_id'] != $this->getId()) {
return Mage::helper('core')->__('Variable Code must be unique.');
}
return true;
}
- return Mage::helper('core')->__('Vaidation failed.');
+ return Mage::helper('core')->__('Validation failed.');
}
/**
diff --git a/app/code/core/Mage/Core/etc/config.xml b/app/code/core/Mage/Core/etc/config.xml
index 0795ca4c29..a4541e7e07 100644
--- a/app/code/core/Mage/Core/etc/config.xml
+++ b/app/code/core/Mage/Core/etc/config.xml
@@ -28,7 +28,7 @@
- 0.8.24
+ 0.8.25
@@ -252,6 +252,7 @@
0
+ 1
0
diff --git a/app/code/core/Mage/Core/etc/system.xml b/app/code/core/Mage/Core/etc/system.xml
index 4c35820e9f..63a8cc9fa4 100644
--- a/app/code/core/Mage/Core/etc/system.xml
+++ b/app/code/core/Mage/Core/etc/system.xml
@@ -697,6 +697,7 @@
1
1
1
+ 1
@@ -984,6 +985,15 @@
0
0
+
+ Redirect to Base URL if requested URL doesn't match it
+ select
+ adminhtml/system_config_source_yesno
+ 20
+ 1
+ 0
+ 0
+
diff --git a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.2-0.1.3.php b/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.8.24-0.8.25.php
similarity index 83%
rename from app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.2-0.1.3.php
rename to app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.8.24-0.8.25.php
index a7d91088a9..d2a3d2cc69 100644
--- a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.2-0.1.3.php
+++ b/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.8.24-0.8.25.php
@@ -19,15 +19,18 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Paybox
+ * @package Mage_Core
* @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)
*/
+
+/** @var Mage_Core_Model_Resource_Setup */
$installer = $this;
-/* @var $installer Mage_Sales_Model_Entity_Setup */
$installer->startSetup();
-$installer->addAttribute('order_payment', 'paybox_question_number', array());
+$installer->getConnection()->modifyColumn(
+ $this->getTable('core_flag'), 'flag_id', 'INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT'
+);
$installer->endSetup();
diff --git a/app/code/core/Mage/Cron/Model/Observer.php b/app/code/core/Mage/Cron/Model/Observer.php
index 4460a44b0a..f3471dde77 100644
--- a/app/code/core/Mage/Cron/Model/Observer.php
+++ b/app/code/core/Mage/Cron/Model/Observer.php
@@ -36,7 +36,7 @@ class Mage_Cron_Model_Observer
const CACHE_KEY_LAST_SCHEDULE_GENERATE_AT = 'cron_last_schedule_generate_at';
const CACHE_KEY_LAST_HISTORY_CLEANUP_AT = 'cron_last_history_cleanup_at';
- const XML_PATH_SCHEDULE_GENERATE_EVERY = 'system/cron/schedule_generate_freq';
+ const XML_PATH_SCHEDULE_GENERATE_EVERY = 'system/cron/schedule_generate_every';
const XML_PATH_SCHEDULE_AHEAD_FOR = 'system/cron/schedule_ahead_for';
const XML_PATH_SCHEDULE_LIFETIME = 'system/cron/schedule_lifetime';
const XML_PATH_HISTORY_CLEANUP_EVERY = 'system/cron/history_cleanup_every';
diff --git a/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php b/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php
index cd1b0c98ff..313dceb42f 100644
--- a/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php
+++ b/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php
@@ -31,7 +31,7 @@ class Mage_Customer_Model_Convert_Adapter_Customer
const MULTI_DELIMITER = ' , ';
/**
- * Product model
+ * Customer model
*
* @var Mage_Customer_Model_Customer
*/
@@ -369,7 +369,7 @@ public function save()
if ($collections instanceof Mage_Customer_Model_Entity_Customer_Collection) {
$collections = array($collections->getEntity()->getStoreId()=>$collections);
} elseif (!is_array($collections)) {
- $this->addException(Mage::helper('customer')->__('No product collections found'), Mage_Dataflow_Model_Convert_Exception::FATAL);
+ $this->addException(Mage::helper('customer')->__('No customer collections found'), Mage_Dataflow_Model_Convert_Exception::FATAL);
}
foreach ($collections as $storeId=>$collection) {
@@ -382,7 +382,7 @@ public function save()
$i = 0;
foreach ($collection->getIterator() as $model) {
$new = false;
- // if product is new, create default values first
+ // if customer is new, create default values first
if (!$model->getId()) {
$new = true;
$model->save();
@@ -419,7 +419,6 @@ public function saveRow($importData)
{
$customer = $this->getCustomerModel();
$customer->setId(null);
- $customer->setImportMode(true);
if (empty($importData['website'])) {
$message = Mage::helper('customer')->__('Skip import row, required field "%s" not defined', 'website');
@@ -688,6 +687,7 @@ public function saveRow($importData)
}
}
+ $customer->setImportMode(true);
$customer->save();
$saveCustomer = false;
diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php
index 04072b1923..57e03f09ef 100644
--- a/app/code/core/Mage/Customer/Model/Customer.php
+++ b/app/code/core/Mage/Customer/Model/Customer.php
@@ -50,10 +50,24 @@ class Mage_Customer_Model_Customer extends Mage_Core_Model_Abstract
protected $_eventPrefix = 'customer';
protected $_eventObject = 'customer';
- protected $_addresses = null;
protected $_errors = array();
protected $_attributes;
+ /**
+ * Customer addresses array
+ *
+ * @var array
+ * @deprecated after 1.4.0.0-rc1
+ */
+ protected $_addresses = null;
+
+ /**
+ * Customer addresses collection
+ *
+ * @var Mage_Customer_Model_Entity_Address_Collection
+ */
+ protected $_addressesCollection;
+
/**
* Is model deleteable
*
@@ -187,6 +201,7 @@ public function getName()
*/
public function addAddress(Mage_Customer_Model_Address $address)
{
+ $this->getAddressesCollection()->addItem($address);
$this->getAddresses();
$this->_addresses[] = $address;
return $this;
@@ -204,10 +219,21 @@ public function getAddressById($addressId)
->load($addressId);
}
+ /**
+ * Getting customer address object from collection by identifier
+ *
+ * @param int $addressId
+ * @return Mage_Customer_Model_Address
+ */
+ public function getAddressItemById($addressId)
+ {
+ return $this->getAddressesCollection()->getItemById($addressId);
+ }
+
/**
* Retrieve not loaded address collection
*
- * @return Mage_Customer_Model_Address_Collection
+ * @return Mage_Customer_Model_Entity_Address_Collection
*/
public function getAddressCollection()
{
@@ -215,23 +241,30 @@ public function getAddressCollection()
}
/**
- * Retrieve customer address array
+ * Customer addresses collection
*
- * @return array
+ * @return Mage_Customer_Model_Entity_Address_Collection
*/
- public function getAddresses()
+ public function getAddressesCollection()
{
- if (is_null($this->_addresses)) {
- $this->_addresses = array();
- $collection = $this->getAddressCollection()
+ if (is_null($this->_addressesCollection)) {
+ $this->_addressesCollection = $this->getAddressCollection()
->setCustomerFilter($this)
->addAttributeToSelect('*')
->load();
- foreach ($collection as $address) {
- $this->_addresses[] = $address;
- }
}
+ return $this->_addressesCollection;
+ }
+
+ /**
+ * Retrieve customer address array
+ *
+ * @return array
+ */
+ public function getAddresses()
+ {
+ $this->_addresses = $this->getAddressesCollection()->getItems();
return $this->_addresses;
}
@@ -345,16 +378,9 @@ public function decryptPassword($password)
*/
public function getPrimaryAddress($attributeCode)
{
- $addressId = $this->getData($attributeCode);
- $primaryAddress = false;
- if ($addressId) {
- foreach ($this->getAddresses() as $address) {
- if ($addressId == $address->getId()) {
- return $address;
- }
- }
- }
- return $primaryAddress;
+ $primaryAddress = $this->getAddressesCollection()->getItemById($this->getData($attributeCode));
+
+ return $primaryAddress ? $primaryAddress : false;
}
/**
@@ -450,7 +476,7 @@ public function getAdditionalAddresses()
{
$addresses = array();
$primatyIds = $this->getPrimaryAddressIds();
- foreach ($this->getAddresses() as $address) {
+ foreach ($this->getAddressesCollection() as $address) {
if (!in_array($address->getId(), $primatyIds)) {
$addresses[] = $address;
}
@@ -914,7 +940,8 @@ function unsetSubscription()
}
function cleanAllAddresses() {
- $this->_addresses = null;
+ $this->_addressesCollection = null;
+ $this->_addresses = null;
}
function addError($error)
diff --git a/app/code/core/Mage/Customer/Model/Entity/Address/Attribute/Backend/Region.php b/app/code/core/Mage/Customer/Model/Entity/Address/Attribute/Backend/Region.php
index f582c5ca30..aa777d5574 100644
--- a/app/code/core/Mage/Customer/Model/Entity/Address/Attribute/Backend/Region.php
+++ b/app/code/core/Mage/Customer/Model/Entity/Address/Attribute/Backend/Region.php
@@ -36,16 +36,11 @@ class Mage_Customer_Model_Entity_Address_Attribute_Backend_Region extends Mage_E
public function beforeSave($object)
{
$region = $object->getData('region');
- if ($regionId = (int) $region) {
- $regionModel = Mage::getModel('directory/region')->load($regionId);
- if ($regionModel->getId()) {
- if ($object->getCountryId()==$regionModel->getCountryId()) {
- $object->setRegionId($regionModel->getId())
- ->setRegion($regionModel->getName());
- }
- else {
- Mage::throwException(Mage::helper('customer')->__('Wrong region id by selected country'));
- }
+ if (is_numeric($region)) {
+ $regionModel = Mage::getModel('directory/region')->load($region);
+ if ($regionModel->getId() && $object->getCountryId() == $regionModel->getCountryId()) {
+ $object->setRegionId($regionModel->getId())
+ ->setRegion($regionModel->getName());
}
}
return $this;
diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php
index 6a7c36d6b9..7bb5c09d5a 100644
--- a/app/code/core/Mage/Customer/controllers/AccountController.php
+++ b/app/code/core/Mage/Customer/controllers/AccountController.php
@@ -184,13 +184,23 @@ protected function _loginPostRedirect()
}
}
}
+ else if ($session->getAfterAuthUrl()) {
+ $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
+ }
} else {
$session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
}
} else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
$session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
}
-
+ else {
+ if (!$session->getAfterAuthUrl()) {
+ $session->setAfterAuthUrl($session->getBeforeAuthUrl());
+ }
+ if ($session->isLoggedIn()) {
+ $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
+ }
+ }
$this->_redirectUrl($session->getBeforeAuthUrl(true));
}
@@ -247,12 +257,14 @@ public function createPostAction()
$customer = Mage::getModel('customer/customer')->setId(null);
}
+ $data = $this->_filterPostData($this->getRequest()->getPost());
+
foreach (Mage::getConfig()->getFieldset('customer_account') as $code=>$node) {
- if ($node->is('create') && ($value = $this->getRequest()->getParam($code)) !== null) {
+ if ($node->is('create') && isset($data[$code])) {
if ($code == 'email') {
- $value = trim($value);
+ $data[$code] = trim($data[$code]);
}
- $customer->setData($code, $value);
+ $customer->setData($code, $data[$code]);
}
}
@@ -564,9 +576,11 @@ public function editPostAction()
->setWebsiteId($this->_getSession()->getCustomer()->getWebsiteId());
$fields = Mage::getConfig()->getFieldset('customer_account');
+ $data = $this->_filterPostData($this->getRequest()->getPost());
+
foreach ($fields as $code=>$node) {
- if ($node->is('update') && ($value = $this->getRequest()->getParam($code)) !== null) {
- $customer->setData($code, $value);
+ if ($node->is('update') && isset($data[$code])) {
+ $customer->setData($code, $data[$code]);
}
}
@@ -618,7 +632,6 @@ public function editPostAction()
return $this;
}
-
try {
$customer->save();
$this->_getSession()->setCustomer($customer)
@@ -639,4 +652,16 @@ public function editPostAction()
$this->_redirect('*/*/edit');
}
+
+ /**
+ * Filtering posted data. Converting localized data if needed
+ *
+ * @param array
+ * @return array
+ */
+ protected function _filterPostData($data)
+ {
+ $data = $this->_filterDates($data, array('dob'));
+ return $data;
+ }
}
diff --git a/app/code/core/Mage/Customer/etc/config.xml b/app/code/core/Mage/Customer/etc/config.xml
index 186ce0d901..d17bb186e2 100644
--- a/app/code/core/Mage/Customer/etc/config.xml
+++ b/app/code/core/Mage/Customer/etc/config.xml
@@ -28,7 +28,7 @@
- 1.4.0.0.4
+ 1.4.0.0.6
diff --git a/app/code/core/Mage/Flo2Cash/sql/flo2cash_setup/mysql4-upgrade-0.1.0-0.1.1.php b/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.4.0.0.5-1.4.0.0.6.php
similarity index 86%
rename from app/code/core/Mage/Flo2Cash/sql/flo2cash_setup/mysql4-upgrade-0.1.0-0.1.1.php
rename to app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.4.0.0.5-1.4.0.0.6.php
index 2d9ba52cf6..e5c9fcbf63 100644
--- a/app/code/core/Mage/Flo2Cash/sql/flo2cash_setup/mysql4-upgrade-0.1.0-0.1.1.php
+++ b/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.4.0.0.5-1.4.0.0.6.php
@@ -19,14 +19,14 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Flo2Cash
+ * @package Mage_Customer
* @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)
*/
+
$installer = $this;
+/* @var $installer Mage_Customer_Model_Entity_Setup */
$installer->startSetup();
-
-$installer->addAttribute('order_payment', 'flo2cash_account_id', array());
-
+$installer->updateAttribute('customer', 'dob', 'backend_model', '');
$installer->endSetup();
diff --git a/app/code/core/Mage/Cybermut/Block/Error.php b/app/code/core/Mage/Cybermut/Block/Error.php
deleted file mode 100644
index 41eff0b517..0000000000
--- a/app/code/core/Mage/Cybermut/Block/Error.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
-*/
-class Mage_Cybermut_Block_Error extends Mage_Core_Block_Template
-{
-}
diff --git a/app/code/core/Mage/Cybermut/Block/Form.php b/app/code/core/Mage/Cybermut/Block/Form.php
deleted file mode 100644
index b440ad58c7..0000000000
--- a/app/code/core/Mage/Cybermut/Block/Form.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- */
-class Mage_Cybermut_Block_Form extends Mage_Payment_Block_Form
-{
- protected function _construct()
- {
- $this->setTemplate('cybermut/form.phtml');
- parent::_construct();
- }
-
-}
diff --git a/app/code/core/Mage/Cybermut/Block/Redirect.php b/app/code/core/Mage/Cybermut/Block/Redirect.php
deleted file mode 100644
index be8cc3e81a..0000000000
--- a/app/code/core/Mage/Cybermut/Block/Redirect.php
+++ /dev/null
@@ -1,67 +0,0 @@
-
- */
-class Mage_Cybermut_Block_Redirect extends Mage_Core_Block_Abstract
-{
-
- protected function _toHtml()
- {
- $standard = Mage::getModel('cybermut/payment');
- $form = new Varien_Data_Form();
- $form->setAction($standard->getCybermutUrl())
- ->setId('cybermut_payment_checkout')
- ->setName('cybermut_payment_checkout')
- ->setMethod('POST')
- ->setUseContainer(true);
- foreach ($standard->setOrder($this->getOrder())->getStandardCheckoutFormFields() as $field => $value) {
- $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
- }
-
- $formHTML = $form->toHtml();
-
- $html = '';
- $html.= $this->__('You will be redirected to Cybermut in a few seconds.');
- $html.= $formHTML;
- $html.= '';
- $html.= '';
-
- if ($standard->getConfigData('debug_flag')) {
- Mage::getModel('cybermut/api_debug')
- ->setRequestBody($formHTML)
- ->save();
- }
-
- return $html;
- }
-}
diff --git a/app/code/core/Mage/Cybermut/Helper/Data.php b/app/code/core/Mage/Cybermut/Helper/Data.php
deleted file mode 100644
index cfda934a0e..0000000000
--- a/app/code/core/Mage/Cybermut/Helper/Data.php
+++ /dev/null
@@ -1,38 +0,0 @@
-
- */
-class Mage_Cybermut_Helper_Data extends Mage_Core_Helper_Abstract
-{
-
-}
diff --git a/app/code/core/Mage/Cybermut/Model/Api/Debug.php b/app/code/core/Mage/Cybermut/Model/Api/Debug.php
deleted file mode 100644
index d81ed2c28f..0000000000
--- a/app/code/core/Mage/Cybermut/Model/Api/Debug.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Cybermut_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('cybermut/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Cybermut/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Cybermut/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index 03ffbd8e07..0000000000
--- a/app/code/core/Mage/Cybermut/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-
-class Mage_Cybermut_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('cybermut/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Cybermut/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/Cybermut/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index 96a02589da..0000000000
--- a/app/code/core/Mage/Cybermut/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Cybermut_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('cybermut/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Cybermut/Model/Mysql4/Setup.php b/app/code/core/Mage/Cybermut/Model/Mysql4/Setup.php
deleted file mode 100644
index 5ebe774184..0000000000
--- a/app/code/core/Mage/Cybermut/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-
-class Mage_Cybermut_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
-{
-
-}
diff --git a/app/code/core/Mage/Cybermut/Model/Payment.php b/app/code/core/Mage/Cybermut/Model/Payment.php
deleted file mode 100644
index 12cb0ccb36..0000000000
--- a/app/code/core/Mage/Cybermut/Model/Payment.php
+++ /dev/null
@@ -1,369 +0,0 @@
-
- */
-
-class Mage_Cybermut_Model_Payment extends Mage_Payment_Model_Method_Abstract
-{
- protected $_code = 'cybermut_payment';
- protected $_formBlockType = 'cybermut/form';
-
- // Cybermut return codes of payment
- const RETURN_CODE_ACCEPTED = 'paiement';
- const RETURN_CODE_TEST_ACCEPTED = 'payetest';
- const RETURN_CODE_ERROR = 'Annulation';
-
- // Payment configuration
- protected $_isGateway = false;
- protected $_canAuthorize = true;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = false;
- protected $_canVoid = false;
- protected $_canUseInternal = false;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = false;
-
- // Order instance
- protected $_order = null;
-
- /**
- * Return CyberMut protocol version
- *
- * @return string Protocol version
- */
- protected function getVersion()
- {
- return '1.2open';
- }
-
- /**
- * Returns Target URL
- *
- * @return string Target URL
- */
- public function getCybermutUrl()
- {
- $url = '';
- switch ($this->getConfigData('bank'))
- {
- default:
- case 'mutuel':
- $url = $this->getConfigData('test_mode')
- ? 'https://paiement.creditmutuel.fr/test/paiement.cgi'
- : 'https://paiement.creditmutuel.fr/paiement.cgi';
- break;
- case 'cic':
- $url = $this->getConfigData('test_mode')
- ? 'https://ssl.paiement.cic-banques.fr/test/paiement.cgi'
- : 'https://ssl.paiement.cic-banques.fr/paiement.cgi';
- break;
- case 'obc':
- $url = $this->getConfigData('test_mode')
- ? 'https://ssl.paiement.banque-obc.fr/test/paiement.cgi'
- : 'https://ssl.paiement.banque-obc.fr/paiement.cgi';
- break;
- }
- return $url;
- }
-
- /**
- * Return back URL
- *
- * @return string URL
- */
- protected function getReturnURL()
- {
- return $this->getSuccessURL();
- }
-
- /**
- * Return URL for Cybermut success response
- *
- * @return string URL
- */
- protected function getSuccessURL()
- {
- return Mage::getUrl('cybermut/payment/success', array('_secure' => true));
- }
-
- /**
- * Return URL for Cybermut failure response
- *
- * @return string URL
- */
- protected function getErrorURL()
- {
- return Mage::getUrl('cybermut/payment/error', array('_secure' => true));
- }
-
- /**
- * Capture payment
- *
- * @param Varien_Object $orderPayment
- * @return Mage_Payment_Model_Abstract
- */
- public function capture(Varien_Object $payment, $amount)
- {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId());
-
- return $this;
- }
-
- /**
- * Form block description
- *
- * @return object
- */
- public function createFormBlock($name)
- {
- $block = $this->getLayout()->createBlock('cybermut/form_payment', $name);
- $block->setMethod($this->_code);
- $block->setPayment($this->getPayment());
-
- return $block;
- }
-
- /**
- * Return Order Place Redirect URL
- *
- * @return string Order Redirect URL
- */
- public function getOrderPlaceRedirectUrl()
- {
- return Mage::getUrl('cybermut/payment/redirect');
- }
-
- /**
- * Return Standard Checkout Form Fields for request to Cybermut
- *
- * @return array Array of hidden form fields
- */
- public function getStandardCheckoutFormFields()
- {
- $order = $this->getOrder();
- if (!($order instanceof Mage_Sales_Model_Order)) {
- Mage::throwException($this->_getHelper()->__('Cannot retrieve order object'));
- }
-
- $description = $this->getConfigData('description')
- ? $this->getConfigData('description')
- : Mage::helper('cybermut')->__('Order #%s', $order->getRealOrderId());
-
- $fields = array(
- 'version' => $this->getVersion(),
- 'TPE' => $this->getConfigData('tpe_no'),
- 'date' => date('d/m/Y:H:i:s'),
- 'montant' => sprintf('%.2f', $order->getBaseGrandTotal()) . $order->getBaseCurrencyCode(),
- 'reference' => $order->getRealOrderId(),
- 'texte-libre' => $description,
- 'lgue' => $this->getConfigData('language'),
- 'societe' => $this->getConfigData('site_code'),
- 'url_retour' => $this->getReturnURL(),
- 'url_retour_ok' => $this->getSuccessURL(),
- 'url_retour_err' => $this->getErrorURL(),
- 'bouton' => 'ButtonLabel'
- );
-
- $fields['MAC'] = $this->_getMAC($fields);
-
- return $fields;
- }
-
- /**
- * Prepare string for MAC generation
- *
- * @param array $data
- * @return string MAC string
- */
- protected function _getMAC($data)
- {
- $string = sprintf('%s*%s*%s*%s*%s*%s*%s*%s*',
- $data['TPE'],
- $data['date'],
- $data['montant'],
- $data['reference'],
- $data['texte-libre'],
- $data['version'],
- $data['lgue'],
- $data['societe']
- );
-
- return $this->_CMCIC_hmac($string);
- }
-
- /**
- * Return SHA key
- *
- * @return string SHA key
- */
- protected function _getSHAKey()
- {
- return $this->getConfigData('sha_key');
- }
-
- /**
- * Return merchant key
- *
- * @return string Merchant key
- */
- protected function _getKey()
- {
- return $this->getConfigData('key');
- }
-
- /**
- * Return MAC string for payment authentification
- *
- * @param string $string
- * @return string MAC
- */
- protected function _CMCIC_hmac($string)
- {
- $pass = $this->_getSHAKey();
- $k1 = pack("H*",sha1($this->_getSHAKey()));
- $l1 = strlen($k1);
- $k2 = pack("H*", $this->_getKey());
- $l2 = strlen($k2);
- if ($l1 > $l2) {
- $k2 = str_pad($k2, $l1, chr(0x00));
- } elseif ($l2 > $l1) {
- $k1 = str_pad($k1, $l2, chr(0x00));
- }
- return strtolower($this->_hmacSHA1($k1 ^ $k2, $string));
- }
-
- /**
- * MAC generation algorithm
- *
- * @param string $key
- * @param string $string
- * @return string MAC
- */
- protected function _hmacSHA1($key, $string)
- {
- $length = 64; // block length for SHA1
- if (strlen($key) > $length) {
- $key = pack("H*",sha1($key));
- }
- $key = str_pad($key, $length, chr(0x00));
- $ipad = str_pad('', $length, chr(0x36));
- $opad = str_pad('', $length, chr(0x5c));
- $k_ipad = $key ^ $ipad ;
- $k_opad = $key ^ $opad;
-
- return sha1($k_opad . pack("H*",sha1($k_ipad . $string)));
- }
-
- /**
- * Return MAC string on basis of Cybermut response data
- *
- * @param array $data
- * @return string MAC
- */
- public function getResponseMAC($data)
- {
- $string = sprintf('%s%s+%s+%s+%s+%s+%s+%s+',
- $data['retourPLUS'],
- $data['TPE'],
- $data['date'],
- $data['montant'],
- $data['reference'],
- $data['texte-libre'],
- $this->getVersion(),
- $data['code-retour']
- );
- return strtoupper($this->_CMCIC_hmac($string));
- }
-
- /**
- * Transaction successful or not
- *
- * @param string $returnCode
- * @return boolean
- */
- public function isSuccessfulPayment($returnCode)
- {
- return in_array($returnCode, array(self::RETURN_CODE_ACCEPTED, self::RETURN_CODE_TEST_ACCEPTED));
- }
-
- /**
- * Output success response and stop the script
- */
- public function generateSuccessResponse()
- {
- die($this->getSuccessResponse());
- }
-
- /**
- * Output failure response and stop the script
- */
- public function generateErrorResponse()
- {
- die($this->getErrorResponse());
- }
-
- /**
- * Return response for Cybermut success payment
- *
- * @return string Success response string
- */
- public function getSuccessResponse()
- {
- $response = array(
- 'Pragma: no-cache',
- 'Content-type : text/plain',
- 'Version: 1',
- 'OK'
- );
- return implode("\n", $response) . "\n";
- }
-
- /**
- * Return response for Cybermut failure payment
- *
- * @return string Failure response string
- */
- public function getErrorResponse()
- {
- $response = array(
- 'Pragma: no-cache',
- 'Content-type : text/plain',
- 'Version: 1',
- 'Document falsifie'
- );
- return implode("\n", $response) . "\n";
- }
-
-}
diff --git a/app/code/core/Mage/Cybermut/Model/Source/Bank.php b/app/code/core/Mage/Cybermut/Model/Source/Bank.php
deleted file mode 100644
index 01376f60ff..0000000000
--- a/app/code/core/Mage/Cybermut/Model/Source/Bank.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- */
-
-class Mage_Cybermut_Model_Source_Bank
-{
- public function toOptionArray()
- {
- return array(
- array('value' => 'mutuel', 'label' => Mage::helper('cybermut')->__('Credit Mutuel')),
- array('value' => 'cic', 'label' => Mage::helper('cybermut')->__('Groupe CIC')),
- array('value' => 'obc', 'label' => Mage::helper('cybermut')->__('OBC')),
- );
- }
-}
-
-
-
diff --git a/app/code/core/Mage/Cybermut/Model/Source/Language.php b/app/code/core/Mage/Cybermut/Model/Source/Language.php
deleted file mode 100644
index f8b7d18235..0000000000
--- a/app/code/core/Mage/Cybermut/Model/Source/Language.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- */
-
-class Mage_Cybermut_Model_Source_Language
-{
- public function toOptionArray()
- {
- return array(
- array('value' => 'EN', 'label' => Mage::helper('cybermut')->__('English')),
- array('value' => 'FR', 'label' => Mage::helper('cybermut')->__('French')),
- array('value' => 'DE', 'label' => Mage::helper('cybermut')->__('German')),
- array('value' => 'IT', 'label' => Mage::helper('cybermut')->__('Italian')),
- array('value' => 'ES', 'label' => Mage::helper('cybermut')->__('Spain')),
- array('value' => 'NL', 'label' => Mage::helper('cybermut')->__('Dutch')),
- );
- }
-}
-
-
-
diff --git a/app/code/core/Mage/Cybermut/controllers/PaymentController.php b/app/code/core/Mage/Cybermut/controllers/PaymentController.php
deleted file mode 100644
index 6e0710c84d..0000000000
--- a/app/code/core/Mage/Cybermut/controllers/PaymentController.php
+++ /dev/null
@@ -1,207 +0,0 @@
-
- */
-class Mage_Cybermut_PaymentController extends Mage_Core_Controller_Front_Action
-{
- /**
- * Order instance
- */
- protected $_order;
-
- /**
- * Get order
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder()
- {
- if ($this->_order == null) {
- $session = Mage::getSingleton('checkout/session');
- $this->_order = Mage::getModel('sales/order');
- $this->_order->loadByIncrementId($session->getLastRealOrderId());
- }
- return $this->_order;
- }
-
- /**
- * When a customer chooses Cybermut on Checkout/Payment page
- *
- */
- public function redirectAction()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setCybermutPaymentQuoteId($session->getQuoteId());
-
- $order = $this->getOrder();
-
- if (!$order->getId()) {
- $this->norouteAction();
- return;
- }
-
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('cybermut')->__('Customer was redirected to Cybermut')
- );
- $order->save();
-
- $this->getResponse()
- ->setBody($this->getLayout()
- ->createBlock('cybermut/redirect')
- ->setOrder($order)
- ->toHtml());
-
- $session->unsQuoteId();
- }
-
- /**
- * Cybermut response router
- *
- */
- public function notifyAction()
- {
- $model = Mage::getModel('cybermut/payment');
-
- if (!$this->getRequest()->isPost()) {
- $model->generateErrorResponse();
- }
-
- $postData = $this->getRequest()->getPost();
- $returnedMAC = $this->getRequest()->getPost('MAC');
- $correctMAC = $model->getResponseMAC($postData);
-
- if ($model->getConfigData('debug_flag')) {
- Mage::getModel('cybermut/api_debug')
- ->setResponseBody(print_r($postData ,1))
- ->save();
- }
-
- $order = Mage::getModel('sales/order')
- ->loadByIncrementId($this->getRequest()->getPost('reference'));
-
- if (!$order->getId()) {
- $model->generateErrorResponse();
- }
-
- if ($returnedMAC == $correctMAC && $model->isSuccessfulPayment($this->getRequest()->getPost('code-retour'))) {
- $order->addStatusToHistory($model->getConfigData('order_status'));
- $order->sendNewOrderEmail();
- if ($this->saveInvoice($order)) {
-// $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
- }
- $order->save();
- $model->generateSuccessResponse();
- } else {
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('cybermut')->__('Returned MAC is invalid. Order cancelled.')
- );
- $order->cancel();
- $order->save();
- $model->generateErrorResponse();
- }
- }
-
- /**
- * Save invoice for order
- *
- * @param Mage_Sales_Model_Order $order
- * @return boolean Can save invoice or not
- */
- protected function saveInvoice(Mage_Sales_Model_Order $order)
- {
- if ($order->canInvoice()) {
- $invoice = $order->prepareInvoice();
- $invoice->register()->capture();
- Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
- return true;
- }
-
- return false;
- }
-
- /**
- * Success payment page
- */
- public function successAction()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setQuoteId($session->getCybermutPaymentQuoteId());
- $session->unsCybermutPaymentQuoteId();
-
- $order = $this->getOrder();
-
- if (!$order->getId()) {
- $this->norouteAction();
- return;
- }
-
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('cybermut')->__('Customer successfully returned from Cybermut')
- );
-
- $order->save();
- $this->_redirect('checkout/onepage/success');
- }
-
- /**
- * Failure payment page
- */
- public function errorAction()
- {
- $errorMsg = Mage::helper('cybermut')->__(' There was an error occurred during paying process.');
-
- $order = $this->getOrder();
-
- if (!$order->getId()) {
- $this->norouteAction();
- return;
- }
- if ($order instanceof Mage_Sales_Model_Order && $order->getId()) {
- $order->addStatusToHistory(
- $order->getStatus(),
- Mage::helper('cybermut')->__('Customer returned from Cybermut.') . $errorMsg
- );
- $order->cancel();
- $order->save();
- }
-
- $this->loadLayout();
- $this->renderLayout();
- Mage::getSingleton('checkout/session')->unsLastRealOrderId();
- }
-}
diff --git a/app/code/core/Mage/Cybermut/etc/config.xml b/app/code/core/Mage/Cybermut/etc/config.xml
deleted file mode 100644
index 3a21a03b95..0000000000
--- a/app/code/core/Mage/Cybermut/etc/config.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
- 0.1.0
-
-
-
-
-
- Mage_Cybermut_Model
- cybermut_mysql4
-
-
- Mage_Cybermut_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Cybermut
- Mage_Cybermut_Model_Mysql4_Setup
-
-
-
-
- Mage_Cybermut_Block
-
-
-
-
- /cybermut/payment
-
-
-
- standard
-
- Mage_Cybermut
- cybermut
-
-
-
-
-
-
-
- Mage_Cybermut.csv
-
-
-
-
-
-
-
- cybermut.xml
-
-
-
-
-
-
-
-
-
- Mage_Cybermut.csv
-
-
-
-
-
-
-
-
- cybermut/payment
- CyberMUT-P@iement
- 0
- O
-
-
-
-
diff --git a/app/code/core/Mage/Cybermut/etc/system.xml b/app/code/core/Mage/Cybermut/etc/system.xml
deleted file mode 100644
index 035793feca..0000000000
--- a/app/code/core/Mage/Cybermut/etc/system.xml
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
-
-
-
-
-
- Cybermut Payment
- text
- 300
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- TPE number
- text
- 3
- 1
- 1
- 0
-
-
- Site code
- text
- 4
- 1
- 1
- 0
-
-
- SHA key
- text
- 5
- 1
- 1
- 0
-
-
- Key
- text
- 6
- 1
- 1
- 0
-
-
- Bank
- select
- cybermut/source_bank
- 7
- 1
- 1
- 0
-
-
- Transaction Description
- Order number will be used if left empty
- text
- 8
- 1
- 1
- 0
-
-
- Customer Interface language
- select
- cybermut/source_language
- 9
- 1
- 1
- 0
-
-
- Test mode
- select
- adminhtml/system_config_source_yesno
- 10
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 11
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status
- 12
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 13
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 14
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 15
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Cybermut/sql/cybermut_setup/mysql4-install-0.1.0.php b/app/code/core/Mage/Cybermut/sql/cybermut_setup/mysql4-install-0.1.0.php
deleted file mode 100644
index 78bd7163ce..0000000000
--- a/app/code/core/Mage/Cybermut/sql/cybermut_setup/mysql4-install-0.1.0.php
+++ /dev/null
@@ -1,45 +0,0 @@
-startSetup();
-
-$installer->run("
-CREATE TABLE `{$this->getTable('cybermut_api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Cybersource/Block/Form.php b/app/code/core/Mage/Cybersource/Block/Form.php
deleted file mode 100644
index 5391c7ca43..0000000000
--- a/app/code/core/Mage/Cybersource/Block/Form.php
+++ /dev/null
@@ -1,96 +0,0 @@
-setTemplate('cybersource/form.phtml');
- }
-
- protected function _getConfig()
- {
- return Mage::getSingleton('cybersource/config');
- }
-
- /**
- * Retrieve availables credit card types
- *
- * @return array
- */
- public function getCcAvailableTypes()
- {
- $types = $this->_getConfig()->getCcTypes();
- if ($method = $this->getMethod()) {
- $availableTypes = $method->getConfigData('cctypes');
- if ($availableTypes) {
- $availableTypes = explode(',', $availableTypes);
- foreach ($types as $code=>$name) {
- if (!in_array($code, $availableTypes)) {
- unset($types[$code]);
- }
- }
- }
- }
- return $types;
- }
-
-
- /*
- * solo/switch card start year
- * @return array
- */
- public function getSsStartYears()
- {
- $years = array();
- $first = date("Y");
-
- for ($index=5; $index>=0; $index--) {
- $year = $first - $index;
- $years[$year] = $year;
- }
- $years = array(0=>$this->__('Year'))+$years;
- return $years;
- }
-
- /*
- * switch/solo card type available
- */
- public function hasSsCardType()
- {
- $availableTypes =$this->getMethod()->getConfigData('cctypes');
- if ($availableTypes) {
- $availableTypes = explode(',', $availableTypes);
- if (in_array('SS', $availableTypes)) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/app/code/core/Mage/Cybersource/Block/Info.php b/app/code/core/Mage/Cybersource/Block/Info.php
deleted file mode 100644
index 1028e1c058..0000000000
--- a/app/code/core/Mage/Cybersource/Block/Info.php
+++ /dev/null
@@ -1,75 +0,0 @@
-setTemplate('cybersource/info.phtml');
- }
-
- protected function _getConfig()
- {
- return Mage::getSingleton('cybersource/config');
- }
-
-
- /**
- * Retrieve credit card type name
- *
- * @return string
- */
- public function getCcTypeName()
- {
- $types = $this->_getConfig()->getCcTypes();
- if (isset($types[$this->getInfo()->getCcType()])) {
- return $types[$this->getInfo()->getCcType()];
- }
- return $this->getInfo()->getCcType();
- }
-
- /**
- * Retrieve CC start month for switch/solo card
- *
- * @return string
- */
- public function getCcStartMonth()
- {
- $month = $this->getInfo()->getCcSsStartMonth();
- if ($month<10) {
- $month = '0'.$month;
- }
- return $month;
- }
-
- public function toPdf()
- {
- $this->setTemplate('cybersource/pdf/info.phtml');
- return $this->toHtml();
- }
-}
diff --git a/app/code/core/Mage/Cybersource/Helper/Data.php b/app/code/core/Mage/Cybersource/Helper/Data.php
deleted file mode 100644
index 2099d8735e..0000000000
--- a/app/code/core/Mage/Cybersource/Helper/Data.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
- */
-class Mage_Cybersource_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('cybersource/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Cybersource/Model/Api/ExtendedSoapClient.php b/app/code/core/Mage/Cybersource/Model/Api/ExtendedSoapClient.php
deleted file mode 100644
index 7ce6be9caa..0000000000
--- a/app/code/core/Mage/Cybersource/Model/Api/ExtendedSoapClient.php
+++ /dev/null
@@ -1,121 +0,0 @@
-_storeId = $storeId;
- return $this;
- }
-
- /**
- * Store Id getter
- *
- * @return int
- */
- public function getStoreId()
- {
- return $this->_storeId;
- }
-
- /**
- * XPaths that should be replaced in debug with '***'
- *
- * @var array
- */
- protected $_debugReplacePrivateDataXPaths = array(
- '//*[contains(name(),\'merchantID\')]/text()',
- '//*[contains(name(),\'card\')]/*/text()',
- '//*[contains(name(),\'UsernameToken\')]/*/text()'
- );
-
- public function __construct($wsdl, $options = array())
- {
- parent::__construct($wsdl, $options);
- }
-
- protected function getBaseApi()
- {
- return Mage::getSingleton('cybersource/soap');
- }
-
- public function __doRequest($request, $location, $action, $version)
- {
- $api = $this->getBaseApi();
- $user = $api->getConfigData('merchant_id', $this->getStoreId());
- $password = $api->getConfigData('security_key', $this->getStoreId());
- $soapHeader = "$user $password ";
-
- $requestDOM = new DOMDocument('1.0');
- $soapHeaderDOM = new DOMDocument('1.0');
- $requestDOM->loadXML($request);
- $soapHeaderDOM->loadXML($soapHeader);
-
- $node = $requestDOM->importNode($soapHeaderDOM->firstChild, true);
- $requestDOM->firstChild->insertBefore(
- $node, $requestDOM->firstChild->firstChild);
-
- $request = $requestDOM->saveXML();
- if ($api->getConfigData('debug', $this->getStoreId())) {
-
- $requestDOMXPath = new DOMXPath($requestDOM);
-
- foreach ($this->_debugReplacePrivateDataXPaths as $xPath) {
- foreach ($requestDOMXPath->query($xPath) as $element) {
- $element->data = '***';
- }
- }
-
- $debug = Mage::getModel('cybersource/api_debug')
- ->setAction($action)
- ->setRequestBody($requestDOM->saveXML())
- ->save();
- }
-
- $response = parent::__doRequest($request, $location, $action, $version);
-
- if (!empty($debug)) {
- $debug
- ->setResponseBody($response)
- ->save();
- }
-
- return $response;
- }
-}
diff --git a/app/code/core/Mage/Cybersource/Model/Config.php b/app/code/core/Mage/Cybersource/Model/Config.php
deleted file mode 100644
index 9c0fd1e159..0000000000
--- a/app/code/core/Mage/Cybersource/Model/Config.php
+++ /dev/null
@@ -1,62 +0,0 @@
-_ccTypes = array();
- $added = false;
- foreach ($pTypes as $code => $name) {
- if ($code=='OT') {
- $added = true;
- $this->addExtraCcTypes();
- }
- $this->_ccTypes[$code] = $name;
- }
- if (!$added) {
- $this->addExtraCcTypes();
- }
- return $this->_ccTypes;
- }
-
- public function addExtraCcTypes()
- {
- $this->_ccTypes['JCB'] = Mage::helper('cybersource')->__('JCB');
- $this->_ccTypes['LASER'] = Mage::helper('cybersource')->__('Laser');
- $this->_ccTypes['UATP'] = Mage::helper('cybersource')->__('UATP');
- $this->_ccTypes['MCI'] = Mage::helper('cybersource')->__('Maestro (International)');
- $this->_ccTypes[Mage_Cybersource_Model_Soap::CC_CARDTYPE_SS] = Mage::helper('cybersource')->__('Maestro/Solo(UK Domestic)');
-
- }
-
-}
diff --git a/app/code/core/Mage/Cybersource/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Cybersource/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index fae3f152df..0000000000
--- a/app/code/core/Mage/Cybersource/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-class Mage_Cybersource_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('cybersource/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Cybersource/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/Cybersource/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index 3d6cc2925d..0000000000
--- a/app/code/core/Mage/Cybersource/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-class Mage_Cybersource_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('cybersource/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Cybersource/Model/Mysql4/Setup.php b/app/code/core/Mage/Cybersource/Model/Mysql4/Setup.php
deleted file mode 100644
index 0166b2eb15..0000000000
--- a/app/code/core/Mage/Cybersource/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,38 +0,0 @@
-getInfoInstance();
-
- if ($data->getCcType()==self::CC_CARDTYPE_SS) {
- $info->setCcSsIssue($data->getCcSsIssue())
- ->setCcSsStartMonth($data->getCcSsStartMonth())
- ->setCcSsStartYear($data->getCcSsStartYear())
- ;
- }
- return $this;
- }
-
- /**
- * Validate payment method information object
- *
- * @param Mage_Payment_Model_Info $info
- * @return Mage_Payment_Model_Abstract
- */
- public function validate()
- {
- if (!extension_loaded('soap')) {
- Mage::throwException(Mage::helper('cybersource')->__('SOAP extension is not enabled. Please contact us.'));
- }
- /**
- * to validate paymene method is allowed for billing country or not
- */
- $paymentInfo = $this->getInfoInstance();
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
- $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
- } else {
- $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
- }
- if (!$this->canUseForCountry($billingCountry)) {
- Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.'));
- }
-
- $info = $this->getInfoInstance();
- $errorMsg = false;
- $availableTypes = explode(',',$this->getConfigData('cctypes'));
-
- $ccNumber = $info->getCcNumber();
-
- // remove credit card number delimiters such as "-" and space
- $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
- $info->setCcNumber($ccNumber);
-
- $ccType = '';
-
- if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
- $errorCode = 'ccsave_expiration,ccsave_expiration_yr';
- $errorMsg = $this->_getHelper()->__('Incorrect credit card expiration date');
- }
-
- if (in_array($info->getCcType(), $availableTypes)){
- if ($this->validateCcNum($ccNumber)
- // Other credit card type number validation
- || ($this->OtherCcType($info->getCcType()) && $this->validateCcNumOther($ccNumber))) {
-
- $ccType = 'OT';
- $ccTypeRegExpList = array(
- 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', // Visa
- 'MC' => '/^5[1-5][0-9]{14}$/', // Master Card
- 'AE' => '/^3[47][0-9]{13}$/', // American Express
- 'DI' => '/^6011[0-9]{12}$/', // Discovery
- 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{12})$/', // JCB
- 'LASER' => '/^(6304|6706|6771|6709)[0-9]{12}([0-9]{3})?$/' // LASER
- );
-
- foreach ($ccTypeRegExpList as $ccTypeMatch=>$ccTypeRegExp) {
- if (preg_match($ccTypeRegExp, $ccNumber)) {
- $ccType = $ccTypeMatch;
- break;
- }
- }
-
- if (!$this->OtherCcType($info->getCcType()) && $ccType!=$info->getCcType()) {
- $errorCode = 'ccsave_cc_type,ccsave_cc_number';
- $errorMsg = $this->_getHelper()->__('Credit card number mismatch with credit card type');
- }
- }
- else {
- $errorCode = 'ccsave_cc_number';
- $errorMsg = $this->_getHelper()->__('Invalid Credit Card Number');
- }
-
- }
- else {
- $errorCode = 'ccsave_cc_type';
- $errorMsg = $this->_getHelper()->__('Credit card type is not allowed for this payment method');
- }
-
- //validate credit card verification number
- if ($errorMsg === false && $this->hasVerification()) {
- $verifcationRegEx = $this->getVerificationRegEx();
- $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
- if (!$info->getCcCid() || !$regExp || !preg_match($regExp ,$info->getCcCid())){
- $errorMsg = $this->_getHelper()->__('Please enter a valid credit card verification number.');
- }
- }
-
- if($errorMsg){
- Mage::throwException($errorMsg);
- }
- return $this;
- }
-
- /**
- * Getting Soap Api object
- *
- * @param array $options
- * @return Mage_Cybersource_Model_Api_ExtendedSoapClient
- */
- protected function getSoapApi($options = array())
- {
- $wsdl = $this->getConfigData('test') ? self::WSDL_URL_TEST : self::WSDL_URL_LIVE;
- $_api = new Mage_Cybersource_Model_Api_ExtendedSoapClient($wsdl, $options);
- $_api->setStoreId($this->getStore());
- return $_api;
- }
-
- /**
- * Initializing soap header
- */
- protected function iniRequest()
- {
- $this->_request = new stdClass();
- $this->_request->merchantID = $this->getConfigData('merchant_id');
- $this->_request->merchantReferenceCode = $this->_generateReferenceCode();
-
- $this->_request->clientLibrary = "PHP";
- $this->_request->clientLibraryVersion = phpversion();
- $this->_request->clientEnvironment = php_uname();
- }
-
- /**
- * Random generator for merchant referenc code
- *
- * @return random number
- */
- protected function _generateReferenceCode()
- {
- return Mage::helper('core')->uniqHash();
- }
-
- /**
- * Getting customer IP address
- *
- * @return IP address string
- */
- protected function getIpAddress()
- {
- return Mage::helper('core/http')->getRemoteAddr();
- }
-
- /**
- * Assigning billing address to soap
- *
- * @param Varien_Object $billing
- * @param String $email
- */
- protected function addBillingAddress($billing, $email)
- {
- if (!$email) {
- $email = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getEmail();
- }
- $billTo = new stdClass();
- $billTo->firstName = $billing->getFirstname();
- $billTo->lastName = $billing->getLastname();
- $billTo->company = $billing->getCompany();
- $billTo->street1 = $billing->getStreet(1);
- $billTo->street2 = $billing->getStreet(2);
- $billTo->city = $billing->getCity();
- $billTo->state = $billing->getRegion();
- $billTo->postalCode = $billing->getPostcode();
- $billTo->country = $billing->getCountry();
- $billTo->phoneNumber = $billing->getTelephone();
- $billTo->email = ($email ? $email : Mage::getStoreConfig('trans_email/ident_general/email'));
- $billTo->ipAddress = $this->getIpAddress();
- $this->_request->billTo = $billTo;
- }
-
- /**
- * Assigning shipping address to soap object
- *
- * @param Varien_Object $shipping
- */
- protected function addShippingAddress($shipping)
- {
- //checking if we have shipping address, in case of virtual order we will not have it
- if ($shipping) {
- $shipTo = new stdClass();
- $shipTo->firstName = $shipping->getFirstname();
- $shipTo->lastName = $shipping->getLastname();
- $shipTo->company = $shipping->getCompany();
- $shipTo->street1 = $shipping->getStreet(1);
- $shipTo->street2 = $shipping->getStreet(2);
- $shipTo->city = $shipping->getCity();
- $shipTo->state = $shipping->getRegion();
- $shipTo->postalCode = $shipping->getPostcode();
- $shipTo->country = $shipping->getCountry();
- $shipTo->phoneNumber = $shipping->getTelephone();
- $this->_request->shipTo = $shipTo;
- }
- }
-
- /**
- * Assigning credit card information
- *
- * @param Mage_Model_Order_Payment $payment
- */
- protected function addCcInfo($payment)
- {
- $card = new stdClass();
- $card->fullName = $payment->getCcOwner();
- $card->accountNumber = $payment->getCcNumber();
- $card->expirationMonth = $payment->getCcExpMonth();
- $card->expirationYear = $payment->getCcExpYear();
- if ($payment->hasCcCid()) {
- $card->cvNumber = $payment->getCcCid();
- }
- if ($payment->getCcType()==self::CC_CARDTYPE_SS && $payment->hasCcSsIssue()) {
- $card->issueNumber = $payment->getCcSsIssue();
- }
- if ($payment->getCcType()==self::CC_CARDTYPE_SS && $payment->hasCcSsStartYear()) {
- $card->startMonth = $payment->getCcSsStartMonth();
- $card->startYear = $payment->getCcSsStartYear();
- }
- $this->_request->card = $card;
- }
-
- /**
- * Authorizing payment
- *
- * @param Varien_Object $payment
- * @param float $amount
- * @return Mage_Cybersource_Model_Soap
- */
- public function authorize(Varien_Object $payment, $amount)
- {
- $error = false;
-
- $soapClient = $this->getSoapApi();
-
- $this->iniRequest();
-
- $ccAuthService = new stdClass();
- $ccAuthService->run = "true";
- $this->_request->ccAuthService = $ccAuthService;
- $this->addBillingAddress($payment->getOrder()->getBillingAddress(), $payment->getOrder()->getCustomerEmail());
- $this->addShippingAddress($payment->getOrder()->getShippingAddress());
- $this->addCcInfo($payment);
-
- $purchaseTotals = new stdClass();
- $purchaseTotals->currency = $payment->getOrder()->getBaseCurrencyCode();
- $purchaseTotals->grandTotalAmount = $amount;
- $this->_request->purchaseTotals = $purchaseTotals;
-
- try {
- $result = $soapClient->runTransaction($this->_request);
- if ($result->reasonCode==self::RESPONSE_CODE_SUCCESS) {
- $payment->setLastTransId($result->requestID)
- ->setCcTransId($result->requestID)
- ->setCybersourceToken($result->requestToken)
- ->setCcAvsStatus($result->ccAuthReply->avsCode);
- /*
- * checking if we have cvCode in response bc
- * if we don't send cvn we don't get cvCode in response
- */
- if (isset($result->ccAuthReply->cvCode)) {
- $payment->setCcCidStatus($result->ccAuthReply->cvCode);
- }
- } else {
- $error = Mage::helper('cybersource')->__('There is an error in processing payment. Please try again or contact us.');
- }
- } catch (Exception $e) {
- Mage::throwException(
- Mage::helper('cybersource')->__('Gateway request error: %s', $e->getMessage())
- );
- }
-
- if ($error !== false) {
- Mage::throwException($error);
- }
- return $this;
- }
-
- /**
- * Capturing payment
- *
- * @param Varien_Object $payment
- * @param float $amount
- * @return Mage_Cybersource_Model_Soap
- */
- public function capture(Varien_Object $payment, $amount)
- {
- $error = false;
- $soapClient = $this->getSoapApi();
- $this->iniRequest();
-
- if ($payment->getCcTransId() && $payment->getCybersourceToken()) {
- $ccCaptureService = new stdClass();
- $ccCaptureService->run = "true";
- $ccCaptureService->authRequestToken = $payment->getCybersourceToken();
- $ccCaptureService->authRequestID = $payment->getCcTransId();
- $this->_request->ccCaptureService = $ccCaptureService;
-
- $item0 = new stdClass();
- $item0->unitPrice = $amount;
- $item0->id = 0;
- $this->_request->item = array($item0);
- } else {
- $ccAuthService = new stdClass();
- $ccAuthService->run = "true";
- $this->_request->ccAuthService = $ccAuthService;
-
- $ccCaptureService = new stdClass();
- $ccCaptureService->run = "true";
- $this->_request->ccCaptureService = $ccCaptureService;
-
- $this->addBillingAddress($payment->getOrder()->getBillingAddress(), $payment->getOrder()->getCustomerEmail());
- $this->addShippingAddress($payment->getOrder()->getShippingAddress());
- $this->addCcInfo($payment);
-
- $purchaseTotals = new stdClass();
- $purchaseTotals->currency = $payment->getOrder()->getBaseCurrencyCode();
- $purchaseTotals->grandTotalAmount = $amount;
- $this->_request->purchaseTotals = $purchaseTotals;
- }
- try {
- $result = $soapClient->runTransaction($this->_request);
- if ($result->reasonCode==self::RESPONSE_CODE_SUCCESS) {
- /*
- for multiple capture we need to use the latest capture transaction id
- */
- $payment->setLastTransId($result->requestID)
- ->setLastCybersourceToken($result->requestToken)
- ->setCcTransId($result->requestID)
- ->setCybersourceToken($result->requestToken)
- ;
- } else {
- $error = Mage::helper('cybersource')->__('There is an error in processing payment. Please try again or contact us.');
- }
- } catch (Exception $e) {
- Mage::throwException(
- Mage::helper('cybersource')->__('Gateway request error: %s', $e->getMessage())
- );
- }
- if ($error !== false) {
- Mage::throwException($error);
- }
- return $this;
- }
-
- /**
- * To assign transaction id and token after capturing payment
- *
- * @param Mage_Sale_Model_Order_Invoice $invoice
- * @param Mage_Sale_Model_Order_Payment $payment
- * @return Mage_Cybersource_Model_Soap
- */
- public function processInvoice($invoice, $payment)
- {
- parent::processInvoice($invoice, $payment);
- $invoice->setTransactionId($payment->getLastTransId());
- $invoice->setCybersourceToken($payment->getLastCybersourceToken());
- return $this;
- }
-
- /**
- * To assign transaction id and token before voiding the transaction
- *
- * @param Mage_Sale_Model_Order_Invoice $invoice
- * @param Mage_Sale_Order_Payment $payment
- * @return Mage_Cybersource_Model_Soap
- */
- public function processBeforeVoid($invoice, $payment)
- {
- parent::processBeforeVoid($invoice, $payment);
- $payment->setVoidTransactionId($invoice->getTransactionId());
- $payment->setVoidCybersourceToken($invoice->getCybersourceToken());
- return $this;
- }
-
- /**
- * Void the payment transaction
- *
- * @param Mage_Sale_Model_Order_Payment $payment
- * @return Mage_Cybersource_Model_Soap
- */
- public function void(Varien_Object $payment)
- {
- $error = false;
- if ($payment->getVoidTransactionId() && $payment->getVoidCybersourceToken()) {
- $soapClient = $this->getSoapApi();
- $this->iniRequest();
- $voidService = new stdClass();
- $voidService->run = "true";
- $voidService->voidRequestToken = $payment->getVoidCybersourceToken();
- $voidService->voidRequestID = $payment->getVoidTransactionId();
- $this->_request->voidService = $voidService;
- try {
- $result = $soapClient->runTransaction($this->_request);
- if ($result->reasonCode==self::RESPONSE_CODE_SUCCESS) {
- $payment->setLastTransId($result->requestID)
- ->setCcTransId($result->requestID)
- ->setCybersourceToken($result->requestToken)
- ;
- } else {
- $error = Mage::helper('cybersource')->__('There is an error in processing payment. Please try again or contact us.');
- }
- } catch (Exception $e) {
- Mage::throwException(
- Mage::helper('cybersource')->__('Gateway request error: %s', $e->getMessage())
- );
- }
- }else{
- $error = Mage::helper('cybersource')->__('Invalid transaction id or token');
- }
- if ($error !== false) {
- Mage::throwException($error);
- }
- return $this;
- }
-
- /**
- * To assign correct transaction id and token before refund
- *
- * @param Mage_Sale_Model_Order_Invoice $invoice
- * @param Mage_Sale_Model_Order_Payment $payment
- * @return Mage_Cybersource_Model_Soap
- */
- public function processBeforeRefund($invoice, $payment)
- {
- parent::processBeforeRefund($invoice, $payment);
- $payment->setRefundTransactionId($invoice->getTransactionId());
- $payment->setRefundCybersourceToken($invoice->getCybersourceToken());
- return $this;
- }
-
- /**
- * Refund the payment transaction
- *
- * @param Mage_Sale_Model_Order_Payment $payment
- * @param flaot $amount
- * @return Mage_Cybersource_Model_Soap
- */
- public function refund(Varien_Object $payment, $amount)
- {
- $error = false;
- if ($payment->getRefundTransactionId() && $payment->getRefundCybersourceToken() && $amount>0) {
- $soapClient = $this->getSoapApi();
- $this->iniRequest();
- $ccCreditService = new stdClass();
- $ccCreditService->run = "true";
- $ccCreditService->captureRequestToken = $payment->getCybersourceToken();
- $ccCreditService->captureRequestID = $payment->getCcTransId();
- $this->_request->ccCreditService = $ccCreditService;
-
- $purchaseTotals = new stdClass();
- $purchaseTotals->grandTotalAmount = $amount;
- $this->_request->purchaseTotals = $purchaseTotals;
-
- try {
- $result = $soapClient->runTransaction($this->_request);
- if ($result->reasonCode==self::RESPONSE_CODE_SUCCESS) {
- $payment->setLastTransId($result->requestID)
- ->setLastCybersourceToken($result->requestToken)
- ;
- } else {
- $error = Mage::helper('cybersource')->__('There is an error in processing payment. Please try again or contact us.');
- }
- } catch (Exception $e) {
- Mage::throwException(
- Mage::helper('cybersource')->__('Gateway request error: %s', $e->getMessage())
- );
- }
- } else {
- $error = Mage::helper('cybersource')->__('Error in refunding the payment');
- }
- if ($error !== false) {
- Mage::throwException($error);
- }
- return $this;
- }
-
-
- /**
- * To assign correct transaction id and token after refund
- *
- * @param Mage_Sale_Model_Order_Creditmemo $creditmemo
- * @param Mage_Sale_Model_Order_Payment $payment
- * @return Mage_Cybersource_Model_Soap
- */
- public function processCreditmemo($creditmemo, $payment)
- {
- parent::processCreditmemo($creditmemo, $payment);
- $creditmemo->setTransactionId($payment->getLastTransId());
- $creditmemo->setCybersourceToken($payment->getLastCybersourceToken());
- return $this;
- }
-}
diff --git a/app/code/core/Mage/Cybersource/Model/Source/Cctype.php b/app/code/core/Mage/Cybersource/Model/Source/Cctype.php
deleted file mode 100644
index 6c8a974562..0000000000
--- a/app/code/core/Mage/Cybersource/Model/Source/Cctype.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
- */
-class Mage_Cybersource_Model_Source_PaymentAction
-{
- public function toOptionArray()
- {
- return array(
- array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, 'label' => Mage::helper('cybersource')->__('Authorization')),
- array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, 'label' => Mage::helper('cybersource')->__('Sale')),
- );
- }
-}
diff --git a/app/code/core/Mage/Cybersource/etc/config.xml b/app/code/core/Mage/Cybersource/etc/config.xml
deleted file mode 100644
index dfdc1738ec..0000000000
--- a/app/code/core/Mage/Cybersource/etc/config.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
- 0.7.0
-
-
-
-
-
- Mage_Cybersource_Model
- cybersource_mysql4
-
-
- Mage_Cybersource_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Cybersource
- Mage_Cybersource_Model_Mysql4_Setup
-
-
-
-
- Mage_Cybersource_Block
-
-
-
-
-
- JCB
- JCB
- 50
-
-
- LASER
- Laser
- 51
-
-
- UATP
- UATP
- 52
-
-
- MCI
- Maestro (International)
- 53
-
-
- SS
- Maestro/Solo(UK Domestic)
- 53
-
-
-
-
-
-
-
- /cybersource/soap
-
-
-
- standard
-
- Mage_Cybersource
- cybersource
-
-
-
-
-
-
-
- Mage_Cybersource.csv
-
-
-
-
-
-
-
-
-
-
- Mage_Cybersource.csv
-
-
-
-
-
-
-
-
-
- authorize
- Credit Card (Cybersource)
- processing
- AE,VI,MC,DI
- cybersource/soap
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Cybersource/etc/system.xml b/app/code/core/Mage/Cybersource/etc/system.xml
deleted file mode 100644
index 0333a94ade..0000000000
--- a/app/code/core/Mage/Cybersource/etc/system.xml
+++ /dev/null
@@ -1,160 +0,0 @@
-
-
-
-
-
-
-
- Cybersource (SOAP Toolkit)
- text
- 500
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- Merchant ID
- adminhtml/system_config_backend_encrypted
- obscure
- 3
- 1
- 1
- 0
-
-
- Security Key
- adminhtml/system_config_backend_encrypted
- obscure
- 4
- 1
- 1
- 0
-
-
- Payment Action
- select
- cybersource/source_paymentAction
- 5
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 6
- 1
- 1
- 0
-
-
- Credit Card Types
- multiselect
- cybersource/source_cctype
- 15
- 1
- 1
- 0
-
-
- Credit Card Verification
- select
- adminhtml/system_config_source_yesno
- 16
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 50
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 51
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Test mode
- select
- adminhtml/system_config_source_yesno
- 55
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 56
- 1
- 1
- 0
-
-
- Sort order
- text
- 100
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Cybersource/sql/cybersource_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Cybersource/sql/cybersource_setup/mysql4-install-0.7.0.php
deleted file mode 100644
index 5cfd6dc68f..0000000000
--- a/app/code/core/Mage/Cybersource/sql/cybersource_setup/mysql4-install-0.7.0.php
+++ /dev/null
@@ -1,54 +0,0 @@
-startSetup();
-
-$installer->run("
-
--- DROP TABLE IF EXISTS `{$this->getTable('cybersource_api_debug')}`;
-CREATE TABLE `{$this->getTable('cybersource_api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `action` varchar(255),
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
- ");
-
-$installer->endSetup();
-
-$installer->addAttribute('quote_payment', 'cybersource_token', array());
-$installer->addAttribute('order_payment', 'cybersource_token', array());
-$installer->addAttribute('invoice', 'cybersource_token', array());
-$installer->addAttribute('creditmemo', 'cybersource_token', array());
-
diff --git a/app/code/core/Mage/Directory/Block/Currency.php b/app/code/core/Mage/Directory/Block/Currency.php
index bfe37ba44c..83fb8359b5 100644
--- a/app/code/core/Mage/Directory/Block/Currency.php
+++ b/app/code/core/Mage/Directory/Block/Currency.php
@@ -86,6 +86,17 @@ public function getSwitchUrl()
return $this->getUrl('directory/currency/switch');
}
+ /**
+ * Return URL for specified currency to switch
+ *
+ * @param string $code Currency code
+ * @return string
+ */
+ public function getSwitchCurrencyUrl($code)
+ {
+ return Mage::helper('directory/url')->getSwitchCurrencyUrl(array('currency' => $code));
+ }
+
/**
* Retrieve Current Currency code
*
@@ -98,7 +109,7 @@ public function getCurrentCurrencyCode()
// to get an invalid (without base rate) currency from code saved in session
$this->setData('current_currency_code', Mage::app()->getStore()->getCurrentCurrency()->getCode());
}
-
+
return $this->_getData('current_currency_code');
}
}
diff --git a/app/code/core/Mage/Directory/Helper/Url.php b/app/code/core/Mage/Directory/Helper/Url.php
index 0c783546c9..aee192f9b2 100644
--- a/app/code/core/Mage/Directory/Helper/Url.php
+++ b/app/code/core/Mage/Directory/Helper/Url.php
@@ -34,19 +34,21 @@ class Mage_Directory_Helper_Url extends Mage_Core_Helper_Url
/**
* Retrieve switch currency url
*
+ * @param array $params Additional url params
* @return string
*/
- public function getSwitchCurrencyUrl()
+ public function getSwitchCurrencyUrl($params = array())
{
+ $params = is_array($params) ? $params : array();
+
if ($this->_getRequest()->getAlias('rewrite_request_path')) {
$url = Mage::app()->getStore()->getBaseUrl() . $this->_getRequest()->getAlias('rewrite_request_path');
}
else {
$url = $this->getCurrentUrl();
}
- $params = array(
- Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => Mage::helper('core')->urlEncode($url)
- );
+ $params[Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED] = Mage::helper('core')->urlEncode($url);
+
return $this->_getUrl('directory/currency/switch', $params);
}
diff --git a/app/code/core/Mage/Directory/Model/Mysql4/Country/Collection.php b/app/code/core/Mage/Directory/Model/Mysql4/Country/Collection.php
index b83e14b5f5..d378f3d1bc 100644
--- a/app/code/core/Mage/Directory/Model/Mysql4/Country/Collection.php
+++ b/app/code/core/Mage/Directory/Model/Mysql4/Country/Collection.php
@@ -109,7 +109,7 @@ public function addCountryIdFilter($countryId)
return $this;
}
- public function toOptionArray($emptyLabel = ' ')
+ public function toOptionArray($emptyLabel = ' ')
{
$options = $this->_toOptionArray('country_id', 'name', array('title'=>'iso2_code'));
diff --git a/app/code/core/Mage/Directory/etc/system.xml b/app/code/core/Mage/Directory/etc/system.xml
index af78725e35..ea046f1694 100644
--- a/app/code/core/Mage/Directory/etc/system.xml
+++ b/app/code/core/Mage/Directory/etc/system.xml
@@ -73,6 +73,7 @@
1
1
1
+ 1
@@ -186,6 +187,7 @@
1
0
0
+ 1
@@ -203,6 +205,7 @@
1
0
0
+ 1
diff --git a/app/code/core/Mage/Downloadable/Helper/Download.php b/app/code/core/Mage/Downloadable/Helper/Download.php
index d8ae34ef47..06d663f6ba 100644
--- a/app/code/core/Mage/Downloadable/Helper/Download.php
+++ b/app/code/core/Mage/Downloadable/Helper/Download.php
@@ -199,8 +199,8 @@ public function getContentType()
{
$handle = $this->_getHandle();
if ($this->_linkType == self::LINK_TYPE_FILE) {
- if (function_exists('mime_content_type')) {
- return mime_content_type($this->_resourceFile);
+ if (function_exists('mime_content_type') && ($contentType = mime_content_type($this->_resourceFile))) {
+ return $contentType;
} else {
return Mage::helper('downloadable/file')->getFileType($this->_resourceFile);
}
diff --git a/app/code/core/Mage/Downloadable/Helper/File.php b/app/code/core/Mage/Downloadable/Helper/File.php
index f826925f1c..340617f318 100644
--- a/app/code/core/Mage/Downloadable/Helper/File.php
+++ b/app/code/core/Mage/Downloadable/Helper/File.php
@@ -767,6 +767,7 @@ public function getAllMineTypes()
'xxyz' => 'chemical/x-xyz',
'xzaz' => 'application/vnd.zzazz.deck+xml',
'xzip' => 'application/zip',
- 'xzmm' => 'application/vnd.handheld-entertainment+xml'
+ 'xzmm' => 'application/vnd.handheld-entertainment+xml',
+ 'xodt' => 'application/x-vnd.oasis.opendocument.spreadsheet'
);
}
diff --git a/app/code/core/Mage/Downloadable/Model/Product/Type.php b/app/code/core/Mage/Downloadable/Model/Product/Type.php
index 486a534c42..4a32ac5f6a 100644
--- a/app/code/core/Mage/Downloadable/Model/Product/Type.php
+++ b/app/code/core/Mage/Downloadable/Model/Product/Type.php
@@ -355,10 +355,8 @@ public function beforeSave($product = null)
if ($this->getLinkSelectionRequired($product)) {
- $this->getProduct($product)->setTypeHasOptions(true);
$this->getProduct($product)->setTypeHasRequiredOptions(true);
} else {
- $this->getProduct($product)->setTypeHasOptions(false);
$this->getProduct($product)->setTypeHasRequiredOptions(false);
}
@@ -380,7 +378,7 @@ public function beforeSave($product = null)
* set this flag "true" to force saving of 'required_options' attribute
*/
$this->getProduct($product)->setCanSaveCustomOptions(true);
-
+ $this->getProduct($product)->setTypeHasOptions($linksExist);
$this->getProduct($product)->setLinksExist($linksExist);
}
diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Config.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Config.php
index 63546cd481..72dcbb65dd 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Config.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Config.php
@@ -47,6 +47,7 @@ public function getAllOptions()
{
if (is_null($this->_options)) {
$this->_options = array();
+ $rootNode = null;
if ($this->_configNodePath) {
$rootNode = Mage::getConfig()->getNode($this->_configNodePath);
}
@@ -60,7 +61,7 @@ public function getAllOptions()
foreach ($options as $option) {
$this->_options[] = array(
'value' => (string)$option->value,
- 'label' => (string)$option->label
+ 'label' => Mage::helper('eav')->__((string)$option->label)
);
}
}
diff --git a/app/code/core/Mage/Eav/Model/Entity/Setup.php b/app/code/core/Mage/Eav/Model/Entity/Setup.php
index 5734c0f5a2..6fc3bc3d84 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Setup.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Setup.php
@@ -988,6 +988,7 @@ public function addAttributeToGroup($entityType, $setId, $groupId, $attributeId,
->where('attribute_group_id=?', $groupId);
$sortOrder = $this->getConnection()->fetchOne($select);
}
+ $sortOrder = is_numeric($sortOrder) ? $sortOrder : 1;
$bind['sort_order'] = $sortOrder;
$this->getConnection()->insert($this->getTable('eav/entity_attribute'), $bind);
}
diff --git a/app/code/core/Mage/Eway/Block/Form.php b/app/code/core/Mage/Eway/Block/Form.php
deleted file mode 100644
index fc990f0840..0000000000
--- a/app/code/core/Mage/Eway/Block/Form.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Eway_Block_Form extends Mage_Payment_Block_Form_Cc
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('eway/form.phtml');
- }
-
-}
diff --git a/app/code/core/Mage/Eway/Block/Info.php b/app/code/core/Mage/Eway/Block/Info.php
deleted file mode 100644
index 70ac6e0f06..0000000000
--- a/app/code/core/Mage/Eway/Block/Info.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
- */
-class Mage_Eway_Block_Info extends Mage_Payment_Block_Info_Cc
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('eway/info.phtml');
- }
-
- public function toPdf()
- {
- $this->setTemplate('eway/pdf/info.phtml');
- return $this->toHtml();
- }
-
-}
diff --git a/app/code/core/Mage/Eway/Block/Secure/Form.php b/app/code/core/Mage/Eway/Block/Secure/Form.php
deleted file mode 100644
index 97e1fa6247..0000000000
--- a/app/code/core/Mage/Eway/Block/Secure/Form.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Eway_Block_Secure_Form extends Mage_Payment_Block_Form
-{
- protected function _construct()
- {
- $this->setTemplate('eway/secure/form.phtml');
- parent::_construct();
- }
-}
diff --git a/app/code/core/Mage/Eway/Block/Secure/Redirect.php b/app/code/core/Mage/Eway/Block/Secure/Redirect.php
deleted file mode 100644
index d260871483..0000000000
--- a/app/code/core/Mage/Eway/Block/Secure/Redirect.php
+++ /dev/null
@@ -1,57 +0,0 @@
-
- */
-class Mage_Eway_Block_Secure_Redirect extends Mage_Core_Block_Abstract
-{
- protected function _toHtml()
- {
- $secure = $this->getOrder()->getPayment()->getMethodInstance();
-
- $form = new Varien_Data_Form();
- $form->setAction($secure->getEwaySecureUrl())
- ->setId('eway_secure_checkout')
- ->setName('eway_secure_checkout')
- ->setMethod('POST')
- ->setUseContainer(true);
- foreach ($secure->getFormFields() as $field=>$value) {
- $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
- }
- $html = '';
- $html.= $this->__('You will be redirected to eWAY 3D-Secure in a few seconds.');
- $html.= $form->toHtml();
- $html.= '';
- $html.= '';
-
- return $html;
- }
-}
diff --git a/app/code/core/Mage/Eway/Block/Shared/Failure.php b/app/code/core/Mage/Eway/Block/Shared/Failure.php
deleted file mode 100644
index cee68baeca..0000000000
--- a/app/code/core/Mage/Eway/Block/Shared/Failure.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- */
-
-class Mage_Eway_Block_Shared_Failure extends Mage_Core_Block_Template
-{
- /**
- * Return Error message
- *
- * @return string
- */
- public function getErrorMessage ()
- {
- $msg = Mage::getSingleton('checkout/session')->getEwayErrorMessage();
- Mage::getSingleton('checkout/session')->unsEwayErrorMessage();
- return $msg;
- }
-
- /**
- * Get continue shopping url
- */
- public function getContinueShoppingUrl()
- {
- return Mage::getUrl('checkout/cart');
- }
-}
diff --git a/app/code/core/Mage/Eway/Block/Shared/Form.php b/app/code/core/Mage/Eway/Block/Shared/Form.php
deleted file mode 100644
index 2ca04700b2..0000000000
--- a/app/code/core/Mage/Eway/Block/Shared/Form.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Eway_Block_Shared_Form extends Mage_Payment_Block_Form
-{
- protected function _construct()
- {
- $this->setTemplate('eway/shared/form.phtml');
- parent::_construct();
- }
-}
diff --git a/app/code/core/Mage/Eway/Block/Shared/Redirect.php b/app/code/core/Mage/Eway/Block/Shared/Redirect.php
deleted file mode 100644
index 87bfdff22b..0000000000
--- a/app/code/core/Mage/Eway/Block/Shared/Redirect.php
+++ /dev/null
@@ -1,58 +0,0 @@
-
- */
-class Mage_Eway_Block_Shared_Redirect extends Mage_Core_Block_Abstract
-{
- protected function _toHtml()
- {
- $shared = $this->getOrder()->getPayment()->getMethodInstance();
-
- $form = new Varien_Data_Form();
- $form->setAction($shared->getEwaySharedUrl())
- ->setId('eway_shared_checkout')
- ->setName('eway_shared_checkout')
- ->setMethod('POST')
- ->setUseContainer(true);
- foreach ($shared->getFormFields() as $field=>$value) {
- $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
- }
-
- $html = '';
- $html.= $this->__('You will be redirected to eWAY in a few seconds.');
- $html.= $form->toHtml();
- $html.= '';
- $html.= '';
-
- return $html;
- }
-}
diff --git a/app/code/core/Mage/Eway/Controller/Abstract.php b/app/code/core/Mage/Eway/Controller/Abstract.php
deleted file mode 100644
index 612d60a145..0000000000
--- a/app/code/core/Mage/Eway/Controller/Abstract.php
+++ /dev/null
@@ -1,178 +0,0 @@
-
- */
-abstract class Mage_Eway_Controller_Abstract extends Mage_Core_Controller_Front_Action
-{
- protected function _expireAjax()
- {
- if (!$this->getCheckout()->getQuote()->hasItems()) {
- $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
- exit;
- }
- }
-
- /**
- * Redirect Block
- * need to be redeclared
- */
- protected $_redirectBlockType;
-
- /**
- * Get singleton of Checkout Session Model
- *
- * @return Mage_Checkout_Model_Session
- */
- public function getCheckout()
- {
- return Mage::getSingleton('checkout/session');
- }
-
- /**
- * when customer select eWay payment method
- */
- public function redirectAction()
- {
- $session = $this->getCheckout();
- $session->setEwayQuoteId($session->getQuoteId());
- $session->setEwayRealOrderId($session->getLastRealOrderId());
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($session->getLastRealOrderId());
- $order->addStatusToHistory($order->getStatus(), Mage::helper('eway')->__('Customer was redirected to eWAY.'));
- $order->save();
-
- $this->getResponse()->setBody(
- $this->getLayout()
- ->createBlock($this->_redirectBlockType)
- ->setOrder($order)
- ->toHtml()
- );
-
- $session->unsQuoteId();
- }
-
- /**
- * eWay returns POST variables to this action
- */
- public function successAction()
- {
- $status = $this->_checkReturnedPost();
-
- $session = $this->getCheckout();
-
- $session->unsEwayRealOrderId();
- $session->setQuoteId($session->getEwayQuoteId(true));
- $session->getQuote()->setIsActive(false)->save();
-
- $order = Mage::getModel('sales/order');
- $order->load($this->getCheckout()->getLastOrderId());
- if($order->getId()) {
- $order->sendNewOrderEmail();
- }
-
- if ($status) {
- $this->_redirect('checkout/onepage/success');
- } else {
- $this->_redirect('*/*/failure');
- }
- }
-
- /**
- * Display failure page if error
- *
- */
- public function failureAction()
- {
- if (!$this->getCheckout()->getEwayErrorMessage()) {
- $this->norouteAction();
- return;
- }
-
- $this->getCheckout()->clear();
-
- $this->loadLayout();
- $this->renderLayout();
- }
-
- /**
- * Checking POST variables.
- * Creating invoice if payment was successfull or cancel order if payment was declined
- */
- protected function _checkReturnedPost()
- {
- if (!$this->getRequest()->isPost()) {
- $this->norouteAction();
- return;
- }
- $status = true;
- $response = $this->getRequest()->getPost();
-
- if ($this->getCheckout()->getEwayRealOrderId() != $response['ewayTrxnNumber'] ||
- $this->getCheckout()->getEwayRealOrderId() != Mage::helper('core')->decrypt($response['eWAYoption2'])) {
- $this->norouteAction();
- return;
- }
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($response['ewayTrxnNumber']);
-
- $paymentInst = $order->getPayment()->getMethodInstance();
- $paymentInst->setResponse($response);
-
- if ($paymentInst->parseResponse()) {
-
- if ($order->canInvoice()) {
- $invoice = $order->prepareInvoice();
- $invoice->register()->capture();
- Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
-
- $paymentInst->setTransactionId($response['ewayTrxnReference']);
- $order->addStatusToHistory($order->getStatus(), Mage::helper('eway')->__('Customer successfully returned from eWAY'));
- }
- } else {
- $paymentInst->setTransactionId($response['ewayTrxnReference']);
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), Mage::helper('eway')->__('Customer was rejected by eWAY'));
- $status = false;
- $this->getCheckout()->setEwayErrorMessage($response['eWAYresponseText']);
- }
-
- $order->save();
-
- return $status;
- }
-
-}
diff --git a/app/code/core/Mage/Eway/Helper/Data.php b/app/code/core/Mage/Eway/Helper/Data.php
deleted file mode 100644
index a2b4284463..0000000000
--- a/app/code/core/Mage/Eway/Helper/Data.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-class Mage_Eway_Helper_Data extends Mage_Core_Helper_Abstract
-{
-
-}
diff --git a/app/code/core/Mage/Eway/Model/Api/Debug.php b/app/code/core/Mage/Eway/Model/Api/Debug.php
deleted file mode 100644
index 9ff7490362..0000000000
--- a/app/code/core/Mage/Eway/Model/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Eway_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('eway/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Eway/Model/Direct.php b/app/code/core/Mage/Eway/Model/Direct.php
deleted file mode 100644
index 23cf0e7c25..0000000000
--- a/app/code/core/Mage/Eway/Model/Direct.php
+++ /dev/null
@@ -1,296 +0,0 @@
-
- */
-class Mage_Eway_Model_Direct extends Mage_Payment_Model_Method_Cc
-{
- protected $_code = 'eway_direct';
-
- protected $_isGateway = true;
- protected $_canAuthorize = false;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = false;
- protected $_canVoid = false;
- protected $_canUseInternal = true;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = true;
- protected $_canSaveCc = true;
-
- protected $_formBlockType = 'eway/form';
- protected $_infoBlockType = 'eway/info';
-
- /**
- * Get debug flag
- *
- * @return string
- */
- public function getDebug()
- {
- return Mage::getStoreConfig('payment/eway_direct/debug_flag');
- }
-
- /**
- * Get flag to use CCV or not
- *
- * @return string
- */
- public function getUseccv()
- {
- return Mage::getStoreConfig('payment/eway_direct/useccv');
- }
-
- /**
- * Get api url of eWAY Direct payment
- *
- * @return string
- */
- public function getApiGatewayUrl()
- {
- $value = Mage::getStoreConfig('payment/eway_direct/api_url');
- if (!$value || $value === false) {
- return 'https://www.eway.com.au/gateway/xmlpayment.asp';
- }
- return $value;
- }
-
- /**
- * Get Customer Id
- *
- * @return string
- */
- public function getCustomerId()
- {
- return Mage::getStoreConfig('payment/eway_direct/customer_id');
- }
-
- /**
- * Get currency that accepted by eWAY account
- *
- * @return string
- */
- public function getAccepteCurrency()
- {
- return Mage::getStoreConfig('payment/' . $this->getCode() . '/currency');
- }
-
- public function validate()
- {
- parent::validate();
- $paymentInfo = $this->getInfoInstance();
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
- $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
- } else {
- $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
- }
- if ($currency_code != $this->getAccepteCurrency()) {
- Mage::throwException(Mage::helper('eway')->__('Selected currency code ('.$currency_code.') is not compatible with eWAY'));
- }
- return $this;
- }
-
- public function capture(Varien_Object $payment, $amount)
- {
- $this->setAmount($amount)
- ->setPayment($payment);
-
- $result = $this->callDoDirectPayment($payment)!==false;
-
- if ($result) {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId());
- } else {
- $e = $this->getError();
- if (isset($e['message'])) {
- $message = Mage::helper('eway')->__('There has been an error processing your payment.') . $e['message'];
- } else {
- $message = Mage::helper('eway')->__('There has been an error processing your payment. Please try later or contact us for help.');
- }
- Mage::throwException($message);
- }
- return $this;
- }
-
- public function cancel(Varien_Object $payment)
- {
- $payment->setStatus(self::STATUS_DECLINED);
- return $this;
- }
-
- /**
- * prepare params to send to gateway
- *
- * @return bool | array
- */
- public function callDoDirectPayment()
- {
- $payment = $this->getPayment();
- $billing = $payment->getOrder()->getBillingAddress();
-
- $invoiceDesc = '';
- $lengs = 0;
- foreach ($payment->getOrder()->getAllItems() as $item) {
- if ($item->getParentItem()) {
- continue;
- }
- if (Mage::helper('core/string')->strlen($invoiceDesc.$item->getName()) > 10000) {
- break;
- }
- $invoiceDesc .= $item->getName() . ', ';
- }
- $invoiceDesc = Mage::helper('core/string')->substr($invoiceDesc, 0, -2);
-
- $address = clone $billing;
- $address->unsFirstname();
- $address->unsLastname();
- $address->unsPostcode();
- $formatedAddress = '';
- $tmpAddress = explode(' ', str_replace("\n", ' ', trim($address->format('text'))));
- foreach ($tmpAddress as $part) {
- if (strlen($part) > 0) $formatedAddress .= $part . ' ';
- }
-// $this->getQuote()->reserveOrderId();
- $xml = "";
- $xml .= "" . $this->getCustomerId() . " ";
- $xml .= "" . ($this->getAmount()*100) . " ";
- $xml .= "" . htmlentities(trim($payment->getCcOwner()), ENT_QUOTES, 'UTF-8') . " ";
- $xml .= "" . $payment->getCcNumber() . " ";
- $xml .= "" . $payment->getCcExpMonth() . " ";
- $xml .= "" . $payment->getCcExpYear() . " ";
- $xml .= "" . '' . " ";
- $xml .= "" . htmlentities(trim($invoiceDesc), ENT_QUOTES, 'UTF-8') . " ";
- $xml .= "" . htmlentities(trim($billing->getFirstname()), ENT_QUOTES, 'UTF-8') . " ";
- $xml .= "" . htmlentities(trim($billing->getLastname()), ENT_QUOTES, 'UTF-8') . " ";
- $xml .= "" . htmlentities(trim($payment->getOrder()->getCustomerEmail()), ENT_QUOTES, 'UTF-8') . " ";
- $xml .= "" . htmlentities(trim($formatedAddress), ENT_QUOTES, 'UTF-8') . " ";
- $xml .= "" . htmlentities(trim($billing->getPostcode()), ENT_QUOTES, 'UTF-8') . " ";
-// $xml .= "" . $this->getQuote()->getReservedOrderId() . " ";
- $xml .= "" . '' . " ";
-
- if ($this->getUseccv()) {
- $xml .= "" . $payment->getCcCid() . " ";
- }
-
- $xml .= "" . '' . " ";
- $xml .= "" . '' . " ";
- $xml .= "" . '' . " ";
-
-
- if (Mage::getStoreConfig('payment/eway_direct/use_anti_fraud')) {
- $xml .= "". Mage::helper('core/http')->getRemoteAddr() ." ";
- $xml .= "". $billing->getCountryId() ." ";
- }
-
- $xml .= " ";
-
- $resultArr = $this->call($xml);
-
- if ($resultArr === false) {
- return false;
- }
-
- $this->setTransactionId($resultArr['ewayTrxnNumber']);
-
- return $resultArr;
- }
-
- /**
- * Send params to gateway
- *
- * @param string $xml
- * @return bool | array
- */
- public function call($xml)
- {
- if ($this->getDebug()) {
- $debug = Mage::getModel('eway/api_debug')
- ->setRequestBody($xml)
- ->save();
- }
-
- $http = new Varien_Http_Adapter_Curl();
- $config = array('timeout' => 30);
-
- $http->setConfig($config);
- $http->write(Zend_Http_Client::POST, $this->getApiGatewayUrl(), '1.1', array(), $xml);
- $response = $http->read();
-
- $response = preg_split('/^\r?$/m', $response, 2);
- $response = trim($response[1]);
-
- if ($this->getDebug()) {
- $debug->setResponseBody($response)->save();
- }
-
- if ($http->getErrno()) {
- $http->close();
- $this->setError(array(
- 'message' => $http->getError()
- ));
- return false;
- }
- $http->close();
-
- $parsedResArr = $this->parseXmlResponse($response);
-
- if ($parsedResArr['ewayTrxnStatus'] == 'True') {
- $this->unsError();
- return $parsedResArr;
- }
-
- if (isset($parsedResArr['ewayTrxnError'])) {
- $this->setError(array(
- 'message' => $parsedResArr['ewayTrxnError']
- ));
- }
-
- return false;
- }
-
- /**
- * parse response of gateway
- *
- * @param string $xmlResponse
- * @return array
- */
- public function parseXmlResponse($xmlResponse)
- {
- $xmlObj = simplexml_load_string($xmlResponse);
- $newResArr = array();
- foreach ($xmlObj as $key => $val) {
- $newResArr[$key] = (string)$val;
- }
-
- return $newResArr;
- }
-
-}
diff --git a/app/code/core/Mage/Eway/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Eway/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index 0b09086bba..0000000000
--- a/app/code/core/Mage/Eway/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Eway_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('eway/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Eway/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/Eway/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index a68ddebd1d..0000000000
--- a/app/code/core/Mage/Eway/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Eway_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('eway/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Eway/Model/Mysql4/Setup.php b/app/code/core/Mage/Eway/Model/Mysql4/Setup.php
deleted file mode 100644
index bb9fd49dc7..0000000000
--- a/app/code/core/Mage/Eway/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,38 +0,0 @@
-
- */
-class Mage_Eway_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
-{
-
-}
diff --git a/app/code/core/Mage/Eway/Model/Secure.php b/app/code/core/Mage/Eway/Model/Secure.php
deleted file mode 100644
index cb61ef1246..0000000000
--- a/app/code/core/Mage/Eway/Model/Secure.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
- */
-class Mage_Eway_Model_Secure extends Mage_Eway_Model_Shared
-{
- protected $_code = 'eway_secure';
-
- protected $_formBlockType = 'eway/secure_form';
- protected $_paymentMethod = 'secure';
-
- /**
- * Get url of eWAY 3D-Secure Payment
- *
- * @return string
- */
- public function getEwaySecureUrl()
- {
- if (!$url = Mage::getStoreConfig('payment/' . $this->getCode() . '/api_url')) {
- $url = 'https://www.eway.com.au/gateway_3d/payment.asp';
- }
- return $url;
- }
-
-}
diff --git a/app/code/core/Mage/Eway/Model/Shared.php b/app/code/core/Mage/Eway/Model/Shared.php
deleted file mode 100644
index b436fdb86b..0000000000
--- a/app/code/core/Mage/Eway/Model/Shared.php
+++ /dev/null
@@ -1,252 +0,0 @@
-
- */
-class Mage_Eway_Model_Shared extends Mage_Payment_Model_Method_Abstract
-{
- protected $_code = 'eway_shared';
-
- protected $_isGateway = false;
- protected $_canAuthorize = false;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = false;
- protected $_canVoid = false;
- protected $_canUseInternal = false;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = false;
-
- protected $_formBlockType = 'eway/shared_form';
- protected $_paymentMethod = 'shared';
-
- protected $_order;
-
- /**
- * Get order model
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder()
- {
- if (!$this->_order) {
- $paymentInfo = $this->getInfoInstance();
- $this->_order = Mage::getModel('sales/order')
- ->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
- }
- return $this->_order;
- }
-
- /**
- * Get Customer Id
- *
- * @return string
- */
- public function getCustomerId()
- {
- return Mage::getStoreConfig('payment/' . $this->getCode() . '/customer_id');
- }
-
- /**
- * Get currency that accepted by eWAY account
- *
- * @return string
- */
- public function getAccepteCurrency()
- {
- return Mage::getStoreConfig('payment/' . $this->getCode() . '/currency');
- }
-
- public function validate()
- {
- parent::validate();
- $paymentInfo = $this->getInfoInstance();
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
- $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
- } else {
- $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
- }
- if ($currency_code != $this->getAccepteCurrency()) {
- Mage::throwException(Mage::helper('eway')->__('Selected currency code ('.$currency_code.') is not compatible with eWAY'));
- }
- return $this;
- }
-
- public function getOrderPlaceRedirectUrl()
- {
- return Mage::getUrl('eway/' . $this->_paymentMethod . '/redirect');
- }
-
- /**
- * prepare params array to send it to gateway page via POST
- *
- * @return array
- */
- public function getFormFields()
- {
- $billing = $this->getOrder()->getBillingAddress();
- $fieldsArr = array();
- $invoiceDesc = '';
- $lengs = 0;
- foreach ($this->getOrder()->getAllItems() as $item) {
- if ($item->getParentItem()) {
- continue;
- }
- if (Mage::helper('core/string')->strlen($invoiceDesc.$item->getName()) > 10000) {
- break;
- }
- $invoiceDesc .= $item->getName() . ', ';
- }
- $invoiceDesc = Mage::helper('core/string')->substr($invoiceDesc, 0, -2);
-
- $address = clone $billing;
- $address->unsFirstname();
- $address->unsLastname();
- $address->unsPostcode();
- $formatedAddress = '';
- $tmpAddress = explode(' ', str_replace("\n", ' ', trim($address->format('text'))));
- foreach ($tmpAddress as $part) {
- if (strlen($part) > 0) $formatedAddress .= $part . ' ';
- }
- $paymentInfo = $this->getInfoInstance();
- $fieldsArr['ewayCustomerID'] = $this->getCustomerId();
- $fieldsArr['ewayTotalAmount'] = ($this->getOrder()->getBaseGrandTotal()*100);
- $fieldsArr['ewayCustomerFirstName'] = $billing->getFirstname();
- $fieldsArr['ewayCustomerLastName'] = $billing->getLastname();
- $fieldsArr['ewayCustomerEmail'] = $this->getOrder()->getCustomerEmail();
- $fieldsArr['ewayCustomerAddress'] = trim($formatedAddress);
- $fieldsArr['ewayCustomerPostcode'] = $billing->getPostcode();
-// $fieldsArr['ewayCustomerInvoiceRef'] = '';
- $fieldsArr['ewayCustomerInvoiceDescription'] = $invoiceDesc;
- $fieldsArr['eWAYSiteTitle '] = Mage::app()->getStore()->getFrontendName();
- $fieldsArr['eWAYAutoRedirect'] = 1;
- $fieldsArr['ewayURL'] = Mage::getUrl('eway/' . $this->_paymentMethod . '/success', array('_secure' => true));
- $fieldsArr['eWAYTrxnNumber'] = $paymentInfo->getOrder()->getRealOrderId();
- $fieldsArr['ewayOption1'] = '';
- $fieldsArr['ewayOption2'] = Mage::helper('core')->encrypt($fieldsArr['eWAYTrxnNumber']);
- $fieldsArr['ewayOption3'] = '';
-
- $request = '';
- foreach ($fieldsArr as $k=>$v) {
- $request .= '<' . $k . '>' . $v . '' . $k . '>';
- }
-
- if ($this->getDebug()) {
- $debug = Mage::getModel('eway/api_debug')
- ->setRequestBody($request)
- ->save();
- $fieldsArr['ewayOption1'] = $debug->getId();
- }
-
- return $fieldsArr;
- }
-
- /**
- * Get url of eWAY Shared Payment
- *
- * @return string
- */
- public function getEwaySharedUrl()
- {
- if (!$url = Mage::getStoreConfig('payment/eway_shared/api_url')) {
- $url = 'https://www.eway.com.au/gateway/payment.asp';
- }
- return $url;
- }
-
- /**
- * Get debug flag
- *
- * @return string
- */
- public function getDebug()
- {
- return Mage::getStoreConfig('payment/' . $this->getCode() . '/debug_flag');
- }
-
- public function capture(Varien_Object $payment, $amount)
- {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId());
-
- return $this;
- }
-
- public function cancel(Varien_Object $payment)
- {
- $payment->setStatus(self::STATUS_DECLINED)
- ->setLastTransId($this->getTransactionId());
-
- return $this;
- }
-
- /**
- * parse response POST array from gateway page and return payment status
- *
- * @return bool
- */
- public function parseResponse()
- {
- $response = $this->getResponse();
-
- if ($this->getDebug()) {
- $debug = Mage::getModel('eway/api_debug')
- ->load($response['eWAYoption1'])
- ->setResponseBody(print_r($response, 1))
- ->save();
- }
-
- if ($response['ewayTrxnStatus'] == 'True') {
- return true;
- }
- return false;
- }
-
- /**
- * Return redirect block type
- *
- * @return string
- */
- public function getRedirectBlockType()
- {
- return $this->_redirectBlockType;
- }
-
- /**
- * Return payment method type string
- *
- * @return string
- */
- public function getPaymentMethodType()
- {
- return $this->_paymentMethod;
- }
-}
diff --git a/app/code/core/Mage/Eway/Model/Source/Cctype.php b/app/code/core/Mage/Eway/Model/Source/Cctype.php
deleted file mode 100644
index fa7e9bb201..0000000000
--- a/app/code/core/Mage/Eway/Model/Source/Cctype.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Eway_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
-{
- public function getAllowedTypes()
- {
- return array('VI', 'MC', 'AE', 'DICL', 'JCB');
- }
-}
diff --git a/app/code/core/Mage/Eway/controllers/SharedController.php b/app/code/core/Mage/Eway/controllers/SharedController.php
deleted file mode 100644
index 7b7fb08966..0000000000
--- a/app/code/core/Mage/Eway/controllers/SharedController.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Eway_SharedController extends Mage_Eway_Controller_Abstract
-{
- /**
- * Redirect Block Type
- *
- * @var string
- */
- protected $_redirectBlockType = 'eway/shared_redirect';
-}
diff --git a/app/code/core/Mage/Eway/etc/config.xml b/app/code/core/Mage/Eway/etc/config.xml
deleted file mode 100644
index db507f6eb3..0000000000
--- a/app/code/core/Mage/Eway/etc/config.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
-
-
- 0.1.0
-
-
-
-
-
- Mage_Eway_Model
- eway_mysql4
-
-
- Mage_Eway_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Eway
- Mage_Eway_Model_Mysql4_Setup
-
-
-
-
- Mage_Eway_Block
-
-
-
-
-
- JCB
- JCB
- 50
-
-
- DICL
- Diners Club
- 60
-
-
-
-
-
-
-
- /eway/shared
-
-
-
- standard
-
- Mage_Eway
- eway
-
-
-
-
-
-
-
- Mage_Eway.csv
-
-
-
-
-
-
-
- eway.xml
-
-
-
-
-
-
-
-
-
- Mage_Eway.csv
-
-
-
-
-
-
-
-
-
- AUD
- authorize_capture
- eway/direct
- eWAY Direct
- processing
- AE,VI,MC,DICL,JCB
- 0
- 0
-
-
-
- AUD
- eway/shared
- eWAY Shared
- processing
- 0
-
-
-
- AUD
- eway/secure
- eWAY 3D-Secure
- processing
- 0
-
-
-
-
diff --git a/app/code/core/Mage/Eway/etc/system.xml b/app/code/core/Mage/Eway/etc/system.xml
deleted file mode 100644
index 0582ba05f1..0000000000
--- a/app/code/core/Mage/Eway/etc/system.xml
+++ /dev/null
@@ -1,354 +0,0 @@
-
-
-
-
-
-
-
- eWAY Direct
- text
- 201
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- Customer ID
- obscure
- adminhtml/system_config_backend_encrypted
- 3
- 1
- 1
- 0
-
-
- Accepted currency
- select
- adminhtml/system_config_source_currency
- 4
- 1
- 1
- 0
-
-
- Use Beagle Anti-Fraud
- Please set Beagle Anti-Fraud Gateway URL
- select
- adminhtml/system_config_source_yesno
- 4
- 1
- 1
- 0
-
-
- API Gateway URL
- text
- 5
- 1
- 1
- 0
-
-
- Debug Flag
- select
- adminhtml/system_config_source_yesno
- 6
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 7
- 1
- 1
- 0
-
-
- Credit Card Types
- multiselect
- eway/source_cctype
- 8
- 1
- 1
- 0
-
-
- Credit Card Verification
- select
- adminhtml/system_config_source_yesno
- 9
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 10
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 11
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 12
- 1
- 1
- 0
-
-
-
-
- eWAY Shared
- text
- 202
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- Customer ID
- obscure
- adminhtml/system_config_backend_encrypted
- 3
- 1
- 1
- 0
-
-
- Accepted currency
- select
- adminhtml/system_config_source_currency
- 4
- 1
- 1
- 0
-
-
- API Gateway URL
- text
- 5
- 1
- 1
- 0
-
-
- Debug Flag
- select
- adminhtml/system_config_source_yesno
- 6
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 7
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 8
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 9
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 10
- 1
- 1
- 0
-
-
-
-
- eWAY 3D-Secure
- text
- 203
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Title
- text
- 2
- 1
- 1
- 1
-
-
- Customer ID
- obscure
- adminhtml/system_config_backend_encrypted
- 3
- 1
- 1
- 0
-
-
- Accepted currency
- select
- adminhtml/system_config_source_currency
- 4
- 1
- 1
- 0
-
-
- API Gateway URL
- text
- 5
- 1
- 1
- 0
-
-
- Debug Flag
- select
- adminhtml/system_config_source_yesno
- 6
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 7
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 8
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 9
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 10
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Eway/sql/eway_setup/mysql4-install-0.1.0.php b/app/code/core/Mage/Eway/sql/eway_setup/mysql4-install-0.1.0.php
deleted file mode 100644
index 5ae7a86c74..0000000000
--- a/app/code/core/Mage/Eway/sql/eway_setup/mysql4-install-0.1.0.php
+++ /dev/null
@@ -1,46 +0,0 @@
-startSetup();
-
-$installer->run("
-
--- DROP TABLE IF EXISTS `{$this->getTable('eway/api_debug')}`;
-CREATE TABLE `{$this->getTable('eway/api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Flo2Cash/Block/Form.php b/app/code/core/Mage/Flo2Cash/Block/Form.php
deleted file mode 100644
index 6aa0622e51..0000000000
--- a/app/code/core/Mage/Flo2Cash/Block/Form.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Flo2Cash_Block_Form extends Mage_Payment_Block_Form_Cc
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('flo2cash/form.phtml');
- }
-}
diff --git a/app/code/core/Mage/Flo2Cash/Block/Info.php b/app/code/core/Mage/Flo2Cash/Block/Info.php
deleted file mode 100644
index 4dc447ec33..0000000000
--- a/app/code/core/Mage/Flo2Cash/Block/Info.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
- */
-class Mage_Flo2Cash_Block_Info extends Mage_Payment_Block_Info_Cc
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('flo2cash/info.phtml');
- }
-
- public function toPdf()
- {
- $this->setTemplate('flo2cash/pdf/info.phtml');
- return $this->toHtml();
- }
-
-}
diff --git a/app/code/core/Mage/Flo2Cash/Helper/Data.php b/app/code/core/Mage/Flo2Cash/Helper/Data.php
deleted file mode 100644
index 48a63f1c9f..0000000000
--- a/app/code/core/Mage/Flo2Cash/Helper/Data.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-class Mage_Flo2Cash_Helper_Data extends Mage_Core_Helper_Abstract
-{
-
-}
diff --git a/app/code/core/Mage/Flo2Cash/Model/Api/Debug.php b/app/code/core/Mage/Flo2Cash/Model/Api/Debug.php
deleted file mode 100644
index 1de21ac89b..0000000000
--- a/app/code/core/Mage/Flo2Cash/Model/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Flo2Cash_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('flo2cash/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Flo2Cash/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Flo2Cash/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index 3c51a72154..0000000000
--- a/app/code/core/Mage/Flo2Cash/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Flo2Cash_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('flo2cash/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Flo2Cash/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/Flo2Cash/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index 04ee7b7c88..0000000000
--- a/app/code/core/Mage/Flo2Cash/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Flo2Cash_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('flo2cash/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Flo2Cash/Model/Mysql4/Setup.php b/app/code/core/Mage/Flo2Cash/Model/Mysql4/Setup.php
deleted file mode 100644
index 0ade30fadd..0000000000
--- a/app/code/core/Mage/Flo2Cash/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-class Mage_Flo2Cash_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
-{
-
-}
diff --git a/app/code/core/Mage/Flo2Cash/Model/Source/Cctype.php b/app/code/core/Mage/Flo2Cash/Model/Source/Cctype.php
deleted file mode 100644
index d0d2124598..0000000000
--- a/app/code/core/Mage/Flo2Cash/Model/Source/Cctype.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Flo2Cash_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
-{
- public function getAllowedTypes()
- {
- return array('VI', 'MC', 'AE', 'DICL');
- }
-}
diff --git a/app/code/core/Mage/Flo2Cash/Model/Source/PaymentAction.php b/app/code/core/Mage/Flo2Cash/Model/Source/PaymentAction.php
deleted file mode 100644
index 27d4e087ec..0000000000
--- a/app/code/core/Mage/Flo2Cash/Model/Source/PaymentAction.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- */
-class Mage_Flo2Cash_Model_Source_PaymentAction
-{
- public function toOptionArray()
- {
- return array(
- array(
- 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
- 'label' => Mage::helper('flo2cash')->__('Authorize')
- ),
- array(
- 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
- 'label' => Mage::helper('flo2cash')->__('Purchase')
- ),
- );
- }
-}
diff --git a/app/code/core/Mage/Flo2Cash/Model/Web.php b/app/code/core/Mage/Flo2Cash/Model/Web.php
deleted file mode 100644
index 45698a0258..0000000000
--- a/app/code/core/Mage/Flo2Cash/Model/Web.php
+++ /dev/null
@@ -1,298 +0,0 @@
-
- */
-class Mage_Flo2Cash_Model_Web extends Mage_Payment_Model_Method_Cc
-{
- const WSDL_URL_DEMO = 'http://demo.flo2cash.co.nz/ws/paynzws.asmx?wsdl';
- const WSDL_URL_LIVE = 'https://secure.flo2cash.co.nz/ws/paynzws.asmx?wsdl';
-
- protected $_code = 'flo2cash_web';
-
- protected $_allowCurrencyCode = array('NZD');
-
- /**
- * Availability options
- */
- protected $_isGateway = true;
- protected $_canAuthorize = true;
- protected $_canCapture = true;
- protected $_canCapturePartial = true;
- protected $_canRefund = true;
- protected $_canVoid = false;
- protected $_canUseInternal = true;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = true;
- protected $_canSaveCc = false;
-
- protected $_ccTypesConvert = array(
- 'VI' => 'VISA',
- 'MC' => 'MC',
- 'DICL' => 'DINERS',
- 'AE' => 'AMEX'
- );
-
- const TRANSACTION_TYPE_PURCHASE = 1;
- const TRANSACTION_TYPE_REFUND = 2;
- const TRANSACTION_TYPE_AUTHORISE = 3;
- const TRANSACTION_TYPE_CAPTURE = 4;
-
- const TRANSACTION_STATUS_ACCEPTED = 1;
- const TRANSACTION_STATUS_DECLINED = 2;
-
- protected $_formBlockType = 'flo2cash/form';
- protected $_infoBlockType = 'flo2cash/info';
-
- /**
- * Get Account Id for selected payment action
- *
- * @return string
- */
- public function getAccountId()
- {
- if ($this->getConfigData('payment_action') == self::ACTION_AUTHORIZE_CAPTURE) {
- $acountId = $this->getConfigData('payzn_purchase_account_id');
- } else {
- $acountId = $this->getConfigData('payzn_account_id');
- }
- return $acountId;
- }
-
- /**
- * validate the currency code is avaialable to use for Flo2Cash Basic or not
- *
- * @return bool
- */
- public function validate()
- {
- parent::validate();
- $paymentInfo = $this->getInfoInstance();
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
- $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
- } else {
- $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
- }
- if (!in_array($currency_code, $this->_allowCurrencyCode)) {
- Mage::throwException(Mage::helper('flo2cash')->__('Selected currency code (%s) is not compatible with Flo2Cash', $currency_code));
- }
- return $this;
- }
-
- public function authorize(Varien_Object $payment, $amount)
- {
- $txnDetails = $this->_prepareTxnDetails($payment, $amount);
-
- $response = $this->_sendRequest($txnDetails);
-
- if ($response['txn_status'] == self::TRANSACTION_STATUS_DECLINED) {
- Mage::throwException(Mage::helper('flo2cash')->__('Payment transaction has been declined.'));
- }
-
- $payment->setStatus(self::STATUS_APPROVED);
- $payment->setCcTransId($response['transaction_id']);
- $payment->setFlo2cashAccountId($response['paynz_account_id']);
-
- return $this;
- }
-
- public function capture(Varien_Object $payment, $amount)
- {
- $txnDetails = $this->_prepareTxnDetails($payment, $amount);
-
- $response = $this->_sendRequest($txnDetails);
-
- if ($response['txn_status'] == self::TRANSACTION_STATUS_DECLINED) {
- Mage::throwException(Mage::helper('flo2cash')->__('Payment transaction has been declined.'));
- }
-
- $payment->setStatus(self::STATUS_APPROVED);
- $payment->setLastTransId($response['transaction_id']);
- $payment->setFlo2cashAccountId($response['paynz_account_id']);
-
- return $this;
- }
-
- public function void(Varien_Object $payment)
- {
- $payment->setStatus(self::STATUS_SUCCESS );
- return $this;
- }
-
- public function refund(Varien_Object $payment, $amount)
- {
- if ($payment->getRefundTransactionId() && $amount>0) {
-
- $transId = $payment->getCcTransId();
- //if transaction type was purchase (authorize & capture)
- if (is_null($transId)) {
- $transId = $payment->getLastTransId();
- }
-
- $txnDetails = array(
- 'txn_type' => self::TRANSACTION_TYPE_REFUND,
- 'refund_transaction_id' => $transId,
- 'paynz_account_id' => $payment->getFlo2cashAccountId(),
- 'amount' => sprintf('%.2f', $amount)
- );
- } else {
- Mage::throwException(Mage::helper('flo2cash')->__('Error in refunding the payment.'));
- }
-
- $response = $this->_sendRequest($txnDetails);
-
- if ($response['txn_status'] == self::TRANSACTION_STATUS_DECLINED) {
- Mage::throwException(Mage::helper('flo2cash')->__('Payment transaction has been declined.'));
- }
-
- $payment->setLastTransId($response['transaction_id']);
-
- return $this;
- }
-
- /**
- * Sending SOAP request to gateway
- *
- * @param array $txnDetails
- * @return void
- */
- protected function _sendRequest($txnDetails)
- {
- if ($this->getConfigData('demo_mode')) {
- $url = self::WSDL_URL_DEMO;
- } else {
- $url = self::WSDL_URL_LIVE;
- }
-
- $client = new SoapClient($url);
-
- $parameters = array(
- 'username' => $this->getConfigData('username'),
- 'password' => $this->getConfigData('password'),
- 'txn_details' => $txnDetails
- );
-
- try {
- $response = $client->ProcessPayment($parameters);
-
- if ($this->getConfigData('debug_flag')) {
- $debug = Mage::getModel('flo2cash/api_debug')
- ->setRequestBody(print_r($parameters, true))
- ->setResponseBody(print_r($response, true))
- ->save();
- }
- return (array)$response->ProcessPaymentResult;
- } catch (SoapFault $e) {
- if ($this->getConfigData('debug_flag')) {
- $debug = Mage::getModel('flo2cash/api_debug')
- ->setRequestBody(print_r($parameters, true))
- ->setException($e->getMessage())
- ->save();
- }
-
- if (strpos($e->getMessage(), ' ---> ') !== FALSE) {
- list($title, $error) = explode(' ---> ', $e->getMessage());
- } else {
- $error = $e->getMessage();
- }
-
- Mage::throwException(Mage::helper('flo2cash')->__('Gateway returned an error message: %s', $error));
- }
- }
-
- /**
- * Preapare basic paramters for transaction
- *
- * @param Varien_Object $payment
- * @param decimal $amount
- * @return array
- */
- protected function _prepareTxnDetails(Varien_Object $payment, $amount)
- {
- if ($payment->getCcTransId()) {
- $txnDetails = array(
- 'txn_type' => self::TRANSACTION_TYPE_CAPTURE,
- 'capture_transaction_id' => $payment->getCcTransId()
- );
- } else {
- $billingAddress = $payment->getOrder()->getBillingAddress();
-
- if ($payment->getOrder()->getCustomerEmail()) {
- $customerEmail = $payment->getOrder()->getCustomerEmail();
- } elseif ($billingAddress->getEmail()) {
- $customerEmail = $billingAddress->getEmail();
- } else {
- $customerEmail = '';
- }
-
- $txnDetails = array(
- 'card_holder_name' => $payment->getCcOwner(),
- 'card_number' => $payment->getCcNumber(),
- 'card_type' => $this->_convertCcType($payment->getCcType()),
- 'card_expiry' => sprintf('%02d', $payment->getCcExpMonth()).substr($payment->getCcExpYear(), 2, 2),
- 'card_csc' => $payment->getCcCid(),
- 'customer_email' => $customerEmail
- );
-
- if ($this->getConfigData('payment_action') == self::ACTION_AUTHORIZE) {
- $txnDetails['txn_type'] = self::TRANSACTION_TYPE_AUTHORISE;
- } else {
- $txnDetails['txn_type'] = self::TRANSACTION_TYPE_PURCHASE;
- }
- }
-
- $accountId = $payment->getFlo2cashAccountId();
- //if transaction type is authorize & capture or only authorize
- if (is_null($accountId)) {
- $accountId = $this->getAccountId();
- }
-
- $txnDetails = array_merge($txnDetails, array(
- //'txn_reference' => $payment->getOrder()->getIncrementId(),
- 'merchant_reference' => $payment->getOrder()->getIncrementId(),
- 'paynz_account_id' => $accountId,
- 'amount' => sprintf('%.2f', $amount),
- ));
-
- return $txnDetails;
- }
-
- /**
- * Converst CC Types Code from Magento to Flo2Cash
- *
- * @param string $magentoCcType
- * @return string
- */
- protected function _convertCcType($magentoCcType = 'VI')
- {
- return $this->_ccTypesConvert[$magentoCcType];
- }
-}
diff --git a/app/code/core/Mage/Flo2Cash/etc/config.xml b/app/code/core/Mage/Flo2Cash/etc/config.xml
deleted file mode 100644
index 9d15f1c54c..0000000000
--- a/app/code/core/Mage/Flo2Cash/etc/config.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
- 0.1.1
-
-
-
-
-
- Mage_Flo2Cash_Model
- flo2cash_mysql4
-
-
- Mage_Flo2Cash_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Flo2Cash
- Mage_Flo2Cash_Model_Mysql4_Setup
-
-
-
-
- Mage_Flo2Cash_Block
-
-
- Mage_Flo2Cash_Helper
-
-
-
-
-
- DICL
- Diners Club
- 60
-
-
-
-
-
-
-
-
- standard
-
- Mage_Flo2Cash
- flo2cash
-
-
-
-
-
-
-
- Mage_Flo2Cash.csv
-
-
-
-
-
-
-
- flo2cash.xml
-
-
-
-
-
-
-
-
-
- Mage_Flo2Cash.csv
-
-
-
-
-
-
-
-
- Flo2Cash Web Service
- AE,VI,MC,DICL
- 0
- flo2cash/web
-
-
-
-
diff --git a/app/code/core/Mage/Flo2Cash/etc/system.xml b/app/code/core/Mage/Flo2Cash/etc/system.xml
deleted file mode 100644
index 3522a3ca5e..0000000000
--- a/app/code/core/Mage/Flo2Cash/etc/system.xml
+++ /dev/null
@@ -1,176 +0,0 @@
-
-
-
-
-
-
-
- Flo2Cash Payment Web Service
- text
- 501
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 0
- 1
- 1
- 0
-
-
- Title
- text
- 10
- 1
- 1
- 1
-
-
- Username
- text
- 20
- 1
- 1
- 0
-
-
- Password
- text
- 30
- 1
- 1
- 0
-
-
- Account number
- For Authorize or Capture Transactions only
- text
- 31
- 1
- 1
- 0
-
-
- Account number
- For Purchase Transactions only
- text
- 32
- 1
- 1
- 0
-
-
- Demo mode
- select
- adminhtml/system_config_source_yesno
- 33
- 1
- 1
- 0
-
-
- Payment Action
- select
- flo2cash/source_paymentAction
- 40
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 50
- 1
- 1
- 0
-
-
- Credit Card Types
- multiselect
- flo2cash/source_cctype
- 60
- 1
- 1
- 0
-
-
- Credit Card Verification
- select
- adminhtml/system_config_source_yesno
- 70
- 1
- 1
- 0
-
-
- Debug Flag
- select
- adminhtml/system_config_source_yesno
- 75
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 80
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 90
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 100
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Flo2Cash/sql/flo2cash_setup/mysql4-install-0.1.0.php b/app/code/core/Mage/Flo2Cash/sql/flo2cash_setup/mysql4-install-0.1.0.php
deleted file mode 100644
index c364ce918e..0000000000
--- a/app/code/core/Mage/Flo2Cash/sql/flo2cash_setup/mysql4-install-0.1.0.php
+++ /dev/null
@@ -1,47 +0,0 @@
-startSetup();
-
-$installer->run("
-
-DROP TABLE IF EXISTS `{$this->getTable('flo2cash/api_debug')}`;
-CREATE TABLE `{$this->getTable('flo2cash/api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- `exception` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/GiftMessage/Helper/Message.php b/app/code/core/Mage/GiftMessage/Helper/Message.php
index 09cc65758a..e24afadb67 100644
--- a/app/code/core/Mage/GiftMessage/Helper/Message.php
+++ b/app/code/core/Mage/GiftMessage/Helper/Message.php
@@ -126,12 +126,12 @@ public function isMessagesAvailable($type, Varien_Object $entity, $store=null)
}
if ($type=='item') {
- return $resultItems && $this->_getDependenceFromStoreConfig(
+ return !$entity->getProduct()->isVirtual() && $resultItems && $this->_getDependenceFromStoreConfig(
$entity->getProduct()->getGiftMessageAvailable(),
$store
);
} elseif ($type=='order_item') {
- return $resultItems && $this->_getDependenceFromStoreConfig(
+ return !$entity->getIsVirtual() && $resultItems && $this->_getDependenceFromStoreConfig(
(is_null($entity->getGiftMessageAvailable()) ? 2 : $entity->getGiftMessageAvailable()),
$store
);
@@ -148,7 +148,7 @@ public function isMessagesAvailable($type, Varien_Object $entity, $store=null)
->getGiftMessageAvailable()
);
}
- return $this->_getDependenceFromStoreConfig(
+ return !$entity->getProduct()->isVirtual() && $this->_getDependenceFromStoreConfig(
$this->getCached('address_item_' . $entity->getProductId()),
$store
);
diff --git a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
index 8da91fda9b..b4dba8dd52 100644
--- a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
+++ b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
@@ -93,7 +93,7 @@ public function getOrderHtml()
$html = '';
@@ -171,14 +171,14 @@ protected function _toHtml()
-
diff --git a/app/code/core/Mage/GoogleBase/Model/Service.php b/app/code/core/Mage/GoogleBase/Model/Service.php
index 522d84fda9..8a8976cb3b 100644
--- a/app/code/core/Mage/GoogleBase/Model/Service.php
+++ b/app/code/core/Mage/GoogleBase/Model/Service.php
@@ -33,6 +33,13 @@
*/
class Mage_GoogleBase_Model_Service extends Varien_Object
{
+ /**
+ * Client instance identifier in registry
+ *
+ * @var string
+ */
+ protected $_clientRegistryId = 'GBASE_HTTP_CLIENT';
+
/**
* Retutn Google Base Client Instance
*
@@ -47,11 +54,14 @@ public function getClient($storeId = null, $loginToken = null, $loginCaptcha = n
// 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,
- Zend_Gdata_ClientLogin::CLIENTLOGIN_URI,
- $type
- );
+ if (! Mage::registry($this->_clientRegistryId)) {
+ $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Gbase::AUTH_SERVICE_NAME, null, '',
+ $loginToken, $loginCaptcha,
+ Zend_Gdata_ClientLogin::CLIENTLOGIN_URI,
+ $type
+ );
+ Mage::register($this->_clientRegistryId, $client);
+ }
} catch (Zend_Gdata_App_CaptchaRequiredException $e) {
throw $e;
} catch (Zend_Gdata_App_HttpException $e) {
@@ -60,7 +70,7 @@ public function getClient($storeId = null, $loginToken = null, $loginCaptcha = n
Mage::throwException($errorMsg . Mage::helper('googlebase')->__('Error: %s', $e->getMessage()));
}
- return $client;
+ return Mage::registry($this->_clientRegistryId);
}
/**
diff --git a/app/code/core/Mage/GoogleBase/Model/Service/Item.php b/app/code/core/Mage/GoogleBase/Model/Service/Item.php
index 7e1917f3a9..55ac08b5a2 100644
--- a/app/code/core/Mage/GoogleBase/Model/Service/Item.php
+++ b/app/code/core/Mage/GoogleBase/Model/Service/Item.php
@@ -280,7 +280,15 @@ protected function _setUniversalData()
$entry->setContent($content);
}
- $this->_setAttributePrice(false, $object->getPrice());
+ $attributeValues = $this->getAttributeValues();
+
+ if (isset($attributeValues['price']['value']) && floatval($attributeValues['price']['value']) > 0) {
+ $price = $attributeValues['price']['value'];
+ } else {
+ $price = $object->getPrice();
+ }
+
+ $this->_setAttributePrice(false, $price);
if ($object->getQuantity()) {
$quantity = $object->getQuantity() ? max(1, (int)$object->getQuantity()) : 1;
diff --git a/app/code/core/Mage/GoogleBase/controllers/ItemsController.php b/app/code/core/Mage/GoogleBase/controllers/ItemsController.php
index ab4e55a543..6c1601db00 100644
--- a/app/code/core/Mage/GoogleBase/controllers/ItemsController.php
+++ b/app/code/core/Mage/GoogleBase/controllers/ItemsController.php
@@ -45,6 +45,10 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Google base'))
+ ->_title($this->__('Manage Items'));
+
if (0 === (int)$this->getRequest()->getParam('store')) {
$this->_redirect('*/*/', array('store' => Mage::app()->getAnyStoreView()->getId(), '_current' => true));
return;
@@ -91,29 +95,34 @@ public function gridAction()
public function massAddAction()
{
$storeId = $this->_getStore()->getId();
- $productIds = $this->getRequest()->getParam('product');
+ $productIds = $this->getRequest()->getParam('product', null);
$totalAdded = 0;
try {
- foreach ($productIds as $productId) {
- $product = Mage::getSingleton('catalog/product')
- ->setStoreId($storeId)
- ->load($productId);
-
- if ($product->getId()) {
- Mage::getModel('googlebase/item')
- ->setProduct($product)
- ->insertItem()
- ->save();
-
- $totalAdded++;
+ if (is_array($productIds)) {
+ foreach ($productIds as $productId) {
+ $product = Mage::getSingleton('catalog/product')
+ ->setStoreId($storeId)
+ ->load($productId);
+
+ if ($product->getId()) {
+ Mage::getModel('googlebase/item')
+ ->setProduct($product)
+ ->insertItem()
+ ->save();
+
+ $totalAdded++;
+ }
}
}
+
if ($totalAdded > 0) {
$this->_getSession()->addSuccess(
$this->__('Total of %d product(s) were successfully added to Google Base', $totalAdded)
);
+ } elseif (is_null($productIds)) {
+ $this->_getSession()->addError($this->__('Session expired during export. Please, revise exported products and repeat a process if necessary'));
} else {
$this->_getSession()->addError($this->__('No products were added to Google Base'));
}
diff --git a/app/code/core/Mage/GoogleBase/controllers/TypesController.php b/app/code/core/Mage/GoogleBase/controllers/TypesController.php
index f280ce5625..56914a104a 100644
--- a/app/code/core/Mage/GoogleBase/controllers/TypesController.php
+++ b/app/code/core/Mage/GoogleBase/controllers/TypesController.php
@@ -48,6 +48,10 @@ public function postDispatch()
protected function _initItemType()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Google base'))
+ ->_title($this->__('Manage Attributes'));
+
Mage::register('current_item_type', Mage::getModel('googlebase/type'));
$typeId = $this->getRequest()->getParam('id');
if (!is_null($typeId)) {
@@ -66,6 +70,10 @@ protected function _initAction()
public function indexAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Google base'))
+ ->_title($this->__('Manage Attributes'));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('googlebase')->__('Item Types'), Mage::helper('googlebase')->__('Item Types'))
->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types'))
@@ -86,6 +94,9 @@ public function newAction()
{
try {
$this->_initItemType();
+
+ $this->_title($this->__('New ItemType'));
+
$this->_initAction()
->_addBreadcrumb(Mage::helper('googlebase')->__('New Item Type'), Mage::helper('adminhtml')->__('New Item Type'))
->_addContent($this->getLayout()->createBlock('googlebase/adminhtml_types_edit'))
@@ -98,6 +109,10 @@ public function newAction()
public function editAction()
{
+ $this->_title($this->__('Catalog'))
+ ->_title($this->__('Google base'))
+ ->_title($this->__('Manage Attributes'));
+
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('googlebase/type');
@@ -113,6 +128,8 @@ public function editAction()
}
}
+ $this->_title($this->__('Edit Item Type'));
+
Mage::register('current_item_type', $model);
Mage::register('attributes', $result);
diff --git a/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php b/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php
index 44d78bff20..43b36aaa1f 100644
--- a/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php
+++ b/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Callback.php
@@ -67,7 +67,7 @@ public function process()
try {
$this->$method();
} catch (Exception $e) {
- $this->getGResponse()->log->logError($e->getMessage());
+ $this->getGResponse()->log->logError($e->__toString());
}
$response = ob_get_flush();
@@ -115,7 +115,10 @@ protected function _responseMerchantCalculationCallback()
$merchantCalculations = new GoogleMerchantCalculations($this->getCurrency());
$quoteId = $this->getData('root/shopping-cart/merchant-private-data/quote-id/VALUE');
- $quote = Mage::getModel('sales/quote')->load($quoteId);
+ $storeId = $this->getData('root/shopping-cart/merchant-private-data/store-id/VALUE');
+ $quote = Mage::getModel('sales/quote')
+ ->setStoreId($storeId)
+ ->load($quoteId);
$billingAddress = $quote->getBillingAddress();
$address = $quote->getShippingAddress();
@@ -161,7 +164,10 @@ protected function _responseMerchantCalculationCallback()
->setPostcode($googleAddress['postal-code']['VALUE'])
->setLimitCarrier($limitCarrier);
- $address->setCollectShippingRates(true)->collectShippingRates();
+ $address->setCollectShippingRates(true)
+ ->collectShippingRates()
+ ->collectTotals();
+ $billingAddress->collectTotals();
if ($gRequestMethods = $this->getData('root/calculate/shipping/method')) {
$carriers = array();
@@ -231,9 +237,6 @@ protected function _responseMerchantCalculationCallback()
if ($this->getData('root/calculate/tax/VALUE')=='true') {
$address->setShippingMethod($rateCodes[$methodName]);
- $address->setCollectShippingRates(true)->collectTotals();
- $billingAddress->setCollectShippingRates(true)->collectTotals();
-
$taxAmount = $address->getBaseTaxAmount();
$taxAmount += $billingAddress->getBaseTaxAmount();
@@ -278,7 +281,11 @@ protected function _responseNewOrderNotification()
// IMPORT GOOGLE ORDER DATA INTO QUOTE
$quoteId = $this->getData('root/shopping-cart/merchant-private-data/quote-id/VALUE');
- $quote = Mage::getModel('sales/quote')->load($quoteId)->setIsActive(true);
+ $storeId = $this->getData('root/shopping-cart/merchant-private-data/store-id/VALUE');
+ $quote = Mage::getModel('sales/quote')
+ ->setStoreId($storeId)
+ ->load($quoteId)
+ ->setIsActive(true);
//
// $quoteItems = $quote->getItemsCollection();
// foreach ($this->getData('root/shopping-cart/items') as $item) {
@@ -295,8 +302,7 @@ protected function _responseNewOrderNotification()
$shipping = $this->_importGoogleAddress($this->getData('root/buyer-shipping-address'));
$quote->setShippingAddress($shipping);
-
- $quote->collectTotals();
+ $quote->getPayment()->importData(array('method'=>'googlecheckout'));
$this->_importGoogleTotals($quote->getShippingAddress());
@@ -333,7 +339,11 @@ protected function _responseNewOrderNotification()
#$order->setPayment($convertQuote->paymentToOrderPayment($quote->getPayment()));
foreach ($quote->getAllItems() as $item) {
- $order->addItem($convertQuote->itemToOrderItem($item));
+ $orderItem = $convertQuote->itemToOrderItem($item);
+ if ($item->getParentItem()) {
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
+ }
+ $order->addItem($orderItem);
}
$payment = Mage::getModel('sales/order_payment')->setMethod('googlecheckout');
@@ -367,11 +377,11 @@ protected function _responseNewOrderNotification()
$order->sendNewOrderEmail();
- Mage::getSingleton('checkout/session')
- ->setLastQuoteId($quote->getId())
- ->setLastOrderId($order->getId())
- ->setLastSuccessQuoteId($quote->getId())
- ->setLastRealOrderId($order->getIncrementId());
+// Mage::getSingleton('checkout/session')
+// ->setLastQuoteId($quote->getId())
+// ->setLastOrderId($order->getId())
+// ->setLastSuccessQuoteId($quote->getId())
+// ->setLastRealOrderId($order->getIncrementId());
$quote->setIsActive(false)->save();
@@ -379,8 +389,8 @@ protected function _responseNewOrderNotification()
Mage::getModel('newsletter/subscriber')->subscribe($order->getCustomerEmail());
}
- $shoppingCartQuoteId = Mage::getSingleton('checkout/session')->getQuoteId();
- $tmpQuote = Mage::getModel('sales/quote')->load($shoppingCartQuoteId);
+// $shoppingCartQuoteId = Mage::getSingleton('checkout/session')->getQuoteId();
+// $tmpQuote = Mage::getModel('sales/quote')->load($shoppingCartQuoteId);
/*
if (!$tmpQuote->getIsChanged()) {
$tmpQuote->delete();
diff --git a/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Checkout.php b/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Checkout.php
index ab26467266..4ac2dbe141 100644
--- a/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Checkout.php
+++ b/app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Checkout.php
@@ -157,6 +157,7 @@ protected function _getMerchantPrivateDataXml()
$xml = <<
getQuote()->getId()}]]>
+ getQuote()->getStoreId()}]]>
EOT;
return $xml;
@@ -266,7 +267,7 @@ protected function _getCarrierCalculatedShippingXml()
$addressCategory = Mage::getStoreConfig('google/checkout_shipping_carrier/address_category', $this->getQuote()->getStoreId());
- $defPrice = Mage::helper('tax')->getShippingPrice($defPrice, false, false);
+ $defPrice = (float) Mage::helper('tax')->getShippingPrice($defPrice, false, false);
// $taxRate = $this->_getShippingTaxRate();
// {$taxRate}
@@ -330,7 +331,7 @@ protected function _getFlatRateShippingXml()
$title = Mage::getStoreConfig('google/checkout_shipping_flatrate/title_'.$i, $this->getQuote()->getStoreId());
$price = Mage::getStoreConfig('google/checkout_shipping_flatrate/price_'.$i, $this->getQuote()->getStoreId());
$price = number_format($price, 2, '.','');
- $price = Mage::helper('tax')->getShippingPrice($price, false, false);
+ $price = (float) Mage::helper('tax')->getShippingPrice($price, false, false);
if (empty($title) || $price <= 0) {
continue;
@@ -403,7 +404,7 @@ protected function _getMerchantCalculatedShippingXml()
$method .= ' - '.$allowedMethods[$methodCode];
}
- $defaultPrice = $methods['price'][$i];
+ $defaultPrice = (float) $methods['price'][$i];
$defaultPrice = Mage::helper('tax')->getShippingPrice($defaultPrice, false, false);
$allowedAreasXml = $this->_getAllowedCountries($carrier->getConfigData('sallowspecific'), $carrier->getConfigData('specificcountry'));
@@ -433,7 +434,7 @@ protected function _getPickupXml()
$title = Mage::getStoreConfig('google/checkout_shipping_pickup/title', $this->getQuote()->getStoreId());
$price = Mage::getStoreConfig('google/checkout_shipping_pickup/price', $this->getQuote()->getStoreId());
- $price = Mage::helper('tax')->getShippingPrice($price, false, false);
+ $price = (float) Mage::helper('tax')->getShippingPrice($price, false, false);
$xml = <<
diff --git a/app/code/core/Mage/GoogleCheckout/controllers/RedirectController.php b/app/code/core/Mage/GoogleCheckout/controllers/RedirectController.php
index 58ef7c8a98..65bbdf0098 100644
--- a/app/code/core/Mage/GoogleCheckout/controllers/RedirectController.php
+++ b/app/code/core/Mage/GoogleCheckout/controllers/RedirectController.php
@@ -134,8 +134,8 @@ public function continueAction()
if ($quoteId = $session->getGoogleCheckoutQuoteId()) {
$quote = Mage::getModel('sales/quote')->load($quoteId)
->setIsActive(false)->save();
- $session->clear();
}
+ $session->clear();
if (Mage::getStoreConfigFlag('google/checkout/hide_cart_contents')) {
$session->setGoogleCheckoutQuoteId(null);
diff --git a/app/code/core/Mage/GoogleCheckout/etc/system.xml b/app/code/core/Mage/GoogleCheckout/etc/system.xml
index 9d95a4e23b..6b83320c0b 100644
--- a/app/code/core/Mage/GoogleCheckout/etc/system.xml
+++ b/app/code/core/Mage/GoogleCheckout/etc/system.xml
@@ -213,6 +213,7 @@
1
1
0
+ 1
Delivery Address Category
@@ -337,6 +338,7 @@
1
1
0
+ 1
Rate 1 Ship to Specific Countries
@@ -346,6 +348,7 @@
1
1
0
+ 1
@@ -375,6 +378,7 @@
1
1
0
+ 1
Rate 2 Ship to Specific Countries
@@ -384,6 +388,7 @@
1
1
0
+ 1
@@ -412,6 +417,7 @@
1
1
0
+ 1
Rate 3 Ship to Specific Countries
@@ -421,6 +427,7 @@
1
1
0
+ 1
diff --git a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Catalog/Product/Edit/Tab/Googleoptimizer.php b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Catalog/Product/Edit/Tab/Googleoptimizer.php
index fea2c34c33..55eea09923 100644
--- a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Catalog/Product/Edit/Tab/Googleoptimizer.php
+++ b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Catalog/Product/Edit/Tab/Googleoptimizer.php
@@ -31,7 +31,7 @@
* @package Mage_GoogleOptimizer
* @author Magento Core Team
*/
-class Mage_Googleoptimizer_Block_Adminhtml_Catalog_Product_Edit_Tab_Googleoptimizer
+class Mage_GoogleOptimizer_Block_Adminhtml_Catalog_Product_Edit_Tab_Googleoptimizer
extends Mage_Adminhtml_Block_Catalog_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
diff --git a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Enable.php b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Enable.php
index 338dc8eed5..b7ffa5561a 100644
--- a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Enable.php
+++ b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Enable.php
@@ -31,7 +31,7 @@
* @package Mage_GoogleOptimizer
* @author Magento Core Team
*/
-class Mage_Googleoptimizer_Block_Adminhtml_Cms_Page_Edit_Enable extends Mage_Adminhtml_Block_Template
+class Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Enable extends Mage_Adminhtml_Block_Template
{
/**
* Utility method to call method of specified block
@@ -41,7 +41,7 @@ class Mage_Googleoptimizer_Block_Adminhtml_Cms_Page_Edit_Enable extends Mage_Adm
* @param string $name
* @param string $method
* @param array $params
- * @return Mage_Googleoptimizer_Block_Adminhtml_Cms_Page_Edit_Enable
+ * @return Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Enable
*/
public function ifGoogleOptimizerEnabled($name, $method, $params = array())
{
@@ -63,7 +63,7 @@ public function ifGoogleOptimizerEnabled($name, $method, $params = array())
* @param string $name
* @param string $type
* @param string $attributes
- * @return Mage_Googleoptimizer_Block_Adminhtml_Cms_Page_Edit_Enable
+ * @return Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Enable
*/
public function ifGoogleOptimizerEnabledAppend($container, $name, $type, $attributes = array())
{
diff --git a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php
index f994085d59..697d7a9b14 100644
--- a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php
+++ b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php
@@ -31,7 +31,7 @@
* @package Mage_GoogleOptimizer
* @author Magento Core Team
*/
-class Mage_Googleoptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer
+class Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer
extends Mage_Adminhtml_Block_Widget_Form
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
@@ -162,7 +162,7 @@ protected function _prepareForm()
if ($this->getGoogleOptimizer() && $this->getGoogleOptimizer()->getData()) {
$values = $this->getGoogleOptimizer()->getData();
$fieldset->addField('code_id', 'hidden', array('name' => 'code_id'));
- if ($this->getGoogleOptimizer()->getData('page_type') == Mage_Googleoptimizer_Model_Code_Page::PAGE_TYPE_VARIANT) {
+ if ($this->getGoogleOptimizer()->getData('page_type') == Mage_GoogleOptimizer_Model_Code_Page::PAGE_TYPE_VARIANT) {
foreach ($fieldset->getElements() as $element) {
if (($element->getId() != 'tracking_script' && $element->getId() != 'page_type')
&& ($element->getType() == 'textarea' || $element->getType() == 'select'))
diff --git a/app/code/core/Mage/GoogleOptimizer/Model/Code.php b/app/code/core/Mage/GoogleOptimizer/Model/Code.php
index 57c1535414..9232d0014c 100644
--- a/app/code/core/Mage/GoogleOptimizer/Model/Code.php
+++ b/app/code/core/Mage/GoogleOptimizer/Model/Code.php
@@ -80,7 +80,7 @@ public function getEntityType()
* Loading scripts and assigning scripts on entity
*
* @param Varien_Object $entity
- * @return Mage_Googleoptimizer_Model_Code
+ * @return Mage_GoogleOptimizer_Model_Code
*/
public function loadScripts($storeId)
{
@@ -129,7 +129,7 @@ protected function _validate()
* Save scripts assigned on entity
*
* @param Varien_Object $entity
- * @return Mage_Googleoptimizer_Model_Code
+ * @return Mage_GoogleOptimizer_Model_Code
*/
public function saveScripts($storeId)
{
@@ -170,7 +170,7 @@ public function saveScripts($storeId)
* Removing scripts assigned to entity
*
* @param integer $storeId
- * @return Mage_Googleoptimizer_Model_Code
+ * @return Mage_GoogleOptimizer_Model_Code
*/
public function deleteScripts($storeId)
{
diff --git a/app/code/core/Mage/GoogleOptimizer/Model/Code/Category.php b/app/code/core/Mage/GoogleOptimizer/Model/Code/Category.php
index 01852bc9b7..bbfac6b0a1 100644
--- a/app/code/core/Mage/GoogleOptimizer/Model/Code/Category.php
+++ b/app/code/core/Mage/GoogleOptimizer/Model/Code/Category.php
@@ -29,19 +29,19 @@
* Google Optimizer Category model
*
* @category Mage
- * @package Mage_Googleoptimizer
+ * @package Mage_GoogleOptimizer
* @author Magento Core Team
*/
class Mage_GoogleOptimizer_Model_Code_Category extends Mage_GoogleOptimizer_Model_Code
{
-
+
protected $_entityType = 'category';
/**
* Removing scripts assigned to entity
*
* @param integer $storeId
- * @return Mage_Googleoptimizer_Model_Code
+ * @return Mage_GoogleOptimizer_Model_Code
*/
public function deleteScripts($storeId)
{
diff --git a/app/code/core/Mage/GoogleOptimizer/Model/Observer.php b/app/code/core/Mage/GoogleOptimizer/Model/Observer.php
index f59c294f00..d47e915706 100644
--- a/app/code/core/Mage/GoogleOptimizer/Model/Observer.php
+++ b/app/code/core/Mage/GoogleOptimizer/Model/Observer.php
@@ -37,7 +37,7 @@ class Mage_GoogleOptimizer_Model_Observer
* Loading product scripts after load product
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function appendToProductGoogleOptimizerScripts($observer)
{
@@ -70,7 +70,7 @@ public function prepareGoogleOptimizerScripts($observer)
* Prepare product scripts for saving
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function prepareProductGoogleOptimizerScripts($observer)
{
@@ -87,7 +87,7 @@ public function prepareProductGoogleOptimizerScripts($observer)
* Save product scripts after saving product
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function saveProductGoogleOptimizerScripts($observer)
{
@@ -106,7 +106,7 @@ public function saveProductGoogleOptimizerScripts($observer)
* Delete Produt scripts after deleting product
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function deleteProductGoogleOptimizerScripts($observer)
{
@@ -121,7 +121,7 @@ public function deleteProductGoogleOptimizerScripts($observer)
* Loading page scripts after load page
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function appendToPageGoogleOptimizerScripts($observer)
{
@@ -131,7 +131,7 @@ public function appendToPageGoogleOptimizerScripts($observer)
if (Mage::app()->getStore()->getId() && !Mage::helper('googleoptimizer')->isOptimizerActive()) {
return $this;
}
-
+
$cmsPage = $observer->getEvent()->getObject();
$googleOptimizerModel = Mage::getModel('googleoptimizer/code_page')
->setEntity($cmsPage)
@@ -147,7 +147,7 @@ public function appendToPageGoogleOptimizerScripts($observer)
* Prepare page scripts for saving
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function preparePageGoogleOptimizerScripts($observer)
{
@@ -164,7 +164,7 @@ public function preparePageGoogleOptimizerScripts($observer)
* Save page scripts after saving page
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function savePageGoogleOptimizerScripts($observer)
{
@@ -183,7 +183,7 @@ public function savePageGoogleOptimizerScripts($observer)
* Delete page scripts after deleting page
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function deletePageGoogleOptimizerScripts($observer)
{
@@ -207,7 +207,7 @@ public function assignHandlers($observer)
* Loading category scripts after load category
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function appendToCategoryGoogleOptimizerScripts($observer)
{
@@ -230,7 +230,7 @@ public function appendToCategoryGoogleOptimizerScripts($observer)
* Prepare category scripts for saving
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function prepareCategoryGoogleOptimizerScripts($observer)
{
@@ -247,7 +247,7 @@ public function prepareCategoryGoogleOptimizerScripts($observer)
* Save category scripts after saving category
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function saveCategoryGoogleOptimizerScripts($observer)
{
@@ -270,7 +270,7 @@ public function saveCategoryGoogleOptimizerScripts($observer)
* Delete category scripts after deleting category
*
* @param Varien_Object $observer
- * @return Mage_Googleoptimizer_Model_Observer
+ * @return Mage_GoogleOptimizer_Model_Observer
*/
public function deleteCategoryGoogleOptimizerScripts($observer)
{
diff --git a/app/code/core/Mage/Ideal/Block/Advanced/Failure.php b/app/code/core/Mage/Ideal/Block/Advanced/Failure.php
deleted file mode 100644
index a6e1701f6a..0000000000
--- a/app/code/core/Mage/Ideal/Block/Advanced/Failure.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- */
-
-class Mage_Ideal_Block_Advanced_Failure extends Mage_Core_Block_Template
-{
- /**
- * Returns error from session and clears it
- *
- * @return string
- */
- public function getErrorMessage ()
- {
- $error = Mage::getSingleton('checkout/session')->getIdealErrorMessage();
- Mage::getSingleton('checkout/session')->unsIdealErrorMessage();
- return $error;
- }
-
- /**
- * Get continue shopping url
- */
- public function getContinueShoppingUrl()
- {
- return Mage::getUrl('checkout/cart');
- }
-}
diff --git a/app/code/core/Mage/Ideal/Block/Advanced/Form.php b/app/code/core/Mage/Ideal/Block/Advanced/Form.php
deleted file mode 100755
index 79bcada000..0000000000
--- a/app/code/core/Mage/Ideal/Block/Advanced/Form.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- */
-
-class Mage_Ideal_Block_Advanced_Form extends Mage_Payment_Block_Form
-{
- protected function _construct()
- {
- $this->setTemplate('ideal/advanced/form.phtml');
- parent::_construct();
- }
-
- /**
- * Return array that contains issuer list
- *
- * @return array
- */
- public function getIssuerList()
- {
- return $this->getMethod()->getIssuerList();
- }
-}
diff --git a/app/code/core/Mage/Ideal/Block/Advanced/Info.php b/app/code/core/Mage/Ideal/Block/Advanced/Info.php
deleted file mode 100644
index 12f026cd95..0000000000
--- a/app/code/core/Mage/Ideal/Block/Advanced/Info.php
+++ /dev/null
@@ -1,63 +0,0 @@
-
- */
-class Mage_Ideal_Block_Advanced_Info extends Mage_Payment_Block_Info
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('ideal/advanced/info.phtml');
- }
-
- public function toPdf()
- {
- $this->setTemplate('ideal/advanced/pdf/info.phtml');
- return $this->toHtml();
- }
-
- /**
- * Gets Issuer Title from Payment Attribute
- *
- * @return string
- */
- public function getIssuerTitle()
- {
- if ($this->getInfo() instanceof Mage_Sales_Model_Quote_Payment) {
- $issuerList = unserialize($this->getInfo()->getIdealIssuerList());
- return $issuerList[$this->getInfo()->getIdealIssuerId()];
- } else {
- return $this->getInfo()->getIdealIssuerTitle();
- }
- }
-
-}
diff --git a/app/code/core/Mage/Ideal/Block/Advanced/Redirect.php b/app/code/core/Mage/Ideal/Block/Advanced/Redirect.php
deleted file mode 100755
index f8b0180092..0000000000
--- a/app/code/core/Mage/Ideal/Block/Advanced/Redirect.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-
-class Mage_Ideal_Block_Advanced_Redirect extends Mage_Core_Block_Abstract
-{
- protected function _toHtml()
- {
- $html = '';
- $html.= $this->getMessage();
- $html.= '';
- $html.= '';
- return $html;
- }
-}
diff --git a/app/code/core/Mage/Ideal/Block/Basic/Failure.php b/app/code/core/Mage/Ideal/Block/Basic/Failure.php
deleted file mode 100644
index 11b3383591..0000000000
--- a/app/code/core/Mage/Ideal/Block/Basic/Failure.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- */
-
-class Mage_Ideal_Block_Basic_Failure extends Mage_Core_Block_Template
-{
- /**
- * Returns error from session and clears it
- *
- * @return string
- */
- public function getErrorMessage ()
- {
- $error = Mage::getSingleton('checkout/session')->getIdealErrorMessage();
- Mage::getSingleton('checkout/session')->unsIdealErrorMessage();
- return $error;
- }
-
- /**
- * Get continue shopping url
- */
- public function getContinueShoppingUrl()
- {
- return Mage::getUrl('checkout/cart');
- }
-}
diff --git a/app/code/core/Mage/Ideal/Block/Basic/Form.php b/app/code/core/Mage/Ideal/Block/Basic/Form.php
deleted file mode 100755
index 143228266e..0000000000
--- a/app/code/core/Mage/Ideal/Block/Basic/Form.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-
-class Mage_Ideal_Block_Basic_Form extends Mage_Payment_Block_Form
-{
- protected function _construct()
- {
- $this->setTemplate('ideal/basic/form.phtml');
- parent::_construct();
- }
-}
diff --git a/app/code/core/Mage/Ideal/Block/Basic/Redirect.php b/app/code/core/Mage/Ideal/Block/Basic/Redirect.php
deleted file mode 100755
index 710a7ee39d..0000000000
--- a/app/code/core/Mage/Ideal/Block/Basic/Redirect.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
- */
-
-class Mage_Ideal_Block_Basic_Redirect extends Mage_Core_Block_Abstract
-{
- protected function _toHtml()
- {
- $basic = $this->getOrder()->getPayment()->getMethodInstance();
-
- $form = new Varien_Data_Form();
- $form->setAction($basic->getApiUrl())
- ->setId('ideal_basic_checkout')
- ->setName('ideal_basic_checkout')
- ->setMethod('POST')
- ->setUseContainer(true);
-
- foreach ($basic->getBasicCheckoutFormFields() as $field=>$value) {
- $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
- }
-
- $html = '';
- $html.= $this->__('You will be redirected to iDEAL in a few seconds.');
- $html.= $form->toHtml();
- $html.= '';
- $html.= '';
- return $html;
- }
-}
diff --git a/app/code/core/Mage/Ideal/Helper/Data.php b/app/code/core/Mage/Ideal/Helper/Data.php
deleted file mode 100755
index ab97a146f4..0000000000
--- a/app/code/core/Mage/Ideal/Helper/Data.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- */
-
-class Mage_Ideal_Helper_Data extends Mage_Core_Helper_Abstract
-{
- public function encrypt($token)
- {
- return bin2hex(base64_decode(Mage::helper('core')->encrypt($token)));
- }
-
- public function decrypt($token)
- {
- return Mage::helper('core')->decrypt(base64_encode(pack('H*', $token)));
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Advanced.php b/app/code/core/Mage/Ideal/Model/Advanced.php
deleted file mode 100755
index 755d4196ee..0000000000
--- a/app/code/core/Mage/Ideal/Model/Advanced.php
+++ /dev/null
@@ -1,227 +0,0 @@
-
- */
-
-class Mage_Ideal_Model_Advanced extends Mage_Payment_Model_Method_Abstract
-{
- protected $_code = 'ideal_advanced';
- protected $_formBlockType = 'ideal/advanced_form';
- protected $_infoBlockType = 'ideal/advanced_info';
- protected $_allowCurrencyCode = array('EUR', 'GBP', 'USD', 'CAD', 'SHR', 'NOK', 'SEK', 'DKK');
-
- protected $_isGateway = false;
- protected $_canAuthorize = false;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = false;
- protected $_canVoid = false;
- protected $_canUseInternal = false;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = false;
-
- protected $_issuersList = null;
-
- public function canUseCheckout()
- {
- if ($this->getIssuerList() && parent::canUseCheckout()) {
- return true;
- } else {
- return false;
- }
- }
-
- public function getOrderPlaceRedirectUrl()
- {
- return Mage::getUrl('ideal/advanced/redirect', array('_secure' => true));
- }
-
- /**
- * Get iDEAL API Model
- *
- * @return Mage_Ideal_Api_Advanced
- */
- public function getApi()
- {
- return Mage::getSingleton('ideal/api_advanced');
- }
-
- public function getIssuerList($saveAttrbute = false)
- {
- if ($this->_issuersList == null) {
- $request = new Mage_Ideal_Model_Api_Advanced_DirectoryRequest();
- $response = $this->getApi()->processRequest($request, $this->getDebug());
- if ($response) {
- $this->_issuersList = $response->getIssuerList();
- return $this->_issuersList;
- } else {
- $this->_issuersList = null;
- $this->setError($this->getApi()->getError());
- return false;
- }
- } else {
- $this->getInfoInstance()
- ->setIdealIssuerList(serialize($this->_issuersList))
- ->save();
- return $this->_issuersList;
- }
- }
-
- /**
- * validate the currency code is avaialable to use for iDEAL Advanced or not
- *
- * @return bool
- */
- public function validate()
- {
- parent::validate();
- $paymentInfo = $this->getInfoInstance();
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
- $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
- } else {
- $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
- }
-
- if (!in_array($currency_code,$this->_allowCurrencyCode)) {
- Mage::throwException(Mage::helper('ideal')->__('Selected currency code (%s) is not compatible with iDEAL', $currency_code));
- }
-
- return $this;
- }
-
- /**
- * Preapre and send transaction request
- *
- * @param Mage_Sales_Model_Order $order
- * @param string $issuerId
- * @return Mage_Ideal_Model_Api_Advanced_AcquirerTrxResponse
- */
- public function sendTransactionRequest(Mage_Sales_Model_Order $order, $issuerId)
- {
- $request = new Mage_Ideal_Model_Api_Advanced_AcquirerTrxRequest();
- $request->setIssuerId($issuerId);
- $request->setPurchaseId($order->getIncrementId());
- $request->setEntranceCode(Mage::helper('ideal')->encrypt($order->getIncrementId()));
- //we need to be sure that we sending number without decimal part
- $request->setAmount(floor($order->getBaseGrandTotal()*100));
- $response = $this->getApi()->processRequest($request, $this->getDebug());
- return $response;
- }
-
- /**
- * Prepare and send transaction status request
- *
- * @param string $transactionId
- * @return Mage_Ideal_Model_Api_Advanced_AcquirerStatusResponse
- */
- public function getTransactionStatus($transactionId)
- {
- $request = new Mage_Ideal_Model_Api_Advanced_AcquirerStatusRequest();
- $request->setTransactionId($transactionId);
- $response = $this->getApi()->processRequest($request, $this->getDebug());
- return $response;
- }
-
- public function capture(Varien_Object $payment, $amount)
- {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId());
-
- return $this;
- }
-
- public function cancel(Varien_Object $payment)
- {
- $payment->setStatus(self::STATUS_DECLINED);
-
- return $this;
- }
-
- /**
- * Executes by cron and check transactions status
- * for every iDEAL order that was created in last hour
- */
- public function transactionStatusCheck($shedule = null)
- {
- $gmtStamp = Mage::getModel('core/date')->gmtTimestamp();
- $to = $this->getConfigData('cron_start') > 0?$this->getConfigData('cron_start'):1;
- $to = date('Y-m-d H:i:s', $gmtStamp - $to * 3600);
-
- $from = $this->getConfigData('cron_end') > 0?$this->getConfigData('cron_end'):1;
- $from = date('Y-m-d H:i:s', $gmtStamp - $from * 86400);
-
- $paymentCollection = Mage::getModel('sales/order_payment')->getCollection()
- ->addAttributeToFilter('last_trans_id', array('neq' => ''))
- ->addAttributeToFilter('method', $this->_code)
- ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to, 'datetime' => true))
- ->addAttributeToFilter('ideal_transaction_checked', array('neq' => '1'));
-
- $order = Mage::getModel('sales/order');
- foreach($paymentCollection->getItems() as $item) {
- $order->reset();
- $order->load($item->getParentId());
- $response = $this->getTransactionStatus($item->getLastTransId());
-
- if ($response->getTransactionStatus() == Mage_Ideal_Model_Api_Advanced::STATUS_SUCCESS) {
- if ($order->canInvoice()) {
- $invoice = $order->prepareInvoice();
- $invoice->register()->capture();
- Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
-
- $order->addStatusToHistory($order->getStatus(), Mage::helper('ideal')->__('Transaction Status Update: finished successfully'));
- }
- } else if ($response->getTransactionStatus() == Mage_Ideal_Model_Api_Advanced::STATUS_CANCELLED) {
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), Mage::helper('ideal')->__('Transaction Status Update: cancelled by customer'));
- } else {
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), Mage::helper('ideal')->__('Transaction Status Update: rejected by iDEAL'));
- }
-
- $order->getPayment()->setIdealTransactionChecked(1);
- $order->save();
- }
- }
-
- /**
- * Get debug flag
- *
- * @return boolean
- */
- public function getDebug()
- {
- return $this->getConfigData('debug_flag');
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced.php b/app/code/core/Mage/Ideal/Model/Api/Advanced.php
deleted file mode 100755
index 5e0deb0a40..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced.php
+++ /dev/null
@@ -1,507 +0,0 @@
-
- */
-
-class Mage_Ideal_Model_Api_Advanced extends Varien_Object
-{
- /**
- * Transaction status returned in Status Request
- */
- const STATUS_OPEN = 'Open';
- const STATUS_EXPIRED = 'Expired';
- const STATUS_SUCCESS = 'Success';
- const STATUS_CANCELLED = 'Cancelled';
- const STATUS_FAILED = 'Failed';
-
- /**
- * @var Mage_Ideal_Model_Api_Advanced_Security
- */
- protected $_security;
-
- /**
- * array with configuration values
- *
- * @var array()
- */
- protected $_conf;
-
- /**
- * @var Varien_Http_Adapter_Curl
- */
- protected $_http;
-
- public function __construct()
- {
- $this->_http = new Varien_Http_Adapter_Curl();
- $this->_security = new Mage_Ideal_Model_Api_Advanced_Security();
-
- if ($this->getConfigData('test_flag') == 1) {
- $acquirerUrl = 'https://idealtest.secure-ing.com/ideal/iDeal';
- } else {
- $acquirerUrl = 'https://ideal.secure-ing.com/ideal/iDeal';
- }
-
- if (!($description = $this->getConfigData('description'))) {
- $description = Mage::app()->getStore()->getFrontendName() . ' payment';
- }
-
- $this->_conf = array(
- 'PRIVATEKEY' => $this->getConfigData('private_key'),
- 'PRIVATEKEYPASS' => $this->getConfigData('private_keypass'),
- 'PRIVATECERT' => $this->getConfigData('private_cert'),
- 'AUTHENTICATIONTYPE' => 'SHA1_RSA',
- 'CERTIFICATE0' => $this->getConfigData('certificate'),
- 'ACQUIRERURL' => $acquirerUrl,
- 'ACQUIRERTIMEOUT' => '10',
- 'MERCHANTID' => $this->getConfigData('merchant_id'),
- 'SUBID' => '0',
- 'MERCHANTRETURNURL' => Mage::getUrl('ideal/advanced/result', array('_secure' => true)),
- 'CURRENCY' => 'EUR',
- 'EXPIRATIONPERIOD' => 'PT10M',
- 'LANGUAGE' => 'nl',
- 'DESCRIPTION' => $description,
- 'ENTRANCECODE' => ''
- );
-
- if ((int)$this->getConfigData('expire_period') >= 1 && $this->getConfigData('expire_period') < 60) {
- $this->_conf['EXPIRATIONPERIOD'] = 'PT' . $this->getConfigData('expire_period') . 'M';
- } else if ($this->getConfigData('description') == 60) {
- $this->_conf['EXPIRATIONPERIOD'] = 'PT1H';
- }
- }
-
- /**
- * Getting config parametrs
- *
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- public function getConfigData($key, $default=false)
- {
- if (!$this->hasData($key)) {
- $value = Mage::getStoreConfig('payment/ideal_advanced/'.$key);
- if (is_null($value) || false===$value) {
- $value = $default;
- }
- $this->setData($key, $value);
- }
- return $this->getData($key);
- }
-
- /**
- * this method processes a request regardless of the type.
- */
-
- public function processRequest($requestType, $debug = false)
- {
- if($requestType instanceof Mage_Ideal_Model_Api_Advanced_DirectoryRequest) {
- $response = $this->processDirRequest($requestType);
- } else if($requestType instanceof Mage_Ideal_Model_Api_Advanced_AcquirerStatusRequest) {
- $response = $this->processStatusRequest($requestType);
- } else if($requestType instanceof Mage_Ideal_Model_Api_Advanced_AcquirerTrxRequest) {
- $response = $this->processTrxRequest($requestType);
- }
-
- if ($debug) {
-
- if ($response === false) {
- $responseData = $this->getError();
- } else {
- $responseData = $response->getData();
- }
-
- Mage::getModel('ideal/api_debug')
- ->setResponseBody(get_class($requestType) . "\n" . print_r($responseData, true))
- ->setRequestBody(get_class($requestType) . "\n" . print_r($requestType->getData(), true))
- ->save();
- }
-
- return $response;
- }
-
- /**
- * This method sends HTTP XML DirectoryRequest to the Acquirer system.
- * Befor calling, all mandatory properties have to be set in the Request object
- * by calling the associated setter methods.
- * If the request was successful, the response Object is returned.
- * @param Request Object filled with necessary data for the XML Request
- * @return Response Object with the data of the XML response.
- */
- public function processDirRequest($request)
- {
- if ($request->getMerchantId() == "") {
- $request->setMerchantId($this->_conf["MERCHANTID"]);
- }
-
- if ($request->getSubId() == "") {
- $request->setSubId($this->_conf["SUBID"]);
- }
-
- if ($request->getAuthentication() == "") {
- $request->setAuthentication($this->_conf["AUTHENTICATIONTYPE"]);
- }
-
- $res = new Mage_Ideal_Model_Api_Advanced_DirectoryResponse();
-
- if (!$request->checkMandatory()) {
- $res->setError(Mage::helper('ideal')->__('Required fields missing'));
- return $res;
- }
-
- // build concatenated string
- $timestamp = $this->getGMTTimeMark();
- $token = "";
- $tokenCode = "";
-
- if ("SHA1_RSA" == $request->getAuthentication()) {
- $message = $timestamp . $request->getMerchantId() . $request->getSubId();
- $message = $this->_strip($message);
-
- //build fingerprint of your own certificate
- $token = $this->_security->createCertFingerprint($this->_conf["PRIVATECERT"]);
-
- //sign the part of the message that need to be signed
- $tokenCode = $this->_security->signMessage($this->_conf["PRIVATEKEY"], $this->_conf["PRIVATEKEYPASS"], $message);
-
- //encode with base64
- $tokenCode = base64_encode($tokenCode);
- }
-
- $reqMsg = "\n"
- . "\n"
- . "" . utf8_encode( $timestamp ) . " \n"
- . "\n"
- . "" . utf8_encode( htmlspecialchars( $request->getMerchantId() ) ) . " \n"
- . "" . utf8_encode( $request->getSubId() ) . " \n"
- . "" . utf8_encode( $request->getAuthentication() ) . " \n"
- . "" . utf8_encode( $token ) . " \n"
- . "" . utf8_encode( $tokenCode ) . " \n"
- . " \n"
- . " ";
-
- $response = $this->_post($this->_conf["ACQUIRERURL"], $this->_conf["ACQUIRERTIMEOUT"], $reqMsg);
-
- if ($response === false) {
- return false;
- }
-
- $xml = new SimpleXMLElement($response);
-
- if(!$xml->Error) {
- $res->setOk(true);
- $res->setAcquirer($xml->Acquirer->acquirerID);
- $issuerArray = array();
- foreach ($xml->Directory->Issuer as $issuer) {
- $issuerArray[(string)$issuer->issuerID] = (string)$issuer->issuerName;
- }
- $res->setIssuerList($issuerArray);
- return $res;
- } else {
- $this->setError($xml->Error->consumerMessage);
- return false;
- }
- }
-
- /**
- * This method sends HTTP XML AcquirerTrxRequest to the Acquirer system.
- * Befor calling, all mandatory properties have to be set in the Request object
- * by calling the associated setter methods.
- * If the request was successful, the response Object is returned.
- * @param Request Object filled with necessary data for the XML Request
- * @return Response Object with the data of the XML response.
- */
- public function processTrxRequest($request) {
-
- if ($request->getMerchantId() == "")
- $request->setMerchantId($this->_conf["MERCHANTID"]);
- if ($request->getSubId() == "")
- $request->setSubId($this->_conf["SUBID"]);
- if ($request->getAuthentication() == "")
- $request->setAuthentication($this->_conf["AUTHENTICATIONTYPE"]);
- if ($request->getMerchantReturnUrl() == "")
- $request->setMerchantReturnUrl($this->_conf["MERCHANTRETURNURL"]);
- if ($request->getCurrency() == "")
- $request->setCurrency($this->_conf["CURRENCY"]);
- if ($request->getExpirationPeriod() == "")
- $request->setExpirationPeriod($this->_conf["EXPIRATIONPERIOD"]);
- if ($request->getLanguage() == "")
- $request->setLanguage($this->_conf["LANGUAGE"]);
- if ($request->getEntranceCode() == "")
- $request->setEntranceCode($this->_conf["ENTRANCECODE"]);
- if ($request->getDescription() == "")
- $request->setDescription($this->_conf["DESCRIPTION"]);
-
- $res = new Mage_Ideal_Model_Api_Advanced_AcquirerTrxResponse();
-
- if (!$request->checkMandatory()) {
- $res->setError(Mage::helper('ideal')->__('Required fields missing'));
- return $res;
- }
-
- // build concatenated string
- $timestamp = $this->getGMTTimeMark();
- $token = "";
- $tokenCode = "";
- if ( "SHA1_RSA" == $request->getAuthentication() ) {
- $message = $timestamp
- . $request->getIssuerId()
- . $request->getMerchantId()
- . $request->getSubId()
- . $request->getMerchantReturnUrl()
- . $request->getPurchaseId()
- . $request->getAmount()
- . $request->getCurrency()
- . $request->getLanguage()
- . $request->getDescription()
- . $request->getEntranceCode();
- $message = $this->_strip($message);
-
- //create fingerprint so the receiver knows what certificate to use
- $token = $this->_security->createCertFingerprint($this->_conf["PRIVATECERT"]);
-
- //sign the message
- $tokenCode = $this->_security->signMessage($this->_conf["PRIVATEKEY"], $this->_conf["PRIVATEKEYPASS"], $message);
- //encode it with base64
- $tokenCode = base64_encode($tokenCode);
- }
-
- $reqMsg = "\n"
- . "\n"
- . "" . utf8_encode($timestamp) . " \n"
- . "" . "" . utf8_encode(htmlspecialchars($request->getIssuerId())) . " \n"
- . " \n"
- . "" . "" . utf8_encode(htmlspecialchars($request->getMerchantId())) . " \n"
- . "" . utf8_encode($request->getSubId()) . " \n"
- . "" . utf8_encode($request->getAuthentication()) . " \n"
- . "" . utf8_encode($token) . " \n"
- . "" . utf8_encode($tokenCode) . " \n"
- . "" . utf8_encode(htmlspecialchars($request->getMerchantReturnUrl())) . " \n"
- . " \n"
- . "" . "" . utf8_encode(htmlspecialchars($request->getPurchaseId())) . " \n"
- . "" . utf8_encode($request->getAmount()) . " \n"
- . "" . utf8_encode($request->getCurrency()) . " \n"
- . "" . utf8_encode($request->getExpirationPeriod()) . " \n"
- . "" . utf8_encode($request->getLanguage()) . " \n"
- . "" . utf8_encode(htmlspecialchars($request->getDescription())) . " \n"
- . "" . utf8_encode(htmlspecialchars($request->getEntranceCode())) . " \n"
- . " " . " ";
-
- $response = $this->_post($this->_conf["ACQUIRERURL"], $this->_conf["ACQUIRERTIMEOUT"], $reqMsg);
-
- if ($response === false) {
- return false;
- }
-
- $xml = new SimpleXMLElement($response);
-
- if(!$xml->Error) {
- $issuerUrl = (string)$xml->Issuer->issuerAuthenticationURL;
- $transactionId = (string)$xml->Transaction->transactionID;
- $res->setIssuerAuthenticationUrl($issuerUrl);
- $res->setTransactionId($transactionId);
- $res->setOk(true);
- return $res;
- } else {
- $this->setError($xml->Error->consumerMessage);
- return false;
- }
- }
-
- /**
- * This method sends HTTP XML AcquirerStatusRequest to the Acquirer system.
- * Befor calling, all mandatory properties have to be set in the Request object
- * by calling the associated setter methods.
- * If the request was successful, the response Object is returned.
- * @param Request Object filled with necessary data for the XML Request
- * @return Response Object with the data of the XML response.
- */
- public function processStatusRequest($request)
- {
- if ($request->getMerchantId() == "")
- $request->setMerchantId($this->_conf["MERCHANTID"]);
- if ($request->getSubId() == "")
- $request->setSubId($this->_conf["SUBID"]);
- if ($request->getAuthentication() == "")
- $request->setAuthentication($this->_conf["AUTHENTICATIONTYPE"]);
-
- $res = new Mage_Ideal_Model_Api_Advanced_AcquirerStatusResponse();
-
- if (!$request->checkMandatory()) {
- $$request->setErrorMessage(Mage::helper('ideal')->__('Required fields missing'));
- return $res;
- }
-
- // build concatenated string
- $timestamp = $this->getGMTTimeMark();
- $token = "";
- $tokenCode = "";
- if ("SHA1_RSA" == $request->getAuthentication()) {
- $message = $timestamp . $request->getMerchantId() . $request->getSubId() . $request->getTransactionId();
- $message = $this->_strip($message);
-
- //create fingerprint of your own certificate
- $token = $this->_security->createCertFingerprint($this->_conf["PRIVATECERT"]);
- //sign the message
- $tokenCode = $this->_security->signMessage( $this->_conf["PRIVATEKEY"], $this->_conf["PRIVATEKEYPASS"], $message );
- //encode with base64
- $tokenCode = base64_encode($tokenCode);
- }
- $reqMsg = "\n"
- . "\n"
- . "" . utf8_encode($timestamp) . " \n"
- . "" . "" . utf8_encode(htmlspecialchars($request->getMerchantId())) . " \n"
- . "" . utf8_encode($request->getSubId()) . " \n"
- . "" . utf8_encode($request->getAuthentication()) . " \n"
- . "" . utf8_encode($token) . " \n"
- . "" . utf8_encode($tokenCode) . " \n"
- . " \n"
- . "" . "" . utf8_encode(htmlspecialchars($request->getTransactionId())) . " \n"
- . " " . " ";
-
- $response = $this->_post($this->_conf["ACQUIRERURL"], $this->_conf["ACQUIRERTIMEOUT"], $reqMsg);
-
- if ($response === false) {
- return false;
- }
-
- //Process response
- $xml = new SimpleXMLElement($response);
- $status = (string)$xml->Transaction->status;
- $creationTime = (string)$xml->createDateTimeStamp;
- $transactionId = (string)$xml->Transaction->transactionID;
- $consumerAccountNumber = (string)$xml->Transaction->consumerAccountNumber;
- $consumerName = (string)$xml->Transaction->consumerName;
- $consumerCity = (string)$xml->Transaction->consumerCity;
-
- //Check status
- if ( strtoupper('Success') == strtoupper($status) ) {
- $res->setAuthenticated(true);
- } else {
- $res->setAuthenticated(false);
- }
-
- $res->setTransactionStatus($status);
- $res->setTransactionId($transactionId);
- $res->setConsumerAccountNumber($consumerAccountNumber);
- $res->setConsumerName($consumerName);
- $res->setConsumerCity($consumerCity);
- $res->setCreationTime($creationTime);
-
- // now check the signature of the incoming message
- //create signed message string
- $message = $creationTime . $transactionId . $status . $consumerAccountNumber;
- $message = trim( $message );
-
- //now we want to check the signature that has been sent
- $signature64 = (string)$xml->Signature->signatureValue;
-
- //decode the base64 encoded signature
- $sig = base64_decode($signature64);
-
- //get the fingerprint out of the response
- $fingerprint = (string)$xml->Signature->fingerprint;
-
- //search for the certificate file with the given fingerprint
- $certfile = $this->_security->getCertificateName($fingerprint, $this->_conf);
-
- if($certfile == false) {
- $res->setAuthenticated(false);
- $res->setError('Fingerprint unknown.');
- return $res;
- }
-
- //prepend directory
- $valid = $this->_security->verifyMessage($certfile, $message, $sig);
-
- if( $valid != 1 ) {
- $res->setAuthenticated(false);
- $res->setError('Bad signature.');
- return $res;
- }
-
- $res->setOk(true);
- return $res;
- }
-
- /**
- * Return GMT Time mark
- *
- * @return string
- */
- public function getGMTTimeMark()
- {
- return gmdate('Y') . '-' . gmdate('m') . '-' . gmdate('d') . 'T'
- . gmdate('H') . ':' . gmdate('i') . ':' . gmdate('s') . '.000Z';
- }
-
- /**
- * Post a request, note that for a HTTPS URL no port is required
- *
- * @param string $url
- * @param string $path
- * @param array $params
- * @return mixed
- */
- protected function _post($url, $timeout, $dataToSend)
- {
- $config = array('timeout' => 30);
- $this->_http->setConfig($config);
- $this->_http->write(Zend_Http_Client::POST, $url, '1.1', array(), $dataToSend);
- $response = $this->_http->read();
- $response = preg_split('/^\r?$/m', $response, 2);
- $response = trim($response[1]);
-
- if ($this->_http->getErrno()) {
- $this->_http->close();
- $this->setError($this->_http->getErrno() . ':' . $this->_http->getError());
- return false;
- }
- $this->_http->close();
- return $response;
- }
-
- /**
- * stripping spaces
- *
- * @param string $message
- * @return string
- */
- protected function _strip($message)
- {
- $message = str_replace(' ', '', $message);
- $message = str_replace("\t", '', $message);
- $message = str_replace("\n", '', $message );
- return $message;
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerStatusRequest.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerStatusRequest.php
deleted file mode 100755
index 06158e2e4f..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerStatusRequest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_AcquirerStatusRequest extends Mage_Ideal_Model_Api_Advanced_Request
-{
- /**
- * rests all input data to empty strings
- */
- function clear()
- {
- parent::clear();
- $this->unsTransactionId();
- }
-
- /**
- * this method checks, wheather all mandatory properties were set.
- * If done so, true is returned, otherwise false.
- * @return If done so, true is returned, otherwise false.
- */
- function checkMandatory()
- {
- if (parent::checkMandatory() && strlen($this->getTransactionId()) > 0) {
- return true;
- } else {
- return false;
- }
-
- }
-
-}
-
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerStatusResponse.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerStatusResponse.php
deleted file mode 100755
index 6dc4b8b791..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerStatusResponse.php
+++ /dev/null
@@ -1,44 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_AcquirerStatusResponse extends Mage_Ideal_Model_Api_Advanced_Response
-{
- /* available vars
- var $authenticated
- var $consumerName
- var $consumerAccountNumber
- var $consumerCity
- var $transactionId
- var $status
- */
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerTrxRequest.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerTrxRequest.php
deleted file mode 100755
index 4f29b58711..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerTrxRequest.php
+++ /dev/null
@@ -1,84 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_AcquirerTrxRequest extends Mage_Ideal_Model_Api_Advanced_Request
-{
- /* fields for request xml message
- var $issuerId (mandatory)
- var $merchantReturnUrl (mandatory)
- var $purchaseId (mandatory)
- var $amount (mandatory)
- var $currency (mandatory)
- var $expirationPeriod (mandatory)
- var $language (mandatory)
- var $description (optional)
- var $entranceCode (mandatory)
- */
-
- function clear() {
- parent::clear();
- $this->unsIssuerId();
- $this->unsMerchantReturnUrl();
- $this->unsPurchaseId();
- $this->unsAmount();
- $this->unsCurrency();
- $this->unsExpirationPeriod();
- $this->unsLanguage();
- $this->unsDescription();
- $this->unsEntranceCode();
- }
-
- /**
- * this method checks, whether all mandatory properties were set.
- * If done so, true is returned, otherwise false.
- * @return If done so, true is returned, otherwise false.
- */
- function checkMandatory () {
- if ((parent::checkMandatory() == true)
- && (strlen($this->getIssuerId()) > 0)
- && (strlen($this->getMerchantReturnUrl()) > 0)
- && (strlen($this->getPurchaseID()) > 0)
- && (strlen($this->getAmount()) > 0)
- && (strlen($this->getCurrency()) > 0)
- && (strlen($this->getExpirationPeriod()) > 0)
- && (strlen($this->getLanguage()) > 0)
- && (strlen($this->getEntranceCode()) > 0)
- && (strlen($this->getDescription()) > 0)
- ) {
- return true;
- } else {
- return false;
- }
- }
-
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerTrxResponse.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerTrxResponse.php
deleted file mode 100755
index ac49a6027a..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/AcquirerTrxResponse.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_AcquirerTrxResponse extends Mage_Ideal_Model_Api_Advanced_Response
-{
- /*
- var $acquirerId;
- var $issuerAuthenticationUrl;
- var $transactionId;
- */
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/DirectoryRequest.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/DirectoryRequest.php
deleted file mode 100755
index 0fc7e761c7..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/DirectoryRequest.php
+++ /dev/null
@@ -1,36 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_DirectoryRequest extends Mage_Ideal_Model_Api_Advanced_Request{
-
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/DirectoryResponse.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/DirectoryResponse.php
deleted file mode 100755
index d48cf1ae1a..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/DirectoryResponse.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_DirectoryResponse extends Mage_Ideal_Model_Api_Advanced_Response {
- /*
- var $acquirerId
- var $issuerList - array of Issuer Objects
- */
-
- /**
- * adds an Issuer to the IssuerList
- */
- function addIssuer($issuer) {
- if(is_a($issuer, "Mage_Ideal_Api_Advanced_Issuer")) {
- $this->setIssuerList(array_merge((array)$this->getIssuerList(), (array)$issuer));
- }
- }
-}
-
-?>
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/Issuer.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/Issuer.php
deleted file mode 100755
index aa0143278f..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/Issuer.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_Issuer extends Varien_Object
-{
- /*
- var $issuerID
- var $issuerName
- var $issuerList ("Short", "Long")
- */
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/Request.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/Request.php
deleted file mode 100755
index 67826eac33..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/Request.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_Request extends Varien_Object
-{
- /**
- * clears all parameters
- */
- public function clear() {
- $this->unsMerchantId();
- $this->unsSubId();
- $this->unsAuthentication();
- }
-
- /**
- * this method checks, whether all mandatory properties are set.
- * @return true if all fields are valid, otherwise returns false
- */
- function checkMandatory () {
- if (strlen($this->getMerchantId()) > 0
- && strlen($this->getSubID()) > 0
- && strlen($this->getAuthentication()) > 0) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * @param authentication The type of authentication to set.
- * Currently only "RSA_SHA1" is implemented. (mandatory)
- */
- function setAuthentication($authentication) {
- $this->setData('authentication', trim($authentication));
- }
-
- /**
- * @param merchantID The merchantID to set. (mandatory)
- */
- function setMerchantId($merchantID) {
- $this->setData('merchant_id', trim($merchantID));
- }
-
- /**
- * @param subID The subID to set. (mandatory)
- */
- function setSubId($subID) {
- $this->setData('sub_id', trim($subID));
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/Response.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/Response.php
deleted file mode 100755
index 8f7f63993d..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/Response.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_Response extends Varien_Object
-{
- /* available vars
- var $ok
- var $errorMessage
- var $errorCode
- var $errorDetail
- var $suggestedAction
- var $suggestedExpirationPeriod
- var $consumerMessage
- */
-
- /**
- * @return true, if the request was processed successfully, otherwise false. If
- * false, additional information can be received calling getErrorMessage()
- */
-
- function isOk() {
- return $this->ok;
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Advanced/Security.php b/app/code/core/Mage/Ideal/Model/Api/Advanced/Security.php
deleted file mode 100755
index 32364dc7ca..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Advanced/Security.php
+++ /dev/null
@@ -1,155 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Advanced_Security
-{
- /**
- * reads in a certificate file and creates a fingerprint
- * @param Filename of the certificate
- * @return fingerprint
- */
- function createCertFingerprint($filename)
- {
- if(is_readable($filename)) {
- $cert = file_get_contents($filename);
- } else {
- return false;
- }
-
- $data = openssl_x509_read($cert);
-
- if(!openssl_x509_export($data, $data)) {
-
- return false;
- }
-
- $data = str_replace("-----BEGIN CERTIFICATE-----", "", $data);
- $data = str_replace("-----END CERTIFICATE-----", "", $data);
-
- $data = base64_decode($data);
-
- $fingerprint = sha1($data);
-
- $fingerprint = strtoupper( $fingerprint );
-
- return $fingerprint;
- }
-
- /**
- * function to sign a message
- * @param filename of the private key
- * @param message to sign
- * @return signature
- */
- function signMessage($priv_keyfile, $key_pass, $data)
- {
- $data = preg_replace("/\s/","",$data);
- if (is_readable($priv_keyfile)) {
- $priv_key = file_get_contents($priv_keyfile);
-
- $params = array($priv_key, $key_pass);
- $pkeyid = openssl_pkey_get_private($params);
-
- // compute signature
- openssl_sign($data, $signature, $pkeyid);
-
- // free the key from memory
- openssl_free_key($pkeyid);
-
- return $signature;
- } else {
- return false;
- }
- }
-
- /**
- * function to verify a message
- * @param filename of the public key to decrypt the signature
- * @param message to verify
- * @param sent signature
- * @return signature
- */
- function verifyMessage($certfile, $data, $signature)
- {
- // $data and $signature are assumed to contain the data and the signature
- $ok = 0;
- if (is_readable($certfile)) {
- $cert = file_get_contents($certfile);
- } else {
- return false;
- }
-
- $pubkeyid = openssl_get_publickey($cert);
-
- // state whether signature is okay or not
- $ok = openssl_verify($data, $signature, $pubkeyid);
-
- // free the key from memory
- openssl_free_key($pubkeyid);
-
- return $ok;
- }
-
- /**
- * @param fingerprint that's been sent
- * @param the configuration file loaded in as an array
- * @return the filename of the certificate with this fingerprint
- */
- function getCertificateName($fingerprint, $config)
- {
- $count = 0;
-
- if (isset($config["CERTIFICATE" . $count])) {
- $certFilename = $config["CERTIFICATE" . $count];
- } else {
- return false;
- }
-
- while( isset($certFilename) ) {
- $buff = $this->createCertFingerprint($certFilename);
-
- if( $fingerprint == $buff ) {
- return $certFilename;
- }
-
- $count+=1;
- if (isset($config["CERTIFICATE" . $count])) {
- $certFilename = $config["CERTIFICATE" . $count];
- } else {
- return false;
- }
- }
-
- return false;
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Api/Debug.php b/app/code/core/Mage/Ideal/Model/Api/Debug.php
deleted file mode 100644
index 82dba2a6ae..0000000000
--- a/app/code/core/Mage/Ideal/Model/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Ideal_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('ideal/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Basic.php b/app/code/core/Mage/Ideal/Model/Basic.php
deleted file mode 100755
index 72598e08dc..0000000000
--- a/app/code/core/Mage/Ideal/Model/Basic.php
+++ /dev/null
@@ -1,217 +0,0 @@
-
- */
-
-class Mage_Ideal_Model_Basic extends Mage_Payment_Model_Method_Abstract
-{
- protected $_code = 'ideal_basic';
- protected $_formBlockType = 'ideal/basic_form';
- protected $_allowCurrencyCode = array('EUR', 'GBP', 'USD', 'CAD', 'SHR', 'NOK', 'SEK', 'DKK');
-
- protected $_isGateway = false;
- protected $_canAuthorize = false;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = false;
- protected $_canVoid = false;
- protected $_canUseInternal = false;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = false;
-
- /**
- * Get debug flag
- *
- * @return boolean
- */
- public function getDebug()
- {
- return $this->getConfigData('debug_flag');
- }
-
- /**
- * validate the currency code is avaialable to use for iDEAL Basic or not
- *
- * @return bool
- */
- public function validate()
- {
- parent::validate();
- $paymentInfo = $this->getInfoInstance();
- if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
- $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
- } else {
- $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
- }
- if (!in_array($currency_code, $this->_allowCurrencyCode)) {
- Mage::throwException(Mage::helper('ideal')->__('Selected currency code (%s) is not compatible with iDEAL', $currency_code));
- }
- return $this;
- }
-
- public function getOrderPlaceRedirectUrl()
- {
- return Mage::getUrl('ideal/basic/redirect', array('_secure' => true));
- }
-
- /**
- * Return iDEAL Basic Api Url
- *
- * @return string Payment API URL
- */
- public function getApiUrl()
- {
- if ($this->getConfigData('test_flag') == 1) {
- if (($url = trim($this->getConfigData('api_test_url'))) == '') {
- $url = "https://idealtest.secure-ing.com/ideal/mpiPayInitIng.do";
- }
- } else {
- if (($url = trim($this->getConfigData('api_url'))) == '') {
- $url = "https://ideal.secure-ing.com/ideal/mpiPayInitIng.do";
- }
- }
- return $url;
- }
-
- /**
- * Generates array of fields for redirect form
- *
- * @return array
- */
- public function getBasicCheckoutFormFields()
- {
- $order = $this->getInfoInstance()->getOrder();
-
- $shippingAddress = $order->getShippingAddress();
- $currency_code = $order->getBaseCurrencyCode();
-
- $fields = array(
- 'merchantID' => $this->getConfigData('merchant_id'),
- 'subID' => '0',
- 'amount' => round($order->getBaseGrandTotal()*100),
- 'purchaseID' => $order->getIncrementId(),
- 'paymentType' => 'ideal',
- 'validUntil' => date('Y-m-d\TH:i:s.000\Z', strtotime ('+1 week')) // plus 1 week
- );
-
- $i = 1;
- foreach ($order->getItemsCollection() as $item) {
- $fields = array_merge($fields, array(
- "itemNumber".$i => $item->getSku(),
- "itemDescription".$i => $item->getName(),
- "itemQuantity".$i => $item->getQtyOrdered()*1,
- "itemPrice".$i => round($item->getBasePrice()*100)
- ));
- $i++;
- }
-
- if ($order->getBaseShippingAmount() > 0) {
- $fields = array_merge($fields, array(
- "itemNumber".$i => $order->getShippingMethod(),
- "itemDescription".$i => $order->getShippingDescription(),
- "itemQuantity".$i => 1,
- "itemPrice".$i => round($order->getBaseShippingAmount()*100)
- ));
- $i++;
- }
-
- if ($order->getBaseTaxAmount() > 0) {
- $fields = array_merge($fields, array(
- "itemNumber".$i => 'Tax',
- "itemDescription".$i => '',
- "itemQuantity".$i => 1,
- "itemPrice".$i => round($order->getBaseTaxAmount()*100)
- ));
- $i++;
- }
-
- if ($order->getBaseDiscountAmount() > 0) {
- $fields = array_merge($fields, array(
- "itemNumber".$i => 'Discount',
- "itemDescription".$i => '',
- "itemQuantity".$i => 1,
- "itemPrice".$i => -round($order->getBaseDiscountAmount()*100)
- ));
- $i++;
- }
-
- $fields = $this->appendHash($fields);
-
- $description = $this->getConfigData('description');
- if ($description == '') {
- $description = Mage::app()->getStore()->getFrontendName() . ' ' . 'payment';
- }
-
- $fields = array_merge($fields, array(
- 'language' => $this->getConfigData('language'),
- 'currency' => $currency_code,
- 'description' => $description,
- 'urlCancel' => Mage::getUrl('ideal/basic/cancel', array('_secure' => true)),
- 'urlSuccess' => Mage::getUrl('ideal/basic/success', array('_secure' => true)),
- 'urlError' => Mage::getUrl('ideal/basic/failure', array('_secure' => true))
- ));
-
- $requestString = '';
- $returnArray = array();
-
- foreach ($fields as $k=>$v) {
- $returnArray[$k] = $v;
- $requestString .= '&'.$k.'='.$v;
- }
-
- if ($this->getDebug()) {
- Mage::getModel('ideal/api_debug')
- ->setRequestBody($this->getApiUrl() . "\n" . $requestString)
- ->save();
- }
-
- return $returnArray;
- }
-
- /**
- * Calculates and appends hash to form fields
- *
- * @param array $returnArray
- * @return array
- */
- public function appendHash($returnArray)
- {
- $merchantKey = $this->getConfigData('merchant_key');
- $hashString = $merchantKey.implode('', $returnArray);
- $hashString = str_replace(
- array(" ", "\t", "\n", "&", "<", ">", ""e;"),
- array("", "", "", "&", "<", ">", "\""),
- $hashString);
- $hash = sha1($hashString);
- return array_merge($returnArray, array('hash' => $hash));
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Ideal/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index 3c0db840c7..0000000000
--- a/app/code/core/Mage/Ideal/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-
-class Mage_Ideal_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('ideal/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/Ideal/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index 40221addbd..0000000000
--- a/app/code/core/Mage/Ideal/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Ideal_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('ideal/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Mysql4/Setup.php b/app/code/core/Mage/Ideal/Model/Mysql4/Setup.php
deleted file mode 100755
index 19de383561..0000000000
--- a/app/code/core/Mage/Ideal/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-class Mage_Ideal_Model_Observer
-{
- /**
- * Convert specific attributes from Quote Payment to Order Payment
- *
- * @param Varien_Object $observer
- * @return Mage_Ideal_Model_Observer
- */
- public function convertPayment($observer)
- {
- $orderPayment = $observer->getEvent()->getOrderPayment();
- $quotePayment = $observer->getEvent()->getQuotePayment();
- $orderPayment->setIdealIssuerId($quotePayment->getIdealIssuerId());
-
- if ($quotePayment->getIdealIssuerId()) {
- $issuerList = unserialize($quotePayment->getIdealIssuerList());
- if (isset($issuerList[$quotePayment->getIdealIssuerId()])) {
- $orderPayment->setIdealIssuerTitle(
- $issuerList[$quotePayment->getIdealIssuerId()]
- );
- }
- }
- return $this;
- }
-}
diff --git a/app/code/core/Mage/Ideal/Model/Source/Language.php b/app/code/core/Mage/Ideal/Model/Source/Language.php
deleted file mode 100644
index fce0788f0d..0000000000
--- a/app/code/core/Mage/Ideal/Model/Source/Language.php
+++ /dev/null
@@ -1,47 +0,0 @@
-
- */
-
-class Mage_Ideal_Model_Source_Language
-{
- public function toOptionArray()
- {
- return array(
- array('value' => 'en', 'label' => Mage::helper('ideal')->__('English')),
- array('value' => 'nl', 'label' => Mage::helper('ideal')->__('Dutch'))
- );
- }
-}
-
-
-
diff --git a/app/code/core/Mage/Ideal/controllers/AdvancedController.php b/app/code/core/Mage/Ideal/controllers/AdvancedController.php
deleted file mode 100755
index 418dbdfc25..0000000000
--- a/app/code/core/Mage/Ideal/controllers/AdvancedController.php
+++ /dev/null
@@ -1,195 +0,0 @@
-
- */
-
-class Mage_Ideal_AdvancedController extends Mage_Core_Controller_Front_Action
-{
- public function getCheckout()
- {
- return Mage::getSingleton('checkout/session');
- }
-
- /**
- * When a customer chooses iDEAL Advanced on Checkout/Payment page
- *
- */
- public function redirectAction()
- {
- $order = Mage::getModel('sales/order');
- $order->load($this->getCheckout()->getLastOrderId());
- if($order->getId()){
- $advanced = $order->getPayment()->getMethodInstance();
- $issuerId = $order->getPayment()->getIdealIssuerId();
-
- $response = $advanced->sendTransactionRequest($order, $issuerId);
-
- if ($response) {
- $order->getPayment()->setTransactionId($response->getTransactionId());
- $order->getPayment()->setLastTransId($response->getTransactionId());
- $order->getPayment()->setIdealTransactionChecked(0);
-
- if ($response->getError()) {
- $this->getCheckout()->setIdealErrorMessage($response->getError());
- $this->_redirect('*/*/failure');
- return;
- }
-
- $this->getResponse()->setBody(
- $this->getLayout()->createBlock('ideal/advanced_redirect')
- ->setMessage($this->__('You will be redirected to bank in a few seconds.'))
- ->setRedirectUrl($response->getIssuerAuthenticationUrl())
- ->toHtml()
- );
-
- $order->addStatusToHistory(
- $order->getStatus(),
- $this->__('Customer was redirected to iDEAL')
- );
- $order->save();
-
- $this->getCheckout()->setIdealAdvancedQuoteId($this->getCheckout()->getQuoteId(true));
- $this->getCheckout()->setIdealAdvancedOrderId($this->getCheckout()->getLastOrderId(true));
-
-
- return;
- }
- }
-
- $this->getResponse()->setBody(
- $this->getLayout()->createBlock('ideal/advanced_redirect')
- ->setMessage($this->__('Error occured. You will be redirected back to store.'))
- ->setRedirectUrl(Mage::getUrl('checkout/cart'))
- ->toHtml()
- );
- }
-
- /**
- * When a customer cancels payment from iDEAL
- */
- public function cancelAction()
- {
- $order = Mage::getModel('sales/order');
- $this->getCheckout()->setLastOrderId($this->getCheckout()->getIdealAdvancedOrderId(true));
- $order->load($this->getCheckout()->getLastOrderId());
-
- if (!$order->getId()) {
- $this->norouteAction();
- return;
- }
-
- $order->addStatusToHistory(
- $order->getStatus(),
- $this->__('Customer canceled payment.')
- );
- $order->cancel();
- $order->save();
-
- $$this->getCheckout()->setQuoteId($$this->getCheckout()->setIdealAdvancedQuoteId(true));
- $this->_redirect('checkout/cart');
- }
-
- /**
- * When customer return from iDEAL
- */
- public function resultAction()
- {
- /**
- * Decrypt Real Order Id that was sent encrypted
- */
- $orderId = Mage::helper('ideal')->decrypt($this->getRequest()->getParam('ec'));
- $transactionId = $this->getRequest()->getParam('trxid');
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($orderId);
-
- if ($order->getId() > 0) {
- $advanced = $order->getPayment()->getMethodInstance();
- $advanced->setTransactionId($transactionId);
- $response = $advanced->getTransactionStatus($transactionId);
-
- $this->getCheckout()->setQuoteId($this->getCheckout()->getIdealAdvancedQuoteId(true));
- $this->getCheckout()->setLastOrderId($this->getCheckout()->getIdealAdvancedOrderId(true));
-
- if ($response->getTransactionStatus() == Mage_Ideal_Model_Api_Advanced::STATUS_SUCCESS) {
- $this->getCheckout()->getQuote()->setIsActive(false)->save();
-
- if ($order->canInvoice()) {
- $invoice = $order->prepareInvoice();
- $invoice->register()->capture();
- Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
-
- $order->addStatusToHistory($order->getStatus(), Mage::helper('ideal')->__('Customer successfully returned from iDEAL'));
- }
-
- $order->sendNewOrderEmail();
-
- $this->_redirect('checkout/onepage/success');
- } else if ($response->getTransactionStatus() == Mage_Ideal_Model_Api_Advanced::STATUS_CANCELLED) {
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), Mage::helper('ideal')->__('Customer cancelled payment'));
-
- $this->_redirect('checkout/cart');
- } else {
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), Mage::helper('ideal')->__('Customer was rejected by iDEAL'));
- $this->getCheckout()->setIdealErrorMessage(
- Mage::helper('ideal')->__('An error occurred while processing your iDEAL transaction. Please contact the web shop or try
-again later. Transaction number is %s.', $order->getIncrementId())
- );
-
- $this->_redirect('*/*/failure');
- }
- $order->getPayment()->setIdealTransactionChecked(1);
- $order->save();
- } else {
- $this->_redirect('checkout/cart');
- }
- }
-
- /**
- * Redirected here when customer returns with error
- */
- public function failureAction()
- {
- if (!$this->getCheckout()->getIdealErrorMessage()) {
- $this->norouteAction();
- return;
- }
-
- $this->loadLayout();
- $this->renderLayout();
- }
-}
diff --git a/app/code/core/Mage/Ideal/controllers/BasicController.php b/app/code/core/Mage/Ideal/controllers/BasicController.php
deleted file mode 100755
index 0f0d6ba547..0000000000
--- a/app/code/core/Mage/Ideal/controllers/BasicController.php
+++ /dev/null
@@ -1,247 +0,0 @@
-
- */
-class Mage_Ideal_BasicController extends Mage_Core_Controller_Front_Action
-{
-
- /**
- * Return order instance for last real order ID (stored in session)
- *
- * @return Mage_Sales_Model_Entity_Order object
- */
- protected function _getOrder ()
- {
- $order = Mage::getModel('sales/order');
- $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
-
- if (!$order->getId()) {
- return false;
- }
-
- return $order;
- }
-
- /**
- * When a customer chooses iDEAL Basic on Checkout/Payment page
- */
- public function redirectAction()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setIdealBasicQuoteId($session->getQuoteId());
- $session->setIdealBasicOrderId($session->getLastOrderId());
-
- if (!($order = $this->_getOrder())) {
- $this->norouteAction();
- return;
- }
- $order->addStatusToHistory(
- $order->getStatus(),
- $this->__('Customer was redirected to iDEAL. Please, check the status of a transaction via the ING iDEAL Dashboard before delivery of the goods purchased.')
- );
- $order->save();
-
- $this->getResponse()->setBody(
- $this->getLayout()->createBlock('ideal/basic_redirect')
- ->setOrder($order)
- ->toHtml()
- );
- $session->unsQuoteId();
- $session->unsLastOrderId();
- }
-
- /**
- * Success response from iDEAL
- */
- public function successAction()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setLastOrderId($session->getIdealBasicOrderId(true));
-
- $order = $this->_getOrder();
- if (!$order->getId()) {
- $this->norouteAction();
- return false;
- }
-
- $session->setQuoteId($session->getIdealBasicQuoteId(true));
-
- $order->addStatusToHistory(
- $order->getStatus(),
- $this->__('Customer successfully returned from iDEAL')
- );
-
- $order->sendNewOrderEmail();
-
- $this->_saveInvoice($order);
-
- $order->save();
-
- $this->_redirect('checkout/onepage/success');
- }
-
- /**
- * Cancel response from iDEAL
- */
- public function cancelAction()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setLastOrderId($session->getIdealBasicOrderId(true));
-
- $order = $this->_getOrder();
- if (!$order->getId()) {
- $this->norouteAction();
- return false;
- }
-
- $order->cancel();
-
- $history = $this->__('Payment was canceled by customer');
-
- $order->addStatusToHistory(
- $order->getStatus(),
- $history
- );
-
- $order->save();
-
- $session->setQuoteId($session->getIdealBasicQuoteId(true));
-
- $this->_redirect('checkout/cart');
- }
-
-
- /**
- * Error response from iDEAL
- */
- public function failureAction ()
- {
- $session = Mage::getSingleton('checkout/session');
- $session->setLastOrderId($session->getIdealBasicOrderId(true));
-
- $order = $this->_getOrder();
-
- if (!$order->getId()) {
- $this->norouteAction();
- return false;
- }
-
- $order->cancel();
-
- $history = $this->__('Error occured with transaction %s.', $order->getIncrementId()) . ' '
- . $this->__('Customer was returned from iDEAL.');
-
- $order->addStatusToHistory(
- $order->getStatus(),
- $history
- );
-
- $order->save();
-
- $session->setQuoteId($session->getIdealBasicQuoteId(true));
- $session->setIdealErrorMessage($this->__('An error occurred while processing your iDEAL transaction. Please contact the web shop or try again later. Transaction number is %s.', $order->getIncrementId()));
-
- $this->loadLayout();
- $this->renderLayout();
-
- }
-
- /**
- * Notification action that calling by iDEAL
- *
- */
- public function notifyAction()
- {
- if (isset($HTTP_RAW_POST_DATA)) {
- $xmlResponse = $HTTP_RAW_POST_DATA;
- } else {
- $xmlResponse = file_get_contents("php://input");
- }
-
- if (!strlen($xmlResponse)) {
- $this->norouteAction();
- return;
- }
-
- $xmlObj = simplexml_load_string($xmlResponse);
- $status = (string)$xmlObj->status;
-
- $order = Mage::getModel('sales/order')
- ->loadByIncrementId((int)$xmlObj->purchaseID);
-
- if (!$order->getId()) {
- return;
- }
-
- if ($status == 'Success') {
- if (!$order->hasInvoices()) {
- $this->_saveInvoice($order);
- $order->addStatusToHistory($order->getStatus(),
- $this->__('Notification from iDEAL was recived with status %s. Invoice was created. Please, check the status of a transaction via the ING iDEAL Dashboard before delivery of the goods purchased.', $status)
- );
- } else {
- $order->addStatusToHistory($order->getStatus(),
- $this->__('Notification from iDEAL was recived with status %s.', $status)
- );
- }
- } else {
- $order->addStatusToHistory($order->getStatus(),
- $this->__('Notification from iDEAL was recived with status %s.', $status)
- );
- $order->cancel();
- }
-
- $order->save();
- }
-
- /**
- * Save invoice for order
- *
- * @param Mage_Sales_Model_Order $order
- * @return boolean Can save invoice or not
- */
- protected function _saveInvoice(Mage_Sales_Model_Order $order)
- {
- if ($order->canInvoice()) {
- $invoice = $order->prepareInvoice();
- $invoice->register()->capture();
- Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
- return true;
- }
- return false;
- }
-
-}
diff --git a/app/code/core/Mage/Ideal/etc/config.xml b/app/code/core/Mage/Ideal/etc/config.xml
deleted file mode 100755
index 64319e6de6..0000000000
--- a/app/code/core/Mage/Ideal/etc/config.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
- 0.1.0
-
-
-
-
-
- Mage_Ideal_Model
- ideal_mysql4
-
-
- Mage_Ideal_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Ideal
- Mage_Ideal_Model_Mysql4_Setup
-
-
-
-
- Mage_Ideal_Block
-
-
-
-
- /ideal/advanced
- /ideal/basic
-
-
-
- standard
-
- Mage_Ideal
- ideal
-
-
-
-
-
-
-
- Mage_Ideal.csv
-
-
-
-
-
-
-
- ideal.xml
-
-
-
-
-
-
-
- ideal/observer
- convertPayment
-
-
-
-
-
-
-
-
-
-
- Mage_Ideal.csv
-
-
-
-
-
-
-
-
- ideal/basic
- iDEAL Basic
- 0
-
-
- ideal/advanced
- iDEAL Advanced
- 0
- 10
- 1
- 1
-
-
-
-
-
-
- 0 */1 * * *
- ideal/advanced::transactionStatusCheck
-
-
-
-
diff --git a/app/code/core/Mage/Ideal/etc/system.xml b/app/code/core/Mage/Ideal/etc/system.xml
deleted file mode 100755
index 46a6373e0e..0000000000
--- a/app/code/core/Mage/Ideal/etc/system.xml
+++ /dev/null
@@ -1,326 +0,0 @@
-
-
-
-
-
-
-
- iDEAL Basic
- text
- 301
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 0
- 1
- 1
- 0
-
-
- Title
- text
- 10
- 1
- 1
- 1
-
-
- Merchant ID
- text
- 20
- 1
- 1
- 0
-
-
- Merchant Key
- text
- 30
- 1
- 1
- 0
-
-
- Secure URL (production)
- Leave empty for default value
- text
- 30
- 1
- 1
- 0
-
-
- Secure URL (test mode)
- Leave empty for default value
- text
- 30
- 1
- 1
- 0
-
-
- Test Mode
- select
- adminhtml/system_config_source_yesno
- 40
- 1
- 1
- 0
-
-
- Transaction Description
- Store name will be used if left empty
- text
- 50
- 1
- 1
- 0
-
-
- Language
- select
- ideal/source_language
- 60
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 70
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 80
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 90
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 100
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 110
- 1
- 1
- 0
-
-
-
-
- iDEAL Advanced
- text
- 302
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 0
- 1
- 1
- 0
-
-
- Title
- text
- 10
- 1
- 1
- 1
-
-
- Merchant ID
- text
- 20
- 1
- 1
- 0
-
-
- Private Key
- Absolute path to private key file
- text
- 30
- 1
- 1
- 0
-
-
- Private Key Password
- text
- 40
- 1
- 1
- 0
-
-
- Private Certificate
- Absolute path to private certificate file
- text
- 30
- 1
- 1
- 0
-
-
- iDEAL Certificate
- Absolute path to public payment provider certificate file
- text
- 50
- 1
- 1
- 0
-
-
- Test Mode
- select
- adminhtml/system_config_source_yesno
- 60
- 1
- 1
- 0
-
-
- Transaction Description
- Store name will be used if left empty
- text
- 70
- 1
- 1
- 0
-
-
- Transaction Expire Period
- In minutes. Minimum is 1 minute and maximum is 60.
- text
- 80
- 1
- 1
- 0
-
-
- Check Begin
- Begin to check transaction status if order was made {N} hours ago
- text
- 90
- 1
- 1
- 0
-
-
- Check End
- Don't check transaction status if order older than {N} days
- text
- 100
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 110
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 120
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 130
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 140
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 150
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Ideal/sql/ideal_setup/mysql4-install-0.1.0.php b/app/code/core/Mage/Ideal/sql/ideal_setup/mysql4-install-0.1.0.php
deleted file mode 100755
index 01337a4f60..0000000000
--- a/app/code/core/Mage/Ideal/sql/ideal_setup/mysql4-install-0.1.0.php
+++ /dev/null
@@ -1,51 +0,0 @@
-startSetup();
-
-$installer->run("
-DROP TABLE IF EXISTS `{$this->getTable('ideal/api_debug')}`;
-CREATE TABLE `{$this->getTable('ideal/api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-");
-
-$installer->endSetup();
-
-$installer->addAttribute('quote_payment', 'ideal_issuer_id', array());
-$installer->addAttribute('quote_payment', 'ideal_issuer_list', array('type' => 'text'));
-$installer->addAttribute('order_payment', 'ideal_issuer_id', array());
-$installer->addAttribute('order_payment', 'ideal_issuer_title', array());
-$installer->addAttribute('order_payment', 'ideal_transaction_checked', array('type'=>'int'));
diff --git a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php
index a9721c468a..7798ec4472 100644
--- a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php
+++ b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php
@@ -47,6 +47,8 @@ protected function _initProcess()
*/
public function listAction()
{
+ $this->_title($this->__('System'))->_title($this->__('Index Management'));
+
$this->loadLayout();
$this->_setActiveMenu('system/index');
$this->_addContent($this->getLayout()->createBlock('index/adminhtml_process'));
@@ -60,6 +62,12 @@ public function editAction()
{
$process = $this->_initProcess();
if ($process) {
+ $this->_title($process->getIndexCode());
+
+ $this->_title($this->__('System'))
+ ->_title($this->__('Index Management'))
+ ->_title($this->__($process->getIndexer()->getName()));
+
Mage::register('current_index_process', $process);
$this->loadLayout();
$this->renderLayout();
diff --git a/app/code/core/Mage/Install/Block/End.php b/app/code/core/Mage/Install/Block/End.php
index 0fc086503c..cfae42e899 100644
--- a/app/code/core/Mage/Install/Block/End.php
+++ b/app/code/core/Mage/Install/Block/End.php
@@ -23,7 +23,7 @@
* @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)
*/
-
+
/**
* Installation ending block
*
@@ -31,12 +31,12 @@
*/
class Mage_Install_Block_End extends Mage_Install_Block_Abstract
{
- public function __construct()
+ public function __construct()
{
parent::__construct();
$this->setTemplate('install/end.phtml');
}
-
+
public function getEncryptionKey()
{
$key = $this->getData('encryption_key');
@@ -46,4 +46,19 @@ public function getEncryptionKey()
}
return $key;
}
+
+ /**
+ * Return url for iframe source
+ *
+ * @return string
+ */
+ public function getIframeSourceUrl()
+ {
+ if (!Mage_AdminNotification_Model_Survey::isSurveyUrlValid()
+ || Mage::getSingleton('install/installer')->getHideIframe())
+ {
+ return null;
+ }
+ return Mage_AdminNotification_Model_Survey::getSurveyUrl();
+ }
}
diff --git a/app/code/core/Mage/Install/controllers/WizardController.php b/app/code/core/Mage/Install/controllers/WizardController.php
index a988e90119..064652d10c 100644
--- a/app/code/core/Mage/Install/controllers/WizardController.php
+++ b/app/code/core/Mage/Install/controllers/WizardController.php
@@ -432,6 +432,8 @@ public function endAction()
$this->_getInstaller()->finish();
+ Mage_AdminNotification_Model_Survey::saveSurveyViewed(true);
+
$this->_prepareLayout();
$this->_initLayoutMessages('install/session');
diff --git a/app/code/core/Mage/Newsletter/Model/Mysql4/Subscriber/Collection.php b/app/code/core/Mage/Newsletter/Model/Mysql4/Subscriber/Collection.php
index 12a886bd5f..d8a4a6e784 100644
--- a/app/code/core/Mage/Newsletter/Model/Mysql4/Subscriber/Collection.php
+++ b/app/code/core/Mage/Newsletter/Model/Mysql4/Subscriber/Collection.php
@@ -89,6 +89,14 @@ protected function _construct()
$this->_queueLinkTable = Mage::getSingleton('core/resource')->getTableName('newsletter/queue_link');
$this->_storeTable = Mage::getSingleton('core/resource')->getTableName('core/store');
$this->_init('newsletter/subscriber');
+
+ // defining mapping for fields represented in several tables
+ $this->_map['fields']['customer_lastname'] = 'customer_lastname_table.value';
+ $this->_map['fields']['customer_firstname'] = 'customer_firstname_table.value';
+ $this->_map['fields']['type'] = 'IF(main_table.customer_id = 0, 1, 2)';
+ $this->_map['fields']['website_id'] = 'store.website_id';
+ $this->_map['fields']['group_id'] = 'store.group_id';
+ $this->_map['fields']['store_id'] = 'main_table.store_id';
}
/**
@@ -152,10 +160,15 @@ public function showCustomerInfo()
return $this;
}
+ /**
+ * Add type field expression to select
+ *
+ * @return Mage_Newsletter_Model_Mysql4_Subscriber_Collection
+ */
public function addSubscriberTypeField()
{
$this->getSelect()
- ->columns(array('type'=>new Zend_Db_Expr('IF(main_table.customer_id = 0, 1, 2)')));
+ ->columns(array('type'=>new Zend_Db_Expr($this->_getMappedField('type'))));
return $this;
}
@@ -176,15 +189,12 @@ public function showStoreInfo()
return $this;
}
- public function addFieldToFilter($field, $condition=null)
- {
- if(!is_null($condition)) {
- parent::addFieldToFilter($field, $condition);
- $this->_countFilterPart[] = $this->_getConditionSql($this->_getFieldTableAlias($field), $condition);
- }
- return $this;
- }
-
+ /**
+ * @deprecated after 1.4.0.0-rc1
+ *
+ * @param string $field
+ * @return string
+ */
public function _getFieldTableAlias($field)
{
if (strpos($field,'customer') === 0) {
diff --git a/app/code/core/Mage/Ogone/Block/Form.php b/app/code/core/Mage/Ogone/Block/Form.php
deleted file mode 100644
index c0a4b28f80..0000000000
--- a/app/code/core/Mage/Ogone/Block/Form.php
+++ /dev/null
@@ -1,39 +0,0 @@
-setTemplate('ogone/form.phtml');
- }
-}
diff --git a/app/code/core/Mage/Ogone/Block/Paypage.php b/app/code/core/Mage/Ogone/Block/Paypage.php
deleted file mode 100644
index 60136e1cf4..0000000000
--- a/app/code/core/Mage/Ogone/Block/Paypage.php
+++ /dev/null
@@ -1,41 +0,0 @@
-setTemplate('ogone/paypage.phtml');
- return $this;
- }
-}
diff --git a/app/code/core/Mage/Ogone/Block/Placeform.php b/app/code/core/Mage/Ogone/Block/Placeform.php
deleted file mode 100644
index 618bec4899..0000000000
--- a/app/code/core/Mage/Ogone/Block/Placeform.php
+++ /dev/null
@@ -1,90 +0,0 @@
-getOrder()) {
- $order = $this->getOrder();
- } else if ($this->getCheckout()->getLastRealOrderId()) {
- $order = Mage::getModel('sales/order')->loadByIncrementId($this->getCheckout()->getLastRealOrderId());
- } else {
- return null;
- }
- return $order;
- }
-
- /**
- * Get Form data by using ogone payment api
- *
- * @return array
- */
- public function getFormData()
- {
- return $this->_getApi()->getFormFields($this->_getOrder());
- }
-
- /**
- * Getting gateway url
- *
- * @return string
- */
- public function getFormAction()
- {
- return $this->_getApi()->getConfig()->getGatewayPath();
- }
-}
diff --git a/app/code/core/Mage/Ogone/Helper/Data.php b/app/code/core/Mage/Ogone/Helper/Data.php
deleted file mode 100644
index 1f461918e5..0000000000
--- a/app/code/core/Mage/Ogone/Helper/Data.php
+++ /dev/null
@@ -1,70 +0,0 @@
-_config = Mage::getSingleton('ogone/config');
- return $this;
- }
-
- /**
- * Return ogone config instance
- *
- * @return Mage_Ogone_Model_Config
- */
- public function getConfig()
- {
- return $this->_config;
- }
-
- /**
- * Return debug flag by storeConfig
- *
- * @param int storeId
- * @return bool
- */
- public function getDebug($storeId=null)
- {
- return $this->getConfig()->getConfigData('debug_flag', $storeId);
- }
-
- /**
- * Flag witch prevent automatic invoice creation
- *
- * @return bool
- */
- public function isInitializeNeeded()
- {
- return true;
- }
-
- /**
- * Redirect url to ogone submit form
- *
- * @return string
- */
- public function getOrderPlaceRedirectUrl()
- {
- return Mage::getUrl('ogone/api/placeform', array('_secure' => true));
- }
-
- /**
- * Return payment_action value from config area
- *
- * @return string
- */
- public function getPaymentAction()
- {
- return $this->getConfig()->getConfigData('payment_action');
- }
-
- /**
- * Rrepare params array to send it to gateway page via POST
- *
- * @param Mage_Sales_Model_Order
- * @return array
- */
- public function getFormFields($order)
- {
- if (empty($order)) {
- if (!($order = $this->getOrder())) {
- return array();
- }
- }
- $billingAddress = $order->getBillingAddress();
- $formFields = array();
- $formFields['PSPID'] = $this->getConfig()->getPSPID();
- $formFields['orderID'] = $order->getIncrementId();
- $formFields['amount'] = round($order->getBaseGrandTotal()*100);
- $formFields['currency'] = Mage::app()->getStore()->getBaseCurrencyCode();
- $formFields['language'] = Mage::app()->getLocale()->getLocaleCode();
-
- $formFields['CN'] = $this->_translate($billingAddress->getFirstname().' '.$billingAddress->getLastname());
- $formFields['EMAIL'] = $order->getCustomerEmail();
- $formFields['ownerZIP'] = $billingAddress->getPostcode();
- $formFields['ownercty'] = $billingAddress->getCountry();
- $formFields['ownertown']= $this->_translate($billingAddress->getCity());
- $formFields['COM'] = $this->_translate($this->_getOrderDescription($order));
- $formFields['ownertelno'] = $billingAddress->getTelephone();
- $formFields['owneraddress'] = $this->_translate(str_replace("\n", ' ',$billingAddress->getStreet(-1)));
-
- $paymentAction = $this->_getOgonePaymentOperation();
- if ($paymentAction ) {
- $formFields['operation'] = $paymentAction;
- }
-
- $secretCode = $this->getConfig()->getShaOutCode();
- $secretSet = $formFields['orderID'] . $formFields['amount'] . $formFields['currency'] .
- $formFields['PSPID'] . $paymentAction . $secretCode;
-
- $formFields['SHASign'] = Mage::helper('ogone')->shaCrypt($secretSet);
-
- $formFields['homeurl'] = $this->getConfig()->getHomeUrl();
- $formFields['catalogurl'] = $this->getConfig()->getHomeUrl();
- $formFields['accepturl'] = $this->getConfig()->getAcceptUrl();
- $formFields['declineurl'] = $this->getConfig()->getDeclineUrl();
- $formFields['exceptionurl'] = $this->getConfig()->getExceptionUrl();
- $formFields['cancelurl'] = $this->getConfig()->getCancelUrl();
-
- if ($this->getConfig()->getConfigData('template')=='ogone') {
- $formFields['TP']= '';
- $formFields['PMListType'] = $this->getConfig()->getConfigData('pmlist');
- } else {
- $formFields['TP']= $this->getConfig()->getPayPageTemplate();
- }
- $formFields['TITLE'] = $this->_translate($this->getConfig()->getConfigData('html_title'));
- $formFields['BGCOLOR'] = $this->getConfig()->getConfigData('bgcolor');
- $formFields['TXTCOLOR'] = $this->getConfig()->getConfigData('txtcolor');
- $formFields['TBLBGCOLOR'] = $this->getConfig()->getConfigData('tblbgcolor');
- $formFields['TBLTXTCOLOR'] = $this->getConfig()->getConfigData('tbltxtcolor');
- $formFields['BUTTONBGCOLOR'] = $this->getConfig()->getConfigData('buttonbgcolor');
- $formFields['BUTTONTXTCOLOR'] = $this->getConfig()->getConfigData('buttontxtcolor');
- $formFields['FONTTYPE'] = $this->getConfig()->getConfigData('fonttype');
- $formFields['LOGO'] = $this->getConfig()->getConfigData('logo');
- return $formFields;
- }
-
- /**
- * to translate UTF 8 to ISO 8859-1
- * Ogone system is only compatible with iso-8859-1 and does not (yet) fully support the utf-8
- */
- protected function _translate($text)
- {
- return htmlentities(iconv("UTF-8", "ISO-8859-1", $text));
- }
-
- /**
- * Get Ogone Payment Action value
- *
- * @param string
- * @return string
- */
- protected function _getOgonePaymentOperation()
- {
- $value = $this->getPaymentAction();
- if ($value==Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
- $value = Mage_Ogone_Model_Api::OGONE_AUTHORIZE_ACTION;
- } elseif ($value==Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
- $value = Mage_Ogone_Model_Api::OGONE_AUTHORIZE_CAPTURE_ACTION;
- }
- return $value;
- }
-
- /**
- * get formated order description
- *
- * @param Mage_Sales_Model_Order
- * @return string
- */
- protected function _getOrderDescription($order)
- {
- $invoiceDesc = '';
- $lengs = 0;
- foreach ($order->getAllItems() as $item) {
- if ($item->getParentItem()) {
- continue;
- }
- if (Mage::helper('core/string')->strlen($invoiceDesc.$item->getName()) > 10000) {
- break;
- }
- $invoiceDesc .= $item->getName() . ', ';
- }
- return Mage::helper('core/string')->substr($invoiceDesc, 0, -2);
- }
-}
diff --git a/app/code/core/Mage/Ogone/Model/Api/Debug.php b/app/code/core/Mage/Ogone/Model/Api/Debug.php
deleted file mode 100644
index fb00951991..0000000000
--- a/app/code/core/Mage/Ogone/Model/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-_init('ogone/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Ogone/Model/Config.php b/app/code/core/Mage/Ogone/Model/Config.php
deleted file mode 100644
index e75a4f760e..0000000000
--- a/app/code/core/Mage/Ogone/Model/Config.php
+++ /dev/null
@@ -1,151 +0,0 @@
-decrypt($this->getConfigData('secret_key_in', $storeId));
- }
-
- /**
- * Return SHA1-out crypt key from config. Setup on admin place.
- * @param int $storeId
- * @return string
- */
- public function getShaOutCode($storeId=null)
- {
- return Mage::helper('core')->decrypt($this->getConfigData('secret_key_out', $storeId));
- }
-
- /**
- * Return gateway path, get from confing. Setup on admin place.
- *
- * @param int $storeId
- * @return string
- */
- public function getGatewayPath($storeId=null)
- {
- return $this->getConfigData('ogone_gateway', $storeId);
- }
-
- /**
- * Get PSPID, affiliation name in ogone system
- *
- * @param int $storeId
- * @return string
- */
- public function getPSPID($storeId=null)
- {
- return $this->getConfigData('pspid', $storeId);
- }
-
- /**
- * Get paypage template for magento style templates using
- *
- * @return string
- */
- public function getPayPageTemplate()
- {
- return Mage::getUrl('ogone/api/paypage');
- }
-
- /**
- * Return url which ogone system will use as accept
- *
- * @return string
- */
- public function getAcceptUrl()
- {
- return Mage::getUrl('ogone/api/accept');
- }
-
- /**
- * Return url which ogone system will use as decline url
- *
- * @return string
- */
- public function getDeclineUrl()
- {
- return Mage::getUrl('ogone/api/decline');
- }
-
- /**
- * Return url which ogone system will use as exception url
- *
- * @return string
- */
- public function getExceptionUrl()
- {
- return Mage::getUrl('ogone/api/exception');
- }
-
- /**
- * Return url which ogone system will use as cancel url
- *
- * @return string
- */
- public function getCancelUrl()
- {
- return Mage::getUrl('ogone/api/cancel');
- }
-
- /**
- * Return url which ogone system will use as our magento home url on ogone success page
- *
- * @return string
- */
- public function getHomeUrl()
- {
- return Mage::getUrl('checkout/cart');
- }
-}
diff --git a/app/code/core/Mage/Ogone/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Ogone/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index ef075451e4..0000000000
--- a/app/code/core/Mage/Ogone/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-_init('ogone/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Ogone/Model/Source/PaymentAction.php b/app/code/core/Mage/Ogone/Model/Source/PaymentAction.php
deleted file mode 100644
index 4c21a81571..0000000000
--- a/app/code/core/Mage/Ogone/Model/Source/PaymentAction.php
+++ /dev/null
@@ -1,45 +0,0 @@
- '', 'label' => Mage::helper('ogone')->__('Ogone default Operation')),
- array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, 'label' => Mage::helper('ogone')->__('Authorization')),
- array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, 'label' => Mage::helper('ogone')->__('Direct Sale')),
- );
- }
-}
diff --git a/app/code/core/Mage/Ogone/Model/Source/Pmlist.php b/app/code/core/Mage/Ogone/Model/Source/Pmlist.php
deleted file mode 100644
index 0552ed8fdf..0000000000
--- a/app/code/core/Mage/Ogone/Model/Source/Pmlist.php
+++ /dev/null
@@ -1,45 +0,0 @@
- Mage_Ogone_Model_Api::PMLIST_HORISONTAL_LEFT, 'label' => Mage::helper('ogone')->__('Horizontally grouped logo with group name on left')),
- array('value' => Mage_Ogone_Model_Api::PMLIST_HORISONTAL, 'label' => Mage::helper('ogone')->__('Horizontally grouped logo with no group name')),
- array('value' => Mage_Ogone_Model_Api::PMLIST_VERTICAL, 'label' => Mage::helper('ogone')->__('Verical list')),
- );
- }
-}
diff --git a/app/code/core/Mage/Ogone/Model/Source/Template.php b/app/code/core/Mage/Ogone/Model/Source/Template.php
deleted file mode 100644
index ee49d3bd87..0000000000
--- a/app/code/core/Mage/Ogone/Model/Source/Template.php
+++ /dev/null
@@ -1,44 +0,0 @@
- Mage_Ogone_Model_Api::TEMPLATE_OGONE, 'label' => Mage::helper('ogone')->__('Ogone')),
- array('value' => Mage_Ogone_Model_Api::TEMPLATE_MAGENTO, 'label' => Mage::helper('ogone')->__('Magento')),
- );
- }
-}
diff --git a/app/code/core/Mage/Ogone/controllers/ApiController.php b/app/code/core/Mage/Ogone/controllers/ApiController.php
deleted file mode 100644
index c764deda55..0000000000
--- a/app/code/core/Mage/Ogone/controllers/ApiController.php
+++ /dev/null
@@ -1,492 +0,0 @@
-_order)) {
- $orderId = $this->getRequest()->getParam('orderID');
- $this->_order = Mage::getModel('sales/order');
- $this->_order->loadByIncrementId($orderId);
- }
- return $this->_order;
- }
-
- /**
- * Validation of incoming Ogone data
- *
- * @return bool
- */
- protected function _validateOgoneData()
- {
- if ($this->_getApi()->getDebug()) {
- $debug = Mage::getModel('ogone/api_debug')
- ->setDir('in')
- ->setUrl($this->getRequest()->getPathInfo())
- ->setData('data',http_build_query($this->getRequest()->getParams()))
- ->save();
- }
-
- $params = $this->getRequest()->getParams();
- $secureKey = $this->_getApi()->getConfig()->getShaInCode();
- $secureSet = $this->_getSHAInSet($params, $secureKey);
-
- if (Mage::helper('ogone')->shaCryptValidation($secureSet, $params['SHASIGN'])!=true) {
- $this->_getCheckout()->addError($this->__('Hash is not valid'));
- return false;
- }
-
- $order = $this->_getOrder();
- if (!$order->getId()){
- $this->_getCheckout()->addError($this->__('Order is not valid'));
- return false;
- }
-
- return true;
- }
-
- /**
- * Load place from layout to make POST on ogone
- */
- public function placeformAction()
- {
- $lastIncrementId = $this->_getCheckout()->getLastRealOrderId();
- if ($lastIncrementId) {
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($lastIncrementId);
- if ($order->getId()) {
- $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Ogone_Model_Api::PENDING_OGONE_STATUS, Mage::helper('ogone')->__('Start ogone processing'));
- $order->save();
-
- if ($this->_getApi()->getDebug()) {
- $debug = Mage::getModel('ogone/api_debug')
- ->setDir('out')
- ->setUrl($this->getRequest()->getPathInfo())
- ->setData('data', http_build_query($this->_getApi()->getFormFields($order)))
- ->save();
- }
- }
- }
-
- $this->_getCheckout()->getQuote()->setIsActive(false)->save();
- $this->_getCheckout()->setOgoneQuoteId($this->_getCheckout()->getQuoteId());
- $this->_getCheckout()->setOgoneLastSuccessQuoteId($this->_getCheckout()->getLastSuccessQuoteId());
- $this->_getCheckout()->clear();
-
- $this->loadLayout();
- $this->renderLayout();
- }
-
- /**
- * Display our pay page, need to ogone payment with external pay page mode *
- */
- public function paypageAction()
- {
- $this->loadLayout();
- $this->renderLayout();
- }
-
- /**
- * Action to control postback data from ogone
- *
- */
- public function postBackAction()
- {
- if (!$this->_validateOgoneData()) {
- $this->getResponse()->setHeader("Status", "404 Not Found");
- return false;
- }
-
- $this->_ogoneProcess();
- }
-
- /**
- * Action to process ogone offline data
- *
- */
- public function offlineProcessAction()
- {
- if (!$this->_validateOgoneData()) {
- $this->getResponse()->setHeader("Status","404 Not Found");
- return false;
- }
- $this->_ogoneProcess();
- }
-
- /**
- * Made offline ogone data processing, depending of incoming statuses
- */
- protected function _ogoneProcess()
- {
- $status = $this->getRequest()->getParam('STATUS');
- switch ($status) {
- case Mage_Ogone_Model_Api::OGONE_AUTHORIZED :
- case Mage_Ogone_Model_Api::OGONE_AUTH_PROCESSING:
- case Mage_Ogone_Model_Api::OGONE_PAYMENT_REQUESTED_STATUS :
- $this->_acceptProcess();
- break;
- case Mage_Ogone_Model_Api::OGONE_AUTH_REFUZED:
- case Mage_Ogone_Model_Api::OGONE_PAYMENT_INCOMPLETE:
- case Mage_Ogone_Model_Api::OGONE_TECH_PROBLEM:
- $this->_declineProcess();
- break;
- case Mage_Ogone_Model_Api::OGONE_AUTH_UKNKOWN_STATUS:
- case Mage_Ogone_Model_Api::OGONE_PAYMENT_UNCERTAIN_STATUS:
- $this->_exceptionProcess();
- break;
- default:
- //all unknown transaction will accept as exceptional
- $this->_exceptionProcess();
- }
- }
-
- /**
- * when payment gateway accept the payment, it will land to here
- * need to change order status as processed ogone
- * update transaction id
- *
- */
- public function acceptAction()
- {
- if (!$this->_validateOgoneData()) {
- $this->_redirect('checkout/cart');
- return;
- }
- $this->_ogoneProcess();
- }
-
- /**
- * Process success action by accept url
- */
- protected function _acceptProcess()
- {
- $params = $this->getRequest()->getParams();
- $order = $this->_getOrder();
-
- $this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
-
- $this->_prepareCCInfo($order, $params);
- $order->getPayment()->setLastTransId($params['PAYID']);
-
- try{
- if ($this->_getApi()->getPaymentAction()==Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
- $this->_processDirectSale();
- } else {
- $this->_processAuthorize();
- }
- }catch(Exception $e) {
- $this->_getCheckout()->addError(Mage::helper('ogone')->__('Order can\'t save'));
- $this->_redirect('checkout/cart');
- return;
- }
- }
-
- /**
- * Process Configured Payment Action: Direct Sale, create invoce if state is Pending
- *
- */
- protected function _processDirectSale()
- {
- $order = $this->_getOrder();
- $status = $this->getRequest()->getParam('STATUS');
- try{
- if ($status == Mage_Ogone_Model_Api::OGONE_AUTH_PROCESSING) {
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Ogone_Model_Api::WAITING_AUTHORIZATION, Mage::helper('ogone')->__('Authorization Waiting from Ogone'));
- $order->save();
- }elseif ($order->getState()==Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
- if ($status == Mage_Ogone_Model_Api::OGONE_AUTHORIZED) {
- if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Ogone_Model_Api::PROCESSING_OGONE_STATUS, Mage::helper('ogone')->__('Processed by Ogone'));
- }
- } else {
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Ogone_Model_Api::PROCESSED_OGONE_STATUS, Mage::helper('ogone')->__('Processed by Ogone'));
- }
-
- if (!$order->getInvoiceCollection()->getSize()) {
- $invoice = $order->prepareInvoice();
- $invoice->register();
- $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
- $invoice->getOrder()->setIsInProcess(true);
-
- $transactionSave = Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
- $order->sendNewOrderEmail();
- }
- } else {
- $order->save();
- }
- $this->_redirect('checkout/onepage/success');
- return;
- } catch (Exception $e) {
- $this->_getCheckout()->addError(Mage::helper('ogone')->__('Order can\'t save'));
- $this->_redirect('checkout/cart');
- return;
- }
- }
-
- /**
- * Process Configured Payment Actions: Authorized, Default operation
- * just place order
- */
- protected function _processAuthorize()
- {
- $order = $this->_getOrder();
- $status = $this->getRequest()->getParam('STATUS');
- try {
- if ($status == Mage_Ogone_Model_Api::OGONE_AUTH_PROCESSING) {
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Ogone_Model_Api::WAITING_AUTHORIZATION, Mage::helper('ogone')->__('Authorization Waiting from Ogone'));
- } else {
- //to send new order email only when state is pending payment
- if ($order->getState()==Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
- $order->sendNewOrderEmail();
- }
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Ogone_Model_Api::PROCESSED_OGONE_STATUS, Mage::helper('ogone')->__('Processed by Ogone'));
- }
- $order->save();
- $this->_redirect('checkout/onepage/success');
- return;
- } catch(Exception $e) {
- $this->_getCheckout()->addError(Mage::helper('ogone')->__('Order can\'t save'));
- $this->_redirect('checkout/cart');
- return;
- }
- }
-
- /**
- * We get some CC info from ogone, so we must save it
- *
- * @param Mage_Sales_Model_Order $order
- * @param array $ccInfo
- *
- * @return Mage_Ogone_ApiController
- */
- protected function _prepareCCInfo($order, $ccInfo)
- {
- $order->getPayment()->setCcOwner($ccInfo['CN']);
- $order->getPayment()->setCcNumberEnc($ccInfo['CARDNO']);
- $order->getPayment()->setCcLast4(substr($ccInfo['CARDNO'], -4));
- $order->getPayment()->setCcExpMonth(substr($ccInfo['ED'], 0, 2));
- $order->getPayment()->setCcExpYear(substr($ccInfo['ED'], 2, 2));
- return $this;
- }
-
-
- /**
- * the payment result is uncertain
- * exception status can be 52 or 92
- * need to change order status as processing ogone
- * update transaction id
- *
- */
- public function exceptionAction()
- {
- if (!$this->_validateOgoneData()) {
- $this->_redirect('checkout/cart');
- return;
- }
- $this->_exceptionProcess();
- }
-
- /**
- * Process exception action by ogone exception url
- */
- public function _exceptionProcess()
- {
- $params = $this->getRequest()->getParams();
- $order = $this->_getOrder();
-
- $exception = '';
- switch($params['STATUS']) {
- case Mage_Ogone_Model_Api::OGONE_PAYMENT_UNCERTAIN_STATUS :
- $exception = Mage::helper('ogone')->__('Payment uncertain: A technical problem arose during payment process, giving unpredictable result');
- break;
- case Mage_Ogone_Model_Api::OGONE_AUTH_UKNKOWN_STATUS :
- $exception = Mage::helper('ogone')->__('Authorization not known: A technical problem arose during authorization process, giving unpredictable result');
- break;
- default:
- $exception = Mage::helper('ogone')->__('Unknown exception');
- }
-
- if (!empty($exception)) {
- try{
- $this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
- $this->_prepareCCInfo($order, $params);
- $order->getPayment()->setLastTransId($params['PAYID']);
- //to send new order email only when state is pending payment
- if ($order->getState()==Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
- $order->sendNewOrderEmail();
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Ogone_Model_Api::PROCESSING_OGONE_STATUS, $exception);
- } else {
- $order->addStatusToHistory(Mage_Ogone_Model_Api::PROCESSING_OGONE_STATUS, $exception);
- }
- $order->save();
- }catch(Exception $e) {
- $this->_getCheckout()->addError(Mage::helper('ogone')->__('Order can not be save for system reason'));
- }
- } else {
- $this->_getCheckout()->addError(Mage::helper('ogone')->__('Exception not defined'));
- }
-
- $this->_redirect('checkout/onepage/success');
- }
-
- /**
- * when payment got decline
- * need to change order status to cancelled
- * take the user back to shopping cart
- *
- */
- public function declineAction()
- {
- if (!$this->_validateOgoneData()) {
- $this->_redirect('checkout/cart');
- return;
- }
- $this->_getCheckout()->setQuoteId($this->_getCheckout()->getOgoneQuoteId());
- $this->_declineProcess();
- return $this;
- }
-
- /**
- * Process decline action by ogone decline url
- */
- protected function _declineProcess()
- {
- $status = Mage_Ogone_Model_Api::DECLINE_OGONE_STATUS;
- $comment = Mage::helper('ogone')->__('Declined Order on ogone side');
- $this->_getCheckout()->addError(Mage::helper('ogone')->__('Payment transaction has been declined.'));
- $this->_cancelOrder($status, $comment);
- }
-
- /**
- * when user cancel the payment
- * change order status to cancelled
- * need to rediect user to shopping cart
- *
- * @return Mage_Ogone_ApiController
- */
- public function cancelAction()
- {
- if (!$this->_validateOgoneData()) {
- $this->_redirect('checkout/cart');
- return;
- }
- $this->_getCheckout()->setQuoteId($this->_getCheckout()->getOgoneQuoteId());
- $this->_cancelProcess();
- return $this;
- }
-
- /**
- * Process cancel action by cancel url
- *
- * @return Mage_Ogone_ApiController
- */
- public function _cancelProcess()
- {
- $status = Mage_Ogone_Model_Api::CANCEL_OGONE_STATUS;
- $comment = Mage::helper('ogone')->__('Order canceled on ogone side');
- $this->_cancelOrder($status, $comment);
- return $this;
- }
-
- /**
- * Cancel action, used for decline and cancel processes
- *
- * @return Mage_Ogone_ApiController
- */
- protected function _cancelOrder($status, $comment='')
- {
- $order = $this->_getOrder();
- try{
- $order->cancel();
- $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, $status, $comment);
- $order->save();
- }catch(Exception $e) {
- $this->_getCheckout()->addError(Mage::helper('ogone')->__('Order can not be canceled for system reason'));
- }
-
- $this->_redirect('checkout/cart');
- return $this;
- }
-
- /**
- * Return set of data which is ready for SHA crypt
- *
- * @param array $data
- * @param string $key
- *
- * @return string
- */
- protected function _getSHAInSet($params, $key)
- {
- return $this->getRequest()->getParam('orderID') .
- $this->getRequest()->getParam('currency') .
- $this->getRequest()->getParam('amount') .
- $this->getRequest()->getParam('PM') .
- $this->getRequest()->getParam('ACCEPTANCE') .
- $this->getRequest()->getParam('STATUS') .
- $this->getRequest()->getParam('CARDNO') .
- $this->getRequest()->getParam('PAYID') .
- $this->getRequest()->getParam('NCERROR') .
- $this->getRequest()->getParam('BRAND') . $key;
- }
-}
diff --git a/app/code/core/Mage/Ogone/etc/config.xml b/app/code/core/Mage/Ogone/etc/config.xml
deleted file mode 100644
index cd68a4b1ae..0000000000
--- a/app/code/core/Mage/Ogone/etc/config.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-
-
-
-
-
- 0.0.1
-
-
-
-
-
- Mage_Ogone_Model
- ogone_mysql4
-
-
- Mage_Ogone_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Ogone
-
-
- core_setup
-
-
-
-
- core_write
-
-
-
-
- core_read
-
-
-
-
-
- Mage_Ogone_Block
-
-
-
-
-
- Pending Ogone
- Cancelled Ogone
- Declined Ogone
- Processing Ogone Payment
- Processed Ogone Payment
- Waiting Authorization
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ogone.xml
-
-
-
-
- /ogone/api
-
-
-
- standard
-
- Mage_Ogone
- ogone
-
-
-
-
-
-
-
-
- ogone/api
- Ogone
-
- authorize
- ogone
- https://secure.ogone.com/ncol/test/orderstandard.asp
- pending_ogone
- cancel_ogone
- decline_ogone
- processing_ogone
- processed_ogone
- waiting_authorozation
-
-
-
-
diff --git a/app/code/core/Mage/Ogone/etc/system.xml b/app/code/core/Mage/Ogone/etc/system.xml
deleted file mode 100644
index ba839b1ead..0000000000
--- a/app/code/core/Mage/Ogone/etc/system.xml
+++ /dev/null
@@ -1,236 +0,0 @@
-
-
-
-
-
-
-
- Ogone
-
-
-
-
Signing up with Ogone
-
Please enter the correct post back url and offline processiong url in Ogone configuration
-
post back url example: http://myMagentoStore.com/ogone/api/postBack
-
offline processing url example: http://myMagentoStore.com/ogone/api/offlineProcess
-
-
-]]>
- text
- 800
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 2
- 1
- 1
- 0
-
-
- Title
- text
- 3
- 1
- 1
- 1
-
-
- PSPID
- text
- PSPID is a case sensitive field
- 4
- 1
- 1
- 0
-
-
- SHA Signature (used by Magento)
-
- Use in Feedback data checking by Magento
- ]]>
- adminhtml/system_config_backend_encrypted
- obscure
- 5
- 1
- 1
- 0
-
-
- SHA Signature (used by Ogone)
-
- Use in data checking by Ogone before the payment.
- ]]>
- adminhtml/system_config_backend_encrypted
- obscure
- 6
- 1
- 1
- 0
-
-
- Gateway URL
- text
- For production, replace "test" with "prod" Example: https://secure.ogone.com/ncol/prod/orderstandard.asp
- 7
- 1
- 1
- 0
-
-
- Payment Action
- select
- ogone/source_paymentAction
- If you choose "No Operation", Ogone will use default Payment procedure setup in Ogone configuration
- 8
- 1
- 1
- 0
-
-
- Payment Template
- select
- ogone/source_template
- If you choose "Ogone Template", you will need to fill in all the following fields.
- 10
- 1
- 1
- 0
-
-
- Title of the Ogone Template
- text
- 11
- 1
- 1
- 1
-
-
- Background color of Ogone Template
- text
-
- 12
- 1
- 1
- 1
-
-
- Text Color of the Ogone Template
- text
-
- 13
- 1
- 1
- 1
-
-
- Table background color of the Ogone Template
- text
-
- 14
- 1
- 1
- 1
-
-
- Table text color of the Ogone Template
- text
-
- 15
- 1
- 1
- 1
-
-
- Button background color of the Ogone Template
- text
- 16
- 1
- 1
- 1
-
-
- Button text color of the Ogone Template
- text
-
- 17
- 1
- 1
- 1
-
-
- Font Family of the Ogone Template
- text
-
- 18
- 1
- 1
- 1
-
-
- Logo of the Ogone Template
- text
- The URL must be absolute and stored on a secure server.
- ]]>
- 19
- 1
- 1
- 1
-
-
- Layout of Payment Methods
- select
- ogone/source_pmlist
- You can arrange the layout/list of the payment methods on Ogone payment page
- 20
- 1
- 1
- 1
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Ogone/sql/ogone_setup/mysql4-install-0.0.1.php b/app/code/core/Mage/Ogone/sql/ogone_setup/mysql4-install-0.0.1.php
deleted file mode 100644
index 4893dbd1ff..0000000000
--- a/app/code/core/Mage/Ogone/sql/ogone_setup/mysql4-install-0.0.1.php
+++ /dev/null
@@ -1,46 +0,0 @@
-startSetup();
-
-$installer->run("
-
-DROP TABLE IF EXISTS `{$this->getTable('ogone/api_debug')}`;
-CREATE TABLE `{$this->getTable('ogone/api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `dir` enum('in', 'out'),
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `url` varchar(255),
- `data` text,
- PRIMARY KEY (`debug_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import.php
deleted file mode 100644
index 5a644813bf..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- */
-
-class Mage_Oscommerce_Block_Adminhtml_Import extends Mage_Adminhtml_Block_Widget_Grid_Container
-{
- protected $_blockGroup = 'oscommerce';
- public function __construct()
- {
- $this->_controller = 'adminhtml_import';
- $this->_headerText = Mage::helper('adminhtml')->__('Manage osCommerce Profiles');
- $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New osCommerce Profile');
- parent::__construct();
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit.php
deleted file mode 100644
index d83add003b..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit.php
+++ /dev/null
@@ -1,68 +0,0 @@
-
- */
-
-class Mage_Oscommerce_Block_Adminhtml_Import_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
-{
- protected $_blockGroup = 'oscommerce';
-
- public function __construct()
- {
- $this->_objectId = 'id';
- $this->_controller = 'adminhtml_import';
- $this->_updateButton('save', 'label', Mage::helper('oscommerce')->__('Save Profile'));
- $this->_updateButton('delete', 'label', Mage::helper('oscommerce')->__('Delete Profile'));
- $this->_addButton('save_and_edit_button',
- array(
- 'label' => Mage::helper('oscommerce')->__('Save And Continue Edit'),
- 'onclick' => 'saveAndContinueEdit()',
- 'class' => 'save'
- ), 100
-
- );
- $this->_formScripts[] = "
- function saveAndContinueEdit(){
- editForm.submit($('edit_form').action+'continue/back/');
- }
- ";
- parent::__construct();
- }
-
- public function getHeaderText()
- {
- if (Mage::registry('oscommerce_adminhtml_import')->getId()) { // TOCHECK
- return Mage::helper('oscommerce')->__('Edit osCommerce Profile :: %s', Mage::registry('oscommerce_adminhtml_import')->getName());
- }
- else {
- return Mage::helper('oscommerce')->__('New osCommerce Profile');
- }
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Form.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Form.php
deleted file mode 100644
index 7c6f9e59d4..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Form.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- */
-
-class Mage_Oscommerce_Block_Adminhtml_Import_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
-{
- protected function _prepareForm()
- {
- $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'POST'));
-
- $model = Mage::registry('oscommerce_adminhtml_import');
-
- if ($model->getId()) {
- $form->addField('import_id', 'hidden', array(
- 'name' => 'import_id',
- ));
- $form->setValues($model->getData());
- }
-
- $form->setUseContainer(true);
- $this->setForm($form);
- return parent::_prepareForm();
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tab/General.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tab/General.php
deleted file mode 100644
index 2a0111cb94..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tab/General.php
+++ /dev/null
@@ -1,110 +0,0 @@
-
- */
-class Mage_Oscommerce_Block_Adminhtml_Import_Edit_Tab_General extends Mage_Adminhtml_Block_Widget_Form
-{
-
- function initForm()
- {
- $model = Mage::registry('oscommerce_adminhtml_import');
-
-
- $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
-
- if ($model->getId()) {
- $form->addField('import_id', 'hidden', array(
- 'name' => 'import_id',
- ));
- }
- $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('oscommerce')->__('General Information')));
- $fieldset->addField('name', 'text', array(
- 'label' => $this->__('Name'),
- 'title' => $this->__('Name'),
- 'name' => 'name',
- 'required' => true,
- ));
-
- $fieldset->addField('host', 'text', array(
- 'label' => $this->__('IP or Hostname'),
- 'title' => $this->__('IP or Hostname'),
- 'name' => 'host',
- 'required' => true,
- ));
-
-// $fieldset->addField('port', 'text', array(
-// 'label' => $this->__('Port (Default as 3306)'),
-// 'title' => $this->__('Port (Default as 3306)'),
-// 'name' => 'port',
-// 'required' => true,
-// 'value' => $model->getData('port') ? $model->getData('port'): Mage_Oscommerce_Model_Oscommerce::DEFAULT_PORT
-// ));
-
- $fieldset->addField('db_name', 'text', array(
- 'label' => $this->__('DB Name'),
- 'title' => $this->__('DB Name'),
- 'name' => 'db_name',
- 'required' => true,
- ));
-
- $fieldset->addField('db_user', 'text', array(
- 'label' => $this->__('DB Username'),
- 'title' => $this->__('DB Username'),
- 'name' => 'db_user',
- 'required' => true,
- ));
-
- $fieldset->addField('db_password', 'password', array(
- 'label' => $this->__('DB Password'),
- 'title' => $this->__('DB Password'),
- 'name' => 'db_password',
- ));
-
- $fieldset->addField('table_prefix', 'text', array(
- 'label' => $this->__('Prefix'),
- 'title' => $this->__('Prefix'),
- 'name' => 'table_prefix',
- ));
-
- $fieldset->addField('send_subscription', 'checkbox', array(
- 'label' => $this->__('Send subscription notify to customers'),
- 'title' => $this->__('Send subscription notify to customers'),
- 'name' => 'send_subscription',
- 'values' => $this->getData('send_subscription'),
- 'checked' => $this->getData('send_subscription'),
- ));
-
- $form->setValues($model->getData());
-
- $this->setForm($form);
-
- return $this;
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tab/Run.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tab/Run.php
deleted file mode 100644
index 7e2c59f5da..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tab/Run.php
+++ /dev/null
@@ -1,239 +0,0 @@
-
- */
-class Mage_Oscommerce_Block_Adminhtml_Import_Edit_Tab_Run extends Mage_Adminhtml_Block_Template
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('oscommerce/convert/run.phtml');
- }
-
- /**
- * Prepares layout of block
- *
- */
- protected function _prepareLayout()
- {
- $this->setChild('save_button',
- $this->getLayout()->createBlock('adminhtml/widget_button')
- ->setData(array(
- 'label' => Mage::helper('oscommerce')->__('Start Runing!'),
- 'class' => 'run',
- 'id' => 'run_import'
- ))
-
- );
-
- $this->setChild('check_button',
- $this->getLayout()->createBlock('adminhtml/widget_button')
- ->setData(array(
- 'label' => Mage::helper('oscommerce')->__('Check requirements!'),
- 'class' => 'run',
- 'id' => 'check_import'
- ))
-
- );
-
- }
-
- public function getImportId()
- {
- return Mage::registry('oscommerce_adminhtml_import')->getId();
- }
-
- /**
- * Retrieve run url
- *
- * @return string
- */
- public function getSubmitUrl()
- {
- return $this->getUrl('*/*/run/', array('id'=>$this->getOscId()));
- }
-
- /**
- * Retrive run button html
- *
- * @return string
- */
- public function getSaveButtonHtml()
- {
- return $this->getChildHtml('save_button');
- }
-
- public function getCheckButtonHtml()
- {
- return $this->getChildHtml('check_button');
- }
-
- public function getWebsiteOptionHtml()
- {
-
- $html = '';
- $html .= ' '.Mage::helper('oscommerce')->__('Select a website'). ' ';
- $websites = Mage::app()->getWebsites();
- $websiteData = array();
- if ($websites) foreach($websites as $website) {
- $html .= '' . $website->getName() . ' ';
- }
- $html .= ' ';
- return $html;
- }
-
- public function getTimezoneOptionHtml()
- {
- $html = '';
- $html .= ' '.Mage::helper('oscommerce')->__('Select a timezone'). ' ';
- $options = Mage::getModel('core/locale')->getOptionTimezones();
- if ($options) foreach($options as $option) {
- $html .= '' . $option['label'] . ' ';
- }
- $html .= ' ';
- return $html;
-
- }
-
- /**
- * Get list available for mysql connection charsets
- *
- * @return array
- */
- public function getConnectionCharsets()
- {
- $charsetList = array();
- $fileName = Mage::getModuleDir('etc','Mage_Oscommerce').DS.'charsets.xml';
- if (is_readable($fileName)) {
- $xml = new Varien_Simplexml_Config();
- $xml->loadFile($fileName);
- $charsets = $xml->getNode('charset');
- foreach($charsets as $charset) {
- $attributes = $charset->attributes();
- $code = (string) $attributes['name'];
- $charsetList[$code] = (string)$charset->family;
- }
- }
- return $charsetList;
- }
-
- /**
- * Get list available for iconv function charsets
- *
- * @return array
- */
- public function getDataCharsets()
- {
- $charsetList = array(
- 'BIG-5' => Mage::helper('oscommerce')->__('Traditional Chinese'),
- 'ISO-8859-2' => Mage::helper('oscommerce')->__('Central European'),
- 'CP850' => Mage::helper('oscommerce')->__('Western'),
- 'ISO-8859-1' => Mage::helper('oscommerce')->__('Western'),
- 'HP-ROMAN8' => Mage::helper('oscommerce')->__('Western'),
- 'KOI8-R' => Mage::helper('oscommerce')->__('Cyrillic'),
- 'ASCII' => Mage::helper('oscommerce')->__('Western'),
- 'EUC-JP' => Mage::helper('oscommerce')->__('Japanese'),
- 'SHIFT-JIS' => Mage::helper('oscommerce')->__('Japanese'),
- 'windows-1251' => Mage::helper('oscommerce')->__('Cyrillic'),
- 'ISO-8859-8' => Mage::helper('oscommerce')->__('Hebrew'),
- 'TIS-620' => Mage::helper('oscommerce')->__('Thai'),
- 'EUC-KR' => Mage::helper('oscommerce')->__('Korean'),
- 'ISO-8859-13' => Mage::helper('oscommerce')->__('Baltic'),
- 'KOI8-U' => Mage::helper('oscommerce')->__('Cyrillic'),
- 'CHINESE' => Mage::helper('oscommerce')->__('Simplified Chinese'),
- 'ISO-8859-7' => Mage::helper('oscommerce')->__('Greek'),
- 'WINDOWS-1250' => Mage::helper('oscommerce')->__('Central European'),
- 'CP936' => Mage::helper('oscommerce')->__('East Asian'),
- 'WINDOWS-1257' => Mage::helper('oscommerce')->__('Baltic'),
- 'ISO-8859-9' => Mage::helper('oscommerce')->__('South Asian'),
- 'ARMSCII-8' => Mage::helper('oscommerce')->__('South Asian'),
- 'UTF-8' => Mage::helper('oscommerce')->__('Unicode'),
- 'UCS-2' => Mage::helper('oscommerce')->__('Unicode'),
- 'CP866' => Mage::helper('oscommerce')->__('Cyrillic'),
- 'MACCENTRALEUROPE' => Mage::helper('oscommerce')->__('Central European'),
- 'MAC' => Mage::helper('oscommerce')->__('Western'),
- 'CP852' => Mage::helper('oscommerce')->__('Central European'),
- 'CP1256' => Mage::helper('oscommerce')->__('Arabic'),
- 'CP932' => Mage::helper('oscommerce')->__('Japanese'),
- );
- return $charsetList;
- }
-
- public function drowOptions($options = array())
- {
- asort($options);
- $html = '';
- foreach($options as $code => $name) {
- $html.= '' . $name . ' ('. $code .') ';
- }
-
- return $html;
- }
-
- public function getDataCharsetOptionHtml()
- {
-
- $html = '';
- $html .= ' '.Mage::helper('oscommerce')->__('Select a data charset'). ' ';
- $html .= $this->drowOptions($this->getDataCharsets());
- $html .= ' ';
- return $html;
- }
-
- public function getConnectionCharsetOptionHtml()
- {
- $html = '';
- $html .= ' '.Mage::helper('oscommerce')->__('Select a connection charset'). ' ';
- $html .= $this->drowOptions($this->getConnectionCharsets());
- $html .= ' ';
- return $html;
- }
-
- /**
- * Deprecated
- *
- * @return string
- */
- public function getCharsetOption()
- {
- $options = '';
- $fileName = Mage::getModuleDir('etc','Mage_Oscommerce').DS.'charsets.xml';
- if (is_readable($fileName)) {
- $xml = new Varien_Simplexml_Config();
- $xml->loadFile($fileName);
- $charsets = $xml->getNode('charset');
- foreach($charsets as $charset) {
- $attributes = $charset->attributes();
- $options .= '' . $charset->family . ' ('. $attributes['name'] .') ';
- }
- }
- return $options;
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tabs.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tabs.php
deleted file mode 100644
index 4fd02294f6..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Edit/Tabs.php
+++ /dev/null
@@ -1,66 +0,0 @@
-
- */
-class Mage_Oscommerce_Block_Adminhtml_Import_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
-{
- public function __construct()
- {
- parent::__construct();
- $this->setId('oscommerce_import_tabs');
- $this->setDestElementId('edit_form');
- $this->setTitle(Mage::helper('oscommerce')->__('osCommerce Profile'));
- }
-
- protected function _beforeToHtml()
- {
- $model = Mage::registry('oscommerce_adminhtml_import');
-
- $generalBlock = $this->getLayout()->createBlock('oscommerce/adminhtml_import_edit_tab_general');
- $generalBlock->addData($model->getData());
-
- $new = !$model->getId();
-
- $this->addTab('general', array(
- 'label' => Mage::helper('oscommerce')->__('General Information'),
- 'content' => $generalBlock->initForm()->toHtml(),
- 'active' => true,
- ));
-
- if (!$new) {
- $this->addTab('run', array(
- 'label' => Mage::helper('oscommerce')->__('Run Profile'),
- 'content' => $this->getLayout()->createBlock('oscommerce/adminhtml_import_edit_tab_run')->toHtml(),
- ));
- }
-
- return parent::_beforeToHtml();
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Grid.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Grid.php
deleted file mode 100644
index c078101671..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Grid.php
+++ /dev/null
@@ -1,94 +0,0 @@
-
- */
-
-class Mage_Oscommerce_Block_Adminhtml_Import_Grid extends Mage_Adminhtml_Block_Widget_Grid
-{
-
- public function __construct()
- {
- parent::__construct();
- $this->setId('convertOscGrid');
- $this->setDefaultSort('id');
- }
-
- protected function _prepareCollection()
- {
- $collection = Mage::getModel('oscommerce/oscommerce')->getCollection();
- $this->setCollection($collection);
- return parent::_prepareCollection();
- }
-
- protected function _prepareColumns()
- {
- $this->addColumn('id', array(
- 'header' =>Mage::helper('oscommerce')->__('ID'),
- 'width' =>'50px',
- 'index' =>'import_id',
- ));
- $this->addColumn('name', array(
- 'header' =>Mage::helper('oscommerce')->__('Adapter Name'),
- 'index' =>'name',
- ));
- $this->addColumn('host', array(
- 'header' =>Mage::helper('oscommerce')->__('IP or Hostname'),
- 'index' =>'host',
- 'width' =>'120px',
- ));
-
- $this->addColumn('db_name', array(
- 'header' =>Mage::helper('oscommerce')->__('Db Name'),
- 'index' =>'db_name',
- 'width' =>'120px',
- ));
-
- $this->addColumn('created_at', array(
- 'header' =>Mage::helper('oscommerce')->__('Created At'),
- 'type' => 'date',
- 'align' => 'center',
- 'index' =>'created_at',
- ));
- $this->addColumn('updated_at', array(
- 'header' =>Mage::helper('oscommerce')->__('Updated At'),
- 'type' => 'date',
- 'align' => 'center',
- 'index' =>'updated_at',
- ));
-
- return parent::_prepareColumns();
- }
-
- public function getRowUrl($row)
- {
- return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
- }
-
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php
deleted file mode 100644
index 28b81ceeca..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php
+++ /dev/null
@@ -1,293 +0,0 @@
-
- */
-class Mage_Oscommerce_Block_Adminhtml_Import_Run extends Mage_Adminhtml_Block_Abstract
-{
- public function getImportModel()
- {
- return Mage::registry('oscommerce_adminhtml_import');
- }
-
- protected function _toHtml()
- {
- $importModel = $this->getImportModel();
-
- echo '';
-
- $headBlock = $this->getLayout()->createBlock('page/html_head');
- $headBlock->addJs('prototype/prototype.js');
- echo $headBlock->getCssJsHtml();
-
- echo '
- '.($importModel->getId() ? $this->htmlEscape($importModel->getName()) : $this->__('No osCommerce profile')).'
-';
- echo '';
- echo '';
- if ($importModel->getId()) {
- echo ' ';
- echo $this->__("Starting profile execution, please wait...");
- echo ' ';
- echo '';
- echo ' ';
- echo $this->__("Warning: Please don't close window during importing/exporting data");
- echo ' ';
- } else {
- echo ' ';
- echo $this->__("No osCommerce profile loaded...");
- }
- echo '';
- echo ' ';
-
- if ($importModel->getId()) {
- echo '';
- ob_implicit_flush();
- $showFinished = false;
- $countItems = 0;
- $batchConfig = array(
- 'styles' => array(
- 'error' => array(
- 'icon' => Mage::getDesign()->getSkinUrl('images/error_msg_icon.gif'),
- 'bg' => '#FDD'
- ),
- 'message' => array(
- 'icon' => Mage::getDesign()->getSkinUrl('images/fam_bullet_success.gif'),
- 'bg' => '#DDF'
- ),
- 'loader' => Mage::getDesign()->getSkinUrl('images/ajax-loader.gif')
- ),
- 'template' => ''
- . ' '
- . '#{text} '
- . ' ',
- 'text' => $this->__('processed %s%% %s/%s records', '#{percent}', '#{updated}', '#{total}'),
- 'successText' => $this->__('Total imported %s records (%s)', '#{updated}', '#{totalImported}')
- );
-
-
- echo '';
- echo ' ';
- echo $this->__("Finished profile execution.");
- echo ' ';
-
-
- echo " ";
-echo '
-
-
-';
-
-// echo '';
-
-
- if ($totalRecords = $importModel->getTotalRecords()) {
-
- $maxRows = $importModel->getResource()->getMaxRows();
- echo '';
- foreach($totalRecords as $importType => $totalRecord) {
- echo '';
- $page = floor($totalRecord/$maxRows) + 1;
- for ($i = 0; $i < $page; $i++) {
- $data = array(
- 'import_id' => $importModel->getId(),
- 'import_type' => $importType,
- 'from' => ($i > 0 ? $i * $maxRows:$i),
- 'is_done' => ($i == $page - 1)?true:false
- );
- echo '';
- }
-
-// if ($importType=='categories') {
-// $data = array(
-// 'import_id' => $importModel->getId(),
-// 'import_type' => $importType,
-// 'page' => 'all',
-// 'is_done' => true
-// );
-// echo '';
-//
-// } else {
-// $page = floor($totalRecord/$maxRows) + 1;
-// for ($i = 0; $i < $page; $i++) {
-// $data = array(
-// 'import_id' => $importModel->getId(),
-// 'import_type' => $importType,
-// 'from' => ($i > 0 ? $i * $maxRows:$i),
-// 'is_done' => ($i == $page - 1)?true:false
-// );
-// echo '';
-// }
-// }
- }
- echo '';
-
- }
-
- }
- echo '';
- exit;
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order.php
deleted file mode 100644
index 7d6758f894..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- */
-
-class Mage_Oscommerce_Block_Adminhtml_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
-{
- protected $_blockGroup = 'oscommerce';
- public function __construct()
- {
- $this->_controller = 'adminhtml_order';
- $this->_headerText = Mage::helper('adminhtml')->__('Manage osCommerce Orders');
- parent::__construct();
- $this->_removeButton('add');
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order/Grid.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order/Grid.php
deleted file mode 100644
index 4c4e84ddb8..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order/Grid.php
+++ /dev/null
@@ -1,128 +0,0 @@
-
- */
-
-class Mage_Oscommerce_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
-{
-
- public function __construct()
- {
- parent::__construct();
- $this->setId('oscommerceOrderGrid');
- $this->setDefaultSort('id');
- }
-
- protected function _prepareCollection()
- {
- $collection = Mage::getModel('oscommerce/oscommerce_order')->getCollection();
- $this->setCollection($collection);
- return parent::_prepareCollection();
- }
-
- protected function _prepareColumns()
- {
- $this->addColumn('order_id', array(
- 'header' =>Mage::helper('oscommerce')->__('Order #'),
- 'width' =>'50px',
- 'index' =>'osc_magento_id',
- 'type' => 'number',
- ));
-
- $this->addColumn('billing_name', array(
- 'header' =>Mage::helper('oscommerce')->__('Billing to Name'),
- 'index' =>'billing_name',
- ));
-
- $this->addColumn('delivery_name', array(
- 'header' =>Mage::helper('oscommerce')->__('Ship to Name'),
- 'index' =>'delivery_name',
- ));
-
- $this->addColumn('currency', array(
- 'header' =>Mage::helper('oscommerce')->__('Currency'),
- 'width' =>'50px',
- 'index' =>'currency',
- ));
-
- $this->addColumn('orders_total', array(
- 'header' =>Mage::helper('oscommerce')->__('Order Total'),
- 'width' =>'50px',
- 'index' =>'orders_total',
- 'type' => 'currency',
- 'currency'=>'order_currency_code'
- ));
-
- $this->addColumn('orders_status', array(
- 'header' =>Mage::helper('oscommerce')->__('Order Status'),
- 'width' =>'50px',
- 'index' =>'orders_status',
- ));
-
- $this->addColumn('date_purchased', array(
- 'header' => Mage::helper('oscommerce')->__('Purchased Year'),
- 'width' => '150px',
- 'index' => 'date_purchased',
- 'type' => 'datetime',
- ));
-
-// $this->addColumn('purchased_year', array(
-// 'header' =>Mage::helper('oscommerce')->__('Purchased Year'),
-// 'width' =>'50px',
-// 'index' =>'purchased_year',
-// 'type' => 'currency',
-// 'currency' => 'store_currency_code',
-// ));
-//
-// $this->addColumn('purchased_month', array(
-// 'header' =>Mage::helper('oscommerce')->__('Purchased Month'),
-// 'width' =>'50px',
-// 'index' =>'purchased_month',
-// 'type' => 'currency',
-// 'currency' => 'store_currency_code',
-// ));
-//
-// $this->addColumn('purchased_day', array(
-// 'header' =>Mage::helper('oscommerce')->__('Purchased Date'),
-// 'width' =>'50px',
-// 'index' =>'purchased_day',
-// 'type' => 'currency',
-// 'currency' => 'store_currency_code',
-// ));
-
- return parent::_prepareColumns();
- }
-
- public function getRowUrl($row)
- {
- return $this->getUrl('*/*/view', array('order_id'=>$row->getId()));
- }
-
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order/View.php b/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order/View.php
deleted file mode 100644
index 0b9b8697dd..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Adminhtml/Order/View.php
+++ /dev/null
@@ -1,102 +0,0 @@
-
- */
-class Mage_Oscommerce_Block_Adminhtml_Order_View extends Mage_Adminhtml_Block_Template
-{
-
- public function __construct()
- {
- parent::__construct();
- $this->setTemplate('oscommerce/order/view.phtml');
-
-
- }
-
- protected function _prepareLayout()
- {
- $this->setChild('backButton',
- $this->getLayout()->createBlock('adminhtml/widget_button')
- ->setData(array(
- 'label' => Mage::helper('oscommerce')->__('Back'),
- 'id' => 'back_button',
- 'name' => 'back_button',
- 'element_name' => 'back_button',
- 'class' => 'scalable back',
- 'onclick'=> "setLocation('".$this->getBackUrl()."')",
- ))
- );
- }
- /**
- * Retrieve order model object
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder()
- {
- return Mage::registry('current_oscommerce_order');
- }
-
- /**
- * Retrieve Order Identifier
- *
- * @return int
- */
- public function getOrderId()
- {
- return $this->getOrder()->getId();
- }
-
- public function getHeaderText()
- {
- $text = Mage::helper('oscommerce')->__('osCommerce Order # %s | Order Date %s',
- $this->getOrder()->getOrdersId(),
- $this->formatDate($this->getOrder()->getDatePurchased(), 'medium', true)
- );
- return $text;
- }
-
- public function getUrl($params='', $params2=array())
- {
- $params2['order_id'] = $this->getOrderId();
- return parent::getUrl($params, $params2);
- }
-
-
- public function getBackButtonHtml()
- {
- return $this->getChildHtml('backButton');
- }
-
- public function getBackUrl()
- {
- return $this->getUrl("*/*/");
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Order/List.php b/app/code/core/Mage/Oscommerce/Block/Order/List.php
deleted file mode 100644
index 5374da7c85..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Order/List.php
+++ /dev/null
@@ -1,73 +0,0 @@
-
- */
-class Mage_Oscommerce_Block_Order_List extends Mage_Core_Block_Template
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('oscommerce/order/list.phtml');
- $customerId = Mage::getSingleton('customer/session')->getCustomerId();
- $websiteId = $websiteId = Mage::app()->getStore()->getWebsiteId();
- $osCommerce = Mage::getModel('oscommerce/oscommerce');
- $oscOrders = $osCommerce->loadOrders($customerId, $websiteId);
- $this->setOsCommerceOrders($oscOrders);
- }
-
- protected function _prepareLayout()
- {
- $orderInfo = $this->getOrder();
- $order = $orderInfo['order'];
- if ($headBlock = $this->getLayout()->getBlock('head')) {
- $headBlock->setTitle($this->__('Order # %s', $order['orders_id']));
- }
- }
-
- public function getViewOscommerceUrl($order)
- {
- return $this->getUrl('oscommerce/order/view', array('order_id'=>$order['osc_magento_id']));
- }
-
- /**
- * Retrieve current order model instance
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder()
- {
- return Mage::registry('current_oscommerce_order');
- }
-
- public function getBackUrl()
- {
- return Mage::getUrl('*/*/history');
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Block/Order/View.php b/app/code/core/Mage/Oscommerce/Block/Order/View.php
deleted file mode 100644
index aaee6088ff..0000000000
--- a/app/code/core/Mage/Oscommerce/Block/Order/View.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
- */
-class Mage_Oscommerce_Block_Order_View extends Mage_Core_Block_Template
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('oscommerce/order/view.phtml');
- }
-
- protected function _prepareLayout()
- {
- $orderInfo = $this->getOrder();
- $order = $orderInfo['order'];
- if ($headBlock = $this->getLayout()->getBlock('head')) {
- $headBlock->setTitle($this->__('Order # %s', $order['orders_id']));
- }
- }
-
- public function getPaymentInfoHtml()
- {
- return $this->getChildHtml('payment_info');
- }
-
- /**
- * Retrieve current order model instance
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder()
- {
- return Mage::registry('current_oscommerce_order');
- }
-
- public function getBackUrl()
- {
- return Mage::getUrl('sales/order/history');
- }
-
-}
diff --git a/app/code/core/Mage/Oscommerce/Helper/Data.php b/app/code/core/Mage/Oscommerce/Helper/Data.php
deleted file mode 100644
index 5553a2e963..0000000000
--- a/app/code/core/Mage/Oscommerce/Helper/Data.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
- */
-class Mage_Oscommerce_Helper_Data extends Mage_Core_Helper_Data
-{
-
-}
diff --git a/app/code/core/Mage/Oscommerce/Model/Config.php b/app/code/core/Mage/Oscommerce/Model/Config.php
deleted file mode 100644
index 22f5878abd..0000000000
--- a/app/code/core/Mage/Oscommerce/Model/Config.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- */
-class Mage_Oscommerce_Model_Config extends Mage_Core_Model_Config_Base
-{
- public function __construct()
- {
- parent::__construct(Mage::getConfig()->getNode('global'));
- }
-
- public function initForeignConnection($data)
- {
- $connectionNode = $this->getNode('resources/oscommerce_foreign/connection');
- if ($connectionNode) {
- $connectionNode->addChild('host', isset($data['host']) ? $data['host'] : '');
- $connectionNode->addChild('username', isset($data['db_user']) ? $data['db_user'] : '');
- $connectionNode->addChild('password', isset($data['db_password']) ? $data['db_password'] : '');
- $connectionNode->addChild('dbname', isset($data['db_name']) ? $data['db_name'] : '');
- }
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce.php b/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce.php
deleted file mode 100644
index 19a077e925..0000000000
--- a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce.php
+++ /dev/null
@@ -1,2113 +0,0 @@
-
- */
-class Mage_Oscommerce_Model_Mysql4_Oscommerce extends Mage_Core_Model_Mysql4_Abstract
-{
- const DEFAULT_DISPLAY_MODE = 'PRODUCTS';
- const DEFAULT_IS_ANCHOR = '0';
- const DEFAULT_STORE = 'Default';
- const DEFAULT_PRODUCT_TYPE = 'Simple';
- const DEFAULT_ATTRIBUTE_SET = 'Default';
- const DEFAULT_VISIBILITY = 'Catalog, Search';
- const DEFAULT_LOCALE = 'en_US';
- const DEFAULT_MAGENTO_CHARSET = 'UTF-8';
- const DEFAULT_OSC_CHARSET = 'ISO-8859-1';
- const DEFAULT_FIELD_CHARSET = 'utf8';
-
- protected $_currentWebsiteId;
- protected $_currentWebsite;
-
- protected $_importType = array();
- protected $_countryIdToCode = array();
- protected $_countryNameToCode = array();
- protected $_regionCode = array();
- protected $_logData = array();
- protected $_languagesToStores = array();
- protected $_prefix = '';
- protected $_storeLocales = array();
- protected $_rootCategory = '';
-
- protected $_websiteCode = '';
- protected $_isProductWithCategories = false;
- protected $_setupConnection ;
- protected $_customerIdPair = array();
- protected $_categoryIdPair = array();
- protected $_prefixPath = '';
- protected $_stores = array();
- protected $_productsToCategories = array();
- protected $_productsToStores = array();
- protected $_connectionCharset;
- protected $_dataCharset;
- protected $_maxRows;
- protected $_oscStores;
- protected $_oscDefaultLanguage;
- protected $_oscStoreInformation;
- protected $_categoryModel;
- protected $_customerModel;
- protected $_productModel;
- protected $_productAdapterModel;
- protected $_orderModel;
- protected $_addressModel;
- protected $_websiteModel;
- protected $_storeGroupModel;
- protected $_configModel;
- protected $_customerGroupModel;
- protected $_storeModel;
- protected $_importCollection;
- protected $_saveRows = 0;
- protected $_errors = array();
- protected $_importModel;
- protected $_lengthShortDescription;
- protected $_currentUserId;
-
- protected $_oscTables = array(
- 'products', 'customers', 'categories', 'orders', 'languages',
- 'orders_products', 'orders_status_history', 'orders_total',
- 'products_description', 'address_book', 'categories_description'
- );
-
- protected function _construct()
- {
- $this->_init('oscommerce/oscommerce', 'import_id');
- $this->_setupConnection = Mage::getSingleton('core/resource')->getConnection('oscommerce_setup');
- $this->_currentWebsite = Mage::app()->getWebsite();
- $this->_currentWebsiteId = $this->_currentWebsite->getId();
- $this->_maxRows = Mage::getStoreConfig('oscommerce/import/max_rows');
- $this->_lengthShortDescription = Mage::getStoreConfig('oscommerce/import/short_description_length');
- }
-
- /**
- * Get paypal session namespace
- *
- * @return Mage_Paypal_Model_Session
- */
- public function getSession()
- {
- return Mage::getSingleton('oscommerce/session');
- }
-
- /**
- * Get website object
- *
- * @return Mage_Core_Model_Website
- */
- public function getCurrentWebsite()
- {
- return $this->_currentWebsite;
- }
-
- protected function _beforeSave(Mage_Core_Model_Abstract $object)
- {
- if (!$object->getCreatedAt()) {
- $object->setCreatedAt($this->formatDate(time()));
- }
- $object->setUpdatedAt($this->formatDate(time()));
- parent::_beforeSave($object);
- }
-
- /**
- * Getting external connection adapter
- *
- * @return object
- */
- protected function _getForeignAdapter()
- {
- return $this->_getConnection('foreign');
- }
-
- /**
- * Get store code by id
- *
- * @param integer $id
- * @return string
- */
- public function getStoreCodeById($id)
- {
- if (!$this->_stores) {
- $stores = Mage::app()->getStores();
- foreach($stores as $store) {
- $this->_stores[$store->getId()] = $store->getCode();
- }
- }
- if (isset($this->_stores[$id])) {
- return $this->_stores[$id];
- }
- return false;
- }
-
- public function setWebsiteCode($code)
- {
- if (isset($code)) $this->_websiteCode = $code;
- }
-
- /**
- * Create new website or set current website as default website
- *
- * @param integer $websiteId
- */
- public function createWebsite($websiteId = null)
- {
- $importModel = $this->getImportModel();
- $websiteModel = $this->getWebsiteModel();
- if (!is_null($websiteId)) {
- $websiteModel->load($websiteId);
- }
-
- if (!$websiteModel->getId()) {
- $storeInfo = $this->getOscStoreInformation();
- if ($this->_websiteCode && !($websiteModel->load($this->_websiteCode)->getId())) {
- $websiteModel->setName($storeInfo['STORE_NAME']);
- $websiteModel->setCode($this->_websiteCode ? $this->_websiteCode : $this->_format($storeInfo['STORE_NAME']));
- $websiteModel->save();
- }
- }
-
-
- if ($websiteModel->getId()) {
- $this->saveLogs(array( 0 => $websiteModel->getId()), 'website');
- }
-
- /**
- * Create Root category
- */
- $this->createRootCategory();
-
- /**
- * Create default store group
- */
- $this->createStoreGroup();
- }
-
- public function createStoreGroup()
- {
- $importModel = $this->getImportModel();
- $storeInfo = $this->getOscStoreInformation();
- $websiteModel = $this->getWebsiteModel();
- if (!$websiteModel->getId()) {
- $websiteModel->load($this->_currentWebsiteId); // NEED TO GET DEFAULT WEBSITE ID FROM CONFIG
- }
- $storeGroupModel = $this->getStoreGroupModel();
- $storeGroupModel->unsetData();
- $storeGroupModel->setOrigData();
-
- $storeGroupName = Mage::helper('oscommerce')->__('%s Store', $websiteModel->getId() == $this->_currentWebsiteId ? $storeInfo['STORE_NAME'] : $websiteModel->getName());
- $storeGroupModel->setWebsiteId($websiteModel->getId());
- $storeGroupModel->setName($storeGroupName);
- $storeGroupModel->setRootCategoryId($this->getRootCategory()->getId());
-
- try {
- $storeGroupModel->save();
-
- $websiteModel->setDefaultGroupId($storeGroupModel->getId());
- $websiteModel->save();
- }
- catch (Exception $e) {
-
- }
-
- $this->saveLogs(array(0 => $storeGroupModel->getId(), 'group'));
- return $this;
- }
-
- public function createRootCategory()
- {
- $importModel = $this->getImportModel();
- $categoryModel = $this->getCategoryModel();
- $categoryModel->unsetData();
- $categoryModel->setOrigData();
-
- $websiteModel = $this->getWebsiteModel();
- if (!$websiteModel->getId()) {
- $websiteModel->load($this->_currentWebsiteId); // NEED TO GET DEFAULT WEBSITE ID FROM CONFIG
- }
-
- $storeInfo = $this->getOscStoreInformation();
-
- $categoryName = Mage::helper('oscommerce')->__('Root category for %s', $websiteModel->getName());
-
- $categoryModel->setStoreId(0);
- $categoryModel->setIsActive(1);
- $categoryModel->setDisplayMode(self::DEFAULT_DISPLAY_MODE);
- $categoryModel->setName($categoryName);
- $categoryModel->setParentId(1);
- $categoryModel->setPath('1');
-
- try {
- $categoryModel->save();
- $this->saveLogs(array(0 => $categoryModel->getId()), 'root_category');
- }
- catch (Exception $e) {
-
- }
-
- $this->setRootCategory(clone $categoryModel);
-
- return $this;
- }
-
- /**
- * Importing store data from osCommerce to Magento
- *
- * @param Mage_Oscommerce_Model_Oscommerce $obj
- */
- public function importStores()
- {
- $importModel = $this->getImportModel();
- $locales = $this->getStoreLocales();
- $defaultStore = '';
- $storeInformation = $this->getOscStoreInformation();
- $defaultStoreCode = $storeInformation['DEFAULT_LANGUAGE'];
- $configModel = $this->getConfigModel();
- $storeModel = $this->getStoreModel();
- $storeGroupModel = $this->getStoreGroupModel();
- $storeGroupId = $storeGroupModel->getId();
- $websiteModel = $this->getWebsiteModel();
- $websiteId = $websiteModel->getId();
- $storePairs = array();
- if ($stores = $this->getOscStores()) {
- foreach($stores as $store) {
- try {
- $oscStoreId = $store['id'];
- unset($store['id']);
-
- $store['group_id'] = $storeGroupId;
- $store['website_id'] = $websiteId;
- $storeModel->unsetData();
- $storeModel->setOrigData();
- $storeModel->load($store['code']);
- if ($storeModel->getId() && $storeModel->getCode() == $store['code']) {
- $localeCode = $locales[$store['code']];
- unset($locales[$store['code']]);
- $store['code'] = $store['code'].'_'.$websiteId.time(); // for unique store code
- $locales[$store['code']] = $localeCode;
- }
- $store['name'] = $this->convert($store['name']);
- $storeModel->unsetData();
- $storeModel->setOrigData();
- $storeModel->setData($store);
- $storeModel->save();
-
- $storePairs[$oscStoreId] = $storeModel->getId();
-
- $storeLocale = isset($locales[$storeModel->getCode()])?$locales[$storeModel->getCode()]: $locales['default'];
-
- $configModel->unsetData();
- $configModel->setOrigData();
- $configModel->setScope('stores')
- ->setScopeId($storeModel->getId())
- ->setPath('general/locale/code')
- ->setValue($storeLocale)
- ->save();
- if ($store['scode'] == $defaultStoreCode) {
- $defaultStore = $storeModel->getId();
- }
- Mage::dispatchEvent('store_add', array('store'=>$storeModel));
- } catch (Exception $e) {
- //echo $e->getMessage();
- }
- }
- }
- if (sizeof($storePairs) > 0) {
- $this->saveLogs($storePairs, 'store');
- }
- $this->setStoreLocales($locales);
-
- if ($defaultStore) {
- $storeGroupModel->setDefaultStoreId($defaultStore);
- $storeGroupModel->save();
- }
- Mage::app()->reinitStores();
- unset($stores);
- }
-
- /**
- * Importing customer/address from osCommerce to Magento
- *
- * @param Mage_Oscommerce_Model_Oscommerce $obj
- */
- public function importCustomers($startFrom = 0, $useStartFrom = false, $sendSubscription = true)
- {
- $this->_resetSaveRows();
- $this->_resetErrors();
- $totalCustomers = $this->getTotalCustomers();
- $maxRows = $this->getMaxRows();
- $pages = floor($totalCustomers / $maxRows) + 1;
-
- if (!$useStartFrom) {
- for ($i = 0; $i < $pages; $i++) {
- if ($customers = $this->getCustomers(array('from'=>($i * $maxRows),'max'=>$maxRows))) {
- foreach ($customers as $customer) {
- $customer['sendSubscription'] = $sendSubscription;
- $this->_saveCustomer($customer);
- }
- }
- }
- } else {
- if ($customers = $this->getCustomers(array('from'=> $startFrom ,'max'=>$maxRows))) {
- foreach ($customers as $customer) {
- $customer['sendSubscription'] = $sendSubscription;
- $this->_saveCustomer($customer);
- }
- }
- }
- }
-
- /**
- * Save customer data
- *
- * @param Mage_Oscommerce_Model_Oscommerce $obj
- * @param array $data
- */
- protected function _saveCustomer($data = null) {
- $addressFieldMapping = array(
- 'street' => 'entry_street_address',
- 'firstname' => 'entry_firstname',
- 'lastname' => 'entry_lastname',
- 'city' => 'entry_city',
- 'region' => 'entry_state'
- );
- $importModel = $this->getImportModel();
- $timezone = $importModel->getTimezone();
- if (!is_null($data)) {
- $customerAddresses = array();
- // Getting customer group data
- $customerGroupId = Mage::getStoreConfig(Mage_Customer_Model_Group::XML_PATH_DEFAULT_ID);
- $customerGroupModel = $this->getCustomerGroupModel()->load($customerGroupId);
- $websiteId = $this->getWebsiteModel()->getId();
- $customerModel = $this->getCustomerModel();
- $addressModel = $this->getAddressModel();
- $oscCustomerId = $data['id'];
- $data['group_id'] = $customerGroupModel->getName();
-
- $prepareCreated = explode(' ', $data['created_at']);
- $dateFormat = 'YYYY-MM-dd HH:mm:ss';
- $dateCreated = new Zend_Date();
- $dateCreated->setTimezone($timezone);
- $dateCreated->setDate($prepareCreated[0], 'YYYY-MM-dd');
- $dateCreated->setTime($prepareCreated[1], 'HH:mm:ss');
- $dateCreated->setTimezone('GMT');
- $data['created_at'] = $dateCreated->toString($dateFormat);
-
- foreach($data as $field => $value) {
- if (in_array($field, array('firstname', 'lastname'))) {
- $value = $this->convert($value);
- }
- $data[$field] = html_entity_decode($value, ENT_QUOTES, self::DEFAULT_MAGENTO_CHARSET);
-
- }
-
-
- // Getting addresses
- $addresses = $this->getAddresses($data['id']);
- if ($addresses) {
- foreach ($addresses as $address) {
- foreach ($address as $field => $value) {
-
- if ($field == 'street1') {
- $field = 'street';
- }
- if ($field == 'country_id') {
- $value = $this->getCountryCodeById($value);
- $field = 'country';
- }
- if ($field == 'region_id'
- && in_array($address['country_id'], array(38, 223))) {
- $field = 'region';
- }
-
- if (in_array($field, array_keys($addressFieldMapping))) {
- $value = $this->convert($value);
- }
-
- if (!in_array($field, array('customers_id'))) {
- $address[$field] = $value;
- } else {
- unset($address[$field]);
- }
- }
- $address['country_id'] = $address['country'];
- unset($address['country']);
- $customerAddresses[] = $address;
- }
- }
- $defaultBilling = '';
- $defaultBilling = $data['default_billing'];
- unset($data['default_billing']);
- unset($data['id']);
-
- try {
- $customerModel->setData($data);
- $customerModel->setImportMode(true);
- $customerModel->setWebsiteId($websiteId > 0 ? $websiteId: $this->getCurrentWebsite()->getId());
- $customerModel->save();
- $customerId = $customerModel->getId();
-
- if ($customerAddresses) foreach ($customerAddresses as $customerAddress) {
- $customerAddress['telephone'] = $data['telephone'];
- $customerAddress['fax'] = $data['fax'];
- $addressModel->unsetData();
- $addressModel->setData($customerAddress);
- $addressModel->setCustomerId($customerId);
- $addressModel->setId(null);
- $addressModel->save();
- if ($defaultBilling == $customerAddress['id']) {
- $addressId = $addressModel->getId();
- $customerModel->setDefaultBilling($addressId);
- $customerModel->setDefaultShipping($addressId);
- }
- }
- $customerModel->save();
- $this->saveLogs(array($oscCustomerId => $customerId), 'customer');
- $this->_saveRows++;
- } catch (Exception $e) {
- $this->_addErrors(Mage::helper('oscommerce')->__('Email %s cannot be saved because of %s', $data['email'], $e->getMessage()));
- }
- }
- }
-
- public function getCustomerIdPair()
- {
- if (!$this->_customerIdPair) {
- $this->_customerIdPair = $this->getLogPairsByTypeCode('customer');
- }
- return $this->_customerIdPair;
- }
-
- public function setCustomerIdPair($data)
- {
- if (is_array($data)) {
- $this->_customerIdPair = $data;
- }
- }
-
- public function importCategories($startFrom = 0, $useStartFrom = false)
- {
- $importModel = $this->getImportModel();
- $this->_logData['type_id'] = $this->getImportTypeIdByCode('category');
- $this->_logData['import_id'] = $importModel->getId();
- $categoryModel = $this->getCategoryModel();
-
- $this->_resetSaveRows();
- $this->_resetErrors();
- $maxRows = $this->getMaxRows();
- $totalCategories = $this->getCategoriesCount();
-
- $pages = floor($totalCategories / $maxRows) + 1;
- if (!$useStartFrom) {
- for ($i = 0; $i < $pages; $i++) {
- if ($categories = $this->getCategories(array('from'=> $i * $maxRows,'max'=>$maxRows))) {
- foreach ($categories as $category) {
- $this->_saveCategory($category);
- }
- }
- }
- } else {
- if ($categories = $this->getCategories(array('from'=> $startFrom ,'max'=>$maxRows))) {
- foreach ($categories as $category) {
- $this->_saveCategory($category);
- }
- }
- }
- }
-
- protected function _saveCategory($data) {
- $importModel = $this->getImportModel();
- $categoryModel = $this->getCategoryModel();
- $oscCategoryId = $data['id'];
- unset($data['id']);
- try {
- $data['store_id'] = 0;
- $data['is_active'] = 1;
- $data['display_mode'] = self::DEFAULT_DISPLAY_MODE;
- $data['is_anchor'] = self::DEFAULT_IS_ANCHOR;
- $data['attribute_set_id'] = $categoryModel->getDefaultAttributeSetId();
- $data['name'] = $this->convert($data['name']);
- $data['meta_title'] = html_entity_decode($data['name'], ENT_QUOTES, self::DEFAULT_MAGENTO_CHARSET);
- $categoryModel->setData($data);
- $categoryModel->save();
- $categoryId = $categoryModel->getId();
- $this->saveLogs(array($oscCategoryId => $categoryId), 'category');
-
- // saving data for different (encoding has been done in getCategoryToStores method)
- $storeData = $data['stores'];
- unset($data['stores']);
- if (isset($storeData)) {
- foreach($storeData as $storeId=>$catData) {
- $categoryModel->setStoreId($storeId)->setName($catData['name'])->setMetaTitle($catData['name'])
- ->save();
- }
- }
- $this->_saveRows++;
- } catch (Exception $e) {
- $this->_addErrors(Mage::helper('oscommerce')->__('Category %s cannot be saved because of %s', $data['name'], $e->getMessage()));
- }
- }
-
-
-
- public function buildCategoryPath()
- {
- $categoryIdPair = $this->getCategoryIdPair();
- $importModel = $this->getImportModel();
- if ($categoryIdPair) foreach ($categoryIdPair as $oscommerceId => $magentoId) {
- $path = $this->getRootCategory()->getPath().'/'.join('/',$this->getCategoryPath($oscommerceId));
- $this->_getWriteAdapter()->raw_query("UPDATE `{$this->getTable('catalog_category')}` SET `path`='{$path}' WHERE `entity_id`={$magentoId}");
- }
- }
-
- public function getCategoryPath($categoryId)
- {
- $categoryIdPair = $this->getCategoryIdPair();
- $select = "SELECT `c`.`parent_id` FROM `{$this->getOscTable('categories')}` c ";
- $select .= " WHERE `c`.`categories_id`={$categoryId}";
- if ($parentId = $this->_getForeignAdapter()->fetchOne($select)) {
- if ($result = $this->getCategoryPath($parentId)) {
- if (!isset($results)) {
- $results = $result;
- } else {
- array_merge($results, $result);
- }
- } else {
- $results[] = $categoryIdPair[$parentId];
- }
- }
- $results[] = $categoryIdPair[$categoryId];
- return $results;
- }
-
- public function getCategoryIdPair()
- {
- if (!$this->_categoryIdPair) {
- $this->_categoryIdPair = $this->getLogPairsByTypeCode('category');
- }
- return $this->_categoryIdPair;
- }
-
- public function setCategoryIdPair($data)
- {
- if (is_array($data)) {
- $this->_categoryIdPair = $data;
- }
- }
-
- /**
- * Import products
- *
- * @param Mage_Oscommerce_Model_Oscommerce $obj
- */
- public function importProducts($startFrom = 0, $useStartFrom = false)
- {
- $importModel = $this->getImportModel();
- $productAdapterModel = Mage::getModel('catalog/convert_adapter_product');
- $productModel = $this->getProductModel();
- $taxCollections = $this->_getTaxCollections();
- $this->_resetSaveRows();
- $this->_resetErrors();
- $maxRows = $this->getMaxRows();
- $totalProducts = $this->getProductsCount();
- $pages = floor($totalProducts / $maxRows) + 1;
- if (!$useStartFrom) {
- for ($i = 0; $i < $pages; $i++) {
- if ($products = $this->getProducts(array('from'=> $i * $maxRows,'max'=>$maxRows))) {
- foreach ($products as $product) {
- if (!empty($product['tax_class_id'])) {
- $product['tax_class_id'] = $taxCollections[$product['tax_class_id']];
- }
- $this->_saveProduct($product);
- }
- }
- }
- } else {
- if ($products = $this->getProducts(array('from'=> $startFrom ,'max'=>$maxRows))) {
- foreach ($products as $product) {
- if (!empty($product['tax_class_id'])) {
- $product['tax_class_id'] = $taxCollections[$product['tax_class_id']];
- }
- $this->_saveProduct($product);
- }
- }
- }
- }
-
- /**
- * Save products data
- *
- * @param Mage_Oscommerce_Model_Oscommerce $obj
- * @param array $data
- */
- protected function _saveProduct($data) {
- $importModel = $this->getImportModel();
- $productAdapterModel = $this->getProductAdapterModel();
- $productModel = $this->getProductModel();
- $mageStores = $this->getLanguagesToStores();
- $storeInfo = $this->getOscStoreInformation();
- $storeName = $storeInfo['STORE_NAME'];
- $oscProductId = $data['id'];
- unset($data['id']);
- if ($this->_isProductWithCategories) {
- if ($categories = $this->getProductCategories($oscProductId))
- $data['category_ids'] = $categories;
- }
-
- /**
- * Checking product by using sku and website
- */
- if (empty($data['sku'])) {
- $data['sku'] = $storeName . ' - ' . $oscProductId;
- }
- $productModel->unsetData();
- $productId = $productModel->getIdBySku($data['sku']);
- $productModel->load($productId);
- if ($productModel->getId()) {
- $websiteIds = $productModel->getWebsiteIds();
-
- if ($websiteIds) foreach($websiteIds as $websiteId) {
- if ($websiteId == $this->getWebsiteModel()->getId()) {
- $this->_addErrors(Mage::helper('oscommerce')->__('SKU %s was not imported since it already exists in %s',
- $data['sku'],
- $this->getWebsiteModel()->getName()));
- return ;
- }
- }
- }
- try {
- if (isset($data['image'])) {
- if (substr($data['image'], 0,1) != DS) {
- $data['image'] = DS . $data['image'];
- }
-
- if (!file_exists(Mage::getBaseDir('media'). DS . 'import' . $data['image'])) {
- unset($data['image']);
- } else {
- $data['thumbnail'] = $data['small_image'] = $data['image'];
- }
- }
- if ($stores = $this->getProductStores($oscProductId)) {
-
- foreach ($stores as $storeId => $store) {
- if (!$storeCode = $this->getStoreCodeById($mageStores[$storeId])) {
- $storeCode = $this->getCurrentWebsite()->getDefaultStore()->getCode();
- }
- $data['store'] = $storeCode;
- $data['name'] = html_entity_decode($this->convert($store['name']), ENT_QUOTES, self::DEFAULT_MAGENTO_CHARSET);
- $data['description'] = html_entity_decode($this->convert($store['description']), ENT_QUOTES, self::DEFAULT_MAGENTO_CHARSET);
- $data['short_description'] = $data['description'];
- $productAdapterModel->saveRow($data);
- }
- }
-
- $productId = $productAdapterModel->getProductModel()->getId();
- $this->saveLogs(array($oscProductId => $productId), 'product');
- $this->_saveRows++;
- } catch (Exception $e) {
- $this->_addErrors(Mage::helper('oscommerce')->__('SKU %s cannot be saved because of %s', $data['sku'], $e->getMessage()));
- }
- }
-
- public function importOrders($startFrom = 0, $useStartFrom = false)
- {
- $importModel = $this->getImportModel();
- $this->_resetSaveRows();
- $this->_resetErrors();
- // Get orders
-
- $totalOrders = $this->getOrdersCount();
- $maxRows = $this->getMaxRows();
- $pages = floor($totalOrders / $maxRows) + 1;
-
- if (!$useStartFrom) {
- for ($i = 0; $i < $pages; $i++) {
- $orders = $this->getOrders(array('from' => $i * $maxRows, 'max' => $maxRows));
- if ($orders) foreach($orders as $order) {
- $this->_saveOrder($order);
- }
- }
- } else {
- $orders = $this->getOrders(array('from' => $startFrom, 'max' => $maxRows));
- if ($orders) foreach($orders as $order) {
- $this->_saveOrder($order);
- }
- }
- }
-
- public function createOrderTables()
- {
- $importModel = $this->getImportModel();
- $importId = $importModel->getId();
- $websiteId = $this->getWebsiteModel()->getId();
-
- $tables = array(
- 'orders' => "CREATE TABLE `{$this->getTable('oscommerce_order')}` (
- `osc_magento_id` int(11) NOT NULL auto_increment,
- `orders_id` int(11) NOT NULL default '0',
- `customers_id` int(11) NOT NULL default '0',
- `magento_customers_id` int(11) NOT NULL default '0',
- `import_id` int(11) NOT NULL default '0',
- `website_id` int(11) NOT NULL default '0',
- `customers_name` varchar(64) NOT NULL default '',
- `customers_company` varchar(32) default NULL,
- `customers_street_address` varchar(64) NOT NULL default '',
- `customers_suburb` varchar(32) default NULL,
- `customers_city` varchar(32) NOT NULL default '',
- `customers_postcode` varchar(10) NOT NULL default '',
- `customers_state` varchar(32) default NULL,
- `customers_country` varchar(32) NOT NULL default '',
- `customers_telephone` varchar(32) NOT NULL default '',
- `customers_email_address` varchar(96) NOT NULL default '',
- `customers_address_format_id` int(5) NOT NULL default '0',
- `delivery_name` varchar(64) NOT NULL default '',
- `delivery_company` varchar(32) default NULL,
- `delivery_street_address` varchar(64) NOT NULL default '',
- `delivery_suburb` varchar(32) default NULL,
- `delivery_city` varchar(32) NOT NULL default '',
- `delivery_postcode` varchar(10) NOT NULL default '',
- `delivery_state` varchar(32) default NULL,
- `delivery_country` varchar(32) NOT NULL default '',
- `delivery_address_format_id` int(5) NOT NULL default '0',
- `billing_name` varchar(64) NOT NULL default '',
- `billing_company` varchar(32) default NULL,
- `billing_street_address` varchar(64) NOT NULL default '',
- `billing_suburb` varchar(32) default NULL,
- `billing_city` varchar(32) NOT NULL default '',
- `billing_postcode` varchar(10) NOT NULL default '',
- `billing_state` varchar(32) default NULL,
- `billing_country` varchar(32) NOT NULL default '',
- `billing_address_format_id` int(5) NOT NULL default '0',
- `payment_method` varchar(255) NOT NULL default '',
- `cc_type` varchar(20) default NULL,
- `cc_owner` varchar(64) default NULL,
- `cc_number` varchar(32) default NULL,
- `cc_expires` varchar(4) default NULL,
- `last_modified` datetime default NULL,
- `date_purchased` datetime default NULL,
- `orders_status` varchar(32) default NULL,
- `orders_date_finished` datetime default NULL,
- `currency` varchar(3) default NULL,
- `currency_value` decimal(14,6) default NULL,
- `currency_symbol` varchar(3) default NULL,
- `orders_total` decimal(14,6) default NULL,
- PRIMARY KEY (`osc_magento_id`),
- KEY `idx_orders_customers_id` (`customers_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
- "
- , 'orders_products' => "CREATE TABLE `{$this->getTable('oscommerce_order_products')}` (
- `orders_products_id` int(11) NOT NULL auto_increment,
- `osc_magento_id` int(11) NOT NULL default '0',
- `products_id` int(11) NOT NULL default '0',
- `products_model` varchar(12) default NULL,
- `products_name` varchar(64) NOT NULL default '',
- `products_price` decimal(15,4) NOT NULL default '0.0000',
- `final_price` decimal(15,4) NOT NULL default '0.0000',
- `products_tax` decimal(7,4) NOT NULL default '0.0000',
- `products_quantity` int(2) NOT NULL default '0',
- PRIMARY KEY (`orders_products_id`),
- KEY `idx_orders_products_osc_magento_id` (`osc_magento_id`),
- KEY `idx_orders_products_products_id` (`products_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
- "
-
- , 'orders_total' => "CREATE TABLE IF NOT EXISTS `{$this->getTable('oscommerce_order_total')}` (
- `orders_total_id` int(10) unsigned NOT NULL auto_increment,
- `osc_magento_id` int(11) NOT NULL default '0',
- `title` varchar(255) NOT NULL default '',
- `text` varchar(255) NOT NULL default '',
- `value` decimal(15,4) NOT NULL default '0.0000',
- `class` varchar(32) NOT NULL default '',
- `sort_order` int(11) NOT NULL default '0',
- PRIMARY KEY (`orders_total_id`),
- KEY `idx_orders_total_osc_magento_id` (`osc_magento_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"
-
- , 'orders_status_history'=>"CREATE TABLE IF NOT EXISTS `{$this->getTable('oscommerce_order_history')}` (
- `orders_status_history_id` int(11) NOT NULL auto_increment,
- `osc_magento_id` int(11) NOT NULL default '0',
- `orders_status_id` int(5) NOT NULL default '0',
- `date_added` datetime NOT NULL default '0000-00-00 00:00:00',
- `customer_notified` int(1) default '0',
- `comments` text,
- `orders_status` varchar(32) default NULL,
- PRIMARY KEY (`orders_status_history_id`),
- KEY `idx_orders_status_history_osc_magento_id` (`osc_magento_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"
-
- );
-
- $conn = $this->_setupConnection;
- foreach ($tables as $table => $schema) {
- $conn->beginTransaction();
- try {
- $conn->query($schema);
- $conn->commit();
- } catch (Exception $e) {
-// $conn->rollBack();
- }
- }
-
- $this->checkOrderField();
- }
-
- public function setTablePrefix($prefix)
- {
- if (isset($prefix)) $this->_prefix = $prefix;
- }
-
- public function getTablePrefix()
- {
- return $this->_prefix;
- }
-
- public function setIsProductWithCategories($yn)
- {
- if (is_bool($yn)) {
- $this->_isProductWithCategories = $yn;
- }
- }
-
- /**
- * Logging imported data to oscommerce_ref table
- *
- * @param array data
- */
- public function log($data = array())
- {
- if (isset($data)) {
- $this->_getWriteAdapter()->beginTransaction();
- try {
- $this->_getWriteAdapter()->insert($this->getTable('oscommerce_ref'), $data);
- $this->_getWriteAdapter()->commit();
- } catch (Exception $e) {
- $this->_getWriteAdapter()->rollBack();
- }
- }
- }
-
- public function getOscStoreInformation()
- {
- if (!$this->_oscStoreInformation) {
- $select = "SELECT `configuration_key` `key`, `configuration_value` `value` FROM `{$this->getOscTable('configuration')}`";
- $select .= " WHERE `configuration_key` IN ('STORE_NAME', 'STORE_OWNER', 'STORE_OWNER_EMAIL', 'STORE_COUNTRY',' STORE_ZONE','DEFAULT_LANGUAGE')";
- if (!($result = $this->_getForeignAdapter()->fetchPairs($select))) {
- $result = array();
- }
- $this->_oscStoreInformation = $result;
- }
- return $this->_oscStoreInformation;
- }
-
- /**
- * Getting products data from osCommerce
- *
- */
- public function getProducts($limit = array())
- {
- $defaultLanguage = $this->getOscDefaultLanguage();
- $defaultLanguageId = $defaultLanguage['id'];
- $code = $this->getWebsiteModel()->getCode();
- $website = $code? $code: $this->getCurrentWebsite()->getCode();
- $connection = $this->_getForeignAdapter();
- $select = " SELECT `p`.`products_id` `id`, `p`.`products_quantity` `qty` ";
- $select .= " , `p`.`products_model` `sku`, `p`.`products_price` `price`";
- $select .= " , `p`.`products_image` `image` ";
- $select .= " , `p`.`products_weight` `weight`, IF(`p`.`products_status`,'Enabled','Disabled') `status` ";
- $select .= " , IF(`p`.`products_status`,'1','0') `is_in_stock`";
- $select .= " , `pd`.`products_name` `name`, `pd`.`products_description` `description` ";
-// $select .= " , `tc`.`tax_class_title` `tax_class_id`, IF(1,'".self::DEFAULT_VISIBILITY."','') `visibility` ";
- $select .= " , `p`.`products_tax_class_id` `tax_class_id`, IF(1,'".self::DEFAULT_VISIBILITY."','') `visibility` ";
- $select .= " , `sp`.`specials_new_products_price` `special_price` ";
- $select .= " , `sp`.`specials_date_added` `special_from_date` ";
- $select .= " , `sp`.`expires_date` `special_to_date` ";
- $select .= " , IF(1,'".self::DEFAULT_ATTRIBUTE_SET."','') `attribute_set` ";
- $select .= " , IF(1,'".self::DEFAULT_PRODUCT_TYPE ."','') `type` ";
- //$select .= ", IF(1,'".self::DEFAULT_STORE."','') `store` ";
- $select .= " , IF(1,'".$website."','') `website` ";
- $select .= " FROM `{$this->getOscTable('products')}` p LEFT JOIN `{$this->getOscTable('products_description')}` pd ";
- $select .= " ON `pd`.`products_id`=`p`.`products_id` AND `pd`.`language_id`={$defaultLanguageId} ";
-// $select .= " LEFT JOIN `{$this->getOscTable('tax_class')}` tc ON `tc`.`tax_class_id`=`p`.`products_tax_class_id` ";
- $select .= " LEFT JOIN `{$this->getOscTable('specials')}` sp ON `sp`.`products_id`=`p`.`products_id` ";
- if ($limit && isset($limit['from']) && isset($limit['max'])) {
- $select .= " LIMIT {$limit['from']}, {$limit['max']}";
- }
- if (!($result = $this->_getForeignAdapter()->fetchAll($select))) {
- $result = array();
- }
- return $result;
- }
-
- public function getProductsCount()
- {
- return $this->_getForeignAdapter()->fetchOne("SELECT count(*) FROM `{$this->getOscTable('products')}`");
- }
-
- public function getCategoriesCount()
- {
- return $this->_getForeignAdapter()->fetchOne("SELECT count(*) FROM `{$this->getOscTable('categories')}`");
- }
-
- public function getCustomersCount()
- {
- return $this->_getForeignAdapter()->fetchOne("SELECT count(*) FROM `{$this->getOscTable('customers')}`");
- }
-
- public function getOrdersCount()
- {
- return $this->_getForeignAdapter()->fetchOne("SELECT count(*) FROM `{$this->getOscTable('orders')}`");
- }
-
- public function getOrders($limit = array()) {
- $defaultLanguage = $this->getOscDefaultLanguage();
- $defaultLanguageId = $defaultLanguage['id'];
- $select = "SELECT `o`.`orders_id`, `o`.`customers_id`, `o`.`customers_name`";
- $select .= " ,`o`.`customers_company`,`o`.`customers_street_address`";
- $select .= " ,`o`.`customers_suburb`, `o`.`customers_city`";
- $select .= " ,`o`.`customers_postcode`, `o`.`customers_state`";
- $select .= " ,`o`.`customers_country`, `o`.`customers_telephone`";
- $select .= " ,`o`.`customers_email_address`, `o`.`customers_address_format_id`";
- $select .= " ,`o`.`delivery_name`, `o`.`delivery_company`";
- $select .= " ,`o`.`delivery_street_address`, `o`.`delivery_suburb`";
- $select .= " ,`o`.`delivery_city`, `o`.`delivery_postcode`, `o`.`delivery_state`";
- $select .= " ,`o`.`delivery_country`, `o`.`delivery_address_format_id`";
- $select .= " ,`o`.`billing_name`, `o`.`billing_company`";
- $select .= " ,`o`.`billing_street_address`, `o`.`billing_suburb`";
- $select .= " ,`o`.`billing_city`, `o`.`billing_postcode`, `o`.`billing_state`";
- $select .= " ,`o`.`billing_country`, `o`.`billing_address_format_id`";
- $select .= " ,`o`.`payment_method`, `o`.`cc_type`, `o`.`cc_owner`, `o`.`cc_number`";
- $select .= " ,`o`.`cc_expires`, `o`.`last_modified`, `o`.`date_purchased`";
- $select .= " ,`o`.`orders_status`, `o`.`orders_date_finished`, `o`.`currency`, `o`.`currency_value`";
- $select .= " ,`c`.`symbol_left` `currency_symbol`,`ot`.`value` `orders_total`";
- $select .= " ,`os`.`orders_status_name` FROM `{$this->getOscTable('orders')}` `o`";
- $select .= " LEFT JOIN `{$this->getOscTable('currencies')}` `c` ON `c`.`code`=`o`.`currency` ";
- $select .= " LEFT JOIN `{$this->getOscTable('orders_total')}` `ot` ON `ot`.`orders_id`=`o`.`orders_id` ";
- $select .= " AND `ot`.`class`='ot_total'";
- $select .= " LEFT JOIN `{$this->getOscTable('orders_status')}` os ON `os`.`orders_status_id`=`o`.`orders_status` ";
- $select .= " AND `os`.`language_id`={$defaultLanguageId} ";
- if (isset($limit) && isset($limit['from']) && isset($limit['max'])) {
- $select .= " LIMIT {$limit['from']}, {$limit['max']} ";
- }
- if (!($result = $this->_getForeignAdapter()->fetchAll($select))) {
- $result = array();
- }
- return $result;
- }
-
- protected function _saveOrder($data)
- {
- $fieldNoEnc = array(
- 'customers_id',
- 'orders_id',
- 'date_purchased',
- 'last_modified',
- 'orders_date_finished',
- 'orders_products_id',
- 'osc_magento_id',
- 'products_id'
- );
-
- $importModel = $this->getImportModel();
- $timezone = $importModel->getTimezone();
- $customerIdPair = $this->getCustomerIdPair();
- $importId = $importModel->getId();
- $websiteId = $this->getWebsiteModel()->getId();
- if ($data['customers_id'] > 0 && isset($this->_customerIdPair[$data['customers_id']])) {
- foreach($data as $field => $value) {
- if (!in_array($field, $fieldNoEnc)) {
- $data[$field] = $this->convert($value);
- }
- }
-
- if ($data['date_purchased']) {
- $preparePurchased = explode(' ', $data['date_purchased']);
- $dateFormat = 'YYYY-MM-dd HH:mm:ss';
- $datePurchased = new Zend_Date();
- $datePurchased->setTimezone($timezone);
- $datePurchased->setDate($preparePurchased[0], 'YYYY-MM-dd');
- $datePurchased->setTime($preparePurchased[1], 'HH:mm:ss');
- $datePurchased->setTimezone('GMT');
- $data['date_purchased'] = $datePurchased->toString($dateFormat);
- }
-
- if ($data['last_modified']) {
- $prepareModified = explode(' ', $data['last_modified']);
- $dateModified = new Zend_Date();
- $dateModified->setTimezone($timezone);
- $dateModified->setDate($prepareModified[0], 'YYYY-MM-dd');
- $dateModified->setTime($prepareModified[1], 'HH:mm:ss');
- $dateModified->setTimezone('GMT');
- $data['last_modified'] = $dateModified->toString($dateFormat);
- }
-
- if ($data['orders_date_finished']) {
- $prepareFinished = explode(' ', $data['orders_date_finished']);
- $dateFinished = new Zend_Date();
- $dateFinished->setTimezone($timezone);
- $dateFinished->setDate($prepareFinished[0], 'YYYY-MM-dd');
- $dateFinished->setTime($prepareFinished[1], 'HH:mm:ss');
- $dateFinished->setTimezone('GMT');
- $data['orders_date_finished'] = $dateFinished->toString($dateFormat);
- }
-
- $data['magento_customers_id'] = $this->_customerIdPair[$data['customers_id']]; // get Magento CustomerId
- $data['import_id'] = $importId;
- $data['website_id'] = $websiteId;
- $data['orders_status'] = $data['orders_status_name'];
- unset($data['orders_status_name']);
- $this->_getWriteAdapter()->insert($this->getTable('oscommerce_order'), $data);
- $oscMagentoId = $this->_getWriteAdapter()->lastInsertId();
- $this->_saveRows++;
-
- // Get orders products
- $select = "SELECT `orders_products_id`, `orders_id`, `products_id` ";
- $select .= ", `products_model`, `products_name`, `products_price`, `final_price` ";
- $select .= ", `products_tax`, `products_quantity` ";
- $select .= " FROM `{$this->getOscTable('orders_products')}` WHERE `orders_id`={$data['orders_id']}";
- if ($orderProducts = $this->_getForeignAdapter()->fetchAll($select)) {
- foreach ($orderProducts as $orderProduct) {
- unset($orderProduct['orders_id']);
- unset($orderProduct['orders_products_id']);
- $orderProduct['osc_magento_id'] = $oscMagentoId;
- foreach ($orderProduct as $field => $value) {
- if (!in_array($field, $fieldNoEnc)) {
- $orderProduct[$field] = $this->convert($value);
- }
- }
- $this->_getWriteAdapter()->insert($this->getTable('oscommerce_order_products'), $orderProduct);
- }
- }
-
- // Get orders totals
- $select = "SELECT `orders_total_id`, `orders_id`, `title`, `text`, `value`, `class`, `sort_order` ";
- $select .= " FROM `{$this->getOscTable('orders_total')}` WHERE `orders_id`={$data['orders_id']} ORDER BY `sort_order`";
-
- if ($orderTotals = $this->_getForeignAdapter()->fetchAll($select)) {
- foreach ($orderTotals as $orderTotal) {
-
- unset($orderTotal['orders_id']);
- unset($orderTotal['orders_total_id']);
- $orderTotal['osc_magento_id'] = $oscMagentoId;
- $orderTotal['title'] = $this->convert($orderTotal['title']);
- $orderTotal['text'] = $this->convert($orderTotal['text']);
- $this->_getWriteAdapter()->insert($this->getTable('oscommerce_order_total'), $orderTotal);
- }
- }
-
- $defaultLanguage = $this->getOscDefaultLanguage();
- $defaultLanguageId = $defaultLanguage['id'];
-
- // Get orders status history
- $select = "SELECT `osh`.`orders_status_history_id`, `osh`.`orders_id`, `osh`.`orders_status_id` ";
- $select .= ", `os`.`orders_status_name` `orders_status`, `osh`.`date_added`, `osh`.`customer_notified`, `osh`.`comments` ";
- $select .= " FROM `{$this->getOscTable('orders_status_history')}` osh ";
- $select .= " LEFT JOIN `{$this->getOscTable('orders_status')}` os ON `os`.`orders_status_id`=`osh`.`orders_status_id` ";
- $select .= " AND `os`.`language_id`={$defaultLanguageId}";
- $select .= " WHERE `osh`.`orders_id`={$data['orders_id']}";
- if ($orderHistories = $this->_getForeignAdapter()->fetchAll($select)) {
- foreach ($orderHistories as $orderHistory) {
- unset($orderHistory['orders_id']);
- unset($orderHistory['orders_status_history_id']);
- $orderHistory['osc_magento_id'] = $oscMagentoId;
- $prepareAdded = explode(' ', $orderHistory['date_added']);
- $dateFormat = 'YYYY-MM-dd HH:mm:ss';
- $dateAdded = new Zend_Date();
- $dateAdded->setTimezone($timezone);
- $dateAdded->setDate($prepareAdded[0], 'YYYY-MM-dd');
- $dateAdded->setTime($prepareAdded[1], 'HH:mm:ss');
- $dateAdded->setTimezone('GMT');
- $orderHistory['date_added'] = $dateAdded->toString($dateFormat);
- $orderHistory['orders_status'] = $this->convert($orderHistory['orders_status']);
- $orderHistory['comments'] = $this->convert($orderHistory['comments']);
- $orderHistory['customer_notified'] = $this->convert($orderHistory['customer_notified']);
-
- $this->_getWriteAdapter()->insert($this->getTable('oscommerce_order_history'), $orderHistory);
- }
- }
- } else {
- $this->_addErrors(Mage::helper('oscommerce')->__('Order #%s failed to import because the customer ID #%s associated with this order could not be found.', $data['orders_id'], $data['customers_id']));
- }
- }
-
- /**
- * Getting product description for different stores
- *
- * @param integer $productId
- * @return mix array/boolean
- */
- public function getProductStores($productId) {
- if (!$this->_productsToStores) {
- $select = "SELECT `products_id`, `language_id` `store`, `products_name` `name`, `products_description` `description`";
- $select .= " FROM `{$this->getOscTable('products_description')}` ";
- if ($results = $this->_getForeignAdapter()->fetchAll($select)) {
- foreach ($results as $result) {
- $this->_productsToStores[$result['products_id']][$result['store']] = array('name'=>$result['name'], 'description' => $result['description']);
- }
- }
- }
- if (isset($this->_productsToStores[$productId])) {
- return $this->_productsToStores[$productId];
- }
- return false;
- }
-
- /**
- * Getting new created categories recursively using products of osCommerce
- *
- * @param integer $productId
- * @return string
- */
- public function getProductCategories($productId)
- {
- $importModel = $this->getImportModel();
- if (!$this->_productsToCategories) {
- $select = "SELECT `products_id`, `categories_id` FROM `{$this->getOscTable('products_to_categories')}`";
-
- if ($results = $this->_getForeignAdapter()->fetchAll($select)) {
- $categories = array();
- foreach ($results as $result) {
- $categories[$result['products_id']] = $result['categories_id'];
- if (isset($categories[$result['products_id']])) {
- $categories[$result['products_id']] .= ','.$result['categories_id'];
- } else {
- $categories[$result['products_id']] = $result['categories_id'];
- }
- }
- //$categories = join(',', array_values($results));
-
- //$this->_getReadAdapter();
- $importId = $importModel->getId();
- $typeId = $this->getImportTypeIdByCode('category');
-
-
- if ($categories) foreach ($categories as $product => $category) {
- $select = $this->_getReadAdapter()->select();
- $select->from(array('osc'=>$this->getTable('oscommerce_ref')), array('id'=>'id','ref_id'=>'ref_id'));
- $select->where("`osc`.`import_id`='{$importId}' AND `osc`.`type_id`='{$typeId}' AND `osc`.`value` in (".$category.")");
- $resultCategories = $this->_getReadAdapter()->fetchPairs($select);
- if ($resultCategories) {
- $this->_productsToCategories[$product] = join(',',array_values($resultCategories));
- }
- }
- }
- }
- if (isset($this->_productsToCategories[$productId])) {
- return $this->_productsToCategories[$productId];
- }
- return false;
- }
-
- public function getCategories($limit = array()) {
- $importModel = $this->getImportModel();
- $defaultLanguage = $this->getOscDefaultLanguage();
- $defaultLanguageId = $defaultLanguage['id'];
- $select = "SELECT `c`.`categories_id` as `id`, `c`.`parent_id`, `cd`.`categories_name` `name` FROM `{$this->getOscTable('categories')}` c ";// WHERE `c`.`parent_id`={$parentId}";
- $select .= " INNER JOIN `{$this->getOscTable('categories_description')}` cd on `cd`.`categories_id`=`c`.`categories_id`";
- $select .= " AND `cd`.`language_id`={$defaultLanguageId} ";
- if ($limit && isset($limit['from']) && isset($limit['max'])) {
- $select .= " LIMIT {$limit['from']}, {$limit['max']} ";
- }
- if (!$results = $this->_getForeignAdapter()->fetchAll($select)) {
- $results = array();
- } else {
- $stores = $this->getLanguagesToStores();
- foreach($results as $index => $result) {
- if ($categoriesToStores = $this->getCategoriesToStores($result['id'])) {
- foreach($categoriesToStores as $store => $categoriesName) {
- $results[$index]['stores'][$stores[$store]] = array(
- 'name'=>html_entity_decode($this->convert($categoriesName), ENT_QUOTES, self::DEFAULT_MAGENTO_CHARSET)
- );
- }
- }
- }
- }
- return $results;
- }
-
- /**
- * Getting language to Magento store data
- *
- * @return array
- */
- public function getLanguagesToStores()
- {
- $importModel = $this->getImportModel();
- $typeId = $this->getImportTypeIdByCode('store');
- $importId = $importModel->getId();
- if (!$this->_languagesToStores) {
- //$this->_languagesToStores[1] = 1;
- $select = $this->_getReadAdapter()->select();
- $select->from(array('ref'=>$this->getTable('oscommerce_ref')), array('value'=>'value', 'ref_id'=>'ref_id'));
- $select->where("`ref`.`import_id`='{$importId}' AND `ref`.`type_id`='{$typeId}'");
- $this->_languagesToStores = $this->_getReadAdapter()->fetchPairs($select);
- }
- return $this->_languagesToStores;
- }
-
- /**
- * Getting categry description for different languages
- *
- * @param integer $categoryId
- * @return mix array/boolean
- */
- public function getCategoriesToStores($categoryId)
- {
- $select = "SELECT `language_id`, `categories_name` FROM `{$this->getOscTable('categories_description')}`";
- $select .= "WHERE `categories_id`='{$categoryId}'";
- if ($categoryId && $result = $this->_getForeignAdapter()->fetchPairs($select)) {
- return $result;
- }
- return false;
- }
-
- /**
- * Getting store data of osCommerce
- *
- * @return array
- */
- public function getOscStores()
- {
- if (!$this->_oscStores) {
- $select = "SELECT `languages_id` `id`, `name`, `code` `scode`, ";
- $select .= " `directory` `code`, 1 `is_active` FROM `{$this->getOscTable('languages')}`";
- $this->_oscStores = $this->_getForeignAdapter()->fetchAll($select);
- }
- return $this->_oscStores;
- }
-
-
- public function getOscDefaultLanguage()
- {
- if (!$this->_oscDefaultLanguage) {
- $oscStoreInfo = $this->getOscStoreInformation();
- $languageCode = $oscStoreInfo['DEFAULT_LANGUAGE'];
- if ($stores = $this->getOscStores()) foreach($stores as $store) {
- if ($store['scode'] == $languageCode) {
- $this->_oscDefaultLanguage = $store;
- }
- }
- }
- return $this->_oscDefaultLanguage;
- }
-
- /**
- * Getting customers from osCommerce
- *
- * @return array
- */
- public function getCustomers($limit = array())
- {
- $select = "SELECT `c`.`customers_id` `id`, `c`.`customers_firstname` `firstname` ";
- $select .= " ,`c`.`customers_lastname` `lastname`, `c`.`customers_email_address` `email` ";
- $select .= " ,`c`.`customers_telephone` `telephone`, `c`.`customers_fax` `fax` ";
- $select .= " ,`c`.`customers_password` `password_hash`, `c`.`customers_newsletter` `is_subscribed` ";
- $select .= " ,`ci`.`customers_info_date_account_created` `created_at` ";
- $select .= " ,`c`.`customers_default_address_id` `default_billing` FROM `{$this->getOscTable('customers')}` c";
- $select .= " LEFT JOIN `customers_info` ci ON `ci`.`customers_info_id`=`c`.`customers_id` ";
- if ($limit && isset($limit['from']) && isset($limit['max'])) {
- $select .= " LIMIT {$limit['from']}, {$limit['max']}";
- }
-
- if (!($result = $this->_getForeignAdapter()->fetchAll($select))) {
- $result = array();
- }
-
- return $result;
- }
-
- public function getTotalCustomers() {
- return $this->_getForeignAdapter()->fetchOne("SELECT count(*) FROM `{$this->getOscTable('customers')}`");
- }
-
- public function getCustomerName($name)
- {
- if (isset($name)) {
- $n = explode(" ", $name);
- if (sizeof($n) > 1) {
- $newName['lastname'] = $n[(sizeof($n) - 1)];
- $newName['fistname'] = Mage::helper('core/string')->substr($name, 0,
- Mage::helper('core/string')->strlen($name) - (Mage::helper('core/string')->strlen($newName['lastname'] + 1))
- );
- return $newName;
- } else {
- return array('firstname' => $n);
- }
- }
- return false;
- }
-
-
- /**
- * Getting customer address by CustomerId from osCommerce
- *
- * @param integer $customerId
- * @return array
- */
- public function getAddresses($customerId)
- {
-
- $select = "SELECT `address_book_id` `id`, `customers_id`, `entry_firstname` `firstname`";
- $select .= ", `entry_lastname` `lastname`, `entry_street_address` `street1`";
- $select .= ", `entry_company` `company` ";
- $select .= ", `entry_postcode` `postcode`, `entry_city` `city`";
- $select .= ", `entry_state` `region`, `entry_country_id` `country_id`";
- $select .= ", `entry_zone_id` `region_id` FROM `{$this->getOscTable('address_book')}` WHERE customers_id={$customerId}";
- if (!isset($customerId) || !($result = $this->_getForeignAdapter()->fetchAll($select))) {
- $result = array();
- }
- return $result;
- }
-
- /**
- * Get address from address book
- *
- * @param integer $address_id
- * @return array
- */
- public function getAddressById($addressId)
- {
-
- $select = "SELECT `address_book_id` `id`, `customers_id`, `entry_firstname` `firstname`";
- $select .= ", `entry_lastname` `lastname`, `entry_street_address` `street1`";
- $select .= ", `entry_postcode` `postcode`, `entry_city` `city`";
- $select .= ", `entry_state` `region`, `entry_country_id` `country_id`";
- $select .= ", `entry_zone_id` `region_id` FROM `{$this->getOscTable('address_book')}` WHERE address_book_id={$addressId}";
- if (!isset($addressId) || !($result = $this->_getForeignAdapter()->fetchRow($select))) {
- $result = array();
- }
- return $result;
- }
-
- /**
- * Getting importing types for loging into oscommerce_ref
- *
- * @return array
- */
- public function getImportTypes()
- {
- if (! $this->_importType) {
- $connection = $this->_getReadAdapter();
- $select = $connection->select();
- $select->from($this->getTable('oscommerce_type'), array('*'));
- $this->_importType = $connection->fetchAll($select);
- }
- return $this->_importType;
- }
-
- /**
- * Getting import_type_id by code
- *
- * @param integer $code
- * @return string/boolean
- */
- public function getImportTypeIdByCode($code = '') {
- $types = $this->getImportTypes();
- if (isset($code) && $types) {
- foreach ($types as $type) {
- if ($type['type_code'] == $code) {
- return $type['type_id'];
- }
- }
- }
- return false;
- }
-
- public function getCountryCodeData()
- {
- $select = "SELECT * FROM `{$this->getOscTable('countries')}`";
- $countries = $this->_getForeignAdapter()->fetchAll($select);
- if ($countries) foreach($countries as $country) {
- $this->_countryIdToCode[$country['countries_id']] = $country['countries_iso_code_2'];
- $this->_countryNameToCode[$country['countries_name']] = $country['countries_iso_code_2'];
- }
- }
-
- /**
- * Getting country code by country id
- *
- * @param integer $id
- * @return string/boolean
- */
- public function getCountryCodeById($id)
- {
- if (!$this->_countryIdToCode) {
- $this->getCountryCodeData();
- }
- $countries = $this->_countryIdToCode;
- if (isset($id) && isset($countries[$id])) {
- return $countries[$id];
- }
- return false;
- }
-
- public function getCountryCodeByName($name)
- {
- if (!$this->_countryNameToCode) {
- $this->getCountryCodeData();
- }
- $countries = $this->_countryNameToCode;
- if (isset($id) && isset($countries[$name])) {
- return $countries[$name];
- }
- return false;
- }
-
- public function getCountryIdByCode($countryCode)
- {
- if (!$this->_countryIdToCode) {
- $this->getCountryCodeData();
- }
- if (isset($code)) {
- foreach($this->_countryToCode as $id => $code) {
- if ($code == $countryCode) {
- return $id;
- }
- }
- }
- return false;
- }
-
-
- /**
- * Getting regions from osCommerce
- *
- * @return array
- */
- public function getRegions()
- {
- if (!$this->_regionCode) {
- $select = "SELECT `zone_id`, `zone_name` FROM `{$this->getOscTable('zones')}`";
- $this->_regionCode = $this->_getForeignAdapter()->fetchPairs($select);
- }
- return $this->_regionCode;
- }
-
- /**
- * Getting region name by id
- *
- * @param integer $id
- * @return string/boolean
- */
- public function getRegionCode($id)
- {
- $regions = $this->getRegions();
- if (isset($id) && isset($regions[$id])) {
- return $regions[$id];
- }
- return false;
- }
-
- public function setStoreLocales($locale)
- {
- if (isset($locale) && is_array($locale))
- $this->_storeLocales = $locale;
- }
-
- public function getStoreLocales()
- {
- if ($this->_storeLocales) {
- return $this->_storeLocales;
- } else {
- return array('default' => self::DEFAULT_LOCALE );
- }
- }
-
- public function setRootCategory(Mage_Catalog_Model_Category $category) {
- $this->_rootCategory = $category;
- }
-
- public function getRootCategory()
- {
- if (!$this->_rootCategory) {
- $this->_rootCategory = $this->getCategoryModel()->load($this->getCurrentWebsite()->getDefaultStoreGroup()->getRootCategoryId());
- }
- return $this->_rootCategory;
- }
-
- public function setWebsiteId($id)
- {
- $this->_websiteId = (int) ($id ? $id : 0);
- }
-
- public function importTaxClasses()
- {
- $taxModel = Mage::getModel('tax/class');
- $storeInfo = $this->getOscStoreInformation();
- $storeName = $storeInfo['STORE_NAME'];
- $taxPairs = array();
- if ($classes = $this->getTaxClasses()) {
- $existedClasses = $taxCollections = Mage::getResourceModel('tax/class_collection')
- ->addFieldToFilter('class_type', 'PRODUCT')
- ->load()
- ->toOptionHash();
-
- foreach ($classes as $id => $name) {
- $taxModel->unsData();
- $className = $name . '_' . $storeName;
- if (in_array($className, $existedClasses)) {
- $taxId = array_search($className, $existedClasses);
- } else {
- $taxModel->setId(null);
- $taxModel->setClassType('PRODUCT');
- $taxModel->setClassName($name . '_' . $storeName);
- $taxModel->save();
- $taxId = $taxModel->getId();
- }
- $taxPairs[$id] = $taxId;
- }
- }
-
- if (sizeof($taxPairs) > 0) {
- $this->saveLogs($taxPairs, 'taxclass');
- }
- }
-
- protected function _getTaxCollections()
- {
- $taxPairs = $this->getLogPairsByTypeCode('taxclass');
- $flipTaxPairs = array_flip($taxPairs);
- $newTaxPairs = array();
- $taxCollections = Mage::getResourceModel('tax/class_collection')
- ->addFieldToFilter('class_type', 'PRODUCT')
- ->load()
- ->toOptionArray();
- if ($taxCollections) {
- foreach ($taxCollections as $tax) {
- if (isset($flipTaxPairs[$tax['value']])) {
- $newTaxPairs[$flipTaxPairs[$tax['value']]] = $tax['label'];
- }
- }
- }
- return $newTaxPairs;
- }
-
- public function saveLogs($data, $type = null)
- {
- $importId = $this->getImportModel()->getId();
- $typeId = $this->getImportTypeIdByCode($type);
- $userId = $this->_getCurrentUserId();
- $createdAt = $this->formatDate(time());
- if (is_array($data) && $typeId > 0) {
- foreach($data as $value => $refId) {
- $log = array(
- 'value' => $value,
- 'ref_id' => $refId,
- 'import_id' => $importId,
- 'type_id' => $typeId,
- 'user_id' => $userId,
- 'created_at'=> $createdAt
- );
- $this->_getWriteAdapter()->insert($this->getTable('oscommerce_ref'), $log);
- }
- }
- }
-
- public function getLogPairsByTypeCode($code)
- {
- $typeId = $this->getImportTypeIdByCode($code);
- $importId = $this->getImportModel()->getId();
- $result = array();
- if (!is_null($typeId)) {
- $select = $this->_getReadAdapter()->select();
- $select->from($this->getTable('oscommerce_ref'), array('value','ref_id'))
- ->where("import_id={$importId}")
- ->where("type_id={$typeId}");
- $result = $this->_getReadAdapter()->fetchPairs($select);
- }
- return $result;
- }
-
- public function getTaxClasses()
- {
- $select = "SELECT `tax_class_id` `id`, `tax_class_title` `title` FROM `{$this->getOscTable('tax_class')}`";
- if (!($results = $this->_getForeignAdapter()->fetchPairs($select))) {
- $results = array();
- }
- return $results;
- }
-
- private function _format($str)
- {
- $str = preg_replace('#[^0-9a-z\/\.]+#i', '', $str);
- $str = strtolower(str_replace('\\s','',$str));
- return $str;
- }
-
- public function setPrefixPath($prefix) {
- if ($prefix) {
- $this->_prefixPath = $prefix;
- }
- }
-
- /**
- * Load osCommerce orders
- *
- * @param integer $customerId
- * @param integer $websiteId
- * @return array
- */
- public function loadOrders($customerId, $websiteId = '')
- {
- if (!isset($websiteId)) {
- $webisteId = $this->_currentWebsiteId;
- }
- $result = array();
- if (!empty($customerId)) {
- $select = $this->_getReadAdapter()->select()
- ->from(array('order'=>$this->getTable('oscommerce_order')))
- ->join(
- array('order_total'=>$this->getTable('oscommerce_order_total')),
- "order_total.osc_magento_id=order.osc_magento_id AND order_total.class='ot_total'",
- array('value'))
- ->where("order.magento_customers_id={$customerId}")
- ->where("order.website_id={$websiteId}");
- $result = $this->_getReadAdapter()->fetchAll($select);
- }
- return $result;
- }
-
- /**
- * Load osCommerce order
- *
- * @param integer $id
- * @return array
- */
- public function loadOrderById($id)
- {
- $result = array();
- if (!empty($id)) {
- $select = "SELECT * FROM {$this->getTable('oscommerce_order')} WHERE osc_magento_id={$id}";
- $order = $this->_getReadAdapter()->fetchRow($select);
- if ($order) {
- $result['order'] = $order;
- foreach (array('products','total','history') as $table) {
- $select = "SELECT * FROM {$this->getTable('oscommerce_order_'.$table)} WHERE osc_magento_id={$id}";
- $result[$table] = $this->_getReadAdapter()->fetchAll($select);
-
- }
- }
-
- }
- return $result;
- }
-
- // Fix for previous version
- protected function checkOrderField()
- {
- $columnName = 'currency_symbol';
- try {
- if (!($result = $this->_getReadAdapter()->fetchRow("SHOW `columns` FROM `{$this->getTable('oscommerce_order')}` WHERE field='{$columnName}'"))) {
- $this->_setupConnection()->query("ALTER TABLE `{$this->getTable('oscommerce_order')}` ADD {$columnName} char(3) DEFAULT NULL");
- $this->_setupConnection()->commit();
- }
- } catch (Exception $e) {
-
- }
- }
-
- public function setMaxRows($rows)
- {
- if (is_integer($rows)) {
- $this->_maxRows = $rows;
- }
- }
-
- public function getMaxRows()
- {
- if ($this->_maxRows <= 0) {
- $this->_maxRows = Mage::getStoreConfig('oscommerce/import/max_rows');
- }
- return $this->_maxRows;
- }
-
- /**
- * Retrieve website model cache
- *
- * @return Mage_Core_Model_Web
- */
- public function getWebsiteModel()
- {
- if (is_null($this->_websiteModel)) {
- $object = Mage::getModel('core/website');
- $this->_websiteModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_websiteModel);
- }
-
- /**
- * Retrieve store model cache
- *
- * @return Mage_Core_Model_Store
- */
- public function getStoreModel()
- {
- if (is_null($this->_storeModel)) {
- $object = Mage::getModel('core/store');
- $this->_storeModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_storeModel);
- }
-
- /**
- * Retrieve customer model cache
- *
- * @return Mage_Customer_Model_Customer
- */
- public function getCustomerModel()
- {
- if (is_null($this->_customerModel)) {
- $object = Mage::getModel('customer/customer');
- $this->_customerModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_customerModel);
- }
-
- /**
- * Retrieve customer model cache
- *
- * @return Mage_Customer_Model_Customer
- */
- public function getCustomerGroupModel()
- {
- if (is_null($this->_customerGroupModel)) {
- $object = Mage::getModel('customer/group');
- $this->_customerGroupModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_customerGroupModel);
- }
-
- /**
- * Retrieve address model cache
- *
- * @return Mage_Customer_Model_Address
- */
- public function getAddressModel()
- {
- if (is_null($this->_addressModel)) {
- $object = Mage::getModel('customer/address');
- $this->_addressModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_addressModel);
- }
-
-
- /**
- * Retrieve category model cache
- *
- * @return Mage_Catalog_Model_Category
- */
- public function getCategoryModel()
- {
- if (is_null($this->_categoryModel)) {
- $object = Mage::getModel('catalog/category');
- $this->_categoryModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_categoryModel);
- }
-
- /**
- * Retrieve category model cache
- *
- * @return Mage_Catalog_Model_Category
- */
- public function getProductModel()
- {
- if (is_null($this->_productModel)) {
- $object = Mage::getModel('catalog/product');
- $this->_productModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_productModel);
- }
-
- public function getProductAdapterModel()
- {
- if (is_null($this->_productAdapterModel)) {
- $object = Mage::getModel('catalog/convert_adapter_product');
- $this->_productAdapterModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_productAdapterModel);
- }
- /**
- * Retrieve store group model cache
- *
- * @return Mage_Core_Model_Store_Group
- */
- public function getStoreGroupModel()
- {
- if (is_null($this->_storeGroupModel)) {
- $object = Mage::getModel('core/store_group');
- $this->_storeGroupModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_storeGroupModel);
- }
-
- public function getConfigModel()
- {
- if (is_null($this->_configModel)) {
- $object = Mage::getModel('core/config_data');
- $this->_configModel = Varien_Object_Cache::singleton()->save($object);
- }
- return Varien_Object_Cache::singleton()->load($this->_configModel);
-
- }
-
- public function importCollection($importId = null) {
- $importTypes = array('website', 'root_category', 'group');
- $result = array();
- if (!is_null($importId)) {
- $select = $this->_getReadAdapter()->select()
- ->from(array('ref'=>$this->getTable('oscommerce_ref')))
- ->join(
- array('type'=>$this->getTable('oscommerce_type')),
- "type.type_id=ref.type_id AND type.type_code in ('".join("','",$importTypes)."')",
- array('type.type_code'))
- ->where("ref.import_id={$importId}");
- if ($results = $this->_getReadAdapter()->fetchAll($select)) {
- foreach ($results as $result) {
- $this->_importCollection[$result['type_code']] = $result['ref_id'];
- }
- }
-
- }
- return $this->_importCollection;
- }
-
- public function setImportModel(Mage_Oscommerce_Model_Oscommerce $model)
- {
- $this->_importModel = $model;
- }
-
- public function getImportModel()
- {
- if ($this->_importModel) {
- return $this->_importModel;
- }
- }
-
- public function getCollections($code)
- {
- if ($this->_importCollection) {
- return $this->_importCollection;
- }
- return;
- }
-
- /**
- * Deleting oscommerce reference records
- *
- * @param integer $id
- */
- public function deleteRecords($id = null)
- {
- if (!is_null($id) && $id > 0) {
- if ($result = $this->_getReadAdapter()
- ->fetchRow('SELECT * FROM '.$this->getTable('oscommerce_ref').' WHERE import_id='.$id)) {
- $this->_getWriteAdapter()->raw_query('DELETE FROM '.$this->getTable('oscommerce_ref').' WHERE import_id='.$id);
- }
- }
- }
-
- /**
- * Formatting string
- *
- * @param string $input
- * @param integer $number
- * @return string
- */
- protected function _formatStringTruncate($data, $number)
- {
- if (str_word_count($data, 0)>$number) {
- $wordKey = str_word_count($data, 1);
- $posKey = str_word_count($data, 2);
- reset($posKey);
- foreach ($wordKey as $key => &$value) {
- $value=key($posKey);
- next($posKey);
- }
- return substr($data, 0, $wordKey[$number]);
- } else {
- return $data;
- }
- }
-
- /**
- * Getting current user ID
- *
- * @return string
- */
- protected function _getCurrentUserId()
- {
- if (!$this->_currentUserId) {
- $this->_currentUserId = Mage::getSingleton('admin/session')->getUser()->getId();
- $this->_logData['user_id'] = $this->_currentUserId;
- }
- return $this->_currentUserId;
- }
-
- /**
- * Getting oscommerce table with prefix
- *
- * @param string $table
- * @return string
- */
- function getOscTable($table)
- {
- return $this->_prefix.$table;
- }
-
- /**
- * Setting connection charset
- *
- * @param string $charset
- */
- public function setConnectionCharset($charset)
- {
- $this->_connectionCharset = $charset;
- }
-
- /**
- * Getting connection charset, set deafult as utf8
- * if there is no predefine charset
- *
- * @return string
- */
- public function getConnectionCharset()
- {
- if (!$this->_connectionCharset) {
- $this->_connectionCharset = self::DEFAULT_FIELD_CHARSET;
- }
- return $this->_connectionCharset;
- }
-
- public function resetConnectionCharset()
- {
- $charset = $this->getConnectionCharset();
- $this->_getForeignAdapter()->query("SET NAMES '{$charset}'");
- }
-
-
- /**
- * Setting dataCharset by user defined encoding charset
- *
- * @param string $charset
- */
- public function setDataCharset($charset)
- {
- if (!is_null($charset)) {
- $this->_dataCharset = $charset;
- }
- }
-
- /**
- * Getting dataCharset
- *
- * @return string
- */
- public function getDataCharset()
- {
- return $this->_dataCharset;
- }
-
- /**
- * Converting encoded charsets
- *
- * @param mixed $data
- * @param array $notIncludedFields
- * @return mixed
- */
- public function convert($data, array $notIncludedFields = array())
- {
- $charset = $this->getDataCharset();
- if (!is_null($charset) || $charset != self::DEFAULT_FIELD_CHARSET) {
- if (is_array($data)) {
- foreach($data as $field => $value) {
- if (!in_array($field, $notIncludedFields)) {
- $newValue = @iconv($charset, self::DEFAULT_FIELD_CHARSET, $value);
- if (strlen($newValue)) {
- $data[$field] = $newValue;
- }
- }
- }
- } else {
- $newValue = @iconv($charset, self::DEFAULT_MAGENTO_CHARSET, $data);
- if (strlen($newValue)) {
- $data = $newValue;
- }
- }
- }
- return $data;
- }
-
- /**
- * Getting saveRows
- *
- * @return integer
- */
- public function getSaveRows()
- {
- return $this->_saveRows;
- }
-
- /**
- * Resetting saveRows as zero
- *
- */
- protected function _resetSaveRows()
- {
- $this->_saveRows = 0;
- }
-
- /**
- * Adding error messages
- *
- * @param string $error
- */
- protected function _addErrors($error)
- {
- if (isset($error)) $this->_errors[] = $error;
- }
-
- /**
- * Getting all errors
- *
- * @return array
- */
- public function getErrors()
- {
- if (sizeof($this->_errors) > 0) {
- return $this->_errors;
- }
- }
-
- /**
- * Resetting error as empty array
- *
- */
- protected function _resetErrors()
- {
- $this->_errors = array();
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Collection.php b/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Collection.php
deleted file mode 100755
index 0230cebaae..0000000000
--- a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Collection.php
+++ /dev/null
@@ -1,38 +0,0 @@
-
- */
-class Mage_Oscommerce_Model_Mysql4_Oscommerce_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('oscommerce/oscommerce');
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Order.php b/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Order.php
deleted file mode 100644
index 98953f15a8..0000000000
--- a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Order.php
+++ /dev/null
@@ -1,81 +0,0 @@
-
- */
-class Mage_Oscommerce_Model_Mysql4_Oscommerce_Order extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('oscommerce/oscommerce_order', 'osc_magento_id');
- }
-
- public function getProducts()
- {
- $order = Mage::registry('current_oscommerce_order');
- $result = array();
- if ($order && $order->getData() && $id = $order->getId())
- {
- $select = $this->_getReadAdapter()->select();
- $select->from($this->getTable('oscommerce_order_products'))
- ->where("osc_magento_id={$id}");
- $result = $this->_getReadAdapter()->fetchAll($select);
- }
- return $result;
- }
-
- public function getTotal()
- {
- $order = Mage::registry('current_oscommerce_order');
- $result = array();
- if ($order && $order->getData() && $id = $order->getId())
- {
- $select = $this->_getReadAdapter()->select();
- $select->from($this->getTable('oscommerce_order_total'))
- ->where("osc_magento_id={$id}")->order('sort_order');
- $result = $this->_getReadAdapter()->fetchAll($select);
- }
- return $result;
- }
-
- public function getComments()
- {
- $order = Mage::registry('current_oscommerce_order');
- $result = array();
- if ($order && $order->getData() && $id = $order->getId())
- {
- $select = $this->_getReadAdapter()->select();
- $select->from($this->getTable('oscommerce_order_history'))
- ->where("osc_magento_id={$id}");
- $result = $this->_getReadAdapter()->fetchAll($select);
- }
- return $result;
- }
-}
-
diff --git a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Order/Collection.php b/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Order/Collection.php
deleted file mode 100644
index 532b161cbe..0000000000
--- a/app/code/core/Mage/Oscommerce/Model/Mysql4/Oscommerce/Order/Collection.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- */
-class Mage_Oscommerce_Model_Mysql4_Oscommerce_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('oscommerce/oscommerce_order');
- }
-
- public function addOrderTotalField()
- {
- $this->_select
- ->columns(array('orders_total'=>new Zend_Db_Expr('FORMAT(main_table.orders_total,2)')));
- return $this;
- }
-
- public function load($printQuery=false, $logQuery=false)
- {
- if ($this->isLoaded()) {
- return $this;
- }
- $this->addOrderTotalField();
- parent::load($printQuery, $logQuery);
- return $this;
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Model/Oscommerce.php b/app/code/core/Mage/Oscommerce/Model/Oscommerce.php
deleted file mode 100755
index e84c6a7163..0000000000
--- a/app/code/core/Mage/Oscommerce/Model/Oscommerce.php
+++ /dev/null
@@ -1,87 +0,0 @@
-
- */
-class Mage_Oscommerce_Model_Oscommerce extends Mage_Core_Model_Abstract
-{
- const DEFAULT_PORT = 3360;
- const CONNECTION_TYPE = 'pdo_mysql';
- const CONNECTION_NAME = 'oscommerce_db';
-
- protected function _construct()
- {
- $this->_init('oscommerce/oscommerce');
- }
-
- protected function _afterLoad()
- {
- parent::_afterLoad();
- Mage::getSingleton('oscommerce/config')->initForeignConnection($this->getData());
-
-// if (Mage::app()->getRequest()->getActionName() == 'run') {
-// $this->importStores();
-// }
-
- }
- /**
- * Get paypal session namespace
- *
- * @return Mage_Paypal_Model_Session
- */
- public function getSession()
- {
- return Mage::getSingleton('oscommerce/session');
- }
-
- public function importStores() {
- $this->getResource()->importStores($this);
- }
-
- public function getImportTypeIdByCode($code = '') {
- return $this->getResource()->getImportTypeIdByCode($code);
- }
-
- public function loadOrders($customerId, $websiteId)
- {
- return $this->getResource()->loadOrders($customerId, $websiteId);
- }
-
- public function loadOrderById($id)
- {
- return $this->getResource()->loadOrderById($id);
- }
-
- public function deleteImportedRecords($id)
- {
- if (isset($id) && $id == $this->getId()) {
- $this->getResource()->deleteRecords($id);
- }
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/Model/Oscommerce/Order.php b/app/code/core/Mage/Oscommerce/Model/Oscommerce/Order.php
deleted file mode 100644
index 522ef49571..0000000000
--- a/app/code/core/Mage/Oscommerce/Model/Oscommerce/Order.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- */
-class Mage_Oscommerce_Model_Oscommerce_Order extends Mage_Core_Model_Abstract
-{
-
- protected function _construct()
- {
- $this->_init('oscommerce/oscommerce_order');
- }
-
- public function getProducts()
- {
- return $this->getResource()->getProducts();
- }
-
- public function getTotal()
- {
- return $this->getResource()->getTotal();
- }
-
- public function getComments()
- {
- return $this->getResource()->getComments();
- }
-
-}
diff --git a/app/code/core/Mage/Oscommerce/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/Oscommerce/controllers/Adminhtml/ImportController.php
deleted file mode 100644
index ffe3cca81c..0000000000
--- a/app/code/core/Mage/Oscommerce/controllers/Adminhtml/ImportController.php
+++ /dev/null
@@ -1,422 +0,0 @@
-
- */
-class Mage_Oscommerce_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action
-{
- /**
- * Initailization action of importController
- */
- protected function _initAction()
- {
- $this->loadLayout();
- $this->_setActiveMenu('oscommerce/adminhtml_import');
- return $this;
- }
-
- /**
- * Initialization of importController
- *
- * @param idFieldnName string
- * @return Mage_Oscommerce_Adminhtml_ImportController
- */
- protected function _initImport($idFieldName = 'id')
- {
- $id = (int) $this->getRequest()->getParam($idFieldName);
- $model = Mage::getModel('oscommerce/oscommerce');
- if ($id) {
- $model->load($id);
- }
-
- Mage::register('oscommerce_adminhtml_import', $model);
- return $this;
- }
-
- /**
- * Index action of importController
- */
- public function indexAction()
- {
- $this->_initAction();
- $this->_addContent(
- $this->getLayout()->createBlock('oscommerce/adminhtml_import')
- );
- $this->renderLayout();
- }
-
- /**
- * Edit action of importController
- */
- public function editAction()
- {
- $this->_initImport();
- $this->loadLayout();
-
- $model = Mage::registry('oscommerce_adminhtml_import');
- $data = Mage::getSingleton('adminhtml/session')->getSystemConvertOscData(true);
-
- if (!empty($data)) {
- $model->addData($data);
- }
-
- $this->_initAction();
- $this->_addBreadcrumb
- (Mage::helper('oscommerce')->__('Edit osCommerce Profile'),
- Mage::helper('oscommerce')->__('Edit osCommerce Profile'));
- /**
- * Append edit tabs to left block
- */
- $this->_addLeft($this->getLayout()->createBlock('oscommerce/adminhtml_import_edit_tabs'));
-
- $this->_addContent($this->getLayout()->createBlock('oscommerce/adminhtml_import_edit'));
-
- $this->renderLayout();
- }
-
- /**
- * Create new action of importController
- */
- public function newAction()
- {
- $this->_forward('edit');
- }
-
- /**
- * Save action of
- */
- public function saveAction()
- {
- if ($data = $this->getRequest()->getPost()) {
- if (isset($data['send_subscription'])) {
- $data['send_subscription'] = 1;
- } else {
- $data['send_subscription'] = 0;
- }
-
- $this->_initImport('import_id');
- $model = Mage::registry('oscommerce_adminhtml_import');
-
- // Prepare saving data
- if (isset($data)) {
- $model->addData($data);
- }
-
-// if (empty($data['port']))
-// $data['port'] = Mage_Oscommerce_Model_Oscommerce::DEFAULT_PORT;
-
- try {
- $model->save();
-
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('oscommerce')->__('osCommerce Profile was successfully saved'));
- }
- catch (Exception $e){
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
- Mage::getSingleton('adminhtml/session')->setSystemConvertOscData($data);
- $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('id'=>$model->getId())));
- return;
- }
- }
- if ($this->getRequest()->getParam('continue')) {
- $this->_redirect('*/*/edit', array('id'=>$model->getId()));
- } else {
- $this->_redirect('*/*');
- }
- }
-
- public function batchRunAction()
- {
- @set_time_limit(0);
- $this->_initImport('import_id');
- $importModel = Mage::registry('oscommerce_adminhtml_import');
-
- if ($tablePrefix = $importModel->getTablePrefix()) {
- $importModel->getResource()->setTablePrefix($tablePrefix);
- }
-
- // Start setting data from sessions
- if ($connCharset = $importModel->getSession()->getConnectionCharset()) {
- $importModel->getResource()->setConnectionCharset($connCharset);
- }
- if ($dataCharset = $importModel->getSession()->getDataCharset()) {
- $importModel->getResource()->setDataCharset($dataCharset);
- }
- if ($timezone = $importModel->getSession()->getTimezone()) {
- $importModel->setTimezone($timezone);
- }
- if ($storeLocales = $importModel->getSession()->getStoreLocales()) {
- $importModel->getResource()->setStoreLocales($storeLocales);
- }
- if ($isPoductWithCategories = $importModel->getSession()->getIsProductWithCategories()) {
- $importModel->getResource()->setIsProductWithCategories($isPoductWithCategories);
- }
- // End setting data from sessions
-
- // Resetting connection charset
- $importModel->getResource()->resetConnectionCharset();
-
- $importModel->getResource()->setImportModel($importModel);
- if ($collections = $importModel->getResource()->importCollection($importModel->getId())) {
- if (isset($collections['website'])) {
- $importModel->getResource()->getWebsiteModel()->load($collections['website']);
- }
- if (isset($collections['root_category'])) {
- $importModel->getResource()->setRootCategory(clone $importModel->getResource()->getCategoryModel()->load($collections['root_category']));
- }
- if (isset($collections['group'])) {
- $importModel->getResource()->getStoreGroupModel()->load($collections['group']);
-
- }
- }
-
- //$isUnderDefaultWebsite = $this->getRequest()->getParam('under_default_website') ? true: false;
- $importType = $this->getRequest()->getParam('import_type');
- $importFrom = $this->getRequest()->getParam('from');
- $isImportDone = $this->getRequest()->getParam('is_done');
- switch($importType) {
- case 'products':
- $importModel->getResource()->importProducts($importFrom, true);
- break;
- case 'categories':
- $importModel->getResource()->importCategories($importFrom, true);
- if ($isImportDone == 'true') {
- $importModel->getResource()->buildCategoryPath();
- }
- break;
- case 'customers':
- $importModel->getResource()->importCustomers($importFrom, true, $importModel->getData('send_subscription'));
- break;
- case 'orders':
- $importModel->getResource()->importOrders($importFrom, true);
- break;
- }
-
- $errors = $importModel->getResource()->getErrors();
- $result = array(
- 'savedRows' => $importModel->getResource()->getSaveRows(),
- 'errors' => ( $errors ? $errors: array())
- );
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
- }
-
- public function runAction()
- {
- @set_time_limit(0);
- Mage::app()->cleanCache(); // Clean all cach
- $this->_initImport();
- $importModel = Mage::registry('oscommerce_adminhtml_import');
- /** @var $importModel Mage_Oscommerce_Model_Oscommerce */
- $totalRecords = array();
-
- // Start handling charsets
- $connCharset = $this->getRequest()->getParam('connection_charset');
- if ($connCharset) {
- $importModel->getSession()->setConnectionCharset($connCharset);
- $importModel->getResource()->setConnectionCharset($connCharset);
- }
- $dataCharset = $this->getRequest()->getParam('data_charset');
- if ($dataCharset) {
- $importModel->getSession()->setDataCharset($dataCharset);
- $importModel->getResource()->setDataCharset($dataCharset);
- } // End hanlding charsets
-
- $timezone = $this->getRequest()->getParam('timezone');
- $importModel->getSession()->setTimezone($timezone);
- $importModel->getResource()->resetConnectionCharset();
-
- if ($tablPrefix = $importModel->getTablePrefix()) {
- $importModel->getResource()->setTablePrefix($tablPrefix);
- }
-
- $importModel->getResource()->setImportModel($importModel);
- $importModel->getResource()->importCollection($importModel->getId());
-
- // Setting Locale for stores
- $locales = explode("|",$this->getRequest()->getParam('store_locale'));
- $storeLocales = array();
- if ($locales) foreach($locales as $locale) {
- $localeCode = explode(':', $locale);
- $storeLocales[$localeCode[0]] = $localeCode[1];
- }
-
- $importModel->getSession()->setStoreLocales($storeLocales);
- $importModel->getResource()->setStoreLocales($storeLocales);
- // End setting Locale for stores
-
- $websiteId = $this->getRequest()->getParam('website_id');
- $websiteCode = $this->getRequest()->getParam('website_code');
- $options = $this->getRequest()->getParam('import');
-
- // Checking Website, StoreGroup and RootCategory
- if (!$websiteId) {
- $importModel->getResource()->setWebsiteCode($websiteCode);
- $importModel->getResource()->createWebsite();
- } else {
- $importModel->getResource()->createWebsite($websiteId);
- }
- // End checking Website, StoreGroup and RootCategory
-
- $importModel->getResource()->importStores();
- $importModel->getResource()->importTaxClasses();
- $importModel->getResource()->createOrderTables();
-
- if (isset($options['categories'])) {
- $importModel->getSession()->setIsProductWithCategories(true);
- $totalRecords['categories'] = $importModel->getResource()->getCategoriesCount();
- }
- if (isset($options['products'])) {
- $totalRecords['products'] = $importModel->getResource()->getProductsCount();
- }
- if (isset($options['customers'])) {
- $totalRecords['customers'] = $importModel->getResource()->getCustomersCount();
- }
- if (isset($options['customers']) && isset($options['orders'])) {
- $totalRecords['orders'] = $importModel->getResource()->getOrdersCount();
- }
- if ($totalRecords) {
- $importModel->setTotalRecords($totalRecords);
- Mage::unRegister('oscommerce_adminhtml_import');
- Mage::register('oscommerce_adminhtml_import', $importModel);
- }
- $this->getResponse()->setBody($this->getLayout()->createBlock('oscommerce/adminhtml_import_run')->toHtml());
- $this->getResponse()->sendResponse();
- }
-
- public function batchFinishAction()
- {
- if ($importId = $this->getRequest()->getParam('id')) {
- $importModel = Mage::getModel('oscommerce/oscommerce')->load($importId);
- /* @var $batchModel Mage_Dataflow_Model_Batch */
-
- if ($importId = $importModel->getId()) {
- $importModel->deleteImportedRecords($importId);
-// $importModel->getSession()->unsStoreLocales();
-// $importModel->getSession()->unsIsProductWithCategories();
-// if ($importModel->getSession()->getTablePrefix()) {
-// $importModel->getSession()->unsTablePrefix();
-// }
- $importModel->getSession()->clear();
- }
- }
- }
-
- /**
- * Delete osc action
- */
- public function deleteAction()
- {
- $this->_initImport();
- $model = Mage::registry('oscommerce_adminhtml_import');
- if ($model->getId()) {
- try {
- $model->delete();
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('oscommerce')->__('osCommerce profile was deleted'));
- }
- catch (Exception $e){
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
- }
- }
- $this->_redirect('*/*/');
- }
-
- /**
- * Ajax checking store
- *
- */
- public function checkStoreAction()
- {
- $this->_initImport();
- $importModel = Mage::registry('oscommerce_adminhtml_import');
- $error = false;
- if ($importModel->getId()) {
- try {
- $charset = $importModel->getResource()->getConnectionCharset();
- $defaultOscCharset = Mage_Oscommerce_Model_Mysql4_Oscommerce::DEFAULT_OSC_CHARSET;
- $defaultMageCharset = Mage_Oscommerce_Model_Mysql4_Oscommerce::DEFAULT_MAGENTO_CHARSET;
-
- $stores = $importModel->getResource()->getOscStores();
-
- $locales = Mage::app()->getLocale()->getOptionLocales();
- $options = '';
- foreach ($locales as $locale) {
- $options .= "{$locale['label']} ";
- }
- $html = '';
- if ($stores) {
- $html .= "\n";
- foreach ($stores as $store) {
- $html .= "" . $importModel->getResource()->convert($store['name']) . " Store ";
- $html .= "getMessage())? Mage::helper('oscommerce')->__('languages table error '):'') . $e->getMessage();
- }
-
- if ($error) {
- $result = array(
- 'error' => true,
- 'messages' => $html
- );
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
- } else {
- $this->getResponse()->setBody($html);
- }
- }
- }
-
- public function checkWebsiteCodeAction()
- {
-
- $this->_initImport();
- $model = Mage::registry('oscommerce_adminhtml_import');
- if ($model->getId()) {
- $website = Mage::getModel('core/website');
- $collections = $website->getCollection();
- $result = 'false';
- $websiteCode = $this->getRequest()->getParam('website_code');
- if ($collections) foreach ($collections as $collection) {
- if ($collection->getCode() == $websiteCode) {
- $result = 'true';
- }
- }
- $this->getResponse()->setBody($result);
- }
- }
-
- protected function _isAllowed()
- {
- return Mage::getSingleton('admin/session')->isAllowed('system/convert/oscimport');
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/controllers/Adminhtml/OrderController.php b/app/code/core/Mage/Oscommerce/controllers/Adminhtml/OrderController.php
deleted file mode 100644
index 59a8202f04..0000000000
--- a/app/code/core/Mage/Oscommerce/controllers/Adminhtml/OrderController.php
+++ /dev/null
@@ -1,101 +0,0 @@
-
- */
-
-class Mage_Oscommerce_Adminhtml_OrderController extends Mage_Adminhtml_Controller_Action
-{
-
- /**
- * Initailization of action
- */
- protected function _initAction()
- {
- $this->loadLayout()
- ->_setActiveMenu('sales/oscorder')
- ->_addBreadcrumb(Mage::helper('oscommerce')->__('Sales'), Mage::helper('checkout')->__('Sales'))
- ->_addBreadcrumb(Mage::helper('oscommerce')->__('osCommerce Orders'), Mage::helper('checkout')->__('osCommerce Orders'))
- ;
- return $this;
- }
-
-
- /**
- * Initialization of order
- *
- * @param idFieldnName string
- * @return Mage_Adminhtml_System_Convert_OscController
- */
- protected function _initOrder()
- {
- $id = $this->getRequest()->getParam('order_id');
- $order = Mage::getModel('oscommerce/oscommerce_order')->load($id);
-
- if (!$order->getId()) {
- $this->_getSession()->addError($this->__('This order no longer exists.'));
- $this->_redirect('*/*/');
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
- return false;
- }
-
- Mage::register('current_oscommerce_order', $order);
- return $order;
- }
-
- /**
- * Index osc action
- */
- public function indexAction()
- {
- $this->_initAction();
- $this->_addContent(
- $this->getLayout()->createBlock('oscommerce/adminhtml_order')
- );
- $this->renderLayout();
- }
-
- /**
- * osCommerce Order view page
- */
- public function viewAction()
- {
- if ($order = $this->_initOrder()) {
- $this->_initAction()
- ->_addBreadcrumb($this->__('View Order'), $this->__('View Order'))
- ->_addContent($this->getLayout()->createBlock('oscommerce/adminhtml_order_view'))
- ->renderLayout();
- }
- }
-
- protected function _isAllowed()
- {
- return Mage::getSingleton('admin/session')->isAllowed('sales/oscorder');
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/controllers/OrderController.php b/app/code/core/Mage/Oscommerce/controllers/OrderController.php
deleted file mode 100644
index 04600f33f9..0000000000
--- a/app/code/core/Mage/Oscommerce/controllers/OrderController.php
+++ /dev/null
@@ -1,100 +0,0 @@
-
- */
-
-class Mage_Oscommerce_OrderController extends Mage_Core_Controller_Front_Action
-{
-
- /**
- * Action predispatch
- *
- * Check customer authentication for some actions
- */
- public function preDispatch()
- {
- parent::preDispatch();
- $action = $this->getRequest()->getActionName();
- $loginUrl = Mage::helper('customer')->getLoginUrl();
- if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
- }
- }
-
-
- /**
- * Check osCommerce order view availability
- *
- * @param array $order
- * @return bool
- */
- protected function _canViewOrder($order)
- {
- $customerId = Mage::getSingleton('customer/session')->getCustomerId();
- if (isset($order['osc_magento_id']) && isset($order['magento_customers_id']) && $order['magento_customers_id'] == $customerId) {
- return true;
- }
- return false;
- }
-
- /**
- *
- */
- public function indexAction()
- {
- $this->_redirect('sales/order/history');
- }
-
- /**
- * osCommerce Order view page
- */
- public function viewAction()
- {
- $orderId = (int) $this->getRequest()->getParam('order_id');
- if (!$orderId) {
- $this->_redirect('sales/order/history');
- return;
- }
-
- $order = Mage::getModel('oscommerce/oscommerce')->loadOrderById($orderId);
- if ($order && $this->_canViewOrder($order['order'])) {
- Mage::register('current_oscommerce_order', $order);
- $this->loadLayout();
- if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) {
- $navigationBlock->setActive('oscommerce/order/view');
- }
-
- $this->renderLayout();
- }
- else {
- $this->_redirect('sales/order/history');
- }
- }
-}
diff --git a/app/code/core/Mage/Oscommerce/etc/adminhtml.xml b/app/code/core/Mage/Oscommerce/etc/adminhtml.xml
deleted file mode 100644
index 8ee60d10ce..0000000000
--- a/app/code/core/Mage/Oscommerce/etc/adminhtml.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
-
- osCommerce
- oscommerce/adminhtml_import
-
-
-
-
-
-
-
-
- osCommerce Orders
- oscommerce/adminhtml_order
- 100
-
-
-
-
-
-
-
-
-
-
-
- osCommerce Orders
- 100
-
-
-
-
-
-
-
-
- osCommerce
- 100
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Oscommerce/etc/charsets.xml b/app/code/core/Mage/Oscommerce/etc/charsets.xml
deleted file mode 100644
index 8d6aa906d0..0000000000
--- a/app/code/core/Mage/Oscommerce/etc/charsets.xml
+++ /dev/null
@@ -1,595 +0,0 @@
-
-
-
-
-
- Copyright (C) 2003 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
-This file lists all of the available character sets.
-To make maintaining easier please:
- - keep records sorted by collation number.
- - change charsets.max-id when adding a new collation.
-
-
-
- Traditional Chinese
- Big5 Traditional Chinese
- big-5
- bigfive
- big-five
- cn-big5
- csbig5
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Central European
- ISO 8859-2 Central European
- csisolatin2
- iso-8859-2
- iso-ir-101
- iso_8859-2
- iso_8859-2:1987
- l2
-
-
- Hungarian
- Polish
- Romanian
- Croatian
- Slovak
- Slovenian
- Sorbian
-
-
-
-
-
-
-
- Western
- DEC West European
-
-
- Dutch
- English
- French
- German Duden
- Italian
- Latin
- Portuguese
- Spanish
-
-
-
-
- Western
- DOS West European
- 850
- cspc850multilingual
- ibm850
-
- Dutch
- English
- French
- German Duden
- Italian
- Latin
- Portuguese
- Spanish
-
-
-
-
-
- Western
- cp1252 West European
- csisolatin1
- iso-8859-1
- iso-ir-100
- iso_8859-1
- iso_8859-1:1987
- l1
- latin1
-
-
- primary
- compiled
-
-
-
-
-
- binary
- compiled
-
-
- Dutch
- English
- French
- German Duden
- Italian
- Latin
- Portuguese
- Spanish
-
-
- Dutch
- English
- French
- German Duden
- Italian
- Latin
- Portuguese
- Spanish
-
-
-
-
- Western
- HP West European
- hproman8
-
-
- Dutch
- English
- French
- German Duden
- Italian
- Latin
- Portuguese
- Spanish
-
-
-
-
- Cyrillic
- KOI8-R Relcom Russian
- koi8-r
- cskoi8r
-
-
-
-
-
- Western
- 7bit Swedish
- iso-646-se
-
-
-
-
-
- Western
- US ASCII
- us
- us-ascii
- csascii
- iso-ir-6
- iso646-us
-
-
-
-
-
- Japanese
- EUC-JP Japanese
- euc-jp
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Japanese
- Shift-JIS Japanese
- s-jis
- shift-jis
- x-sjis
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Cyrillic
- Windows Cyrillic
- windows-1251
- ms-cyr
- ms-cyrillic
-
- Belarusian
- Bulgarian
- Macedonian
- Russian
- Serbian
- Mongolian
- Ukrainian
-
-
-
-
- Belarusian
- Bulgarian
- Macedonian
- Russian
- Serbian
- Mongolian
- Ukrainian
-
-
- Belarusian
- Bulgarian
- Macedonian
- Russian
- Serbian
- Mongolian
- Ukrainian
-
-
-
-
- Hebrew
- ISO 8859-8 Hebrew
- csisolatinhebrew
- iso-8859-8
- iso-ir-138
-
-
-
-
-
- Thai
- TIS620 Thai
- tis-620
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Korean
- EUC-KR Korean
- euc_kr
- euc-kr
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Baltic
- ISO 8859-13 Baltic
- BalticRim
- iso-8859-13
- l7
-
- Estonian
-
-
- Latvian
- Lithuanian
- primary
-
-
- Latvian
- Lithuanian
-
-
-
-
-
- Cyrillic
- KOI8-U Ukrainian
- koi8-u
-
-
-
-
-
- Simplified Chinese
- GB2312 Simplified Chinese
- chinese
- iso-ir-58
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Greek
- ISO 8859-7 Greek
- csisolatingreek
- ecma-118
- greek8
- iso-8859-7
- iso-ir-126
-
-
-
-
-
- Central European
- Windows Central European
- ms-ce
- windows-1250
-
- Hungarian
- Polish
- Romanian
- Croatian
- Slovak
- Slovenian
- Sorbian
-
-
- Croatian
-
-
- compiled
-
-
-
-
-
- East Asian
- GBK Simplified Chinese
- cp936
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Baltic
- Windows Baltic
- WinBaltRim
- windows-1257
-
-
-
- Latvian
- Lithuanian
-
-
-
-
-
-
- South Asian
- ISO 8859-9 Turkish
- csisolatin5
- iso-8859-9
- iso-ir-148
- l5
- latin5
- turkish
-
-
-
-
-
- South Asian
- ARMSCII-8 Armenian
- armscii-8
-
-
-
-
-
- Unicode
- UTF-8 Unicode
- utf-8
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Unicode
- UCS-2 Unicode
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Cyrillic
- DOS Russian
- 866
- csibm866
- ibm866
- DOSCyrillicRussian
-
-
-
-
-
- Central European
- DOS Kamenicky Czech-Slovak
-
-
-
-
-
- Central European
- Mac Central European
- MacCentralEurope
-
- Hungarian
- Polish
- Romanian
- Croatian
- Slovak
- Slovenian
- Sorbian
-
-
-
-
-
- Western
- Mac West European
- Mac
- Macintosh
- csmacintosh
-
- Dutch
- English
- French
- German Duden
- Italian
- Latin
- Portuguese
- Spanish
-
-
-
-
-
-
-
-
- Central European
- DOS Central European
- 852
- cp852
- ibm852
-
- Hungarian
- Polish
- Romanian
- Croatian
- Slovak
- Slovenian
- Sorbian
-
-
-
-
-
- Arabic
- Windows Arabic
- ms-arab
- windows-1256
-
-
- Arabic
- Persian
- Pakistani
- Urdu
-
-
-
-
- South Asian
- GEOSTD8 Georgian
-
-
-
-
-
- Binary pseudo charset
-
- primary
- compiled
-
-
-
-
- Japanese
- SJIS for Windows Japanese
- ms_cp932
- sjis_cp932
- sjis_ms
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
- Japanese
- UJIS for Windows Japanese
- eucjpms
- eucJP_ms
- ujis_ms
- ujis_cp932
-
- primary
- compiled
-
-
- binary
- compiled
-
-
-
-
-
diff --git a/app/code/core/Mage/Oscommerce/etc/config.xml b/app/code/core/Mage/Oscommerce/etc/config.xml
deleted file mode 100755
index 6cfc265802..0000000000
--- a/app/code/core/Mage/Oscommerce/etc/config.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
-
- 0.8.10
-
-
-
-
-
- Mage_Oscommerce_Model
- oscommerce_mysql4
-
-
- Mage_Oscommerce_Model_Mysql4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- oscommerce_orders_products
-
-
-
-
-
- oscommerce_orders_status_history
-
-
-
-
-
-
- Mage_Oscommerce_Block
-
-
-
-
-
- Mage_Oscommerce
-
-
-
-
- pdo_mysql
- mysql4
- 1
-
-
-
-
-
-
-
- admin
-
- Mage_Oscommerce
- oscommerce
-
-
-
-
-
-
-
-
-
- admin/observer
- actionPreDispatchAdmin
-
-
-
-
-
-
-
-
-
- standard
-
- Mage_Oscommerce
- oscommerce
-
-
-
-
-
-
- oscommerce.xml
-
-
-
-
-
-
-
-
- 10
-
-
-
-
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-install-0.8.0.php b/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-install-0.8.0.php
deleted file mode 100755
index 8526581b1f..0000000000
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-install-0.8.0.php
+++ /dev/null
@@ -1,72 +0,0 @@
-startSetup();
-
-$installer->run("
-
--- DROP TABLE IF EXISTS `{$this->getTable('oscommerce_import')}`;
-
-CREATE TABLE `{$this->getTable('oscommerce_import')}` (
- `import_id` int(10) unsigned NOT NULL auto_increment,
- `name` varchar(255) default NULL,
- `created_at` datetime default NULL,
- `updated_at` datetime default NULL,
- `host` varchar(255) NOT NULL,
- `port` int(5) NOT NULL,
- `db_name` varchar(255) default NULL,
- `db_user` varchar(255) default NULL,
- `db_password` varchar(255) default NULL,
- `db_type` varchar(32) default NULL,
- PRIMARY KEY (`import_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `{$this->getTable('oscommerce_import_type')}` (
- `type_id` int(2) unsigned NOT NULL auto_increment,
- `type_code` varchar(32) NOT NULL,
- `type_name` varchar(255) NOT NULL,
- PRIMARY KEY (`type_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
-
-insert into `{$this->getTable('oscommerce_import_type')}`(`type_id`,`type_code`,`type_name`) values (1,'store','Store'),(2,'category','Category'),(3,'product','Product'), (4,'customer','Customer'),(5,'order','Order');
-
-CREATE TABLE `{$this->getTable('oscommerce_ref')}` (
- `id` int(10) unsigned NOT NULL auto_increment,
- `import_id` int(10) NOT NULL,
- `type_id` int(10) NOT NULL,
- `value` int(10) NOT NULL,
- `ref_id` int(10) NOT NULL,
- `created_at` datetime default NULL,
- `user_id` int(10) default NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.1-0.8.2.php b/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.1-0.8.2.php
deleted file mode 100644
index 8dca2f61e6..0000000000
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.1-0.8.2.php
+++ /dev/null
@@ -1,41 +0,0 @@
-startSetup();
-
-$installer->run("
-
-truncate `{$this->getTable('oscommerce_import_type')}`;
-insert into `{$this->getTable('oscommerce_import_type')}`(`type_code`,`type_name`) values ('website', 'Website'),('store','Store'),('category','Category'),('product','Product'), ('customer','Customer'),('order','Order'),('group','Store Group'), ('taxclass', 'Product Tax Class');
-
-ALTER TABLE `{$this->getTable('oscommerce_import')}` ADD table_prefix VARCHAR(32) DEFAULT NULL;
-
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.2-0.8.3.php b/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.2-0.8.3.php
deleted file mode 100644
index a5f49df556..0000000000
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.2-0.8.3.php
+++ /dev/null
@@ -1,125 +0,0 @@
-startSetup();
-
-$installer->run("
-CREATE TABLE IF NOT EXISTS `{$this->getTable('oscommerce_orders')}` (
- `osc_magento_id` int(11) NOT NULL auto_increment,
- `orders_id` int(11) NOT NULL,
- `customers_id` int(11) NOT NULL default '0',
- `magento_customers_id` int(11) NOT NULL default '0',
- `import_id` int(11) NOT NULL default '0',
- `website_id` int(11) NOT NULL default '0',
- `customers_name` varchar(64) NOT NULL default '',
- `customers_company` varchar(32) default NULL,
- `customers_street_address` varchar(64) NOT NULL default '',
- `customers_suburb` varchar(32) default NULL,
- `customers_city` varchar(32) NOT NULL default '',
- `customers_postcode` varchar(10) NOT NULL default '',
- `customers_state` varchar(32) default NULL,
- `customers_country` varchar(32) NOT NULL default '',
- `customers_telephone` varchar(32) NOT NULL default '',
- `customers_email_address` varchar(96) NOT NULL default '',
- `customers_address_format_id` int(5) NOT NULL default '0',
- `delivery_name` varchar(64) NOT NULL default '',
- `delivery_company` varchar(32) default NULL,
- `delivery_street_address` varchar(64) NOT NULL default '',
- `delivery_suburb` varchar(32) default NULL,
- `delivery_city` varchar(32) NOT NULL default '',
- `delivery_postcode` varchar(10) NOT NULL default '',
- `delivery_state` varchar(32) default NULL,
- `delivery_country` varchar(32) NOT NULL default '',
- `delivery_address_format_id` int(5) NOT NULL default '0',
- `billing_name` varchar(64) NOT NULL default '',
- `billing_company` varchar(32) default NULL,
- `billing_street_address` varchar(64) NOT NULL default '',
- `billing_suburb` varchar(32) default NULL,
- `billing_city` varchar(32) NOT NULL default '',
- `billing_postcode` varchar(10) NOT NULL default '',
- `billing_state` varchar(32) default NULL,
- `billing_country` varchar(32) NOT NULL default '',
- `billing_address_format_id` int(5) NOT NULL default '0',
- `payment_method` varchar(255) NOT NULL default '',
- `cc_type` varchar(20) default NULL,
- `cc_owner` varchar(64) default NULL,
- `cc_number` varchar(32) default NULL,
- `cc_expires` varchar(4) default NULL,
- `last_modified` datetime default NULL,
- `date_purchased` datetime default NULL,
- `orders_status` int(5) NOT NULL default '0',
- `orders_date_finished` datetime default NULL,
- `currency` char(3) default NULL,
- `currency_value` decimal(14,6) default NULL,
- `currency_symbol` char(3) default NULL,
- PRIMARY KEY (`osc_magento_id`),
- KEY `idx_orders_customers_id` (`customers_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-CREATE TABLE IF NOT EXISTS `{$this->getTable('oscommerce_orders_products')}` (
- `orders_products_id` int(11) NOT NULL auto_increment,
- `osc_magento_id` int(11) NOT NULL default '0',
- `products_id` int(11) NOT NULL default '0',
- `products_model` varchar(12) default NULL,
- `products_name` varchar(64) NOT NULL default '',
- `products_price` decimal(15,4) NOT NULL default '0.0000',
- `final_price` decimal(15,4) NOT NULL default '0.0000',
- `products_tax` decimal(7,4) NOT NULL default '0.0000',
- `products_quantity` int(2) NOT NULL default '0',
- PRIMARY KEY (`orders_products_id`),
- KEY `idx_orders_products_osc_magento_id` (`osc_magento_id`),
- KEY `idx_orders_products_products_id` (`products_id`)
-) ENGINE=MyISAM CHARSET=latin1;
-
-CREATE TABLE IF NOT EXISTS `{$this->getTable('oscommerce_orders_total')}` (
- `orders_total_id` int(10) unsigned NOT NULL auto_increment,
- `osc_magento_id` int(11) NOT NULL default '0',
- `title` varchar(255) NOT NULL default '',
- `text` varchar(255) NOT NULL default '',
- `value` decimal(15,4) NOT NULL default '0.0000',
- `class` varchar(32) NOT NULL default '',
- `sort_order` int(11) NOT NULL default '0',
- PRIMARY KEY (`orders_total_id`),
- KEY `idx_orders_total_osc_magento_id` (`osc_magento_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-CREATE TABLE IF NOT EXISTS `{$this->getTable('oscommerce_orders_status_history')}`(
- `orders_status_history_id` int(11) NOT NULL auto_increment,
- `osc_magento_id` int(11) NOT NULL default '0',
- `orders_status_id` int(5) NOT NULL default '0',
- `date_added` datetime NOT NULL default '0000-00-00 00:00:00',
- `customer_notified` int(1) default '0',
- `comments` text,
- PRIMARY KEY (`orders_status_history_id`),
- KEY `idx_orders_status_history_osc_magento_id` (`osc_magento_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.4-0.8.5.php b/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.4-0.8.5.php
deleted file mode 100644
index 85ad7eed7c..0000000000
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.4-0.8.5.php
+++ /dev/null
@@ -1,37 +0,0 @@
-startSetup();
-
-$installer->run("
- ALTER TABLE `{$this->getTable('oscommerce_orders')}` MODIFY orders_status varchar(32) default NULL;
- ALTER TABLE `{$this->getTable('oscommerce_orders_status_history')}` ADD orders_status varchar(32) default NULL;
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.6-0.8.7.php b/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.6-0.8.7.php
deleted file mode 100644
index 980784ed95..0000000000
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.6-0.8.7.php
+++ /dev/null
@@ -1,39 +0,0 @@
-startSetup();
-
-$installer->run("
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
-ALTER TABLE `{$this->getTable('oscommerce_orders_products')}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
-ALTER TABLE `{$this->getTable('oscommerce_orders_status_history')}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
-ALTER TABLE `{$this->getTable('oscommerce_orders_total')}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.7-0.8.8.php b/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.7-0.8.8.php
deleted file mode 100644
index 4c013e8178..0000000000
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.7-0.8.8.php
+++ /dev/null
@@ -1,41 +0,0 @@
-startSetup();
-
-$installer->run("
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` ADD purchased_year INT(4) DEFAULT NULL;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` ADD purchased_month INT(2) DEFAULT NULL;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` ADD purchased_day INT(2) DEFAULT NULL;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` ADD modified_year INT(4) DEFAULT NULL;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` ADD modified_month INT(2) DEFAULT NULL;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` ADD modified_day INT(2) DEFAULT NULL;
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.8-0.8.9.php b/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.8-0.8.9.php
deleted file mode 100644
index 78baa3674e..0000000000
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.8-0.8.9.php
+++ /dev/null
@@ -1,41 +0,0 @@
-startSetup();
-
-$installer->run("
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` DROP COLUMN purchased_year;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` DROP COLUMN purchased_month;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` DROP COLUMN purchased_day;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` DROP COLUMN modified_year;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` DROP COLUMN modified_month;
-ALTER TABLE `{$this->getTable('oscommerce_orders')}` DROP COLUMN modified_day;
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Page/Block/Html/Head.php b/app/code/core/Mage/Page/Block/Html/Head.php
index cba29c64b1..0774c22b92 100644
--- a/app/code/core/Mage/Page/Block/Html/Head.php
+++ b/app/code/core/Mage/Page/Block/Html/Head.php
@@ -236,7 +236,7 @@ public function getCssJsHtml()
protected function &_prepareStaticAndSkinElements($format, array $staticItems, array $skinItems, $mergeCallback = null)
{
$designPackage = Mage::getDesign();
- $baseUrl = Mage::getBaseUrl('web');
+ $baseJsUrl = Mage::getBaseUrl('js');
$items = array();
if ($mergeCallback && !is_callable($mergeCallback)) {
$mergeCallback = null;
@@ -245,8 +245,7 @@ protected function &_prepareStaticAndSkinElements($format, array $staticItems, a
// get static files from the js folder, no need in lookups
foreach ($staticItems as $params => $rows) {
foreach ($rows as $name) {
- $items[$params][] = $mergeCallback ? Mage::getBaseDir() . DS . 'js' . DS . $name
- : $baseUrl . 'js/' . $name;
+ $items[$params][] = $mergeCallback ? Mage::getBaseDir() . DS . 'js' . DS . $name : $baseJsUrl . $name;
}
}
diff --git a/app/code/core/Mage/Page/Block/Html/Pager.php b/app/code/core/Mage/Page/Block/Html/Pager.php
index d9bb273413..55f401f87f 100644
--- a/app/code/core/Mage/Page/Block/Html/Pager.php
+++ b/app/code/core/Mage/Page/Block/Html/Pager.php
@@ -36,13 +36,14 @@
class Mage_Page_Block_Html_Pager extends Mage_Core_Block_Template
{
protected $_collection = null;
- protected $_pageVarName = 'p';
- protected $_limitVarName = 'limit';
- protected $_availableLimit = array(10=>10,20=>20,50=>50);
- protected $_dispersion = 3;
- protected $_displayPages = 5;
- protected $_showPerPage = true;
- protected $_limit = null;
+ protected $_pageVarName = 'p';
+ protected $_limitVarName = 'limit';
+ protected $_availableLimit = array(10=>10,20=>20,50=>50);
+ protected $_dispersion = 3;
+ protected $_displayPages = 5;
+ protected $_showPerPage = true;
+ protected $_limit = null;
+ protected $_outputRequired = true;
/**
* Pages quantity per frame
@@ -409,7 +410,7 @@ public function getJump()
* Setter for $_frameLength
*
* @param int $frame
- * @return Mage_Catalog_Block_Product_List_Toolbar_Pager
+ * @return Mage_Page_Block_Html_Pager
*/
public function setFrameLength($frame)
{
@@ -429,7 +430,7 @@ public function setFrameLength($frame)
* Setter for $_jump
*
* @param int $jump
- * @return Mage_Catalog_Block_Product_List_Toolbar_Pager
+ * @return Mage_Page_Block_Html_Pager
*/
public function setJump($jump)
{
@@ -485,7 +486,7 @@ public function canShowNextJump()
/**
* Initialize frame data, such as frame start, frame start etc.
*
- * @return Mage_Catalog_Block_Product_List_Toolbar_Pager
+ * @return Mage_Page_Block_Html_Pager
*/
protected function _initFrame()
{
@@ -526,7 +527,7 @@ protected function _initFrame()
* Setter for flag _frameInitialized
*
* @param bool $flag
- * @return Mage_Catalog_Block_Product_List_Toolbar_Pager
+ * @return Mage_Page_Block_Html_Pager
*/
protected function _setFrameInitialized($flag)
{
@@ -537,7 +538,7 @@ protected function _setFrameInitialized($flag)
/**
* Check if frame data was initialized
*
- * @return Mage_Catalog_Block_Product_List_Toolbar_Pager
+ * @return Mage_Page_Block_Html_Pager
*/
public function isFrameInitialized()
{
@@ -563,5 +564,29 @@ public function getAnchorTextForNext()
{
return Mage::getStoreConfig('design/pagination/anchor_text_for_next');
}
-}
+ /**
+ * Set whether output of the pager is mandatory
+ *
+ * @param bool $isRequired
+ * @return Mage_Page_Block_Html_Pager
+ */
+ public function setIsOutputRequired($isRequired)
+ {
+ $this->_outputRequired = (bool)$isRequired;
+ return $this;
+ }
+
+ /**
+ * Determine whether the pagination should be eventually rendered
+ *
+ * @return string
+ */
+ protected function _toHtml()
+ {
+ if ($this->_outputRequired || $this->getTotalNum() > $this->getLimit()) {
+ return parent::_toHtml();
+ }
+ return '';
+ }
+}
diff --git a/app/code/core/Mage/Page/Block/Html/Wrapper.php b/app/code/core/Mage/Page/Block/Html/Wrapper.php
index 9197866947..74e52eff09 100644
--- a/app/code/core/Mage/Page/Block/Html/Wrapper.php
+++ b/app/code/core/Mage/Page/Block/Html/Wrapper.php
@@ -49,15 +49,17 @@ class Mage_Page_Block_Html_Wrapper extends Mage_Core_Block_Abstract
*/
protected function _toHtml()
{
- if ($this->_dependsOnChildren && empty($this->_children)) {
+ $html = empty($this->_children) ? '' : trim($this->getChildHtml('', true, true));
+ if ($this->_dependsOnChildren && empty($html)) {
return '';
}
+ if ($this->_isInvisible()) {
+ return $html;
+ }
$id = $this->hasElementId() ? sprintf(' id="%s"', $this->getElementId()) : '';
$class = $this->hasElementClass() ? sprintf(' class="%s"', $this->getElementClass()) : '';
$otherParams = $this->hasOtherParams() ? ' ' . $this->getOtherParams() : '';
- return sprintf('<%1$s%2$s%3$s%4$s>%5$s%1$s>',
- $this->getElementTagName(), $id, $class, $otherParams, $this->getChildHtml()
- );
+ return sprintf('<%1$s%2$s%3$s%4$s>%5$s%1$s>', $this->getElementTagName(), $id, $class, $otherParams, $html);
}
/**
@@ -80,4 +82,23 @@ public function dependsOnChildren($depends = '0')
$this->_dependsOnChildren = (bool)(int)$depends;
return $this;
}
+
+ /**
+ * Whether the wrapper element should be eventually rendered
+ * If it becomes "invisible", the behaviour will be somewhat similar to core/text_list
+ *
+ * @return bool
+ */
+ protected function _isInvisible()
+ {
+ if (!$this->hasMayBeInvisible()) {
+ return false;
+ }
+ foreach ($this->_children as $child) {
+ if ($child->hasWrapperMustBeVisible()) {
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/app/code/core/Mage/Eway/Block/Secure/Failure.php b/app/code/core/Mage/Page/Block/Js/Cookie.php
similarity index 59%
rename from app/code/core/Mage/Eway/Block/Secure/Failure.php
rename to app/code/core/Mage/Page/Block/Js/Cookie.php
index 9c76d62811..a1c41b9dc3 100644
--- a/app/code/core/Mage/Eway/Block/Secure/Failure.php
+++ b/app/code/core/Mage/Page/Block/Js/Cookie.php
@@ -19,35 +19,43 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Eway
+ * @package Mage_Page
* @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)
*/
-/**
- * Secure Failure Response Block
- *
- * @category Mage
- * @package Mage_Eway
- * @author Magento Core Team
- */
-class Mage_Eway_Block_Secure_Failure extends Mage_Core_Block_Template
+class Mage_Page_Block_Js_Cookie extends Mage_Core_Block_Template
{
/**
- * Return Error message
+ * Get cookie model instance
*
- * @return string
+ * @return Mage_Core_Model_Cookie
*/
- public function getErrorMessage ()
+ public function getCookie()
{
- return Mage::getSingleton('checkout/session')->getEwayErrorMessage();
+ return Mage::getSingleton('core/cookie');
+ }
+ /**
+ * Get configured cookie domain
+ *
+ * @return string
+ */
+ public function getDomain()
+ {
+ $domain = $this->getCookie()->getDomain();
+ if (!empty($domain[0]) && ($domain[0] !== '.')) {
+ $domain = '.'.$domain;
+ }
+ return $domain;
}
/**
- * Get continue shopping url
+ * Get configured cookie path
+ *
+ * @return string
*/
- public function getContinueShoppingUrl()
+ public function getPath()
{
- return Mage::getUrl('checkout/cart');
+ return $this->getCookie()->getPath();
}
}
diff --git a/app/code/core/Mage/Paybox/Block/Adminhtml/Cart/Type.php b/app/code/core/Mage/Paybox/Block/Adminhtml/Cart/Type.php
deleted file mode 100644
index 98fc47b8f3..0000000000
--- a/app/code/core/Mage/Paybox/Block/Adminhtml/Cart/Type.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- */
-class Mage_Paybox_Block_Adminhtml_Cart_Type extends Mage_Adminhtml_Block_System_Config_Form_Field
-{
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
- {
- $additional = Mage::getSingleton('core/layout')->createBlock('paybox/adminhtml_cart_type_select')
- ->setTemplate('paybox/adminhtml/cart/type/select.phtml')
- ->setDependHtmlId($element->getHtmlId())
- ->toHtml();
-
- return parent::_getElementHtml($element).$additional;
- }
-
-}
diff --git a/app/code/core/Mage/Paybox/Block/Direct/Form.php b/app/code/core/Mage/Paybox/Block/Direct/Form.php
deleted file mode 100644
index 42f9a29602..0000000000
--- a/app/code/core/Mage/Paybox/Block/Direct/Form.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Paybox_Block_Direct_Form extends Mage_Payment_Block_Form_Cc
-{
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('paybox/direct/form.phtml');
- }
-
-}
diff --git a/app/code/core/Mage/Paybox/Block/System/Error.php b/app/code/core/Mage/Paybox/Block/System/Error.php
deleted file mode 100644
index cf545cbd0f..0000000000
--- a/app/code/core/Mage/Paybox/Block/System/Error.php
+++ /dev/null
@@ -1,93 +0,0 @@
-
- */
-class Mage_Paybox_Block_System_Error extends Mage_Core_Block_Template
-{
-
- /**
- * Error messages desciptions
- *
- * @var array
- */
- protected $_pbxErrorsDesc;
-
- /**
- * Enter description here...
- *
- * @return Mage_Checkout_Model_Session
- */
- public function getCheckout()
- {
- return Mage::getSingleton('checkout/session');
- }
-
- public function getErrorMessage()
- {
- if (empty($this->_pbxErrorsDesc)) {
- $this->_pbxErrorsDesc = array(
- '-1' => 'Error in reading the parameters via stdin (POST method) (error in http reception)',
- '-2' => 'Error in memory allocation. Not enough memory available on the trader\'s server',
- '-3' => 'Error in reading the parameters QUERY_STRING or CONTENT_LENGTH. (http error)',
- '-4' => 'PBX_RETOUR, PBX_ANNULE, PBX_REFUSE or PBX_EFFECTUE are too long (<150 characters)',
- '-5' => 'Error in opening the file (if PBX_MODE contains 3) : local file non-existent, not found or access error',
- '-6' => 'Error in file format (if PBX_MODE contains 3) : local file badly formed, empty or lines are badly formatted',
- '-7' => 'A compulsory variable is missing (PBX_SITE, PBX_RANG, PBX_IDENTIFIANT, PBX_TOTAL, PBX_CMD, etc.)',
- '-8' => 'One of the numerical variables contains a non-numerical character (site, rank, identifier, amount, currency etc.)',
- '-9' => 'PBX_SITE contains a site number which does not consist of exactly 7 characters',
- '-10' => 'PBX_RANG contains a rank number which does not consist of exactly 2 characters',
- '-11' => 'PBX_TOTAL has more than 10 or fewer than 3 numerical characters',
- '-12' => 'PBX_LANGUE or PBX_DEVISE contains a code which does not contain exactly 3 characters',
- '-13' => 'PBX_CMD is empty or contains a reference longer than 250 characters',
- '-14' => '',
- '-15' => '',
- '-16' => 'PBX_PORTEUR does not contain a valid e-mail address',
- '-17' => 'Error of coherence (multi-baskets) : Reserved Future Usage',
- );
- }
- $msg = Mage::helper('paybox')->__($this->_pbxErrorsDesc[$this->getCheckout()->getPayboxErrorNumber()]);
- $this->getCheckout()->unsPayboxErrorNumber();
- return $msg;
- }
-
- /**
- * Get continue shopping url
- *
- * @return string
- */
- public function getContinueShoppingUrl()
- {
- return Mage::getUrl('checkout/cart', array('_secure' => true));
- }
-
-}
diff --git a/app/code/core/Mage/Paybox/Block/System/Form.php b/app/code/core/Mage/Paybox/Block/System/Form.php
deleted file mode 100644
index e2785d4082..0000000000
--- a/app/code/core/Mage/Paybox/Block/System/Form.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Paybox_Block_System_Form extends Mage_Payment_Block_Form
-{
- protected function _construct()
- {
- $this->setTemplate('paybox/system/form.phtml');
- parent::_construct();
- }
-}
diff --git a/app/code/core/Mage/Paybox/Block/System/Redirect.php b/app/code/core/Mage/Paybox/Block/System/Redirect.php
deleted file mode 100644
index 576e613971..0000000000
--- a/app/code/core/Mage/Paybox/Block/System/Redirect.php
+++ /dev/null
@@ -1,57 +0,0 @@
-
- */
-class Mage_Paybox_Block_System_Redirect extends Mage_Core_Block_Abstract
-{
- protected function _toHtml()
- {
- $system = $this->getOrder()->getPayment()->getMethodInstance();
-
- $form = new Varien_Data_Form();
- $form->setAction(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$system->getPayboxFile())
- ->setId('paybox_system_checkout')
- ->setName('paybox_system_checkout')
- ->setMethod('POST')
- ->setUseContainer(true);
- foreach ($system->getFormFields() as $field=>$value) {
- $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
- }
- $html = '';
- $html.= $this->__('You will be redirected to Paybox in a few seconds.');
- $html.= $form->toHtml();
- $html.= '';
- $html.= '';
-
- return $html;
- }
-}
diff --git a/app/code/core/Mage/Paybox/Helper/Data.php b/app/code/core/Mage/Paybox/Helper/Data.php
deleted file mode 100644
index b398b2d488..0000000000
--- a/app/code/core/Mage/Paybox/Helper/Data.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-class Mage_Paybox_Helper_Data extends Mage_Core_Helper_Abstract
-{
-
-}
diff --git a/app/code/core/Mage/Paybox/Model/Api/Debug.php b/app/code/core/Mage/Paybox/Model/Api/Debug.php
deleted file mode 100644
index e2f9274a4c..0000000000
--- a/app/code/core/Mage/Paybox/Model/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Paybox_Model_Api_Debug extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('paybox/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Direct.php b/app/code/core/Mage/Paybox/Model/Direct.php
deleted file mode 100644
index de6c8aaec1..0000000000
--- a/app/code/core/Mage/Paybox/Model/Direct.php
+++ /dev/null
@@ -1,506 +0,0 @@
-
- */
-class Mage_Paybox_Model_Direct extends Mage_Payment_Model_Method_Cc
-{
- /**
- * Paybox direct payment actions
- */
- const PBX_PAYMENT_ACTION_ATHORIZE = '00001';
- const PBX_PAYMENT_ACTION_DEBIT = '00002';
- const PBX_PAYMENT_ACTION_ATHORIZE_CAPTURE = '00003';
- const PBX_PAYMENT_ACTION_CANCELLATION = '00005';
- const PBX_PAYMENT_ACTION_REFUND = '00004';
-
- const PBX_VERSION = '00103';
-
- /**
- * ECL(Electronic Commerce Indicator).
- * Type of ordering items. Need for some banks.
- * 024 - request by internet
- */
- const PBX_ACTIVITE_VALUE = '024';
-
- protected $_code = 'paybox_direct';
-
- protected $_isGateway = true;
- protected $_canAuthorize = true;
- protected $_canCapture = true;
- protected $_canCapturePartial = false;
- protected $_canRefund = true;
- protected $_canVoid = false;
- protected $_canUseInternal = true;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = true;
- protected $_canSaveCc = true;
-
- protected $_formBlockType = 'paybox/direct_form';
- protected $_infoBlockType = 'paybox/direct_info';
-
- protected $_order;
- protected $_currenciesNumbers;
- protected $_questionNumberModel;
-
- /**
- * Return paybox gateway url.
- * If $recallNumber > 0 (primary url is not available) return url of backup gateway
- *
- * @param integer $recallNumber
- * @return string
- */
- public function getPayboxUrl($recallNumber)
- {
- $path = 'pbx_url';
- if ($recallNumber) {
- $path = 'pbx_backupurl';
- }
- return $this->getConfigData($path);
- }
-
- /**
- * Get Payment Action of Paybox Direct,
- * changed to Paybox specification
- *
- * @return string
- */
- public function getPaymentAction()
- {
- $paymentAction = $this->getConfigData('payment_action');
- switch ($paymentAction) {
- case self::ACTION_AUTHORIZE:
- return self::PBX_PAYMENT_ACTION_ATHORIZE;
- break;
- case self::ACTION_AUTHORIZE_CAPTURE:
- return self::PBX_PAYMENT_ACTION_ATHORIZE_CAPTURE;
- break;
- default:
- return self::PBX_PAYMENT_ACTION_ATHORIZE;
- break;
- }
- }
-
- /**
- * Return site number of account (TPE)
- *
- * @return string
- */
- public function getSiteNumber()
- {
- return $this->getConfigData('pbx_site');
- }
-
- /**
- * Return rang number of account
- *
- * @return string
- */
- public function getRang()
- {
- return $this->getConfigData('pbx_rang');
- }
-
- /**
- * Return Cle number of account
- *
- * @return string
- */
- public function getCleNumber()
- {
- return $this->getConfigData('pbx_cle');
- }
-
- /**
- * Return currency number in ISO4217 format
- *
- * @return string
- */
- public function getCurrencyNumb()
- {
- $currencyCode = $this->getPayment()->getOrder()->getBaseCurrencyCode();
- if (!$this->_currenciesNumbers) {
- $this->_currenciesNumbers = simplexml_load_file(Mage::getBaseDir().'/app/code/core/Mage/Paybox/etc/currency.xml');
- }
- if ($this->_currenciesNumbers->$currencyCode) {
- return (string)$this->_currenciesNumbers->$currencyCode;
- }
- }
-
- /**
- * Return model of Question Number
- *
- * @return Mage_Paybox_Model_Question_Number
- */
- public function getQuestionNumberModel()
- {
- if (!$this->_questionNumberModel) {
- $accountHash = md5($this->getSiteNumber().$this->getRang());
- $this->_questionNumberModel = Mage::getModel('paybox/question_number')->load($accountHash, 'account_hash');
- }
- return $this->_questionNumberModel;
- }
-
- /**
- * Return Debug Flag
- *
- * @return string
- */
- public function getDebugFlag()
- {
- return $this->getConfigData('debug_flag');
- }
-
- public function authorize(Varien_Object $payment, $amount)
- {
- parent::authorize($payment, $amount);
-
- $this->setAmount($amount)
- ->setPayment($payment);
-
- if ($this->callDoDirectPayment()!==false) {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId())
- ->setPayboxRequestNumber($this->getRequestNumber())
- ->setPayboxQuestionNumber($this->getQuestionNumber());
- } else {
- $e = $this->getError();
- if (isset($e['message'])) {
- $message = Mage::helper('paybox')->__('There has been an error processing your payment. ') . $e['message'];
- } else {
- $message = Mage::helper('paybox')->__('There has been an error processing your payment. Please try later or contact us for help.');
- }
- Mage::throwException($message);
- }
-
- return $this;
- }
-
- public function capture(Varien_Object $payment, $amount)
- {
- parent::capture($payment, $amount);
-
- $this->setAmount($amount)
- ->setPayment($payment);
-
- if ($payment->getLastTransId()) {//if after authorize
- $result = $this->callDoDebitPayment()!==false;
- } else {//authorize+capture (debit)
- $result = $this->callDoDirectPayment()!==false;
- }
-
- if ($result) {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId())
- ->setPayboxRequestNumber($this->getRequestNumber());
- } else {
- $e = $this->getError();
- if (isset($e['message'])) {
- $message = Mage::helper('paybox')->__('There has been an error processing your payment. ') . $e['message'];
- } else {
- $message = Mage::helper('paybox')->__('There has been an error processing your payment. Please try later or contact us for help.');
- }
- Mage::throwException($message);
- }
-
- return $this;
- }
-
- public function cancel(Varien_Object $payment)
- {
- $payment->setStatus(self::STATUS_DECLINED);
- return $this;
- }
-
- public function refund(Varien_Object $payment, $amount)
- {
- parent::refund($payment, $amount);
-
- $error = false;
- if($payment->getRefundTransactionId() && $amount>0) {
- $this->setTransactionId($payment->getRefundTransactionId())
- ->setPayment($payment)
- ->setAmount($amount);
-
- if ($this->callDoRefund()!==false) {
- $payment->setStatus(self::STATUS_SUCCESS)
- ->setCcTransId($this->getTransactionId());
- } else {
- $payment->setStatus(self::STATUS_ERROR);
- $e = $this->getError();
- if (isset($e['message'])) {
- $error = $e['message'];
- } else {
- $error = Mage::helper('paybox')->__('Error in refunding the payment');
- }
- }
- } else {
- $payment->setStatus(self::STATUS_ERROR);
- $error = Mage::helper('paybox')->__('Error in refunding the payment');
- }
- if ($error !== false) {
- Mage::throwException($error);
- }
-
- return $this;
- }
-
- /**
- * Building array of params for direct payment
- *
- * @return bool | array
- */
- public function callDoDirectPayment()
- {
- $payment = $this->getPayment();
- $requestStr = '';
-
- $tmpArr = array(
- 'VERSION' => self::PBX_VERSION,
- 'DATEQ' => Mage::getModel('core/date')->date('dmYHis'),
- 'TYPE' => $this->getPaymentAction(),
- 'NUMQUESTION' => $this->getQuestionNumberModel()->getNextQuestionNumber(),
- 'SITE' => $this->getSiteNumber(),
- 'RANG' => $this->getRang(),
- 'CLE' => $this->getCleNumber(),
- 'IDENTIFIANT' => '',
- 'MONTANT' => ($this->getAmount()*100),
- 'DEVISE' => $this->getCurrencyNumb(),
- 'REFERENCE' => base64_encode($payment->getOrder()->getRealOrderId()),
- 'PORTEUR' => $payment->getCcNumber(),
- 'DATEVAL' => Mage::getModel('core/date')->date('my', mktime(0,0,0,$payment->getCcExpMonth(),1,$payment->getCcExpYear())),
- 'CVV' => $payment->getCcCid(),
- 'ACTIVITE' => self::PBX_ACTIVITE_VALUE,
- );
-
- foreach ($tmpArr as $param=>$value) {
- $requestStr .= $param . '=' . $value . '&';
- }
- $requestStr = substr($requestStr, 0, -1);
-
- $resultArr = $this->call($requestStr);
-
- if ($resultArr === false) {
- return false;
- }
-
- $this->getQuestionNumberModel()
- ->increaseQuestionNumber();
-
- $this->setTransactionId($resultArr['NUMTRANS']);
- $this->setRequestNumber($resultArr['NUMAPPEL']);
- $this->setQuestionNumber($resultArr['NUMQUESTION']);
-
- return $resultArr;
- }
-
- /**
- * Building array of params for debit (after authorize)
- *
- * @return bool | array
- */
- public function callDoDebitPayment()
- {
- $payment = $this->getPayment();
- $requestStr = '';
-
- $tmpArr = array(
- 'VERSION' => self::PBX_VERSION,
- 'DATEQ' => Mage::getModel('core/date')->date('dmYHis'),
- 'TYPE' => self::PBX_PAYMENT_ACTION_DEBIT,
- 'NUMQUESTION' => $payment->getPayboxQuestionNumber(),
- 'SITE' => $this->getSiteNumber(),
- 'RANG' => $this->getRang(),
- 'CLE' => $this->getCleNumber(),
- 'MONTANT' => ($this->getAmount()*100),
- 'DEVISE' => (string)$this->getCurrencyNumb(),
- 'REFERENCE' => base64_encode($payment->getOrder()->getRealOrderId()),
- 'NUMAPPEL' => $payment->getPayboxRequestNumber(),
- 'NUMTRANS' => $payment->getLastTransId(),
- );
-
- foreach ($tmpArr as $param=>$value) {
- $requestStr .= $param . '=' . $value . '&';
- }
- $requestStr = substr($requestStr, 0, -1);
-
- $resultArr = $this->call($requestStr);
-
- if ($resultArr === false) {
- return false;
- }
-
- $this->setTransactionId($resultArr['NUMTRANS']);
-
- return $resultArr;
- }
-
- /**
- * Building array of params for refund
- *
- * @return bool | array
- */
- public function callDoRefund()
- {
- $payment = $this->getPayment();
- $requestStr = '';
-
- $tmpArr = array(
- 'VERSION' => self::PBX_VERSION,
- 'DATEQ' => Mage::getModel('core/date')->date('dmYHis'),
- 'TYPE' => self::PBX_PAYMENT_ACTION_REFUND,
- 'NUMQUESTION' => $this->getQuestionNumberModel()->getNextQuestionNumber(),
- 'SITE' => $this->getSiteNumber(),
- 'RANG' => $this->getRang(),
- 'CLE' => $this->getCleNumber(),
- 'MONTANT' => ($this->getAmount()*100),
- 'DEVISE' => (string)$this->getCurrencyNumb(),
- 'REFERENCE' => base64_encode($payment->getOrder()->getRealOrderId()),
- 'PORTEUR' => $payment->getCcNumber(),
- 'DATEVAL' => Mage::getModel('core/date')->date('my', mktime(0,0,0,$payment->getCcExpMonth(),1,$payment->getCcExpYear())),
- 'NUMAPPEL' => '',
- 'NUMTRANS' => '',
- );
-
- foreach ($tmpArr as $param=>$value) {
- $requestStr .= $param . '=' . $value . '&';
- }
- $requestStr = substr($requestStr, 0, -1);
-
- $resultArr = $this->call($requestStr);
-
- if ($resultArr === false) {
- return false;
- }
-
- $this->getQuestionNumberModel()
- ->increaseQuestionNumber();
-
- $this->setTransactionId($resultArr['NUMTRANS']);
-
- return $resultArr;
- }
-
- /**
- * Making a call to gateway
- *
- * @param string $requestStr
- * @return bool | array
- */
- public function call($requestStr)
- {
- if ($this->getDebugFlag()) {
- $debug = Mage::getModel('paybox/api_debug')
- ->setRequestBody($requestStr)
- ->save();
- }
- $recall = true;
- $recallCounter = 0;
- while ($recall && $recallCounter < 3) {
- $recall = false;
- $this->unsError();
-
- $http = new Varien_Http_Adapter_Curl();
- $config = array('timeout' => 30);
- $http->setConfig($config);
- $http->write(Zend_Http_Client::POST, $this->getPayboxUrl($recallCounter), '1.1', array(), $requestStr);
- $response = $http->read();
-
- $response = preg_split('/^\r?$/m', $response, 2);
- $response = trim($response[1]);
-
- if ($http->getErrno()) {
- $http->close();
- if ($this->getDebugFlag()) {
- $debug->setResponseBody($response)->save();
- }
- $this->setError(array(
- 'message' => $http->getError()
- ));
- return false;
- }
- $http->close();
-
- $parsedResArr = $this->parseResponseStr($response);
-
- //primary gateway is down, need to recall to backup gateway
- if ($parsedResArr['CODEREPONSE'] == '00001' ||
- $parsedResArr['CODEREPONSE'] == '00097' ||
- $parsedResArr['CODEREPONSE'] == '00098'
- ) {
- $recallCounter++;
- $recall = true;
- }
- }
-
- if ($this->getDebugFlag()) {
- $debug->setResponseBody($response)->save();
- }
-
- //if backup gateway was down too
- if ($recall) {
- $this->setError(array(
- 'message' => Mage::helper('paybox')->__('Paybox payment gateway is not available right now')
- ));
- return false;
- }
-
- if ($parsedResArr['CODEREPONSE'] == '00000') {
- return $parsedResArr;
- }
-
- if (isset($parsedResArr['COMMENTAIRE'])) {
- $this->setError(array(
- 'message' => $parsedResArr['CODEREPONSE'] . ':' . $parsedResArr['COMMENTAIRE']
- ));
- }
-
- return false;
- }
-
- /**
- * Parsing response string
- *
- * @param string $str
- * @return array
- */
- public function parseResponseStr($str)
- {
- $tmpResponseArr = explode('&', $str);
- $responseArr = array();
- foreach ($tmpResponseArr as $response) {
- $paramValue = explode('=', $response);
- $responseArr[$paramValue[0]] = $paramValue[1];
- }
-
- return $responseArr;
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Mysql4/Api/Debug.php b/app/code/core/Mage/Paybox/Model/Mysql4/Api/Debug.php
deleted file mode 100644
index cc7bd6adc6..0000000000
--- a/app/code/core/Mage/Paybox/Model/Mysql4/Api/Debug.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Paybox_Model_Mysql4_Api_Debug extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('paybox/api_debug', 'debug_id');
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Mysql4/Api/Debug/Collection.php b/app/code/core/Mage/Paybox/Model/Mysql4/Api/Debug/Collection.php
deleted file mode 100644
index d644c98ffe..0000000000
--- a/app/code/core/Mage/Paybox/Model/Mysql4/Api/Debug/Collection.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Paybox_Model_Mysql4_Api_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('paybox/api_debug');
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Mysql4/Question/Number.php b/app/code/core/Mage/Paybox/Model/Mysql4/Question/Number.php
deleted file mode 100644
index 15dd4dc113..0000000000
--- a/app/code/core/Mage/Paybox/Model/Mysql4/Question/Number.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- */
-class Mage_Paybox_Model_Mysql4_Question_Number extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('paybox/question_number', 'account_id');
- }
-
-}
diff --git a/app/code/core/Mage/Paybox/Model/Mysql4/Setup.php b/app/code/core/Mage/Paybox/Model/Mysql4/Setup.php
deleted file mode 100644
index 482999c6f8..0000000000
--- a/app/code/core/Mage/Paybox/Model/Mysql4/Setup.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-class Mage_Paybox_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
-{
-
-}
diff --git a/app/code/core/Mage/Paybox/Model/Question/Number.php b/app/code/core/Mage/Paybox/Model/Question/Number.php
deleted file mode 100644
index b87a4c8854..0000000000
--- a/app/code/core/Mage/Paybox/Model/Question/Number.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
- */
-class Mage_Paybox_Model_Question_Number extends Mage_Core_Model_Abstract
-{
- /**
- * Max value of question number
- */
- const MAX_QUESTION_NUMBER_VALUE = 2147483647;
-
- protected $_accountHash;
-
- protected function _construct()
- {
- $this->_init('paybox/question_number');
- }
-
- public function load($id, $field=null)
- {
- $this->_accountHash = $id;
- return parent::load($id, $field);
- }
-
- protected function _afterLoad()
- {
- //need to create new record (with default data) if it first time using of paybox direct
- if (!$this->getAccountHash()) {
- $this->setAccountHash($this->_accountHash);
- $this->setIncrementValue(1);
- $this->save();
- }
- unset($this->_accountHash);
-
- //need to set default value of question number if it reach max value
- if ($this->getIncrementValue() >= self::MAX_QUESTION_NUMBER_VALUE) {
- $this->setResetDate('CURRENT_TIMESTAMP')
- ->setIncrementValue(1);
- }
-
- return parent::_afterLoad();
- }
-
- /**
- * Return next number formated to paybox specification
- *
- * @return string
- */
- public function getNextQuestionNumber()
- {
- $questionNumber = $this->getIncrementValue()+1;
- return sprintf('%010d', $questionNumber);
- }
-
- /**
- * Increase question number and save it after successful transaction
- *
- * @return Mage_Paybox_Model_Question_Number
- */
- public function increaseQuestionNumber()
- {
- $this->setIncrementValue($this->getIncrementValue()+1)
- ->save();
- return $this;
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/CartType.php b/app/code/core/Mage/Paybox/Model/Source/CartType.php
deleted file mode 100644
index d7bb0662b2..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/CartType.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_CartType
-{
- /**
- * Enter description here...
- *
- * @return Mage_Paybox_Model_System
- */
- public function getModel()
- {
- return Mage::getModel('paybox/system');
- }
-
- public function toOptionArray()
- {
- $cartTypesArr = array();
- $tmpArr = $this->getModel()->getCartTypesByPayment($this->getModel()->getPaymentType());
-
- foreach ($tmpArr as $code => $name) {
- $cartTypesArr[] = array(
- 'value' => $code,
- 'label' => $name
- );
- }
-
- return $cartTypesArr;
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/Cctype.php b/app/code/core/Mage/Paybox/Model/Source/Cctype.php
deleted file mode 100644
index d571ff3cba..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/Cctype.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
-{
- public function getAllowedTypes()
- {
- return array('VI', 'MC', 'AE', 'OT');
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/Language.php b/app/code/core/Mage/Paybox/Model/Source/Language.php
deleted file mode 100644
index 6a9a08105a..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/Language.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_Language
-{
- public function toOptionArray()
- {
- return array(
-// array('value' => Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_AUTH, 'label' => Mage::helper('paypal')->__('Authorization')),
- array('value' => 'FRA', 'label' => Mage::helper('paybox')->__('FRA (French)')),
- array('value' => 'GBR', 'label' => Mage::helper('paybox')->__('GBR (English)')),
- array('value' => 'ESP', 'label' => Mage::helper('paybox')->__('ESP (Spanish)')),
- array('value' => 'ITA', 'label' => Mage::helper('paybox')->__('ITA (Italian)')),
- array('value' => 'DEU', 'label' => Mage::helper('paybox')->__('DEU (German)')),
- array('value' => 'NLD', 'label' => Mage::helper('paybox')->__('NLD (Dutch)')),
- array('value' => 'SWE', 'label' => Mage::helper('paybox')->__('SWE (Swedish)')),
- );
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/ManagementMode.php b/app/code/core/Mage/Paybox/Model/Source/ManagementMode.php
deleted file mode 100644
index 7d4746016b..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/ManagementMode.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_ManagementMode
-{
- public function toOptionArray()
- {
- return array(
-// array('value' => Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_AUTH, 'label' => Mage::helper('paypal')->__('Authorization')),
- array('value' => 'A', 'label' => Mage::helper('paybox')->__('Mode A')),
- array('value' => 'B', 'label' => Mage::helper('paybox')->__('Mode B')),
- array('value' => 'C', 'label' => Mage::helper('paybox')->__('Mode C')),
- array('value' => 'D', 'label' => Mage::helper('paybox')->__('Mode D')),
- array('value' => 'E', 'label' => Mage::helper('paybox')->__('Mode E')),
- );
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/MethodCall.php b/app/code/core/Mage/Paybox/Model/Source/MethodCall.php
deleted file mode 100644
index 3ed23f4263..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/MethodCall.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_MethodCall
-{
- public function toOptionArray()
- {
- return array(
-// array('value' => Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_AUTH, 'label' => Mage::helper('paypal')->__('Authorization')),
- array('value' => 'GET', 'label' => Mage::helper('paybox')->__('GET')),
- array('value' => 'POST', 'label' => Mage::helper('paybox')->__('POST')),
- );
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/PaymentAction.php b/app/code/core/Mage/Paybox/Model/Source/PaymentAction.php
deleted file mode 100644
index faa2c732d6..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/PaymentAction.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_PaymentAction
-{
- public function toOptionArray()
- {
- return array(
- array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, 'label' => Mage::helper('paybox')->__('Authorization')),
- array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, 'label' => Mage::helper('paybox')->__('Payment')),
- );
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/PaymentMode.php b/app/code/core/Mage/Paybox/Model/Source/PaymentMode.php
deleted file mode 100644
index f90a92c74d..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/PaymentMode.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_PaymentMode
-{
- public function toOptionArray()
- {
- return array(
-// array('value' => Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_AUTH, 'label' => Mage::helper('paypal')->__('Authorization')),
- array('value' => 1, 'label' => Mage::helper('paybox')->__('HTML form')),
- array('value' => 4, 'label' => Mage::helper('paybox')->__('Command Line Mode')),
- );
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/Source/PaymentType.php b/app/code/core/Mage/Paybox/Model/Source/PaymentType.php
deleted file mode 100644
index d1ba5b3b98..0000000000
--- a/app/code/core/Mage/Paybox/Model/Source/PaymentType.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
- */
-class Mage_Paybox_Model_Source_PaymentType
-{
- public function toOptionArray()
- {
- return array(
- array('value' => '', 'label' => Mage::helper('paybox')->__('--Please Select--')),
- array('value' => Mage_Paybox_Model_System::PBX_PAYMENT_TYPE_CARTE, 'label' => Mage::helper('paybox')->__('CARTE')),
- array('value' => Mage_Paybox_Model_System::PBX_PAYMENT_TYPE_SYMPASS, 'label' => Mage::helper('paybox')->__('SYMPASS')),
- array('value' => Mage_Paybox_Model_System::PBX_PAYMENT_TYPE_PAYNOVA , 'label' => Mage::helper('paybox')->__('PAYNOVA')),
- array('value' => Mage_Paybox_Model_System::PBX_PAYMENT_TYPE_TERMINEO, 'label' => Mage::helper('paybox')->__('TERMINEO')),
- array('value' => Mage_Paybox_Model_System::PBX_PAYMENT_TYPE_PAYPAL, 'label' => Mage::helper('paybox')->__('PAYPAL')),
- );
- }
-}
diff --git a/app/code/core/Mage/Paybox/Model/System.php b/app/code/core/Mage/Paybox/Model/System.php
deleted file mode 100644
index bd66516c4f..0000000000
--- a/app/code/core/Mage/Paybox/Model/System.php
+++ /dev/null
@@ -1,529 +0,0 @@
-
- */
-class Mage_Paybox_Model_System extends Mage_Payment_Model_Method_Abstract
-{
- /**
- * Paybox const variables
- */
- const PBX_FORM_HTML_METHOD = 1;
- const PBX_COMMAND_LINE_METHOD = 4;
-
- const PBX_METHOD_CALL = 'POST';
-
- const PBX_PAYMENT_ACTION_ATHORIZE = 'O';
- const PBX_PAYMENT_ACTION_ATHORIZE_CAPTURE = 'N';
-
- const PBX_PAYMENT_TYPE_CARTE = 'CARTE';
- const PBX_PAYMENT_TYPE_SYMPASS = 'SYMPASS';
- const PBX_PAYMENT_TYPE_PAYNOVA = 'PAYNOVA';
- const PBX_PAYMENT_TYPE_TERMINEO = 'TERMINEO';
- const PBX_PAYMENT_TYPE_PAYPAL = 'PAYPAL';
-
- const PBX_CARTE_TYPE_CB = 'CB';
- const PBX_CARTE_TYPE_VISA = 'VISA';
- const PBX_CARTE_TYPE_EUROCARDMASTERCARD = 'EUROCARD_MASTERCARD';
- const PBX_CARTE_TYPE_ECARD = 'E_CARD';
- const PBX_CARTE_TYPE_AMEX = 'AMEX';
- const PBX_CARTE_TYPE_DINERS = 'DINERS';
- const PBX_CARTE_TYPE_JCB = 'JCB';
- const PBX_CARTE_TYPE_AURORE = 'AURORE';
- const PBX_CARTE_TYPE_PAYNOVA = 'PAYNOVA';
- const PBX_CARTE_TYPE_TERMINEO = 'TERMINEO';
- const PBX_CARTE_TYPE_PAYPAL = 'PAYPAL';
-
- protected $_code = 'paybox_system';
-
- protected $_isGateway = false;
- protected $_canAuthorize = true;
- protected $_canCapture = false;
- protected $_canCapturePartial = false;
- protected $_canRefund = false;
- protected $_canVoid = false;
- protected $_canUseInternal = false;
- protected $_canUseCheckout = true;
- protected $_canUseForMultishipping = false;
-
- protected $_formBlockType = 'paybox/system_form';
-
- protected $_order;
- protected $_cartTypes;
- protected $_currenciesNumbers;
-
- /**
- * Get order model
- *
- * @return Mage_Sales_Model_Order
- */
- public function getOrder()
- {
- if (!$this->_order) {
- $paymentInfo = $this->getInfoInstance();
- $this->_order = Mage::getModel('sales/order')
- ->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
- }
- return $this->_order;
- }
-
- /**
- * Set order
- *
- * @param Mage_Sales_Model_Order $order
- */
- public function setOrder(Mage_Sales_Model_Order $order)
- {
- $this->_order = $order;
- return $this;
- }
-
- /**
- * Get cart types for all payment types
- * or for given payment type
- *
- * @param string $paymentType
- * @return array
- */
- protected function _getCartTypes($paymentType = null)
- {
- if (!$this->_cartTypes) {
- $this->_cartTypes = array(
- self::PBX_PAYMENT_TYPE_CARTE => array(
- 'none' => Mage::helper('paybox')->__('Customer Choise'),
- self::PBX_CARTE_TYPE_CB => Mage::helper('paybox')->__('CB'),
- self::PBX_CARTE_TYPE_VISA => Mage::helper('paybox')->__('VISA'),
- self::PBX_CARTE_TYPE_EUROCARDMASTERCARD => Mage::helper('paybox')->__('EUROCARD & MASTERCARD'),
- self::PBX_CARTE_TYPE_ECARD => Mage::helper('paybox')->__('E CARD'),
- self::PBX_CARTE_TYPE_AMEX => Mage::helper('paybox')->__('AMEX'),
- self::PBX_CARTE_TYPE_DINERS => Mage::helper('paybox')->__('DINERS'),
- self::PBX_CARTE_TYPE_JCB => Mage::helper('paybox')->__('JCB'),
- self::PBX_CARTE_TYPE_AURORE => Mage::helper('paybox')->__('AURORE'),
- ),
- self::PBX_PAYMENT_TYPE_SYMPASS => array(
- 'none' => Mage::helper('paybox')->__('Customer Choise'),
- self::PBX_CARTE_TYPE_CB => Mage::helper('paybox')->__('CB'),
- self::PBX_CARTE_TYPE_VISA => Mage::helper('paybox')->__('VISA'),
- self::PBX_CARTE_TYPE_EUROCARDMASTERCARD => Mage::helper('paybox')->__('EUROCARD & MASTERCARD'),
- self::PBX_CARTE_TYPE_ECARD => Mage::helper('paybox')->__('E CARD'),
- self::PBX_CARTE_TYPE_AMEX => Mage::helper('paybox')->__('AMEX'),
- self::PBX_CARTE_TYPE_DINERS => Mage::helper('paybox')->__('DINERS'),
- self::PBX_CARTE_TYPE_JCB => Mage::helper('paybox')->__('JCB'),
- self::PBX_CARTE_TYPE_AURORE => Mage::helper('paybox')->__('AURORE'),
- ),
- self::PBX_PAYMENT_TYPE_PAYNOVA => array(
- self::PBX_CARTE_TYPE_PAYNOVA => Mage::helper('paybox')->__('PAYNOVA'),
- ),
- self::PBX_PAYMENT_TYPE_TERMINEO => array(
- self::PBX_CARTE_TYPE_TERMINEO => Mage::helper('paybox')->__('TERMINEO'),
- ),
- self::PBX_PAYMENT_TYPE_PAYPAL => array(
- self::PBX_CARTE_TYPE_PAYPAL => Mage::helper('paybox')->__('PAYPAL'),
- )
- );
- }
-
- if (!is_null($paymentType)) {
- if (isset($this->_cartTypes[$paymentType])) {
- return $this->_cartTypes[$paymentType];
- }
- }
-
- return $this->_cartTypes;
- }
-
- /**
- * Get cart types by given payment
- *
- * @param string $paymentType
- * @return array
- */
- public function getCartTypesByPayment($paymentType)
- {
- if ($paymentType == '') {
- return array();
- }
- return $this->_getCartTypes($paymentType);
- }
-
- /**
- * Get all cart types in JSON format
- *
- * @return string
- */
- public function getJsonCartTypes()
- {
- return Mage::helper('core')->jsonEncode($this->_getCartTypes());
- }
-
- /**
- * Get payment method
- *
- * @return string
- */
- public function getPaymentMethod()
- {
- return $this->getConfigData('pbx_mode');
- }
-
- /**
- * Get name of executable file
- *
- * @return string
- */
- public function getPayboxFile()
- {
- return $this->getConfigData('pbx_file');
- }
-
- /**
- * Get Payment type
- *
- * @return string
- */
- public function getPaymentType()
- {
- return $this->getConfigData('pbx_typepaiement');
- }
-
- /**
- * Get Payment Action of Paybox System changed to Paybox specification
- *
- * @return string
- */
- public function getPaymentAction()
- {
- $paymentAction = $this->getConfigData('pbx_autoseule');
- switch ($paymentAction) {
- case self::ACTION_AUTHORIZE:
- return self::PBX_PAYMENT_ACTION_ATHORIZE;
- break;
- case self::ACTION_AUTHORIZE_CAPTURE:
- return self::PBX_PAYMENT_ACTION_ATHORIZE_CAPTURE;
- break;
- default:
- return self::PBX_PAYMENT_ACTION_ATHORIZE;
- break;
- }
- }
-
- /**
- * Get cart type
- *
- * @return string
- */
- public function getCartType()
- {
- return $this->getConfigData('pbx_typecarte');
- }
-
- /**
- * Get Site number (TPE)
- *
- * @return string
- */
- public function getSiteNumber()
- {
- return $this->getConfigData('pbx_site');
- }
-
- /**
- * Get Rang number
- *
- * @return string
- */
- public function getRang()
- {
- return $this->getConfigData('pbx_rang');
- }
-
- /**
- * Get Identifiant number
- *
- * @return string
- */
- public function getIdentifiant()
- {
- return $this->getConfigData('pbx_identifiant');
- }
-
- /**
- * Get currency number in ISO4217 format
- *
- * @return string
- */
- public function getCurrencyNumber()
- {
- $currencyCode = $this->getOrder()->getBaseCurrencyCode();
- if (!$this->_currenciesNumbers) {
- $this->_currenciesNumbers = simplexml_load_file(Mage::getBaseDir().'/app/code/core/Mage/Paybox/etc/currency.xml');
- }
- if ($this->_currenciesNumbers->$currencyCode) {
- return (string)$this->_currenciesNumbers->$currencyCode;
- }
- }
-
- /**
- * Get language of interface of payment defined in config
- *
- * @return string
- */
- public function getLanguage()
- {
- return $this->getConfigData('pbx_langue');
- }
-
- /**
- * Get api urls if they defined in config
- *
- * @return unknown
- */
- public function getApiUrls()
- {
- $fielldsArr = array();
- if (($primary = trim($this->getConfigData('pbx_paybox'))) != '') {
- $fielldsArr['PBX_PAYBOX'] = $primary;
- }
-
- if (($backup1 = trim($this->getConfigData('pbx_backup1'))) != '') {
- $fielldsArr['PBX_BACKUP1'] = $backup1;
- }
-
- if (($backup2 = trim($this->getConfigData('pbx_backup2'))) != '') {
- $fielldsArr['PBX_BACKUP2'] = $backup2;
- }
-
- if (($backup3 = trim($this->getConfigData('pbx_backup3'))) != '') {
- $fielldsArr['PBX_BACKUP3'] = $backup3;
- }
-
- return $fielldsArr;
- }
-
- /**
- * Get timeouts for api urls if timeouts diferent from default
- *
- * @return array
- */
- public function getTimeouts()
- {
- $fielldsArr = array();
- if (($timeout = trim($this->getConfigData('pbx_timeout'))) != '') {
- $fielldsArr['PBX_TIMEOUT'] = $timeout;
- }
-
- if (($timeout1 = trim($this->getConfigData('pbx_timeout1'))) != '') {
- $fielldsArr['PBX_TIMEOUT1'] = $timeout1;
- }
-
- if (($timeout2 = trim($this->getConfigData('pbx_timeout2'))) != '') {
- $fielldsArr['PBX_TIMEOUT2'] = $timeout2;
- }
-
- if (($timeout3 = trim($this->getConfigData('pbx_timeout3'))) != '') {
- $fielldsArr['PBX_TIMEOUT3'] = $timeout3;
- }
-
- return $fielldsArr;
- }
-
- /**
- * Get params from config for HTML form mode
- *
- * @return array
- */
- public function getManagementMode()
- {
- $fieldsArr = array();
- if (($text = trim($this->getConfigData('pbx_txt'))) != '') {
- $fieldsArr['PBX_TXT'] = $text;
- }
-
- if (($wait = trim($this->getConfigData('pbx_wait'))) != '') {
- $fieldsArr['PBX_WAIT'] = $wait;
- }
-
- if (($boutpi = trim($this->getConfigData('pbx_boutpi')))) {
- $fieldsArr['PBX_BOUTPI'] = $boutpi;
- }
-
- if (($bkgd = trim($this->getConfigData('pbx_bkgd'))) != '') {
- $fieldsArr['PBX_BKGD'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'payment/paybox/bkgd/' . $bkgd;
- }
-
- $fieldsArr['PBX_OUTPUT'] = $this->getConfigData('pbx_output');
-
- return $fieldsArr;
- }
-
- /**
- * Get ping flag (commandline mode)
- *
- * @return unknown
- */
- public function getPingFlag()
- {
- return $this->getConfigData('pbx_ping');
- }
-
- /**
- * Get ping port (commandline mode)
- *
- * @return string
- */
- public function getPingPort()
- {
- return $this->getConfigData('pbx_port');
- }
-
- /**
- * Get debug flag
- *
- * @return string
- */
- public function getDebugFlag()
- {
- return $this->getConfigData('debug_flag');
- }
-
- public function getOrderPlaceRedirectUrl()
- {
- if ($this->getPaymentMethod() == self::PBX_FORM_HTML_METHOD) {
- return Mage::getUrl('paybox/system/redirect', array('_secure' => true));
- } else {
- return Mage::getUrl('paybox/system/commandline', array('_secure' => true));
- }
- }
-
- /**
- * Building array of params to send
- *
- * @return array
- */
- public function getFormFields()
- {
- $fieldsArr = array();
-
- $fieldsArr = array(
- 'PBX_MODE' => $this->getPaymentMethod(),
- 'PBX_SITE' => $this->getSiteNumber(),//'1999888',
- 'PBX_RANG' => $this->getRang(),//'99',
- 'PBX_IDENTIFIANT' => $this->getIdentifiant(),//'2',
- 'PBX_TOTAL' => ($this->getOrder()->getBaseGrandTotal()*100),
- 'PBX_DEVISE' => $this->getCurrencyNumber(),
- 'PBX_CMD' => $this->getOrder()->getRealOrderId(),
- 'PBX_PORTEUR' => $this->getOrder()->getCustomerEmail(),
- 'PBX_RETOUR' => 'amount:M;ref:R;auto:A;trans:T;error:E',
- 'PBX_EFFECTUE' => Mage::getUrl('paybox/system/success', array('_secure' => true)),
- 'PBX_REFUSE' => Mage::getUrl('paybox/system/refuse', array('_secure' => true)),
- 'PBX_ANNULE' => Mage::getUrl('paybox/system/decline', array('_secure' => true)),
- 'PBX_AUTOSEULE' => $this->getPaymentAction(),
- 'PBX_LANGUE' => $this->getLanguage(),
- 'PBX_ERREUR' => Mage::getUrl('paybox/system/error', array('_secure' => true)),
- 'PBX_TYPEPAIEMENT' => $this->getPaymentType(),
- 'PBX_TYPECARTE' => $this->getCartType(),
- 'PBX_RUF1' => self::PBX_METHOD_CALL,
- );
-
- if (count($apiUrls = $this->getApiUrls())) {
- $fieldsArr = array_merge($fieldsArr, $this->getApiUrls());
- }
- if (count($timeouts = $this->getTimeouts())) {
- $fieldsArr = array_merge($fieldsArr, $this->getTimeouts());
- }
-
- if ($this->getPaymentMethod() == self::PBX_FORM_HTML_METHOD) {
- $fieldsArr = array_merge($fieldsArr, $this->getManagementMode());
- }
-
- if ($this->getPaymentMethod() == self::PBX_COMMAND_LINE_METHOD && $this->getPingFlag()) {
- $tmpFieldsArr['PBX_PING'] = '1';
- if (($pingPort = trim($this->getPingPort())) != '') {
- $tmpFieldsArr['PING_PORT'] = $pingPort;
- }
-
- $fieldsArr = array_merge($fieldsArr, $tmpFieldsArr);
- }
-
- if ($this->getDebugFlag()) {
- $debug = Mage::getModel('paybox/api_debug')
- ->setRealOrderId($this->getOrder()->getRealOrderId())
- ->setRequestBody(print_r($fieldsArr, 1))
- ->save();
- }
-
- return $fieldsArr;
- }
-
- /**
- * Checking response
- *
- * @param array $response
- * @return bool
- */
- public function checkResponse($response)
- {
- if ($this->getDebugFlag()) {
- $debug = Mage::getModel('paybox/api_debug')
- ->load($response['ref'], 'real_order_id')
- ->setResponseBody(print_r($response, 1))
- ->save();
- }
-
- if (isset($response['error'], $response['amount'],
- $response['ref'], $response['trans'])
- ) {
- return true;
- }
- return false;
- }
-
- public function capture(Varien_Object $payment, $amount)
- {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId());
- return $this;
- }
-
- public function authorize(Varien_Object $payment, $amount)
- {
- $payment->setStatus(self::STATUS_APPROVED)
- ->setLastTransId($this->getTransactionId());
-
- return $this;
- }
-
- public function cancel(Varien_Object $payment)
- {
- $payment->setStatus(self::STATUS_DECLINED);
- return $this;
- }
-}
diff --git a/app/code/core/Mage/Paybox/controllers/SystemController.php b/app/code/core/Mage/Paybox/controllers/SystemController.php
deleted file mode 100644
index 7aa6caa2e8..0000000000
--- a/app/code/core/Mage/Paybox/controllers/SystemController.php
+++ /dev/null
@@ -1,364 +0,0 @@
-
- */
-class Mage_Paybox_SystemController extends Mage_Core_Controller_Front_Action
-{
- protected $_payboxResponse = null;
-
- protected $_responseStatus = false;
-
- /**
- * seting response after returning from paybox
- *
- * @param array $response
- * @return object $this
- */
- protected function setPayboxResponse($response)
- {
- if (count($response)) {
- $this->_payboxResponse = $response;
- }
- return $this;
- }
-
- /**
- * Get System Model
- *
- * @return Mage_Paybox_Model_System
- */
- public function getModel()
- {
- return Mage::getSingleton('paybox/system');
- }
-
- /**
- * Get Checkout Singleton
- *
- * @return Mage_Checkout_Model_Session
- */
- public function getCheckout()
- {
- return Mage::getSingleton('checkout/session');
- }
-
- /**
- * Redirect action. Redirect customer to Paybox
- *
- */
- public function redirectAction()
- {
- $session = $this->getCheckout();
- $session->setPayboxQuoteId($session->getQuoteId());
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($session->getLastRealOrderId());
- $order->addStatusToHistory($order->getStatus(), $this->__('Customer was redirected to Paybox'));
- $order->save();
-
- $session->setPayboxOrderId(Mage::helper('core')->encrypt($session->getLastRealOrderId()));
- $session->setPayboxPaymentAction(
- $order->getPayment()->getMethodInstance()->getPaymentAction()
- );
-
- $this->getResponse()->setBody(
- $this->getLayout()
- ->createBlock('paybox/system_redirect')
- ->setOrder($order)
- ->toHtml()
- );
-
- $session->unsQuoteId();
- }
-
- /**
- * Customer returning to this action if payment was successe
- */
- public function successAction()
- {
- $this->setPayboxResponse($this->getRequest()->getParams());
- if ($this->_checkResponse()) {
-
- $order = Mage::getModel('sales/order');
- $order->loadByIncrementId($this->_payboxResponse['ref']);
-
- if (!$order->getId()) {
- Mage::throwException($this->__('There are no order.'));
- }
-
- if (Mage::helper('core')->decrypt($this->getCheckout()->getPayboxOrderId()) != $this->_payboxResponse['ref']) {
- Mage::throwException($this->__('Order is not match.'));
- }
- $this->getCheckout()->unsPayboxOrderId();
-
- if (($order->getBaseGrandTotal()*100) != $this->_payboxResponse['amount']) {
- Mage::throwException($this->__('Amount is not match.'));
- }
-
- if ($this->_payboxResponse['error'] == '00000') {
- $order->addStatusToHistory($order->getStatus(), $this->__('Customer successfully returned from Paybox'));
-
- $redirectTo = 'checkout/onepage/success';
- if ($this->getCheckout()->getPayboxPaymentAction() == Mage_Paybox_Model_System::PBX_PAYMENT_ACTION_ATHORIZE_CAPTURE) {
- $this->getCheckout()->unsPayboxPaymentAction();
- $order->getPayment()
- ->getMethodInstance()
- ->setTransactionId($this->_payboxResponse['trans']);
- if ($this->_createInvoice($order)) {
- $order->addStatusToHistory($order->getStatus(), $this->__('Invoice was create successfully'));
- } else {
- $order->addStatusToHistory($order->getStatus(), $this->__('Cann\'t create invoice'));
- $redirectTo = '*/*/failure';
- }
- }
-
- $session = $this->getCheckout();
- $session->setQuoteId($session->getPayboxQuoteId(true));
- $session->getQuote()->setIsActive(false)->save();
- $session->unsPayboxQuoteId();
- } else {
- $redirectTo = '*/*/failure';
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), $this->__('Customer was rejected by Paybox'));
- }
-
- $order->sendNewOrderEmail();
- $order->save();
-
- $this->_redirect($redirectTo);
- } else {
- $this->norouteAction();
- return;
- }
- }
-
- /**
- * Action when payment was declined by Paybox
- */
- public function refuseAction()
- {
- $this->setPayboxResponse($this->getRequest()->getParams());
- if ($this->_checkResponse()) {
- $this->getCheckout()->unsPayboxQuoteId();
- $this->getCheckout()->setPayboxErrorMessage('Order was canceled by Paybox');
-
- $order = Mage::getModel('sales/order')
- ->loadByIncrementId($this->_payboxResponse['ref']);
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), $this->__('Customer was refuse by Paybox'));
- $order->save();
-
- $this->_redirect('*/*/failure');
- } else {
- $this->norouteAction();
- return;
- }
- }
-
- /**
- * Action when customer cancele payment or press button to back to shop
- */
- public function declineAction()
- {
- $this->setPayboxResponse($this->getRequest()->getParams());
- if ($this->_checkResponse()) {
-
- $order = Mage::getModel('sales/order')
- ->loadByIncrementId($this->_payboxResponse['ref']);
- $order->cancel();
- $order->addStatusToHistory($order->getStatus(), $this->__('Order was canceled by customer'));
- $order->save();
-
- $session = $this->getCheckout();
- $session->setQuoteId($session->getPayboxQuoteId(true));
- $session->getQuote()->setIsActive(false)->save();
- $session->unsPayboxQuoteId();
-
- $this->_redirect('checkout/cart');
- } else {
- $this->norouteAction();
- return;
- }
- }
-
- /**
- * Redirect action. Redirect to Paybox using commandline mode
- *
- */
- public function commandlineAction()
- {
- $session = $this->getCheckout();
- $session->setPayboxQuoteId($session->getQuoteId());
-
- $order = Mage::getModel('sales/order')
- ->loadByIncrementId($this->getCheckout()->getLastRealOrderId());
- $order->addStatusToHistory(
- $order->getStatus(), $this->__('Customer was redirected to Paybox using \'command line\' mode')
- );
- $order->save();
-
- $session->setPayboxOrderId(Mage::helper('core')->encrypt($session->getLastRealOrderId()));
- $session->setPayboxPaymentAction(
- $order->getPayment()->getMethodInstance()->getPaymentAction()
- );
-
- $session->unsQuoteId();
-
- $payment = $order->getPayment()->getMethodInstance();
- $fieldsArr = $payment->getFormFields();
- $paramStr = '';
- foreach ($fieldsArr as $k => $v) {
- $paramStr .= $k.'='.$v.' ';
- }
-
- $paramStr = str_replace(';', '\;', $paramStr);
- $result = shell_exec(Mage::getBaseDir().'/'.$this->getModel()->getPayboxFile().' '.$paramStr);
-
- if (isset($fieldsArr['PBX_PING']) && $fieldsArr['PBX_PING'] == '1') {
- $fieldsArr['PBX_PING'] = '0';
- $fieldsArr['PBX_PAYBOX'] = trim(substr($result, strpos($result, 'http')));
- $paramStr = '';
- foreach ($fieldsArr as $k => $v) {
- $paramStr .= $k.'='.$v.' ';
- }
-
- $paramStr = str_replace(';', '\;', $paramStr);
- $result = shell_exec(Mage::getBaseDir().'/'.$this->getModel()->getPayboxFile().' '.$paramStr);
- }
-
- $this->loadLayout(false);
- $this->getResponse()->setBody($result);
- $this->renderLayout();
- }
-
- /**
- * Error action. If request params to Paybox has mistakes
- *
- */
- public function errorAction()
- {
- if (!$this->getCheckout()->getPayboxQuoteId()) {
- $this->norouteAction();
- return;
- }
-
- $session = $this->getCheckout();
- $session->setQuoteId($session->getPayboxQuoteId(true));
- $session->getQuote()->setIsActive(false)->save();
- $session->unsPayboxQuoteId();
-
- if (!$this->getRequest()->getParam('NUMERR')) {
- $this->norouteAction();
- return;
- }
-
- $this->loadLayout();
-
- $this->getCheckout()
- ->setPayboxErrorNumber(
- $this->getRequest()->getParam('NUMERR')
- );
-
- $this->renderLayout();
- }
-
- /**
- * Failure action.
- * Displaying information if customer was redirecting to cancel or decline actions
- *
- */
- public function failureAction()
- {
- if (!$this->getCheckout()->getPayboxErrorMessage()) {
- $this->norouteAction();
- return;
- }
-
- $this->loadLayout();
- $this->renderLayout();
- }
-
- /**
- * Checking response and Paybox session variables
- *
- * @return unknown
- */
- protected function _checkResponse()
- {
- if (!$this->getCheckout()->getPayboxQuoteId()) {
- $this->norouteAction();
- return;
- }
-
- if (!$this->getCheckout()->getPayboxOrderId()) {
- $this->norouteAction();
- return;
- }
-
- if (!$this->getCheckout()->getPayboxPaymentAction()) {
- $this->norouteAction();
- return;
- }
-
- if (!$this->_payboxResponse) {
- return false;
- }
-
- //check for valid response
- if ($this->getModel()->checkResponse($this->_payboxResponse)) {
- return true;
- }
-
- return true;
- }
-
- /**
- * Creating invoice
- *
- * @param Mage_Sales_Model_Order $order
- * @return bool
- */
- protected function _createInvoice(Mage_Sales_Model_Order $order)
- {
- if ($order->canInvoice()) {
- $invoice = $order->prepareInvoice();
- $invoice->register()->capture();
- Mage::getModel('core/resource_transaction')
- ->addObject($invoice)
- ->addObject($invoice->getOrder())
- ->save();
- return true;
- }
- return false;
- }
-
-}
diff --git a/app/code/core/Mage/Paybox/etc/config.xml b/app/code/core/Mage/Paybox/etc/config.xml
deleted file mode 100644
index 70a6f841dc..0000000000
--- a/app/code/core/Mage/Paybox/etc/config.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
- 0.1.3
-
-
-
-
-
- Mage_Paybox_Model
- paybox_mysql4
-
-
- Mage_Paybox_Model_Mysql4
-
-
-
-
-
-
-
-
-
- Mage_Paybox
- Mage_Paybox_Model_Mysql4_Setup
-
-
-
-
- Mage_Paybox_Block
-
-
-
-
-
- standard
-
- Mage_Paybox
- paybox
-
-
-
-
-
-
-
- Mage_Paybox.csv
-
-
-
-
-
-
-
-
-
-
- Mage_Paybox.csv
-
-
-
-
-
-
-
-
- 1
-
-
-
- authorize
- E
- FRA
- paybox/system
- Paybox System
- processing
- 0
-
-
-
-
-
- authorize
- paybox/direct
- Paybox Direct
- 1
- processing
- AE,VI,MC,DI
- 0
-
-
-
-
diff --git a/app/code/core/Mage/Paybox/etc/currency.xml b/app/code/core/Mage/Paybox/etc/currency.xml
deleted file mode 100644
index 0d6f6fe047..0000000000
--- a/app/code/core/Mage/Paybox/etc/currency.xml
+++ /dev/null
@@ -1,209 +0,0 @@
-
-
-
-
- 971
- 008
- 012
- 840
- 978
- 973
- 951
- 032
- 051
- 533
- 036
- 944
- 044
- 048
- 050
- 052
- 974
- 084
- 952
- 060
- 356
- 064
- 068
- 984
- 977
- 072
- 578
- 986
- 096
- 975
- 108
- 116
- 950
- 124
- 132
- 136
- 152
- 156
- 170
- 174
- 976
- 554
- 188
- 191
- 192
- 203
- 208
- 262
- 214
- 818
- 222
- 232
- 233
- 230
- 238
- 242
- 953
- 270
- 981
- 936
- 292
- 320
- 324
- 328
- 332
- 340
- 344
- 348
- 352
- 360
- 960
- 364
- 368
- 376
- 388
- 392
- 400
- 398
- 404
- 408
- 410
- 414
- 417
- 418
- 428
- 422
- 710
- 426
- 430
- 434
- 756
- 440
- 446
- 807
- 969
- 454
- 458
- 462
- 478
- 480
- 484
- 979
- 498
- 496
- 504
- 943
- 104
- 516
- 524
- 532
- 558
- 566
- 512
- 586
- 590
- 598
- 600
- 604
- 608
- 985
- 634
- 946
- 643
- 646
- 654
- 882
- 678
- 682
- 941
- 690
- 694
- 702
- 703
- 090
- 706
- 144
- 938
- 968
- 748
- 752
- 948
- 947
- 760
- 901
- 972
- 834
- 764
- 776
- 780
- 788
- 949
- 795
- 800
- 980
- 784
- 826
- 998
- 997
- 858
- 940
- 860
- 548
- 937
- 704
- 886
- 894
- 716
- 959
- 955
- 956
- 957
- 958
- 964
- 962
- 961
- Nil
- Nil
- 963
- 999
-
diff --git a/app/code/core/Mage/Paybox/etc/system.xml b/app/code/core/Mage/Paybox/etc/system.xml
deleted file mode 100644
index 50d1f025e1..0000000000
--- a/app/code/core/Mage/Paybox/etc/system.xml
+++ /dev/null
@@ -1,459 +0,0 @@
-
-
-
-
-
-
-
- Paybox System
- text
- 101
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Paybox CGI file
- text
- 5
- 1
- 1
- 0
-
-
- Mode of retrieval of information
- select
- paybox/source_paymentMode
- 10
- 1
- 1
- 0
-
-
- Payment Action
- select
- paybox/source_paymentAction
- 15
- 1
- 1
- 0
-
-
- Site number (TPE)
- obscure
- adminhtml/system_config_backend_encrypted
- 20
- 1
- 1
- 0
-
-
- Rank number
- obscure
- adminhtml/system_config_backend_encrypted
- 30
- 1
- 1
- 0
-
-
- PAYBOX identifier
- obscure
- adminhtml/system_config_backend_encrypted
- 40
- 1
- 1
- 0
-
-
- Management mode of the intermediary page
- Only if you HTML From mode selected
- select
- paybox/source_managementMode
- 50
- 1
- 1
- 0
-
-
- Text on the intermediary page
- Only if you HTML From mode selected
- text
- 60
- 1
- 1
- 0
-
-
- Name of the button on the intermediary page
- Only if you HTML From mode selected
- text
- 70
- 1
- 1
- 0
-
-
- Screen background of the intermediary page
- Only if you HTML From mode selected
- image
- adminhtml/system_config_backend_image
- payment/paybox/bkgd
- payment/paybox/bkgd
- 80
- 1
- 1
- 0
-
-
- Delay in displaying the intermediary page (in msec)
- Only if you HTML From mode selected
- text
- 90
- 1
- 1
- 0
-
-
- Language of the payment page
- select
- paybox/source_language
- 100
- 1
- 1
- 0
-
-
- Payment Type
- select
- paybox/source_paymentType
- 105
- 1
- 1
- 0
-
-
- Cart Type
- select
- paybox/adminhtml_cart_type
- paybox/source_cartType
- 108
- 1
- 1
- 0
-
-
- The URL of the primary payment server
- Specify the URL of the primary payment server if different from default
- text
- 110
- 1
- 1
- 0
-
-
- Timeout for checking
- Time-out (in seconds) to check the avalaibility of the primary payment server (Default 8 seconds)
- text
- 115
- 1
- 1
- 0
-
-
- The URL of the primary backup payment server
- Specify the URL of the primary backup payment server if different from default
- text
- 120
- 1
- 1
- 0
-
-
- Timeout for checking
- Time-out (in seconds) to check the avalaibility of the primary backup payment server (Default 10 seconds)
- text
- 125
- 1
- 1
- 0
-
-
- The URL of the second backup payment server
- Specify the URL of the second backup payment server if different from default
- text
- 130
- 1
- 1
- 0
-
-
- Timeout for checking
- Time-out (in seconds) to check the avalaibility of the second backup payment server (Default 20 seconds)
- text
- 135
- 1
- 1
- 0
-
-
- The URL of the third backup payment server
- Specify the URL of the third backup payment server if different from default
- text
- 140
- 1
- 1
- 0
-
-
- Timeout for checking
- Time-out (in seconds) to check the avalaibility of the third backup payment server (Default 20 seconds)
- text
- 145
- 1
- 1
- 0
-
-
- Ping Flag
- Only with 'Command Line' mode
- select
- adminhtml/system_config_source_yesno
- 160
- 1
- 1
- 0
-
-
- TCP Port
- TCP Port used to check the availability of a payment server if Ping Flag enabled (Default port is 443)
- text
- 170
- 1
- 1
- 0
-
-
- Debug Flag
- select
- adminhtml/system_config_source_yesno
- 300
- 1
- 1
- 0
-
-
- Title
- text
- 310
- 1
- 1
- 1
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 320
- 1
- 1
- 0
-
-
- Sort order
- text
- 500
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 330
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 340
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
-
-
- Paybox Direct
- text
- 101
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Site number (TPE)
- obscure
- adminhtml/system_config_backend_encrypted
- 20
- 1
- 1
- 0
-
-
- Rank number
- obscure
- adminhtml/system_config_backend_encrypted
- 30
- 1
- 1
- 0
-
-
- Activated Key
- obscure
- adminhtml/system_config_backend_encrypted
- 40
- 1
- 1
- 0
-
-
- The URL of the primary payment server
- text
- 50
- 1
- 1
- 0
-
-
- The URL of the backup payment server
- text
- 60
- 1
- 1
- 0
-
-
- Debug Flag
- select
- adminhtml/system_config_source_yesno
- 70
- 1
- 1
- 0
-
-
- Title
- text
- 80
- 1
- 1
- 1
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 90
- 1
- 1
- 0
-
-
- Payment Action
- select
- paybox/source_paymentAction
- 95
- 1
- 1
- 0
-
-
- Credit Card Types
- multiselect
- paybox/source_cctype
- 100
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 110
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 120
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 500
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-install-0.1.0.php b/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-install-0.1.0.php
deleted file mode 100644
index 629c632db7..0000000000
--- a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-install-0.1.0.php
+++ /dev/null
@@ -1,47 +0,0 @@
-startSetup();
-
-$installer->run("
-
-DROP TABLE IF EXISTS `{$this->getTable('paybox/api_debug')}`;
-CREATE TABLE `{$this->getTable('paybox/api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `real_order_id` varchar(50)NOT NULL default '',
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.1-0.1.2.php b/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.1-0.1.2.php
deleted file mode 100644
index bc7dc4b2c2..0000000000
--- a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.1-0.1.2.php
+++ /dev/null
@@ -1,44 +0,0 @@
-startSetup();
-
-$installer->run("
-
-DROP TABLE IF EXISTS `{$this->getTable('paybox/question_number')}`;
-CREATE TABLE `{$this->getTable('paybox/question_number')}` (
- `account_id` int(10) unsigned NOT NULL auto_increment,
- `account_hash` varchar(50) NOT NULL default '',
- `increment_value` int(10) unsigned NOT NULL default 1,
- `reset_date` timestamp NOT NULL default CURRENT_TIMESTAMP,
- PRIMARY KEY (`account_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php
index e790ab4a80..db779dd548 100644
--- a/app/code/core/Mage/Paygate/Model/Authorizenet.php
+++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php
@@ -135,6 +135,8 @@ public function authorize(Varien_Object $payment, $amount)
$payment->setCcApproval($result->getApprovalCode())
->setLastTransId($result->getTransactionId())
+ ->setTransactionId($result->getTransactionId())
+ ->setIsTransactionClosed(0)
->setCcTransId($result->getTransactionId())
->setCcAvsStatus($result->getAvsResultCode())
->setCcCidStatus($result->getCardCodeResponseCode());
@@ -193,10 +195,10 @@ public function capture(Varien_Object $payment, $amount)
*/
public function void(Varien_Object $payment)
{
- if ($payment->getVoidTransactionId()) {
+ if ($payment->getParentTransactionId()) {
$payment->setAnetTransType(self::REQUEST_TYPE_VOID);
$request = $this->_buildRequest($payment);
- $request->setXTransId($payment->getVoidTransactionId());
+ $request->setXTransId($payment->getParentTransactionId());
$result = $this->_postRequest($request);
if ($result->getResponseCode()==self::RESPONSE_CODE_APPROVED) {
$payment->setStatus(self::STATUS_SUCCESS );
diff --git a/app/code/core/Mage/Paygate/Model/Payflow/Pro.php b/app/code/core/Mage/Paygate/Model/Payflow/Pro.php
index 8834294236..1950219049 100644
--- a/app/code/core/Mage/Paygate/Model/Payflow/Pro.php
+++ b/app/code/core/Mage/Paygate/Model/Payflow/Pro.php
@@ -90,6 +90,19 @@ class Mage_Paygate_Model_Payflow_Pro extends Mage_Payment_Model_Method_Cc
*/
protected $_validVoidTransState = array(3,6,9);
+ /**
+ * Centinel cardinal fields map
+ *
+ * @var string
+ */
+ protected $_centinelFieldMap = array(
+ 'centinel_mpivendor' => 'MPIVENDOR3DS',
+ 'centinel_authstatus' => 'AUTHSTATUS3DS',
+ 'centinel_cavv' => 'CAVV',
+ 'centinel_eci' => 'ECI',
+ 'centinel_xid' => 'XID',
+ );
+
public function authorize(Varien_Object $payment, $amount)
{
$error = false;
@@ -99,7 +112,9 @@ public function authorize(Varien_Object $payment, $amount)
$request = $this->_buildRequest($payment);
$result = $this->_postRequest($request);
- $payment->setCcTransId($result->getPnref());
+ $payment->setCcTransId($result->getPnref())
+ ->setTransactionId($result->getPnref())
+ ->setIsTransactionClosed(0);
switch ($result->getResultCode()){
case self::RESPONSE_CODE_APPROVED:
@@ -107,7 +122,8 @@ public function authorize(Varien_Object $payment, $amount)
break;
case self::RESPONSE_CODE_FRAUDSERVICE_FILTER:
- $payment->setFraudFlag(true);
+ $payment->setIsTransactionPending(true);
+ $payment->getTransactionPendingStatus($this->getConfigData('fraud_order_status'));
break;
default:
@@ -129,21 +145,6 @@ public function authorize(Varien_Object $payment, $amount)
return $this;
}
- /**
- * Check capture availability
- * To avoid capture already voided transactions, allow only one capture thus the method
- * cannot make capture partially
- *
- * @return bool
- */
- public function canCapture()
- {
- if ($this->getInfoInstance()->getOrder()->getBaseSubtotalInvoiced() > 0) {
- return false;
- }
- return true;
- }
-
public function capture(Varien_Object $payment, $amount)
{
$error = false;
@@ -170,17 +171,18 @@ public function capture(Varien_Object $payment, $amount)
$payment->setStatus(self::STATUS_APPROVED);
//$payment->setCcTransId($result->getPnref());
$payment->setLastTransId($result->getPnref());
+ $payment->setTransactionId($result->getPnref());
break;
case self::RESPONSE_CODE_FRAUDSERVICE_FILTER:
- $payment->setFraudFlag(true);
+ $payment->setIsTransactionPending(true);
+ $payment->getTransactionPendingStatus($this->getConfigData('fraud_order_status'));
break;
default:
if ($result->getRespmsg()) {
$error = $result->getRespmsg();
- }
- else {
+ } else {
$error = Mage::helper('paygate')->__('Error in capturing the payment');
}
break;
@@ -238,15 +240,16 @@ public function canVoid(Varien_Object $payment)
public function void(Varien_Object $payment)
{
$error = false;
- if($payment->getVoidTransactionId()){
+ if($payment->getParentTransactionId()){
$payment->setTrxtype(self::TRXTYPE_DELAYED_VOID);
- $payment->setTransactionId($payment->getVoidTransactionId());
+ $payment->setTransactionId($payment->getParentTransactionId());
$request=$this->_buildBasicRequest($payment);
$result = $this->_postRequest($request);
if($result->getResultCode()==self::RESPONSE_CODE_APPROVED){
$payment->setStatus(self::STATUS_SUCCESS);
$payment->setCcTransId($result->getPnref());
+ $payment->setTransactionId($result->getPnref());
}else{
$payment->setStatus(self::STATUS_ERROR);
$error = $result->getRespmsg();
@@ -406,6 +409,12 @@ protected function _buildRequest(Varien_Object $payment)
->setRequestId($this->_generateRequestId())
;
+ if ($this->getIsCentinelValidationEnabled()){
+ $params = array();
+ $params = $this->getCentinelValidator()->exportCmpiData($params);
+ $request = Varien_Object_Mapper::accumulateByMap($params, $request, $this->_centinelFieldMap);
+ }
+
if($payment->getAmount()){
$request->setAmt(round($payment->getAmount(),2));
$request->setCurrency($payment->getOrder()->getBaseCurrencyCode());
diff --git a/app/code/core/Mage/Paygate/etc/system.xml b/app/code/core/Mage/Paygate/etc/system.xml
index 95acda0ede..1c6510ef75 100644
--- a/app/code/core/Mage/Paygate/etc/system.xml
+++ b/app/code/core/Mage/Paygate/etc/system.xml
@@ -241,6 +241,36 @@
1
0
+
+ 3D Secure Card Validation
+ select
+ adminhtml/system_config_source_yesno
+ 20
+ 1
+ 1
+ 0
+
+
+ Severe 3D Secure Card Validation
+ Severe Validation Removes Chargeback Liability on Merchant
+ select
+ adminhtml/system_config_source_yesno
+ 25
+ 1
+ 1
+ 0
+ 1
+
+
+ Centinel API URL
+ text
+ adminhtml/system_config_source_yesno
+ 30
+ 1
+ 1
+ 0
+ 1
+
New order status
select
diff --git a/app/code/core/Mage/Payment/Block/Form/Cc.php b/app/code/core/Mage/Payment/Block/Form/Cc.php
index 6736545f76..b994d8885e 100644
--- a/app/code/core/Mage/Payment/Block/Form/Cc.php
+++ b/app/code/core/Mage/Payment/Block/Form/Cc.php
@@ -113,4 +113,47 @@ public function hasVerification()
}
return true;
}
+
+ /*
+ * Whether switch/solo card type available
+ */
+ public function hasSsCardType()
+ {
+ $availableTypes =$this->getMethod()->getConfigData('cctypes');
+ if ($availableTypes && in_array('SS', explode(',', $availableTypes))) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * solo/switch card start year
+ * @return array
+ */
+ public function getSsStartYears()
+ {
+ $years = array();
+ $first = date("Y");
+
+ for ($index=5; $index>=0; $index--) {
+ $year = $first - $index;
+ $years[$year] = $year;
+ }
+ $years = array(0=>$this->__('Year'))+$years;
+ return $years;
+ }
+
+ /**
+ * Render block HTML
+ *
+ * @return string
+ */
+ protected function _toHtml()
+ {
+ Mage::dispatchEvent('payment_form_block_to_html_before', array(
+ 'block' => $this
+ ));
+ return parent::_toHtml();
+ }
}
+
diff --git a/app/code/core/Mage/Payment/Block/Info.php b/app/code/core/Mage/Payment/Block/Info.php
index 8049754797..778e6c091c 100644
--- a/app/code/core/Mage/Payment/Block/Info.php
+++ b/app/code/core/Mage/Payment/Block/Info.php
@@ -30,6 +30,13 @@
*/
class Mage_Payment_Block_Info extends Mage_Core_Block_Template
{
+ /**
+ * Payment rendered specific information
+ *
+ * @var Varien_Object
+ */
+ protected $_paymentSpecificInformation = null;
+
protected function _construct()
{
parent::_construct();
@@ -90,12 +97,12 @@ public function getChildPdfAsArray()
/**
* Get some specific information in format of array($label => $value)
- * (to be extended by descendants)
+ *
* @return array
*/
public function getSpecificInformation()
{
- return array();
+ return $this->_prepareSpecificInformation()->getData();
}
/**
@@ -119,6 +126,51 @@ public function getValueAsArray($value, $escapeHtml = false)
return $value;
}
+ /**
+ * Check whether payment information should show up in secure mode
+ * true => only "public" payment information may be shown
+ * false => full information may be shown
+ *
+ * @return bool
+ */
+ public function getIsSecureMode()
+ {
+ if ($this->hasIsSecureMode()) {
+ return (bool)(int)$this->_getData('is_secure_mode');
+ }
+ if (!$payment = $this->getInfo()) {
+ return true;
+ }
+ if (!$method = $payment->getMethodInstance()) {
+ return true;
+ }
+ return !Mage::app()->getStore($method->getStore())->isAdmin();
+ }
+
+ /**
+ * Prepare information specific to current payment method
+ *
+ * @param Varien_Object|array $transport
+ * @return Varien_Object
+ */
+ protected function _prepareSpecificInformation($transport = null)
+ {
+ if (null === $this->_paymentSpecificInformation) {
+ if (null === $transport) {
+ $transport = new Varien_Object;
+ } elseif (is_array($transport)) {
+ $transport = new Varien_Object($transport);
+ }
+ Mage::dispatchEvent('payment_info_block_prepare_specific_information', array(
+ 'transport' => $transport,
+ 'payment' => $this->getInfo(),
+ 'block' => $this,
+ ));
+ $this->_paymentSpecificInformation = $transport;
+ }
+ return $this->_paymentSpecificInformation;
+ }
+
/**
* Callback for escaping HTML
*
diff --git a/app/code/core/Mage/Payment/Block/Info/Cc.php b/app/code/core/Mage/Payment/Block/Info/Cc.php
index 7f7939c040..348a76dcd2 100644
--- a/app/code/core/Mage/Payment/Block/Info/Cc.php
+++ b/app/code/core/Mage/Payment/Block/Info/Cc.php
@@ -24,18 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-
+/**
+ * Credit card generic payment info
+ */
class Mage_Payment_Block_Info_Cc extends Mage_Payment_Block_Info
{
- /**
- * Init default template for block
- */
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('payment/info/cc.phtml');
- }
-
/**
* Retrieve credit card type name
*
@@ -44,10 +37,11 @@ protected function _construct()
public function getCcTypeName()
{
$types = Mage::getSingleton('payment/config')->getCcTypes();
- if (isset($types[$this->getInfo()->getCcType()])) {
- return $types[$this->getInfo()->getCcType()];
+ $ccType = $this->getInfo()->getCcType();
+ if (isset($types[$ccType])) {
+ return $types[$ccType];
}
- return $this->getInfo()->getCcType();
+ return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType;
}
/**
@@ -76,10 +70,46 @@ public function getCcExpDate()
$date->setMonth($this->getInfo()->getCcExpMonth());
return $date;
}
-
- public function toPdf()
+
+ /**
+ * Prepare credit card related payment info
+ *
+ * @param Varien_Object|array $transport
+ * @return Varien_Object
+ */
+ protected function _prepareSpecificInformation($transport = null)
+ {
+ if (null !== $this->_paymentSpecificInformation) {
+ return $this->_paymentSpecificInformation;
+ }
+ $transport = parent::_prepareSpecificInformation($transport);
+ $data[Mage::helper('payment')->__('Credit Card Type')] = $this->getCcTypeName();
+
+ if ($this->getInfo()->getCcLast4()) {
+ $data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
+ } else {
+ $data[Mage::helper('payment')->__('Credit Card Number')] = Mage::helper('payment')->__('N/A');
+ }
+ if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
+ $data[Mage::helper('payment')->__('Switch/Solo Issue Number')] = $ccSsIssue;
+ }
+ if (!$this->getIsSecureMode()) {
+ if ($year = $this->getInfo()->getCcSsStartYear() && $month = $this->getInfo()->getCcStartMonth()) {
+ $data[Mage::helper('payment')->__('Switch/Solo Start Date')] = $this->_formatCardDate($year, $month);
+ }
+ }
+ return $transport->setData(array_merge($data, $transport->getData()));
+ }
+
+ /**
+ * Format year/month on the credit card
+ *
+ * @param string $year
+ * @param string $month
+ * @return string
+ */
+ protected function _formatCardDate($year, $month)
{
- $this->setTemplate('payment/info/pdf/cc.phtml');
- return $this->toHtml();
+ return sprintf('%s/%s', sprintf('%02d', $month), $year);
}
}
diff --git a/app/code/core/Mage/Payment/Block/Info/Ccsave.php b/app/code/core/Mage/Payment/Block/Info/Ccsave.php
index 5a6762871f..0366a9e3e9 100644
--- a/app/code/core/Mage/Payment/Block/Info/Ccsave.php
+++ b/app/code/core/Mage/Payment/Block/Info/Ccsave.php
@@ -26,17 +26,29 @@
class Mage_Payment_Block_Info_Ccsave extends Mage_Payment_Block_Info_Cc
{
-
- protected function _construct()
- {
- parent::_construct();
- $this->setTemplate('payment/info/ccsave.phtml');
- }
-
- public function toPdf()
+ /**
+ * Show name on card, expiration date and full cc number
+ *
+ * Expiration date and full number will show up only in secure mode (only for admin, not in emails or pdfs)
+ *
+ * @param Varien_Object|array $transport
+ */
+ protected function _prepareSpecificInformation($transport = null)
{
- $this->setTemplate('payment/info/pdf/ccsave.phtml');
- return $this->toHtml();
+ if (null !== $this->_paymentSpecificInformation) {
+ return $this->_paymentSpecificInformation;
+ }
+ $info = $this->getInfo();
+ $transport = new Varien_Object(array(Mage::helper('payment')->__('Name on the Card') => $info->getCcOwner(),));
+ $transport = parent::_prepareSpecificInformation($transport);
+ if (!$this->getIsSecureMode()) {
+ $transport->addData(array(
+ Mage::helper('payment')->__('Expiration Date') => $this->_formatCardDate(
+ $info->getCcExpYear(), $this->getCcExpMonth()
+ ),
+ Mage::helper('payment')->__('Credit Card Number') => $info->getCcNumber(),
+ ));
+ }
+ return $transport;
}
-
}
diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/core/Mage/Payment/Helper/Data.php
index d518f6fa06..3ae300d4b6 100644
--- a/app/code/core/Mage/Payment/Helper/Data.php
+++ b/app/code/core/Mage/Payment/Helper/Data.php
@@ -73,7 +73,7 @@ public function getStoreMethods($store = null, $quote = null)
continue;
}
- $sortOrder = (int)Mage::getStoreConfig($prefix . 'sort_order', $store);
+ $sortOrder = (int)$methodInstance->getConfigData('sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$methodInstance->setStore($store);
$res[] = $methodInstance;
diff --git a/app/code/core/Mage/Payment/Model/Method/Cc.php b/app/code/core/Mage/Payment/Model/Method/Cc.php
index a34cfe533d..9415c955ae 100644
--- a/app/code/core/Mage/Payment/Model/Method/Cc.php
+++ b/app/code/core/Mage/Payment/Model/Method/Cc.php
@@ -49,7 +49,11 @@ public function assignData($data)
->setCcNumber($data->getCcNumber())
->setCcCid($data->getCcCid())
->setCcExpMonth($data->getCcExpMonth())
- ->setCcExpYear($data->getCcExpYear());
+ ->setCcExpYear($data->getCcExpYear())
+ ->setCcSsIssue($data->getCcSsIssue())
+ ->setCcSsStartMonth($data->getCcSsStartMonth())
+ ->setCcSsStartYear($data->getCcSsStartYear())
+ ;
return $this;
}
@@ -95,10 +99,7 @@ public function validate()
$ccType = '';
- if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
- $errorCode = 'ccsave_expiration,ccsave_expiration_yr';
- $errorMsg = $this->_getHelper()->__('Incorrect credit card expiration date');
- }
+
if (in_array($info->getCcType(), $availableTypes)){
if ($this->validateCcNum($ccNumber)
@@ -137,8 +138,8 @@ public function validate()
$errorMsg = $this->_getHelper()->__('Credit card type is not allowed for this payment method');
}
- //validate credit card verification number
- if ($errorMsg === false && $this->hasVerification()) {
+ //validate credit card verification number
+ if ($errorMsg === false && $this->hasVerification() && $ccType != 'SS') {
$verifcationRegEx = $this->getVerificationRegEx();
$regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
if (!$info->getCcCid() || !$regExp || !preg_match($regExp ,$info->getCcCid())){
@@ -151,6 +152,16 @@ public function validate()
//throw Mage::exception('Mage_Payment', $errorMsg, $errorCode);
}
+ if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
+ $errorCode = 'ccsave_expiration,ccsave_expiration_yr';
+ $errorMsg = $this->_getHelper()->__('Incorrect credit card expiration date');
+ }
+
+ //This must be after all validation conditions
+ if ($this->getIsCentinelValidationEnabled()) {
+ $this->getCentinelValidator()->validate($this->getCentinelValidationData());
+ }
+
return $this;
}
@@ -250,4 +261,118 @@ public function isAvailable($quote = null)
return $this->getConfigData('cctypes', ($quote ? $quote->getStoreId() : null))
&& parent::isAvailable($quote);
}
+
+ /**
+ * Whether centinel service is enabled
+ *
+ * @return bool
+ */
+ public function getIsCentinelValidationEnabled()
+ {
+ return false !== Mage::getConfig()->getNode('modules/Mage_Centinel') && 1 == $this->getConfigData('centinel');
+ }
+
+ /**
+ * Instantiate centinel validator model
+ *
+ * @return Mage_Centinel_Model_Service
+ */
+ public function getCentinelValidator()
+ {
+ $validator = Mage::getSingleton('centinel/service');
+ $validator
+ ->setIsModeStrict($this->getConfigData('centinel_is_mode_strict'))
+ ->setCustomApiEndpointUrl($this->getConfigData('centinel_api_url'))
+ ->setStore($this->getStore())
+ ->setIsPlaceOrder($this->_isPlaceOrder());
+ return $validator;
+ }
+
+ /**
+ * Return data for Centinel validation
+ *
+ * @return Varien_Object
+ */
+ public function getCentinelValidationData()
+ {
+ $info = $this->getInfoInstance();
+ $params = new Varien_Object();
+ $params
+ ->setPaymentMethodCode($this->getCode())
+ ->setCardType($info->getCcType())
+ ->setCardNumber($info->getCcNumber())
+ ->setCardExpMonth($info->getCcExpMonth())
+ ->setCardExpYear($info->getCcExpYear())
+ ->setAmount($this->_getAmount())
+ ->setCurrencyCode($this->_getCurrencyCode())
+ ->setOrderNumber($this->_getOrderId());
+ return $params;
+ }
+
+ /**
+ * Order increment ID getter (either real from order or a reserved from quote)
+ *
+ * @return string
+ */
+ private function _getOrderId()
+ {
+ $info = $this->getInfoInstance();
+
+ if ($this->_isPlaceOrder()) {
+ return $info->getOrder()->getIncrementId();
+ } else {
+ if (!$info->getQuote()->getReservedOrderId()) {
+ $info->getQuote()->reserveOrderId();
+ }
+ return $info->getQuote()->getReservedOrderId();
+ }
+ }
+
+ /**
+ * Grand total getter
+ *
+ * @return string
+ */
+ private function _getAmount()
+ {
+ $info = $this->getInfoInstance();
+ if ($this->_isPlaceOrder()) {
+ return (double)$info->getOrder()->getQuoteBaseGrandTotal();
+ } else {
+ return (double)$info->getQuote()->getBaseGrandTotal();
+ }
+ }
+
+ /**
+ * Currency code getter
+ *
+ * @return string
+ */
+ private function _getCurrencyCode()
+ {
+ $info = $this->getInfoInstance();
+
+ if ($this->_isPlaceOrder()) {
+ return $info->getOrder()->getBaseCurrencyCode();
+ } else {
+ return $info->getQuote()->getBaseCurrencyCode();
+ }
+ }
+
+ /**
+ * Whether current operation is order placement
+ *
+ * @return bool
+ */
+ private function _isPlaceOrder()
+ {
+ $info = $this->getInfoInstance();
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
+ return false;
+ } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
+ return true;
+ }
+ }
}
+
+
diff --git a/app/code/core/Mage/Payment/Model/Observer.php b/app/code/core/Mage/Payment/Model/Observer.php
index 98931ee7dc..2efb495a6b 100644
--- a/app/code/core/Mage/Payment/Model/Observer.php
+++ b/app/code/core/Mage/Payment/Model/Observer.php
@@ -55,8 +55,12 @@ public function salesOrderBeforeSave($observer)
$order->getState() === Mage_Sales_Model_Order::STATE_CLOSED ) {
return $this;
}
-
- $order->setForcedCanCreditmemo(true);
+ /**
+ * Allow forced creditmemo just in case if it wasn't defined before
+ */
+ if (!$order->hasForcedCanCreditmemo()) {
+ $order->setForcedCanCreditmemo(true);
+ }
return $this;
}
}
diff --git a/app/code/core/Mage/Payment/etc/adminhtml.xml b/app/code/core/Mage/Payment/etc/adminhtml.xml
index 5116ac29a9..7142ad361d 100644
--- a/app/code/core/Mage/Payment/etc/adminhtml.xml
+++ b/app/code/core/Mage/Payment/etc/adminhtml.xml
@@ -37,6 +37,9 @@
Payment Methods Section
+
+ Payment Services
+
diff --git a/app/code/core/Mage/Payment/etc/config.xml b/app/code/core/Mage/Payment/etc/config.xml
index 256f3c9cf4..bb5c08a641 100644
--- a/app/code/core/Mage/Payment/etc/config.xml
+++ b/app/code/core/Mage/Payment/etc/config.xml
@@ -77,6 +77,11 @@
Discover
30
+
+ SS
+ Maestro/Solo
+ 40
+
OT
Other
diff --git a/app/code/core/Mage/Payment/etc/system.xml b/app/code/core/Mage/Payment/etc/system.xml
index f61dd1d872..423ac1114d 100644
--- a/app/code/core/Mage/Payment/etc/system.xml
+++ b/app/code/core/Mage/Payment/etc/system.xml
@@ -61,6 +61,7 @@
1
1
0
+ 1
New order status
@@ -88,7 +89,7 @@
1
- Credit Card Verification
+ Request Card Security Code
select
adminhtml/system_config_source_yesno
5
@@ -96,6 +97,38 @@
1
0
+
+
+ 3D Secure Card Validation
+ select
+ adminhtml/system_config_source_yesno
+ 20
+ 1
+ 1
+ 0
+
+
+ Severe 3D Secure Card Validation
+ Severe Validation Removes Chargeback Liability on Merchant
+ select
+ adminhtml/system_config_source_yesno
+ 25
+ 1
+ 1
+ 0
+ 1
+
+
+ Centinel API URL
+ text
+ adminhtml/system_config_source_yesno
+ 30
+ 1
+ 1
+ 0
+ 1
+
+
Payment from applicable countries
allowspecific
@@ -113,6 +146,7 @@
1
1
0
+ 1
Minimum Order Total
@@ -193,6 +227,7 @@
1
1
0
+ 1
Make Check payable to
@@ -297,6 +332,7 @@
1
1
0
+ 1
-
-
-
- 0.1.0
-
-
-
-
-
- Mage_Protx_Model
- protx_mysql4
-
-
- Mage_Protx_Model_Mysql4
-
-
-
-
-
-
-
-
- Mage_Protx
-
-
-
-
- Mage_Protx_Block
-
-
-
-
- /protx/standard
-
-
-
- standard
-
- Mage_Protx
- protx
-
-
-
-
-
-
-
- Mage_Protx.csv
-
-
-
-
-
-
-
- protx.xml
-
-
-
-
-
-
-
-
-
- Mage_Protx.csv
-
-
-
-
-
-
-
-
- Payment
- protx/standard
- Protx Standard
- 0
-
-
-
-
diff --git a/app/code/core/Mage/Protx/etc/system.xml b/app/code/core/Mage/Protx/etc/system.xml
deleted file mode 100644
index cc2f007d08..0000000000
--- a/app/code/core/Mage/Protx/etc/system.xml
+++ /dev/null
@@ -1,167 +0,0 @@
-
-
-
-
-
-
-
- Protx Standard
- text
- 101
- 1
- 1
- 1
-
-
- Enabled
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 1
- 0
-
-
- Payment Action
- select
- protx/source_paymentAction
- 2
- 1
- 1
- 0
-
-
- Title
- text
- 3
- 1
- 1
- 1
-
-
- Transaction Description
- Store name will be used if left empty
- text
- 3
- 1
- 1
- 0
-
-
- New order status
- select
- adminhtml/system_config_source_order_status_processing
- 4
- 1
- 1
- 0
-
-
- Vendor name
- text
- 5
- 1
- 1
- 0
-
-
- Vendor encrypted password
- text
- 6
- 1
- 1
- 0
-
-
- Vendor email notification
- select
- adminhtml/system_config_source_yesno
- 7
- 1
- 1
- 0
-
-
- Vendor email
- 'General contact' email will be used if left empty
- text
- 8
- 1
- 1
- 0
-
-
- Mode
- select
- protx/source_modeAction
- 9
- 1
- 1
- 0
-
-
- Debug
- select
- adminhtml/system_config_source_yesno
- 10
- 1
- 1
- 0
-
-
- Payment from applicable countries
- allowspecific
- 50
- adminhtml/system_config_source_payment_allspecificcountries
- 1
- 1
- 0
-
-
- Payment from Specific countries
- multiselect
- 51
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
-
- Sort order
- text
- 100
- 1
- 1
- 0
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Protx/sql/protx_setup/mysql4-install-0.1.0.php b/app/code/core/Mage/Protx/sql/protx_setup/mysql4-install-0.1.0.php
deleted file mode 100644
index 82c748a765..0000000000
--- a/app/code/core/Mage/Protx/sql/protx_setup/mysql4-install-0.1.0.php
+++ /dev/null
@@ -1,46 +0,0 @@
-startSetup();
-
-$installer->run("
-CREATE TABLE `{$this->getTable('protx_api_debug')}` (
- `debug_id` int(10) unsigned NOT NULL auto_increment,
- `transaction_id` varchar(255) NOT NULL default '',
- `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `request_body` text,
- `response_body` text,
- PRIMARY KEY (`debug_id`),
- KEY `debug_at` (`debug_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Reports/Model/Mysql4/Report/Collection.php b/app/code/core/Mage/Reports/Model/Mysql4/Report/Collection.php
index db6cdafaa2..e2853b2849 100644
--- a/app/code/core/Mage/Reports/Model/Mysql4/Report/Collection.php
+++ b/app/code/core/Mage/Reports/Model/Mysql4/Report/Collection.php
@@ -70,14 +70,13 @@ public function getIntervals()
if (!$this->_from && !$this->_to){
return $this->_intervals;
}
- $dateStart = new Zend_Date($this->_from);
- $dateStart2 = new Zend_Date($this->_from);
-
+ $dateStart = new Zend_Date($this->_from);
$dateEnd = new Zend_Date($this->_to);
$t = array();
- while ($dateStart->compare($dateEnd)<=0) {
+ $firstInterval = true;
+ while ($dateStart->compare($dateEnd) <= 0) {
switch ($this->_period) {
case 'day' :
@@ -88,27 +87,44 @@ public function getIntervals()
break;
case 'month':
$t['title'] = $dateStart->toString('MM/yyyy');
- $t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
- $t['end'] = $dateStart->toString('yyyy-MM-'.date('t', $dateStart->getTimestamp()).' 23:59:59');
+ $t['start'] = ($firstInterval) ? $dateStart->toString('yyyy-MM-dd 00:00:00')
+ : $dateStart->toString('yyyy-MM-01 00:00:00');
+
+ $lastInterval = ($dateStart->compareMonth($dateEnd->getMonth()) == 0);
+
+ $t['end'] = ($lastInterval) ? $dateStart->setDay($dateEnd->getDay())
+ ->toString('yyyy-MM-dd 23:59:59')
+ : $dateStart->toString('yyyy-MM-'.date('t', $dateStart->getTimestamp()).' 23:59:59');
+
$dateStart->addMonth(1);
+
+ if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
+ $dateStart->setDay(1);
+ }
+
+ $firstInterval = false;
break;
case 'year':
$t['title'] = $dateStart->toString('yyyy');
- $t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
- $t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
+ $t['start'] = ($firstInterval) ? $dateStart->toString('yyyy-MM-dd 00:00:00')
+ : $dateStart->toString('yyyy-01-01 00:00:00');
+
+ $lastInterval = ($dateStart->compareYear($dateEnd->getYear()) == 0);
+
+ $t['end'] = ($lastInterval) ? $dateStart->setMonth($dateEnd->getMonth())
+ ->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59')
+ : $dateStart->toString('yyyy-12-31 23:59:59');
$dateStart->addYear(1);
+
+ if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
+ $dateStart->setMonth(1)->setDay(1);
+ }
+
+ $firstInterval = false;
break;
}
$this->_intervals[$t['title']] = $t;
}
-
- if ($this->_period != 'day') {
- $titles = array_keys($this->_intervals);
- if (count($titles) > 0) {
- $this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
- $this->_intervals[$titles[count($titles)-1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
- }
- }
}
return $this->_intervals;
}
diff --git a/app/code/core/Mage/Reports/etc/adminhtml.xml b/app/code/core/Mage/Reports/etc/adminhtml.xml
index 293eb3cc33..f368e529af 100644
--- a/app/code/core/Mage/Reports/etc/adminhtml.xml
+++ b/app/code/core/Mage/Reports/etc/adminhtml.xml
@@ -35,7 +35,7 @@
Sales
- Sales Report
+ Sales
adminhtml/report_sales/sales
@@ -47,11 +47,11 @@
adminhtml/report_sales/shipping
- Total invoiced
+ Total Invoiced
adminhtml/report_sales/invoiced
- Total refunded
+ Total Refunded
adminhtml/report_sales/refunded
diff --git a/app/code/core/Mage/Review/Block/Customer/View.php b/app/code/core/Mage/Review/Block/Customer/View.php
index a130c76def..2ad4834ffc 100644
--- a/app/code/core/Mage/Review/Block/Customer/View.php
+++ b/app/code/core/Mage/Review/Block/Customer/View.php
@@ -102,4 +102,14 @@ public function dateFormat($date)
{
return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_LONG);
}
+
+ /**
+ * Check whether current customer is review owner
+ *
+ * @return boolean
+ */
+ public function isReviewOwner()
+ {
+ return ($this->getReviewData()->getCustomerId() == Mage::getSingleton('customer/session')->getCustomerId());
+ }
}
diff --git a/app/code/core/Mage/Review/controllers/CustomerController.php b/app/code/core/Mage/Review/controllers/CustomerController.php
index 63df0b9155..9055583f3e 100644
--- a/app/code/core/Mage/Review/controllers/CustomerController.php
+++ b/app/code/core/Mage/Review/controllers/CustomerController.php
@@ -34,6 +34,19 @@
class Mage_Review_CustomerController extends Mage_Core_Controller_Front_Action
{
+ /**
+ * Action predispatch
+ *
+ * Check customer authentication for some actions
+ */
+ public function preDispatch()
+ {
+ parent::preDispatch();
+ if (!Mage::getSingleton('customer/session')->authenticate($this)) {
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
+ }
+ }
+
public function indexAction()
{
$this->loadLayout();
diff --git a/app/code/core/Mage/Rss/Block/Catalog/Special.php b/app/code/core/Mage/Rss/Block/Catalog/Special.php
index 6d81697abd..3c97bf04e2 100644
--- a/app/code/core/Mage/Rss/Block/Catalog/Special.php
+++ b/app/code/core/Mage/Rss/Block/Catalog/Special.php
@@ -83,7 +83,7 @@ protected function _toHtml()
$specials->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$newurl = Mage::getUrl('rss/catalog/new');
- $title = Mage::helper('rss')->__('%s - Special Discounts', Mage::app()->getStore()->getFrontendName());
+ $title = Mage::helper('rss')->__('%s - Special Products', Mage::app()->getStore()->getFrontendName());
$lang = Mage::getStoreConfig('general/locale/code');
$rssObj = Mage::getModel('rss/rss');
diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Abstract.php
index c627d9e7b3..101970ba90 100644
--- a/app/code/core/Mage/Rule/Model/Condition/Abstract.php
+++ b/app/code/core/Mage/Rule/Model/Condition/Abstract.php
@@ -104,9 +104,8 @@ public function getDefaultOperatorOptions()
'<' => Mage::helper('rule')->__('less than'),
'{}' => Mage::helper('rule')->__('contains'),
'!{}' => Mage::helper('rule')->__('does not contain'),
- '!{}' => Mage::helper('rule')->__('does not contain'),
'()' => Mage::helper('rule')->__('is one of'),
- '!()' => Mage::helper('rule')->__('is not one of'),
+ '!()' => Mage::helper('rule')->__('is not one of')
);
}
return $this->_defaultOperatorOptions;
@@ -533,7 +532,7 @@ public function validateAttribute($validatedValue)
break;
case '<=': case '>':
- if (is_array($validatedValue)) {
+ if (is_array($validatedValue) || is_null($validatedValue)) {
$result = false;
} else {
$result = $validatedValue<=$value;
@@ -541,7 +540,7 @@ public function validateAttribute($validatedValue)
break;
case '>=': case '<':
- if (is_array($validatedValue)) {
+ if (is_array($validatedValue) || is_null($validatedValue)) {
$result = false;
} else {
$result = $validatedValue>=$value;
diff --git a/app/code/core/Mage/Sales/Block/Items/Abstract.php b/app/code/core/Mage/Sales/Block/Items/Abstract.php
index 5c5c05570f..94661b9e99 100644
--- a/app/code/core/Mage/Sales/Block/Items/Abstract.php
+++ b/app/code/core/Mage/Sales/Block/Items/Abstract.php
@@ -104,12 +104,12 @@ protected function _prepareItem(Mage_Core_Block_Abstract $renderer)
}
/**
- * Get item row html
+ * Return product type for quote/order item
*
- * @param Varien_Object $item
- * @return string
+ * @param Varien_Object $item
+ * @return string
*/
- public function getItemHtml(Varien_Object $item)
+ protected function _getItemType(Varien_Object $item)
{
if ($item->getOrderItem()) {
$type = $item->getOrderItem()->getProductType();
@@ -118,6 +118,18 @@ public function getItemHtml(Varien_Object $item)
} else {
$type = $item->getProductType();
}
+ return $type;
+ }
+
+ /**
+ * Get item row html
+ *
+ * @param Varien_Object $item
+ * @return string
+ */
+ public function getItemHtml(Varien_Object $item)
+ {
+ $type = $this->_getItemType($item);
$block = $this->getItemRenderer($type)
->setItem($item);
diff --git a/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php b/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php
index 9097601277..ca42d71c60 100644
--- a/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php
+++ b/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php
@@ -64,8 +64,9 @@ public function getItems()
$order = $this->getLastOrder();
$limit = 5;
if ($order) {
- foreach ($order->getItemsRandomCollection($limit) as $item) {
- if ($item->getProduct()) {
+ $website = Mage::app()->getStore()->getWebsiteId();
+ foreach ($order->getParentItemsRandomCollection($limit) as $item) {
+ if ($item->getProduct() && in_array($website, $item->getProduct()->getWebsiteIds())) {
$items[] = $item;
}
}
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Order.php b/app/code/core/Mage/Sales/Model/Mysql4/Order.php
index e260477bdf..57d628375e 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Order.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Order.php
@@ -78,6 +78,7 @@ public function aggregateProductsByTypes($orderId, $productTypeIds = array(), $i
*/
public function aggregate($from = null, $to = null)
{
+ $writeAdapter = $this->getWriteConnection();
try {
if (!is_null($from)) {
$from = $this->formatDate($from);
@@ -87,7 +88,6 @@ public function aggregate($from = null, $to = null)
}
$tableName = $this->getTable('sales/order_aggregated_created');
- $writeAdapter = $this->getWriteConnection();
$writeAdapter->beginTransaction();
@@ -100,7 +100,7 @@ public function aggregate($from = null, $to = null)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Report/Invoiced.php b/app/code/core/Mage/Sales/Model/Mysql4/Report/Invoiced.php
index f7c80146e9..44fa5f6734 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Report/Invoiced.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Report/Invoiced.php
@@ -81,7 +81,7 @@ protected function _aggregateByInvoiceCreatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order') ), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
@@ -103,17 +103,18 @@ protected function _aggregateByInvoiceCreatedAt($from, $to)
);
$select = $writeAdapter->select()
- ->from(array('soe' => 'sales_order_entity'), $columns)
+ ->from(array('soe' => $this->getTable('sales/order_entity')), $columns)
->where('state <> ?', 'canceled');
- $select->joinInner(array('soei' => $invoiceAttr->getBackend()->getTable()), "`soei`.`entity_id` = `soe`.`entity_id`
+ $select->joinInner(array('soei' => $this->getTable($invoiceAttr->getBackend()->getTable())),
+ "`soei`.`entity_id` = `soe`.`entity_id`
AND `soei`.`attribute_id` = {$invoiceAttr->getAttributeId()}
AND `soei`.`entity_type_id` = `soe`.`entity_type_id`",
array()
);
$select->joinInner(array(
- 'so' => 'sales_order'),
+ 'so' => $this->getTable('sales/order')),
'`soei`.`value` = `so`.`entity_id` AND `so`.base_total_invoiced > 0',
array()
);
@@ -194,7 +195,7 @@ protected function _aggregateByOrderCreatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Report/Refunded.php b/app/code/core/Mage/Sales/Model/Mysql4/Report/Refunded.php
index 4456e7e589..e2eb9684bf 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Report/Refunded.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Report/Refunded.php
@@ -75,7 +75,7 @@ protected function _aggregateByOrderCreatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
@@ -167,7 +167,7 @@ protected function _aggregateByRefundCreatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
@@ -188,18 +188,19 @@ protected function _aggregateByRefundCreatedAt($from, $to)
);
$select = $writeAdapter->select()
- ->from(array('soe' => 'sales_order_entity'), $columns)
+ ->from(array('soe' => $this->getTable('sales/order_entity')), $columns)
->where('state <> ?', 'canceled')
->where('base_total_refunded > 0');
- $select->joinInner(array('soei' => $creditmemoAttr->getBackend()->getTable()), "`soei`.`entity_id` = `soe`.`entity_id`
+ $select->joinInner(array('soei' => $this->getTable($creditmemoAttr->getBackend()->getTable())),
+ "`soei`.`entity_id` = `soe`.`entity_id`
AND `soei`.`attribute_id` = {$creditmemoAttr->getAttributeId()}
AND `soei`.`entity_type_id` = `soe`.`entity_type_id`",
array()
);
$select->joinInner(array(
- 'so' => 'sales_order'),
+ 'so' => $this->getTable('sales/order')),
'`soei`.`value` = `so`.`entity_id`',
array()
);
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Report/Shipping.php b/app/code/core/Mage/Sales/Model/Mysql4/Report/Shipping.php
index af5dbc041f..c5bc12b0f9 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Report/Shipping.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Report/Shipping.php
@@ -75,7 +75,7 @@ protected function _aggregateByOrderCreatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so'=>$this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
@@ -168,7 +168,7 @@ protected function _aggregateByShippingCreatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so'=>$this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
@@ -188,17 +188,17 @@ protected function _aggregateByShippingCreatedAt($from, $to)
$shipmentAttr = $shipment->getAttribute('order_id');
$select = $writeAdapter->select()
- ->from(array('soe' => 'sales_order_entity'), $columns)
+ ->from(array('soe' => $this->getTable('sales/order_entity')), $columns)
->where('state <> ?', 'canceled');
- $select->joinInner(array('soei' => $shipmentAttr->getBackend()->getTable()), "`soei`.`entity_id` = `soe`.`entity_id`
+ $select->joinInner(array('soei' => $this->getTable($shipmentAttr->getBackend()->getTable())), "`soei`.`entity_id` = `soe`.`entity_id`
AND `soei`.`attribute_id` = {$shipmentAttr->getAttributeId()}
AND `soei`.`entity_type_id` = `soe`.`entity_type_id`",
array()
);
- $select->joinInner(array('so' => 'sales_order'),
+ $select->joinInner(array('so' => $this->getTable('sales/order')),
'`soei`.`value` = `so`.`entity_id` AND `so`.base_total_invoiced > 0',
array()
);
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 5c27107dfb..34f97547c1 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Sale/Collection.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Sale/Collection.php
@@ -35,9 +35,19 @@ class Mage_Sales_Model_Mysql4_Sale_Collection extends Varien_Object implements I
*/
protected $_read;
+ /**
+ * Loaded collection items
+ *
+ * @var array
+ */
protected $_items = array();
- protected $_totals = array('lifetime' => 0, 'num_orders' => 0);
+ /**
+ * Totals data
+ *
+ * @var array
+ */
+ protected $_totals = array('lifetime' => 0, 'base_lifetime' => 0, 'base_avgsale' => 0, 'num_orders' => 0);
/**
* Entity attribute
@@ -54,37 +64,95 @@ class Mage_Sales_Model_Mysql4_Sale_Collection extends Varien_Object implements I
protected $_select;
/**
- * Enter description here...
+ * Customer model
*
* @var Mage_Customer_Model_Customer
*/
protected $_customer;
+ /**
+ * Order state value
+ *
+ * @var null|string|array
+ */
+ protected $_orderStateValue = null;
+
+ /**
+ * Order state condition
+ *
+ * @var string
+ */
+ protected $_orderStateCondition = null;
+
+ /**
+ * Set sales order entity and establish read connection
+ *
+ */
public function __construct()
{
$this->_entity = Mage::getModel('sales_entity/order');
$this->_read = $this->_entity->getReadConnection();
}
+ /**
+ * Set filter by customer
+ *
+ * @param Mage_Customer_Model_Customer $customer
+ * @return Mage_Sales_Model_Mysql4_Sale_Collection
+ */
public function setCustomerFilter(Mage_Customer_Model_Customer $customer)
{
$this->_customer = $customer;
return $this;
}
+ /**
+ * Add filter by stores
+ *
+ * @param array $storeIds
+ * @return Mage_Sales_Model_Mysql4_Sale_Collection
+ */
+ public function addStoreFilter($storeIds)
+ {
+ $this->getSelect()->where('store_id IN (?)', $storeIds);
+ return $this;
+ }
+
+ /**
+ * Set filter by order state
+ *
+ * @param string|array $state
+ * @return Mage_Sales_Model_Mysql4_Sale_Collection
+ */
+ public function setOrderStateFilter($state, $exclude = false)
+ {
+ $this->_orderStateCondition = ($exclude) ? 'NOT IN' : 'IN';
+ $this->_orderStateValue = (!is_array($state)) ? array($state) : $state;
+ return $this;
+ }
+
+ /**
+ * Load data
+ *
+ * @param boolean $printQuery
+ * @param boolean $logQuery
+ * @return Mage_Sales_Model_Mysql4_Sale_Collection
+ */
public function load($printQuery = false, $logQuery = false)
{
- $this->_select = $this->_read->select();
- $entityTable= $this->getEntity()->getEntityTable();
- $paidTable = $this->getAttribute('grand_total')->getBackend()->getTable();
- $idField = $this->getEntity()->getIdFieldName();
+ $this->_select = $this->_read->select();
+ $entityTable = $this->getEntity()->getEntityTable();
+ $paidTable = $this->getAttribute('grand_total')->getBackend()->getTable();
+ $idField = $this->getEntity()->getIdFieldName();
$this->getSelect()
->from(array('sales' => $entityTable),
array(
'store_id',
- 'lifetime' => 'sum(sales.base_grand_total)',
- 'avgsale' => 'avg(sales.base_grand_total)',
- 'num_orders'=> 'count(sales.base_grand_total)'
+ 'lifetime' => 'sum(sales.base_grand_total)',
+ 'base_lifetime' => 'sum(sales.base_grand_total * sales.base_to_global_rate)',
+ 'avgsale' => 'avg(sales.base_grand_total)',
+ 'base_avgsale' => 'avg(sales.base_grand_total * sales.base_to_global_rate)',
+ 'num_orders' => 'count(sales.base_grand_total)'
)
)
->where('sales.entity_type_id=?', $this->getEntity()->getTypeId())
@@ -95,6 +163,10 @@ public function load($printQuery = false, $logQuery = false)
->where('sales.customer_id=?', $this->_customer->getId());
}
+ if (!is_null($this->_orderStateValue)) {
+ $this->getSelect()->where('state ' . $this->_orderStateCondition . ' (?)', $this->_orderStateValue);
+ }
+
Mage::dispatchEvent('sales_sale_collection_query_before', array('collection' => $this));
$this->printLogQuery($printQuery, $logQuery);
@@ -112,31 +184,27 @@ public function load($printQuery = false, $logQuery = false)
$this->_items[ $v['store_id'] ] = $obj;
$this->_items[ $v['store_id'] ]->setStoreName($storeName);
+ $this->_items[ $v['store_id'] ]->setWebsiteId(Mage::app()->getStore($obj->getStoreId())->getWebsiteId());
$this->_items[ $v['store_id'] ]->setAvgNormalized($obj->getAvgsale() * $obj->getNumOrders());
foreach ($this->_totals as $key => $value) {
$this->_totals[$key] += $obj->getData($key);
}
}
if ($this->_totals['num_orders']) {
- $this->_totals['avgsale'] = $this->_totals['lifetime'] / $this->_totals['num_orders'];
+ $this->_totals['avgsale'] = $this->_totals['base_lifetime'] / $this->_totals['num_orders'];
}
}
return $this;
}
- public function addStoreFilter($storeIds)
- {
- $this->getSelect()->where('store_id IN (?)', $storeIds);
- return $this;
- }
-
/**
* Print and/or log query
*
* @param boolean $printQuery
* @param boolean $logQuery
- * @return Mage_Sales_Model_Mysql4_Order_Attribute_Collection_Paid
+ * @param mixed $sql
+ * @return Mage_Sales_Model_Mysql4_Sale_Collection
*/
public function printLogQuery($printQuery = false, $logQuery = false, $sql = null) {
if ($printQuery) {
@@ -160,8 +228,9 @@ public function getSelect()
}
/**
- * Enter description here...
+ * Retrieve attribute entity by specified parameter
*
+ * @param int|string|object $attr
* @return Mage_Eav_Model_Entity_Attribute_Abstract
*/
public function getAttribute($attr)
@@ -170,7 +239,7 @@ public function getAttribute($attr)
}
/**
- * Enter description here...
+ * Retrieve currently used entity
*
* @return Mage_Eav_Model_Entity_Abstract
*/
@@ -180,7 +249,7 @@ public function getEntity()
}
/**
- * Enter description here...
+ * Retrieve Iterator instance of items array
*
* @return ArrayIterator
*/
@@ -190,7 +259,7 @@ public function getIterator()
}
/**
- * Enter description here...
+ * Retrieve array of items
*
* @return array
*/
@@ -200,7 +269,7 @@ public function getItems()
}
/**
- * Enter description here...
+ * Retrieve totals data converted into Varien_Object
*
* @return Varien_Object
*/
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Setup.php b/app/code/core/Mage/Sales/Model/Mysql4/Setup.php
index 520fb0629c..00784c5cf5 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Setup.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Setup.php
@@ -582,8 +582,10 @@ public function getDefaultEntities()
'base_amount_ordered' => array('type'=>'decimal'),
'base_amount_authorized' => array('type'=>'decimal'),
'base_amount_paid' => array('type'=>'decimal'),
+ 'base_amount_paid_online' => array('type'=>'decimal'),
'base_amount_canceled' => array('type'=>'decimal'),
'base_amount_refunded' => array('type'=>'decimal'),
+ 'base_amount_refunded_online' => array('type'=>'decimal'),
'base_shipping_amount' => array('type'=>'decimal'),
'base_shipping_captured' => array('type'=>'decimal'),
'base_shipping_refunded' => array('type'=>'decimal'),
diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php
index 5a66f35574..3c1a6cc816 100644
--- a/app/code/core/Mage/Sales/Model/Order.php
+++ b/app/code/core/Mage/Sales/Model/Order.php
@@ -991,13 +991,46 @@ public function getItemsCollection($filterByTypes = array(), $nonChildrenOnly =
return $this->_items;
}
- public function getItemsRandomCollection($limit=1)
+ /**
+ * Get random items collection with related children
+ *
+ * @param int $limit
+ * @return Mage_Sales_Model_Mysql4_Order_Item_Collection
+ */
+ public function getItemsRandomCollection($limit = 1)
+ {
+ return $this->_getItemsRandomCollection($limit);
+ }
+
+ /**
+ * Get random items collection without related children
+ *
+ * @param int $limit
+ * @return Mage_Sales_Model_Mysql4_Order_Item_Collection
+ */
+ public function getParentItemsRandomCollection($limit = 1)
+ {
+ return $this->_getItemsRandomCollection($limit, true);
+ }
+
+ /**
+ * Get random items collection with or without related children
+ *
+ * @param int $limit
+ * @param bool $nonChildrenOnly
+ * @return Mage_Sales_Model_Mysql4_Order_Item_Collection
+ */
+ protected function _getItemsRandomCollection($limit, $nonChildrenOnly = false)
{
$collection = Mage::getModel('sales/order_item')->getCollection()
->setOrderFilter($this->getId())
->setRandomOrder()
->setPageSize($limit);
+ if ($nonChildrenOnly) {
+ $collection->filterByParent();
+ }
+
$products = array();
foreach ($collection as $item) {
$products[] = $item->getProductId();
@@ -1012,6 +1045,7 @@ public function getItemsRandomCollection($limit=1)
foreach ($collection as $item) {
$item->setProduct($productsCollection->getItemById($item->getProductId()));
}
+
return $collection;
}
@@ -1558,9 +1592,10 @@ protected function _checkState()
}
}
/**
- * Order can be closed just in case when we have refunded amount
+ * Order can be closed just in case when we have refunded amount.
+ * In case of "0" grand total order checking ForcedCanCreditmemo flag
*/
- elseif(floatval($this->getTotalRefunded())) {
+ elseif(floatval($this->getTotalRefunded()) || (!$this->getTotalRefunded() && $this->hasForcedCanCreditmemo())) {
if ($this->getState() !== self::STATE_CLOSED) {
$this->_setState(self::STATE_CLOSED, true, '', $userNotification);
}
@@ -1668,7 +1703,7 @@ public function prepareShipment($qtys = array())
if (!$orderItem->isDummy() && !$orderItem->getQtyToShip()) {
continue;
}
- if ($orderItem->isDummy() && !$this->_needToAddDummy($orderItem, $qtys)) {
+ if ($orderItem->isDummy() && !$this->_needToAddDummyForShipment($orderItem, $qtys)) {
continue;
}
$item = $convertor->itemToShipmentItem($orderItem);
@@ -1725,7 +1760,53 @@ protected function _needToAddDummy($item, $qtys = array()) {
return true;
}
} else {
- if (isset($qtys[$child->getId()]) && $qtys[$child->getId()] > 0) {
+ if (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Decides if we need to create dummy shipment item or not
+ * for eaxample we don't need create dummy parent if all
+ * children are not in process
+ *
+ * @param Mage_Sales_Model_Order_Item $item
+ * @param array $qtys
+ * @return bool
+ */
+ protected function _needToAddDummyForShipment($item, $qtys = array()) {
+ if ($item->getHasChildren()) {
+ foreach ($item->getChildrenItems() as $child) {
+ if ($child->getIsVirtual()) {
+ continue;
+ }
+ if (empty($qtys)) {
+ if ($child->getQtyToShip() > 0) {
+ return true;
+ }
+ } else {
+ if (isset($qtys[$child->getId()]) && $qtys[$child->getId()] > 0) {
+ return true;
+ }
+ }
+ }
+ if ($item->isShipSeparately()) {
+ return true;
+ }
+ return false;
+ } else if($item->getParentItem()) {
+ if ($item->getIsVirtual()) {
+ return false;
+ }
+ if (empty($qtys)) {
+ if ($item->getParentItem()->getQtyToShip() > 0) {
+ return true;
+ }
+ } else {
+ if (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) {
return true;
}
}
diff --git a/app/code/core/Mage/Sales/Model/Order/Config.php b/app/code/core/Mage/Sales/Model/Order/Config.php
index 42b9a87f63..920e0bad3a 100644
--- a/app/code/core/Mage/Sales/Model/Order/Config.php
+++ b/app/code/core/Mage/Sales/Model/Order/Config.php
@@ -66,7 +66,8 @@ public function getStateDefaultStatus($state)
$status = $statusNode->getName();
}
$attributes = $statusNode->attributes();
- if (isset($attributes['default'])) {
+ // empty($attributes['default']) is for backwards compatibility
+ if (isset($attributes['default']) && (empty($attributes['default']) || $attributes['default'] == '1')) {
$status = $statusNode->getName();
}
}
diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php
index 43de248b53..c977dcbf23 100644
--- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php
+++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php
@@ -564,6 +564,7 @@ public function sendEmail($notifyCustomer=true, $comment='')
}
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
->setIsSecureMode(true);
+ $paymentBlock->getMethod()->setStore($order->getStore()->getId());
$mailTemplate = Mage::getModel('core/email_template');
diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php
index eefa79021d..13ce7d5ecb 100644
--- a/app/code/core/Mage/Sales/Model/Order/Invoice.php
+++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php
@@ -240,7 +240,9 @@ public function canCancel()
public function capture()
{
$this->getOrder()->getPayment()->capture($this);
- $this->pay();
+ if ($this->getIsPaid()) {
+ $this->pay();
+ }
return $this;
}
@@ -302,7 +304,8 @@ public function void()
*/
public function cancel()
{
- $this->getOrder()->getPayment()->cancelInvoice($this);
+ $order = $this->getOrder();
+ $order->getPayment()->cancelInvoice($this);
foreach ($this->getAllItems() as $item) {
$item->cancel();
}
@@ -310,20 +313,26 @@ public function cancel()
/**
* Unregister order totals only for invoices in state PAID
*/
- if ($this->getState() == self::STATE_PAID) {
- $this->getOrder()->setTotalPaid(
- $this->getOrder()->getTotalPaid()-$this->getGrandTotal()
- );
- $this->getOrder()->setBaseTotalPaid(
- $this->getOrder()->getBaseTotalPaid()-$this->getBaseGrandTotal()
- );
+ $order->setTotalInvoiced($order->getTotalInvoiced() - $this->getGrandTotal());
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() - $this->getBaseGrandTotal());
- $this->getOrder()->setTotalInvoiced(
- $this->getOrder()->getTotalInvoiced()-$this->getGrandTotal()
- );
- $this->getOrder()->setBaseTotalInvoiced(
- $this->getOrder()->getBaseTotalInvoiced()-$this->getBaseGrandTotal()
- );
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() - $this->getSubtotal());
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() - $this->getBaseSubtotal());
+
+ $order->setTaxInvoiced($order->getTaxInvoiced() - $this->getTaxAmount());
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() - $this->getBaseTaxAmount());
+
+ $order->setShippingInvoiced($order->getShippingInvoiced() - $this->getShippingAmount());
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() - $this->getBaseShippingAmount());
+
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() - $this->getDiscountAmount());
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() - $this->getBaseDiscountAmount());
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() - $this->getBaseCost());
+
+
+ if ($this->getState() == self::STATE_PAID) {
+ $this->getOrder()->setTotalPaid($this->getOrder()->getTotalPaid()-$this->getGrandTotal());
+ $this->getOrder()->setBaseTotalPaid($this->getOrder()->getBaseTotalPaid()-$this->getBaseGrandTotal());
}
$this->setState(self::STATE_CANCELED);
$this->getOrder()->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
@@ -454,8 +463,9 @@ public function register()
}
$order = $this->getOrder();
+ $captureCase = $this->getRequestedCaptureCase();
if ($this->canCapture()) {
- if ($captureCase = $this->getRequestedCaptureCase()) {
+ if ($captureCase) {
if ($captureCase == self::CAPTURE_ONLINE) {
$this->capture();
}
@@ -464,8 +474,8 @@ public function register()
$this->pay();
}
}
- }
- elseif(!$order->getPayment()->getMethodInstance()->isGateway()) {
+ } elseif(!$order->getPayment()->getMethodInstance()->isGateway() || $captureCase == self::CAPTURE_OFFLINE) {
+ $this->setCanVoidFlag(false);
$this->pay();
}
@@ -568,6 +578,7 @@ public function sendEmail($notifyCustomer=true, $comment='')
}
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
->setIsSecureMode(true);
+ $paymentBlock->getMethod()->setStore($order->getStore()->getId());
$mailTemplate = Mage::getModel('core/email_template');
diff --git a/app/code/core/Mage/Sales/Model/Order/Payment.php b/app/code/core/Mage/Sales/Model/Order/Payment.php
index 3ffd84cecf..60bf3b3c5a 100644
--- a/app/code/core/Mage/Sales/Model/Order/Payment.php
+++ b/app/code/core/Mage/Sales/Model/Order/Payment.php
@@ -40,14 +40,21 @@ class Mage_Sales_Model_Order_Payment extends Mage_Payment_Model_Info
* Whether can void
* @var string
*/
- private $_canVoidLookup = null;
+ protected $_canVoidLookup = null;
/**
* Transactions registry to spare resource calls
* array(txn_id => sales/order_payment_transaction)
* @var array
*/
- private $_transactionsLookup = array();
+ protected $_transactionsLookup = array();
+
+ /**
+ * Transaction addditional information container
+ *
+ * @var array
+ */
+ protected $_transactionAdditionalInfo = array();
/**
* Initialize resource model
@@ -87,8 +94,12 @@ public function getOrder()
public function canCapture()
{
/**
- * @todo checking amounts
+ * Check Authoriztion transaction state
*/
+ $authTransaction = $this->getAuthorizationTransaction();
+ if ($authTransaction) {
+ return !$authTransaction->getIsClosed();
+ }
return $this->getMethodInstance()->canCapture();
}
@@ -116,14 +127,15 @@ public function canCapturePartial()
public function place()
{
Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
+ $order = $this->getOrder();
- $this->setAmountOrdered($this->getOrder()->getTotalDue());
- $this->setBaseAmountOrdered($this->getOrder()->getBaseTotalDue());
-
- $this->setShippingAmount($this->getOrder()->getShippingAmount());
- $this->setBaseShippingAmount($this->getOrder()->getBaseShippingAmount());
+ $this->setAmountOrdered($order->getTotalDue());
+ $this->setBaseAmountOrdered($order->getBaseTotalDue());
+ $this->setShippingAmount($order->getShippingAmount());
+ $this->setBaseShippingAmount($order->getBaseShippingAmount());
- $methodInstance = $this->getMethodInstance()->setStore($this->getOrder()->getStoreId());
+ $methodInstance = $this->getMethodInstance();
+ $methodInstance->setStore($order->getStoreId());
$orderState = Mage_Sales_Model_Order::STATE_NEW;
$orderStatus= false;
@@ -131,14 +143,11 @@ public function place()
$stateObject = new Varien_Object();
/**
- * validating payment method again
+ * Do order payment validation on payment method level
*/
$methodInstance->validate();
- if ($action = $methodInstance->getConfigPaymentAction()) {
- /**
- * Run action declared for payment method in configuration
- */
-
+ $action = $methodInstance->getConfigPaymentAction();
+ if ($action) {
if ($methodInstance->isInitializeNeeded()) {
/**
* For method initialization we have to use original config value for payment action
@@ -148,12 +157,12 @@ public function place()
$orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
switch ($action) {
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
- $this->setAmountAuthorized($this->getOrder()->getTotalDue());
- $this->_authorize(true, $this->getOrder()->getBaseTotalDue()); // base amount will be set inside
+ $this->_authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
+ $this->setAmountAuthorized($order->getTotalDue());
break;
case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
- $this->setAmountAuthorized($this->getOrder()->getTotalDue());
- $this->setBaseAmountAuthorized($this->getOrder()->getBaseTotalDue());
+ $this->setAmountAuthorized($order->getTotalDue());
+ $this->setBaseAmountAuthorized($order->getBaseTotalDue());
$this->capture(null);
break;
default:
@@ -168,32 +177,29 @@ public function place()
$orderStatus = $stateObject->getStatus();
$orderIsNotified = $stateObject->getIsNotified();
} else {
- /*
- * this flag will set if the order went to as authorization under fraud service for payflowpro
- */
- if ($this->getFraudFlag()) {
- $orderStatus = $methodInstance->getConfigData('fraud_order_status');
- $orderState = Mage_Sales_Model_Order::STATE_HOLDED;
- } else {
- /**
- * Change order status if it specified
- */
- $orderStatus = $methodInstance->getConfigData('order_status');
+ $orderStatus = $methodInstance->getConfigData('order_status');
+ if (!$orderStatus || $order->getIsVirtual()) {
+ $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
}
+ }
+ $isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
+ $message = $order->getCustomerNote();
- if (!$orderStatus || $this->getOrder()->getIsVirtual()) {
- $orderStatus = $this->getOrder()->getConfig()->getStateDefaultStatus($orderState);
+ //add message if order was holded duering authorization or capture
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
+ if ($message) {
+ $order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
}
+ $order->setHoldBeforeState($orderState);
+ $order->setHoldBeforeStatus($orderStatus);
}
-
- // set state and add to order history only if something was changed or there is a message
- $order = $this->getOrder();
- $message = $order->getCustomerNote();
- if ($orderState !== $order->getState() || $orderStatus !== false && $orderStatus !== $order->getStatus() || $message) {
- $order->setState($orderState);
- $order->addStatusToHistory($orderStatus, $message,
- (null !== $orderIsNotified ? $orderIsNotified : $this->getOrder()->getCustomerNoteNotify())
- );
+ // add message to history if order state already declared
+ elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message)) {
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
+ }
+ // set order state
+ elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message) {
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
}
Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
@@ -223,21 +229,43 @@ public function capture($invoice)
$paidWorkaround = (float)$amountToCapture;
}
$this->_isCaptureFinal($paidWorkaround);
- $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE,
- $this->getAuthorizationTransaction()
- );
+ $baseTransaction = false;
+ if ($invoice->getTransactionId()) {
+ $baseTransaction = $this->_lookupTransaction($invoice->getTransactionId());
+ } else {
+ $baseTransaction = $this->getAuthorizationTransaction();
+ }
+ $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $baseTransaction);
Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
- $this->getMethodInstance()->setStore($this->getOrder()->getStoreId())->capture($this, $amountToCapture);
+ $this->getMethodInstance()
+ ->setStore($this->getOrder()->getStoreId())
+ ->capture($this, $amountToCapture);
// update transactions, set order state (order will close itself if required)
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
- $message = $this->_appendTransactionToMessage($transaction,
- Mage::helper('sales')->__('Captured amount of %s online.', $amountToCapture)
- );
- $this->getOrder()->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
+ /**
+ * Check if payment transaction is under pending state.
+ * Gateway can accept peyment transaction but mark it as pending.
+ * We need hold such kind of orders
+ */
+ if ($this->getIsTransactionPending()) {
+ $message = Mage::helper('sales')->__('Amount of %s pending approval on gateway.', $this->_formatPrice($amountToCapture));
+ $message = $this->_prependMessage($message);
+ $message = $this->_appendTransactionToMessage($transaction, $message);
+ $status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
+ $this->getOrder()->setState(Mage_Sales_Model_Order::STATE_HOLDED, $status, $message);
+ $invoice->setIsPaid(false);
+ } else {
+ $this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
+ $message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
+ $message = $this->_prependMessage($message);
+ $message = $this->_appendTransactionToMessage($transaction, $message);
+ $this->getOrder()->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
+ $invoice->setIsPaid(true);
+ }
$this->getMethodInstance()->processInvoice($invoice, $this); // should be deprecated
return $this;
}
@@ -273,13 +301,13 @@ public function registerCaptureNotification($amount)
$order->addRelatedObject($invoice);
$this->setCreatedInvoice($invoice);
} else {
- $this->_updateTotals(array('base_amount_paid' => $amount));
+ $this->_updateTotals(array('base_amount_paid_online' => $amount));
// shipping captured amount should be updated with the invoice
}
// update transactions, set order state (order will close itself later if required)
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice);
- $message = Mage::helper('sales')->__('Registered notification about captured amount of %s.', $this->_formatAmount($amount));
+ $message = Mage::helper('sales')->__('Registered notification about captured amount of %s.', $this->_formatPrice($amount));
$message = $this->_prependMessage($message);
$message = $this->_appendTransactionToMessage($transaction, $message);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
@@ -448,18 +476,20 @@ public function refund($creditmemo)
$this->_updateTotals(array(
'amount_refunded' => $creditmemo->getGrandTotal(),
'base_amount_refunded' => $baseAmountToRefund,
+ 'base_amount_refunded_online' => $isOnline ? $baseAmountToRefund : null,
'shipping_refunded' => $creditmemo->getShippingAmount(),
- 'base_shipping_refunded' => $creditmemo->getBaseShippingAmount()
+ 'base_shipping_refunded' => $creditmemo->getBaseShippingAmount(),
));
// update transactions and order state
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, $creditmemo, $isOnline);
if ($invoice) {
- $message = Mage::helper('sales')->__('Refunded amount of %s online.', $baseAmountToRefund);
+ $message = Mage::helper('sales')->__('Refunded amount of %s online.', $this->_formatPrice($baseAmountToRefund));
} else {
$message = $this->hasMessage() ? $this->getMessage()
- : Mage::helper('sales')->__('Refunded amount of %s offline.', $baseAmountToRefund);
+ : Mage::helper('sales')->__('Refunded amount of %s offline.', $this->_formatPrice($baseAmountToRefund));
}
+ $message = $message = $this->_prependMessage($message);
$message = $this->_appendTransactionToMessage($transaction, $message);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
@@ -500,12 +530,12 @@ public function registerRefundNotification($amount)
$this->setCreatedCreditmemo($creditmemo);
*/
}
- $this->_updateTotals(array('base_amount_refunded' => $amount));
+ $this->_updateTotals(array('base_amount_refunded_online' => $amount));
// update transactions and order state
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, $creditmemo);
$message = $this->_prependMessage(
- Mage::helper('sales')->__('Registered notification about refunded amount of %s.', $this->_formatAmount($amount))
+ Mage::helper('sales')->__('Registered notification about refunded amount of %s.', $this->_formatPrice($amount))
);
$message = $this->_appendTransactionToMessage($transaction, $message);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
@@ -573,19 +603,29 @@ protected function _authorize($isOnline, $amount)
$this->setBaseAmountAuthorized($amount);
// do authorization
- $order = $this->getOrder();
+ $order = $this->getOrder();
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
+ $status = true;
if ($isOnline) {
- $this->getMethodInstance()->setStore($order->getStoreId())->authorize($this, $amount);
- $message = Mage::helper('sales')->__('Authorized amount of %s.', $amount);
+ $this->getMethodInstance()
+ ->setStore($order->getStoreId())
+ ->authorize($this, $amount);
+ if ($this->getIsTransactionPending()) {
+ $status = $this->getTransactionPendingStatus() ? $this->getTransactionPendingStatus() : true;
+ $state = Mage_Sales_Model_Order::STATE_HOLDED;
+ $message = Mage::helper('sales')->__('Authorization amount %s pending approval on gateway.', $this->_formatPrice($amount));
+ } else {
+ $message = Mage::helper('sales')->__('Authorized amount of %s.', $this->_formatPrice($amount));
+ }
} else {
- $message = Mage::helper('sales')->__('Registered notification about authorized amount of %s.', $amount);
+ $message = Mage::helper('sales')->__('Registered notification about authorized amount of %s.', $this->_formatPrice($amount));
}
// update transactions, order state and add comments
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
$message = $this->_prependMessage($message);
$message = $this->_appendTransactionToMessage($transaction, $message);
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
+ $order->setState($state, $status, $message);
return $this;
}
@@ -615,7 +655,7 @@ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')
$this->_avoidDoubleTransactionProcessing();
}
- // if the authorization was untouched, we may update canceled amount of the order grand total
+ // if the authorization was untouched, we may assume voided amount = order grand total
// but only if the payment auth amount equals to order grand total
if ($authTransaction && ($order->getBaseGrandTotal() == $this->getBaseAmountAuthorized())
&& (0 == $this->getBaseAmountCanceled())) {
@@ -625,7 +665,6 @@ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')
}
if ($amount) {
- $this->_updateTotals(array('base_amount_canceled' => $amount));
$amount = $this->_formatAmount($amount);
}
@@ -634,7 +673,7 @@ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')
$message = $this->hasMessage() ? $this->getMessage() : Mage::helper('sales')->__('Voided authorization.');
$message = $this->_prependMessage($message);
if ($amount) {
- $message .= ' ' . Mage::helper('sales')->__('Amount: %s.', $amount);
+ $message .= ' ' . Mage::helper('sales')->__('Amount: %s.', $this->_formatPrice($amount));
}
$message = $this->_appendTransactionToMessage($transaction, $message);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
@@ -686,6 +725,13 @@ protected function _addTransaction($type, $salesDocument = null, $failsafe = fal
$transaction->setIsClosed((int)$this->getIsTransactionClosed());
}
+ //set transaction addition information
+ if ($this->_transactionAdditionalInfo) {
+ foreach ($this->_transactionAdditionalInfo as $key => $value) {
+ $transaction->setAdditionalInformation($key, $value);
+ }
+ }
+
// link with sales entities
$this->setLastTransId($transactionId);
$this->setCreatedTransaction($transaction);
@@ -697,11 +743,12 @@ protected function _addTransaction($type, $salesDocument = null, $failsafe = fal
// link with parent transaction
$parentTransactionId = $this->getParentTransactionId();
+
if ($parentTransactionId) {
$transaction->setParentTxnId($parentTransactionId);
if ($this->getShouldCloseParentTransaction()) {
$parentTransaction = $this->_lookupTransaction($parentTransactionId);
- if ($parentTransaction) {
+ if ($parentTransaction) {
$parentTransaction->isFailsafe($failsafe)->close(false);
$this->getOrder()->addRelatedObject($parentTransaction);
}
@@ -802,6 +849,16 @@ protected function _formatAmount($amount, $asFloat = false)
return $asFloat ? (float)$amount : $amount;
}
+ /**
+ * Format price with currency sign
+ * @param float $amount
+ * @return string
+ */
+ protected function _formatPrice($amount)
+ {
+ return $this->getOrder()->getBaseCurrency()->formatTxt($amount);
+ }
+
/**
* Find one transaction by ID or type
* @param string $txnId
@@ -850,6 +907,15 @@ public function getAuthorizationTransaction()
return $txn;
}
+ /**
+ * Lookup an transaction by id
+ * @return Mage_Sales_Model_Order_Payment_Transaction|false
+ */
+ public function getTransaction($transaction_id)
+ {
+ return $this->_lookupTransaction($transaction_id);
+ }
+
/**
* Update transaction ids for further processing
* If no transactions were set before invoking, may generate an "offline" transaction id
@@ -876,7 +942,7 @@ protected function _generateTransactionId($type, $transactionBasedOn = false)
protected function _isCaptureFinal($amountToCapture)
{
if ((float)$this->getOrder()->getBaseGrandTotal() ===
- ((float)$this->getBaseAmountPaid() + $amountToCapture)) {
+ ((float)$this->getBaseAmountPaidOnline() + $amountToCapture)) {
if (false !== $this->getShouldCloseParentTransaction()) {
$this->setShouldCloseParentTransaction(true);
}
@@ -884,4 +950,15 @@ protected function _isCaptureFinal($amountToCapture)
}
return false;
}
+
+ /**
+ * Additionnal transaction info setter
+ *
+ * @param sting $key
+ * @param string $value
+ */
+ public function setTransactionAdditionalInfo($key, $value)
+ {
+ $this->_transactionAdditionalInfo[$key] = $value;
+ }
}
diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php
index 6e32fc0125..80d8f8c231 100644
--- a/app/code/core/Mage/Sales/Model/Quote.php
+++ b/app/code/core/Mage/Sales/Model/Quote.php
@@ -960,7 +960,7 @@ public function collectTotals()
/**
* Get all quote totals (sorted by priority)
- * Metchod process quote states isVirtual and isMultiShipping
+ * Method process quote states isVirtual and isMultiShipping
*
* @return array
*/
diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php
index a63829a194..47fccedca5 100644
--- a/app/code/core/Mage/Sales/Model/Quote/Address.php
+++ b/app/code/core/Mage/Sales/Model/Quote/Address.php
@@ -601,10 +601,7 @@ public function collectShippingRates()
$this->removeAllShippingRates();
- $countryId = $this->getCountryId();
- $postCode = $this->getPostcode();
- if ((!$countryId && !$postCode)
- || ($countryId && !$postCode && !Mage::helper('directory')->isZipCodeOptional($countryId))) {
+ if (!$this->getCountryId()) {
return $this;
}
diff --git a/app/code/core/Mage/Sales/etc/config.xml b/app/code/core/Mage/Sales/etc/config.xml
index 4e835d7f60..ee468d8396 100644
--- a/app/code/core/Mage/Sales/etc/config.xml
+++ b/app/code/core/Mage/Sales/etc/config.xml
@@ -28,7 +28,7 @@
- 0.9.54
+ 0.9.56
@@ -91,6 +91,8 @@
*
*
+ quote_base_grand_total
+
*
*
*
@@ -554,48 +556,48 @@
New
-
+
Pending Payment
-
+
Processing
-
+
Complete
-
+
Closed
-
+
Canceled
-
+
On Hold
-
+
@@ -896,7 +898,7 @@
0 0 * * *
sales/observer::cleanExpiredQuotes
-
+
0 0 * * *
sales/observer::aggregateSalesReportOrderData
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.8-0.8.9.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.8-0.8.9.php
index a3c3dcc2c3..0054b4bc6b 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.8-0.8.9.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.8.8-0.8.9.php
@@ -50,12 +50,14 @@
$installer->getConnection()->dropColumn($this->getTable('sales_quote_temp_text'), 'store_id');
$installer->getConnection()->dropColumn($this->getTable('sales_quote_temp_varchar'), 'store_id');
-$installer->run("
-ALTER TABLE {$this->getTable('sales_order_entity')}
- ADD CONSTRAINT `FK_SALE_ORDER_ENTITY_STORE` FOREIGN KEY `FK_SALE_ORDER_ENTITY_STORE` (`store_id`)
- REFERENCES {$this->getTable('core_store')} (`store_id`)
- ON DELETE SET NULL
- ON UPDATE CASCADE;
-");
+$installer->getConnection()->addConstraint(
+ 'SALE_ORDER_ENTITY_STORE',
+ $this->getTable('sales_order_entity'),
+ 'store_id',
+ $this->getTable('core_store'),
+ 'store_id',
+ 'SET NULL'
+);
+
$installer->installEntities();
$installer->endSetup();
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.45-0.9.46.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.45-0.9.46.php
index a65044baca..e24dd4c862 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.45-0.9.46.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.45-0.9.46.php
@@ -93,11 +93,20 @@
`base_invoiced_amount` decimal(12,4) NOT NULL DEFAULT '0',
`base_refunded_amount` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_ORDER_AGGREGATED_CREATED_PSS` (`period`,`store_id`, `order_status`),
- KEY `FK_ORDER_AGGREGATED_CREATED_STORE` (`store_id`),
- CONSTRAINT `FK_ORDER_AGGREGATED_CREATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_PERIOD_STORE_ORDER_STATUS` (`period`,`store_id`, `order_status`),
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
+$installer->getConnection()->addConstraint(
+ 'SALES_ORDER_AGGREGATED_CREATED',
+ $installer->getTable('sales/order_aggregated_created'),
+ 'store_id',
+ $installer->getTable('core/store'),
+ 'store_id',
+ 'SET NULL'
+);
+
+
$this->endSetup();
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.46-0.9.47.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.46-0.9.47.php
index d30ad10a7b..774f236698 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.46-0.9.47.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.46-0.9.47.php
@@ -76,7 +76,7 @@
}
$installer->run("
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('sales/shipping_aggregated')}`
+ CREATE TABLE `{$installer->getTable('sales/shipping_aggregated')}`
(
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
@@ -86,13 +86,11 @@
`orders_count` int(11) NOT NULL DEFAULT '0',
`total_shipping` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_SHIPPING_AGGREGATED_CREATED_PSSC` (`period`,`store_id`, `order_status`, `shipping_description`),
- KEY `FK_SHIPPING_AGGREGATED_CREATED_STORE` (`store_id`),
- CONSTRAINT `FK_SHIPPING_AGGREGATED_CREATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_PERIOD_STORE_ORDER_STATUS` (`period`,`store_id`, `order_status`, `shipping_description`),
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('sales/shipping_aggregated_order')}`
+ CREATE TABLE `{$installer->getTable('sales/shipping_aggregated_order')}`
(
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
@@ -102,12 +100,28 @@
`orders_count` int(11) NOT NULL DEFAULT '0',
`total_shipping` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_SHIPPING_AGGREGATED_UPDATED_PSSC` (`period`,`store_id`, `order_status`, `shipping_description`),
- KEY `FK_SHIPPING_AGGREGATED_UPDATED_STORE` (`store_id`),
- CONSTRAINT `FK_SHIPPING_AGGREGATED_UPDATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_PERIOD_STORE_ORDER_STATUS` (`period`,`store_id`, `order_status`, `shipping_description`),
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
+$installer->getConnection()->addConstraint(
+ 'SALES_SHIPPING_AGGREGATED_STORE',
+ $installer->getTable('sales/shipping_aggregated'),
+ 'store_id',
+ $installer->getTable('core/store'),
+ 'store_id',
+ 'SET NULL'
+);
+
+$installer->getConnection()->addConstraint(
+ 'SALES_SHIPPING_AGGREGATED_ORDER_STORE',
+ $installer->getTable('sales/shipping_aggregated_order'),
+ 'store_id',
+ $installer->getTable('core/store'),
+ 'store_id',
+ 'SET NULL'
+);
+
$this->endSetup();
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.47-0.9.48.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.47-0.9.48.php
index afa315a482..501d2dc11c 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.47-0.9.48.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.47-0.9.48.php
@@ -31,7 +31,7 @@
$this->startSetup();
$installer->run("
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('sales/invoiced_aggregated')}`
+ CREATE TABLE `{$installer->getTable('sales/invoiced_aggregated')}`
(
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
@@ -43,13 +43,11 @@
`invoiced_captured` decimal(12,4) NOT NULL DEFAULT '0',
`invoiced_not_captured` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_INVOICED_AGGREGATED_CREATED_PSS` (`period`,`store_id`, `order_status`),
- KEY `FK_INVOICED_AGGREGATED_CREATED_STORE` (`store_id`),
- CONSTRAINT `FK_INVOICED_AGGREGATED_CREATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_PERIOD_STORE_ORDER_STATUS` (`period`,`store_id`, `order_status`),
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('sales/invoiced_aggregated_order')}`
+ CREATE TABLE `{$installer->getTable('sales/invoiced_aggregated_order')}`
(
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
@@ -61,12 +59,29 @@
`invoiced_captured` decimal(12,4) NOT NULL DEFAULT '0',
`invoiced_not_captured` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_INVOICED_AGGREGATED_UPDATED_PSS` (`period`,`store_id`, `order_status`),
- KEY `FK_INVOICED_AGGREGATED_UPDATED_STORE` (`store_id`),
- CONSTRAINT `FK_INVOICED_AGGREGATED_UPDATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_PERIOD_STORE_ORDER_STATUS` (`period`,`store_id`, `order_status`),
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
+
+$installer->getConnection()->addConstraint(
+ 'SALES_INVOICED_AGGREGATED_STORE',
+ $installer->getTable('sales/invoiced_aggregated'),
+ 'store_id',
+ $installer->getTable('core/store'),
+ 'store_id',
+ 'SET NULL'
+);
+
+$installer->getConnection()->addConstraint(
+ 'SALES_INVOICED_AGGREGATED_ORDER_STORE',
+ $installer->getTable('sales/invoiced_aggregated_order'),
+ 'store_id',
+ $installer->getTable('core/store'),
+ 'store_id',
+ 'SET NULL'
+);
+
$this->endSetup();
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.48-0.9.49.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.48-0.9.49.php
index 5fd3caf6f6..3412c27a33 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.48-0.9.49.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.48-0.9.49.php
@@ -31,8 +31,7 @@
$this->startSetup();
$installer->run("
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('sales/refunded_aggregated')}`
- (
+ CREATE TABLE `{$installer->getTable('sales/refunded_aggregated')}` (
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
`store_id` smallint(5) unsigned NULL DEFAULT NULL,
@@ -42,14 +41,11 @@
`online_refunded` decimal(12,4) NOT NULL DEFAULT '0',
`offline_refunded` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_REFUNDED_AGGREGATED_CREATED_PSS` (`period`,`store_id`, `order_status`),
- KEY `FK_REFUNDED_AGGREGATED_CREATED_STORE` (`store_id`),
- CONSTRAINT `FK_REFUNDED_AGGREGATED_CREATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_PERIOD_STORE_ORDER_STATUS` (`period`,`store_id`, `order_status`),
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('sales/refunded_aggregated_order')}`
- (
+ CREATE TABLE `{$installer->getTable('sales/refunded_aggregated_order')}` (
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
`store_id` smallint(5) unsigned NULL DEFAULT NULL,
@@ -59,12 +55,29 @@
`online_refunded` decimal(12,4) NOT NULL DEFAULT '0',
`offline_refunded` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_REFUNDED_AGGREGATED_UPDATED_PSS` (`period`,`store_id`, `order_status`),
- KEY `FK_REFUNDED_AGGREGATED_UPDATED_STORE` (`store_id`),
- CONSTRAINT `FK_REFUNDED_AGGREGATED_UPDATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_PERIOD_STORE_ORDER_STATUS` (`period`,`store_id`, `order_status`),
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
+
+$installer->getConnection()->addConstraint(
+ 'SALES_REFUNDED_AGGREGATED_STORE',
+ $installer->getTable('sales/refunded_aggregated'),
+ 'store_id',
+ $installer->getTable('core/store'),
+ 'store_id',
+ 'SET NULL'
+);
+
+$installer->getConnection()->addConstraint(
+ 'SALES_REFUNDED_AGGREGATED_ORDER_STORE',
+ $installer->getTable('sales/refunded_aggregated_order'),
+ 'store_id',
+ $installer->getTable('core/store'),
+ 'store_id',
+ 'SET NULL'
+);
+
$this->endSetup();
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.49-0.9.50.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.49-0.9.50.php
index b4c54da2e9..d9c1b8f555 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.49-0.9.50.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.49-0.9.50.php
@@ -44,11 +44,33 @@
`is_closed` tinyint(1) unsigned NOT NULL DEFAULT '1',
`additional_information` blob,
PRIMARY KEY (`transaction_id`),
- UNIQUE KEY `UNQ_SALES_TXN_ORDER_PAYMENT_TXN` (`order_id`,`payment_id`,`txn_id`),
- KEY `FK_SALES_TXN_PARENT` (`parent_id`),
- KEY `FK_SALES_TXN_PAYMENT` (`payment_id`),
- CONSTRAINT `FK_SALES_PAYMENT_TXN_PARENT` FOREIGN KEY (`parent_id`) REFERENCES `{$tablePaymentTransaction}` (`transaction_id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `FK_SALES_TXN_ORDER` FOREIGN KEY (`order_id`) REFERENCES `{$tableOrders}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `FK_SALES_TXN_PAYMENT` FOREIGN KEY (`payment_id`) REFERENCES `{$tableOrderPayment}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
+ UNIQUE KEY `UNQ_ORDER_PAYMENT_TXN` (`order_id`,`payment_id`,`txn_id`),
+ KEY `IDX_ORDER_ID` (`order_id`),
+ KEY `IDX_PARENT_ID` (`parent_id`),
+ KEY `IDX_PAYMENT_ID` (`payment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
);
+
+$installer->getConnection()->addConstraint(
+ 'SALES_PAYMENT_TRANSACTION_PARENT',
+ $tablePaymentTransaction,
+ 'parent_id',
+ $tablePaymentTransaction,
+ 'transaction_id'
+);
+
+$installer->getConnection()->addConstraint(
+ 'SALES_PAYMENT_TRANSACTION_ORDER',
+ $tablePaymentTransaction,
+ 'order_id',
+ $tableOrders,
+ 'entity_id'
+);
+
+$installer->getConnection()->addConstraint(
+ 'SALES_PAYMENT_TRANSACTION_PAYMENT',
+ $tablePaymentTransaction,
+ 'payment_id',
+ $tableOrderPayment,
+ 'entity_id'
+);
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.5-0.9.6.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.5-0.9.6.php
index 5d378e814d..9c52eb1f78 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.5-0.9.6.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.5-0.9.6.php
@@ -28,9 +28,15 @@
/* @var $installer Mage_Sales_Model_Mysql4_Setup */
$installer->run("
-ALTER TABLE `{$installer->getTable('sales_flat_quote_address_item')}` ADD COLUMN `parent_item_id` INTEGER UNSIGNED AFTER `address_item_id`,
- ADD CONSTRAINT `FK_SALES_FLAT_QUOTE_ADDRESS_ITEM_PARENT` FOREIGN KEY `FK_SALES_FLAT_QUOTE_ADDRESS_ITEM_PARENT` (`parent_item_id`)
- REFERENCES `{$installer->getTable('sales_flat_quote_address_item')}` (`address_item_id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE;
+ALTER TABLE `{$installer->getTable('sales_flat_quote_address_item')}`
+ ADD COLUMN `parent_item_id` INTEGER UNSIGNED AFTER `address_item_id`,
+ ADD KEY `IDX_PARENT_ITEM_ID` (`parent_item_id`);
");
+
+$installer->getConnection()->addConstraint(
+ 'SALES_FLAT_QUOTE_ADDRESS_ITEM_PARENT',
+ $installer->getTable('sales_flat_quote_address_item'),
+ 'parent_item_id',
+ $installer->getTable('sales_flat_quote_address_item'),
+ 'address_item_id'
+);
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.3-0.8.4.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.54-0.9.55.php
similarity index 77%
rename from app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.3-0.8.4.php
rename to app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.54-0.9.55.php
index a27426d3b0..e63b492a99 100644
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.3-0.8.4.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.54-0.9.55.php
@@ -19,18 +19,14 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Oscommerce
+ * @package Mage_Sales
* @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)
*/
$installer = $this;
-/* @var $installer Mage_Core_Model_Resource_Setup */
+/* @var $installer Mage_Sales_Model_Mysql4_Setup */
-$installer->startSetup();
+$installer->addAttribute('order_payment', 'base_amount_paid_online', array('type' => 'decimal'));
+$installer->addAttribute('order_payment', 'base_amount_refunded_online', array('type' => 'decimal'));
-$installer->run("
- ALTER TABLE `{$this->getTable('oscommerce_orders')}` ADD orders_total decimal(14,6) default NULL;
-");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.0-0.1.1.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.55-0.9.56.php
similarity index 86%
rename from app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.0-0.1.1.php
rename to app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.55-0.9.56.php
index afc0cfdc1d..012fad1af2 100644
--- a/app/code/core/Mage/Paybox/sql/paybox_setup/mysql4-upgrade-0.1.0-0.1.1.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.55-0.9.56.php
@@ -19,15 +19,14 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Paybox
+ * @package Mage_Sales
* @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)
*/
+
$installer = $this;
-/* @var $installer Mage_Sales_Model_Entity_Setup */
+/* @var $installer Mage_Sales_Model_Mysql4_Setup */
$installer->startSetup();
-
-$installer->addAttribute('order_payment', 'paybox_request_number', array());
-
+$installer->updateAttribute('order', 'customer_dob', 'backend_model', '');
$installer->endSetup();
diff --git a/app/code/core/Mage/SalesRule/Model/Mysql4/Rule.php b/app/code/core/Mage/SalesRule/Model/Mysql4/Rule.php
index 90d2a6e2da..dccaaa0ebb 100644
--- a/app/code/core/Mage/SalesRule/Model/Mysql4/Rule.php
+++ b/app/code/core/Mage/SalesRule/Model/Mysql4/Rule.php
@@ -172,7 +172,7 @@ protected function _aggregateByOrderCreatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
@@ -267,7 +267,7 @@ protected function _aggregateByOrderUpdatedAt($from, $to)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php
index 93ae721900..a9a2fcd360 100644
--- a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php
+++ b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Address.php
@@ -123,6 +123,11 @@ public function validate(Varien_Object $object)
$address = $object->getQuote()->getShippingAddress();
}
}
+
+ if ('payment_method' == $this->getAttribute() && ! $address->hasPaymentMethod()) {
+ $address->setPaymentMethod($object->getQuote()->getPayment()->getMethod());
+ }
+
return parent::validate($address);
}
}
diff --git a/app/code/core/Mage/SalesRule/sql/salesrule_setup/mysql4-upgrade-0.7.10-0.7.11.php b/app/code/core/Mage/SalesRule/sql/salesrule_setup/mysql4-upgrade-0.7.10-0.7.11.php
index 3d9fa5a6bb..b113415d93 100644
--- a/app/code/core/Mage/SalesRule/sql/salesrule_setup/mysql4-upgrade-0.7.10-0.7.11.php
+++ b/app/code/core/Mage/SalesRule/sql/salesrule_setup/mysql4-upgrade-0.7.10-0.7.11.php
@@ -62,8 +62,7 @@
}
$installer->run("
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('salesrule/coupon_aggregated')}`
- (
+ CREATE TABLE `{$installer->getTable('salesrule/coupon_aggregated')}` (
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
`store_id` smallint(5) unsigned NULL DEFAULT NULL,
@@ -75,13 +74,10 @@
`total_amount` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `UNQ_COUPON_AGGREGATED_PSOC` (`period`,`store_id`, `order_status`, `coupon_code`),
- KEY `FK_COUPON_AGGREGATED_STORE` (`store_id`),
- CONSTRAINT `FK_COUPON_AGGREGATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
+ KEY `IDX_STORE_ID` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('salesrule/coupon_aggregated_order')}`
- (
+ CREATE TABLE `{$installer->getTable('salesrule/coupon_aggregated_order')}` (
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
`store_id` smallint(5) unsigned NULL DEFAULT NULL,
@@ -93,10 +89,24 @@
`total_amount` decimal(12,4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `UNQ_COUPON_AGGREGATED_ORDER_PSOC` (`period`,`store_id`, `order_status`,`coupon_code`),
- KEY `FK_COUPON_AGGREGATED_ORDER_STORE` (`store_id`),
- CONSTRAINT `FK_COUPON_AGGREGATED_ORDER_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`)
- ON DELETE SET NULL ON UPDATE CASCADE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ KEY `IDX_STORE_ID` (`store_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
+$installer->getConnection()->addConstraint(
+ 'FK_SALESTRULE_COUPON_AGGREGATED_ORDER_STORE',
+ $this->getTable('salesrule/coupon_aggregated_order'),
+ 'store_id',
+ $this->getTable('core_store'),
+ 'store_id'
+);
+
+$installer->getConnection()->addConstraint(
+ 'FK_SALESTRULE_COUPON_AGGREGATED_STORE',
+ $this->getTable('salesrule/coupon_aggregated'),
+ 'store_id',
+ $this->getTable('core_store'),
+ 'store_id'
+);
+
$installer->endSetup();
diff --git a/app/code/core/Mage/Shipping/Helper/Data.php b/app/code/core/Mage/Shipping/Helper/Data.php
index 0273b15268..580d3565a3 100644
--- a/app/code/core/Mage/Shipping/Helper/Data.php
+++ b/app/code/core/Mage/Shipping/Helper/Data.php
@@ -72,7 +72,8 @@ protected function _getTrackingUrl($key, $model, $method = 'getId')
'hash' => Mage::helper('core')->urlEncode("{$key}:{$model->$method()}:{$model->getProtectCode()}")
);
}
- return $this->_getUrl('shipping/tracking/popup', $param);
+ $storeModel = Mage::app()->getStore($model->getStoreId());
+ return $storeModel->getUrl('shipping/tracking/popup', $param);
}
/**
diff --git a/app/code/core/Mage/Shipping/Model/Mysql4/Carrier/Tablerate.php b/app/code/core/Mage/Shipping/Model/Mysql4/Carrier/Tablerate.php
index a829a6e28c..079a06bb93 100644
--- a/app/code/core/Mage/Shipping/Model/Mysql4/Carrier/Tablerate.php
+++ b/app/code/core/Mage/Shipping/Model/Mysql4/Carrier/Tablerate.php
@@ -120,10 +120,18 @@ public function getRate(Mage_Shipping_Model_Rate_Request $request)
return $row;
}
-
+ /**
+ * Upload table rate file and import data from it
+ *
+ * @param Varien_Object $object
+ * @return bool|Mage_Shipping_Model_Mysql4_Carrier_Tablerate
+ */
public function uploadAndImport(Varien_Object $object)
{
- $csvFile = $_FILES["groups"]["tmp_name"]["tablerate"]["fields"]["import"]["value"];
+ if (!isset($_FILES['groups'])) {
+ return false;
+ }
+ $csvFile = $_FILES['groups']['tmp_name']['tablerate']['fields']['import']['value'];
if (!empty($csvFile)) {
@@ -261,6 +269,7 @@ public function uploadAndImport(Varien_Object $object)
}
}
}
+ return $this;
}
protected function _getCsvValues($string, $separator=",")
diff --git a/app/code/core/Mage/Shipping/Model/Shipping.php b/app/code/core/Mage/Shipping/Model/Shipping.php
index 18a3ecc2d5..e783412843 100644
--- a/app/code/core/Mage/Shipping/Model/Shipping.php
+++ b/app/code/core/Mage/Shipping/Model/Shipping.php
@@ -157,6 +157,7 @@ public function collectRatesByAddress(Varien_Object $address, $limitCarrier=null
$request->setDestRegionId($address->getRegionId());
$request->setDestPostcode($address->getPostcode());
$request->setPackageValue($address->getBaseSubtotal());
+ $request->setPackageValueWithDiscount($address->getBaseSubtotalWithDiscount());
$request->setPackageWeight($address->getWeight());
$request->setFreeMethodWeight($address->getFreeMethodWeight());
$request->setPackageQty($address->getItemQty());
diff --git a/app/code/core/Mage/Shipping/etc/system.xml b/app/code/core/Mage/Shipping/etc/system.xml
index 85e2ab4a85..5efef45542 100644
--- a/app/code/core/Mage/Shipping/etc/system.xml
+++ b/app/code/core/Mage/Shipping/etc/system.xml
@@ -211,6 +211,7 @@
1
1
0
+ 1
Show method if not applicable
@@ -298,6 +299,7 @@
1
1
0
+ 1
Show method if not applicable
@@ -429,6 +431,7 @@
1
1
0
+ 1
Show method if not applicable
diff --git a/app/code/core/Mage/Sitemap/Model/Sitemap.php b/app/code/core/Mage/Sitemap/Model/Sitemap.php
index b1702332c5..08344ddda0 100644
--- a/app/code/core/Mage/Sitemap/Model/Sitemap.php
+++ b/app/code/core/Mage/Sitemap/Model/Sitemap.php
@@ -64,7 +64,7 @@ protected function _beforeSave()
* Check exists and writeable path
*/
if (!$io->fileExists($realPath, false)) {
- Mage::throwException(Mage::helper('sitemap')->__('Please create the specified folder "%s" before saving the sitemap.', $this->getSitemapPath()));
+ Mage::throwException(Mage::helper('sitemap')->__('Please create the specified folder "%s" before saving the sitemap.', Mage::helper('core')->htmlEscape($this->getSitemapPath())));
}
if (!$io->isWriteable($realPath)) {
@@ -136,8 +136,8 @@ public function generateXml()
/**
* Generate categories sitemap
*/
- $changefreq = (string)Mage::getStoreConfig('sitemap/category/changefreq');
- $priority = (string)Mage::getStoreConfig('sitemap/category/priority');
+ $changefreq = (string)Mage::getStoreConfig('sitemap/category/changefreq', $storeId);
+ $priority = (string)Mage::getStoreConfig('sitemap/category/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/catalog_category')->getCollection($storeId);
foreach ($collection as $item) {
$xml = sprintf('%s %s %s %.1f ',
@@ -153,8 +153,8 @@ public function generateXml()
/**
* Generate products sitemap
*/
- $changefreq = (string)Mage::getStoreConfig('sitemap/product/changefreq');
- $priority = (string)Mage::getStoreConfig('sitemap/product/priority');
+ $changefreq = (string)Mage::getStoreConfig('sitemap/product/changefreq', $storeId);
+ $priority = (string)Mage::getStoreConfig('sitemap/product/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId);
foreach ($collection as $item) {
$xml = sprintf('%s %s %s %.1f ',
@@ -170,8 +170,8 @@ public function generateXml()
/**
* Generate cms pages sitemap
*/
- $changefreq = (string)Mage::getStoreConfig('sitemap/page/changefreq');
- $priority = (string)Mage::getStoreConfig('sitemap/page/priority');
+ $changefreq = (string)Mage::getStoreConfig('sitemap/page/changefreq', $storeId);
+ $priority = (string)Mage::getStoreConfig('sitemap/page/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/cms_page')->getCollection($storeId);
foreach ($collection as $item) {
$xml = sprintf('%s %s %s %.1f ',
diff --git a/app/code/core/Mage/Strikeiron/Helper/Data.php b/app/code/core/Mage/Strikeiron/Helper/Data.php
deleted file mode 100644
index 13160b572c..0000000000
--- a/app/code/core/Mage/Strikeiron/Helper/Data.php
+++ /dev/null
@@ -1,38 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Currency_Import_Strikeiron extends Mage_Directory_Model_Currency_Import_Abstract
-{
- protected $_messages = array();
-
- public function fetchRates()
- {
- $data = array();
- $currencies = $this->_getCurrencyCodes();
- $defaultCurrencies = $this->_getDefaultCurrencyCodes();
- try {
- $strikeironModel = Mage::getModel('strikeiron/strikeiron');
- foreach ($defaultCurrencies as $currencyFrom) {
- $currenciesToArr = array();
- if (!isset($data[$currencyFrom])) {
- $data[$currencyFrom] = array();
- }
- foreach ($currencies as $currencyTo) {
- if ($currencyFrom == $currencyTo) {
- $data[$currencyFrom][$currencyTo] = $this->_numberFormat(1);
- }
- else {
- $currenciesToArr[] = $currencyTo;
- }
- }
- if ($currenciesToArr) {
- $result = $strikeironModel->fetchExchangeRate($currencyFrom , $currenciesToArr);
- if ($result) {
- $data = array_merge_recursive($result, $data);
- $convertedCurrencies = array();
- foreach ($result[$currencyFrom] as $k => $r) {
- $convertedCurrencies[] = $k;
- }
- $currenciesNotConverted = array_diff($currenciesToArr, $convertedCurrencies);
- if ($currenciesNotConverted) {
- foreach ($currenciesNotConverted as $_currencyNconvert) {
- $this->_messages[] = Mage::helper('strikeiron')->__('%s is not supported currency.', $_currencyNconvert);
- $data[$currencyFrom][$_currencyNconvert] = $this->_numberFormat(null);
- }
- }
- } else {
- $this->_messages[] = Mage::helper('strikeiron')->__('Cannot retreive rate from strikeirion.');
- }
- }
- ksort($data[$currencyFrom]);
- }
- } catch (Exception $e) {
- $this->_messages[] = $e->getMessage();
- }
- return $data;
- }
-
- protected function _convert($currencyFrom, $currencyTo, $retry=0)
- {
-
- try {
- $strikeironModel = Mage::getModel('strikeiron/strikeiron');
- $result = $strikeironModel->fetchExchangeRate($currencyFrom , array($currencyTo));
- return $result;
- }
- catch (Exception $e) {
- if( $retry == 0 ) {
- $this->_convert($currencyFrom, $currencyTo, 1);
- } else {
- $this->_messages[] = Mage::helper('strikeiron')->__('Cannot retrieve rate from %s to %s', $currencyFrom, $currencyTo);
- }
- }
-
- }
-
-
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Mysql4/Taxrate.php b/app/code/core/Mage/Strikeiron/Model/Mysql4/Taxrate.php
deleted file mode 100644
index 8678ff6af7..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Mysql4/Taxrate.php
+++ /dev/null
@@ -1,106 +0,0 @@
-
- */
-
-class Mage_Strikeiron_Model_Mysql4_Taxrate extends Mage_Core_Model_Mysql4_Abstract
-{
- protected function _construct()
- {
- $this->_init('strikeiron/tax_rate', 'tax_rate_id');
- }
-
- /**
- * Initialize unique fields
- *
- * @return Mage_Core_Model_Mysql4_Abstract
- */
- protected function _initUniqueFields()
- {
- $this->_uniqueFields = array(array(
- 'field' => array('tax_country_id', 'tax_region_id', 'tax_postcode'),
- 'title' => Mage::helper('strikeiron')->__('Country/Region/Postal code combination'),
- ));
- return $this;
- }
-
- protected function _checkUnique(Mage_Core_Model_Abstract $object)
- {
- $existent = array();
- $rateValueArray = array();
- if (!empty($this->_uniqueFields)) {
- if (!is_array($this->_uniqueFields)) {
- $this->_uniqueFields = array(
- array(
- 'field' => $this->_uniqueFields,
- 'title' => $this->_uniqueFields
- ));
- }
-
- $data = new Varien_Object($this->_prepareDataForSave($object));
- $select = $this->_getWriteAdapter()->select()
- ->from($this->getMainTable());
-
- foreach ($this->_uniqueFields as $unique) {
- $select->reset(Zend_Db_Select::WHERE);
-
- if (is_array($unique['field'])) {
- foreach ($unique['field'] as $field) {
- $select->where($field.'=?', $data->getData($field));
- $rateValueArray[] = $this->_getWriteAdapter()->quoteInto($field.'=?', $data->getData($field));
- }
- }
- else {
- $select->where( $unique['field'] . ' = ?', $data->getData($unique['field']) );
- $rateValueArray[] = $this->_getWriteAdapter()->quoteInto( $unique['field'] . ' = ?', $data->getData($unique['field']) );
- }
-
- if ($object->getId()) {
- $select->where($this->getIdFieldName().' != ?', $object->getId());
- }
-
- if ( $test = $this->_getWriteAdapter()->fetchRow($select) ) {
- $existent[] = $test['tax_rate_id'];
- }
- }
- }
- if (!empty($existent)) {
- $this->_getWriteAdapter()->delete($this->getMainTable(), $rateValueArray);
- }
-
- }
-
- public function deleteAllRates()
- {
- $this->_getWriteAdapter()->delete($this->getMainTable());
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Mysql4/Taxrate/Collection.php b/app/code/core/Mage/Strikeiron/Model/Mysql4/Taxrate/Collection.php
deleted file mode 100644
index 1008a92a6c..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Mysql4/Taxrate/Collection.php
+++ /dev/null
@@ -1,51 +0,0 @@
-
- */
-
-class Mage_Strikeiron_Model_Mysql4_Taxrate_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
-{
- protected function _construct()
- {
- $this->_init('strikeiron/taxrate');
- }
-
- public function addRateFilter($rateId)
- {
- if (is_int($rateId) && $rateId > 0) {
- return $this->_select->where('main_table.tax_rate_id=?', $rateId);
- }
- else {
- return $this;
- }
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/AddressVerification.php b/app/code/core/Mage/Strikeiron/Model/Service/AddressVerification.php
deleted file mode 100644
index a0d537ee02..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/AddressVerification.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Service_AddressVerification extends Mage_Strikeiron_Model_Service_Base
-{
- const ADDRESS_ERROR_ACCEPT = 'Accept';
- const ADDRESS_ERROR_REJECT = 'Reject';
- const ADDRESS_ERROR_CONFIRM = 'Confirm';
-
- /**
- * Configuration options
- * @param array
- */
- protected $_options = array('username' => null,
- 'password' => null,
- 'client' => null,
- 'options' => null,
- 'headers' => null,
- 'wsdl' => 'aHR0cDovL3dzLnN0cmlrZWlyb24uY29tL3Zhcmllbi5TdHJpa2VJcm9uL1VTQWRkcmVzc1ZlcmlmaWNhdGlvbjRfMD9XU0RM');
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/Base.php b/app/code/core/Mage/Strikeiron/Model/Service/Base.php
deleted file mode 100644
index 208ca33b7d..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/Base.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
- */
-require_once 'Zend/Service/StrikeIron/Base.php';
-
-class Mage_Strikeiron_Model_Service_Base extends Zend_Service_StrikeIron_Base
-{
- public function __construct($options = array())
- {
- $this->_options['wsdl'] = $this->_wsdlDecode();
- parent::__construct($options);
- }
-
- public function _wsdlDecode()
- {
- return base64_decode($this->_options['wsdl']);
- }
-
- public function getOptionData($key)
- {
- if( isset($this->_options[$key]) ){
- return $this->_options[$key];
- } else {
- return null;
- }
- }
-
- public function getOptions()
- {
- return $this->_options;
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/EmailVerification.php b/app/code/core/Mage/Strikeiron/Model/Service/EmailVerification.php
deleted file mode 100644
index c68c4037de..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/EmailVerification.php
+++ /dev/null
@@ -1,48 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Service_EmailVerification extends Mage_Strikeiron_Model_Service_Base
-{
- const EMAIL_UNDETERMINED_ACCEPT = 'Accept';
- const EMAIL_UNDETERMINED_REJECT = 'Reject';
- const EMAIL_UNDETERMINED_CONFIRM = 'Confirm';
- /**
- * Configuration options
- * @param array
- */
- protected $_options = array('username' => null,
- 'password' => null,
- 'client' => null,
- 'options' => null,
- 'headers' => null,
- 'wsdl' => 'aHR0cDovL3dzLnN0cmlrZWlyb24uY29tL3Zhcmllbi5TdHJpa2VJcm9uL2VtYWlsdmVyaWZ5XzNfMD9XU0RM');
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/ForeignExchangeRates.php b/app/code/core/Mage/Strikeiron/Model/Service/ForeignExchangeRates.php
deleted file mode 100644
index d3ab07e661..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/ForeignExchangeRates.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Service_ForeignExchangeRates extends Mage_Strikeiron_Model_Service_Base
-{
- /**
- * Configuration options
- * @param array
- */
- protected $_options = array('username' => null,
- 'password' => null,
- 'client' => null,
- 'options' => null,
- 'headers' => null,
- 'wsdl' => 'aHR0cDovL3dzLnN0cmlrZWlyb24uY29tL3Zhcmllbi5TdHJpa2VJcm9uL0ZvcmVpZ25FeGNoYW5nZVJhdGU/V1NETA==');
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTax.php b/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTax.php
deleted file mode 100644
index c63dd3ef21..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTax.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Service_SalesUseTax extends Mage_Strikeiron_Model_Service_Base
-{
- const SALETAX_TYPE_BASIC = 'B';
- const SALETAX_TYPE_COMPLETE = 'C';
-
- const SALETAX_COMPLETE_MIN = 'MIN';
- const SALETAX_COMPLETE_MAX = 'MAX';
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTaxBasic.php b/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTaxBasic.php
deleted file mode 100644
index 8d3a77ac5a..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTaxBasic.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Service_SalesUseTaxBasic extends Mage_Strikeiron_Model_Service_SalesUseTax
-{
- /**
- * Configuration options
- * @param array
- */
- protected $_options = array('username' => null,
- 'password' => null,
- 'client' => null,
- 'options' => null,
- 'headers' => null,
- 'wsdl' => 'aHR0cDovL3dzLnN0cmlrZWlyb24uY29tL3Zhcmllbi5TdHJpa2VJcm9uL1RheERhdGFCYXNpYzQ/V1NETA==');
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTaxComplete.php b/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTaxComplete.php
deleted file mode 100644
index 65f0cae23d..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/SalesUseTaxComplete.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Service_SalesUseTaxComplete extends Mage_Strikeiron_Model_Service_SalesUseTax
-{
- /**
- * Configuration options
- * @param array
- */
- protected $_options = array('username' => null,
- 'password' => null,
- 'client' => null,
- 'options' => null,
- 'headers' => null,
- 'wsdl' => 'aHR0cDovL3dzLnN0cmlrZWlyb24uY29tL3Zhcmllbi5TdHJpa2VJcm9uL1RheERhdGFDb21wbGV0ZTQ/V1NETA==');
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Service/UsAddressVerification.php b/app/code/core/Mage/Strikeiron/Model/Service/UsAddressVerification.php
deleted file mode 100644
index d11a42da8d..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Service/UsAddressVerification.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Service_UsAddressVerification extends Mage_Strikeiron_Model_Service_AddressVerification
-{
- /**
- * Configuration options
- * @param array
- */
- protected $_options = array('username' => null,
- 'password' => null,
- 'client' => null,
- 'options' => null,
- 'headers' => null,
- 'wsdl' => 'aHR0cDovL3dzLnN0cmlrZWlyb24uY29tL3Zhcmllbi5TdHJpa2VJcm9uL1VTQWRkcmVzc1ZlcmlmaWNhdGlvbjRfMD9XU0RM');
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Session.php b/app/code/core/Mage/Strikeiron/Model/Session.php
deleted file mode 100644
index 1be8b7dd83..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Session.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Session extends Mage_Core_Model_Session_Abstract
-{
- public function __construct()
- {
- $this->init('strikeiron');
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Source/ErrorAddressAction.php b/app/code/core/Mage/Strikeiron/Model/Source/ErrorAddressAction.php
deleted file mode 100644
index 9913ac6c72..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Source/ErrorAddressAction.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Source_ErrorAddressAction
-{
- public function toOptionArray()
- {
- return array(
- array('value' => Mage_Strikeiron_Model_Service_AddressVerification::ADDRESS_ERROR_ACCEPT, 'label' => Mage::helper('strikeiron')->__('Accept')),
- array('value' => Mage_Strikeiron_Model_Service_AddressVerification::ADDRESS_ERROR_REJECT, 'label' => Mage::helper('strikeiron')->__('Reject')),
- array('value' => Mage_Strikeiron_Model_Service_AddressVerification::ADDRESS_ERROR_CONFIRM, 'label' => Mage::helper('strikeiron')->__('Pop up warning and accept')),
- );
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Source/SalesTaxType.php b/app/code/core/Mage/Strikeiron/Model/Source/SalesTaxType.php
deleted file mode 100644
index 9195e9f9f5..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Source/SalesTaxType.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Source_SalesTaxType
-{
- public function toOptionArray()
- {
- return array(
- array('value' => Mage_Strikeiron_Model_Service_SalesUseTax::SALETAX_TYPE_BASIC, 'label' => Mage::helper('strikeiron')->__('Basic')),
- array('value' => Mage_Strikeiron_Model_Service_SalesUseTax::SALETAX_TYPE_COMPLETE, 'label' => Mage::helper('strikeiron')->__('Complete')),
-
- );
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Source/Salestaxminmax.php b/app/code/core/Mage/Strikeiron/Model/Source/Salestaxminmax.php
deleted file mode 100644
index ebdf9095d0..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Source/Salestaxminmax.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Source_Salestaxminmax
-{
- public function toOptionArray()
- {
- return array(
- array('value' => Mage_Strikeiron_Model_Service_SalesUseTax::SALETAX_COMPLETE_MIN, 'label' => Mage::helper('strikeiron')->__('Minimum tax rate')),
- array('value' => Mage_Strikeiron_Model_Service_SalesUseTax::SALETAX_COMPLETE_MAX , 'label' => Mage::helper('strikeiron')->__('Maximum tax rate')),
-
- );
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Source/UndeterminedEmailAction.php b/app/code/core/Mage/Strikeiron/Model/Source/UndeterminedEmailAction.php
deleted file mode 100644
index 411902ed95..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Source/UndeterminedEmailAction.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Source_UndeterminedEmailAction
-{
- public function toOptionArray()
- {
- return array(
- array('value' => Mage_Strikeiron_Model_Service_EmailVerification::EMAIL_UNDETERMINED_ACCEPT, 'label' => Mage::helper('strikeiron')->__('Accept')),
- array('value' => Mage_Strikeiron_Model_Service_EmailVerification::EMAIL_UNDETERMINED_REJECT, 'label' => Mage::helper('strikeiron')->__('Reject')),
- array('value' => Mage_Strikeiron_Model_Service_EmailVerification::EMAIL_UNDETERMINED_CONFIRM, 'label' => Mage::helper('strikeiron')->__('Pop up warning and accept')),
- );
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Strikeiron.php b/app/code/core/Mage/Strikeiron/Model/Strikeiron.php
deleted file mode 100644
index 3778bbdf0e..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Strikeiron.php
+++ /dev/null
@@ -1,391 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Strikeiron extends Mage_Core_Model_Abstract
-{
- public function getApi($service, $options = array())
- {
- return Mage::getSingleton('strikeiron/service_'.$service, array_merge($this->getConfiguration(),$options));
- }
-
- protected function getConfiguration()
- {
- return array('username'=> $this->getConfigData('config', 'user') , 'password'=> $this->getConfigData('config', 'password'));
- }
-
- public function getConfigData($code, $field)
- {
- $path = 'strikeiron/'.$code.'/'.$field;
- return Mage::getStoreConfig($path);
- }
-
-/*********************** EMAIL VERIFICATION***************************/
- /*
- verify email address is valid or not
- wsdl = http://ws.strikeiron.com/varien.StrikeIron/emailverify_3_0?WSDL
- */
- public function emailVerify($email)
- {
- if ($email && $this->getConfigData('email_verification', 'active')) {
- $_session = Mage::getSingleton('strikeiron/session');
- /*
- * following flag will set if the email is undetermined for the first time
- * for second time, we just need to return true
- */
- if ($_session->getStrikeironUndertermined()==$email) {
- $_session->unsStrikeironUndertermined();
- return true;
- }
-
- $emailApi = $this->getApi('emailVerification');
-
- $checkAllServer = $this->getConfigData('email_verification', 'check_allservers');
- $emailArr = array(
- 'email' => $email,
- 'checkAllServers' => ($checkAllServer ? 'True' : 'False')
- );
- $result = '';
-
- try {
- $subscriptionInfo = $emailApi->getSubscriptionInfo();
- if ($subscriptionInfo && $subscriptionInfo->remainingHits>0) {
- $result = $emailApi->validateEmail($emailArr);
- if ($result) {
- switch ($result->IsValid) {
- case 'INVALID':
- Mage::throwException(Mage::helper('strikeiron')->__('Invalid email address'));
- break;
- case 'UNDETERMINED':
- switch($this->getConfigData('email_verification', 'undetermined_action')) {
- case Mage_Strikeiron_Model_Service_EmailVerification::EMAIL_UNDETERMINED_REJECT:
- Mage::throwException(Mage::helper('strikeiron')->__('Invalid email address'));
- break;
- case Mage_Strikeiron_Model_Service_EmailVerification::EMAIL_UNDETERMINED_CONFIRM:
- $_session->setStrikeironUndertermined($email);
- Mage::throwException(Mage::helper('strikeiron')->__('Email address cannot be verified. Please check again and make sure your email address entered correctly.'));
- break;
- }
- break;
- }
- } else {
- Mage::throwException(Mage::helper('strikeiron')->__('There is an error in verifying an email. Please contact us.'));
- }
-
- } else {
- /*
- * when there is no more remaining hits for service
- * we will send email to email recipient for exception
- */
- /* @var $mailTemplate Mage_Core_Model_Email_Template */
- $receipient = $this->getConfigData('email_verification', 'error_email');
- if ($receipient) {
- $translate = Mage::getSingleton('core/translate');
- /* @var $translate Mage_Core_Model_Translate */
- $translate->setTranslateInline(false);
-
- $mailTemplate = Mage::getModel('core/email_template');
- $mailTemplate->setDesignConfig(
- array(
- 'area' => 'frontend',
- )
- )
- ->sendTransactional(
- $this->getConfigData('email_verification', 'error_email_template'),
- $this->getConfigData('email_verification', 'error_email_identity'),
- $receipient,
- null,
- array(
- 'email' => $email,
- 'warnings' => $e->getMessage(),
- )
- );
-
- $translate->setTranslateInline(true);
- }
-
- }
- } catch (Zend_Service_StrikeIron_Exception $e) {
- Mage::throwException(Mage::helper('strikeiron')->__('There is an error in verifying an email. Please contact us.'));
- }
- }
- return true;
- }
-
-/*********************** FOREIGN CURRENCY EXCHANGE***************************/
-
- public function _getAllSupportedCurrencies($exchangeApi)
- {
- $result = $exchangeApi->GetSupportedCurrencies();
- $data = array();
- if ($result && $result->ServiceStatus && $result->ServiceStatus->StatusNbr == 210) {
- $listings = $result->ServiceResult->Listings;
- if ($listings && $listings->CurrencyListing) {
- foreach($listings->CurrencyListing as $listing){
- $data[] = $listing->Symbol;
- }
- }
- }
- return $data;
- }
-
- /*
- retrieving foreign exchange rate for the currency
- wsdl = http://ws.strikeiron.com/varien.StrikeIron/ForeignExchangeRate?WSDL
- */
- public function fetchExchangeRate ($defaultCurrency, $currencies=array())
- {
- if(!$this->getConfigData('currency', 'foreigh_xrate')){
- Mage::throwException(Mage::helper('strikeiron')->__('Strikeiron foreign exchange rate is disabled'));
- }
-
- $data = array();
- $exchangeApi = $this->getApi('foreignExchangeRates');
- $result = '';
- try {
- $subscriptionInfo = $exchangeApi->getSubscriptionInfo();
- if ($subscriptionInfo && $subscriptionInfo->remainingHits>0) {
- $supportedCurrencies = $this->_getAllSupportedCurrencies($exchangeApi);
- if($supportedCurrencies) {
- $availableCurrencies = array_intersect($currencies, $supportedCurrencies);
- if($availableCurrencies && in_array($defaultCurrency,$supportedCurrencies)){
- $currenciesStr = implode(', ' , $availableCurrencies);
- $reqArr = array(
- 'CommaSeparatedListOfCurrenciesFrom' => $currenciesStr,
- 'SingleCurrencyTo' => $defaultCurrency
- );
- $result = $exchangeApi->GetLatestRates($reqArr);
- if ($result) {
- /*
- 212 = Currency rate data Found
- */
- if ($result->ServiceStatus && $result->ServiceStatus->StatusNbr == 212) {
- $listings = $result->ServiceResult->Listings;
- if($listings && $listings->ExchangeRateListing) {
- foreach ($listings->ExchangeRateListing as $listing) {
- $data[$listing->PerCurrency][$listing->Currency] = $listing->Value;
- }
- }
- } else {
- Mage::throwException($result->ServiceStatus->StatusDescription);
- }
- } else {
- Mage::throwException(Mage::helper('strikeiron')->__('There is no response back from Strikeiron server'));
- }
- }
- }
- } else {
- Mage::throwException(Mage::helper('strikeiron')->__('There is no more hits remaining for the foreign Exchange Rate Service.'));
- }
- } catch (Zend_Service_StrikeIron_Exception $e) {
- Mage::throwException(Mage::helper('strikeiron')->__('There is no response back from Strikeiron server'));
- }
- return $data;
- }
-
- public function customerSaveBeforeObserver($observer)
- {
- $customer = $observer->getEvent()->getCustomer();
- $isAdmin = Mage::getDesign()->getArea()==='adminhtml';
- $email = $customer->getEmail();
- $host = Mage::app()->getStore()->getConfig(Mage_Customer_Model_Customer::XML_PATH_DEFAULT_EMAIL_DOMAIN);
- $fakeEmail = $customer->getIncrementId().'@'. $host;
- if ($email && $email != $fakeEmail && $customer->dataHasChangedFor('email') &&
- (!$isAdmin || ($isAdmin && $this->getConfigData('email_verification', 'check_admin')))
- ) {
- $this->emailVerify($email);
- }
- }
-
-/*********************** ADDRESS VERIFICATION***************************/
-
- public function addressSaveBeforeObserver($observer)
- {
- $address = $observer->getEvent()->getCustomerAddress();
- $us = $address->getCountryId() == 'US';
- $addressDataChange = sizeof($address) == 1 && ( $address->dataHasChangedFor('street') || $address->dataHasChangedFor('city') ||
- $address->dataHasChangedFor('postcode') || $address->dataHasChangedFor('country_id') || $address->dataHasChangedFor('region_id') ||
- $address->dataHasChangedFor('region'))
- ;
- if ($addressDataChange) {
- if ($us) {
- $this->UsAddressVerify($address);
- }
- }
-
- }
-
- /*
- verify US address is valid or not
- wsdl = http://ws.strikeiron.com/varien.StrikeIron/USAddressVerification4_0?WSDL
- $subscription = $taxBasic->getSubscriptionInfo();
- echo $subscription->remainingHits;
-
- */
- public function UsAddressVerify($address)
- {
-//echo "";
-//print_r($address);
-return;
-$_session = Mage::getSingleton('strikeiron/session');
- $usAddressApi = $this->getApi('usAddressVerification');
- $cityStateZip = $address->getCity()." ".$address->getRegionCode()." ".$address->getPostcode();
- $reqArr = array(
- 'firm' => $address->getCompany(),
- 'addressLine1' => $address->getStreet(1),
- 'addressLine2' => $address->getStreet(2),
- 'city_state_zip' => $cityStateZip )
- ;
- $result = '';
- try {
- $subscriptionInfo = $usAddressApi->getSubscriptionInfo();
- if ($subscriptionInfo && $subscriptionInfo->remainingHits>0) {
- $result = $usAddressApi->verifyAddressUSA($reqArr);
-//$result = $_session->getUsAddressVerify();
-//$_session->setUsAddressVerify($result);
-//print_r($reqArr);
-//print_r($result);
- } else {
-
- }
-
- } catch (Zend_Service_StrikeIron_Exception $e) {
- Mage::throwException(Mage::helper('strikeiron')->__('There is no response back from Strikeiron server'));
- }
- return true;
- }
-
-/*********************** SALES AND TAX RATE***************************/
- /*
- retrieveing the sale tax rate by zip code for US and by province by canada
- wsdl = http://ws.strikeiron.com/varien.StrikeIron/TaxDataBasic4?WSDL
- wsdl = http://ws.strikeiron.com/varien.StrikeIron/TaxDataComplete4?WSDL
- this method is called by event handler
- event is added in Mage_Tax_Model_Rate_Data
- */
- public function getTaxRate($observer)
- {
- $data = $observer->getEvent()->getRequest();
-// $data = new Varien_Object();
-// $data->setProductClassId(2)
-// ->setCustomerClassId(3)
-// ->setCountryId('CN')
-// ->setRegionId('74')
-// ->setPostcode('95618');
-
- $tax_rate = 0;
- $customerTaxClass = array();
- $customerTaxClass = explode(',' ,$this->getConfigData('sales_tax', 'customer_tax_class'));
- $productTaxClass = array();
- $productTaxClass = explode(',' , $this->getConfigData('sales_tax', 'product_tax_class'));
- if ($this->getConfigData('sales_tax', 'active')
- && in_array($data->getCustomerClassId(), $customerTaxClass)
- && in_array($data->getProductClassId(), $productTaxClass)
- && ($data->getCountryId()=='US' || $data->getCountryId()=='CN')
- ) {
- $type = $this->getConfigData('sales_tax', 'type');
- $isBasic = false;
- if($type == 'B') {
- $isBasic = true;
- }
-
- $saleTaxApi = $this->getApi('salesUseTax'.($isBasic ? 'Basic' : 'Complete'));
- try {
- $subscriptionInfo = $saleTaxApi->getSubscriptionInfo();
- if ($subscriptionInfo && $subscriptionInfo->remainingHits>0) {
- if ($data->getCountryId()=='US') {
- if ($isBasic) {
- $requestArr = array('zip_code' => $data->getPostcode());
- $result = $saleTaxApi->GetTaxRateUS($requestArr);
- if ($result) {
- $tax_rate = $result->total_sales_tax;
- }
- } else {
- $requestArr = array('zipCode' => $data->getPostcode());
-
- $result = $saleTaxApi->GetUSATaxRatesByZipCode($requestArr);
- if ($result && $result->USATaxRate) {
- $tax_rate = $this->parseTaxRateComplete($result);
- }
- }
- } else {
- $region_code = Mage::getSingleton('directory/region')->load($data->getRegionId())->getCode();
- $requestArr = array('province' => $region_code);
- if ($isBasic) {
- $result = $saleTaxApi->GetTaxRateCanada($requestArr);
- if ($result) {
- $tax_rate = $result->total;
- }
- } else {
- $result = $saleTaxApi->GetCanadaTaxRatesByProvince($requestArr);
- if ($result && $result->CanadaTaxRate) {
- $tax_rate = $result->CanadaTaxRate->Total;
- }
- }
- }
- }
- } catch (Zend_Service_StrikeIron_Exception $e) {
- //we won't throw exception
- //since the method is calling via event handler
- //Mage::throwException(Mage::helper('strikeiron')->__('There is an error in retrieving tax rate. Please contact us'));
- }
- }
-
- if ($tax_rate>0) {
- $tax_rate = $tax_rate * 100;
- $dbObj = Mage::getSingleton('strikeiron/taxrate')
- ->setTaxCountryId($data->getCountryId())
- ->setTaxRegionId($data->getRegionId())
- ->setTaxPostcode($data->getPostcode())
- ->setRateValue($tax_rate)
- ->save();
- $data->setRateValue($tax_rate);
- $data->setRateTitle(Mage::helper('strikeiron')->__('Tax'));
- $data->setRateId('strikeiron_tax');
- }
- return $this;
-
- }
-
- protected function parseTaxRateComplete($result)
- {
- $tax_array = array();
- foreach ($result->USATaxRate as $rate) {
- if($rate->TotalSalesTax>0) {
- $tax_array[] = $rate->TotalSalesTax;
- }
- }
- $minMax = strtolower($this->getConfigData('sales_tax', 'min_max'));
- return $minMax($tax_array);
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/Model/Taxrate.php b/app/code/core/Mage/Strikeiron/Model/Taxrate.php
deleted file mode 100644
index 0256f61ec7..0000000000
--- a/app/code/core/Mage/Strikeiron/Model/Taxrate.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-class Mage_Strikeiron_Model_Taxrate extends Mage_Core_Model_Abstract
-{
- protected function _construct()
- {
- $this->_init('strikeiron/taxrate');
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/controllers/TestController.php b/app/code/core/Mage/Strikeiron/controllers/TestController.php
deleted file mode 100644
index 468b36fd66..0000000000
--- a/app/code/core/Mage/Strikeiron/controllers/TestController.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- */
-
-class Mage_Strikeiron_TestController extends Mage_Core_Controller_Front_Action
-{
- public function indexAction()
- {
- $model = Mage::getModel('strikeiron/strikeiron');
- $model->getTaxRate();
- }
-}
diff --git a/app/code/core/Mage/Strikeiron/etc/adminhtml.xml b/app/code/core/Mage/Strikeiron/etc/adminhtml.xml
deleted file mode 100644
index 0fad7a3eae..0000000000
--- a/app/code/core/Mage/Strikeiron/etc/adminhtml.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- Strikeiron Section
- 75
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Strikeiron/etc/config.xml b/app/code/core/Mage/Strikeiron/etc/config.xml
deleted file mode 100644
index 7a3c6fadc0..0000000000
--- a/app/code/core/Mage/Strikeiron/etc/config.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-
-
-
-
-
- 0.9.1
-
-
-
-
-
-
-
- StrikeIron
- strikeiron/currency_import_strikeiron
-
-
-
-
-
-
- Mage_Strikeiron_Model
- strikeiron_mysql4
-
-
- Mage_Strikeiron_Model_Mysql4
-
-
-
-
-
-
-
-
-
-
- Mage_Strikeiron
-
-
-
-
-
-
-
- strikeiron/strikeiron
- customerSaveBeforeObserver
-
-
-
-
-
-
- strikeiron/strikeiron
- addressSaveBeforeObserver
-
-
-
-
-
-
- strikeiron/strikeiron
- getTaxRate
-
-
-
-
-
-
-
- Strikeiron Email Update Warnings
- strikeiron_email_warning.html
- text
-
-
-
-
-
-
-
-
-
-
-
- accept
- strikeiron_customer_error_email_template
-
-
- B
- MAX
-
-
-
-
-
-
-
-
- Mage_Strikeiron.csv
-
-
-
-
-
-
-
-
- standard
-
- Mage_Strikeiron
- strikeiron
-
-
-
-
-
diff --git a/app/code/core/Mage/Strikeiron/etc/system.xml b/app/code/core/Mage/Strikeiron/etc/system.xml
deleted file mode 100644
index 891cc70b65..0000000000
--- a/app/code/core/Mage/Strikeiron/etc/system.xml
+++ /dev/null
@@ -1,291 +0,0 @@
-
-
-
-
-
- Strikeiron
- service
- text
- 100
- 1
- 1
- 1
-
-
- Strikeiron Config
- text
- 1
- 1
- 1
- 1
-
-
- User ID
- obscure
- adminhtml/system_config_backend_encrypted
- 1
- 1
- 1
- 1
-
-
- Password
- obscure
- adminhtml/system_config_backend_encrypted
- 2
- 1
- 1
- 0
-
-
-
-
- Email Verification
- text
- 2
- 1
- 1
- 1
-
-
- Enable email verification
- select
- adminhtml/system_config_source_enabledisable
- 1
- 1
- 1
- 1
-
-
- Verify email in admin
- select
- adminhtml/system_config_source_yesno
- 2
- 1
- 1
- 1
-
-
- Check all email servers
- select
- adminhtml/system_config_source_yesno
- 3
- 1
- 1
- 1
-
-
- Undetermined email action
- select
- strikeiron/source_undeterminedEmailAction
- 4
- 1
- 1
- 1
-
-
- Error Email Recipient
- text
- 5
- 1
- 1
- 1
-
-
- Error Email Sender
- select
- adminhtml/system_config_source_email_identity
- 6
- 1
- 1
- 0
-
-
- Error Email Template
- select
- adminhtml/system_config_source_email_template
- 7
- 1
- 1
- 0
-
-
-
-
- Foreign Exchange Rates
- text
- 3
- 1
- 1
- 1
-
-
- Enable foreign exchange rate
- select
- adminhtml/system_config_source_enabledisable
- 10
- 1
- 1
- 1
-
-
-
-
- US Address Verification
- text
- 4
- 1
- 1
- 1
-
-
- Enable US address verification
- select
- adminhtml/system_config_source_enabledisable
- 1
- 1
- 1
- 1
-
-
- Verify address in admin
- select
- adminhtml/system_config_source_yesno
- 2
- 1
- 1
- 1
-
-
- Error address action
- select
- strikeiron/source_errorAddressAction
- 4
- 1
- 1
- 1
-
-
-
-
- Global Address Verification
- text
- 5
- 1
- 1
- 1
-
-
- Enable global address verification
- select
- adminhtml/system_config_source_enabledisable
- 1
- 1
- 1
- 1
-
-
- Verify address in admin
- select
- adminhtml/system_config_source_yesno
- 2
- 1
- 1
- 1
-
-
- Error address action
- select
- strikeiron/source_errorAddressAction
- 4
- 1
- 1
- 1
-
-
-
-
- Sales and Use Tax
- text
- 6
- 1
- 1
- 1
-
-
- Enable sales and use tax
- select
- adminhtml/system_config_source_enabledisable
- 1
- 1
- 1
- 1
-
-
- Sales and Use Tax Type
- select
- strikeiron/source_salesTaxType
- 3
- 1
- 1
- 1
-
-
- Use
- If type is complete and zip code belongs to multiple tax rates, choose to charge minimum tax rate or maximum tax rate.
- select
- strikeiron/source_salestaxminmax
- 4
- 1
- 1
- 1
-
-
- Customer Tax Class
- multiselect
- tax/class_source_customer
- 5
- 1
- 1
- 1
-
-
- Product Tax Class
- multiselect
- tax/class_source_product
- 6
- 1
- 1
- 1
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Strikeiron/sql/strikeiron_setup/mysql4-install-0.9.1.php b/app/code/core/Mage/Strikeiron/sql/strikeiron_setup/mysql4-install-0.9.1.php
deleted file mode 100644
index 4c259523c8..0000000000
--- a/app/code/core/Mage/Strikeiron/sql/strikeiron_setup/mysql4-install-0.9.1.php
+++ /dev/null
@@ -1,48 +0,0 @@
-startSetup();
-
-$installer->run("
-/*Table structure for table `strikeiron_tax_rate` */
-
-DROP TABLE IF EXISTS {$this->getTable('strikeiron_tax_rate')};
-
-CREATE TABLE {$this->getTable('strikeiron_tax_rate')} (
- `tax_rate_id` tinyint(4) NOT NULL auto_increment,
- `tax_country_id` varchar(6) default NULL,
- `tax_region_id` mediumint(9) unsigned default NULL,
- `tax_postcode` varchar(12) default NULL,
- `rate_value` decimal(12,4) NOT NULL default '0.0000',
- PRIMARY KEY (`tax_rate_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Strikeiron tax rates';
-
- ");
-
-$installer->endSetup();
diff --git a/app/code/core/Mage/Tag/controllers/IndexController.php b/app/code/core/Mage/Tag/controllers/IndexController.php
index 364d624c30..e13a06b720 100644
--- a/app/code/core/Mage/Tag/controllers/IndexController.php
+++ b/app/code/core/Mage/Tag/controllers/IndexController.php
@@ -87,7 +87,8 @@ public function saveAction()
}
}
else {
- $tagModel->setFirstCustomerId($customerId);
+ $tagModel->setFirstCustomerId($customerId)
+ ->setFirstStoreId(Mage::app()->getStore()->getId());
$status = $tagModel->getPendingStatus();
$newCount++;
}
diff --git a/app/code/core/Mage/Tag/etc/config.xml b/app/code/core/Mage/Tag/etc/config.xml
index 5e6f55bf11..02a3874433 100644
--- a/app/code/core/Mage/Tag/etc/config.xml
+++ b/app/code/core/Mage/Tag/etc/config.xml
@@ -28,7 +28,7 @@
- 0.7.4
+ 0.7.5
diff --git a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.0-0.8.1.php b/app/code/core/Mage/Tag/sql/tag_setup/mysql4-upgrade-0.7.4-0.7.5.php
old mode 100755
new mode 100644
similarity index 59%
rename from app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.0-0.8.1.php
rename to app/code/core/Mage/Tag/sql/tag_setup/mysql4-upgrade-0.7.4-0.7.5.php
index 99f7100ed9..e79e7f9bed
--- a/app/code/core/Mage/Oscommerce/sql/oscommerce_setup/mysql4-upgrade-0.8.0-0.8.1.php
+++ b/app/code/core/Mage/Tag/sql/tag_setup/mysql4-upgrade-0.7.4-0.7.5.php
@@ -19,29 +19,25 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Oscommerce
+ * @package Mage_Tag
* @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)
*/
-$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */
-
+$installer = $this;
$installer->startSetup();
-
-$installer->run("
-
-DROP TABLE IF EXISTS `{$this->getTable('oscommerce_import_type')}`;
-
-CREATE TABLE `{$this->getTable('oscommerce_import_type')}` (
- `type_id` int(2) unsigned NOT NULL auto_increment,
- `type_code` varchar(32) NOT NULL,
- `type_name` varchar(255) NOT NULL,
- PRIMARY KEY (`type_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-insert into `{$this->getTable('oscommerce_import_type')}`(`type_code`,`type_name`) values ('website', 'Website'),('store','Store'),('category','Category'),('product','Product'), ('customer','Customer'),('order','Order');
-
-");
+$installer->getConnection()->addColumn($installer->getTable('tag/tag'), 'first_store_id', "smallint(5) UNSIGNED NOT NULL DEFAULT '0'");
+
+$groupedTags = $installer->getConnection()->select()
+ ->from($installer->getTable('tag/relation'))->group('tag_id')->order('created_at ASC');
+$select = $installer->getConnection()->select()
+ ->reset()
+ ->joinInner(array('relation_table' => new Zend_Db_Expr("({$groupedTags->__toString()})")),
+ 'relation_table.tag_id = main_table.tag_id', null)
+ ->columns(array('first_store_id' => 'store_id'));
+
+$updateSql = $select->crossUpdateFromSelect(array('main_table' => $installer->getTable('tag/tag')));
+$installer->getConnection()->query($updateSql);
$installer->endSetup();
diff --git a/app/code/core/Mage/Tax/Block/Sales/Order/Tax.php b/app/code/core/Mage/Tax/Block/Sales/Order/Tax.php
index 16a3b9fd76..94beeb6494 100644
--- a/app/code/core/Mage/Tax/Block/Sales/Order/Tax.php
+++ b/app/code/core/Mage/Tax/Block/Sales/Order/Tax.php
@@ -156,8 +156,9 @@ protected function _initSubtotal()
$parent->addTotal($totalIncl, 'subtotal_excl');
$parent->removeTotal('subtotal');
} elseif ($this->_config->displaySalesSubtotalInclTax($store)) {
- $subtotalIncl = $this->_source->getSubtotalInclTax();
- $baseSubtotalIncl= $this->_source->getBaseSubtotalInclTax();
+ $subtotalIncl = (float) $this->_source->getSubtotalInclTax();
+ $baseSubtotalIncl= (float) $this->_source->getBaseSubtotalInclTax();
+
if (!$subtotalIncl) {
$subtotalIncl = $this->_source->getSubtotal()
+ $this->_source->getTaxAmount()
diff --git a/app/code/core/Mage/Tax/Helper/Data.php b/app/code/core/Mage/Tax/Helper/Data.php
index a8c7c4e022..1b5b9031c6 100644
--- a/app/code/core/Mage/Tax/Helper/Data.php
+++ b/app/code/core/Mage/Tax/Helper/Data.php
@@ -182,7 +182,7 @@ public function needPriceConversion($store = null)
case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH:
return self::PRICE_CONVERSION_MINUS;
case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX:
- $res = false;
+ $res = true;
}
} else {
switch ($this->getPriceDisplayType($store)) {
@@ -451,10 +451,20 @@ public function getPrice($product, $price, $includingTax = null, $shippingAddres
if ($includingPercent != $percent) {
$price = $this->_calculatePrice($price, $includingPercent, false);
/**
- * Round up price excluding tax if customer tax rate !=0
+ * Using regular rounding. Ex:
+ * price incl tax = 52.76
+ * store tax rate = 19.6%
+ * customer tax rate= 19%
+ *
+ * price excl tax = 52.76 / 1.196 = 44.11371237 ~ 44.11
+ * tax = 44.11371237 * 0.19 = 8.381605351 ~ 8.38
+ * price incl tax = 52.49531773 ~ 52.50 != 52.49
+ *
+ * that why we need round prices excluding tax before applying tax
+ * this calculation is used for showing prices on catalog pages
*/
if ($percent != 0) {
- $price = $this->getCalculator()->roundUp($price);
+ $price = $this->getCalculator()->round($price);
$price = $this->_calculatePrice($price, $percent, true);
}
}
diff --git a/app/code/core/Mage/Tax/Model/Calculation.php b/app/code/core/Mage/Tax/Model/Calculation.php
index 0fe83a434c..9d8b4583af 100644
--- a/app/code/core/Mage/Tax/Model/Calculation.php
+++ b/app/code/core/Mage/Tax/Model/Calculation.php
@@ -186,7 +186,7 @@ public function getRate($request)
$this->unsRateValue();
$this->unsCalculationProcess();
$this->unsEventModuleId();
- Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$this));
+ Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$request));
if (!$this->hasRateValue()) {
$rateInfo = $this->_getResource()->getRateInfo($request);
$this->setCalculationProcess($rateInfo['process']);
@@ -414,7 +414,6 @@ public function getRatesByCustomerAndProductTaxClasses($customerTaxClass, $produ
/**
* Calculate rated tax abount based on price and tax rate.
* If you are using price including tax $priceIncludeTax should be true.
- * $taxRate can't be more than 1 (if it is not percent)
*
* @param float $price
* @param float $taxRate
@@ -423,12 +422,7 @@ public function getRatesByCustomerAndProductTaxClasses($customerTaxClass, $produ
*/
public function calcTaxAmount($price, $taxRate, $priceIncludeTax=false, $round=true)
{
- /**
- * $taxRate can be more than 1 if somebody use tax percent
- */
- if ($taxRate>1) {
- $taxRate = $taxRate/100;
- }
+ $taxRate = $taxRate/100;
if ($priceIncludeTax) {
$amount = $price*(1-1/(1+$taxRate));
diff --git a/app/code/core/Mage/Tax/Model/Mysql4/Tax.php b/app/code/core/Mage/Tax/Model/Mysql4/Tax.php
index c1810399bb..016d11dbfc 100644
--- a/app/code/core/Mage/Tax/Model/Mysql4/Tax.php
+++ b/app/code/core/Mage/Tax/Model/Mysql4/Tax.php
@@ -61,7 +61,7 @@ public function aggregate($from = null, $to = null)
}
$subQuery = $writeAdapter->select();
- $subQuery->from(array('so'=>'sales_order'), array('DISTINCT DATE(so.created_at)'))
+ $subQuery->from(array('so' => $this->getTable('sales/order')), array('DISTINCT DATE(so.created_at)'))
->where($where);
$deleteCondition = 'DATE(period) IN (' . new Zend_Db_Expr($subQuery) . ')';
diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php
index 11a12ed55b..d56e2a6c36 100644
--- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php
+++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php
@@ -266,8 +266,8 @@ protected function _recollectItem($address, Mage_Sales_Model_Quote_Item_Abstract
$this->_baseSubtotalInclTax += $baseSubtotal;
if ($this->_config->getAlgorithm($store) == Mage_Tax_Model_Calculation::CALC_UNIT_BASE) {
- $taxAmount = $this->_calculator->calcTaxAmount($taxPrice, $rate, true)*$qty;
- $baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxPrice, $rate, true)*$qty;
+ $taxAmount = $this->_calculator->calcTaxAmount($taxPrice, $rate, true);
+ $baseTaxAmount = $this->_calculator->calcTaxAmount($baseTaxPrice, $rate, true);
$unitPrice = $this->_calculator->round($price-$taxAmount);
$baseUnitPrice = $this->_calculator->round($basePrice-$baseTaxAmount);
$subtotal = $this->_calculator->round($unitPrice*$qty);
diff --git a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php
index 277264a46d..cc31538d91 100644
--- a/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php
+++ b/app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php
@@ -190,14 +190,23 @@ protected function _calculateShippingTax(Mage_Sales_Model_Quote_Address $address
$rate = $this->_calculator->getRate($taxRateRequest);
if ($rate) {
if ($this->_config->shippingPriceIncludesTax($store) && $this->_areTaxRequestsSimilar) {
- $shippingTax = $this->_calculator->calcTaxAmount($calcAmount, $rate, true);
- $shippingBaseTax= $this->_calculator->calcTaxAmount($baseCalcAmount, $rate, true);
+ $shippingTax = $this->_calculator->calcTaxAmount($calcAmount, $rate, true, false);
+ $shippingBaseTax= $this->_calculator->calcTaxAmount($baseCalcAmount, $rate, true, false);
$shippingAmount-= $shippingTax;
$baseShippingAmount-=$shippingBaseTax;
} else {
- $shippingTax = $this->_calculator->calcTaxAmount($calcAmount, $rate);
- $shippingBaseTax= $this->_calculator->calcTaxAmount($baseCalcAmount, $rate);
+ $shippingTax = $this->_calculator->calcTaxAmount($calcAmount, $rate, false, false);
+ $shippingBaseTax= $this->_calculator->calcTaxAmount($baseCalcAmount, $rate, false, false);
}
+ $rateKey = (string) $rate;
+ if (isset($this->_roundingDeltas[$rateKey])) {
+ $shippingTax+= $this->_roundingDeltas[$rateKey];
+ }
+ if (isset($this->_baseRoundingDeltas[$rateKey])) {
+ $shippingBaseTax+= $this->_baseRoundingDeltas[$rateKey];
+ }
+ $shippingTax = $this->_calculator->round($shippingTax);
+ $shippingBaseTax = $this->_calculator->round($shippingBaseTax);
$address->setTotalAmount('shipping', $shippingAmount);
$address->setBaseTotalAmount('shipping', $baseShippingAmount);
@@ -743,7 +752,7 @@ public function fetch(Mage_Sales_Model_Quote_Address $address)
* Modify subtotal
*/
if ($this->_config->displayCartSubtotalBoth($store) || $this->_config->displayCartSubtotalInclTax($store)) {
- if ($address->getSubtotalInclTax()) {
+ if ($address->getSubtotalInclTax() > 0) {
$subtotalInclTax = $address->getSubtotalInclTax();
} else {
$subtotalInclTax = $address->getSubtotal()+$address->getTaxAmount()-$address->getShippingTaxAmount();
diff --git a/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.10-0.7.11.php b/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.10-0.7.11.php
index a354752b1f..aaec52a4d6 100644
--- a/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.10-0.7.11.php
+++ b/app/code/core/Mage/Tax/sql/tax_setup/mysql4-upgrade-0.7.10-0.7.11.php
@@ -30,8 +30,7 @@
$installer->startSetup();
$installer->run("
- CREATE TABLE IF NOT EXISTS `{$installer->getTable('tax_order_aggregated_created')}`
- (
+ CREATE TABLE `{$installer->getTable('tax_order_aggregated_created')}` (
`id` int(11) unsigned NOT NULL auto_increment,
`period` date NOT NULL DEFAULT '0000-00-00',
`store_id` smallint(5) unsigned NULL DEFAULT NULL,
@@ -41,11 +40,18 @@
`orders_count` int(11) unsigned NOT NULL default '0',
`tax_base_amount_sum` float(12,4) NOT NULL default '0.0000',
PRIMARY KEY (`id`),
- UNIQUE KEY `UNQ_TAX_ORDER_AGGREGATED_CREATED_PERIOD_STORE_CODE` (`period`,`store_id`, `code`, `order_status`),
- KEY `FK_TAX_ORDER_AGGREGATED_CREATED_STORE` (`store_id`),
- CONSTRAINT `FK_TAX_ORDER_AGGREGATED_CREATED_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ UNIQUE KEY `UNQ_PERIOD_STORE_CODE_ORDER_STATUS` (`period`,`store_id`, `code`, `order_status`),
+ KEY `IDX_STORE_ID` (`store_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
+$installer->getConnection()->addConstraint(
+ 'FK_TAX_ORDER_AGGREGATED_CREATED_STORE',
+ $this->getTable('tax_order_aggregated_created'),
+ 'store_id',
+ $this->getTable('core_store'),
+ 'store_id'
+);
+
$installer->endSetup();
diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php
index 85f4a4b5a4..979b7b17ba 100644
--- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php
+++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Abstract.php
@@ -88,24 +88,31 @@ public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $r
}
$maxAllowedWeight = (float) $this->getConfigData('max_package_weight');
- $error = null;
+ $errorMsg = '';
+ $configErrorMsg = $this->getConfigData('specificerrmsg');
+ $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
$showMethod = $this->getConfigData('showmethod');
foreach ($request->getAllItems() as $item) {
if ($item->getProduct() && $item->getProduct()->getId()) {
if ($item->getProduct()->getWeight() > $maxAllowedWeight) {
- $error = Mage::getModel('shipping/rate_result_error');
- $error->setCarrier($this->_code)
- ->setCarrierTitle($this->getConfigData('title'));
- $errorMsg = $this->getConfigData('specificerrmsg');
- $error->setErrorMessage($errorMsg?$errorMsg:Mage::helper('shipping')->__('The shipping module is not available.'));
+ $errorMsg = ($configErrorMsg) ? $configErrorMsg : $defaultErrorMsg;
break;
}
}
}
- if (null !== $error && $showMethod) {
+
+ if (!$errorMsg && !$request->getDestPostcode() && $this->isZipCodeRequired()) {
+ $errorMsg = Mage::helper('shipping')->__('This shipping method is not available, please specify ZIP-code');
+ }
+
+ if ($errorMsg && $showMethod) {
+ $error = Mage::getModel('shipping/rate_result_error');
+ $error->setCarrier($this->_code);
+ $error->setCarrierTitle($this->getConfigData('title'));
+ $error->setErrorMessage($errorMsg);
return $error;
- } elseif (null !== $error) {
+ } elseif ($errorMsg) {
return false;
}
return $this;
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 ebbfe59d74..4b4937d0b1 100644
--- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php
+++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php
@@ -377,25 +377,40 @@ public function getCode($type, $code='')
*/
'service_to_code'=>array(
- 'First-Class' => 'FIRST CLASS',
- 'Express Mail' => 'EXPRESS',
- 'Express Mail PO to PO' => 'EXPRESS',
- 'Priority Mail' => 'PRIORITY',
+ 'First-Class' => 'FIRST CLASS',
+ 'First-Class Mail International Large Envelope' => 'FIRST CLASS',
+ 'First-Class Mail International Letters' => 'FIRST CLASS',
+ 'First-Class Mail International Package' => 'FIRST CLASS',
+ 'First-Class Mail' => 'FIRST CLASS',
+ 'First-Class Mail Flat' => 'FIRST CLASS',
+ 'First-Class Mail International' => 'FIRST CLASS',
+ 'First-Class Mail Letter' => 'FIRST CLASS',
+ 'First-Class Mail Parcel' => 'FIRST CLASS',
'Parcel Post' => 'PARCEL',
- 'Express Mail Flat-Rate Envelope' => 'EXPRESS',
- 'Priority Mail Flat-Rate Box' => 'PRIORITY',
'Bound Printed Matter' => 'BPM',
'Media Mail' => 'MEDIA',
'Library Mail' => 'LIBRARY',
- 'Priority Mail Flat-Rate Envelope' => 'PRIORITY',
- 'Global Express Guaranteed' => 'EXPRESS',
+ 'Express Mail' => 'EXPRESS',
+ 'Express Mail PO to PO' => 'EXPRESS',
+ 'Express Mail Flat Rate Envelope' => 'EXPRESS',
+ 'Express Mail Flat Rate Envelope Hold For Pickup' => 'EXPRESS',
+ 'Global Express Guaranteed (GXG)' => 'EXPRESS',
'Global Express Guaranteed Non-Document Rectangular' => 'EXPRESS',
'Global Express Guaranteed Non-Document Non-Rectangular' => 'EXPRESS',
- 'Express Mail International (EMS)' => 'EXPRESS',
- 'Express Mail International (EMS) Flat-Rate Envelope' => 'EXPRESS',
+ 'Express Mail International' => 'EXPRESS',
+ 'Express Mail International Flat Rate Envelope' => 'EXPRESS',
+ 'Priority Mail' => 'PRIORITY',
+ 'Priority Mail Small Flat Rate Box' => 'PRIORITY',
+ 'Priority Mail Medium Flat Rate Box' => 'PRIORITY',
+ 'Priority Mail Large Flat Rate Box' => 'PRIORITY',
+ 'Priority Mail Flat Rate Box' => 'PRIORITY',
+ 'Priority Mail Flat Rate Envelope' => 'PRIORITY',
'Priority Mail International' => 'PRIORITY',
- 'Priority Mail International Flat-Rate Box' => 'PRIORITY',
- 'Priority Mail International Large Flat-Rate Box' => 'PRIORITY'
+ 'Priority Mail International Flat Rate Envelope' => 'PRIORITY',
+ 'Priority Mail International Small Flat Rate Box' => 'PRIORITY',
+ 'Priority Mail International Medium Flat Rate Box' => 'PRIORITY',
+ 'Priority Mail International Large Flat Rate Box' => 'PRIORITY',
+ 'Priority Mail International Flat Rate Box' => 'PRIORITY'
),
'first_class_mail_type'=>array(
diff --git a/app/code/core/Mage/Usa/etc/config.xml b/app/code/core/Mage/Usa/etc/config.xml
index dafc41d5ec..7c337de8d3 100644
--- a/app/code/core/Mage/Usa/etc/config.xml
+++ b/app/code/core/Mage/Usa/etc/config.xml
@@ -170,14 +170,14 @@
0
0
- Bound Printed Matter,Express Mail,Express Mail Flat-Rate Envelope,Express Mail Flat-Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International (EMS),Express Mail International (EMS) Flat-Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First Class Mail International Large Envelope,First Class Mail International Letters,First Class Mail International Package,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,Global Express Guaranteed,Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Flat-Rate Box,Priority Mail Flat-Rate Envelope,Priority Mail International,Priority Mail International Flat-Rate Box,Priority Mail International Flat-Rate Envelope,Priority Mail International Large Flat-Rate Box,Priority Mail Large Flat-Rate Box,USPS GXG Envelopes
+ Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes
VARIABLE
http://production.shippingapis.com/ShippingAPI.dll
true
- Bound Printed Matter,Express Mail,Express Mail Flat-Rate Envelope,Express Mail Flat-Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International (EMS),Express Mail International (EMS) Flat-Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First Class Mail International Large Envelope,First Class Mail International Letters,First Class Mail International Package,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,Global Express Guaranteed,Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Flat-Rate Box,Priority Mail Flat-Rate Envelope,Priority Mail International,Priority Mail International Flat-Rate Box,Priority Mail International Flat-Rate Envelope,Priority Mail International Large Flat-Rate Box,Priority Mail Large Flat-Rate Box,USPS GXG Envelopes
+ Bound Printed Matter,Express Mail,Express Mail Flat Rate Envelope,Express Mail Flat Rate Envelope Hold For Pickup,Express Mail Flat-Rate Envelope Sunday/Holiday Guarantee,Express Mail Hold For Pickup,Express Mail International,Express Mail International Flat Rate Envelope,Express Mail PO to PO,Express Mail Sunday/Holiday Guarantee,First-Class Mail International Large Envelope,First-Class Mail International Letters,First-Class Mail International Package,First-Class,First-Class Mail,First-Class Mail Flat,First-Class Mail International,First-Class Mail Letter,First-Class Mail Parcel,Global Express Guaranteed (GXG),Global Express Guaranteed Non-Document Non-Rectangular,Global Express Guaranteed Non-Document Rectangular,Library Mail,Media Mail,Parcel Post,Priority Mail,Priority Mail Small Flat Rate Box,Priority Mail Medium Flat Rate Box,Priority Mail Large Flat Rate Box,Priority Mail Flat Rate Box,Priority Mail Flat Rate Envelope,Priority Mail International,Priority Mail International Flat Rate Box,Priority Mail International Flat Rate Envelope,Priority Mail International Small Flat Rate Box,Priority Mail International Medium Flat Rate Box,Priority Mail International Large Flat Rate Box,USPS GXG Envelopes
usa/shipping_carrier_usps
REGULAR
United States Postal Service
diff --git a/app/code/core/Mage/Usa/etc/system.xml b/app/code/core/Mage/Usa/etc/system.xml
index 3e4b8968c1..83146b1abd 100644
--- a/app/code/core/Mage/Usa/etc/system.xml
+++ b/app/code/core/Mage/Usa/etc/system.xml
@@ -62,6 +62,7 @@
1
1
0
+ 1
Package Description
@@ -241,6 +242,7 @@
1
1
0
+ 1
Show method if not applicable
@@ -350,6 +352,7 @@
1
1
0
+ 1
@@ -360,6 +363,7 @@
1
1
0
+ 1
@@ -399,6 +403,7 @@
1
1
0
+ 1
Free shipping with minimum order amount
@@ -530,6 +535,7 @@
1
1
0
+ 1
Show method if not applicable
@@ -585,6 +591,7 @@
1
1
0
+ 1
Container
@@ -795,6 +802,7 @@
1
1
0
+ 1
Show method if not applicable
@@ -851,6 +859,7 @@
1
1
0
+ 1
Container
@@ -991,6 +1000,7 @@
1
1
0
+ 1
Show method if not applicable
diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php
index 79fb1e2e12..fb1a2b3cdd 100644
--- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php
+++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php
@@ -49,7 +49,7 @@ public function __construct()
$this->_updateButton('save', 'id', 'insert_button');
$this->_updateButton('save', 'onclick', 'wWidget.insertWidget()');
- $this->_formScripts[] = 'wWidget = new WysiwygWidget.Widget("edit_form", "select_widget_type", "widget_options", "'
+ $this->_formScripts[] = 'wWidget = new WysiwygWidget.Widget("widget_options_form", "select_widget_type", "widget_options", "'
. $this->getUrl('*/*/loadOptions').'", "' . $this->getRequest()->getParam('widget_target_id') . '");';
}
}
diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Form.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Form.php
index fad7a12922..3d8484951c 100644
--- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Form.php
+++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Form.php
@@ -55,7 +55,7 @@ protected function _prepareForm()
));
$form->setUseContainer(true);
- $form->setId('edit_form');
+ $form->setId('widget_options_form');
$form->setMethod('post');
$form->setAction($this->getUrl('*/*/buildWidget'));
$this->setForm($form);
diff --git a/app/code/core/Mage/Widget/Model/Template/Filter.php b/app/code/core/Mage/Widget/Model/Template/Filter.php
index ec5f0f3727..10ace77207 100644
--- a/app/code/core/Mage/Widget/Model/Template/Filter.php
+++ b/app/code/core/Mage/Widget/Model/Template/Filter.php
@@ -60,7 +60,13 @@ public function widgetDirective($construction)
} else {
return '';
}
-
+
+ // we have no other way to avoid fatal errors for type like 'cms/widget__link', '_cms/widget_link' etc.
+ $xml = Mage::getSingleton('widget/widget')->getXmlElementByType($type);
+ if ($xml === null) {
+ return '';
+ }
+
// define widget block and check the type is instance of Widget Interface
$widget = Mage::app()->getLayout()->createBlock($type, $name, $params);
if (!$widget instanceof Mage_Widget_Block_Interface) {
diff --git a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php
index e8f0b10ea8..cef4cc48b9 100644
--- a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php
+++ b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php
@@ -66,6 +66,8 @@ protected function _initAction()
*/
protected function _initWidgetInstance()
{
+ $this->_title($this->__('CMS'))->_title($this->__('Widgets'));
+
$widgetInstance = Mage::getModel('widget/widget_instance');
$instanceId = $this->getRequest()->getParam('instance_id', null);
$type = $this->getRequest()->getParam('type', null);
@@ -92,6 +94,8 @@ protected function _initWidgetInstance()
*/
public function indexAction()
{
+ $this->_title($this->__('CMS'))->_title($this->__('Widgets'));
+
$this->_initAction()
->renderLayout();
}
@@ -116,6 +120,9 @@ public function editAction()
$this->_redirect('*/*/');
return;
}
+
+ $this->_title($widgetInstance->getId() ? $widgetInstance->getTitle() : $this->__('New Instance'));
+
$this->_initAction();
$this->renderLayout();
}
diff --git a/app/code/core/Mage/Wishlist/Controller/Abstract.php b/app/code/core/Mage/Wishlist/Controller/Abstract.php
index 4b37f5c8e8..3d4befa38f 100644
--- a/app/code/core/Mage/Wishlist/Controller/Abstract.php
+++ b/app/code/core/Mage/Wishlist/Controller/Abstract.php
@@ -149,7 +149,7 @@ public function allcartAction()
if ($addedItems) {
$products = array();
foreach ($addedItems as $product) {
- $products[] = '"' . $item->getProduct()->getName() . '"';
+ $products[] = '"' . $product->getName() . '"';
}
Mage::getSingleton('checkout/session')->addSuccess(
diff --git a/app/design/frontend/default/modern/layout/reports.xml b/app/design/adminhtml/default/default/layout/adminnotification.xml
similarity index 66%
rename from app/design/frontend/default/modern/layout/reports.xml
rename to app/design/adminhtml/default/default/layout/adminnotification.xml
index c25564b4b8..bb07c1f84b 100644
--- a/app/design/frontend/default/modern/layout/reports.xml
+++ b/app/design/adminhtml/default/default/layout/adminnotification.xml
@@ -20,18 +20,19 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
- * @package default_modern
+ * @package default_default
* @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)
*/
-
-->
-
+
+
-
-
-
-
+
+
+
+
+
diff --git a/app/design/adminhtml/default/default/layout/centinel.xml b/app/design/adminhtml/default/default/layout/centinel.xml
new file mode 100644
index 0000000000..182521d902
--- /dev/null
+++ b/app/design/adminhtml/default/default/layout/centinel.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/design/adminhtml/default/default/layout/main.xml b/app/design/adminhtml/default/default/layout/main.xml
index 7bc5c85d02..f45d3f33e3 100644
--- a/app/design/adminhtml/default/default/layout/main.xml
+++ b/app/design/adminhtml/default/default/layout/main.xml
@@ -79,6 +79,8 @@ Default layout, loads most of the pages
skin_css below_ie7.css lt IE 7
skin_css ie7.css IE 7
+ print.css media="print"
+
js lib/ds-sleight.js defer lt IE 7
js varien/iehover-fix.js lt IE 7
@@ -104,9 +106,9 @@ Default layout, loads most of the pages
-
+
@@ -122,7 +124,6 @@ Default layout, loads most of the pages
-
@@ -157,6 +158,7 @@ Layout for editor element
+
diff --git a/app/design/adminhtml/default/default/template/api/role_users_grid_js.phtml b/app/design/adminhtml/default/default/template/api/role_users_grid_js.phtml
index 3120563800..4939f5b274 100644
--- a/app/design/adminhtml/default/default/template/api/role_users_grid_js.phtml
+++ b/app/design/adminhtml/default/default/template/api/role_users_grid_js.phtml
@@ -55,14 +55,14 @@
if ( !confirm("__('Warning!\r\nThis action will remove this user from already assigned role\r\nAre you sure?') ?>") ) {
checkbox[0].checked = false;
for(i in checkBoxes) {
- if( checkBoxes[i].status == 1) {
+ if( checkBoxes[i].status == 1) {
checkBoxes[i].object.checked = true;
}
}
return false;
}
warning = false;
- }
+ }
getJsObjectName() ?>.setCheckboxChecked(checkbox[0], checked);
}
}
@@ -81,7 +81,7 @@
if ( !confirm("__('Warning!\r\nThis action will remove those users from already assigned roles\r\nAre you sure?') ?>") ) {
o.checked = false;
for(i in checkBoxes) {
- if( checkBoxes[i].status == 1) {
+ if( checkBoxes[i].status == 1) {
checkBoxes[i].object.checked = true;
}
}
@@ -91,12 +91,13 @@
}
for(i in checkBoxes) getJsObjectName() ?>.setCheckboxChecked(checkBoxes[i].object, o.checked);
}
-
+
getJsObjectName() ?>.rowClickCallback = roleUsersRowClick;
getJsObjectName() ?>.initRowCallback = roleUsersRowInit;
getJsObjectName() ?>.checkboxCheckCallback = registerUserRole;
getJsObjectName() ?>.checkCheckboxes = myhandler;
getJsObjectName() ?>.rows.each(function(row){roleUsersRowInit(getJsObjectName() ?>, row)});
+ $('in_role_user_old').value = $('in_role_user').value;
//-->
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 d961556bae..5edb6689df 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
@@ -67,7 +67,7 @@
htmlEscape($_item->getName()) ?>
helper('sales')->__('SKU') ?>:
- ', Mage::helper('catalog')->splitSku($_item->getSku())); ?>
+ ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?>
@@ -397,7 +397,7 @@
- getDescription() ?>
+ htmlEscape($_item->getDescription()) ?>
diff --git a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml
index 5f9c4282de..32dfa14b23 100644
--- a/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml
+++ b/app/design/adminhtml/default/default/template/bundle/sales/creditmemo/view/items/renderer.phtml
@@ -65,7 +65,7 @@
htmlEscape($_item->getName()) ?>
helper('sales')->__('SKU') ?>:
- ', Mage::helper('catalog')->splitSku($_item->getSku())); ?>
+ ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?>
@@ -329,7 +329,7 @@
- getItem()->getDescription() ?>
+ htmlEscape($this->getItem()->getDescription()) ?>
diff --git a/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml
index 071482fc36..44972de5e5 100644
--- a/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml
+++ b/app/design/adminhtml/default/default/template/bundle/sales/invoice/create/items/renderer.phtml
@@ -66,7 +66,7 @@
htmlEscape($_item->getName()) ?>
helper('sales')->__('SKU') ?>:
- ', Mage::helper('catalog')->splitSku($_item->getSku())); ?>
+ ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?>
@@ -385,7 +385,7 @@
- getDescription() ?>
+ htmlEscape($_item->getDescription()) ?>
diff --git a/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml
index 7dc65bfeb3..97e49d4d8b 100644
--- a/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml
+++ b/app/design/adminhtml/default/default/template/bundle/sales/invoice/view/items/renderer.phtml
@@ -65,7 +65,7 @@
htmlEscape($_item->getName()) ?>
helper('sales')->__('SKU') ?>:
- ', Mage::helper('catalog')->splitSku($_item->getSku())); ?>
+ ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?>
getValueHtml($_item)?>
@@ -328,7 +328,7 @@
- getItem()->getDescription() ?>
+ htmlEscape($this->getItem()->getDescription()) ?>
diff --git a/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml
index a1f5be5497..7ae0058920 100644
--- a/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml
+++ b/app/design/adminhtml/default/default/template/bundle/sales/order/view/items/renderer.phtml
@@ -69,7 +69,7 @@
htmlEscape($_item->getName()) ?>
helper('sales')->__('SKU') ?>:
- ', Mage::helper('catalog')->splitSku($_item->getSku())); ?>
+ ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?>
@@ -399,7 +399,7 @@
- getDescription() ?>
+ htmlEscape($_item->getDescription()) ?>
diff --git a/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml
index 62be0d81d3..6ee2d11a18 100644
--- a/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml
+++ b/app/design/adminhtml/default/default/template/bundle/sales/shipment/create/items/renderer.phtml
@@ -61,7 +61,7 @@
htmlEscape($_item->getName()) ?>
helper('sales')->__('SKU') ?>:
- ', Mage::helper('catalog')->splitSku($_item->getSku())); ?>
+ ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?>
@@ -110,7 +110,7 @@
- getDescription() ?>
+ htmlEscape($_item->getDescription()) ?>
diff --git a/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml b/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml
index 691fbb3351..e690e62288 100644
--- a/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml
+++ b/app/design/adminhtml/default/default/template/bundle/sales/shipment/view/items/renderer.phtml
@@ -62,7 +62,7 @@
htmlEscape($_item->getName()) ?>
helper('sales')->__('SKU') ?>:
- ', Mage::helper('catalog')->splitSku($_item->getSku())); ?>
+ ', Mage::helper('catalog')->splitSku($this->htmlEscape($_item->getSku()))); ?>
@@ -108,7 +108,7 @@
- getDescription() ?>
+ htmlEscape($_item->getDescription()) ?>
diff --git a/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml b/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml
index a9a9e5c0a5..a36ba91893 100644
--- a/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml
+++ b/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml
@@ -26,7 +26,7 @@
?>