]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
trac750 Add prefix string option in Facebook app for notice sync
authorZach Copley <zach@controlyourself.ca>
Mon, 12 Jan 2009 05:25:07 +0000 (05:25 +0000)
committerZach Copley <zach@controlyourself.ca>
Mon, 12 Jan 2009 05:25:07 +0000 (05:25 +0000)
actions/facebookhome.php
actions/facebookinvite.php
actions/facebooksettings.php
scripts/update_facebook.php

index bbef447cdb6f0abc6873bb63c2c2024b44fd1712..f72f08a3454b9f04ce92d3f13c62cf9800fca309 100644 (file)
@@ -70,6 +70,8 @@ class FacebookhomeAction extends FacebookAction
 
                 // XXX: Do some error handling here
 
+                $this->setDefaults();
+
                 $this->showHome($flink, _('You can now use Identi.ca from Facebook!'));
 
             } else {
@@ -80,18 +82,26 @@ class FacebookhomeAction extends FacebookAction
         $this->showLoginForm($msg);
     }
 
+    function setDefaults()
+    {
+        $facebook = get_facebook();
+
+        // A default prefix string for notices
+        $facebook->api_client->data_setUserPreference(1, 'dented: ');
+    }
+
     function showHome($flink, $msg)
     {
-        
+
         $facebook = get_facebook();
         $fbuid = $facebook->require_login();
-        
+
         $user = $flink->getUser();
-        
+
         $notice = $user->getCurrentNotice();
         update_profile_box($facebook, $fbuid, $user, $notice);
-        
-        
+
+
         $this->show_header('Home');
 
         if ($msg) {
index 14c09db3d2853ed886165729a598350efcfb84bb..fe0c5e49343a0129d162d639f52d4e49148e29d0 100644 (file)
@@ -46,7 +46,7 @@ class FacebookinviteAction extends FacebookAction
         common_element('h2', null, _('Thanks for inviting your friends to use Identi.ca!'));
         common_element('p', null, _('Invitations have been sent to the following users:'));
 
-        $friend_ids = $_POST['ids']; // Hmm... $arg->('ids) doesn't seem to work
+        $friend_ids = $_POST['ids']; // Hmm... $this->arg('ids') doesn't seem to work
 
         common_element_start("ul");
 
index 862dc073222054176fe1cc13c0dc87be2cf1440e..ab04ad82b56cd2a1dafee52989714a4868683732 100644 (file)
@@ -39,6 +39,7 @@ class FacebooksettingsAction extends FacebookAction
 
         $noticesync = $this->arg('noticesync');
         $replysync = $this->arg('replysync');
+        $prefix = $this->trimmed('prefix');
 
         $facebook = get_facebook();
         $fbuid = $facebook->require_login();
@@ -49,6 +50,8 @@ class FacebooksettingsAction extends FacebookAction
         $flink->set_flags($noticesync, $replysync, false);
         $result = $flink->update($original);
 
+        $facebook->api_client->data_setUserPreference(1, substr($prefix, 0, 128));
+
         if ($result) {
             $this->show_form('Sync preferences saved.', true);
         } else {
@@ -91,6 +94,14 @@ class FacebooksettingsAction extends FacebookAction
             common_checkbox('replysync', _('Send local "@" replies to Facebook.'),
                              ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
 
+            // function common_input($id, $label, $value=null,$instructions=null)
+
+            $prefix = $facebook->api_client->data_getUserPreference(1);
+            
+
+            common_input('prefix', _('Prefix'),
+                         ($prefix) ? $prefix : null,
+                         _('A string to prefix notices with.'));
             common_submit('save', _('Save'));
 
             common_element_end('form');
index 2a1251f3721beec8da04a0716ef6a8171661c889..8c91df384b215dd2f97803a1a6f1fc1de86ba6eb 100755 (executable)
@@ -57,7 +57,10 @@ while($notice->fetch()) {
     $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE);
     $user = $flink->getUser();
     $fbuid = $flink->foreign_id;
-    $content = $notice->content;
+
+    $prefix = $facebook->api_client->data_getUserPreference(1, $fbuid);
+
+    $content = "$prefix $notice->content";
 
     if (($flink->noticesync & FOREIGN_NOTICE_SEND) == FOREIGN_NOTICE_SEND) {