function __construct($module_instance = null, $api_key = null, $api_secret = null) { $this->api_key = !$api_key ? TextMasterConfiguration::get('api_key') : $api_key; $this->api_secret = !$api_secret ? TextMasterConfiguration::get('api_secret') : $api_secret; date_default_timezone_set('UTC'); // timezone must be UTC, otherwise API refuses connection $this->connection &= $this->testConnection(); $this->module_instance = (!$module_instance or !is_object($module_instance)) ? Module::getInstanceByName('textmaster') : $module_instance; // initiates module instance $this->getAuthors(); }
/** * Updates configuration values */ private function saveSettings() { $configuration = new TextMasterConfiguration(); /* geting rid of unecessary values in POST */ unset($_POST['tab']); unset($_POST['savesettings']); /* checkboxe values has to be nulled, because in case they are unchecked, they won't be added into POST array at all. * If POST array features only 2 elements, that means only api key and api secret codes should be updated. */ if (count($_POST) != 2) { $configuration->copywriting_on = $configuration->proofreading_on = $configuration->translation_on = $configuration->copywriting_quality_on = $configuration->proofreading_quality_on = $configuration->translation_quality_on = $configuration->copywriting_expertise_on = $configuration->proofreading_expertise_on = $configuration->translation_expertise_on = 0; } foreach ($_POST as $name => $value) { $configuration->{$name} = pSQL($value); } // new configuration values are being assigned if ($configuration->updateConfiguration()) { $this->addFlashMessage($this->l('Setting were successfully updated')); Tools::redirectAdmin(self::CURRENT_INDEX . Tools::getValue('token') . '&configure=' . $this->name . '&menu=settings&token=' . Tools::getAdminTokenLite('AdminModules')); exit; } else { $this->_html .= $this->displayError($this->l('Error! Settings were not updated')); } }