Ejemplo n.º 1
0
 public static function getInterface()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new PS_CLI_INTERFACE();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 private function _update_value($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = true;
     switch ($key) {
         case 'PS_ONE_PHONE_AT_LEAST':
         case 'PS_REGISTRATION_PROCESS_TYPE':
         case 'PS_CART_FOLLOWING':
         case 'PS_CUSTOMER_CREATION_EMAIL':
         case 'PS_B2B_ENABLE':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_PASSWD_TIME_FRONT':
             $validValue = Validate::isUnsignedInt($value);
             break;
         default:
             $interface->error("The configuration key {$key} is not handled by this plugin !");
             break;
     }
     if (!$validValue) {
         $interface->error("Invalid value '{$value}' for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 3
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_STORE_DISPLAY_FOOTER':
         case 'PS_STORE_DISPLAY_SITEMAP':
         case 'PS_STORE_SIMPLIFIED':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_STORES_CENTER_LAT':
         case 'PS_STORES_CENTER_LONG':
             $validValue = Validate::isCoordinate($value);
             break;
         case 'PS_SHOP_NAME':
             $validValue = Validate::isName($value);
             break;
         case 'PS_SHOP_EMAIL':
             $validValue = Validate::isEmail($value);
             break;
         case 'PS_SHOP_DETAILS':
             $validValue = Validate::isString($value);
             break;
         case 'PS_SHOP_ADDR1':
         case 'PS_SHOP_ADDR2':
             $validValue = Validate::isAddress($value);
             break;
         case 'PS_SHOP_CODE':
             $validValue = Validate::isPostCode($value);
             break;
         case 'PS_SHOP_CITY':
             $validValue = Validate::isCityName($value);
             break;
         case 'PS_SHOP_COUNTRY_ID':
             if (Validate::isUnsignedId($value)) {
                 $obj = new Country((int) $value);
                 $validValue = Validate::isLoadedObject($obj);
             }
             break;
         case 'PS_SHOP_STATE_ID':
             $validValue = Validate::isUnsignedId($value);
             break;
         case 'PS_SHOP_PHONE':
         case 'PS_SHOP_FAX':
             $validValue = Validate::isPhoneNumber($value);
             break;
         default:
             $interface->error("Configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("value '{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated '{$key}' configuration");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 4
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_CATALOG_MODE':
         case 'PS_CART_REDIRECT':
         case 'PS_FORCE_FRIENDLY_PRODUCT':
         case 'PS_DISPLAY_QTIES':
         case 'PS_DISPLAY_JQZOOM':
         case 'PS_DISP_UNAVAILABLE_ATTR':
         case 'PS_ATTRIBUTE_CATEGORY_DISPLAY':
         case 'PS_DISPLAY_DISCOUNT_PRICE':
         case 'PS_ORDER_OUT_OF_STOCK':
         case 'PS_STOCK_MANAGEMENT':
         case 'PS_ADVANCED_STOCK_MANAGEMENT':
         case 'PS_FORCE_ASM_NEW_PRODUCT':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_COMPARATOR_MAX_ITEM':
         case 'PS_NB_DAYS_NEW_PRODUCT':
         case 'PS_PRODUCT_SHORT_DESC_LIMIT':
         case 'PS_PRODUCTS_PER_PAGE':
         case 'PS_LAST_QTIES':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_PRODUCTS_ORDER_BY':
             $validValue = Validate::isUnsignedInt($value) && $value <= 7;
             break;
         case 'PS_ATTRIBUTE_ANCHOR_SEPARATOR':
             //todo
             break;
         case 'PS_DEFAULT_WAREHOUSE_NEW_PRODUCT':
             $validValue = Validate::isUnsignedId($value);
             break;
         default:
             $interface->error("The configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration($key, $value)) {
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 5
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($opt = $arguments->getOpt('list', false)) {
         $this->print_profile_list();
     } elseif ($id = $arguments->getOpt('delete', false)) {
         $status = $this->delete_profile($id);
     } elseif ($id = $arguments->getOpt('list-permissions', false)) {
         $status = $this->list_permissions($id);
     } else {
         $arguments->show_command_usage('profile');
         exit(1);
     }
     exit(0);
 }
Ejemplo n.º 6
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($arguments->getOpt('check-version', false)) {
         $this->core_check_version();
     } elseif ($arguments->getOpt('list-modified-files', false)) {
         $this->core_list_changed_files();
     } elseif ($arguments->getOpt('show-info', false)) {
         $this->print_server_info();
     } elseif ($arguments->getOpt('show-version', false)) {
         $this->core_show_version();
     } else {
         $arguments->show_command_usage('core');
         exit(1);
     }
 }
Ejemplo n.º 7
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     $status = null;
     if ($arguments->getOpt('list', false)) {
         $status = $this->list_customers();
     } elseif ($arguments->getOpt('anonimize', false)) {
         $status = $this->anonimize_customers();
     } else {
         $arguments->show_command_usage('customer');
         exit(1);
     }
     if ($status === false) {
         exit(1);
     }
     exit(0);
 }
Ejemplo n.º 8
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($arguments->getOpt('backup', false)) {
         $skipStats = $arguments->getOpt('skip-stats', false);
         $status = PS_CLI_DB::database_create_backup($skipStats);
     } elseif ($arguments->getOpt('list', false)) {
         $status = PS_CLI_DB::list_database_backups();
     } else {
         $arguments->show_command_usage('db');
         exit(1);
     }
     if ($status === false) {
         exit(1);
     } else {
         exit(0);
     }
 }
Ejemplo n.º 9
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($opt = $arguments->getOpt('list', false)) {
         $this->print_theme_list();
         exit(0);
     } elseif ($opt = $arguments->getOpt('list-available', false)) {
         $this->print_available_themes();
         exit(0);
     } elseif ($theme = $arguments->getOpt('activate', false)) {
         $this->activate_theme($theme);
         exit(0);
     } elseif ($zip = $arguments->getOpt('install-zip', false)) {
         $this->install_theme_zip($zip);
     } else {
         $arguments->show_command_usage('theme');
         exit(1);
     }
 }
