]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/facebookhome.php
update version in README, add note about status.net
[quix0rs-gnu-social.git] / actions / facebookhome.php
index d943104c2b3b6ff1038e279a98ce2b0014713d5b..70f20520530d2140ea7a4709d9fa2736d70160ae 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
  * along with this program.     If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 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);        
-                
+        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
@@ -58,7 +57,7 @@ class FacebookhomeAction extends FacebookAction
 
             // 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('status_update')) {
+            if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) {
 
                  if ($this->facebook->api_client->data_getUserPreference(
                     FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') {
@@ -73,7 +72,7 @@ class FacebookhomeAction extends FacebookAction
                  $this->updateProfileBox($notice);
              }
 
-             if ($this->arg('status_submit') == 'Send') {            
+             if ($this->arg('status_submit') == 'Send') {
                 $this->saveNewNotice();
              }
 
@@ -81,7 +80,7 @@ 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
@@ -89,12 +88,12 @@ class FacebookhomeAction extends FacebookAction
         }
 
     }
-    
+
     function login()
     {
-        
+
         $this->showStylesheets();
-        
+
         $nickname = common_canonical_nickname($this->trimmed('nickname'));
         $password = $this->arg('password');
 
@@ -115,7 +114,7 @@ class FacebookhomeAction extends FacebookAction
                 $flink->foreign_id = $this->fbuid;
                 $flink->service = FACEBOOK_SERVICE;
                 $flink->created = common_sql_now();
-                $flink->set_flags(true, false, false);
+                $flink->set_flags(true, false, false, false);
 
                 $flink_id = $flink->insert();
 
@@ -138,24 +137,17 @@ class FacebookhomeAction extends FacebookAction
 
     function setDefaults()
     {
-        // A default prefix string for notices
-        $this->facebook->api_client->data_setUserPreference(
-            FACEBOOK_NOTICE_PREFIX, 'dented: ');
         $this->facebook->api_client->data_setUserPreference(
             FACEBOOK_PROMPTED_UPDATE_PREF, 'false');
     }
-    
 
     function showNoticeForm()
     {
-        
         $post_action = "$this->app_uri/index.php";
-        
-        $notice_form = new FacebookNoticeForm($this, $post_action, null, 
+
+        $notice_form = new FacebookNoticeForm($this, $post_action, null,
             $post_action, $this->user);
         $notice_form->show();
-    
-    
     }
 
     function title()
@@ -169,22 +161,19 @@ class FacebookhomeAction extends FacebookAction
 
     function showContent()
     {
+        $notice = $this->user->noticeInbox(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
 
-        $notice = $this->user->noticesWithFriends(($this->page-1) *
-            NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
-        
         $nl = new NoticeList($notice, $this);
 
         $cnt = $nl->show();
 
         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
                           $this->page, 'index.php', array('nickname' => $this->user->nickname));
-
     }
 
     function showNoticeList($notice)
     {
-                
+
         $nl = new NoticeList($notice, $this);
         return $nl->show();
     }
@@ -209,16 +198,16 @@ class FacebookhomeAction extends FacebookAction
 
         $this->elementStart('ul', array('id' => 'fb-permissions-list'));
         $this->elementStart('li', array('id' => 'fb-permissions-item'));
-        
+
         $next = urlencode("$this->app_uri/index.php");
         $api_key = common_config('facebook', 'apikey');
-        
+
         $auth_url = 'http://www.facebook.com/authorize.php?api_key=' .
-            $api_key . '&v=1.0&ext_perm=status_update&next=' . $next . 
+            $api_key . '&v=1.0&ext_perm=publish_stream&next=' . $next .
             '&next_cancel=' . $next . '&submit=skip';
-        
+
         $this->elementStart('span', array('class' => 'facebook-button'));
-        $this->element('a', array('href' => $auth_url), 
+        $this->element('a', array('href' => $auth_url),
             sprintf(_('Okay, do it!'), $this->app_name));
         $this->elementEnd('span');
 
@@ -233,7 +222,7 @@ class FacebookhomeAction extends FacebookAction
         $this->elementEnd('div');
 
     }
-    
+
     /**
      * Generate pagination links
      *
@@ -247,11 +236,11 @@ 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);
@@ -262,7 +251,7 @@ class FacebookhomeAction extends FacebookAction
         if ($have_before) {
             $pargs   = array('page' => $page-1);
             $newargs = $args ? array_merge($args, $pargs) : $pargs;
-            $this->elementStart('li', array('class' => 'nav_prev'));            
+            $this->elementStart('li', array('class' => 'nav_prev'));
             $this->element('a', array('href' => "$action?page=$newargs[page]", 'rel' => 'prev'),
                            _('After'));
             $this->elementEnd('li');
@@ -282,6 +271,5 @@ class FacebookhomeAction extends FacebookAction
             $this->elementEnd('div');
         }
     }
-    
 
 }