/** * @param TabTable $tab * @param UserTable $user * @param int $ui * @param array $postdata */ public function getCBpluginComponent( /** @noinspection PhpUnusedParameterInspection */ $tab, /** @noinspection PhpUnusedParameterInspection */ $user, /** @noinspection PhpUnusedParameterInspection */ $ui, /** @noinspection PhpUnusedParameterInspection */ $postdata ) { $returnUrl = $this->input( 'return', null, GetterInterface::BASE64 ); if ( $returnUrl ) { $returnUrl = base64_decode( $returnUrl ); } try { $hybrid = new cbconnectHybrid(); } catch ( Exception $e ) { cbRedirect( ( $returnUrl ? $returnUrl : 'index.php' ), $e->getMessage(), 'error' ); return; } $provider = $this->input( 'provider', null, GetterInterface::STRING ); $providerId = null; if ( ! $provider ) { $providerId = $this->input( 'hauth_start', null, GetterInterface::STRING ); if ( ! $providerId ) { $providerId = $this->input( 'hauth_done', null, GetterInterface::STRING ); } $provider = $hybrid->getProviderFromId( $providerId ); } else { $providerId = $hybrid->getIdFromProvider( $provider ); } $action = $this->input( 'action', null, GetterInterface::STRING ); $hybridAuth = null; $error = null; try { $hybridAuth = $hybrid->getHybridAuth(); /** @var Hybrid_Storage $storage */ $storage = $hybridAuth->storage(); if ( $storage ) { if ( ! $returnUrl ) { $redirectUrl = $storage->get( 'redirect_url' ); if ( $redirectUrl ) { $returnUrl = base64_decode( $redirectUrl ); } } else { $storage->set( 'redirect_url', base64_encode( $returnUrl ) ); } } } catch ( Exception $e ) { $error = $e->getMessage(); } if ( ! $returnUrl ) { $returnUrl = 'index.php'; } if ( ( ! $hybridAuth ) || ( ! $this->params->get( $provider . '_enabled', false, GetterInterface::BOOLEAN ) ) ) { if ( ! $error ) { $error = CBTxt::T( 'PROVIDER_NOT_AVAILABLE', '[provider] is not available.', array( '[provider]' => $providerId ) ); } cbRedirect( $this->_returnUrl, $error, 'error' ); return; } $this->_hybrid = $hybrid; $this->_hybridAuth = $hybridAuth; $this->_provider = $provider; $this->_providerId = $providerId; $this->_providerField = $hybrid->getProviderField( $provider ); $this->_providerName = $hybrid->getProviderName( $provider ); $this->_returnUrl = $returnUrl; switch ( $action ) { case 'authenticate': $this->authenticate(); break; case 'endpoint': $this->endpoint(); break; } }