コード例 #1
0
 public function init()
 {
     $this->cleanSessionData(self::$network);
     $error = SJB_Request::getVar('error', false);
     if ($error && $error == 'access_denied') {
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL'));
     }
     if (isset($_GET['code'])) {
         $this->initialize();
         $googlePlusService = new Google_PlusService(self::$object);
         $oauth2 = new Google_Oauth2Service(self::$object);
         self::$object->authenticate($_GET['code']);
         $_SESSION['access_token'] = self::$object->getAccessToken();
         if (!empty($_SESSION['access_token'])) {
             self::$oProfile = self::getProfileInformation($googlePlusService, $oauth2);
             if (self::$oProfile) {
                 $this->flagSocialPluginInSession(self::$network);
                 self::$oSocialPlugin = $this;
                 $this->redirectToRegistrationSocialPage();
             }
         }
     }
     if (is_null(self::$object) && empty($_SESSION['sn']['authorized'])) {
         $this->initialize();
         $authUrl = self::$object->createAuthUrl();
         SJB_HelperFunctions::redirect($authUrl);
     } elseif (self::$oProfile && !parent::ifUserIsRegistered(self::$network)) {
         $this->redirectToRegistrationSocialPage();
     }
 }