public function postProcess()
 {
     global $currentIndex;
     if (Tools::isSubmit('submitPrint')) {
         if (!Validate::isDate(Tools::getValue('date_from'))) {
             $this->_errors[] = $this->l('Invalid from date');
         }
         if (!Validate::isDate(Tools::getValue('date_to'))) {
             $this->_errors[] = $this->l('Invalid end date');
         }
         if (!sizeof($this->_errors)) {
             $orders = Order::getOrdersIdInvoiceByDate(Tools::getValue('date_from'), Tools::getValue('date_to'), NULL, 'invoice');
             if (sizeof($orders)) {
                 Tools::redirectAdmin('pdf.php?invoices&date_from=' . urlencode(Tools::getValue('date_from')) . '&date_to=' . urlencode(Tools::getValue('date_to')) . '&token=' . $this->token);
             }
             $this->_errors[] = $this->l('No invoice found for this period');
         }
     } elseif (Tools::isSubmit('submitOptionsinvoice')) {
         if (intval(Tools::getValue('PS_INVOICE_NUMBER')) == 0) {
             $this->_errors[] = $this->l('Invalid invoice number');
         } else {
             parent::postProcess();
         }
     } else {
         parent::postProcess();
     }
 }
 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table])) {
         $search = strval(Tools::getValue('search'));
         $string = strval(Tools::getValue('alias'));
         $aliases = explode(',', $string);
         if (empty($search) or empty($string)) {
             $this->_errors[] = $this->l('aliases and result are both required');
         }
         if (!Validate::isValidSearch($search)) {
             $this->_errors[] = $search . ' ' . $this->l('is not a valid result');
         }
         foreach ($aliases as $alias) {
             if (!Validate::isValidSearch($alias)) {
                 $this->_errors[] = $alias . ' ' . $this->l('is not a valid alias');
             }
         }
         if (!sizeof($this->_errors)) {
             foreach ($aliases as $alias) {
                 $obj = new Alias(NULL, trim($alias), trim($search));
                 $obj->save();
             }
         }
     } else {
         parent::postProcess();
     }
 }
