diff --git a/e107_plugins/facebook/e_module.php b/e107_plugins/facebook/e_module.php
index 16c57aac5..418ddc86c 100644
--- a/e107_plugins/facebook/e_module.php
+++ b/e107_plugins/facebook/e_module.php
@@ -4,8 +4,10 @@
-if (e_ADMIN_AREA != TRUE)
+if (e_ADMIN_AREA !== TRUE)
{
+
+
e107::getEvent()->register('logout',array('e_facebook','fb_logout'),e_PLUGIN.'facebook/facebook_function.php');
global $fb;
@@ -47,10 +49,11 @@ if (e_ADMIN_AREA != TRUE)
{
Switch_Facebook_User();
}
-
- if (USERID && (e_QUERY == 'facebook_link'))
+
+ if (USERID && (e_QUERY == 'facebook_link') && $fb->fb_uid) //
{
- Add_Facebook_Connect_User('', USERID);
+ // $fb->Add_Facebook_Connect_User('', USERID);
+ $fb->addFacebookUser();
}
if (e_QUERY == 'facebook_delete')
diff --git a/e107_plugins/facebook/facebook_function.php b/e107_plugins/facebook/facebook_function.php
index 15086f062..86918a406 100644
--- a/e107_plugins/facebook/facebook_function.php
+++ b/e107_plugins/facebook/facebook_function.php
@@ -10,8 +10,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/facebook/facebook_function.php,v $
- | $Revision: 1.9 $
- | $Date: 2009-11-12 09:09:37 $
+ | $Revision: 1.10 $
+ | $Date: 2009-11-12 10:42:32 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -465,64 +465,10 @@ function single_uid()
return $count;
}
-function uid_check()
-{
- $sql = e107::getDb();
-
- if (!$sql->db_Select("facebook", "*", "facebook_user_id = ".USERID." "))
- {
- return "
";
- // ".your_facebook_is()."
";
- }
- else
- {
- return '
-
- ';
- }
- /*
- $msg = "";
-
- if ($sql->db_Select("facebook", "*", "facebook_uid = '".is_fb()."' AND facebook_user_id != ".USERID." "))
- {
- // header ( 'Location: ' . e_SELF ) ;
- $msg .= "";
- $msg .= "";
- }
- else if($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID != '".is_fb()."' AND user_plugin_facebook_ID != '' "))
- {
- $msg .= " ".your_facebook_is()."
";
- }
- else if($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID = '' "))
- {
- $msg .= "".your_facebook_is()."
";
- }
- else
- {
- $msg .= '
-
- ';
- }
-
- return $msg;*/
-}
-function uid_exists()
-{
- $sql = e107::getDb();
-
- if ($sql->db_Select("facebook", "*", "facebook_user_id = ".USERID." AND facebook_uid = ".is_fb()." "))
- {
- return USERID;
- // $row = $sql->db_Fetch();
- // return $row['user_extended_id'];
- }
- else
- {
- return null;
- }
-}
+
+
/**
* simple display icon
@@ -890,10 +836,14 @@ class e_facebook
'user_loginname' => $username,
'user_password' => $password,
'user_login' => $this->fb_getUserData('name'),
+ 'user_join' => time(),
'user_image' => $this->fb_getUserData('pic')
);
- $this->e107_userid = $sql->db_Insert('user',$insert);
+ if($this->e107_userid = $sql->db_Insert('user',$insert))
+ {
+ e107::getEvent()->trigger('usersup', $insert);
+ }
if(!$this->e107_userid)
{
@@ -907,6 +857,7 @@ class e_facebook
{
if($sql->db_Insert('facebook', $query))
{
+ e107::getEvent()->trigger('fb_usersignup', $query);
$this->e107Login();
}
}
@@ -915,10 +866,27 @@ class e_facebook
$query['WHERE'] = "facebook_uid = ".$this->fb_uid;
if($sql->db_Update('facebook', $query))
{
+ e107::getEvent()->trigger('fb_userupdate', $query);
$this->e107Login();
}
}
+ $this->redirect(e_SELF);
+ }
+ else // Update existing Facebook Record to use current e107 account and delete other 'facebook' e107 user-account from e107.
+ {
+ $sql->db_Update("facebook", "facebook_user_id = ".USERID.", facebook_connected =1 WHERE facebook_uid = ".$this->fb_uid." LIMIT 1 ");
+ if($sql->db_Select("user","user_loginname = 'FacebookUser_".$this->fb_uid."' "))
+ {
+ $data = $sql->db_Fetch();
+
+ if($sql->db_Delete("user","user_loginname = 'FacebookUser_".$this->fb_uid."' "))
+ {
+ e107::getEvent()->trigger('fb_userdelete',$data);
+ }
+
+ }
+
$this->redirect(e_SELF);
}
}
@@ -1211,6 +1179,7 @@ class e_facebook
if ($sql->db_Update("facebook", "facebook_connected = '1' WHERE facebook_uid = ".$this->fb_uid))
{
+ e107::getEvent()->trigger('fb_userlogin',array('facebook_uid'=>$this->fb_uid));
$this->e107Login(); // Log_In_Registered_User(); // log in to e107.
}
else
@@ -1273,30 +1242,32 @@ class e_facebook
}
else
{
- $html .= uid_check();
+ $html .= $this->uid_check();
}
}
else
{
- if ($this->fb_uid && uid_exists() && (single_uid() == 1))
+ if ($this->fb_uid && $this->uid_exists())
{
- Add_Facebook_Connect_User('', USERID);
- header('Location:'.e_SELF);
+ echo "This shouldn't occur";
+ exit;
+ //Add_Facebook_Connect_User('', USERID);
+ // header('Location:'.e_SELF);
}
else if ($this->fb_uid && (USERID != $this->e107_userid))
{
//return Facebook_LogOut();
- $html .= uid_check();
+ return $this->uid_check();
}
}
if (!$this->isLoggedIn() && ($this->isConnected() === true))
{
- $html .= uid_check();
+ $html .= $this->uid_check();
}
else
@@ -1327,6 +1298,7 @@ class e_facebook
//not a real error! just some problem with Facebook ID
$html .= 'Ops... Some error Occur';
+ // Facebook table is marked as 'connected' but you are logged out of e107.
}
else if ($this->isLoggedIn() == 0)
{
@@ -1348,6 +1320,67 @@ class e_facebook
}
+
+
+ function uid_exists()
+ {
+ $sql = e107::getDb();
+
+ if ($sql->db_Select("facebook", "*", "facebook_user_id = ".USERID." AND facebook_uid = ".$this->fb_uid." LIMIT 1"))
+ {
+ return USERID;
+ // $row = $sql->db_Fetch();
+ // return $row['user_extended_id'];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ function uid_check()
+ {
+ $sql = e107::getDb();
+
+ if (!$sql->db_Select("facebook", "*", "facebook_user_id = ".USERID." "))
+ {
+ return "";
+ // ".your_facebook_is()."
";
+ }
+ else
+ {
+ return '
+
+ ';
+ }
+ /*
+ $msg = "";
+
+ if ($sql->db_Select("facebook", "*", "facebook_uid = '".is_fb()."' AND facebook_user_id != ".USERID." "))
+ {
+ // header ( 'Location: ' . e_SELF ) ;
+ $msg .= "";
+ $msg .= "";
+ }
+ else if($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID != '".is_fb()."' AND user_plugin_facebook_ID != '' "))
+ {
+ $msg .= " ".your_facebook_is()."
";
+ }
+ else if($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID = '' "))
+ {
+ $msg .= "".your_facebook_is()."
";
+ }
+ else
+ {
+ $msg .= '
+
+ ';
+ }
+
+ return $msg;*/
+ }
+
+
function Render_Connect_Invite_Friends()