public function processSave() { parent::processSave(); if (Tools::isSubmit('submitAddaddress')) { $this->display = 'editaddresses'; } }
public function processSave() { if (!$this->validateDiscount(Tools::getValue('reduction'))) { $this->errors[] = Tools::displayError('The discount value is incorrect (must be a percentage).'); } else { $this->updateCategoryReduction(); $object = parent::processSave(); $this->updateRestrictions(); return $object; } }
public function processSave() { $employee = new Employee((int) Tools::getValue('id_employee')); // If the employee is editing its own account if ($this->restrict_edition) { $current_password = trim(Tools::getValue('old_passwd')); if (Tools::getValue('passwd') && (empty($current_password) || !Validate::isPasswdAdmin($current_password) || !$employee->getByEmail($employee->email, $current_password))) { $this->errors[] = Tools::displayError('Your current password is invalid.'); } elseif (Tools::getValue('passwd') && (!Tools::getValue('passwd2') || Tools::getValue('passwd') !== Tools::getValue('passwd2'))) { $this->errors[] = Tools::displayError('The confirmation password does not match.'); } $_POST['id_profile'] = $_GET['id_profile'] = $employee->id_profile; $_POST['active'] = $_GET['active'] = $employee->active; // Unset set shops foreach ($_POST as $postkey => $postvalue) { if (strstr($postkey, 'checkBoxShopAsso_' . $this->table) !== false) { unset($_POST[$postkey]); } } foreach ($_GET as $postkey => $postvalue) { if (strstr($postkey, 'checkBoxShopAsso_' . $this->table) !== false) { unset($_GET[$postkey]); } } // Add current shops associated to the employee $result = Shop::getShopById((int) $employee->id, $this->identifier, $this->table); foreach ($result as $row) { $key = 'checkBoxShopAsso_' . $this->table; if (!isset($_POST[$key])) { $_POST[$key] = array(); } if (!isset($_GET[$key])) { $_GET[$key] = array(); } $_POST[$key][$row['id_shop']] = 1; $_GET[$key][$row['id_shop']] = 1; } } else { $_POST['id_last_order'] = $employee->getLastElementsForNotify('order'); $_POST['id_last_customer_message'] = $employee->getLastElementsForNotify('customer_message'); $_POST['id_last_customer'] = $employee->getLastElementsForNotify('customer'); } //if profile is super admin, manually fill checkBoxShopAsso_employee because in the form they are disabled. if ($_POST['id_profile'] == _PS_ADMIN_PROFILE_) { $result = Db::getInstance()->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop'); foreach ($result as $row) { $key = 'checkBoxShopAsso_' . $this->table; if (!isset($_POST[$key])) { $_POST[$key] = array(); } if (!isset($_GET[$key])) { $_GET[$key] = array(); } $_POST[$key][$row['id_shop']] = 1; $_GET[$key][$row['id_shop']] = 1; } } if ($employee->isLastAdmin()) { if (Tools::getValue('id_profile') != (int) _PS_ADMIN_PROFILE_) { $this->errors[] = Tools::displayError('You should have at least one employee in the administrator group.'); return false; } if (Tools::getvalue('active') == 0) { $this->errors[] = Tools::displayError('You cannot disable or delete the administrator account.'); return false; } } if (Tools::getValue('bo_theme_css')) { $bo_theme = explode('|', Tools::getValue('bo_theme_css')); $_POST['bo_theme'] = $bo_theme[0]; if (!in_array($bo_theme[0], scandir(_PS_ADMIN_DIR_ . DIRECTORY_SEPARATOR . 'themes'))) { $this->errors[] = Tools::displayError('Invalid theme'); return false; } if (isset($bo_theme[1])) { $_POST['bo_css'] = $bo_theme[1]; } } $assos = $this->getSelectedAssoShop($this->table); if (!$assos && ($this->table = 'employee')) { if (Shop::isFeatureActive() && _PS_ADMIN_PROFILE_ != $_POST['id_profile']) { $this->errors[] = Tools::displayError('The employee must be associated with at least one shop.'); } } if (count($this->errors)) { return false; } return parent::processSave(); }
public function processSave() { $_POST['price'] = Tools::getValue('leave_bprice_on') ? '-1' : Tools::getValue('price'); if (Validate::isLoadedObject($object = parent::processSave())) { $object->deleteConditions(); foreach ($_POST as $key => $values) { if (preg_match('/^condition_group_([0-9]+)$/Ui', $key, $condition_group)) { $conditions = array(); foreach ($values as $value) { $condition = explode('_', $value); $conditions[] = array('type' => $condition[0], 'value' => $condition[1]); } $object->addConditions($conditions); } } $object->apply(); return $object; } }
public function processSave() { /** @var ShopUrl $object */ $object = $this->loadObject(true); if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri'))) { $this->errors[] = $this->trans('A shop URL that uses this domain already exists.', array(), 'Admin.Notifications.Error'); } $unallowed = str_replace('/', '', Tools::getValue('virtual_uri')); if ($unallowed == 'c' || $unallowed == 'img' || is_numeric($unallowed)) { $this->errors[] = $this->trans('A shop virtual URL cannot be "%URL%"', array('%URL%' => $unallowed), 'Admin.Notifications.Error'); } $return = parent::processSave(); if (!$this->errors) { Tools::generateHtaccess(); Tools::clearSmartyCache(); Media::clearCache(); } return $return; }
public function processSave() { // Check that default group is selected if (!is_array(Tools::getValue('groupBox')) || !in_array(Tools::getValue('id_default_group'), Tools::getValue('groupBox'))) { $this->errors[] = Tools::displayError('A default customer group must be selected in group box.'); } // Check the requires fields which are settings in the BO $customer = new Customer(); $this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase()); return parent::processSave(); }
/** * Call the right method for creating or updating object * * @return mixed */ public function processSave() { if ($this->table == 'feature') { $id_feature = (int) Tools::getValue('id_feature'); // Adding last position to the feature if not exist if ($id_feature <= 0) { $sql = 'SELECT `position`+1 FROM `' . _DB_PREFIX_ . 'feature` ORDER BY position DESC'; // set the position of the new feature in $_POST for postProcess() method $_POST['position'] = DB::getInstance()->getValue($sql); } // clean \n\r characters foreach ($_POST as $key => $value) { if (preg_match('/^name_/Ui', $key)) { $_POST[$key] = str_replace('\\n', '', str_replace('\\r', '', $value)); } } } return parent::processSave(); }
/** * Call the right method for creating or updating object * * @return mixed */ public function processSave() { if ($this->table == 'feature') { $id_feature = (int) Tools::getValue('id_feature'); // Adding last position to the feature if not exist if ($id_feature <= 0) { $sql = 'SELECT `position`+1 FROM `' . _DB_PREFIX_ . 'feature` ORDER BY position DESC'; // set the position of the new feature in $_POST for postProcess() method $_POST['position'] = DB::getInstance()->getValue($sql); } // clean \n\r characters foreach ($_POST as $key => $value) { if (preg_match('/^name_/Ui', $key)) { $_POST[$key] = str_replace('\\n', '', str_replace('\\r', '', $value)); } } //by webkul to save image of feature with feature name $obj_feature = parent::processSave(); $feature_values = FeatureValue::getFeatureValuesWithLang(1, $obj_feature->id); if ($feature_values) { $obj_feature_value = new FeatureValue($feature_values[0]['id_feature_value']); } else { $obj_feature_value = new FeatureValue(); } //validate feature image if (isset($_FILES['logo'])) { $this->validAddFeatureImage($_FILES['logo']); } $img_path = _PS_IMG_DIR_ . 'rf/' . $obj_feature->id . '.png'; if (isset($_FILES['logo'])) { $current_file = _PS_TMP_IMG_DIR_ . 'feature_mini_' . $obj_feature->id . '_' . $this->context->shop->id . '.png'; if (file_exists($current_file)) { unlink($current_file); } $this->uploadFeatureImage($_FILES['logo'], $img_path); } $obj_feature_value->id_feature = $obj_feature->id; foreach (Language::getLanguages(true) as $lang) { $obj_feature_value->value[$lang['id_lang']] = $obj_feature->id . '.png'; } $obj_feature_value->save(); } return $obj_feature; }
public function processSave() { if (!$this->id_object) { $tmp_addr_format = new AddressFormat(); } else { $tmp_addr_format = new AddressFormat($this->id_object); } $tmp_addr_format->format = Tools::getValue('address_layout'); if (!$tmp_addr_format->checkFormatFields()) { $error_list = $tmp_addr_format->getErrorList(); foreach ($error_list as $num_error => $error) { $this->errors[] = $error; } } if (strlen($tmp_addr_format->format) <= 0) { $this->errors[] = $this->l('Address format invalid'); } $country = parent::processSave(); if (!count($this->errors)) { if (is_null($tmp_addr_format->id_country)) { $tmp_addr_format->id_country = $country->id; } if (!$tmp_addr_format->save()) { $this->errors[] = Tools::displayError('Invalid address layout ' . Db::getInstance()->getMsgError()); } } return $country; }
public function processSave() { $object = $this->loadObject(true); if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri'))) { $this->errors[] = Tools::displayError('A shop URL that uses this domain already exists.'); } $return = parent::processSave(); if (!$this->errors) { Tools::generateHtaccess(); } return $return; }
public function processSave() { $confirmpayment = new TableConfirmPayment(); $this->errors = array_merge($this->errors, $confirmpayment->validateFieldsRequiredDatabase()); return parent::processSave(); }
public function processSave() { if (!$this->validateDiscount(Tools::getValue('reduction'))) { $this->errors[] = $this->trans('The discount value is incorrect (must be a percentage).', array(), 'Admin.Parameters.Notification'); } else { $this->updateCategoryReduction(); $object = parent::processSave(); $this->updateRestrictions(); return $object; } }
public function processSave() { $object = $this->loadObject(true); if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri'))) { $this->errors[] = Tools::displayError('A shop URL that uses this domain already exists.'); } if (str_replace('/', '', Tools::getValue('virtual_uri')) == 'c') { $this->errors[] = Tools::displayError('A shop virtual URL can not be "/c/", because "/c/" is the virtual url prefix for category images.'); } $return = parent::processSave(); if (!$this->errors) { Tools::generateHtaccess(); Tools::clearSmartyCache(); Media::clearCache(); } return $return; }
public function processSave() { if (!count($this->errors)) { $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()) { $address_format_result = $tmp_addr_format->save(); } else { $error_list = $tmp_addr_format->getErrorList(); foreach ($error_list as $num_error => $error) { $this->errors[] = $error; } } if (!isset($address_format_result) || !$address_format_result) { $this->errors[] = Tools::displayError('Invalid address layout ' . Db::getInstance()->getMsgError()); } } unset($tmp_addr_format); } return parent::processSave(); }
public function processSave() { $id = Tools::getValue('block_identifier'); if (Validate::isModuleName($id)) { return parent::processSave(); } $this->errors[] = Tools::displayError('The field "block_identifier" is invalid. Allowed characters:') . ' a-z, A-Z, 0-9, _'; $this->display = 'edit'; return FALSE; }
public function processSave() { if (Tools::getValue('submitFormAjax')) { $this->redirect_after = false; } // Transform e-mail in id_customer for parent processing if (Validate::isEmail(Tools::getValue('email'))) { $customer = new Customer(); $customer->getByEmail(Tools::getValue('email'), null, false); if (Validate::isLoadedObject($customer)) { $_POST['id_customer'] = $customer->id; } else { $this->errors[] = Tools::displayError('This email address is not registered.'); } } else { if ($id_customer = Tools::getValue('id_customer')) { $customer = new Customer((int) $id_customer); if (Validate::isLoadedObject($customer)) { $_POST['id_customer'] = $customer->id; } else { $this->errors[] = Tools::displayError('Unknown customer'); } } else { $this->errors[] = Tools::displayError('Unknown customer'); } } if (Country::isNeedDniByCountryId(Tools::getValue('id_country')) && !Tools::getValue('dni')) { $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.'); } /* If the selected country does not contain states */ $id_state = (int) Tools::getValue('id_state'); $id_country = (int) Tools::getValue('id_country'); $country = new Country((int) $id_country); if ($country && !(int) $country->contains_states && $id_state) { $this->errors[] = Tools::displayError('You have selected a state for a country that does not contain states.'); } /* If the selected country contains states, then a state have to be selected */ if ((int) $country->contains_states && !$id_state) { $this->errors[] = Tools::displayError('An address located in a country containing states must have a state selected.'); } $postcode = Tools::getValue('postcode'); /* Check zip code format */ if ($country->zip_code_format && !$country->checkZipCode($postcode)) { $this->errors[] = Tools::displayError('Your Zip/postal code is incorrect.') . '<br />' . Tools::displayError('It must be entered as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))); } elseif (empty($postcode) && $country->need_zip_code) { $this->errors[] = Tools::displayError('A Zip/postal code is required.'); } elseif ($postcode && !Validate::isPostCode($postcode)) { $this->errors[] = Tools::displayError('The Zip/postal code is invalid.'); } if (Configuration::get('PS_ONE_PHONE_AT_LEAST') && !Tools::getValue('phone') && !Tools::getValue('phone_mobile')) { $this->errors[] = Tools::displayError('You must register at least one phone number.'); } /* If this address come from order's edition and is the same as the other one (invoice or delivery one) ** we delete its id_address to force the creation of a new one */ if ((int) Tools::getValue('id_order')) { $this->_redirect = false; if (isset($_POST['address_type'])) { $_POST['id_address'] = ''; } } // Check the requires fields which are settings in the BO $address = new Address(); $this->errors = array_merge($this->errors, $address->validateFieldsRequiredDatabase()); if (empty($this->errors)) { return parent::processSave(); } else { // if we have errors, we stay on the form instead of going back to the list $this->display = 'edit'; } /* Reassignation of the order's new (invoice or delivery) address */ $address_type = (int) Tools::getValue('address_type') == 2 ? 'invoice' : ((int) Tools::getValue('address_type') == 1 ? 'delivery' : ''); if ($this->action == 'save' && ($id_order = (int) Tools::getValue('id_order')) && !count($this->errors) && !empty($address_type)) { if (!Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'orders SET `id_address_' . $address_type . '` = ' . Db::getInstance()->Insert_ID() . ' WHERE `id_order` = ' . $id_order)) { $this->errors[] = Tools::displayError('An error occurred while linking this address to its order.'); } else { Tools::redirectAdmin(Tools::getValue('back') . '&conf=4'); } } }
/** * Overrided to check if the image's folder exist */ public function processSave() { return parent::processSave(); }