]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
trac750 Automatically update Identi.ca profile box with user's latest dent
authorZach Copley <zach@controlyourself.ca>
Sun, 11 Jan 2009 08:33:28 +0000 (08:33 +0000)
committerZach Copley <zach@controlyourself.ca>
Sun, 11 Jan 2009 08:33:28 +0000 (08:33 +0000)
actions/facebookhome.php
lib/facebookaction.php
lib/facebookutil.php
scripts/update_facebook.php

index 4e67494f0498f620835053db4d2beaeec6e55ea6..bbef447cdb6f0abc6873bb63c2c2024b44fd1712 100644 (file)
@@ -82,21 +82,24 @@ class FacebookhomeAction extends FacebookAction
 
     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) {
             common_element('fb:success', array('message' => $msg));
         }
 
-        $facebook = get_facebook();
-        $fbuid = $facebook->require_login();
-
-        $user = $flink->getUser();
-
         echo $this->show_notices($user);
 
-        $this->update_profile_box($facebook, $fbuid, $user);
-
         $this->show_footer();
     }
 
index 04bbd67bae8c004e49690f3c1d3d8e02af6bd97b..ddf81c034bf68ac497e7517ae4507db7bcd95c94 100644 (file)
@@ -29,61 +29,6 @@ class FacebookAction extends Action
         parent::handle($args);
     }
 
-    function update_profile_box($facebook, $fbuid, $user)
-    {
-
-        $notice = $user->getCurrentNotice();
-
-        # Need to include inline CSS for styling the Profile box
-
-         $style = '<style>
-         #notices {
-         clear: both;
-         margin: 0 auto;
-         padding: 0;
-         list-style-type: none;
-         width: 600px;
-         border-top: 1px solid #dec5b5;
-         }
-         #notices a:hover {
-         text-decoration: underline;
-         }
-         .notice_single {
-         clear: both;
-         display: block;
-         margin: 0;
-         padding: 5px 5px 5px 0;
-         min-height: 48px;
-         font-family: Georgia, "Times New Roman", Times, serif;
-         font-size: 13px;
-         line-height: 16px;
-         border-bottom: 1px solid #dec5b5;
-         background-color:#FCFFF5;
-         opacity:1;
-         }
-         .notice_single:hover {
-         background-color: #f7ebcc;
-         }
-         .notice_single p {
-         display: inline;
-         margin: 0;
-         padding: 0;
-         }
-         </style>';
-
-        $html = Facebookaction::render_notice($notice);
-
-
-        $fbml = "<fb:wide>$style $html</fb:wide>";
-        $fbml .= "<fb:narrow>$style $html</fb:narrow>";
-
-        $fbml_main = "<fb:narrow>$style $html</fb:narrow>";
-
-        $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);
-    }
-
-    # Display methods
-
     function show_header($selected = 'Home', $msg = null, $success = false)
     {
 
index e844dd09a58ea5541de67466e067416f55c0a2a9..2529b8a4b8c6a9369be94dfb1ad9fee578a510de 100644 (file)
@@ -48,4 +48,59 @@ function start_fbml($indent = true)
     $xw = new XMLWriter();
     $xw->openURI('php://output');
     $xw->setIndent($indent);
-}
\ No newline at end of file
+}
+
+function update_profile_box($facebook, $fbuid, $user, $notice)
+{
+
+    // Need to include inline CSS for styling the Profile box
+
+    $style = '<style>
+     #notices {
+         clear: both;
+         margin: 0 auto;
+         padding: 0;
+         list-style-type: none;
+         width: 600px;
+         border-top: 1px solid #dec5b5;
+     }
+     #notices a:hover {
+         text-decoration: underline;
+     }
+     .notice_single {
+         clear: both;
+         display: block;
+         margin: 0;
+         padding: 5px 5px 5px 0;
+         min-height: 48px;
+         font-family: Georgia, "Times New Roman", Times, serif;
+         font-size: 13px;
+         line-height: 16px;
+         border-bottom: 1px solid #dec5b5;
+         background-color:#FCFFF5;
+         opacity:1;
+     }
+     .notice_single:hover {
+         background-color: #f7ebcc;
+     }
+     .notice_single p {
+         display: inline;
+         margin: 0;
+         padding: 0;
+     }
+     </style>';
+
+    global $xw;
+    $xw = new XMLWriter();
+    $xw->openMemory();
+
+    $item = new NoticeListItem($notice);
+    $item->show();
+
+    $fbml = "<fb:wide>$style " . $xw->outputMemory(false) . "</fb:wide>";
+    $fbml .= "<fb:narrow>$style " . $xw->outputMemory(false) . "</fb:narrow>";
+
+    $fbml_main = "<fb:narrow>$style " . $xw->outputMemory(false) . "</fb:narrow>";
+
+    $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);
+}
index 15c0e49f84fdc2f12e3e94eff63e08c6c48994c9..2a1251f3721beec8da04a0716ef6a8171661c889 100755 (executable)
@@ -31,7 +31,7 @@ require_once(INSTALLDIR . '/lib/common.php');
 require_once(INSTALLDIR . '/lib/facebookutil.php');
 
 // For storing the last run date-time
-$last_updated_file = "/home/zach/laconica/scripts/facebook_last_updated";
+$last_updated_file = INSTALLDIR . '/scripts/facebook_last_updated';
 
 // Lock file name
 $tmp_file = "/tmp/update_facebook.lock";
@@ -54,7 +54,8 @@ $cnt = 0;
 
 while($notice->fetch()) {
 
-    $flink = Foreign_link::getByUserID($notice->profile_id, 2);
+    $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE);
+    $user = $flink->getUser();
     $fbuid = $flink->foreign_id;
     $content = $notice->content;
 
@@ -64,6 +65,7 @@ while($notice->fetch()) {
         if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $content) ||
             (($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) {
                 update_status($fbuid, $content);
+                update_profile_box($facebook, $fbuid, $user, $notice);
                 $cnt++;
             }
     }