summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/fb_user_app.module35
1 files changed, 21 insertions, 14 deletions
diff --git a/contrib/fb_user_app.module b/contrib/fb_user_app.module
index e13785b..c6ecde6 100644
--- a/contrib/fb_user_app.module
+++ b/contrib/fb_user_app.module
@@ -154,22 +154,29 @@ function fb_user_app_track_user($fb, $fb_app) {
$fb_app->apikey, fb_facebook_user($fb));
if ($result && !db_affected_rows()) {
- // The row for this user was never inserted, or deleted. Insert now.
+ // The row for this user was never inserted, or it was deleted, or the times were the same.
$fbu = fb_facebook_user($fb);
if ($fbu) {
- $info = fb_users_getInfo(array($fbu), $fb);
- $data = $info[0];
- $fb_user_type = "user";
- $result = db_query("INSERT INTO {fb_user_app} (apikey, fbu, added, user_type, session_key, session_key_expires, time_access, proxied_email, time_cron) VALUES ('%s', %d, %d, '%s', '%s', %d, %d, '%s', %d)",
- $fb_app->apikey, $fbu,
- $data['is_app_user'],
- $fb_user_type,
- $session['session_key'],
- $session['expires'],
- time(),
- $data['proxied_email'],
- 0 // time_cron
- );
+ //First make sure it was not just the same time
+ $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey='%s' AND fbu=%d",
+ $fb_app->apikey,
+ $fbu);
+ if (!db_fetch_object($result)) {
+ //This row does not exist, even with the same time. Insert now
+ $info = fb_users_getInfo(array($fbu), $fb);
+ $data = $info[0];
+ $fb_user_type = "user";
+ $result = db_query("INSERT INTO {fb_user_app} (apikey, fbu, added, user_type, session_key, session_key_expires, time_access, proxied_email, time_cron) VALUES ('%s', %d, %d, '%s', '%s', %d, %d, '%s', %d)",
+ $fb_app->apikey, $fbu,
+ $data['is_app_user'],
+ $fb_user_type,
+ $session['session_key'],
+ $session['expires'],
+ time(),
+ $data['proxied_email'],
+ 0 // time_cron
+ );
+ }
}
}
if ($result === FALSE) {