]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
trac750 update Facebook status when posting to Identi.ca from Facebook
authorZach Copley <zach@controlyourself.ca>
Thu, 29 Jan 2009 05:58:27 +0000 (05:58 +0000)
committerZach Copley <zach@controlyourself.ca>
Thu, 29 Jan 2009 05:58:27 +0000 (05:58 +0000)
actions/facebookhome.php
lib/facebookaction.php

index 4eaf0b4f76bcd99a925a052e81a39a5ef035df33..7f9c942ea9e16f710307ed960141139298de14c7 100644 (file)
@@ -89,7 +89,7 @@ class FacebookhomeAction extends FacebookAction
         }
 
     }
-
+    
     function login()
     {
         
@@ -232,53 +232,6 @@ class FacebookhomeAction extends FacebookAction
         $this->elementEnd('div');
 
     }
-
-    function saveNewNotice()
-    {
-
-        $user = $this->flink->getUser();
-
-        $content = $this->trimmed('status_textarea');
-        
-        if (!$content) {
-            $this->showPage(_('No notice content!'));
-            return;
-        } else {
-            $content_shortened = common_shorten_links($content);
-
-            if (mb_strlen($content_shortened) > 140) {
-                common_debug("Content = '$content_shortened'", __FILE__);
-                common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
-                $this->showPage(_('That\'s too long. Max notice size is 140 chars.'));
-                return;
-            }
-        }
-
-        $inter = new CommandInterpreter();
-
-        $cmd = $inter->handle_command($user, $content_shortened);
-
-        if ($cmd) {
-            
-            // XXX fix this
-            
-            $cmd->execute(new WebChannel());
-            return;
-        }
-
-        $replyto = $this->trimmed('inreplyto');
-
-        $notice = Notice::saveNew($user->id, $content,
-            'Facebook', 1, ($replyto == 'false') ? null : $replyto);
-
-        if (is_string($notice)) {
-            $this->showPage($notice);
-            return;
-        }
-
-        common_broadcast_notice($notice);
-        
-    }
     
     /**
      * Generate pagination links
index 63ac66250b000f17db567d28858f880877aaa5bc..bfba702e6a09b6bb5d09c95a6b2b280ad0f38ead 100644 (file)
@@ -441,6 +441,66 @@ class FacebookAction extends Action
         }
     }
     
+    function updateFacebookStatus($notice) 
+    {
+        $prefix = $this->facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX, $this->fbuid);
+        $content = "$prefix $notice->content";
+        
+        if ($this->facebook->api_client->users_hasAppPermission('status_update', $this->fbuid)) {
+            $this->facebook->api_client->users_setStatus($content, $this->fbuid, false, true);
+        }
+    }
+    
+    function saveNewNotice()
+    {
+
+        $user = $this->flink->getUser();
+
+        $content = $this->trimmed('status_textarea');
+        
+        if (!$content) {
+            $this->showPage(_('No notice content!'));
+            return;
+        } else {
+            $content_shortened = common_shorten_links($content);
+
+            if (mb_strlen($content_shortened) > 140) {
+                common_debug("Content = '$content_shortened'", __FILE__);
+                common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
+                $this->showPage(_('That\'s too long. Max notice size is 140 chars.'));
+                return;
+            }
+        }
+
+        $inter = new CommandInterpreter();
+
+        $cmd = $inter->handle_command($user, $content_shortened);
+
+        if ($cmd) {
+            
+            // XXX fix this
+            
+            $cmd->execute(new WebChannel());
+            return;
+        }
+
+        $replyto = $this->trimmed('inreplyto');
+
+        $notice = Notice::saveNew($user->id, $content,
+            'Facebook', 1, ($replyto == 'false') ? null : $replyto);
+
+        if (is_string($notice)) {
+            $this->showPage($notice);
+            return;
+        }
+
+        common_broadcast_notice($notice);
+        
+        // Also update the user's Facebook status
+        $this->updateFacebookStatus($notice);
+        $this->updateProfileBox($notice);
+        
+    }
 
 }