Пример #1
0
 public function init()
 {
     $this->cleanSessionData(self::NETWORK_ID);
     if (empty($_SESSION['sn']['authorized'])) {
         if (is_null(self::$object)) {
             self::createFacebookInstance();
         }
         $this->takeDataFromServer = true;
         if (!SJB_Request::getVar('state', null, 'GET')) {
             $this->saveUserGroupIDIfPossible();
             SJB_HelperFunctions::redirect($this->getFacebookLoginUrl());
             exit;
         } elseif ($this->getProfileInformation()) {
             $this->flagSocialPluginInSession(self::NETWORK_ID);
             $this->saveProfileSystemInfo();
             if ($oCurrentUser = SJB_UserManager::getCurrentUser()) {
                 $this->setUserSocialIDByUserSID($oCurrentUser->getSID(), self::$oProfile->id);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-account/');
             } elseif (!(self::$oProfile && parent::ifUserIsRegisteredByReferenceUid($this->getReferenceUid()))) {
                 // redirect user to registration page if he is not registered
                 $this->redirectToRegistrationSocialPage();
             }
         }
     } elseif (self::$oProfile && !parent::ifUserIsRegisteredByReferenceUid($this->getReferenceUid())) {
         // if user already logged in using social plugin but not registered
         // redirect him to registration social page
         $this->redirectToRegistrationSocialPage();
     }
 }