Ejemplo n.º 10
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($opt = $arguments->getOpt('categories', false)) {
         $this->csv_export('categories');
     } elseif ($opt = $arguments->getOpt('products', false)) {
         $this->csv_export('products');
     } elseif ($opt = $arguments->getOpt('customers', false)) {
         $this->csv_export('customers');
     } elseif ($opt = $arguments->getOpt('manufacturers', false)) {
         $this->csv_export('manufacturers');
     } elseif ($opt = $arguments->getOpt('suppliers', false)) {
         $this->csv_export('suppliers');
     } elseif ($opt = $arguments->getOpt('orders', false)) {
         $this->csv_export('orders');
     } else {
         $arguments->show_command_usage('export');
         exit(1);
     }
     exit(0);
 }
Ejemplo n.º 11
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($opt = $arguments->getOpt('list-shops', false)) {
         $this->list_shops();
         $status = true;
     } elseif ($opt = $arguments->getOpt('list-groups', false)) {
         $this->list_groups();
         $status = true;
     } elseif ($opt = $arguments->getOpt('enable-multistore', false)) {
         $this->enable_multistore();
     } elseif ($opt = $arguments->getOpt('disable-multistore', false)) {
         $this->disable_multistore();
     } elseif ($opt = $arguments->getOpt('create-group', false)) {
         $active = $arguments->getOpt('active', false);
         $shareCustomers = $arguments->getOpt('share-customers', false);
         $shareStock = $arguments->getOpt('share-stock', false);
         $shareOrders = $arguments->getOpt('share-orders', false);
         if ($name = $arguments->getOpt('name', false)) {
             if ($name == "1") {
                 echo "You must specify a name with --name option\n";
                 exit(1);
             }
         } else {
             echo "You must specify group name with --name option\n";
             exit(1);
         }
         $this->create_group($name, $shareCustomers, $shareStock, $shareOrders, $active = true);
     } else {
         $arguments->show_command_usage('multistore');
         exit(1);
     }
     if ($status) {
         exit(0);
     } else {
         exit(1);
     }
 }
