From 24a1cb695fb61ca20fc5ebd7f4c165eaa53e25c9 Mon Sep 17 00:00:00 2001 From: Ben Liyanage Date: Wed, 8 Oct 2014 16:08:56 -0400 Subject: [PATCH] cleanup -- not working right yet removed an uncessary variable from the function fbsync_createpost cleaned up some formatting please note, this and previous version of this file will not work because $self is not available in some spots where its needed. --- fbsync/fbsync.php | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/fbsync/fbsync.php b/fbsync/fbsync.php index 8e87cfc5..2ae64676 100644 --- a/fbsync/fbsync.php +++ b/fbsync/fbsync.php @@ -212,7 +212,7 @@ function fbsync_expire($a,$b) { logger('fbsync_expire: expire_end'); } -function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) { +function fbsync_createpost($a, $uid, $contacts, $applications, $post, $create_user) { //Sanitize Inputs $post->actor_id = number_format($post->actor_id, 0, '', ''); $post->source_id = number_format($post->source_id, 0, '', ''); @@ -325,20 +325,21 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr // Change the object type when an attachment is present if (isset($post->attachment->fb_object_type)) logger('fb_object_type: '.$post->attachment->fb_object_type." ".print_r($post->attachment, true), LOGGER_DEBUG); - switch ($post->attachment->fb_object_type) { - case 'photo': - $postarray['object-type'] = ACTIVITY_OBJ_IMAGE; // photo is deprecated: http://activitystrea.ms/head/activity-schema.html#image - break; - case 'video': - $postarray['object-type'] = ACTIVITY_OBJ_VIDEO; - break; - case '': - //$postarray['object-type'] = ACTIVITY_OBJ_BOOKMARK; - break; - default: - logger('Unknown object type '.$post->attachment->fb_object_type, LOGGER_DEBUG); - break; - } + + switch ($post->attachment->fb_object_type) { + case 'photo': + $postarray['object-type'] = ACTIVITY_OBJ_IMAGE; // photo is deprecated: http://activitystrea.ms/head/activity-schema.html#image + break; + case 'video': + $postarray['object-type'] = ACTIVITY_OBJ_VIDEO; + break; + case '': + //$postarray['object-type'] = ACTIVITY_OBJ_BOOKMARK; + break; + default: + logger('Unknown object type '.$post->attachment->fb_object_type, LOGGER_DEBUG); + break; + } $content = ""; $type = ""; @@ -445,11 +446,11 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr if(isset($post->privacy) && $post->privacy->value !== '') { $postarray['private'] = 1; - $postarray['allow_cid'] = '<' . $self[0]['id'] . '>'; + $postarray['allow_cid'] = '<' . $uid . '>'; } $item = item_store($postarray); - logger('fbsync_createpost: User '.$self[0]["nick"].' posted feed item '.$item, LOGGER_DEBUG); + logger('fbsync_createpost: User ' . $uid . ' posted feed item '.$item, LOGGER_DEBUG); } function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $applications, $comment) { @@ -1094,11 +1095,13 @@ function fbsync_processfeed($data){ } unset($applications); + + //FIXME: Need $self, which is in the fetch_data function foreach ($posts AS $post) { if ($post->updated_time > $last_updated) $last_updated = $post->updated_time; - fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user); + fbsync_createpost($a, $uid, $contacts, $applications, $post, $create_user); } foreach ($comments AS $comment) {