diff --git a/classes/FileUploader.php b/classes/FileUploader.php index b2611d69f..350579faa 100755 --- a/classes/FileUploader.php +++ b/classes/FileUploader.php @@ -160,12 +160,10 @@ class qqUploadedFileXhr unlink($tmpName); Hook::exec('watermark', array('id_image' => $id_image, 'id_product' => $id_product)); $lang = Context::getContext()->employee->id_lang; - - foreach (Language::getLanguages(false) as $l) - $image->legend[$l['id_lang']] = $id_image." ".$p->name[$l['id_lang']]." ".$p->reference; + if (!$image->update()) return array('error' => Tools::displayError('Error while updating status')); - $img = array('id_image' => $image->id, 'legend' => $image->legend[$lang], 'position' => $image->position, 'cover' => $image->cover); + $img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover); return array("success" => $img); } @@ -173,6 +171,7 @@ class qqUploadedFileXhr { return $_GET['qqfile']; } + function getSize() { if (isset($_SERVER["CONTENT_LENGTH"])) diff --git a/classes/Image.php b/classes/Image.php index 9cc07da05..15dce1d27 100644 --- a/classes/Image.php +++ b/classes/Image.php @@ -35,9 +35,6 @@ class ImageCore extends ObjectModel /** @var integer Product ID */ public $id_product; - /** @var string HTML title and alt attributes */ - public $legend; - /** @var integer Position used to order images of the same product */ public $position; @@ -70,9 +67,6 @@ class ImageCore extends ObjectModel 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'cover' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - - // Lang fields - 'legend' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), ), ); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index c9d69d333..5170261d3 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1130,7 +1130,6 @@ class AdminImportControllerCore extends AdminController $image->id_product = (int)$product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = (!$key && !$product_has_images) ? true : false; - $image->legend = self::createMultiLangField($product->name[$default_language_id]); if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) { @@ -1139,7 +1138,7 @@ class AdminImportControllerCore extends AdminController } else { - $this->warnings[] = $image->legend[$default_language_id].(isset($image->id_product) ? ' ('.$image->id_product.')' : ''). + $this->warnings[] = (isset($image->id_product) ? ' ('.$image->id_product.')' : ''). ' '.Tools::displayError('Cannot be saved'); $this->_errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -1208,7 +1207,6 @@ class AdminImportControllerCore extends AdminController $image->id_product = (int)$product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = (!$product_has_images) ? true : false; - $image->legend = self::createMultiLangField($product->name); if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) @@ -1220,7 +1218,7 @@ class AdminImportControllerCore extends AdminController } else { - $this->warnings[] = $image->legend[$default_language_id].(isset($image->id_product) ? ' ('.$image->id_product.')' : ''). + $this->warnings[] = (isset($image->id_product) ? ' ('.$image->id_product.')' : ''). ' '.Tools::displayError('Cannot be saved'); $this->_errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').mysql_error(); } diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 494c88196..4981da5a8 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -483,10 +483,7 @@ class AdminProductsControllerCore extends AdminController { if ($image->cover) $_POST['cover'] = 1; - $languages = Language::getLanguages(false); - foreach ($languages as $language) - if (isset($image->legend[$language['id_lang']])) - $_POST['legend_'.$language['id_lang']] = $image->legend[$language['id_lang']]; + $_POST['id_image'] = $image->id; } @@ -795,7 +792,7 @@ class AdminProductsControllerCore extends AdminController if (!$specificPrice->delete()) $this->_errors[] = Tools::displayError('An error occurred while deleting the specific price'); else - $this->redirect_after = self::$currentIndex.(Tools::getValue('id_category') ? '&action=Prices&id_category='.Tools::getValue('id_category') : '').'&id_product='.$obj->id.'&add'.$this->table.'&conf=1&token='.($token ? $token : $this->token); + $this->confirmations[] = $this->l('Specific price successfully deleted'); } } @@ -810,12 +807,12 @@ class AdminProductsControllerCore extends AdminController if (!SpecificPrice::setPriorities($priorities)) $this->_errors[] = Tools::displayError('An error occurred while updating priorities.'); else - $this->redirect_after = self::$currentIndex.'&id_product='.$obj->id.'&add'.$this->table.'&action=Prices&conf=4&token='.($token ? $token : $this->token); + $this->confirmations[] = $this->l('Price rule successfully updated'); } else if (!SpecificPrice::setSpecificPriority((int)($obj->id), $priorities)) $this->_errors[] = Tools::displayError('An error occurred while setting priorities.'); else - $this->redirect_after = self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&action=Prices&id_product='.$obj->id.'&add'.$this->table.'&conf=4&token='.($token ? $token : $this->token); + $this->confirmations[] = $this->l('Price priorities successfully updated'); } public function processCustomizationConfiguration($token) @@ -966,7 +963,10 @@ class AdminProductsControllerCore extends AdminController else if (Tools::isSubmit('submitSpecificPricePriorities')) { if ($this->tabAccess['edit'] === '1') + { $this->action = 'specificPricePriorities'; + $this->tab_display = 'prices'; + } else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } @@ -1024,15 +1024,6 @@ class AdminProductsControllerCore extends AdminController */ public function postProcess($token = null) { - if ($this->action == 'attachments') - if ($id = (int)Tools::getValue($this->identifier)) - { - $attachments = trim(Tools::getValue('arrayAttachments'), ','); - $attachments_tab = explode(',', $attachments); - if (Attachment::attachToProduct($id, $attachments_tab)) - $this->redirect_after = self::$currentIndex.'&id_product='.(int)$id.(isset($_POST['id_category']) ? '&id_category='.(int)$_POST['id_category'] : '').'&conf=4&add'.$this->table.'&action=Attachments&token='.($token ? $token : $this->token); - } - if (!$this->redirect_after) parent::postProcess(true); } @@ -1247,26 +1238,22 @@ class AdminProductsControllerCore extends AdminController public function ajaxProcessDeleteProductImage() { - /* Delete product image */ - if (isset($_GET['deleteProductImage']) || $this->action == 'deleteProductImage') + $image = new Image((int)Tools::getValue('id_image')); + $image->delete(); + if (!Image::getCover($image->id_product)) { - $image = new Image((int)Tools::getValue('id_image')); - $image->delete(); - if (!Image::getCover($image->id_product)) - { - $first_img = Db::getInstance()->getRow(' - SELECT `id_image` FROM `'._DB_PREFIX_.'image` - WHERE `id_product` = '.(int)$image->id_product); - Db::getInstance()->Execute(' - UPDATE `'._DB_PREFIX_.'image` - SET `cover` = 1 - WHERE `id_image` = '.(int)$first_img['id_image']); - } - @unlink(_PS_TMP_IMG_DIR_.'/product_'.$image->id_product.'.jpg'); - @unlink(_PS_TMP_IMG_DIR_.'/product_mini_'.$image->id_product.'.jpg'); - - $this->content = '{"status":"ok"}'; + $first_img = Db::getInstance()->getRow(' + SELECT `id_image` FROM `'._DB_PREFIX_.'image` + WHERE `id_product` = '.(int)$image->id_product); + Db::getInstance()->Execute(' + UPDATE `'._DB_PREFIX_.'image` + SET `cover` = 1 + WHERE `id_image` = '.(int)$first_img['id_image']); } + @unlink(_PS_TMP_IMG_DIR_.'/product_'.$image->id_product.'.jpg'); + @unlink(_PS_TMP_IMG_DIR_.'/product_mini_'.$image->id_product.'.jpg'); + + $this->content = '{"status":"ok"}'; } protected function _validateSpecificPrice($id_shop, $id_currency, $id_country, $id_group, $id_customer, $price, $from_quantity, $reduction, $reduction_type, $from, $to) @@ -3885,7 +3872,6 @@ class AdminProductsControllerCore extends AdminController public function setMedia() { parent::setMedia(); - if ($this->display == 'edit' || $this->display == 'add') { $this->addjQueryPlugin(array(