Пример #1
0
 function LoginJUser()
 {
     $db = JFactory::getDBO();
     $session = JFactory::getSession();
     jimport('joomla.user.helper');
     JPluginHelper::importPlugin('user');
     $user = clone JFactory::getUser();
     $myparams = JComponentHelper::getParams('com_fbconnct');
     if ($this->isJ16()) {
         $mainframe = JFactory::getApplication();
         $redirAfterLogin = $myparams->getValue('data.params.redirect-after-login');
     } else {
         global $mainframe;
         $redirAfterLogin = $myparams->get('redirect-after-login');
     }
     $fb = $this->try_connect();
     $uid = $fb['fbid'];
     $me = $fb['fbdetails'];
     $getappid = $fb['appid'];
     $uemail = $me['email'];
     $intdatetime = time();
     if (fbconnctController::count_jemail($uemail)) {
         $db->setQuery("SELECT id,name,username FROM #__users WHERE email='{$uemail}'");
         $userDetails = $db->loadObjectList();
         $row = $userDetails[0];
         $options = array();
         $options['action'] = 'core.login.site';
         $response = new stdClass();
         $response->username = $row->username;
         $j_uid = $row->id;
         if (!fbconnctController::count_j_fb_user($j_uid)) {
             $fbinsertquary = "INSERT INTO #__facebook_joomla_connect(joomla_userid,facebook_userid,joined_date,linked) VALUES ({$j_uid},{$uid},{$intdatetime},1)";
             $db->setQuery($fbinsertquary);
             $result = $db->query();
         }
         if (fbconnctController::isJ16()) {
             $result = $mainframe->triggerEvent('onUserLogin', array((array) $response, $options));
         } else {
             $result = $mainframe->triggerEvent('onLoginUser', array((array) $response, $options));
         }
         fbconnctController::closeWindow($redirAfterLogin);
     } else {
         $session->set('user_details', $me);
         $createUser_url = JRoute::_('index.php?task=create&option=com_fbconnct&format=raw');
         $mainframe->redirect($createUser_url);
     }
 }