Beispiel #1
0
 /**
  * Represents the "set_settings" action.
  *
  * @throws ShopgateLibraryException
  * @see http://wiki.shopgate.com/Shopgate_Plugin_API_set_settings
  */
 protected function setSettings()
 {
     if (empty($this->params['shopgate_settings']) || !is_array($this->params['shopgate_settings'])) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_NO_SHOPGATE_SETTINGS, 'Request: ' . var_export($this->params, true));
     }
     // settings that may never be changed:
     $shopgateSettingsBlacklist = array('shop_number', 'customer_number', 'apikey', 'plugin_name', 'export_folder_path', 'log_folder_path', 'cache_folder_path', 'items_csv_filename', 'categories_csv_filename', 'reviews_csv_filename', 'access_log_filename', 'error_log_filename', 'request_log_filename', 'debug_log_filename', 'redirect_keyword_cache_filename', 'redirect_skip_keyword_cache_filename');
     // filter the new settings
     $shopgateSettingsNew = array();
     $shopgateSettingsOld = $this->config->toArray();
     foreach ($this->params['shopgate_settings'] as $setting) {
         if (!isset($setting['name'])) {
             throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_NO_SHOPGATE_SETTINGS, 'Wrong format: ' . var_export($setting, true));
         }
         if (in_array($setting['name'], $shopgateSettingsBlacklist)) {
             continue;
         }
         if (!in_array($setting['name'], array_keys($shopgateSettingsOld))) {
             continue;
         }
         $shopgateSettingsNew[$setting['name']] = isset($setting['value']) ? $setting['value'] : null;
     }
     $this->config->load($shopgateSettingsNew);
     $this->config->save(array_keys($shopgateSettingsNew), true);
     $diff = array();
     foreach ($shopgateSettingsNew as $setting => $value) {
         $diff[] = array('name' => $setting, 'old' => $shopgateSettingsOld[$setting], 'new' => $value);
     }
     // set data and return response
     if (empty($this->response)) {
         $this->response = new ShopgatePluginApiResponseAppJson($this->trace_id);
     }
     $this->responseData['shopgate_settings'] = $diff;
 }
Beispiel #2
0
 /**
  * Represents the "ping" action.
  *
  * @see http://wiki.shopgate.com/Shopgate_Plugin_API_ping/
  */
 protected function ping()
 {
     // obfuscate data relevant for authentication
     $config = $this->config->toArray();
     $config['customer_number'] = ShopgateLogger::OBFUSCATION_STRING;
     $config['shop_number'] = ShopgateLogger::OBFUSCATION_STRING;
     $config['apikey'] = ShopgateLogger::OBFUSCATION_STRING;
     // prepare response data array
     $this->responseData['pong'] = 'OK';
     $this->responseData['configuration'] = $config;
     $this->responseData['plugin_info'] = $this->plugin->createPluginInfo();
     $this->responseData['permissions'] = $this->getPermissions();
     $this->responseData['php_version'] = phpversion();
     $this->responseData['php_config'] = $this->getPhpSettings();
     $this->responseData['php_curl'] = function_exists('curl_version') ? curl_version() : 'No PHP-CURL installed';
     $this->responseData['php_extensions'] = get_loaded_extensions();
     $this->responseData['shopgate_library_version'] = SHOPGATE_LIBRARY_VERSION;
     $this->responseData['plugin_version'] = defined('SHOPGATE_PLUGIN_VERSION') ? SHOPGATE_PLUGIN_VERSION : 'UNKNOWN';
     // set data and return response
     if (empty($this->response)) {
         $this->response = new ShopgatePluginApiResponseAppJson($this->trace_id);
     }
 }
Beispiel #3
0
 /**
  * Checks the config for every 'enabled_<action-name>' setting and returns all active as an indexed list
  * @return array
  */
 public function getEnabledPluginActions()
 {
     $enabledActionsList = array();
     $configValues = $this->config->toArray();
     // find all settings that start with "enable_" in the config-value-name and collect all active ones
     $searchKeyPart = 'enable_';
     foreach ($configValues as $key => $val) {
         if (substr($key, 0, strlen($searchKeyPart)) == $searchKeyPart) {
             if ($val) {
                 $enabledActionsList[$key] = $val;
             }
         }
     }
     return $enabledActionsList;
 }