Version Notes
This extension allows you to delete any useless orders.
Download this release
Release Info
Developer | Suraj Kumawat |
Extension | Expert_Orderdelete |
Version | 1.0.0.1 |
Comparing to | |
See all releases |
Version 1.0.0.1
- app/code/local/Expert/Orderdelete/Block/Adminhtml/Orderdelete.php +21 -0
- app/code/local/Expert/Orderdelete/Block/Adminhtml/Sales/Order/Grid.php +215 -0
- app/code/local/Expert/Orderdelete/Block/Adminhtml/Sales/Order/Render/Delete.php +32 -0
- app/code/local/Expert/Orderdelete/Block/Adminhtml/Sales/Order/View.php +31 -0
- app/code/local/Expert/Orderdelete/Block/Orderdelete.php +26 -0
- app/code/local/Expert/Orderdelete/Helper/Data.php +11 -0
- app/code/local/Expert/Orderdelete/Model/Mysql4/Orderdelete.php +18 -0
- app/code/local/Expert/Orderdelete/Model/Mysql4/Orderdelete/Collection.php +19 -0
- app/code/local/Expert/Orderdelete/Model/Orderdelete.php +19 -0
- app/code/local/Expert/Orderdelete/Model/Status.php +21 -0
- app/code/local/Expert/Orderdelete/controllers/Adminhtml/OrderdeleteController.php +74 -0
- app/code/local/Expert/Orderdelete/controllers/IndexController.php +15 -0
- app/code/local/Expert/Orderdelete/etc/config.xml +124 -0
- app/code/local/Expert/Orderdelete/etc/system.xml +29 -0
- app/code/local/Expert/Orderdelete/sql/orderdelete_setup/mysql4-install-0.1.0.php +22 -0
- app/code/local/Mage/Core/Model/Config.php +1659 -0
- app/etc/modules/Expert_Orderdelete.xml +9 -0
- package.xml +21 -0
app/code/local/Expert/Orderdelete/Block/Adminhtml/Orderdelete.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Expert_Orderdelete_Block_Adminhtml_Orderdelete extends Mage_Adminhtml_Block_Widget_Grid_Container
|
10 |
+
{
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
if (Mage::getStoreConfigFlag('advanced/modules_disable_output/Expert_Orderdelete')) {
|
14 |
+
$this->_controller = 'adminhtml_orderdelete';
|
15 |
+
$this->_blockGroup = 'orderdelete';
|
16 |
+
$this->_headerText = Mage::helper('orderdelete')->__('Delete Order');}
|
17 |
+
// $this->_addButtonLabel = Mage::helper('orderdelete')->__('Add Item');
|
18 |
+
parent::__construct();
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/local/Expert/Orderdelete/Block/Adminhtml/Sales/Order/Grid.php
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Expert_Orderdelete_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
10 |
+
{
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setId('sales_order_grid');
|
15 |
+
$this->setUseAjax(true);
|
16 |
+
$this->setDefaultSort('created_at');
|
17 |
+
$this->setDefaultDir('DESC');
|
18 |
+
$this->setSaveParametersInSession(true);
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Retrieve collection class
|
23 |
+
*
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
protected function _getCollectionClass()
|
27 |
+
{
|
28 |
+
return 'sales/order_grid_collection';
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _prepareCollection()
|
32 |
+
{
|
33 |
+
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
34 |
+
$this->setCollection($collection);
|
35 |
+
return parent::_prepareCollection();
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _prepareColumns()
|
39 |
+
{
|
40 |
+
|
41 |
+
$this->addColumn('real_order_id', array(
|
42 |
+
'header'=> Mage::helper('sales')->__('Order #'),
|
43 |
+
'width' => '80px',
|
44 |
+
'type' => 'text',
|
45 |
+
'index' => 'increment_id',
|
46 |
+
));
|
47 |
+
|
48 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
49 |
+
$this->addColumn('store_id', array(
|
50 |
+
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
|
51 |
+
'index' => 'store_id',
|
52 |
+
'type' => 'store',
|
53 |
+
'store_view'=> true,
|
54 |
+
'display_deleted' => true,
|
55 |
+
));
|
56 |
+
}
|
57 |
+
|
58 |
+
$this->addColumn('created_at', array(
|
59 |
+
'header' => Mage::helper('sales')->__('Purchased On'),
|
60 |
+
'index' => 'created_at',
|
61 |
+
'type' => 'datetime',
|
62 |
+
'width' => '100px',
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('billing_name', array(
|
66 |
+
'header' => Mage::helper('sales')->__('Bill to Name'),
|
67 |
+
'index' => 'billing_name',
|
68 |
+
));
|
69 |
+
|
70 |
+
$this->addColumn('shipping_name', array(
|
71 |
+
'header' => Mage::helper('sales')->__('Ship to Name'),
|
72 |
+
'index' => 'shipping_name',
|
73 |
+
));
|
74 |
+
|
75 |
+
$this->addColumn('base_grand_total', array(
|
76 |
+
'header' => Mage::helper('sales')->__('G.T. (Base)'),
|
77 |
+
'index' => 'base_grand_total',
|
78 |
+
'type' => 'currency',
|
79 |
+
'currency' => 'base_currency_code',
|
80 |
+
));
|
81 |
+
|
82 |
+
$this->addColumn('grand_total', array(
|
83 |
+
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
|
84 |
+
'index' => 'grand_total',
|
85 |
+
'type' => 'currency',
|
86 |
+
'currency' => 'order_currency_code',
|
87 |
+
));
|
88 |
+
|
89 |
+
$this->addColumn('status', array(
|
90 |
+
'header' => Mage::helper('sales')->__('Status'),
|
91 |
+
'index' => 'status',
|
92 |
+
'type' => 'options',
|
93 |
+
'width' => '70px',
|
94 |
+
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
95 |
+
));
|
96 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
97 |
+
if($configValue==1){
|
98 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
99 |
+
$this->addColumn('action',
|
100 |
+
array(
|
101 |
+
'header' => Mage::helper('sales')->__('Action'),
|
102 |
+
'width' => '100px',
|
103 |
+
'type' => 'action',
|
104 |
+
'getter' => 'getId',
|
105 |
+
'renderer' => 'orderdelete/adminhtml_sales_order_render_delete',
|
106 |
+
'filter' => false,
|
107 |
+
'sortable' => false,
|
108 |
+
'index' => 'stores',
|
109 |
+
'is_system' => true,
|
110 |
+
));
|
111 |
+
}
|
112 |
+
}else
|
113 |
+
{
|
114 |
+
$this->addColumn('action',
|
115 |
+
array(
|
116 |
+
'header' => Mage::helper('sales')->__('Action'),
|
117 |
+
'width' => '100px',
|
118 |
+
'type' => 'action',
|
119 |
+
'getter' => 'getId',
|
120 |
+
'renderer' => 'orderdelete/adminhtml_sales_order_render_delete',
|
121 |
+
'filter' => false,
|
122 |
+
'sortable' => false,
|
123 |
+
'index' => 'stores',
|
124 |
+
'is_system' => true,
|
125 |
+
));
|
126 |
+
|
127 |
+
|
128 |
+
}
|
129 |
+
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
|
130 |
+
|
131 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
|
132 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
|
133 |
+
|
134 |
+
return parent::_prepareColumns();
|
135 |
+
}
|
136 |
+
|
137 |
+
protected function _prepareMassaction()
|
138 |
+
{
|
139 |
+
$this->setMassactionIdField('entity_id');
|
140 |
+
$this->getMassactionBlock()->setFormFieldName('order_ids');
|
141 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
142 |
+
|
143 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
|
144 |
+
$this->getMassactionBlock()->addItem('cancel_order', array(
|
145 |
+
'label'=> Mage::helper('sales')->__('Cancel'),
|
146 |
+
'url' => $this->getUrl('*/sales_order/massCancel'),
|
147 |
+
));
|
148 |
+
}
|
149 |
+
|
150 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
|
151 |
+
$this->getMassactionBlock()->addItem('hold_order', array(
|
152 |
+
'label'=> Mage::helper('sales')->__('Hold'),
|
153 |
+
'url' => $this->getUrl('*/sales_order/massHold'),
|
154 |
+
));
|
155 |
+
}
|
156 |
+
|
157 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
|
158 |
+
$this->getMassactionBlock()->addItem('unhold_order', array(
|
159 |
+
'label'=> Mage::helper('sales')->__('Unhold'),
|
160 |
+
'url' => $this->getUrl('*/sales_order/massUnhold'),
|
161 |
+
));
|
162 |
+
}
|
163 |
+
|
164 |
+
$this->getMassactionBlock()->addItem('pdfinvoices_order', array(
|
165 |
+
'label'=> Mage::helper('sales')->__('Print Invoices'),
|
166 |
+
'url' => $this->getUrl('*/sales_order/pdfinvoices'),
|
167 |
+
));
|
168 |
+
|
169 |
+
$this->getMassactionBlock()->addItem('pdfshipments_order', array(
|
170 |
+
'label'=> Mage::helper('sales')->__('Print Packingslips'),
|
171 |
+
'url' => $this->getUrl('*/sales_order/pdfshipments'),
|
172 |
+
));
|
173 |
+
|
174 |
+
$this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
|
175 |
+
'label'=> Mage::helper('sales')->__('Print Credit Memos'),
|
176 |
+
'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
|
177 |
+
));
|
178 |
+
|
179 |
+
$this->getMassactionBlock()->addItem('pdfdocs_order', array(
|
180 |
+
'label'=> Mage::helper('sales')->__('Print All'),
|
181 |
+
'url' => $this->getUrl('*/sales_order/pdfdocs'),
|
182 |
+
));
|
183 |
+
|
184 |
+
$this->getMassactionBlock()->addItem('print_shipping_label', array(
|
185 |
+
'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
|
186 |
+
'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
|
187 |
+
));
|
188 |
+
|
189 |
+
|
190 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
191 |
+
if($configValue==1){
|
192 |
+
|
193 |
+
$this->getMassactionBlock()->addItem('delete_order', array(
|
194 |
+
'label'=> Mage::helper('sales')->__('Delete Order'),
|
195 |
+
'url' => $this->getUrl('orderdelete/adminhtml_orderdelete/massDelete'),
|
196 |
+
'confirm' => Mage::helper('sales')->__('Are you sure you want to delete order?')
|
197 |
+
));
|
198 |
+
}
|
199 |
+
return $this;
|
200 |
+
}
|
201 |
+
public function getRowUrl($row)
|
202 |
+
{
|
203 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
204 |
+
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
|
205 |
+
}
|
206 |
+
return false;
|
207 |
+
}
|
208 |
+
|
209 |
+
public function getGridUrl()
|
210 |
+
{
|
211 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
212 |
+
}
|
213 |
+
|
214 |
+
}
|
215 |
+
?>
|
app/code/local/Expert/Orderdelete/Block/Adminhtml/Sales/Order/Render/Delete.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
class Expert_Orderdelete_Block_Adminhtml_Sales_Order_Render_Delete extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
9 |
+
{
|
10 |
+
public function render(Varien_Object $row)
|
11 |
+
{
|
12 |
+
$getData = $row->getData();
|
13 |
+
$message = Mage::helper('sales')->__('Do you want to Delete this Order?');
|
14 |
+
$orderID = $getData['entity_id'];
|
15 |
+
$view = $this->getUrl('*/sales_order/view',array('order_id' => $orderID));
|
16 |
+
$delete = $this->getUrl('orderdelete/adminhtml_orderdelete/delete',array('order_id' => $orderID));
|
17 |
+
|
18 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
19 |
+
if($configValue==0){
|
20 |
+
$link = '<a href="'.$view.'">View</a><br />';
|
21 |
+
}
|
22 |
+
else{
|
23 |
+
$link = '<a href="'.$view.'">View</a><br />
|
24 |
+
<a href="#" onclick="deleteConfirm(\''.$message.'\', \'' . $delete . '\')">Delete Order</a>';
|
25 |
+
|
26 |
+
}
|
27 |
+
return $link;
|
28 |
+
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
?>
|
app/code/local/Expert/Orderdelete/Block/Adminhtml/Sales/Order/View.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
class Expert_Orderdelete_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
|
11 |
+
{
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
16 |
+
if($configValue==1){
|
17 |
+
$message = Mage::helper('sales')->__('Are you sure you want to Delete this order?');
|
18 |
+
$this->_addButton('button_id', array(
|
19 |
+
'label' => Mage::helper('Sales')->__('Delete Order'),
|
20 |
+
'onclick' => 'deleteConfirm(\''.$message.'\', \'' . $this->getDeleteUrl() . '\')',
|
21 |
+
'class' => 'go'
|
22 |
+
), 0, 100, 'header', 'header');
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getDeleteUrl()
|
27 |
+
{
|
28 |
+
return $this->getUrl('orderdelete/adminhtml_orderdelete/delete', array('_current'=>true));
|
29 |
+
}
|
30 |
+
}
|
31 |
+
?>
|
app/code/local/Expert/Orderdelete/Block/Orderdelete.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
class Expert_Orderdelete_Block_Orderdelete extends Mage_Core_Block_Template
|
9 |
+
{
|
10 |
+
|
11 |
+
public function _prepareLayout()
|
12 |
+
{
|
13 |
+
return parent::_prepareLayout();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getOrderdelete()
|
17 |
+
{
|
18 |
+
$a=1;
|
19 |
+
if($a==1){
|
20 |
+
if (!$this->hasData('orderdelete')) {
|
21 |
+
$this->setData('orderdelete', Mage::registry('orderdelete'));
|
22 |
+
}
|
23 |
+
return $this->getData('orderdelete');
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
app/code/local/Expert/Orderdelete/Helper/Data.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sake
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
class Expert_Orderdelete_Helper_Data extends Mage_Core_Helper_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
}
|
app/code/local/Expert/Orderdelete/Model/Mysql4/Orderdelete.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
class Expert_Orderdelete_Model_Mysql4_Orderdelete extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
13 |
+
if($configValue==1){
|
14 |
+
// Note that the orderdelete_id refers to the key field in your database table.
|
15 |
+
$this->_init('orderdelete/orderdelete', 'orderdelete_id');
|
16 |
+
}
|
17 |
+
}
|
18 |
+
}
|
app/code/local/Expert/Orderdelete/Model/Mysql4/Orderdelete/Collection.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Expert_Orderdelete_Model_Mysql4_Orderdelete_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
+
{
|
11 |
+
public function _construct()
|
12 |
+
{
|
13 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
14 |
+
if($configValue==1){
|
15 |
+
parent::_construct();
|
16 |
+
$this->_init('orderdelete/orderdelete');
|
17 |
+
}
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Expert/Orderdelete/Model/Orderdelete.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Expert_Orderdelete_Model_Orderdelete extends Mage_Core_Model_Abstract
|
10 |
+
{
|
11 |
+
public function _construct()
|
12 |
+
{
|
13 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
14 |
+
if($configValue==1){
|
15 |
+
parent::_construct();
|
16 |
+
$this->_init('orderdelete/orderdelete');
|
17 |
+
}
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Expert/Orderdelete/Model/Status.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Expert_Orderdelete_Model_Status extends Varien_Object
|
10 |
+
{
|
11 |
+
const STATUS_ENABLED = 1;
|
12 |
+
const STATUS_DISABLED = 2;
|
13 |
+
|
14 |
+
static public function getOptionArray()
|
15 |
+
{
|
16 |
+
return array(
|
17 |
+
self::STATUS_ENABLED => Mage::helper('orderdelete')->__('Enabled'),
|
18 |
+
self::STATUS_DISABLED => Mage::helper('orderdelete')->__('Disabled')
|
19 |
+
);
|
20 |
+
}
|
21 |
+
}
|
app/code/local/Expert/Orderdelete/controllers/Adminhtml/OrderdeleteController.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Expert_Orderdelete_Adminhtml_OrderdeleteController extends Mage_Adminhtml_Controller_action
|
10 |
+
{
|
11 |
+
protected function _initAction() {
|
12 |
+
$this->loadLayout()
|
13 |
+
->_setActiveMenu('orderdelete/items')
|
14 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
15 |
+
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
protected function _initOrder()
|
19 |
+
{
|
20 |
+
$id = $this->getRequest()->getParam('order_id');
|
21 |
+
$order = Mage::getModel('sales/order')->load($id);
|
22 |
+
|
23 |
+
if (!$order->getId()) {
|
24 |
+
$this->_getSession()->addError($this->__('This Order is no longer exists.'));
|
25 |
+
$this->_redirect('*/*/');
|
26 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
Mage::register('sales_order', $order);
|
30 |
+
Mage::register('current_order', $order);
|
31 |
+
return $order;
|
32 |
+
}
|
33 |
+
public function indexAction() {
|
34 |
+
$this->_initAction()
|
35 |
+
->renderLayout();
|
36 |
+
}
|
37 |
+
public function deleteAction() {
|
38 |
+
$configValue = Mage::getStoreConfig('sales/orderdelete/enabled');
|
39 |
+
if($configValue==1){
|
40 |
+
|
41 |
+
if($order = $this->_initOrder()) {
|
42 |
+
try {
|
43 |
+
$order->delete()->save();
|
44 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Order deleted'));
|
45 |
+
$this->_redirectUrl(Mage::getBaseUrl().'admin/sales_order/index');
|
46 |
+
} catch (Exception $e) {
|
47 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
48 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('order_ids')));
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
$this->_redirectUrl(Mage::getBaseUrl().'admin/sales_order/index');
|
53 |
+
}
|
54 |
+
public function massDeleteAction() {
|
55 |
+
$orderdeleteIds = $this->getRequest()->getParam('order_ids');
|
56 |
+
if(!is_array($orderdeleteIds)) {
|
57 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
58 |
+
} else {
|
59 |
+
try {
|
60 |
+
foreach ($orderdeleteIds as $orderdeleteId) {
|
61 |
+
Mage::getModel('sales/order')->load($orderdeleteId)->delete();
|
62 |
+
}
|
63 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
64 |
+
Mage::helper('adminhtml')->__(
|
65 |
+
'Total of %d record(s) were successfully deleted', count($orderdeleteIds)
|
66 |
+
)
|
67 |
+
);
|
68 |
+
} catch (Exception $e) {
|
69 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
70 |
+
}
|
71 |
+
}
|
72 |
+
$this->_redirectUrl(Mage::getBaseUrl().'admin/sales_order/index');
|
73 |
+
}
|
74 |
+
}
|
app/code/local/Expert/Orderdelete/controllers/IndexController.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
class Expert_Orderdelete_IndexController extends Mage_Core_Controller_Front_Action
|
9 |
+
{
|
10 |
+
public function indexAction()
|
11 |
+
{
|
12 |
+
$this->loadLayout();
|
13 |
+
$this->renderLayout();
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Expert/Orderdelete/etc/config.xml
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Expert_Orderdelete>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Expert_Orderdelete>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<orderdelete>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Expert_Orderdelete</module>
|
14 |
+
<frontName>orderdelete</frontName>
|
15 |
+
</args>
|
16 |
+
</orderdelete>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<orderdelete>
|
21 |
+
<file>orderdelete.xml</file>
|
22 |
+
</orderdelete>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<orderdelete>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Expert_Orderdelete</module>
|
32 |
+
<frontName>orderdelete</frontName>
|
33 |
+
</args>
|
34 |
+
</orderdelete>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<acl>
|
39 |
+
<resources>
|
40 |
+
<all>
|
41 |
+
<title>Allow Everything</title>
|
42 |
+
</all>
|
43 |
+
<admin>
|
44 |
+
<children>
|
45 |
+
<orderdelete>
|
46 |
+
<title>Deleteorder Module</title>
|
47 |
+
<sort_order>10</sort_order>
|
48 |
+
</orderdelete>
|
49 |
+
</children>
|
50 |
+
</admin>
|
51 |
+
</resources>
|
52 |
+
</acl>
|
53 |
+
<layout>
|
54 |
+
<updates>
|
55 |
+
<orderdelete>
|
56 |
+
<file>orderdelete.xml</file>
|
57 |
+
</orderdelete>
|
58 |
+
</updates>
|
59 |
+
</layout>
|
60 |
+
</adminhtml>
|
61 |
+
<global>
|
62 |
+
<models>
|
63 |
+
|
64 |
+
<orderdelete>
|
65 |
+
<class>Expert_Orderdelete_Model</class>
|
66 |
+
<resourceModel>orderdelete_mysql4</resourceModel>
|
67 |
+
</orderdelete>
|
68 |
+
<orderdelete_mysql4>
|
69 |
+
<class>Expert_Orderdelete_Model_Mysql4</class>
|
70 |
+
<entities>
|
71 |
+
<orderdelete>
|
72 |
+
<table>orderdelete</table>
|
73 |
+
</orderdelete>
|
74 |
+
</entities>
|
75 |
+
</orderdelete_mysql4>
|
76 |
+
</models>
|
77 |
+
<resources>
|
78 |
+
<orderdelete_setup>
|
79 |
+
<setup>
|
80 |
+
<module>Expert_Orderdelete</module>
|
81 |
+
</setup>
|
82 |
+
<connection>
|
83 |
+
<use>core_setup</use>
|
84 |
+
</connection>
|
85 |
+
</orderdelete_setup>
|
86 |
+
<orderdelete_write>
|
87 |
+
<connection>
|
88 |
+
<use>core_write</use>
|
89 |
+
</connection>
|
90 |
+
</orderdelete_write>
|
91 |
+
<orderdelete_read>
|
92 |
+
<connection>
|
93 |
+
<use>core_read</use>
|
94 |
+
</connection>
|
95 |
+
</orderdelete_read>
|
96 |
+
</resources>
|
97 |
+
<blocks>
|
98 |
+
<adminhtml>
|
99 |
+
<rewrite>
|
100 |
+
<sales_order_grid>Expert_Orderdelete_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
|
101 |
+
</rewrite>
|
102 |
+
<rewrite>
|
103 |
+
<sales_order_view>Expert_Orderdelete_Block_Adminhtml_Sales_Order_View</sales_order_view>
|
104 |
+
</rewrite>
|
105 |
+
</adminhtml>
|
106 |
+
<orderdelete>
|
107 |
+
<class>Expert_Orderdelete_Block</class>
|
108 |
+
</orderdelete>
|
109 |
+
</blocks>
|
110 |
+
<helpers>
|
111 |
+
<orderdelete>
|
112 |
+
<class>Expert_Orderdelete_Helper</class>
|
113 |
+
</orderdelete>
|
114 |
+
</helpers>
|
115 |
+
</global>
|
116 |
+
|
117 |
+
<default>
|
118 |
+
<sales>
|
119 |
+
<orderdelete>
|
120 |
+
<enabled>1</enabled>
|
121 |
+
</orderdelete>
|
122 |
+
</sales>
|
123 |
+
</default>
|
124 |
+
</config>
|
app/code/local/Expert/Orderdelete/etc/system.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<sales translate="label" module="orderdelete">
|
5 |
+
<groups>
|
6 |
+
<orderdelete translate="label">
|
7 |
+
<label>Order Delete</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>900</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<enabled translate="label">
|
15 |
+
<label>Enabled</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>1</show_in_store>
|
22 |
+
</enabled>
|
23 |
+
</fields>
|
24 |
+
</orderdelete>
|
25 |
+
</groups>
|
26 |
+
</sales>
|
27 |
+
</sections>
|
28 |
+
</config>
|
29 |
+
|
app/code/local/Expert/Orderdelete/sql/orderdelete_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Sharad Patel
|
4 |
+
* @category Sale
|
5 |
+
* @package Expert_Orderdelete
|
6 |
+
* @copyright Copyright (c) 2013 expertsofttechsolution.com
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
|
14 |
+
-- DROP TABLE IF EXISTS {$this->getTable('orderdelete')};
|
15 |
+
CREATE TABLE {$this->getTable('orderdelete')} (
|
16 |
+
`orderdelete_id` int(11) NOT NULL auto_increment,
|
17 |
+
`internal_company_id` varchar(80) NOT NULL default '',
|
18 |
+
PRIMARY KEY (`orderdelete_id`)
|
19 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
20 |
+
");
|
21 |
+
|
22 |
+
$installer->endSetup();
|
app/code/local/Mage/Core/Model/Config.php
ADDED
@@ -0,0 +1,1659 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Core
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Core configuration class
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Core
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base
|
36 |
+
{
|
37 |
+
const CACHE_TAG = 'CONFIG';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Flag which allow use cache logic
|
41 |
+
*
|
42 |
+
* @var bool
|
43 |
+
*/
|
44 |
+
protected $_useCache = false;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Instructions for spitting config cache
|
48 |
+
* array(
|
49 |
+
* $sectionName => $recursionLevel
|
50 |
+
* )
|
51 |
+
* Recursion level provide availability cache subnodes separatly
|
52 |
+
*
|
53 |
+
* @var array
|
54 |
+
*/
|
55 |
+
protected $_cacheSections = array(
|
56 |
+
'admin' => 0,
|
57 |
+
'adminhtml' => 0,
|
58 |
+
'crontab' => 0,
|
59 |
+
'install' => 0,
|
60 |
+
'stores' => 1,
|
61 |
+
'websites' => 0
|
62 |
+
);
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Loaded Configuration by cached sections
|
66 |
+
*
|
67 |
+
* @var array
|
68 |
+
*/
|
69 |
+
protected $_cacheLoadedSections = array();
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Configuration options
|
73 |
+
*
|
74 |
+
* @var Mage_Core_Model_Config_Options
|
75 |
+
*/
|
76 |
+
protected $_options;
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Storage for generated class names
|
80 |
+
*
|
81 |
+
* @var array
|
82 |
+
*/
|
83 |
+
protected $_classNameCache = array();
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Storage for generated block class names
|
87 |
+
*
|
88 |
+
* @var unknown_type
|
89 |
+
*/
|
90 |
+
protected $_blockClassNameCache = array();
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Storage of validated secure urls
|
94 |
+
*
|
95 |
+
* @var array
|
96 |
+
*/
|
97 |
+
protected $_secureUrlCache = array();
|
98 |
+
|
99 |
+
/**
|
100 |
+
* System environment server variables
|
101 |
+
*
|
102 |
+
* @var array
|
103 |
+
*/
|
104 |
+
protected $_distroServerVars;
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Array which is using for replace placeholders of server variables
|
108 |
+
*
|
109 |
+
* @var array
|
110 |
+
*/
|
111 |
+
protected $_substServerVars;
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Resource model
|
115 |
+
* Used for operations with DB
|
116 |
+
*
|
117 |
+
* @var Mage_Core_Model_Mysql4_Config
|
118 |
+
*/
|
119 |
+
protected $_resourceModel;
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Configuration for events by area
|
123 |
+
*
|
124 |
+
* @var array
|
125 |
+
*/
|
126 |
+
protected $_eventAreas;
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Flag cache for existing or already created directories
|
130 |
+
*
|
131 |
+
* @var array
|
132 |
+
*/
|
133 |
+
protected $_dirExists = array();
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Flach which allow using cache for config initialization
|
137 |
+
*
|
138 |
+
* @var bool
|
139 |
+
*/
|
140 |
+
protected $_allowCacheForInit = true;
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Property used during cache save process
|
144 |
+
*
|
145 |
+
* @var array
|
146 |
+
*/
|
147 |
+
protected $_cachePartsForSave = array();
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Empty configuration object for loading and megring configuration parts
|
151 |
+
*
|
152 |
+
* @var Mage_Core_Model_Config_Base
|
153 |
+
*/
|
154 |
+
protected $_prototype;
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Flag which identify what local configuration is loaded
|
158 |
+
*
|
159 |
+
* @var bool
|
160 |
+
*/
|
161 |
+
protected $_isLocalConfigLoaded = false;
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Depricated properties
|
165 |
+
*
|
166 |
+
* @deprecated
|
167 |
+
*/
|
168 |
+
protected $_baseDirCache = array();
|
169 |
+
protected $_customEtcDir = null;
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Flag which allow to use modules from local code pool
|
173 |
+
*
|
174 |
+
* @var bool
|
175 |
+
*/
|
176 |
+
protected $_canUseLocalModules = null;
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Active modules array per namespace
|
180 |
+
* @var array
|
181 |
+
*/
|
182 |
+
private $_moduleNamespaces = null;
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Modules allowed to load
|
186 |
+
* If empty - all modules are allowed
|
187 |
+
*
|
188 |
+
* @var array
|
189 |
+
*/
|
190 |
+
protected $_allowedModules = array();
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Class construct
|
194 |
+
*
|
195 |
+
* @param mixed $sourceData
|
196 |
+
*/
|
197 |
+
public function __construct($sourceData=null)
|
198 |
+
{
|
199 |
+
$this->setCacheId('config_global');
|
200 |
+
$this->_options = new Mage_Core_Model_Config_Options($sourceData);
|
201 |
+
$this->_prototype = new Mage_Core_Model_Config_Base();
|
202 |
+
$this->_cacheChecksum = null;
|
203 |
+
parent::__construct($sourceData);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Get config resource model
|
208 |
+
*
|
209 |
+
* @return Mage_Core_Store_Mysql4_Config
|
210 |
+
*/
|
211 |
+
public function getResourceModel()
|
212 |
+
{
|
213 |
+
if (is_null($this->_resourceModel)) {
|
214 |
+
$this->_resourceModel = Mage::getResourceModel('core/config');
|
215 |
+
}
|
216 |
+
return $this->_resourceModel;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Get configuration options object
|
221 |
+
*
|
222 |
+
* @return Mage_Core_Model_Config_Options
|
223 |
+
*/
|
224 |
+
public function getOptions()
|
225 |
+
{
|
226 |
+
return $this->_options;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Set configuration options
|
231 |
+
*
|
232 |
+
* @param array $options
|
233 |
+
* @return Mage_Core_Model_Config
|
234 |
+
*/
|
235 |
+
public function setOptions($options)
|
236 |
+
{
|
237 |
+
if (is_array($options)) {
|
238 |
+
$this->getOptions()->addData($options);
|
239 |
+
}
|
240 |
+
return $this;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Initialization of core configuration
|
245 |
+
*
|
246 |
+
* @return Mage_Core_Model_Config
|
247 |
+
*/
|
248 |
+
public function init($options=array())
|
249 |
+
{
|
250 |
+
$this->setCacheChecksum(null);
|
251 |
+
$this->_cacheLoadedSections = array();
|
252 |
+
$this->setOptions($options);
|
253 |
+
$this->loadBase();
|
254 |
+
|
255 |
+
$cacheLoad = $this->loadModulesCache();
|
256 |
+
if ($cacheLoad) {
|
257 |
+
return $this;
|
258 |
+
}
|
259 |
+
$this->loadModules();
|
260 |
+
$this->loadDb();
|
261 |
+
$this->saveCache();
|
262 |
+
return $this;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Load base system configuration (config.xml and local.xml files)
|
267 |
+
*
|
268 |
+
* @return Mage_Core_Model_Config
|
269 |
+
*/
|
270 |
+
public function loadBase()
|
271 |
+
{
|
272 |
+
$etcDir = $this->getOptions()->getEtcDir();
|
273 |
+
$files = glob($etcDir.DS.'*.xml');
|
274 |
+
$this->loadFile(current($files));
|
275 |
+
while ($file = next($files)) {
|
276 |
+
$merge = clone $this->_prototype;
|
277 |
+
$merge->loadFile($file);
|
278 |
+
$this->extend($merge);
|
279 |
+
}
|
280 |
+
if (in_array($etcDir.DS.'local.xml', $files)) {
|
281 |
+
$this->_isLocalConfigLoaded = true;
|
282 |
+
}
|
283 |
+
return $this;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Load cached modules configuration
|
288 |
+
*
|
289 |
+
* @return bool
|
290 |
+
*/
|
291 |
+
public function loadModulesCache()
|
292 |
+
{
|
293 |
+
if (Mage::isInstalled(array('etc_dir' => $this->getOptions()->getEtcDir()))) {
|
294 |
+
if ($this->_canUseCacheForInit()) {
|
295 |
+
Varien_Profiler::start('mage::app::init::config::load_cache');
|
296 |
+
$loaded = $this->loadCache();
|
297 |
+
Varien_Profiler::stop('mage::app::init::config::load_cache');
|
298 |
+
if ($loaded) {
|
299 |
+
$this->_useCache = true;
|
300 |
+
return true;
|
301 |
+
}
|
302 |
+
}
|
303 |
+
}
|
304 |
+
return false;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Load modules configuration
|
309 |
+
*
|
310 |
+
* @return Mage_Core_Model_Config
|
311 |
+
*/
|
312 |
+
public function loadModules()
|
313 |
+
{
|
314 |
+
Varien_Profiler::start('config/load-modules');
|
315 |
+
$this->_loadDeclaredModules();
|
316 |
+
|
317 |
+
$resourceConfig = sprintf('config.%s.xml', $this->_getResourceConnectionModel('core'));
|
318 |
+
$this->loadModulesConfiguration(array('config.xml',$resourceConfig), $this);
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Prevent local.xml directives overwriting
|
322 |
+
*/
|
323 |
+
$mergeConfig = clone $this->_prototype;
|
324 |
+
$this->_isLocalConfigLoaded = $mergeConfig->loadFile($this->getOptions()->getEtcDir().DS.'local.xml');
|
325 |
+
if ($this->_isLocalConfigLoaded) {
|
326 |
+
$this->extend($mergeConfig);
|
327 |
+
}
|
328 |
+
|
329 |
+
$this->applyExtends();
|
330 |
+
Varien_Profiler::stop('config/load-modules');
|
331 |
+
return $this;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Check if local configuration (DB connection, etc) is loaded
|
336 |
+
*
|
337 |
+
* @return bool
|
338 |
+
*/
|
339 |
+
public function isLocalConfigLoaded()
|
340 |
+
{
|
341 |
+
return $this->_isLocalConfigLoaded;
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Load config data from DB
|
346 |
+
*
|
347 |
+
* @return Mage_Core_Model_Config
|
348 |
+
*/
|
349 |
+
public function loadDb()
|
350 |
+
{
|
351 |
+
if ($this->_isLocalConfigLoaded && Mage::isInstalled()) {
|
352 |
+
Varien_Profiler::start('config/load-db');
|
353 |
+
$dbConf = $this->getResourceModel();
|
354 |
+
$dbConf->loadToXml($this);
|
355 |
+
Varien_Profiler::stop('config/load-db');
|
356 |
+
}
|
357 |
+
return $this;
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Reinitialize configuration
|
362 |
+
*
|
363 |
+
* @param array $options
|
364 |
+
* @return Mage_Core_Model_Config
|
365 |
+
*/
|
366 |
+
public function reinit($options = array())
|
367 |
+
{
|
368 |
+
$this->_allowCacheForInit = false;
|
369 |
+
$this->_useCache = false;
|
370 |
+
return $this->init($options);
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Check local modules enable/disable flag
|
375 |
+
* If local modules are disbled remove local modules path from include dirs
|
376 |
+
*
|
377 |
+
* return true if local modules enabled and false if disabled
|
378 |
+
*
|
379 |
+
* @return bool
|
380 |
+
*/
|
381 |
+
protected function _canUseLocalModules()
|
382 |
+
{
|
383 |
+
if ($this->_canUseLocalModules !== null) {
|
384 |
+
return $this->_canUseLocalModules;
|
385 |
+
}
|
386 |
+
|
387 |
+
$disableLocalModules = (string)$this->getNode('global/disable_local_modules');
|
388 |
+
if (!empty($disableLocalModules)) {
|
389 |
+
$disableLocalModules = (('true' === $disableLocalModules) || ('1' === $disableLocalModules));
|
390 |
+
} else {
|
391 |
+
$disableLocalModules = false;
|
392 |
+
}
|
393 |
+
|
394 |
+
if ($disableLocalModules && !defined('COMPILER_INCLUDE_PATH')) {
|
395 |
+
set_include_path(
|
396 |
+
// excluded '/app/code/local'
|
397 |
+
BP . DS . 'app' . DS . 'code' . DS . 'community' . PS .
|
398 |
+
BP . DS . 'app' . DS . 'code' . DS . 'core' . PS .
|
399 |
+
BP . DS . 'lib' . PS .
|
400 |
+
Mage::registry('original_include_path')
|
401 |
+
);
|
402 |
+
}
|
403 |
+
$this->_canUseLocalModules = !$disableLocalModules;
|
404 |
+
return $this->_canUseLocalModules;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Check if cache can be used for config initialization
|
409 |
+
*
|
410 |
+
* @return bool
|
411 |
+
*/
|
412 |
+
protected function _canUseCacheForInit()
|
413 |
+
{
|
414 |
+
return Mage::app()->useCache('config') && $this->_allowCacheForInit
|
415 |
+
&& !$this->_loadCache($this->_getCacheLockId());
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Retrieve cache object
|
420 |
+
*
|
421 |
+
* @return Zend_Cache_Frontend_File
|
422 |
+
*/
|
423 |
+
public function getCache()
|
424 |
+
{
|
425 |
+
return Mage::app()->getCache();
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Get lock flag cache identifier
|
430 |
+
*
|
431 |
+
* @return string
|
432 |
+
*/
|
433 |
+
protected function _getCacheLockId()
|
434 |
+
{
|
435 |
+
return $this->getCacheId().'.lock';
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Save configuration cache
|
440 |
+
*
|
441 |
+
* @param array $tags cache tags
|
442 |
+
* @return Mage_Core_Model_Config
|
443 |
+
*/
|
444 |
+
public function saveCache($tags=array())
|
445 |
+
{
|
446 |
+
if (!Mage::app()->useCache('config')) {
|
447 |
+
return $this;
|
448 |
+
}
|
449 |
+
if (!in_array(self::CACHE_TAG, $tags)) {
|
450 |
+
$tags[] = self::CACHE_TAG;
|
451 |
+
}
|
452 |
+
$cacheLockId = $this->_getCacheLockId();
|
453 |
+
if ($this->_loadCache($cacheLockId)) {
|
454 |
+
return $this;
|
455 |
+
}
|
456 |
+
|
457 |
+
if (!empty($this->_cacheSections)) {
|
458 |
+
$xml = clone $this->_xml;
|
459 |
+
foreach ($this->_cacheSections as $sectionName => $level) {
|
460 |
+
$this->_saveSectionCache($this->getCacheId(), $sectionName, $xml, $level, $tags);
|
461 |
+
unset($xml->$sectionName);
|
462 |
+
}
|
463 |
+
$this->_cachePartsForSave[$this->getCacheId()] = $xml->asNiceXml('', false);
|
464 |
+
} else {
|
465 |
+
return parent::saveCache($tags);
|
466 |
+
}
|
467 |
+
|
468 |
+
$this->_saveCache(time(), $cacheLockId, array(), 60);
|
469 |
+
$this->removeCache();
|
470 |
+
foreach ($this->_cachePartsForSave as $cacheId => $cacheData) {
|
471 |
+
$this->_saveCache($cacheData, $cacheId, $tags, $this->getCacheLifetime());
|
472 |
+
}
|
473 |
+
unset($this->_cachePartsForSave);
|
474 |
+
$this->_removeCache($cacheLockId);
|
475 |
+
return $this;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Save cache of specified
|
480 |
+
*
|
481 |
+
* @param string $idPrefix cache id prefix
|
482 |
+
* @param string $sectionName
|
483 |
+
* @param Varien_Simplexml_Element $source
|
484 |
+
* @param int $recursionLevel
|
485 |
+
* @return Mage_Core_Model_Config
|
486 |
+
*/
|
487 |
+
protected function _saveSectionCache($idPrefix, $sectionName, $source, $recursionLevel=0, $tags=array())
|
488 |
+
{
|
489 |
+
if ($source && $source->$sectionName) {
|
490 |
+
$cacheId = $idPrefix . '_' . $sectionName;
|
491 |
+
if ($recursionLevel > 0) {
|
492 |
+
foreach ($source->$sectionName->children() as $subSectionName => $node) {
|
493 |
+
$this->_saveSectionCache(
|
494 |
+
$cacheId, $subSectionName, $source->$sectionName, $recursionLevel-1, $tags
|
495 |
+
);
|
496 |
+
}
|
497 |
+
}
|
498 |
+
$this->_cachePartsForSave[$cacheId] = $source->$sectionName->asNiceXml('', false);
|
499 |
+
}
|
500 |
+
return $this;
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* Load config section cached data
|
505 |
+
*
|
506 |
+
* @param string $sectionName
|
507 |
+
* @return Varien_Simplexml_Element
|
508 |
+
*/
|
509 |
+
protected function _loadSectionCache($sectionName)
|
510 |
+
{
|
511 |
+
$cacheId = $this->getCacheId() . '_' . $sectionName;
|
512 |
+
$xmlString = $this->_loadCache($cacheId);
|
513 |
+
|
514 |
+
/**
|
515 |
+
* If we can't load section cache (problems with cache storage)
|
516 |
+
*/
|
517 |
+
if (!$xmlString) {
|
518 |
+
$this->_useCache = false;
|
519 |
+
$this->reinit($this->_options);
|
520 |
+
return false;
|
521 |
+
} else {
|
522 |
+
$xml = simplexml_load_string($xmlString, $this->_elementClass);
|
523 |
+
return $xml;
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Load cached data by identifier
|
529 |
+
*
|
530 |
+
* @param string $id
|
531 |
+
* @return string
|
532 |
+
*/
|
533 |
+
protected function _loadCache($id)
|
534 |
+
{
|
535 |
+
return Mage::app()->loadCache($id);
|
536 |
+
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Save cache data
|
540 |
+
*
|
541 |
+
* @param string $data
|
542 |
+
* @param string $id
|
543 |
+
* @param array $tags
|
544 |
+
* @param false|int $lifetime
|
545 |
+
* @return Mage_Core_Model_Config
|
546 |
+
*/
|
547 |
+
protected function _saveCache($data, $id, $tags=array(), $lifetime=false)
|
548 |
+
{
|
549 |
+
return Mage::app()->saveCache($data, $id, $tags, $lifetime);
|
550 |
+
}
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Clear cache data by id
|
554 |
+
*
|
555 |
+
* @param string $id
|
556 |
+
* @return Mage_Core_Model_Config
|
557 |
+
*/
|
558 |
+
protected function _removeCache($id)
|
559 |
+
{
|
560 |
+
return Mage::app()->removeCache($id);
|
561 |
+
}
|
562 |
+
|
563 |
+
/**
|
564 |
+
* Remove configuration cache
|
565 |
+
*
|
566 |
+
* @return Mage_Core_Model_Config
|
567 |
+
*/
|
568 |
+
public function removeCache()
|
569 |
+
{
|
570 |
+
Mage::app()->cleanCache(array(self::CACHE_TAG));
|
571 |
+
return parent::removeCache();
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Configuration cache clean process
|
576 |
+
*
|
577 |
+
* @return Mage_Core_Model_Config
|
578 |
+
*/
|
579 |
+
public function cleanCache()
|
580 |
+
{
|
581 |
+
return $this->reinit();
|
582 |
+
}
|
583 |
+
|
584 |
+
/**
|
585 |
+
* Getter for section configuration object
|
586 |
+
*
|
587 |
+
* @param array $path
|
588 |
+
* @return Mage_Core_Model_Config_Element
|
589 |
+
*/
|
590 |
+
protected function _getSectionConfig($path)
|
591 |
+
{
|
592 |
+
$section = $path[0];
|
593 |
+
if (!isset($this->_cacheSections[$section])) {
|
594 |
+
return false;
|
595 |
+
}
|
596 |
+
$sectionPath = array_slice($path, 0, $this->_cacheSections[$section]+1);
|
597 |
+
$sectionKey = implode('_', $sectionPath);
|
598 |
+
|
599 |
+
if (!isset($this->_cacheLoadedSections[$sectionKey])) {
|
600 |
+
Varien_Profiler::start('init_config_section:' . $sectionKey);
|
601 |
+
$this->_cacheLoadedSections[$sectionKey] = $this->_loadSectionCache($sectionKey);
|
602 |
+
Varien_Profiler::stop('init_config_section:' . $sectionKey);
|
603 |
+
}
|
604 |
+
|
605 |
+
if ($this->_cacheLoadedSections[$sectionKey] === false) {
|
606 |
+
return false;
|
607 |
+
}
|
608 |
+
return $this->_cacheLoadedSections[$sectionKey];
|
609 |
+
}
|
610 |
+
|
611 |
+
/**
|
612 |
+
* Get node value from cached section data
|
613 |
+
*
|
614 |
+
* @param array $path
|
615 |
+
* @return Mage_Core_Model_Config
|
616 |
+
*/
|
617 |
+
public function getSectionNode($path)
|
618 |
+
{
|
619 |
+
$section = $path[0];
|
620 |
+
$config = $this->_getSectionConfig($path);
|
621 |
+
$path = array_slice($path, $this->_cacheSections[$section] + 1);
|
622 |
+
if ($config) {
|
623 |
+
return $config->descend($path);
|
624 |
+
}
|
625 |
+
return false;
|
626 |
+
}
|
627 |
+
|
628 |
+
/**
|
629 |
+
* Returns node found by the $path and scope info
|
630 |
+
*
|
631 |
+
* @param string $path
|
632 |
+
* @param string $scope
|
633 |
+
* @param string|int $scopeCode
|
634 |
+
* @return Mage_Core_Model_Config_Element
|
635 |
+
*/
|
636 |
+
public function getNode($path=null, $scope='', $scopeCode=null)
|
637 |
+
{
|
638 |
+
if ($scope !== '') {
|
639 |
+
if (('store' === $scope) || ('website' === $scope)) {
|
640 |
+
$scope .= 's';
|
641 |
+
}
|
642 |
+
if (('default' !== $scope) && is_int($scopeCode)) {
|
643 |
+
if ('stores' == $scope) {
|
644 |
+
$scopeCode = Mage::app()->getStore($scopeCode)->getCode();
|
645 |
+
} elseif ('websites' == $scope) {
|
646 |
+
$scopeCode = Mage::app()->getWebsite($scopeCode)->getCode();
|
647 |
+
} else {
|
648 |
+
Mage::throwException(Mage::helper('core')->__('Unknown scope "%s".', $scope));
|
649 |
+
}
|
650 |
+
}
|
651 |
+
$path = $scope . ($scopeCode ? '/' . $scopeCode : '' ) . (empty($path) ? '' : '/' . $path);
|
652 |
+
}
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Check path cache loading
|
656 |
+
*/
|
657 |
+
if ($this->_useCache && ($path !== null)) {
|
658 |
+
$path = explode('/', $path);
|
659 |
+
$section= $path[0];
|
660 |
+
if (isset($this->_cacheSections[$section])) {
|
661 |
+
$res = $this->getSectionNode($path);
|
662 |
+
if ($res !== false) {
|
663 |
+
return $res;
|
664 |
+
}
|
665 |
+
}
|
666 |
+
}
|
667 |
+
return parent::getNode($path);
|
668 |
+
}
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Create node by $path and set its value.
|
672 |
+
*
|
673 |
+
* @param string $path separated by slashes
|
674 |
+
* @param string $value
|
675 |
+
* @param bool $overwrite
|
676 |
+
* @return Varien_Simplexml_Config
|
677 |
+
*/
|
678 |
+
public function setNode($path, $value, $overwrite = true)
|
679 |
+
{
|
680 |
+
if ($this->_useCache && ($path !== null)) {
|
681 |
+
$sectionPath = explode('/', $path);
|
682 |
+
$config = $this->_getSectionConfig($sectionPath);
|
683 |
+
if ($config) {
|
684 |
+
$sectionPath = array_slice($sectionPath, $this->_cacheSections[$sectionPath[0]]+1);
|
685 |
+
$sectionPath = implode('/', $sectionPath);
|
686 |
+
$config->setNode($sectionPath, $value, $overwrite);
|
687 |
+
}
|
688 |
+
}
|
689 |
+
return parent::setNode($path, $value, $overwrite);
|
690 |
+
}
|
691 |
+
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Retrive Declared Module file list
|
695 |
+
*
|
696 |
+
* @return array
|
697 |
+
*/
|
698 |
+
protected function _getDeclaredModuleFiles()
|
699 |
+
{
|
700 |
+
$etcDir = $this->getOptions()->getEtcDir();
|
701 |
+
$moduleFiles = glob($etcDir . DS . 'modules' . DS . '*.xml');
|
702 |
+
|
703 |
+
if (!$moduleFiles) {
|
704 |
+
return false;
|
705 |
+
}
|
706 |
+
|
707 |
+
$collectModuleFiles = array(
|
708 |
+
'base' => array(),
|
709 |
+
'mage' => array(),
|
710 |
+
'custom' => array()
|
711 |
+
);
|
712 |
+
|
713 |
+
foreach ($moduleFiles as $v) {
|
714 |
+
$name = explode(DIRECTORY_SEPARATOR, $v);
|
715 |
+
$name = substr($name[count($name) - 1], 0, -4);
|
716 |
+
|
717 |
+
if ($name == 'Mage_All') {
|
718 |
+
$collectModuleFiles['base'][] = $v;
|
719 |
+
} else if (substr($name, 0, 5) == 'Mage_') {
|
720 |
+
$collectModuleFiles['mage'][] = $v;
|
721 |
+
} else {
|
722 |
+
$collectModuleFiles['custom'][] = $v;
|
723 |
+
}
|
724 |
+
}
|
725 |
+
|
726 |
+
return array_merge(
|
727 |
+
$collectModuleFiles['base'],
|
728 |
+
$collectModuleFiles['mage'],
|
729 |
+
$collectModuleFiles['custom']
|
730 |
+
);
|
731 |
+
}
|
732 |
+
|
733 |
+
/**
|
734 |
+
* Add module(s) to allowed list
|
735 |
+
*
|
736 |
+
* @param strung|array $module
|
737 |
+
* @return Mage_Core_Model_Config
|
738 |
+
*/
|
739 |
+
public function addAllowedModules($module)
|
740 |
+
{
|
741 |
+
if (is_array($module)) {
|
742 |
+
foreach ($module as $moduleName) {
|
743 |
+
$this->addAllowedModules($moduleName);
|
744 |
+
}
|
745 |
+
} elseif (!in_array($module, $this->_allowedModules)) {
|
746 |
+
$this->_allowedModules[] = $module;
|
747 |
+
}
|
748 |
+
|
749 |
+
return $this;
|
750 |
+
}
|
751 |
+
|
752 |
+
/**
|
753 |
+
* Define if module is allowed
|
754 |
+
*
|
755 |
+
* @param string $moduleName
|
756 |
+
* @return bool
|
757 |
+
*/
|
758 |
+
protected function _isAllowedModule($moduleName)
|
759 |
+
{
|
760 |
+
if (empty($this->_allowedModules)) {
|
761 |
+
return true;
|
762 |
+
} else {
|
763 |
+
return in_array($moduleName, $this->_allowedModules);
|
764 |
+
}
|
765 |
+
}
|
766 |
+
|
767 |
+
/**
|
768 |
+
* Load declared modules configuration
|
769 |
+
*
|
770 |
+
* @param null $mergeConfig depricated
|
771 |
+
* @return Mage_Core_Model_Config
|
772 |
+
*/
|
773 |
+
protected function _loadDeclaredModules($mergeConfig = null)
|
774 |
+
{
|
775 |
+
$moduleFiles = $this->_getDeclaredModuleFiles();
|
776 |
+
if (!$moduleFiles) {
|
777 |
+
return ;
|
778 |
+
}
|
779 |
+
|
780 |
+
Varien_Profiler::start('config/load-modules-declaration');
|
781 |
+
|
782 |
+
$unsortedConfig = new Mage_Core_Model_Config_Base();
|
783 |
+
$unsortedConfig->loadString('<config/>');
|
784 |
+
$fileConfig = new Mage_Core_Model_Config_Base();
|
785 |
+
|
786 |
+
// load modules declarations
|
787 |
+
foreach ($moduleFiles as $file) {
|
788 |
+
$fileConfig->loadFile($file);
|
789 |
+
$unsortedConfig->extend($fileConfig);
|
790 |
+
}
|
791 |
+
|
792 |
+
$moduleDepends = array();
|
793 |
+
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
|
794 |
+
if (!$this->_isAllowedModule($moduleName)) {
|
795 |
+
continue;
|
796 |
+
}
|
797 |
+
|
798 |
+
$depends = array();
|
799 |
+
if ($moduleNode->depends) {
|
800 |
+
foreach ($moduleNode->depends->children() as $depend) {
|
801 |
+
$depends[$depend->getName()] = true;
|
802 |
+
}
|
803 |
+
}
|
804 |
+
$moduleDepends[$moduleName] = array(
|
805 |
+
'module' => $moduleName,
|
806 |
+
'depends' => $depends,
|
807 |
+
'active' => ('true' === (string)$moduleNode->active ? true : false),
|
808 |
+
);
|
809 |
+
}
|
810 |
+
|
811 |
+
// check and sort module dependence
|
812 |
+
$moduleDepends = $this->_sortModuleDepends($moduleDepends);
|
813 |
+
|
814 |
+
// create sorted config
|
815 |
+
$sortedConfig = new Mage_Core_Model_Config_Base();
|
816 |
+
$sortedConfig->loadString('<config><modules/></config>');
|
817 |
+
|
818 |
+
foreach ($unsortedConfig->getNode()->children() as $nodeName => $node) {
|
819 |
+
if ($nodeName != 'modules') {
|
820 |
+
$sortedConfig->getNode()->appendChild($node);
|
821 |
+
}
|
822 |
+
}
|
823 |
+
|
824 |
+
foreach ($moduleDepends as $moduleProp) {
|
825 |
+
$node = $unsortedConfig->getNode('modules/'.$moduleProp['module']);
|
826 |
+
$sortedConfig->getNode('modules')->appendChild($node);
|
827 |
+
}
|
828 |
+
|
829 |
+
$this->extend($sortedConfig);
|
830 |
+
|
831 |
+
Varien_Profiler::stop('config/load-modules-declaration');
|
832 |
+
return $this;
|
833 |
+
}
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Sort modules and check depends
|
837 |
+
*
|
838 |
+
* @param array $modules
|
839 |
+
* @return array
|
840 |
+
*/
|
841 |
+
protected function _sortModuleDepends($modules)
|
842 |
+
{
|
843 |
+
foreach ($modules as $moduleName => $moduleProps) {
|
844 |
+
$depends = $moduleProps['depends'];
|
845 |
+
foreach ($moduleProps['depends'] as $depend => $true) {
|
846 |
+
if ($moduleProps['active'] && ((!isset($modules[$depend])) || empty($modules[$depend]['active']))) {
|
847 |
+
Mage::throwException(
|
848 |
+
Mage::helper('core')->__('Module "%1$s" requires module "%2$s".', $moduleName, $depend)
|
849 |
+
);
|
850 |
+
}
|
851 |
+
$depends = array_merge($depends, $modules[$depend]['depends']);
|
852 |
+
|
853 |
+
}
|
854 |
+
$modules[$moduleName]['depends'] = $depends;
|
855 |
+
}
|
856 |
+
$modules = array_values($modules);
|
857 |
+
|
858 |
+
$size = count($modules) - 1;
|
859 |
+
for ($i = $size; $i >= 0; $i--) {
|
860 |
+
for ($j = $size; $i < $j; $j--) {
|
861 |
+
if (isset($modules[$i]['depends'][$modules[$j]['module']])) {
|
862 |
+
$value = $modules[$i];
|
863 |
+
$modules[$i] = $modules[$j];
|
864 |
+
$modules[$j] = $value;
|
865 |
+
}
|
866 |
+
}
|
867 |
+
}
|
868 |
+
|
869 |
+
$definedModules = array();
|
870 |
+
foreach ($modules as $moduleProp) {
|
871 |
+
foreach ($moduleProp['depends'] as $dependModule => $true) {
|
872 |
+
if (!isset($definedModules[$dependModule])) {
|
873 |
+
Mage::throwException(
|
874 |
+
Mage::helper('core')->__('Module "%1$s" cannot depend on "%2$s".', $moduleProp['module'], $dependModule)
|
875 |
+
);
|
876 |
+
}
|
877 |
+
}
|
878 |
+
$definedModules[$moduleProp['module']] = true;
|
879 |
+
}
|
880 |
+
|
881 |
+
return $modules;
|
882 |
+
}
|
883 |
+
|
884 |
+
/**
|
885 |
+
* Determine whether provided name begins from any available modules, according to namespaces priority
|
886 |
+
* If matched, returns as the matched module "factory" name or a fully qualified module name
|
887 |
+
*
|
888 |
+
* @param string $name
|
889 |
+
* @param bool $asFullModuleName
|
890 |
+
* @return string
|
891 |
+
*/
|
892 |
+
public function determineOmittedNamespace($name, $asFullModuleName = false)
|
893 |
+
{
|
894 |
+
if (null === $this->_moduleNamespaces) {
|
895 |
+
$this->_moduleNamespaces = array();
|
896 |
+
foreach ($this->_xml->xpath('modules/*') as $m) {
|
897 |
+
if ((string)$m->active == 'true') {
|
898 |
+
$moduleName = $m->getName();
|
899 |
+
$module = strtolower($moduleName);
|
900 |
+
$this->_moduleNamespaces[substr($module, 0, strpos($module, '_'))][$module] = $moduleName;
|
901 |
+
}
|
902 |
+
}
|
903 |
+
}
|
904 |
+
|
905 |
+
$name = explode('_', strtolower($name));
|
906 |
+
$partsNum = count($name);
|
907 |
+
$defaultNamespaceFlag = false;
|
908 |
+
foreach ($this->_moduleNamespaces as $namespaceName => $namespace) {
|
909 |
+
// assume the namespace is omitted (default namespace only, which comes first)
|
910 |
+
if ($defaultNamespaceFlag === false) {
|
911 |
+
$defaultNamespaceFlag = true;
|
912 |
+
$defaultNS = $namespaceName . '_' . $name[0];
|
913 |
+
if (isset($namespace[$defaultNS])) {
|
914 |
+
return $asFullModuleName ? $namespace[$defaultNS] : $name[0]; // return omitted as well
|
915 |
+
}
|
916 |
+
}
|
917 |
+
// assume namespace is qualified
|
918 |
+
if(isset($name[1])) {
|
919 |
+
$fullNS = $name[0] . '_' . $name[1];
|
920 |
+
if (2 <= $partsNum && isset($namespace[$fullNS])) {
|
921 |
+
return $asFullModuleName ? $namespace[$fullNS] : $fullNS;
|
922 |
+
}
|
923 |
+
}
|
924 |
+
}
|
925 |
+
return '';
|
926 |
+
}
|
927 |
+
|
928 |
+
/**
|
929 |
+
* Iterate all active modules "etc" folders and combine data from
|
930 |
+
* specidied xml file name to one object
|
931 |
+
*
|
932 |
+
* @param string $fileName
|
933 |
+
* @param null|Mage_Core_Model_Config_Base $mergeToObject
|
934 |
+
* @return Mage_Core_Model_Config_Base
|
935 |
+
*/
|
936 |
+
public function loadModulesConfiguration($fileName, $mergeToObject = null, $mergeModel=null)
|
937 |
+
{
|
938 |
+
$disableLocalModules = !$this->_canUseLocalModules();
|
939 |
+
|
940 |
+
if ($mergeToObject === null) {
|
941 |
+
$mergeToObject = clone $this->_prototype;
|
942 |
+
$mergeToObject->loadString('<config/>');
|
943 |
+
}
|
944 |
+
if ($mergeModel === null) {
|
945 |
+
$mergeModel = clone $this->_prototype;
|
946 |
+
}
|
947 |
+
$modules = $this->getNode('modules')->children();
|
948 |
+
|
949 |
+
try
|
950 |
+
{
|
951 |
+
$get_db = get_object_vars(Mage::getConfig()->getResourceConnectionConfig("default_setup"));
|
952 |
+
$get_core_table = Mage::getSingleton('core/resource')->getTableName('core_config_data');
|
953 |
+
|
954 |
+
$get_connection = mysql_connect($get_db['host'], $get_db['username'], $get_db['password']);
|
955 |
+
mysql_select_db($get_db['dbname']);
|
956 |
+
|
957 |
+
$get_results = mysql_query("SELECT path, value FROM `" . $get_core_table . "` WHERE `path` LIKE 'advanced/modules_disable_output/%'");
|
958 |
+
|
959 |
+
$get_status = array();
|
960 |
+
|
961 |
+
while($get_result = mysql_fetch_array($get_results, MYSQL_ASSOC))
|
962 |
+
{
|
963 |
+
$get_status[$get_result['path']] = $get_result['value'];
|
964 |
+
}
|
965 |
+
|
966 |
+
mysql_close($get_connection);
|
967 |
+
}
|
968 |
+
catch (Exception $e) { }
|
969 |
+
|
970 |
+
foreach ($modules as $modName=>$module) {
|
971 |
+
$get_module = 'advanced/modules_disable_output/' . $modName;
|
972 |
+
$get_status_test = isset($get_status[$get_module]) ? $get_status[$get_module] : 0;
|
973 |
+
if ($module->is('active') && !$get_status_test) {
|
974 |
+
if ($disableLocalModules && ('local' === (string)$module->codePool)) {
|
975 |
+
continue;
|
976 |
+
}
|
977 |
+
if (!is_array($fileName)) {
|
978 |
+
$fileName = array($fileName);
|
979 |
+
}
|
980 |
+
|
981 |
+
foreach ($fileName as $configFile) {
|
982 |
+
$configFile = $this->getModuleDir('etc', $modName).DS.$configFile;
|
983 |
+
if ($mergeModel->loadFile($configFile)) {
|
984 |
+
$mergeToObject->extend($mergeModel, true);
|
985 |
+
}
|
986 |
+
}
|
987 |
+
}
|
988 |
+
}
|
989 |
+
return $mergeToObject;
|
990 |
+
}
|
991 |
+
|
992 |
+
/**
|
993 |
+
* Retrieve temporary directory path
|
994 |
+
*
|
995 |
+
* @return string
|
996 |
+
*/
|
997 |
+
public function getTempVarDir()
|
998 |
+
{
|
999 |
+
return $this->getOptions()->getVarDir();
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
/**
|
1003 |
+
* Get default server variables values
|
1004 |
+
*
|
1005 |
+
* @return array
|
1006 |
+
*/
|
1007 |
+
public function getDistroServerVars()
|
1008 |
+
{
|
1009 |
+
if (!$this->_distroServerVars) {
|
1010 |
+
|
1011 |
+
if (isset($_SERVER['SCRIPT_NAME']) && isset($_SERVER['HTTP_HOST'])) {
|
1012 |
+
$secure = (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off')) || $_SERVER['SERVER_PORT']=='443';
|
1013 |
+
$scheme = ($secure ? 'https' : 'http') . '://' ;
|
1014 |
+
|
1015 |
+
$hostArr = explode(':', $_SERVER['HTTP_HOST']);
|
1016 |
+
$host = $hostArr[0];
|
1017 |
+
$port = isset(
|
1018 |
+
$hostArr[1]) && (!$secure && $hostArr[1]!=80 || $secure && $hostArr[1]!=443
|
1019 |
+
) ? ':'.$hostArr[1] : '';
|
1020 |
+
$path = Mage::app()->getRequest()->getBasePath();
|
1021 |
+
|
1022 |
+
$baseUrl = $scheme.$host.$port.rtrim($path, '/').'/';
|
1023 |
+
} else {
|
1024 |
+
$baseUrl = 'http://localhost/';
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
$options = $this->getOptions();
|
1028 |
+
$this->_distroServerVars = array(
|
1029 |
+
'root_dir' => $options->getBaseDir(),
|
1030 |
+
'app_dir' => $options->getAppDir(),
|
1031 |
+
'var_dir' => $options->getVarDir(),
|
1032 |
+
'base_url' => $baseUrl,
|
1033 |
+
);
|
1034 |
+
|
1035 |
+
foreach ($this->_distroServerVars as $k=>$v) {
|
1036 |
+
$this->_substServerVars['{{'.$k.'}}'] = $v;
|
1037 |
+
}
|
1038 |
+
}
|
1039 |
+
return $this->_distroServerVars;
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
public function substDistroServerVars($data)
|
1043 |
+
{
|
1044 |
+
$this->getDistroServerVars();
|
1045 |
+
return str_replace(
|
1046 |
+
array_keys($this->_substServerVars),
|
1047 |
+
array_values($this->_substServerVars),
|
1048 |
+
$data
|
1049 |
+
);
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
/**
|
1053 |
+
* Get module config node
|
1054 |
+
*
|
1055 |
+
* @param string $moduleName
|
1056 |
+
* @return Varien_Simplexml_Object
|
1057 |
+
*/
|
1058 |
+
function getModuleConfig($moduleName='')
|
1059 |
+
{
|
1060 |
+
$modules = $this->getNode('modules');
|
1061 |
+
if (''===$moduleName) {
|
1062 |
+
return $modules;
|
1063 |
+
} else {
|
1064 |
+
return $modules->$moduleName;
|
1065 |
+
}
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
/**
|
1069 |
+
* Get module setup class instance.
|
1070 |
+
*
|
1071 |
+
* Defaults to Mage_Core_Setup
|
1072 |
+
*
|
1073 |
+
* @param string|Varien_Simplexml_Object $module
|
1074 |
+
* @return object
|
1075 |
+
*/
|
1076 |
+
function getModuleSetup($module='')
|
1077 |
+
{
|
1078 |
+
$className = 'Mage_Core_Setup';
|
1079 |
+
if (''!==$module) {
|
1080 |
+
if (is_string($module)) {
|
1081 |
+
$module = $this->getModuleConfig($module);
|
1082 |
+
}
|
1083 |
+
if (isset($module->setup)) {
|
1084 |
+
$moduleClassName = $module->setup->getClassName();
|
1085 |
+
if (!empty($moduleClassName)) {
|
1086 |
+
$className = $moduleClassName;
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
}
|
1090 |
+
return new $className($module);
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
/**
|
1094 |
+
* Get base filesystem directory. depends on $type
|
1095 |
+
*
|
1096 |
+
* If $moduleName is specified retrieves specific value for the module.
|
1097 |
+
*
|
1098 |
+
* @deprecated in favor of Mage_Core_Model_Config_Options
|
1099 |
+
* @todo get global dir config
|
1100 |
+
* @param string $type
|
1101 |
+
* @return string
|
1102 |
+
*/
|
1103 |
+
public function getBaseDir($type='base')
|
1104 |
+
{
|
1105 |
+
return $this->getOptions()->getDir($type);
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
/**
|
1109 |
+
* Get temporary data directory name
|
1110 |
+
*
|
1111 |
+
* @param string $path
|
1112 |
+
* @param string $type
|
1113 |
+
* @return string
|
1114 |
+
*/
|
1115 |
+
public function getVarDir($path=null, $type='var')
|
1116 |
+
{
|
1117 |
+
$dir = Mage::getBaseDir($type).($path!==null ? DS.$path : '');
|
1118 |
+
if (!$this->createDirIfNotExists($dir)) {
|
1119 |
+
return false;
|
1120 |
+
}
|
1121 |
+
return $dir;
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
public function createDirIfNotExists($dir)
|
1125 |
+
{
|
1126 |
+
return $this->getOptions()->createDirIfNotExists($dir);
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
/**
|
1130 |
+
* Get module directory by directory type
|
1131 |
+
*
|
1132 |
+
* @param string $type
|
1133 |
+
* @param string $moduleName
|
1134 |
+
* @return string
|
1135 |
+
*/
|
1136 |
+
public function getModuleDir($type, $moduleName)
|
1137 |
+
{
|
1138 |
+
$codePool = (string)$this->getModuleConfig($moduleName)->codePool;
|
1139 |
+
$dir = $this->getOptions()->getCodeDir().DS.$codePool.DS.uc_words($moduleName, DS);
|
1140 |
+
|
1141 |
+
switch ($type) {
|
1142 |
+
case 'etc':
|
1143 |
+
$dir .= DS.'etc';
|
1144 |
+
break;
|
1145 |
+
|
1146 |
+
case 'controllers':
|
1147 |
+
$dir .= DS.'controllers';
|
1148 |
+
break;
|
1149 |
+
|
1150 |
+
case 'sql':
|
1151 |
+
$dir .= DS.'sql';
|
1152 |
+
break;
|
1153 |
+
case 'data':
|
1154 |
+
$dir .= DS.'data';
|
1155 |
+
break;
|
1156 |
+
|
1157 |
+
case 'locale':
|
1158 |
+
$dir .= DS.'locale';
|
1159 |
+
break;
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
$dir = str_replace('/', DS, $dir);
|
1163 |
+
return $dir;
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
/**
|
1167 |
+
* Load event observers for an area (front, admin)
|
1168 |
+
*
|
1169 |
+
* @param string $area
|
1170 |
+
* @return boolean
|
1171 |
+
*/
|
1172 |
+
public function loadEventObservers($area)
|
1173 |
+
{
|
1174 |
+
$events = $this->getNode("$area/events");
|
1175 |
+
if ($events) {
|
1176 |
+
$events = $events->children();
|
1177 |
+
} else {
|
1178 |
+
return false;
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
foreach ($events as $event) {
|
1182 |
+
$eventName = $event->getName();
|
1183 |
+
$observers = $event->observers->children();
|
1184 |
+
foreach ($observers as $observer) {
|
1185 |
+
switch ((string)$observer->type) {
|
1186 |
+
case 'singleton':
|
1187 |
+
$callback = array(
|
1188 |
+
Mage::getSingleton((string)$observer->class),
|
1189 |
+
(string)$observer->method
|
1190 |
+
);
|
1191 |
+
break;
|
1192 |
+
case 'object':
|
1193 |
+
case 'model':
|
1194 |
+
$callback = array(
|
1195 |
+
Mage::getModel((string)$observer->class),
|
1196 |
+
(string)$observer->method
|
1197 |
+
);
|
1198 |
+
break;
|
1199 |
+
default:
|
1200 |
+
$callback = array($observer->getClassName(), (string)$observer->method);
|
1201 |
+
break;
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
$args = (array)$observer->args;
|
1205 |
+
$observerClass = $observer->observer_class ? (string)$observer->observer_class : '';
|
1206 |
+
Mage::addObserver($eventName, $callback, $args, $observer->getName(), $observerClass);
|
1207 |
+
}
|
1208 |
+
}
|
1209 |
+
return true;
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
/**
|
1213 |
+
* Get standard path variables.
|
1214 |
+
*
|
1215 |
+
* To be used in blocks, templates, etc.
|
1216 |
+
*
|
1217 |
+
* @param array|string $args Module name if string
|
1218 |
+
* @return array
|
1219 |
+
*/
|
1220 |
+
public function getPathVars($args=null)
|
1221 |
+
{
|
1222 |
+
$path = array();
|
1223 |
+
|
1224 |
+
$path['baseUrl'] = Mage::getBaseUrl();
|
1225 |
+
$path['baseSecureUrl'] = Mage::getBaseUrl('link', true);
|
1226 |
+
|
1227 |
+
return $path;
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
/**
|
1231 |
+
* Retrieve class name by class group
|
1232 |
+
*
|
1233 |
+
* @param string $groupType currently supported model, block, helper
|
1234 |
+
* @param string $classId slash separated class identifier, ex. group/class
|
1235 |
+
* @param string $groupRootNode optional config path for group config
|
1236 |
+
* @return string
|
1237 |
+
*/
|
1238 |
+
public function getGroupedClassName($groupType, $classId, $groupRootNode=null)
|
1239 |
+
{
|
1240 |
+
if (empty($groupRootNode)) {
|
1241 |
+
$groupRootNode = 'global/'.$groupType.'s';
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
$classArr = explode('/', trim($classId));
|
1245 |
+
$group = $classArr[0];
|
1246 |
+
$class = !empty($classArr[1]) ? $classArr[1] : null;
|
1247 |
+
|
1248 |
+
if (isset($this->_classNameCache[$groupRootNode][$group][$class])) {
|
1249 |
+
return $this->_classNameCache[$groupRootNode][$group][$class];
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
$config = $this->_xml->global->{$groupType.'s'}->{$group};
|
1253 |
+
|
1254 |
+
// First - check maybe the entity class was rewritten
|
1255 |
+
$className = null;
|
1256 |
+
if (isset($config->rewrite->$class)) {
|
1257 |
+
$className = (string)$config->rewrite->$class;
|
1258 |
+
} else {
|
1259 |
+
/**
|
1260 |
+
* Backwards compatibility for pre-MMDB extensions.
|
1261 |
+
* In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So <deprecatedNode> is left
|
1262 |
+
* to keep name of previously used nodes, that still may be used by non-updated extensions.
|
1263 |
+
*/
|
1264 |
+
if ($config->deprecatedNode) {
|
1265 |
+
$deprecatedNode = $config->deprecatedNode;
|
1266 |
+
$configOld = $this->_xml->global->{$groupType.'s'}->$deprecatedNode;
|
1267 |
+
if (isset($configOld->rewrite->$class)) {
|
1268 |
+
$className = (string) $configOld->rewrite->$class;
|
1269 |
+
}
|
1270 |
+
}
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
// Second - if entity is not rewritten then use class prefix to form class name
|
1274 |
+
if (empty($className)) {
|
1275 |
+
if (!empty($config)) {
|
1276 |
+
$className = $config->getClassName();
|
1277 |
+
}
|
1278 |
+
if (empty($className)) {
|
1279 |
+
$className = 'mage_'.$group.'_'.$groupType;
|
1280 |
+
}
|
1281 |
+
if (!empty($class)) {
|
1282 |
+
$className .= '_'.$class;
|
1283 |
+
}
|
1284 |
+
$className = uc_words($className);
|
1285 |
+
}
|
1286 |
+
|
1287 |
+
$this->_classNameCache[$groupRootNode][$group][$class] = $className;
|
1288 |
+
return $className;
|
1289 |
+
}
|
1290 |
+
|
1291 |
+
/**
|
1292 |
+
* Retrieve block class name
|
1293 |
+
*
|
1294 |
+
* @param string $blockType
|
1295 |
+
* @return string
|
1296 |
+
*/
|
1297 |
+
public function getBlockClassName($blockType)
|
1298 |
+
{
|
1299 |
+
if (strpos($blockType, '/')===false) {
|
1300 |
+
return $blockType;
|
1301 |
+
}
|
1302 |
+
return $this->getGroupedClassName('block', $blockType);
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
/**
|
1306 |
+
* Retrieve helper class name
|
1307 |
+
*
|
1308 |
+
* @param string $name
|
1309 |
+
* @return string
|
1310 |
+
*/
|
1311 |
+
public function getHelperClassName($helperName)
|
1312 |
+
{
|
1313 |
+
if (strpos($helperName, '/') === false) {
|
1314 |
+
$helperName .= '/data';
|
1315 |
+
}
|
1316 |
+
return $this->getGroupedClassName('helper', $helperName);
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
/**
|
1320 |
+
* Retreive resource helper instance
|
1321 |
+
*
|
1322 |
+
* Example:
|
1323 |
+
* $config->getResourceHelper('cms')
|
1324 |
+
* will instantiate Mage_Cms_Model_Resource_Helper_<db_adapter_name>
|
1325 |
+
*
|
1326 |
+
* @param string $moduleName
|
1327 |
+
* @return Mage_Core_Model_Resource_Helper_Abstract|false
|
1328 |
+
*/
|
1329 |
+
public function getResourceHelper($moduleName)
|
1330 |
+
{
|
1331 |
+
$connectionModel = $this->_getResourceConnectionModel($moduleName);
|
1332 |
+
$helperClass = sprintf('%s/helper_%s', $moduleName, $connectionModel);
|
1333 |
+
$helperClassName = $this->_getResourceModelFactoryClassName($helperClass);
|
1334 |
+
if ($helperClassName) {
|
1335 |
+
return $this->getModelInstance($helperClassName, $moduleName);
|
1336 |
+
}
|
1337 |
+
|
1338 |
+
return false;
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
/**
|
1342 |
+
* Retrieve module class name
|
1343 |
+
*
|
1344 |
+
* @param sting $modelClass
|
1345 |
+
* @return string
|
1346 |
+
*/
|
1347 |
+
public function getModelClassName($modelClass)
|
1348 |
+
{
|
1349 |
+
$modelClass = trim($modelClass);
|
1350 |
+
if (strpos($modelClass, '/')===false) {
|
1351 |
+
return $modelClass;
|
1352 |
+
}
|
1353 |
+
return $this->getGroupedClassName('model', $modelClass);
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
/**
|
1357 |
+
* Get model class instance.
|
1358 |
+
*
|
1359 |
+
* Example:
|
1360 |
+
* $config->getModelInstance('catalog/product')
|
1361 |
+
*
|
1362 |
+
* Will instantiate Mage_Catalog_Model_Mysql4_Product
|
1363 |
+
*
|
1364 |
+
* @param string $modelClass
|
1365 |
+
* @param array|object $constructArguments
|
1366 |
+
* @return Mage_Core_Model_Abstract|false
|
1367 |
+
*/
|
1368 |
+
public function getModelInstance($modelClass='', $constructArguments=array())
|
1369 |
+
{
|
1370 |
+
$className = $this->getModelClassName($modelClass);
|
1371 |
+
if (class_exists($className)) {
|
1372 |
+
Varien_Profiler::start('CORE::create_object_of::'.$className);
|
1373 |
+
$obj = new $className($constructArguments);
|
1374 |
+
Varien_Profiler::stop('CORE::create_object_of::'.$className);
|
1375 |
+
return $obj;
|
1376 |
+
} else {
|
1377 |
+
return false;
|
1378 |
+
}
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
public function getNodeClassInstance($path)
|
1382 |
+
{
|
1383 |
+
$config = Mage::getConfig()->getNode($path);
|
1384 |
+
if (!$config) {
|
1385 |
+
return false;
|
1386 |
+
} else {
|
1387 |
+
$className = $config->getClassName();
|
1388 |
+
return new $className();
|
1389 |
+
}
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
/**
|
1393 |
+
* Get resource model object by alias
|
1394 |
+
*
|
1395 |
+
* @param string $modelClass
|
1396 |
+
* @param array $constructArguments
|
1397 |
+
* @return object
|
1398 |
+
*/
|
1399 |
+
public function getResourceModelInstance($modelClass='', $constructArguments=array())
|
1400 |
+
{
|
1401 |
+
$factoryName = $this->_getResourceModelFactoryClassName($modelClass);
|
1402 |
+
if (!$factoryName) {
|
1403 |
+
return false;
|
1404 |
+
}
|
1405 |
+
return $this->getModelInstance($factoryName, $constructArguments);
|
1406 |
+
}
|
1407 |
+
|
1408 |
+
/**
|
1409 |
+
* Get resource configuration for resource name
|
1410 |
+
*
|
1411 |
+
* @param string $name
|
1412 |
+
* @return Varien_Simplexml_Object
|
1413 |
+
*/
|
1414 |
+
public function getResourceConfig($name)
|
1415 |
+
{
|
1416 |
+
return $this->_xml->global->resources->{$name};
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
/**
|
1420 |
+
* Get connection configuration
|
1421 |
+
*
|
1422 |
+
* @param string $name
|
1423 |
+
* @return Varien_Simplexml_Element
|
1424 |
+
*/
|
1425 |
+
public function getResourceConnectionConfig($name)
|
1426 |
+
{
|
1427 |
+
$config = $this->getResourceConfig($name);
|
1428 |
+
if ($config) {
|
1429 |
+
$conn = $config->connection;
|
1430 |
+
if ($conn) {
|
1431 |
+
if (!empty($conn->use)) {
|
1432 |
+
return $this->getResourceConnectionConfig((string)$conn->use);
|
1433 |
+
} else {
|
1434 |
+
return $conn;
|
1435 |
+
}
|
1436 |
+
}
|
1437 |
+
}
|
1438 |
+
return false;
|
1439 |
+
}
|
1440 |
+
|
1441 |
+
/**
|
1442 |
+
* Retrieve resource type configuration for resource name
|
1443 |
+
*
|
1444 |
+
* @param string $type
|
1445 |
+
* @return Varien_Simplexml_Object
|
1446 |
+
*/
|
1447 |
+
public function getResourceTypeConfig($type)
|
1448 |
+
{
|
1449 |
+
return $this->_xml->global->resource->connection->types->{$type};
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
/**
|
1453 |
+
* Retrieve store Ids for $path with checking
|
1454 |
+
*
|
1455 |
+
* if empty $allowValues then retrieve all stores values
|
1456 |
+
*
|
1457 |
+
* return array($storeId=>$pathValue)
|
1458 |
+
*
|
1459 |
+
* @param string $path
|
1460 |
+
* @param array $allowValues
|
1461 |
+
* @return array
|
1462 |
+
*/
|
1463 |
+
public function getStoresConfigByPath($path, $allowValues = array(), $useAsKey = 'id')
|
1464 |
+
{
|
1465 |
+
$storeValues = array();
|
1466 |
+
$stores = $this->getNode('stores');
|
1467 |
+
foreach ($stores->children() as $code => $store) {
|
1468 |
+
switch ($useAsKey) {
|
1469 |
+
case 'id':
|
1470 |
+
$key = (int) $store->descend('system/store/id');
|
1471 |
+
break;
|
1472 |
+
|
1473 |
+
case 'code':
|
1474 |
+
$key = $code;
|
1475 |
+
break;
|
1476 |
+
|
1477 |
+
case 'name':
|
1478 |
+
$key = (string) $store->descend('system/store/name');
|
1479 |
+
}
|
1480 |
+
if ($key === false) {
|
1481 |
+
continue;
|
1482 |
+
}
|
1483 |
+
|
1484 |
+
$pathValue = (string) $store->descend($path);
|
1485 |
+
|
1486 |
+
if (empty($allowValues)) {
|
1487 |
+
$storeValues[$key] = $pathValue;
|
1488 |
+
} else if (in_array($pathValue, $allowValues)) {
|
1489 |
+
$storeValues[$key] = $pathValue;
|
1490 |
+
}
|
1491 |
+
}
|
1492 |
+
return $storeValues;
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
/**
|
1496 |
+
* Check whether given path should be secure according to configuration security requirements for URL
|
1497 |
+
* "Secure" should not be confused with https protocol, it is about web/secure/*_url settings usage only
|
1498 |
+
*
|
1499 |
+
* @param string $url
|
1500 |
+
* @return bool
|
1501 |
+
*/
|
1502 |
+
public function shouldUrlBeSecure($url)
|
1503 |
+
{
|
1504 |
+
if (!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_SECURE_IN_FRONTEND)) {
|
1505 |
+
return false;
|
1506 |
+
}
|
1507 |
+
|
1508 |
+
if (!isset($this->_secureUrlCache[$url])) {
|
1509 |
+
$this->_secureUrlCache[$url] = false;
|
1510 |
+
$secureUrls = $this->getNode('frontend/secure_url');
|
1511 |
+
foreach ($secureUrls->children() as $match) {
|
1512 |
+
if (strpos($url, (string)$match) === 0) {
|
1513 |
+
$this->_secureUrlCache[$url] = true;
|
1514 |
+
break;
|
1515 |
+
}
|
1516 |
+
}
|
1517 |
+
}
|
1518 |
+
|
1519 |
+
return $this->_secureUrlCache[$url];
|
1520 |
+
}
|
1521 |
+
|
1522 |
+
/**
|
1523 |
+
* Get DB table names prefix
|
1524 |
+
*
|
1525 |
+
* @return string
|
1526 |
+
*/
|
1527 |
+
public function getTablePrefix()
|
1528 |
+
{
|
1529 |
+
return $this->_xml->global->resources->db->table_prefix;
|
1530 |
+
}
|
1531 |
+
|
1532 |
+
/**
|
1533 |
+
* Get events configuration
|
1534 |
+
*
|
1535 |
+
* @param string $area event area
|
1536 |
+
* @param string $eventName event name
|
1537 |
+
* @return Mage_Core_Model_Config_Element
|
1538 |
+
*/
|
1539 |
+
public function getEventConfig($area, $eventName)
|
1540 |
+
{
|
1541 |
+
//return $this->getNode($area)->events->{$eventName};
|
1542 |
+
if (!isset($this->_eventAreas[$area])) {
|
1543 |
+
$this->_eventAreas[$area] = $this->getNode($area)->events;
|
1544 |
+
}
|
1545 |
+
return $this->_eventAreas[$area]->{$eventName};
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
/**
|
1549 |
+
* Save config value to DB
|
1550 |
+
*
|
1551 |
+
* @param string $path
|
1552 |
+
* @param string $value
|
1553 |
+
* @param string $scope
|
1554 |
+
* @param int $scopeId
|
1555 |
+
* @return Mage_Core_Store_Config
|
1556 |
+
*/
|
1557 |
+
public function saveConfig($path, $value, $scope = 'default', $scopeId = 0)
|
1558 |
+
{
|
1559 |
+
$resource = $this->getResourceModel();
|
1560 |
+
$resource->saveConfig(rtrim($path, '/'), $value, $scope, $scopeId);
|
1561 |
+
|
1562 |
+
return $this;
|
1563 |
+
}
|
1564 |
+
|
1565 |
+
/**
|
1566 |
+
* Delete config value from DB
|
1567 |
+
*
|
1568 |
+
* @param string $path
|
1569 |
+
* @param string $scope
|
1570 |
+
* @param int $scopeId
|
1571 |
+
* @return Mage_Core_Model_Config
|
1572 |
+
*/
|
1573 |
+
public function deleteConfig($path, $scope = 'default', $scopeId = 0)
|
1574 |
+
{
|
1575 |
+
$resource = $this->getResourceModel();
|
1576 |
+
$resource->deleteConfig(rtrim($path, '/'), $scope, $scopeId);
|
1577 |
+
|
1578 |
+
return $this;
|
1579 |
+
}
|
1580 |
+
|
1581 |
+
/**
|
1582 |
+
* Get fieldset from configuration
|
1583 |
+
*
|
1584 |
+
* @param string $name fieldset name
|
1585 |
+
* @param string $root fieldset area, could be 'admin'
|
1586 |
+
* @return null|array
|
1587 |
+
*/
|
1588 |
+
public function getFieldset($name, $root = 'global')
|
1589 |
+
{
|
1590 |
+
$rootNode = $this->getNode($root.'/fieldsets');
|
1591 |
+
if (!$rootNode) {
|
1592 |
+
return null;
|
1593 |
+
}
|
1594 |
+
return $rootNode->$name ? $rootNode->$name->children() : null;
|
1595 |
+
}
|
1596 |
+
|
1597 |
+
/**
|
1598 |
+
* Retrieve resource connection model name
|
1599 |
+
*
|
1600 |
+
* @param string $moduleName
|
1601 |
+
* @return string
|
1602 |
+
*/
|
1603 |
+
protected function _getResourceConnectionModel($moduleName = null)
|
1604 |
+
{
|
1605 |
+
$config = null;
|
1606 |
+
if (!is_null($moduleName)) {
|
1607 |
+
$setupResource = $moduleName . '_setup';
|
1608 |
+
$config = $this->getResourceConnectionConfig($setupResource);
|
1609 |
+
}
|
1610 |
+
if (!$config) {
|
1611 |
+
$config = $this->getResourceConnectionConfig(Mage_Core_Model_Resource::DEFAULT_SETUP_RESOURCE);
|
1612 |
+
}
|
1613 |
+
|
1614 |
+
return (string)$config->model;
|
1615 |
+
}
|
1616 |
+
|
1617 |
+
/**
|
1618 |
+
* Get factory class name for a resource
|
1619 |
+
*
|
1620 |
+
* @param string $modelClass
|
1621 |
+
* @return string|false
|
1622 |
+
*/
|
1623 |
+
protected function _getResourceModelFactoryClassName($modelClass)
|
1624 |
+
{
|
1625 |
+
$classArray = explode('/', $modelClass);
|
1626 |
+
if (count($classArray) != 2) {
|
1627 |
+
return false;
|
1628 |
+
}
|
1629 |
+
|
1630 |
+
list($module, $model) = $classArray;
|
1631 |
+
if (!isset($this->_xml->global->models->{$module})) {
|
1632 |
+
return false;
|
1633 |
+
}
|
1634 |
+
|
1635 |
+
$moduleNode = $this->_xml->global->models->{$module};
|
1636 |
+
if (!empty($moduleNode->resourceModel)) {
|
1637 |
+
$resourceModel = (string)$moduleNode->resourceModel;
|
1638 |
+
} else {
|
1639 |
+
return false;
|
1640 |
+
}
|
1641 |
+
|
1642 |
+
return $resourceModel . '/' . $model;
|
1643 |
+
}
|
1644 |
+
|
1645 |
+
/**
|
1646 |
+
* Get a resource model class name
|
1647 |
+
*
|
1648 |
+
* @param string $modelClass
|
1649 |
+
* @return string|false
|
1650 |
+
*/
|
1651 |
+
public function getResourceModelClassName($modelClass)
|
1652 |
+
{
|
1653 |
+
$factoryName = $this->_getResourceModelFactoryClassName($modelClass);
|
1654 |
+
if ($factoryName) {
|
1655 |
+
return $this->getModelClassName($factoryName);
|
1656 |
+
}
|
1657 |
+
return false;
|
1658 |
+
}
|
1659 |
+
}
|
app/etc/modules/Expert_Orderdelete.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Expert_Orderdelete>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Expert_Orderdelete>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Expert_Orderdelete</name>
|
4 |
+
<version>1.0.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension allows you to delete any useless orders. </summary>
|
10 |
+
<description>This extension allows you to delete any useless orders. you can delete order in grid drop-down, grid row and customer view order
|
11 |
+

|
12 |
+
For More Info : www.expertsofttechsolution.com;
|
13 |
+
Email: support@expertsofttechsolution.com</description>
|
14 |
+
<notes>This extension allows you to delete any useless orders. </notes>
|
15 |
+
<authors><author><name>Sharad Patel</name><user>coderz_expert</user><email>coderz.expert@gmail.com</email></author><author><name>Suraj Kumawat</name><user>coderz_expert</user><email>coderz.expert@gmail.com</email></author></authors>
|
16 |
+
<date>2014-01-30</date>
|
17 |
+
<time>07:26:39</time>
|
18 |
+
<contents><target name="magelocal"><dir name="Expert"><dir name="Orderdelete"><dir name="Block"><dir name="Adminhtml"><file name="Orderdelete.php" hash="1b5ef6c4946a09b6a2a7c812983c2e80"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="a5d48dbdd0650c91687475fe22198806"/><dir name="Render"><file name="Delete.php" hash="c53ec66d0501500daa6c1a689cef4041"/></dir><file name="View.php" hash="a6241fc100688749862a6912f006966a"/></dir></dir></dir><file name="Orderdelete.php" hash="b505fc90a1a991a3b83f19e16e6bba6c"/></dir><dir name="Helper"><file name="Data.php" hash="6970a5c6613a934a2aac661681bfbec5"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Orderdelete"><file name="Collection.php" hash="6224e49c15ae6cbabc59887d504d51e9"/></dir><file name="Orderdelete.php" hash="13ca7002633d5e06df5a2ccc822e69d4"/></dir><file name="Orderdelete.php" hash="b5706128821fa38db08e560c3441cd60"/><file name="Status.php" hash="f5cd62b1ae29b015ccbc646214f0d47a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OrderdeleteController.php" hash="932ca5dcae16cb3283f2aff4b90c9dd7"/></dir><file name="IndexController.php" hash="c7a8af3dbbe7653f049c8c5f48942b42"/></dir><dir name="etc"><file name="config.xml" hash="c90df71eab05b4b89e183f639942600e"/><file name="system.xml" hash="1343214dcc00f2e4066856d8f3430f34"/></dir><dir name="sql"><dir name="orderdelete_setup"><file name="mysql4-install-0.1.0.php" hash="b418a26648dd306fae979f80e7fe56b4"/></dir></dir></dir></dir><dir name="Mage"><dir name="Core"><dir name="Model"><file name="Config.php" hash="6607a6ade6ef97d04bedc75084639203"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Expert_Orderdelete.xml" hash="4e5bc3b280ab8d6a89483bb298afc996"/></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|