Skip to content

Commit

Permalink
Added admin area check function into _beforeDelete methods of some mo…
Browse files Browse the repository at this point in the history
…dels

Fixed merging compare lists
  • Loading branch information
Magento Core Team committed Sep 2, 2008
1 parent f5ae7b0 commit 3e5d919
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Mage.php
Expand Up @@ -74,7 +74,7 @@ final class Mage {

public static function getVersion()
{
return '1.1.3';
return '1.1.4';
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app/code/core/Mage/Catalog/Model/Category.php
Expand Up @@ -429,4 +429,9 @@ public function getName()
return $this->_getData('name');
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
3 changes: 2 additions & 1 deletion app/code/core/Mage/Catalog/Model/Product.php
Expand Up @@ -373,7 +373,8 @@ protected function _beforeDelete()
{
$this->_substractQtyFromQuotes();
$this->cleanCache();
parent::_beforeDelete();
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}

/**
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Catalog/Model/Product/Compare/Item.php
Expand Up @@ -80,7 +80,6 @@ public function bindCustomerLogin()
$customer = Mage::getSingleton('customer/session')->getCustomer();
$visitorItemCollection = Mage::getResourceModel('catalog/product_compare_item_collection')
->setObject('catalog/product_compare_item')
->useProductItem(true)
->setVisitorId(Mage::getSingleton('log/visitor')->getId())
->load();

Expand Down
12 changes: 12 additions & 0 deletions app/code/core/Mage/Core/Model/Abstract.php
Expand Up @@ -313,6 +313,18 @@ protected function _beforeDelete()
return $this;
}

/**
* Safeguard func that will check, if we are in admin area
*
* @throws Mage_Core_Exception
*/
protected function _protectFromNonAdmin()
{
if (!Mage::app()->getStore()->isAdmin()) {
Mage::throwException(Mage::helper('core')->__('Cannot complete this operation from non-admin area.'));
}
}

/**
* Processing object after delete data
*
Expand Down
5 changes: 5 additions & 0 deletions app/code/core/Mage/Core/Model/Store.php
Expand Up @@ -742,4 +742,9 @@ public function getName()
return $this->_getData('name');
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Core/Model/Store/Group.php
Expand Up @@ -251,4 +251,9 @@ public function getWebsiteId()
return $this->_getData('website_id');
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Core/Model/Website.php
Expand Up @@ -433,4 +433,9 @@ public function getCode()
return $this->_getData('code');
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Customer/Model/Customer.php
Expand Up @@ -924,4 +924,9 @@ function validateAddress(array $data, $type = 'billing')
return false;
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
6 changes: 6 additions & 0 deletions app/code/core/Mage/Review/Model/Review.php
Expand Up @@ -127,4 +127,10 @@ public function appendSummary($collection)
}
}
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
6 changes: 6 additions & 0 deletions app/code/core/Mage/Sales/Model/Order.php
Expand Up @@ -1417,4 +1417,10 @@ protected function _needToAddDummy($item, $qtys = array()) {
return false;
}
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
6 changes: 6 additions & 0 deletions app/code/core/Mage/Sales/Model/Order/Creditmemo.php
Expand Up @@ -667,4 +667,10 @@ protected function _getEmails($configPath)
}
return false;
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
6 changes: 6 additions & 0 deletions app/code/core/Mage/Sales/Model/Order/Invoice.php
Expand Up @@ -684,4 +684,10 @@ protected function _getEmails($configPath)
}
return false;
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
6 changes: 6 additions & 0 deletions app/code/core/Mage/Sales/Model/Order/Shipment.php
Expand Up @@ -448,4 +448,10 @@ protected function _beforeSave()
);
}
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}
6 changes: 6 additions & 0 deletions app/code/core/Mage/Tag/Model/Tag.php
Expand Up @@ -142,4 +142,10 @@ public function getPopularCollection()
{
return Mage::getResourceModel('tag/popular_collection');
}

protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
return parent::_beforeDelete();
}
}

0 comments on commit 3e5d919

Please sign in to comment.