Auto Disconnection from CRM
-
Unfortunately the plugin disconnect sometimes and will stays disconnected if you don’t hit connect again in Connection tab.
And that is why i changed thePlugin
class andconnected
function like this:public function connected() { $cacheConnected = isset( $this->options ) && isset( $this->options["connected"] ) && $this->options["connected"] == true; if ( $cacheConnected !== true ) { return $this->retryConnect(); } return true; } private function retryConnect() { /* Delete cache section */ ACRM()->purgeCache(); Connection::setConnectionStatus( false ); $options = get_option( Plugin::PREFIX . 'options' ); if ( ! isset( $options["serverUrl"] ) || ! isset( $options["username"] ) || ! isset( $options["password"] ) || ! $options["serverUrl"] || ! $options["username"] || ! $options["password"] ) { return false; } try { $clientSettings = new Settings( $options ); ACRM()->getLogger()->notice( 'Connecting to a new instance', [ 'settings' => [ 'authMode' => $clientSettings->authMode, 'crmUrl' => $clientSettings->serverUrl, 'username' => $clientSettings->username, 'ignoreSslErrors' => $clientSettings->ignoreSslErrors, ] ] ); $client = new Client( $clientSettings, ACRM()->getCache(), ACRM()->getLogger()->withName( 'crmtoolkit' ) ); // next settings are retrieved during Client instantiation $options['organizationName'] = $clientSettings->organizationName; $options['organizationUniqueName'] = $clientSettings->organizationUniqueName; $options['organizationVersion'] = $clientSettings->organizationVersion; $options['organizationId'] = $clientSettings->organizationId; if ( isset( $client ) && $whoAmI = $client->executeAction( "WhoAmI" ) ) { update_option( Plugin::PREFIX . 'options', $options ); $this->options = ACRM()->options = $options; Connection::setConnectionStatus( true ); } } catch ( Exception $e ) { return false; } return true; }
Do you approve it?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Auto Disconnection from CRM’ is closed to new replies.