X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ffacebookhome.php;h=70f20520530d2140ea7a4709d9fa2736d70160ae;hb=03022c6e601f223c92216af9748c764786cf46c2;hp=6206fb6c2704498f3e8300aa47cddb6b52dd5f30;hpb=02877224b20f87af304553f739b69544d7ac4cfa;p=quix0rs-gnu-social.git
diff --git a/actions/facebookhome.php b/actions/facebookhome.php
index 6206fb6c27..70f2052053 100644
--- a/actions/facebookhome.php
+++ b/actions/facebookhome.php
@@ -1,7 +1,7 @@
.
*/
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once(INSTALLDIR.'/lib/facebookaction.php');
+require_once INSTALLDIR.'/lib/facebookaction.php';
class FacebookhomeAction extends FacebookAction
{
+ var $page = null;
+
+ function prepare($argarray)
+ {
+ parent::prepare($argarray);
+
+ $this->page = $this->trimmed('page');
+
+ if (!$this->page) {
+ $this->page = 1;
+ }
+
+ return true;
+ }
+
function handle($args)
{
parent::handle($args);
- $this->login();
+ // If the user has opted not to initially allow the app to have
+ // Facebook status update permission, store that preference. Only
+ // promt the user the first time she uses the app
+ if ($this->arg('skip') || $args['fb_sig_request_method'] == 'GET') {
+ $this->facebook->api_client->data_setUserPreference(
+ FACEBOOK_PROMPTED_UPDATE_PREF, 'true');
+ }
+
+ if ($this->flink) {
+
+ $this->user = $this->flink->getUser();
+
+ // If this is the first time the user has started the app
+ // prompt for Facebook status update permission
+ if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) {
+
+ if ($this->facebook->api_client->data_getUserPreference(
+ FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') {
+ $this->getUpdatePermission();
+ return;
+ }
+ }
+
+ // Make sure the user's profile box has the lastest notice
+ $notice = $this->user->getCurrentNotice();
+ if ($notice) {
+ $this->updateProfileBox($notice);
+ }
+
+ if ($this->arg('status_submit') == 'Send') {
+ $this->saveNewNotice();
+ }
+
+ // User is authenticated and has already been prompted once for
+ // Facebook status update permission? Then show the main page
+ // of the app
+ $this->showPage();
+
+ } else {
+
+ // User hasn't authenticated yet, prompt for creds
+ $this->login();
+ }
+
}
function login()
{
- $user = null;
+ $this->showStylesheets();
- $facebook = get_facebook();
- $fbuid = $facebook->require_login();
+ $nickname = common_canonical_nickname($this->trimmed('nickname'));
+ $password = $this->arg('password');
- # check to see whether there's already a Facebook link for this user
- $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
+ $msg = null;
- if ($flink) {
+ if ($nickname) {
- $user = $flink->getUser();
- $this->show_home($facebook, $fbuid, $user);
+ if (common_check_user($nickname, $password)) {
- } else {
+ $user = User::staticGet('nickname', $nickname);
- # Make the user put in her Laconica creds
- $nickname = common_canonical_nickname($this->trimmed('nickname'));
- $password = $this->arg('password');
+ if (!$user) {
+ $this->showLoginForm(_("Server error - couldn't get user!"));
+ }
- if ($nickname) {
+ $flink = DB_DataObject::factory('foreign_link');
+ $flink->user_id = $user->id;
+ $flink->foreign_id = $this->fbuid;
+ $flink->service = FACEBOOK_SERVICE;
+ $flink->created = common_sql_now();
+ $flink->set_flags(true, false, false, false);
- if (common_check_user($nickname, $password)) {
+ $flink_id = $flink->insert();
+ // XXX: Do some error handling here
- $user = User::staticGet('nickname', $nickname);
+ $this->setDefaults();
- if (!$user) {
- echo '