示例#3
0
 public function postProcess()
 {
     if (isset($_GET['delete' . $this->table]) or Tools::getValue('submitDel' . $this->table)) {
         $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
     } else {
         if (Tools::getValue('submitAdd' . $this->table)) {
             $id_country = Tools::getValue('id_country');
             $tmp_addr_format = new AddressFormat($id_country);
             $save_status = false;
             $is_new = is_null($tmp_addr_format->id_country);
             if ($is_new) {
                 $tmp_addr_format = new AddressFormat();
                 $tmp_addr_format->id_country = $id_country;
             }
             $tmp_addr_format->format = Tools::getValue('address_layout');
             if (strlen($tmp_addr_format->format) > 0) {
                 if ($tmp_addr_format->checkFormatFields()) {
                     $save_status = $is_new ? $tmp_addr_format->save() : $tmp_addr_format->update();
                 } else {
                     $errorList = $tmp_addr_format->getErrorList();
                     foreach ($errorList as $numError => $error) {
                         $this->_errors[] = $error;
                     }
                 }
                 if (!$save_status) {
                     $this->_errors[] = Tools::displayError('Invalid address layout' . Db::getInstance()->getMsgError());
                 }
             }
             unset($tmp_addr_format);
         }
         return parent::postProcess();
     }
 }
 public function postProcess()
 {
     global $cookie, $currentIndex;
     $this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
     $this->adminAttributes->postProcess($this->token);
     Module::hookExec('postProcessAttributeGroup', array('errors' => &$this->_errors));
     // send _errors as reference to allow postProcessAttributeGroup to stop saving process
     if (Tools::getValue('submitDel' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (isset($_POST[$this->table . 'Box'])) {
                 $object = new $this->className();
                 if ($object->deleteSelection($_POST[$this->table . 'Box'])) {
                     Tools::redirectAdmin($currentIndex . '&conf=2' . '&token=' . $this->token);
                 }
                 $this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
             } else {
                 $this->_errors[] = Tools::displayError('You must select at least one element to delete.');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } else {
         parent::postProcess();
     }
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id = intval(Tools::getValue('id_attachment')) and $a = new Attachment($id)) {
             $_POST['file'] = $a->file;
             $_POST['mime'] = $a->mime;
         }
         if (!sizeof($this->_errors)) {
             if (isset($_FILES['file']) and is_uploaded_file($_FILES['file']['tmp_name'])) {
                 if ($_FILES['file']['size'] > $this->maxFileSize) {
                     $this->_errors[] = $this->l('File too large, maximum size allowed:') . ' ' . $this->maxFileSize / 1000 . ' ' . $this->l('kb');
                 } else {
                     $uploadDir = dirname(__FILE__) . '/../../download/';
                     do {
                         $uniqid = sha1(microtime());
                     } while (file_exists($uploadDir . $uniqid));
                     if (!copy($_FILES['file']['tmp_name'], $uploadDir . $uniqid)) {
                         $this->_errors[] = $this->l('File copy failed');
                     }
                     @unlink($_FILES['file']['tmp_name']);
                     $_POST['name_2'] .= '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
                     $_POST['file'] = $uniqid;
                     $_POST['mime'] = $_FILES['file']['type'];
                 }
             }
         }
         $this->validateRules();
     }
     return parent::postProcess();
 }
 public function postProcess()
 {
     global $cookie, $currentIndex;
     $this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
     $this->adminAttributes->postProcess($this->token);
     Module::hookExec('postProcessAttributeGroup', array('errors' => &$this->_errors));
     // send _errors as reference to allow postProcessAttributeGroup to stop saving process
     if (Tools::getValue('submitDel' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (isset($_POST[$this->table . 'Box'])) {
                 $object = new $this->className();
                 if ($object->deleteSelection($_POST[$this->table . 'Box'])) {
                     Tools::redirectAdmin($currentIndex . '&conf=2' . '&token=' . $this->token);
                 }
                 $this->_errors[] = Tools::displayError('cannot delete this Attribute Group, the selected item is still associated with one or more product combinations');
             } else {
                 $this->_errors[] = Tools::displayError('You must select at least one element to delete.');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } else {
         parent::postProcess();
     }
     if (isset($this->_errors) && count($this->_errors)) {
         $key = array_search('An error occurred during deletion of ' . $this->table . '.', $this->_errors);
         if ($key !== false) {
             $this->_errors[$key] = Tools::displayError('cannot delete this Attribute Group, the selected item is still associated with one or more product combinations');
         }
     }
 }
示例#7
0
 public function postProcess()
 {
     global $cookie;
     $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id_category = intval(Tools::getValue('id_category'))) {
             if (!Category::checkBeforeMove($id_category, intval(Tools::getValue('id_parent')))) {
                 $this->_errors[] = Tools::displayError('category cannot be moved here');
                 return false;
             }
             // Updating customer's group
             if ($this->tabAccess['edit'] !== '1') {
                 $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
             } else {
                 $object = new $this->className($id_category);
                 if (Validate::isLoadedObject($object)) {
                     $object->updateGroup(Tools::getValue('groupBox'));
                 } else {
                     $this->_errors[] = Tools::displayError('an error occurred while updating object') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                 }
             }
         }
     }
     parent::postProcess();
 }
 public function postProcess()
 {
     global $currentIndex;
     $this->product = new Product(intval(Tools::getValue('id_product')));
     if (isset($_POST['generate'])) {
         if (!is_array(Tools::getValue('options'))) {
             $this->_errors[] = Tools::displayError('You need to choose at least 1 attribute.');
         } else {
             $tab = array_values($_POST['options']);
             if (sizeof($tab) and Validate::isLoadedObject($this->product)) {
                 self::setAttributesImpacts($this->product->id, $tab);
                 $this->combinations = array_values(self::createCombinations($tab));
                 $values = array_values(array_map(array($this, 'addAttribute'), $this->combinations));
                 $this->product->deleteProductAttributes();
                 $res = $this->product->addProductAttributeMultiple($values);
                 $this->product->addAttributeCombinationMultiple($res, $this->combinations);
             } else {
                 $this->_errors[] = Tools::displayError('Unable to initialize parameters, combinations is missing or object cannot be load.');
             }
         }
     } elseif (isset($_POST['back'])) {
         Tools::redirectAdmin($currentIndex . '&id_product=' . intval(Tools::getValue('id_product')) . '&id_category=' . intval(Tools::getValue('id_category')) . '&addproduct' . '&tabs=2&token=' . Tools::getValue('token'));
     }
     parent::postProcess();
 }
 public function postProcess()
 {
     if (isset($_GET['delete' . $this->table]) || Tools::getValue('submitDel' . $this->table)) {
         $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
     } elseif (Tools::getValue('submitAdd' . $this->table)) {
         if (!Tools::getValue('id_' . $this->table)) {
             if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) {
                 $this->_errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
             }
         } else {
             if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
                 $id_country = Country::getByIso(Tools::getValue('iso_code'));
                 if (!is_null($id_country) && $id_country != Tools::getValue('id_' . $this->table)) {
                     $this->_errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
                 }
             }
         }
         if (Tools::isSubmit('standardization')) {
             Configuration::updateValue('PS_TAASC', (bool) Tools::getValue('standardization', false));
         }
         if (isset($this->_errors) && count($this->_errors)) {
             return false;
         }
     }
     return parent::postProcess();
 }
