From 4b492046c0e4e1ab4514c6ef920746770d7239ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Fri, 12 Jul 2013 10:55:37 +0200 Subject: [PATCH] // add another logs information --- classes/controller/AdminController.php | 27 ++++++++++++----- controllers/admin/AdminImportController.php | 30 ++++++++++++------- controllers/admin/AdminProductsController.php | 7 ++++- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 22a74d32a..db328b8de 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2714,18 +2714,31 @@ class AdminControllerCore extends Controller else { $result = true; - if ($this->deleted) + foreach ($this->boxes as $id) { - foreach ($this->boxes as $id) + $to_delete = new $this->className($id); + $delete_ok = true; + if ($this->deleted) { - $to_delete = new $this->className($id); $to_delete->deleted = 1; - $result = $result && $to_delete->update(); + if (!$to_delete->update()) + { + $result = false; + $delete_ok = false; + } } + else + if (!$to_delete->delete()) + { + $result = false; + $delete_ok = false; + } + + if ($delete_ok) + Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$to_delete->id, true, (int)$this->context->employee->id); + else + $this->errors[] = sprintf(Tools::displayError('Can\'t delete #%d'), $id); } - else - $result = $object->deleteSelection(Tools::getValue($this->table.'Box')); - if ($result) $this->redirect_after = self::$currentIndex.'&conf=2&token='.$this->token; $this->errors[] = Tools::displayError('An error occurred while deleting this selection.'); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 81723c4fc..e267e3b0f 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -2710,43 +2710,51 @@ class AdminImportControllerCore extends AdminController // If i am a superadmin, i can truncate table if (((Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive()) && Tools::getValue('truncate')) $this->truncateTables((int)Tools::getValue('entity')); - + $import_type = false; switch ((int)Tools::getValue('entity')) { - case $this->entities[$this->l('Categories')]: + case $this->entities[$import_type = $this->l('Categories')]: $this->categoryImport(); break; - case $this->entities[$this->l('Products')]: + case $this->entities[$import_type = $this->l('Products')]: + $import_type = $this->l('Categories'); $this->productImport(); break; - case $this->entities[$this->l('Customers')]: + case $this->entities[$import_type = $this->l('Customers')]: $this->customerImport(); break; - case $this->entities[$this->l('Addresses')]: + case $this->entities[$import_type = $this->l('Addresses')]: $this->addressImport(); break; - case $this->entities[$this->l('Combinations')]: + case $this->entities[$import_type = $this->l('Combinations')]: $this->attributeImport(); break; - case $this->entities[$this->l('Manufacturers')]: + case $this->entities[$import_type = $this->l('Manufacturers')]: $this->manufacturerImport(); break; - case $this->entities[$this->l('Suppliers')]: + case $this->entities[$import_type = $this->l('Suppliers')]: $this->supplierImport(); break; // @since 1.5.0 - case $this->entities[$this->l('Supply Orders')]: + case $this->entities[$import_type = $this->l('Supply Orders')]: if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) $this->supplyOrdersImport(); break; // @since 1.5.0 - case $this->entities[$this->l('Supply Order Details')]: + case $this->entities[$import_type = $this->l('Supply Order Details')]: if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) $this->supplyOrdersDetailsImport(); break; default: $this->errors[] = $this->l('Please select what you would like to import'); } + if ($import_type !== false) + { + $log_message = sprintf($this->l('%s import'), $import_type); + if (Tools::getValue('truncate')) + $log_message .= ' '.$this->l('with truncate'); + Logger::addLog($log_message, 1, null, $import_type, null, true, (int)$this->context->employee->id); + } } else $this->errors[] = $this->l('You must upload a file in order to proceed to the next step'); @@ -2806,4 +2814,4 @@ class AdminImportControllerCore extends AdminController die; } } -} +} \ No newline at end of file diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 5c0ee88a0..f9d9a803a 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -739,7 +739,12 @@ class AdminProductsControllerCore extends AdminController $this->errors[] = sprintf(Tools::displayError('You cannot delete the product #%d because there is physical stock left.'), $product->id); } if (!count($this->errors)) - $success &= $product->delete(); + { + if ($product->delete()) + Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$product->id, true, (int)$this->context->employee->id); + else + $success = false; + } else $success = 0; }