public function processAdd()
 {
     if (($new_dir = Tools::getValue('directory')) != '') {
         if (!Validate::isDirName($new_dir)) {
             $this->display = 'add';
             return !($this->errors[] = sprintf(Tools::displayError('"%s" is not a valid directory name'), $new_dir));
         }
         if (Theme::getByDirectory($new_dir)) {
             $this->display = 'add';
             return !($this->errors[] = Tools::displayError('A directory with this name already exist'));
         }
         if (mkdir(_PS_ALL_THEMES_DIR_ . $new_dir, Theme::$access_rights)) {
             $this->confirmations[] = $this->l('The directory was successfully created.');
         }
         if (0 !== ($id_based = (int) Tools::getValue('based_on'))) {
             $base_theme = new Theme($id_based);
             $this->copyTheme($base_theme->directory, $new_dir);
             $base_theme = new Theme((int) Tools::getValue('based_on'));
         }
         if (isset($_FILES['image_preview']) && $_FILES['image_preview']['error'] == 0) {
             if (@getimagesize($_FILES['image_preview']['tmp_name']) && !ImageManager::validateUpload($_FILES['image_preview'], Tools::getMaxUploadSize())) {
                 move_uploaded_file($_FILES['image_preview']['tmp_name'], _PS_ALL_THEMES_DIR_ . $new_dir . '/preview.jpg');
             } else {
                 $this->errors[] = $this->l('Image not valid');
                 $this->display = 'form';
                 return false;
             }
         }
     }
     $theme = parent::processAdd();
     if ((int) $theme->product_per_page == 0) {
         $theme->product_per_page = 1;
         $theme->save();
     }
     if (is_object($theme) && (int) $theme->id > 0) {
         $metas = Meta::getMetas();
         foreach ($metas as &$meta) {
             $meta['left'] = $theme->default_left_column;
             $meta['right'] = $theme->default_right_column;
         }
         $theme->updateMetas($metas, true);
     }
     return $theme;
 }
 /**
  * @see AdminController::processAdd();
  */
 public function processAdd()
 {
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if (!($obj = $this->loadObject(true))) {
             return;
         }
         $this->updateAddress();
         // hack for enable the possibility to update a warehouse without recreate new id
         $this->deleted = false;
         return parent::processAdd();
     }
 }
 public function processAdd()
 {
     $new_dir = Tools::getValue('directory');
     $res = true;
     if ($new_dir != '') {
         if (Validate::isDirName($new_dir) && !is_dir(_PS_ALL_THEMES_DIR_ . $new_dir)) {
             $res &= mkdir(_PS_ALL_THEMES_DIR_ . $new_dir, Theme::$access_rights);
             if ($res) {
                 $this->confirmations[] = $this->l('Directory successfully created');
             }
         }
         if (0 !== ($id_based = (int) Tools::getValue('based_on'))) {
             $base_theme = new Theme($id_based);
             $res = $this->copyTheme($base_theme->directory, $new_dir);
             $base_theme = new Theme((int) Tools::getValue('based_on'));
         }
     }
     return parent::processAdd();
 }
 public function processAdd()
 {
     if (Tools::getValue('submitFormAjax')) {
         $this->redirect_after = false;
     }
     // Check that the new email is not already in use
     $customer_email = strval(Tools::getValue('email'));
     $customer = new Customer();
     if (Validate::isEmail($customer_email)) {
         $customer->getByEmail($customer_email);
     }
     if ($customer->id) {
         $this->errors[] = Tools::displayError('An account already exists for this email address:') . ' ' . $customer_email;
         $this->display = 'edit';
         return $customer;
     } elseif (trim(Tools::getValue('passwd')) == '') {
         $this->validateRules();
         $this->errors[] = Tools::displayError('Password can not be empty.');
         $this->display = 'edit';
     } elseif ($customer = parent::processAdd()) {
         $this->context->smarty->assign('new_customer', $customer);
         return $customer;
     }
     return false;
 }
 /**
  * Override processAdd to change SaveAndStay button action
  * @see classes/AdminControllerCore::processUpdate()
  */
 public function processAdd()
 {
     $object = parent::processAdd();
     if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay') && !count($this->errors)) {
         if ($this->display == 'add') {
             $this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=&conf=3&update' . $this->table . '&token=' . $this->token;
         } else {
             $this->redirect_after = self::$currentIndex . '&id_attribute_group=' . (int) Tools::getValue('id_attribute_group') . '&conf=3&update' . $this->table . '&token=' . $this->token;
         }
     }
     if (count($this->errors)) {
         $this->setTypeAttribute();
     }
     return $object;
 }
 public function processAdd()
 {
     if (Tools::getValue('submitFormAjax')) {
         $this->redirect_after = false;
     }
     return parent::processAdd();
 }
 public function processAdd()
 {
     // Enable the creation of quick links from the URL
     $_POST = array_merge($_POST, $_GET);
     return parent::processAdd();
 }
 /**
  * Override processAdd to change SaveAndStay button action
  * @see classes/AdminControllerCore::processAdd()
  */
 public function processAdd()
 {
     $object = parent::processAdd();
     if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay') && !count($this->errors)) {
         if ($this->table == 'feature_value' && ($this->display == 'edit' || $this->display == 'add')) {
             $this->redirect_after = self::$currentIndex . '&addfeature_value&id_feature=' . (int) Tools::getValue('id_feature') . '&token=' . $this->token;
         } else {
             $this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=&conf=3&update' . $this->table . '&token=' . $this->token;
         }
     } elseif (Tools::isSubmit('submitAdd' . $this->table . 'AndStay') && count($this->errors)) {
         $this->display = 'editFeatureValue';
     }
     return $object;
 }
 /**
  * Override processAdd to change SaveAndStay button action
  * @see classes/AdminControllerCore::processUpdate()
  */
 public function processAdd()
 {
     if ($this->table == 'attribute') {
         /** @var AttributeGroup $object */
         $object = new $this->className();
         foreach (Language::getLanguages(false) as $language) {
             if ($object->isAttribute((int) Tools::getValue('id_attribute_group'), Tools::getValue('name_' . $language['id_lang']), $language['id_lang'])) {
                 $this->errors['name_' . $language['id_lang']] = sprintf(Tools::displayError('The attribute value "%1$s" already exist for %2$s language'), Tools::getValue('name_' . $language['id_lang']), $language['name']);
             }
         }
         if (!empty($this->errors)) {
             return $object;
         }
     }
     $object = parent::processAdd();
     if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay') && !count($this->errors)) {
         if ($this->display == 'add') {
             $this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=&conf=3&update' . $this->table . '&token=' . $this->token;
         } else {
             $this->redirect_after = self::$currentIndex . '&id_attribute_group=' . (int) Tools::getValue('id_attribute_group') . '&conf=3&update' . $this->table . '&token=' . $this->token;
         }
     }
     if (count($this->errors)) {
         $this->setTypeAttribute();
     }
     return $object;
 }
 public function processAdd()
 {
     if (Tools::getValue('submitFormAjax')) {
         $this->redirect_after = false;
     }
     $confirmpayment = new TableConfirmPayment();
     if ($confirmpayment->id) {
         $this->errors[] = Tools::displayError('An account already exists for this email address:') . ' ' . $customer_email;
         $this->display = 'edit';
         return $confirmpayment;
     } elseif ($confirmpayment = parent::processAdd()) {
         $this->context->smarty->assign('new_confirmpayment', $confirmpayment);
         return $confirmpayment;
     }
     return false;
 }
 public function processAdd()
 {
     $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 ($object->id && Tools::getValue('main')) {
         $object->setMain();
     }
     if ($object->main && !Tools::getValue('main')) {
         $this->errors[] = Tools::displayError('You cannot change a main URL to a non-main URL. You have to set another URL as your Main URL for the selected shop.');
     }
     if (($object->main || Tools::getValue('main')) && !Tools::getValue('active')) {
         $this->errors[] = Tools::displayError('You cannot disable the Main URL.');
     }
     return parent::processAdd();
 }
 /**
  * Override processAdd to change SaveAndStay button action
  * @see classes/AdminControllerCore::processAdd()
  */
 public function processAdd()
 {
     $object = parent::processAdd();
     if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay') && !count($this->errors)) {
         $this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=&conf=3&update' . $this->table . '&token=' . $this->token;
     } elseif (Tools::isSubmit('submitAdd' . $this->table . 'AndStay') && count($this->errors)) {
         $this->display = 'editFeatureValue';
     }
     return $object;
 }
 public function processAdd()
 {
     $object = $this->loadObject(true);
     if ($object->id && Tools::getValue('main')) {
         $object->setMain();
     }
     if ($object->main && !Tools::getValue('main')) {
         $this->errors[] = Tools::displayError('You can\'t change a Main URL to a non-Main URL, you have to set another URL as Main URL for selected shop');
     }
     if (($object->main || Tools::getValue('main')) && !Tools::getValue('active')) {
         $this->errors[] = Tools::displayError('You can\'t disable a Main URL');
     }
     return parent::processAdd();
 }
 public function processAdd()
 {
     $id_category = (int) Tools::getValue('id_category');
     $id_parent = (int) Tools::getValue('id_parent');
     // if true, we are in a root category creation
     if (!$id_parent) {
         $_POST['is_root_category'] = $_POST['level_depth'] = 1;
         $_POST['id_parent'] = $id_parent = (int) Configuration::get('PS_ROOT_CATEGORY');
     }
     if ($id_category) {
         if ($id_category != $id_parent) {
             if (!Category::checkBeforeMove($id_category, $id_parent)) {
                 $this->errors[] = $this->trans('The category cannot be moved here.', array(), 'Admin.Catalog.Notification');
             }
         } else {
             $this->errors[] = $this->trans('The category cannot be a parent of itself.', array(), 'Admin.Catalog.Notification');
         }
     }
     $object = parent::processAdd();
     //if we create a you root category you have to associate to a shop before to add sub categories in. So we redirect to AdminCategories listing
     if ($object && Tools::getValue('is_root_category')) {
         Tools::redirectAdmin(self::$currentIndex . '&id_category=' . (int) Configuration::get('PS_ROOT_CATEGORY') . '&token=' . Tools::getAdminTokenLite('AdminCategories') . '&conf=3');
     }
     return $object;
 }
 public function processAdd()
 {
     $id_category = (int) Tools::getValue('id_category');
     $id_parent = (int) Tools::getValue('id_parent');
     // if true, we are in a root category creation
     if (!$id_parent && !Tools::isSubmit('is_root_category')) {
         $_POST['is_root_category'] = $_POST['level_depth'] = $_POST['id_parent'] = $id_parent = 1;
     }
     if ($id_category) {
         if ($id_category != $id_parent) {
             if (!Category::checkBeforeMove($id_category, $id_parent)) {
                 $this->errors[] = Tools::displayError($this->l('Category cannot be moved here'));
             }
         } else {
             $this->errors[] = Tools::displayError($this->l('Category cannot be parent of itself.'));
         }
     }
     $object = parent::processAdd();
     //if we create a you root category you have to associate to a shop before to add sub categories in. So we redirect to AdminCategories listing
     if ($object && Tools::getValue('is_root_category')) {
         Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminCategories') . '&conf=3');
     }
     return $object;
 }
 public function processAdd()
 {
     $id = Tools::getValue('block_identifier');
     $block = BelvgStaticBlocks::getBlockByIdentifier($id);
     if ($block === FALSE) {
         return parent::processAdd();
     }
     $this->errors[] = Tools::displayError('Duplicate field "block_identifier".');
     $this->display = 'edit';
     return FALSE;
 }
 public function processAdd()
 {
     if ($cart_rule = parent::processAdd()) {
         $this->context->smarty->assign('new_cart_rule', $cart_rule);
     }
     if (Tools::getValue('submitFormAjax')) {
         $this->redirect_after = false;
     }
     return $cart_rule;
 }
 public function processAdd()
 {
     /** @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');
     }
     if (Tools::getValue('main') && !Tools::getValue('active')) {
         $this->errors[] = $this->trans('You cannot disable the Main URL.', array(), 'Admin.Notifications.Error');
     }
     return parent::processAdd();
 }
 public function processAdd()
 {
     if (_PS_MODE_DEMO_) {
         $this->errors[] = Tools::displayError('This functionality has been disabled.');
         return;
     }
     if (isset($_POST['iso_code']) && !empty($_POST['iso_code']) && Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Language::getIdByIso($_POST['iso_code'])) {
         $this->errors[] = Tools::displayError('This ISO code is already linked to another language.');
     }
     if ((!empty($_FILES['no_picture']['tmp_name']) || !empty($_FILES['flag']['tmp_name'])) && Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
         if ($_FILES['no_picture']['error'] == UPLOAD_ERR_OK) {
             $this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
         }
         unset($_FILES['no_picture']);
     } else {
         $this->errors[] = Tools::displayError('Flag and "No picture" image fields are required.');
     }
     return parent::processAdd();
 }
 public function processAdd()
 {
     $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 (Tools::getValue('main') && !Tools::getValue('active')) {
         $this->errors[] = Tools::displayError('You cannot disable the Main URL.');
     }
     return parent::processAdd();
 }