<?php include 'core/init.php'; include 'core/timezones.php'; $user = new User(); $fb = new Facebook(); $template = new Template(); $fbaccount = new fbaccount(); $fbapps = new FbApps(); // Switch facebook account request if (Input::Get("switchFbAccount")) { if ($fbaccount->exists(Input::Get("switchFbAccount"))) { $user->UpdateOptions(array('default_Fb_Account' => Input::Get("switchFbAccount"))); if (!httpReferer()) { Redirect::To("settings.php"); } Redirect::To(httpReferer()); } } // Delete facebook account if (Input::get("action", "GET") == "deletefbaccount" && Input::get("id", "GET")) { try { $fbaccount->delete(Input::get("id", "GET")); Session::Flash("settings", "success", lang("FB_ACCOUNT_SUCCESS_DELETED"), true); } catch (Exception $ex) { Session::Flash("settings", "danger", $ex->GetMessage(), true); } Redirect::To("settings.php#tab-fbAccounts"); } // Delete facebook app if (Input::get("action", "GET") == "deletefbapp" && Input::get("id", "GET")) {
if ($fbAppDetails = $fb->AppDetailsFromAt(Input::Get("fb_accesstoken"))) { if ($fb->GetAccessToken($fbAppDetails->id, $userData->id)) { $fb->UpdateAccessToken($user->data()->id, $fbAppDetails->id, $userData->id, Input::Get("fb_accesstoken")); } else { $fb->SaveAccessToken($user->data()->id, $fbAppDetails->id, $userData->id, Input::Get("fb_accesstoken")); } } else { echo lang("UNABLE_TO_GET_FB_APP_DETAILS"); exit; } // Save new facebook account $fbaccount->setUserId($user->data()->id); $fbaccount->setFbId($userData->id); $fbaccount->setLastname($userData->first_name); $fbaccount->setFirstname($userData->last_name); $fbaccount->setGroups($fbgroups); if (!$fbaccount->UserFbAccountDefaultApp()) { $fbaccount->setDefaultApp($fbAppDetails->id); } // Check if this facebook account is already exists; if ($fbaccount->exists($userData->id)) { $fbaccount->Update(); } else { $fbaccount->Save(); } // Set the current account as the default fb account if there is no default account if (!$fbaccount->UserDefaultFbAccount()) { $user->UpdateOptions(array('default_Fb_Account' => $userData->id)); } echo "true"; }