Ejemplo n.º 12
0
 private function _update_configuration_key($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = true;
     switch ($key) {
         case 'PS_PASSWD_TIME_BACK':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG':
             $validValue = Validate::isBool($value);
             break;
         default:
             $interface->error("This configuration key is not handled by this plugin");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Configuration key '{$key}' successfully updated");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 13
0
 protected function _listModifiedFiles()
 {
     $upgrader = new Upgrader();
     if (!is_object($upgrader)) {
         PS_CLI_Interface::error('Could not load upgrader module');
     }
     $modifiedFiles = $upgrader->getChangedFilesList(NULL, true);
     $table = new Cli\Table();
     $table->setHeaders(array('Category', 'File'));
     foreach ($modifiedFiles as $category => $filesArray) {
         foreach ($filesArray as $id => $file) {
             $table->addRow(array($category, $file));
         }
     }
     $table->display();
 }
Ejemplo n.º 14
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_TOKEN_ENABLE':
         case 'PS_ALLOW_HTML_IFRAME':
         case 'PS_USE_HTML_PURIFIER':
         case 'PS_DISPLAY_SUPPLIERS':
         case 'PS_DISPLAY_BEST_SELLERS':
         case 'PS_COOKIE_CHECKIP':
         case 'PS_SSL_ENABLED':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_COOKIE_LIFETIME_FO':
         case 'PS_COOKIE_LIFETIME_FO':
         case 'PS_LIMIT_UPLOAD_FILE_VALUE':
         case 'PS_LIMIT_UPLOAD_IMAGE_VALUE':
         case 'PS_ATTACHMENT_MAXIMUM_SIZE':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_PRICE_ROUND_MODE':
             $validValue = Validate::isUnsignedInt($value) && $value <= 2;
             break;
         case 'PS_SHOP_ACTIVITY':
             $validValue = Validate::isUnsignedInt($value) && $value <= 20;
             break;
         default:
             $interface->error("The configuration key '{$key}' is not handled by this plugin");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Configuration key '{$key}' successfully updated");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 15
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_LANG_DEFAULT':
             if (Validate::isUnsignedId($value)) {
                 $obj = new Language((int) $value);
                 if (Validate::isLoadedObject($obj)) {
                     $validValue = true;
                 } else {
                     $interface->error("No language with ID: {$value} could be loaded");
                 }
             }
             break;
         case 'PS_DETECT_LANG':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_COUNTRY_DEFAULT':
             if (Validate::isUnsignedId($value)) {
                 $obj = new Country((int) $value);
                 if (Validate::isLoadedObject($obj)) {
                     $validValue = true;
                 } else {
                     $interface->error("No country with ID {$value} could be loaded");
                 }
             }
             break;
         case 'PS_TIMEZONE':
             // check if given value is a valid date time zone
             $timeZones = DateTimeZone::listIdentifiers();
             foreach ($timeZones as $code => $tzString) {
                 if ($value == $tzString) {
                     $validValue = true;
                 }
             }
             break;
         case 'PS_CURRENCY_DEFAULT':
             if (Validate::isUnsignedId($value)) {
                 $obj = new Currency((int) $value);
                 if (Validate::isLoadedObject($obj)) {
                     $validValue = true;
                 } else {
                     $interface->error("Could not load a currency with ID '{$value}'");
                 }
             }
             break;
         case 'PS_WEIGHT_UNIT':
         case 'PS_VOLUME_UNIT':
             $validValue = Validate::isWeightUnit($value);
             break;
         case 'PS_DISTANCE_UNIT':
         case 'PS_DIMENSION_UNIT':
             $validValue = Validate::isDistanceUnit($value);
             break;
         case 'PS_LOCALE_LANGUAGE':
         case 'PS_LOCALE_COUNTRY':
             $validValue = Validate::isLanguageIsoCode($value);
             break;
         default:
             $interface->error("The configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 16
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     $status = null;
     if ($arguments->getOpt('list', false)) {
         $status = $this->list_employees();
     } elseif ($opt = $arguments->getOpt('delete', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('employee');
             exit(1);
         }
         $status = $this->delete_employee($opt);
     } elseif ($opt = $arguments->getOpt('disable', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('employee');
             exit(1);
         }
         $status = $this->disable_employee($opt);
     } elseif ($opt = $arguments->getOpt('enable', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('employee');
             exit(1);
         }
         $status = $this->enable_employee($opt);
     } elseif ($email = $arguments->getOpt('create', false)) {
         if (!Validate::isEmail($email)) {
             echo "Error, {$email} is not a valid email address\n";
             exit(1);
         }
         $pwdError = 'You must provide a password for the employee';
         if ($password = $arguments->getOpt('password', false)) {
             if ($password === "1") {
                 $arguments->show_command_usage('employee', $pwdError);
                 exit(1);
             }
         } else {
             $arguments->show_command_usage('employee', $pwdError);
             exit(1);
         }
         $profileError = 'You must provide a profile for the Employee';
         if ($profile = $arguments->getOpt('profile', false)) {
             if (!Validate::isUnsignedInt($profile)) {
                 $arguments->show_command_usage('employee', $profileError);
                 exit(1);
             }
         } else {
             $arguments->show_command_usage('employee', $profileError);
             exit(1);
         }
         $firstnameError = 'You must specify a name with --first-name option';
         if ($firstname = $arguments->getOpt('first-name', false)) {
             if ($firstname == '') {
                 $arguments->show_command_usage('employee', $firstnameError);
                 exit(1);
             }
         } else {
             $arguments->show_command_usage('employee', $firstnameError);
             exit(1);
         }
         $lastnameError = 'You must specify a last name with --last-name option';
         if ($lastname = $arguments->getOpt('last-name', false)) {
             if ($lastname == '') {
                 $arguments->show_command_usage('employee', $lastnameError);
                 exit(1);
             }
         } else {
             $arguments->show_command_usage('employee', $lastnameError);
             exit(1);
         }
         $status = $this->add_employee($email, $password, $profile, $firstname, $lastname);
     } elseif ($email = $arguments->getOpt('edit', false)) {
         if ($email === "1") {
             echo "You must specify an email address!\n";
             $arguments->show_command_usage();
             exit(1);
         }
         if ($password = $arguments->getOpt('password', false)) {
             if ($password === "1") {
                 echo "You must specify a password with --password option\n";
                 exit(1);
             }
         } else {
             $password = NULL;
         }
         if ($profile = $arguments->getOpt('profile', false)) {
             //usual check === 1 cannot work with int values
             if (!Validate::isUnsignedInt($profile)) {
                 echo "{$profile} is not a valid profile id\n";
                 exit(1);
             }
         } else {
             $profile = NULL;
         }
         if ($firstname = $arguments->getOpt('firstname', false)) {
             if ($firstname === "1") {
                 echo "You must specify a name with --firstname option\n";
                 exit(1);
             }
         } else {
             $firstname = NULL;
         }
         if ($lastname = $arguments->getOpt('lastname', false)) {
             if ($firstname === "1") {
                 echo "You must specify a name with --lastname option\n";
                 exit(1);
             }
         } else {
             $lastname = NULL;
         }
         $res = $this->edit_employee($email, $password, $profile, $firstname, $lastname);
         if ($res) {
             echo "Employee {$email} successfully updated\n";
             exit(0);
         } else {
             echo "Error, could not update employee {$email}\n";
             exit(1);
         }
     } else {
         $arguments->show_command_usage('employee');
         exit(1);
     }
     if ($status === false) {
         exit(1);
     }
     exit(0);
 }
Ejemplo n.º 17
0
 private function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     // we need to run a function after updating some configuration value
     $callback = null;
     $validValue = true;
     switch ($key) {
         case 'PS_IMAGE_QUALITY':
             $callback = array(array($this, 'regenerate_thumbnails'), array());
             $validValue = in_array($value, array('jpg', 'png', 'png_all'));
             break;
         case 'PS_JPEG_QUALITY':
             $callback = array(get_class() . '::regenerate_thumbnails', array());
             $validValue = Validate::isPercentage($value);
             break;
         case 'PS_PNG_QUALITY':
             $callback = array(get_class() . '::regenerate_thumbnails', array());
             $validValue = Validate::isUnsignedInt($value) && $value <= 9;
             break;
         case 'PS_IMAGE_GENERATION_METHOD':
             $callback = array(get_class() . '::regenerate_thumbnails', array());
             $validValue = Validate::isUnsignedInt($value) && $value <= 2;
             break;
         case 'PS_PRODUCT_PICTURE_MAX_SIZE':
         case 'PS_PRODUCT_PICTURE_WIDTH':
         case 'PS_PRODUCT_PICTURE_HEIGHT':
             $validValue = Validate::isUnsignedInt($value);
             break;
         default:
             $interface->error("The configuration key '{$key}' is not handled by this plugin");
             break;
     }
     if (!$validValue) {
         $interface->error("Invalid value '{$value}' for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         if (is_array($callback)) {
             call_user_func_array($callback[0], $callback[1]);
         }
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 18
0
 public function find_backoffice_dir()
 {
     if (is_null($this->psPath)) {
         echo "Fatal error, could not find PrestaShop installation dir !\n";
         exit(1);
     }
     $dir = opendir($this->psPath);
     if (!$dir) {
         echo "Fatal error: could not read current directory\n";
         echo "Do you have read access to the filesystem ?\n";
         return false;
     }
     while ($cur = readdir($dir)) {
         if (is_dir($this->psPath . '/' . $cur)) {
             if (file_exists($this->psPath . '/' . $cur . '/get-file-admin.php')) {
                 if ($this->debug) {
                     PS_CLI_Interface::display_line("Found backoffice in {$this->psPath}/{$cur}");
                 }
                 return $this->psPath . '/' . $cur;
             }
         }
     }
     echo "Error, could not find admin directory\n";
     return false;
 }
Ejemplo n.º 19
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_DISABLE_NON_NATIVE':
         case 'PS_DISABLE_OVERRIDES':
         case 'PRESTASTORE_LIVE':
             $validValue = Validate::isBool($value);
             break;
         default:
             $interface->error("Configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated {$key} configuration");
     } else {
         $interface->error("Could not updated {$key} configuration");
     }
 }
Ejemplo n.º 20
0
 protected function update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_SMARTY_CACHE':
         case 'PS_CSS_THEME_CACHE':
         case 'PS_JS_THEME_CACHE':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_SMARTY_CACHING_TYPE':
             switch ($value) {
                 case 'filesytem':
                 case 'mysql':
                     $validValue = true;
                     break;
                 default:
                     $validValue = false;
                     break;
             }
             break;
         case 'PS_SMARTY_CONSOLE':
         case 'PS_SMARTY_FORCE_COMPILE':
             $validValue = Validate::isUnsignedInt($value) && $value <= 2;
             break;
         case 'PS_SMARTY_CONSOLE_KEY':
             $validValue = Validate::isString($value);
             break;
         default:
             $interface->error("Configuration key '{$key}' is not handled by this plugin");
             break;
     }
     if (!$validValue) {
         $configuration->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     // todo: callbacks ?
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 21
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     $updateUri = false;
     switch ($key) {
         case 'PS_CANONICAL_REDIRECT':
             $validValue = Validate::isUnsignedInt($value) && $value <= 2;
             break;
         case 'PS_SHOP_DOMAIN_SSL':
         case 'PS_SHOP_DOMAIN':
             $updateUri = true;
             $validValue = Validate::isCleanHtml($value);
             break;
         case 'PS_HTACCESS_DISABLE_MODSEC':
         case 'PS_HTACCESS_DISABLE_MULTIVIEWS':
         case 'PS_ALLOW_ACCENTED_CHARS_URL':
         case 'PS_REWRITING_SETTINGS':
             $validValue = Validate::isBool($value);
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         if ($updateUri) {
             $this->post_update_uri();
         }
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 22
0
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_SEARCH_INDEXIATION':
         case 'PS_SEARCH_AJAX':
         case 'PS_INSTANCE_SEARCH':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_SEARCH_WEIGHT_PNAME':
         case 'PS_SEARCH_WEIGHT_REF':
         case 'PS_SEARCH_WEIGHT_SHORTDESC':
         case 'PS_SEARCH_WEIGHT_DESC':
         case 'PS_SEARCH_WEIGHT_CNAME':
         case 'PS_SEARCH_WEIGHT_MNAME':
         case 'PS_SEARCH_WEIGHT_TAG':
         case 'PS_SEARCH_WEIGHT_ATTRIBUTE':
         case 'PS_SEARCH_WEIGHT_FEATURE':
         case 'PS_SEARCH_MINWORDLEN':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_SEARCH_BLACKLIST':
             $validValue = Validate::isString($value);
             break;
         default:
             $interface->error("Configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
Ejemplo n.º 23
0
 public function update_configuration_value($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = true;
     switch ($key) {
         case 'PS_MAIL_EMAIL_MESSAGE':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_MAIL_METHOD':
             $validValue = Validate::isUnsignedInt($value) && $value <= 3;
             break;
         case 'PS_MAIL_DOMAIN':
             $validValue = Validate::isUrl($value);
             break;
         case 'PS_MAIL_SERVER':
         case 'PS_MAIL_USER':
             $validValue = Validate::isGenericName($value);
             break;
         case 'PS_MAIL_PASSWD':
             $validValue = Validate::isAnything($value);
             break;
         case 'PS_MAIL_SMTP_ENCRYPTION':
             switch ($value) {
                 case 'off':
                 case 'tls':
                 case 'ssl':
                     $validValue = true;
                     break;
                 default:
                     $validValue = false;
                     break;
             }
             break;
         case 'PS_MAIL_SMTP_PORT':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_MAIL_TYPE':
             switch ($value) {
                 case Mail::TYPE_HTML:
                 case Mail::TYPE_TEXT:
                 case Mail::TYPE_BOTH:
                     break;
                 default:
                     $validValue = false;
                     break;
             }
             break;
         case 'PS_SHOP_EMAIL':
             $validValue = Validate::isEmail($value);
             break;
         case 'PS_LOG_EMAILS':
             $validValue = Validate::isBool($value);
             break;
         default:
             $interface->error("the configuration key {$key} is not managed by this plugin !");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for '{$key}'");
     }
     // all seems ok, update configuration
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated configuration {$key}");
     } else {
         $interface->error("Could not update configuration {$key}!");
     }
 }