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}'"); } }
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}'"); } }
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}'"); } }
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"); } }
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}'"); } }
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}'"); } }
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}'"); } }
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}!"); } }
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}'"); } }
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}'"); } }
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}'"); } }