]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Facebook/facebookhome.php
FacebookPlugin: Fix up FBML canvas app so it keeps working after
[quix0rs-gnu-social.git] / plugins / Facebook / facebookhome.php
index 91c0cc6b861ee4e8ac3da3419958215b7b7024c3..9b18a695bfd0c09bc89cfd79973673a5bfd87eec 100644 (file)
@@ -25,7 +25,6 @@ require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
 
 class FacebookhomeAction extends FacebookAction
 {
-
     var $page = null;
 
     function prepare($argarray)
@@ -45,34 +44,15 @@ class FacebookhomeAction extends FacebookAction
     {
         parent::handle($args);
 
-        // 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) {
-
+        if (!empty($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);
-             }
+                $this->getUpdatePermission();
+               return;
+            }
 
              if ($this->arg('status_submit') == 'Send') {
                 $this->saveNewNotice();
@@ -82,18 +62,14 @@ class FacebookhomeAction extends FacebookAction
             // 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()
     {
-
         $this->showStylesheets();
 
         $nickname = common_canonical_nickname($this->trimmed('nickname'));
@@ -102,13 +78,11 @@ class FacebookhomeAction extends FacebookAction
         $msg = null;
 
         if ($nickname) {
-
             if (common_check_user($nickname, $password)) {
-
                 $user = User::staticGet('nickname', $nickname);
 
                 if (!$user) {
-                    $this->showLoginForm(_("Server error - couldn't get user!"));
+                    $this->showLoginForm(_m("Server error: Couldn't get user!"));
                 }
 
                 $flink = DB_DataObject::factory('foreign_link');
@@ -122,25 +96,15 @@ class FacebookhomeAction extends FacebookAction
 
                 // XXX: Do some error handling here
 
-                $this->setDefaults();
-
                 $this->getUpdatePermission();
                 return;
-
             } else {
-                $msg = _('Incorrect username or password.');
+                $msg = _m('Incorrect username or password.');
             }
         }
 
         $this->showLoginForm($msg);
         $this->showFooter();
-
-    }
-
-    function setDefaults()
-    {
-        $this->facebook->api_client->data_setUserPreference(
-            FACEBOOK_PROMPTED_UPDATE_PREF, 'false');
     }
 
     function showNoticeForm()
@@ -155,9 +119,16 @@ class FacebookhomeAction extends FacebookAction
     function title()
     {
         if ($this->page > 1) {
-            return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page);
+            // @todo FIXME: Core should have methods to get "Full name (nickname)" in a localised form
+            // so that this can be used consistenly throughout StatusNet without having to implement it
+           // over and over..
+            // TRANS: Page title.
+            // TRANS: %1$s is a user nickname, %2$s is a page number.
+            return sprintf(_m('%1$s and friends, page %2$d'), $this->user->nickname, $this->page);
         } else {
-            return sprintf(_("%s and friends"), $this->user->nickname);
+            // TRANS: Page title.
+            // TRANS: %s is a user nickname
+            return sprintf(_m("%s and friends"), $this->user->nickname);
         }
     }
 
@@ -175,18 +146,17 @@ class FacebookhomeAction extends FacebookAction
 
     function showNoticeList($notice)
     {
-
         $nl = new NoticeList($notice, $this);
         return $nl->show();
     }
 
     function getUpdatePermission() {
-
         $this->showStylesheets();
 
         $this->elementStart('div', array('class' => 'facebook_guide'));
 
-        $instructions = sprintf(_('If you would like the %s app to automatically update ' .
+        // TRANS: Instructions. %s is the application name.
+        $instructions = sprintf(_m('If you would like the %s app to automatically update ' .
             'your Facebook status with your latest notice, you need ' .
             'to give it permission.'), $this->app_name);
 
@@ -209,20 +179,21 @@ class FacebookhomeAction extends FacebookAction
             '&next_cancel=' . $next . '&submit=skip';
 
         $this->elementStart('span', array('class' => 'facebook-button'));
+        // @todo FIXME: sprintf not needed here?
         $this->element('a', array('href' => $auth_url),
-            sprintf(_('Okay, do it!'), $this->app_name));
+            sprintf(_m('Okay, do it!'), $this->app_name));
         $this->elementEnd('span');
 
         $this->elementEnd('li');
 
         $this->elementStart('li', array('id' => 'fb-permissions-item'));
-        $this->submit('skip', _('Skip'));
+        // TRANS: Button text. Clicking the button will skip updating Facebook permissions.
+        $this->submit('skip', _m('BUTTON','Skip'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
 
         $this->elementEnd('form');
         $this->elementEnd('div');
-
     }
 
     /**
@@ -238,15 +209,13 @@ class FacebookhomeAction extends FacebookAction
      */
     function pagination($have_before, $have_after, $page, $action, $args=null)
     {
-
         // Does a little before-after block for next/prev page
 
         // XXX: Fix so this uses common_local_url() if possible.
 
         if ($have_before || $have_after) {
-            $this->elementStart('div', array('class' => 'pagination'));
-            $this->elementStart('dl', null);
-            $this->element('dt', null, _('Pagination'));
+            $this->elementStart('dl', 'pagination');
+            $this->element('dt', null, _m('Pagination'));
             $this->elementStart('dd', null);
             $this->elementStart('ul', array('class' => 'nav'));
         }
@@ -255,7 +224,8 @@ class FacebookhomeAction extends FacebookAction
             $newargs = $args ? array_merge($args, $pargs) : $pargs;
             $this->elementStart('li', array('class' => 'nav_prev'));
             $this->element('a', array('href' => "$action?page=$newargs[page]", 'rel' => 'prev'),
-                           _('After'));
+                           // TRANS: Pagination link.
+                           _m('After'));
             $this->elementEnd('li');
         }
         if ($have_after) {
@@ -263,15 +233,14 @@ class FacebookhomeAction extends FacebookAction
             $newargs = $args ? array_merge($args, $pargs) : $pargs;
             $this->elementStart('li', array('class' => 'nav_next'));
             $this->element('a', array('href' => "$action?page=$newargs[page]", 'rel' => 'next'),
-                           _('Before'));
+                           // TRANS: Pagination link.
+                           _m('Before'));
             $this->elementEnd('li');
         }
         if ($have_before || $have_after) {
             $this->elementEnd('ul');
             $this->elementEnd('dd');
             $this->elementEnd('dl');
-            $this->elementEnd('div');
         }
     }
-
 }