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(); }
public function getAPIConnection() { if ($this->api_instance) { return $this->api_instance; } $api_key = TextMasterConfiguration::get('api_key'); $api_secret = TextMasterConfiguration::get('api_secret'); /* checks connection to API if at least one of API codes is set */ if ($api_key or $api_secret) { $textmasterAPI = new TextMasterAPI($this, $api_key, $api_secret); if (!$textmasterAPI->isConnected()) { $this->_html .= $this->displayWarnings(array($this->l('Please login / register'))); return false; } } else { return false; } $this->api_instance = $textmasterAPI; return $this->api_instance; }