Example #1
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}'");
     }
 }
Example #2
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}'");
     }
 }
Example #3
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}'");
     }
 }
Example #4
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");
     }
 }
Example #5
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}'");
     }
 }
Example #6
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}'");
     }
 }
Example #7
0
 public static function ps_cli_initialize()
 {
     ps_cli_init_admin_context();
     self::$LANG = Configuration::get('PS_LANG_DEFAULT');
     self::ps_cli_init_admin_context();
 }
Example #8
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}'");
     }
 }
Example #9
0
 public function show_status()
 {
     $table = new Cli\Table();
     $table->setHeaders(array('Key', 'Configuration', 'Value'));
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_SMARTY_CACHE', 'Smarty Template Cache');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SMARTY_CACHING_TYPE', 'Smarty Caching type', '1.6.0.11');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SMARTY_CONSOLE', 'Display smarty console (0 for never, 1 for URL, 2 for always)', '1.6.0.11');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SMARTY_CONSOLE_KEY', 'Smarty console key', '1.6.0.11');
     $currentConfig = Configuration::getGlobalValue('PS_SMARTY_FORCE_COMPILE');
     $line = array('PS_SMARTY_FORCE_COMPILE', 'Smarty Template Compilation (' . _PS_SMARTY_NO_COMPILE_ . ' for never, ' . _PS_SMARTY_CHECK_COMPILE_ . ' for updated, ' . _PS_SMARTY_FORCE_COMPILE_ . ' for always)');
     switch ($currentConfig) {
         case _PS_SMARTY_NO_COMPILE_:
             array_push($line, $currentConfig . ' (never)');
             break;
         case _PS_SMARTY_CHECK_COMPILE_:
             array_push($line, $currentConfig . ' (if updated)');
             break;
         case _PS_SMARTY_FORCE_COMPILE_:
             array_push($line, $currentConfig . ' (Always)');
             break;
     }
     $table->addRow($line);
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_CSS_THEME_CACHE', 'Css cache');
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_JS_THEME_CACHE', 'JS cache');
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_HTACCESS_CACHE_CONTROL', 'Htaccess cache control');
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_MEDIA_SERVERS', 'Use Media Servers');
     $line = array('PS_CIPHER_ALGORITHM', 'Cipher (0=blowfish, 1=rijndael)');
     if (Configuration::getGlobalValue('PS_CIPHER_ALGORITHM')) {
         array_push($line, 'RIJNDAEL/Mcrypt');
     } else {
         array_push($line, 'Local Blowfish');
     }
     $table->addRow($line);
     $line = array('Const: _PS_CACHE_ENABLED_', 'Cache');
     if (_PS_CACHE_ENABLED_) {
         array_push($line, 'enabled');
     } else {
         array_push($line, 'disabled');
     }
     $table->addRow($line);
     $table->addRow(array('Const: _PS_CACHING_SYSTEM_', 'Active Caching system', _PS_CACHING_SYSTEM_));
     $table->display();
     return;
 }
Example #10
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}!");
     }
 }
Example #11
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}'");
     }
 }
Example #12
0
 public function show_status()
 {
     $table = new Cli\Table();
     $table->setHeaders(array('Key', 'Configuration', 'Value'));
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_STORE_DISPLAY_FOOTER', 'Display link to store locator in the footer');
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_STORE_DISPLAY_SITEMAP', 'Display link to store locator in the sitemap');
     PS_CLI_Utils::add_boolean_configuration_status($table, 'PS_STORE_SIMPLIFIED', 'Show a simplified store locator');
     PS_CLI_Utils::add_configuration_value($table, 'PS_STORES_CENTER_LAT', 'Default latitude');
     PS_CLI_Utils::add_configuration_value($table, 'PS_STORES_CENTER_LONG', 'Default longitude');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_NAME', 'Shop name');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_EMAIL', 'Shop email');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_DETAILS', 'Shop details');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_ADDR1', 'Shop address line 1');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_ADDR2', 'Shop address line 2');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_CODE', 'Zip/postal code');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_CITY', 'City');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_COUNTRY_ID', 'Country ID');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_STATE_ID', 'State ID');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_PHONE', 'Phone number');
     PS_CLI_Utils::add_configuration_value($table, 'PS_SHOP_FAX', 'Fax number');
     $table->display();
     return;
 }
Example #13
0
 protected function _update_configuration($key, $value)
 {
     $validValue = false;
     switch ($key) {
         case 'PS_AUTOUP_KEEP_MAILS':
         case 'PS_AUTOUP_UPDATE_DEFAULT_THEME':
         case 'PS_AUTOUP_CUSTOM_MOD_DESACT':
         case 'PS_AUTOUP_KEEP_IMAGES':
         case 'PS_AUTOUP_BACKUP':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_AUTOUP_PERFORMANCE':
             $validValue = Validate::isUnsignedInt($value) && $value <= 3;
             break;
             /** Check other values too */
         /** Check other values too */
         case 'PS_UPGRADE_CHANNEL':
             $validChannels = array('beta', 'rc', 'stable');
             $validValue = in_array($value, $validChannels);
             break;
         default:
             PS_CLI_Interface::error("The configuration key '{$key}' is not handled by this plugin");
             break;
     }
     if (!$validValue) {
         PS_CLI_Interface::error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration($key, $value)) {
         PS_CLI_Interface::success("Successfully updated configuration key '{$key}'");
     } else {
         PS_CLI_Interface::error("Could not update configuration key '{$key}'");
     }
 }
Example #14
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}'");
     }
 }