示例#10
0
 public function postProcess()
 {
     if (isset($_GET['delete' . $this->table]) or Tools::getValue('submitDel' . $this->table)) {
         $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
     } else {
         return parent::postProcess();
     }
 }
示例#11
0
 public function postProcess()
 {
     global $cookie;
     if (Tools::isSubmit('rebuildStock')) {
         StockMvt::addMissingMvt((int) $cookie->id_employee, false);
     }
     return parent::postProcess();
 }
 public function postProcess()
 {
     if (isset($_GET['delete' . $this->table]) and $_GET[$this->identifier] == (int) _PS_ADMIN_PROFILE_) {
         $this->_errors[] = $this->l('For security reasons, you cannot delete the Administrator profile');
     } else {
         parent::postProcess();
     }
 }
示例#13
0
 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table]) and Tools::getValue('delimiter1') >= Tools::getValue('delimiter2')) {
         $this->_errors[] = Tools::displayError('invalid range');
     } else {
         parent::postProcess();
     }
 }
示例#14
0
 public function postProcess()
 {
     if ($this->tabAccess['edit'] === '1' and Tools::getValue('submitAdd' . $this->table)) {
         if ($id = intval(Tools::getValue($this->identifier)) and $obj = new $this->className($id) and Validate::isLoadedObject($obj)) {
             $obj->setProducts($_POST['products']);
         }
     }
     return parent::postProcess();
 }
    public function postProcess()
    {
        $result = Db::getInstance()->ExecuteS('
			SELECT `id_subdomain`
			FROM `' . _DB_PREFIX_ . 'subdomain`
		');
        if (sizeof($result) === 1) {
            foreach ($result as $row) {
                $this->_listSkipDelete = array($row['id_subdomain']);
            }
        }
        return parent::postProcess();
    }
示例#16
0
 public function postProcess()
 {
     if ($id_tab = intval(Tools::getValue('id_tab')) and $direction = Tools::getValue('move') and Validate::isLoadedObject($tab = new Tab($id_tab))) {
         global $currentIndex;
         if ($tab->move($direction)) {
             Tools::redirectAdmin($currentIndex . '&token=' . $this->token);
         }
     } else {
         if (!Tools::getValue('position')) {
             $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent'));
         }
         parent::postProcess();
     }
 }
示例#17
0
 public function postProcess()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
         return;
     }
     /* PrestaShop demo mode*/
     if (isset($_GET['delete' . $this->table]) and $_GET[$this->identifier] == (int) _PS_ADMIN_PROFILE_) {
         $this->_errors[] = $this->l('For security reasons, you cannot delete the Administrator profile');
     } else {
         parent::postProcess();
     }
 }
 public function postProcess()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
         return;
     }
     global $cookie;
     $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
     if ($this->tabAccess['add'] === '1' and Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id = (int) Tools::getValue('id_attachment') and $a = new Attachment($id)) {
             $_POST['file'] = $a->file;
             $_POST['mime'] = $a->mime;
         }
         if (!sizeof($this->_errors)) {
             if (isset($_FILES['file']) and is_uploaded_file($_FILES['file']['tmp_name'])) {
                 if ($_FILES['file']['size'] > Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024) {
                     $this->_errors[] = $this->l('File too large, maximum size allowed:') . ' ' . Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 . ' ' . $this->l('kb') . '. ' . $this->l('File size you\'re trying to upload is:') . number_format($_FILES['file']['size'] / 1024, 2, '.', '') . $this->l('kb');
                 } else {
                     do {
                         $uniqid = sha1(microtime());
                     } while (file_exists(_PS_DOWNLOAD_DIR_ . $uniqid));
                     if (!copy($_FILES['file']['tmp_name'], _PS_DOWNLOAD_DIR_ . $uniqid)) {
                         $this->_errors[] = $this->l('File copy failed');
                     }
                     $_POST['file_name'] = $_FILES['file']['name'];
                     @unlink($_FILES['file']['tmp_name']);
                     if (!sizeof($this->_errors) && file_exists(_PS_DOWNLOAD_DIR_ . $a->file)) {
                         @unlink(_PS_DOWNLOAD_DIR_ . $a->file);
                     }
                     $_POST['file'] = $uniqid;
                     $_POST['mime'] = $_FILES['file']['type'];
                 }
             } elseif (array_key_exists('file', $_FILES) && (int) $_FILES['file']['error'] === 1) {
                 $max_upload = (int) ini_get('upload_max_filesize');
                 $max_post = (int) ini_get('post_max_size');
                 $upload_mb = min($max_upload, $max_post);
                 $this->_errors[] = $this->l('the File') . ' <b>' . $_FILES['file']['name'] . '</b> ' . $this->l('exceeds the size allowed by the server. This limit is set to') . ' <b>' . $upload_mb . $this->l('Mb') . '</b>';
             } elseif (!empty($_FILES['file']['tmp_name'])) {
                 $this->_errors[] = $this->l('The file does not exist or cannot be downloaded;check your server configuration regarding the maximum upload size.');
             }
         }
         $this->validateRules();
     }
     $return = parent::postProcess();
     if (!$return && isset($uniqid) && file_exists(_PS_DOWNLOAD_DIR_ . $uniqid)) {
         @unlink(_PS_DOWNLOAD_DIR_ . $uniqid);
     }
     return $return;
 }
