From 7ed9ceb59391e0ede7cbea0edbacbf20569419a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 11 Jun 2013 12:18:05 +0200 Subject: [PATCH] [-] BO: Addresses are now totally deleted from the database if not used on a order --- .../admin/AdminAddressesController.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index 959687eef..9c7f49734 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -444,4 +444,41 @@ class AdminAddressesControllerCore extends AdminController } die; } + + /** + * Object Delete + */ + public function processDelete() + { + if (Validate::isLoadedObject($object = $this->loadObject())) + if (!$object->isUsed()) + $this->deleted = false; + + return parent::processDelete(); + } + + /** + * Delete multiple items + * + * @return boolean true if succcess + */ + protected function processBulkDelete() + { + if (is_array($this->boxes) && !empty($this->boxes)) + { + $deleted = false; + foreach ($this->boxes as $id) + { + $to_delete = new Address((int)$id); + if ($to_delete->isUsed()) + { + $deleted = true; + break; + } + } + $this->deleted = $deleted; + } + + parent::processBulkDelete(); + } }