? activitystream_facebook-828456.patch
Index: activitystream_facebook.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/activitystream_facebook/activitystream_facebook.module,v
retrieving revision 1.2.4.4
diff -u -p -r1.2.4.4 activitystream_facebook.module
--- activitystream_facebook.module	24 Apr 2009 16:50:42 -0000	1.2.4.4
+++ activitystream_facebook.module	18 Jun 2010 12:37:06 -0000
@@ -9,7 +9,7 @@
 /*
  * The API passes in a $user object that contains four properties:
  * uid, userid, password, feed. These properties contain the account
- * information entered into the user's settings page, along with the 
+ * information entered into the user's settings page, along with the
  * uid of their Drupal account.
  */
 function activitystream_facebook_streamapi($user) {
@@ -25,7 +25,22 @@ function activitystream_facebook_streama
   //'http://www.new.facebook.com/feeds/status.php?id='.$user->userid .'&viewer='.$user->userid.'&key='.$user->extra.'&format=rss20';
   //$user->feed ='http://www.new.facebook.com/feeds/status.php?id=652116749&viewer=652116749&key=5e35fdee0b&format=rss20';
   $items = activitystream_feed_streamapi($user);
-  return $items;
+  foreach ($items as $fbmsg) {
+    $userid = $user->userid .':';
+    if(empty($fbmsg['title'])) {
+      $fbmsg['title'] = check_plain($fbmsg['link']);
+    }
+    $user_full = activitystream_user_load($user->uid);
+    if(isset($user_full->activitystream_facebook_filter)) {
+      $format_full = filter_format_load($user_full->activitystream_facebook_filter);
+      $format = $format_full->format;
+    } else {
+      $format = FILTER_FORMAT_DEFAULT;
+    }
+    $fbmsg['body'] = check_markup($fbmsg['body'], $format, $check = TRUE);
+    $newitems[] = $fbmsg;
+  }
+  return $newitems;
 }
 
 
@@ -34,7 +49,7 @@ function activitystream_facebook_streama
  * using an array that mirrors the Drupal form API. activitystream.module
  * will add the form elements to a tab called Activity Streams on the
  * user's Profile Edit page. Fields should be named
- * yourmodulename_fieldname. For instance, to store the user ID for 
+ * yourmodulename_fieldname. For instance, to store the user ID for
  * Flickr, the field name is activitystream_flickr_userid
  *
  * To avoid collisions with other activitystream module's forms
@@ -42,7 +57,7 @@ function activitystream_facebook_streama
  *
  * @param $edit
  *   The values of the form fields, used for setting defaults
- * 
+ *
  */
 function activitystream_facebook_activitystream_settings(&$edit) {
   $form['activitystream_facebook'] = array(
@@ -53,7 +68,9 @@ function activitystream_facebook_activit
     '#title' => t('Facebook Status RSS feed URL'),
     '#default_value' => empty($edit['activitystream_facebook_feed']) ? '' : $edit['activitystream_facebook_feed'],
     '#description' => t('<a href="http://heidisoft.com/blogs/subscribe-new-facebook-feeds" target="_blank">Click here</a> for more information'));
-   return $form;  
+  $filter =  empty($edit['activitystream_facebook_filter']) ? 'FILTER_FORMAT_DEFAULT' : $edit['activitystream_facebook_filter'];
+  $form['activitystream_facebook']['activitystream_facebook_filter'] = filter_form($filter, $weight  = NULL, $parents = array('activitystream_facebook_filter'));
+   return $form;
 }
 
 function theme_activitystream_facebook_icon() {
@@ -65,7 +82,15 @@ function theme_activitystream_facebook_i
   $date = theme('activitystream_date', $node->created);
   $user = activitystream_user_load($node->uid);
   $name = theme('activitystream_username', $user);
-  return '<span class="activitystream-item">'. theme('activitystream_facebook_icon')   . " <span>$name " . l($node->title, $activity->link) ." <span class=\"activitystream-created\">$date</span></span>". l('#', 'node/'. $node->nid, array('class' => 'permalink')) .'</span>';
+  $title = activitystream_facebook_makelinks($node->title);
+  return '<span class="activitystream-item">'. theme('activitystream_facebook_icon')   . " <span>$name " . l(title, $activity->link) ." <span class=\"activitystream-created\">$date</span></span>". l('#', 'node/'. $node->nid, array('class' => 'permalink')) .'</span>';
+}
+
+function activitystream_facebook_makelinks($text) {
+  // autolink URLS
+  $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $text);
+  $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<a href="http://\\2">\\2</a>', $text);
+  return $text;
 }
 
 function activitystream_facebook_theme() {
@@ -77,4 +102,4 @@ function activitystream_facebook_theme()
       'arguments' => array('activity' => NULL),
     ),
   );
-}
\ No newline at end of file
+}