示例#19
0
 public function postProcess()
 {
     global $currentIndex, $cookie;
     if (Tools::isSubmit('deleteorder_return_detail')) {
         if ($this->tabAccess['delete'] === '1') {
             if ($id_order_detail = intval(Tools::getValue('id_order_detail')) and Validate::isUnsignedId($id_order_detail)) {
                 if ($id_order_return = intval(Tools::getValue('id_order_return')) and Validate::isUnsignedId($id_order_return)) {
                     $orderReturn = new OrderReturn($id_order_return);
                     if (!Validate::isLoadedObject($orderReturn)) {
                         die(Tools::displayError());
                     }
                     if (intval($orderReturn->countProduct()) > 1) {
                         if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, intval(Tools::getValue('id_customization', 0)))) {
                             Tools::redirectAdmin($currentIndex . '&conf=4token=' . $this->token);
                         } else {
                             $this->_errors[] = Tools::displayError('an error occured while deleting an order return detail');
                         }
                     } else {
                         $this->_errors[] = Tools::displayError('you need at least one product');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('the order return is invalid');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('the order return detail is invalid');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif (Tools::isSubmit('submitAddorder_return')) {
         if ($this->tabAccess['edit'] === '1') {
             if ($id_order_return = intval(Tools::getValue('id_order_return')) and Validate::isUnsignedId($id_order_return)) {
                 $orderReturn = new OrderReturn($id_order_return);
                 $customer = new Customer($orderReturn->id_customer);
                 $orderReturn->state = intval(Tools::getValue('state'));
                 if ($orderReturn->save()) {
                     $orderReturnState = new OrderReturnState($orderReturn->state);
                     $vars = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order_return}' => $id_order_return, '{state_order_return}' => $orderReturnState->name[intval(Configuration::get('PS_LANG_DEFAULT'))]);
                     Mail::Send(intval($cookie->id_lang), 'order_return_state', html_entity_decode($this->l('Your order return state has changed'), ENT_NOQUOTES, 'UTF-8'), $vars, $customer->email, $customer->firstname . ' ' . $customer->lastname);
                     Tools::redirectAdmin($currentIndex . '&conf=4&token=' . $this->token);
                 }
             } else {
                 $this->_errors[] = Tools::displayError('no order return ID.');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     }
     parent::postProcess();
 }
示例#20
0
 public function postProcess()
 {
     global $currentIndex;
     if (Tools::getValue('submitRegenerate' . $this->table)) {
         if ($this->tabAccess['edit'] === '1') {
             if ($this->_regenerateThumbnails(Tools::getValue('type'), Tools::getValue('erase'))) {
                 Tools::redirectAdmin($currentIndex . '&conf=9' . '&token=' . $this->token);
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } else {
         parent::postProcess();
     }
 }
示例#21
0
 public function postProcess()
 {
     if (!isset($this->table)) {
         return false;
     }
     /* Delete object */
     if (isset($_GET['delete' . $this->table])) {
         global $currentIndex;
         // set token
         $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
         // Sub included tab postProcessing
         $this->includeSubTab('postProcess', array('submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset'));
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) and isset($this->fieldImageSettings)) {
                 if (!$object->isUsed()) {
                     // check if request at least one object with noZeroObject
                     if (isset($object->noZeroObject) and sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) {
                         $this->_errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                     } else {
                         $this->deleteImage($object->id);
                         if ($this->deleted) {
                             $object->deleted = 1;
                             if ($object->update()) {
                                 Tools::redirectAdmin($currentIndex . '&conf=1&token=' . $token);
                             }
                         } else {
                             if ($object->delete()) {
                                 Tools::redirectAdmin($currentIndex . '&conf=1&token=' . $token);
                             }
                         }
                         $this->_errors[] = Tools::displayError('An error occurred during deletion.');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('This state is currently in use');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } else {
         parent::postProcess();
     }
 }
 public function postProcess()
 {
     $post_action = array('type' => Tools::getValue('MR_action_name'), 'message_success' => $this->l('Action Succeed'), 'had_errors' => false);
     parent::postProcess();
     if (Tools::isSubmit('submit_order_state')) {
         if ($order_state = (int) Tools::getValue('id_order_state')) {
             $this->mondialrelay->account_shop['MR_ORDER_STATE'] = $order_state;
             if ($this->mondialrelay->updateAccountShop()) {
                 $post_action['message_success'] = $this->l('Order State has been updated');
             } else {
                 $this->post_errors[] = $this->l('Cannot Update the account shop');
             }
         }
     }
     if (count($this->post_errors)) {
         $post_action['had_errors'] = true;
     }
     return $post_action;
 }
示例#23
0
    public function postProcess()
    {
        /* PrestaShop demo mode */
        if (_PS_MODE_DEMO_) {
            $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
            return;
        }
        /* PrestaShop demo mode*/
        $result = Db::getInstance()->ExecuteS('
			SELECT `id_subdomain`
			FROM `' . _DB_PREFIX_ . 'subdomain`
		');
        if (sizeof($result) === 1) {
            foreach ($result as $row) {
                $this->_listSkipDelete = array($row['id_subdomain']);
            }
        }
        return parent::postProcess();
    }
示例#24
0
 public function postProcess()
 {
     if (Tools::isSubmit('submitPrint')) {
         if (!Validate::isDate(Tools::getValue('date_from'))) {
             $this->_errors[] = $this->l('Invalid from date');
         }
         if (!Validate::isDate(Tools::getValue('date_to'))) {
             $this->_errors[] = $this->l('Invalid end date');
         }
         if (!sizeof($this->_errors)) {
             $orderSlips = OrderSlip::getSlipsIdByDate(Tools::getValue('date_from'), Tools::getValue('date_to'));
             if (count($orderSlips)) {
                 Tools::redirectAdmin('pdf.php?slips&date_from=' . urlencode(Tools::getValue('date_from')) . '&date_to=' . urlencode(Tools::getValue('date_to')) . '&token=' . $this->token);
             }
             $this->_errors[] = $this->l('No order slips found for this period');
         }
     }
     return parent::postProcess();
 }
 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table])) {
         $delimiter1 = Tools::getValue('delimiter1');
         $delimiter2 = Tools::getValue('delimiter2');
         if ($delimiter1 >= $delimiter2) {
             $this->_errors[] = Tools::displayError('Invalid range, "From" must be lower than "To"');
         }
         /* Check that a similar range does not exist yet for this carrier */
         if (!Tools::isSubmit('id_range_weight') && !count($this->_errors) && ($ranges = RangeWeight::getRanges((int) Tools::getValue('id_carrier')))) {
             foreach ($ranges as $range) {
                 if (!($delimiter2 <= $range['delimiter1'] || $delimiter1 >= $range['delimiter2'])) {
                     $this->_errors[] = Tools::displayError('Invalid range, this range is overlapping an existing range');
                     break;
                 }
             }
         }
     }
     parent::postProcess();
 }
示例#26
0
 public function postProcess()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
         return;
     }
     /* PrestaShop demo mode*/
     if ($id_tab = (int) Tools::getValue('id_tab') and $direction = Tools::getValue('move') and Validate::isLoadedObject($tab = new Tab($id_tab))) {
         global $currentIndex;
         if ($tab->move($direction)) {
             Tools::redirectAdmin($currentIndex . '&token=' . $this->token);
         }
     } else {
         if (!Tools::getValue('position')) {
             $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent'));
         }
         parent::postProcess();
     }
 }
 public function postProcess()
 {
     global $currentIndex, $cookie;
     if (isset($_POST['resize'])) {
         $imagesTypes = ImageType::getImagesTypes('products');
         $sourceFile['tmp_name'] = _PS_IMG_DIR_ . '/p/' . Tools::getValue('id_product') . '-' . Tools::getValue('id_image') . '.jpg';
         foreach ($imagesTypes as $k => $imageType) {
             if (!imageCut($sourceFile, _PS_IMG_DIR_ . 'p/' . Tools::getValue('id_product') . '-' . Tools::getValue('id_image') . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'], 'jpg', $_POST[$imageType['id_image_type'] . '_x1'], $_POST[$imageType['id_image_type'] . '_y1'])) {
                 $this->_errors = Tools::displayError('An error occurred while copying image.') . ' ' . stripslashes($imageType['name']);
             }
         }
         // Save and stay on same form
         if (Tools::getValue('saveandstay') == 'on') {
             Tools::redirectAdmin($currentIndex . '&id_product=' . Tools::getValue('id_product') . '&id_category=' . (int) Tools::getValue('id_category') . '&addproduct&conf=4&tabs=1&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee));
         }
         // Default behavior (save and back)
         Tools::redirectAdmin($currentIndex . '&id_category=' . (int) Tools::getValue('id_category') . '&conf=' . (int) Tools::getValue('conf') . '&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee));
     } else {
         parent::postProcess();
     }
 }
示例#28
0
 public function postProcess()
 {
     global $currentIndex;
     if (Tools::getValue('submitPrint')) {
         if (!Validate::isDate($_POST['date_from'])) {
             $this->_errors[] = $this->l('Invalid from date');
         }
         if (!Validate::isDate($_POST['date_to'])) {
             $this->_errors[] = $this->l('Invalid end date');
         }
         if (!sizeof($this->_errors)) {
             $orders = Order::getOrdersIdInvoiceByDate($_POST['date_from'], $_POST['date_to'], NULL, 'invoice');
             if (sizeof($orders)) {
                 Tools::redirectAdmin('pdf.php?invoices&date_from=' . urlencode($_POST['date_from']) . '&date_to=' . urlencode($_POST['date_to']) . '&token=' . $this->token);
             }
             $this->_errors[] = $this->l('No invoice found for this period');
         }
     } else {
         parent::postProcess();
     }
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id = (int) Tools::getValue('id_attachment') and $a = new Attachment($id)) {
             $_POST['file'] = $a->file;
             $_POST['mime'] = $a->mime;
         }
         if (!sizeof($this->_errors)) {
             if (isset($_FILES['file']) and is_uploaded_file($_FILES['file']['tmp_name'])) {
                 if ($_FILES['file']['size'] > Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024) {
                     $this->_errors[] = $this->l('File too large, maximum size allowed:') . ' ' . Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 . ' ' . $this->l('kb') . '. ' . $this->l('File size you\'re trying to upload is:') . number_format($_FILES['attachment_file']['size'] / 1024, 2, '.', '') . $this->l('kb');
                 } else {
                     do {
                         $uniqid = sha1(microtime());
                     } while (file_exists(_PS_DOWNLOAD_DIR_ . $uniqid));
                     if (!copy($_FILES['file']['tmp_name'], _PS_DOWNLOAD_DIR_ . $uniqid)) {
                         $this->_errors[] = $this->l('File copy failed');
                     }
                     $_POST['file_name'] = $_FILES['file']['name'];
                     @unlink($_FILES['file']['tmp_name']);
                     $_POST['file'] = $uniqid;
                     $_POST['mime'] = $_FILES['file']['type'];
                 }
             } else {
                 if (array_key_exists('attachment_file', $_FILES) && (int) $_FILES['attachment_file']['error'] === 1) {
                     $max_upload = (int) ini_get('upload_max_filesize');
                     $max_post = (int) ini_get('post_max_size');
                     $upload_mb = min($max_upload, $max_post);
                     $this->_errors[] = $this->l('the File') . ' <b>' . $_FILES['attachment_file']['name'] . '</b> ' . $this->l('exceeds the size allowed by the server. This limit is set to') . ' <b>' . $upload_mb . $this->l('Mb') . '</b>';
                 } else {
                     if (!empty($_FILES['file']['tmp_name'])) {
                         $this->_errors[] = $this->l('No file or your file isn\'t uploadable, check your server configuration about the upload maximum size.');
                     }
                 }
             }
         }
         $this->validateRules();
     }
     return parent::postProcess();
 }
示例#30
0
 public function postProcess()
 {
     global $currentIndex;
     if (Tools::getValue('submitAdd' . $this->table)) {
         /* Checking fields validity */
         $this->validateRules();
         if (!sizeof($this->_errors)) {
             $id = intval(Tools::getValue('id_' . $this->table));
             if (isset($id) and !empty($id)) {
                 if ($this->tabAccess['edit'] !== '1') {
                     $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
                 } else {
                     $object = new $this->className($id);
                     if (Validate::isLoadedObject($object)) {
                         $customer_email = strval(Tools::getValue('email'));
                         // check if e-mail already used
                         if ($customer_email != $object->email) {
                             $customer = new Customer();
                             $customer->getByEmail($customer_email);
                             if ($customer->id) {
                                 $this->_errors[] = Tools::displayError('an account already exists for this e-mail address:') . ' ' . $customer_email;
                             }
                         }
                         // Updating customer's group
                         if (!sizeof($this->_errors)) {
                             $groupList = Tools::getValue('groupBox');
                             $object->cleanGroups();
                             if (is_array($groupList) and sizeof($groupList) > 0) {
                                 $object->addGroups($groupList);
                             }
                         }
                     } else {
                         $this->_errors[] = Tools::displayError('an error occurred while loading object') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                     }
                 }
             }
         }
     }
     return parent::postProcess();
 }