X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=pumpio%2Fpumpio.php;h=86975e47774799e989fd6c4d68689eadd56f3e70;hb=d45b869d46a704ac16ae7bd10ab1e6e08a3f6ffd;hp=e9130dd4bc675c986ccf852bb055c1a393f6cb68;hpb=b8213b207a5073468df94341ed668ce6d7bb1683;p=friendica-addons.git
diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php
index e9130dd4..86975e47 100755
--- a/pumpio/pumpio.php
+++ b/pumpio/pumpio.php
@@ -218,8 +218,13 @@ function pumpio_settings(&$a,&$s) {
/* Add some HTML to the existing form */
- $s .= '
';
+ $s .= '';
$s .= '
' . t('Pump.io Post Settings') . '
';
+ $s .= '';
+ $s .= '
';
+ $s .= '';
+ $s .= '
' . t('Pump.io Post Settings') . '
';
+ $s .= '';
$s .= '
';
$s .= '';
@@ -278,7 +283,7 @@ function pumpio_settings(&$a,&$s) {
/* provide a submit button */
- $s .= '
';
+ $s .= '
';
}
@@ -316,6 +321,8 @@ function pumpio_settings_post(&$a,&$b) {
set_pconfig(local_user(),'pumpio','public',$_POST['pumpio_public']);
set_pconfig(local_user(),'pumpio','mirror',$_POST['pumpio_mirror']);
set_pconfig(local_user(),'pumpio','post_by_default',intval($_POST['pumpio_bydefault']));
+
+ header("Location: ".$a->get_baseurl()."/pumpio/connect");
}
}
}
@@ -351,7 +358,7 @@ function pumpio_send(&$a,&$b) {
return;
}
- logger("pumpio_send: parameter ".print_r($b, true));
+ logger("pumpio_send: parameter ".print_r($b, true), LOGGER_DATA);
if($b['parent'] != $b['id']) {
// Looking if its a reply to a pumpio post
@@ -482,7 +489,7 @@ function pumpio_send(&$a,&$b) {
logger('pumpio_send '.$username.': success '.$post_id);
if($post_id AND $iscomment) {
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
- q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1",
+ q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
dbesc($post_id),
intval($b['id'])
);
@@ -710,8 +717,13 @@ function pumpio_fetchtimeline(&$a, $uid) {
$_REQUEST["body"] = html2bbcode($post->object->content);
- if ($post->object->fullImage->url != "")
- $_REQUEST["body"] = "[url=".$post->object->fullImage->url."][img]".$post->object->image->url."[/img][/url]\n".$_REQUEST["body"];
+ // To-Do: Picture has to be cached and stored locally
+ if ($post->object->fullImage->url != "") {
+ if ($post->object->fullImage->pump_io->proxyURL != "")
+ $_REQUEST["body"] = "[url=".$post->object->fullImage->pump_io->proxyURL."][img]".$post->object->image->pump_io->proxyURL."[/img][/url]\n".$_REQUEST["body"];
+ else
+ $_REQUEST["body"] = "[url=".$post->object->fullImage->url."][img]".$post->object->image->url."[/img][/url]\n".$_REQUEST["body"];
+ }
logger('pumpio: posting for user '.$uid);
@@ -868,6 +880,22 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id) {
function pumpio_get_contact($uid, $contact) {
+ $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
+ dbesc(normalise_link($contact->url)));
+
+ if (count($r) == 0)
+ q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
+ dbesc(normalise_link($contact->url)),
+ dbesc($contact->displayName),
+ dbesc($contact->preferredUsername),
+ dbesc($contact->image->url));
+ else
+ q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
+ dbesc($contact->displayName),
+ dbesc($contact->preferredUsername),
+ dbesc($contact->image->url),
+ dbesc(normalise_link($contact->url)));
+
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
intval($uid), dbesc($contact->url));
@@ -923,7 +951,7 @@ function pumpio_get_contact($uid, $contact) {
`name-date` = '%s',
`uri-date` = '%s',
`avatar-date` = '%s'
- WHERE `id` = %d LIMIT 1
+ WHERE `id` = %d
",
dbesc($photos[0]),
dbesc($photos[1]),
@@ -950,8 +978,10 @@ function pumpio_get_contact($uid, $contact) {
`micro` = '%s',
`name-date` = '%s',
`uri-date` = '%s',
- `avatar-date` = '%s'
- WHERE `id` = %d LIMIT 1
+ `avatar-date` = '%s',
+ `name` = '%s',
+ `nick` = '%s'
+ WHERE `id` = %d
",
dbesc($photos[0]),
dbesc($photos[1]),
@@ -959,6 +989,8 @@ function pumpio_get_contact($uid, $contact) {
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
+ dbesc($contact->displayName),
+ dbesc($contact->preferredUsername),
intval($r[0]['id'])
);
}
@@ -1078,14 +1110,17 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
}
}
+ $reply = new stdClass;
$reply->verb = "note";
$reply->cc = $post->cc;
$reply->to = $post->to;
+ $reply->object = new stdClass;
$reply->object->objectType = $post->object->inReplyTo->objectType;
$reply->object->content = $post->object->inReplyTo->content;
$reply->object->id = $post->object->inReplyTo->id;
$reply->actor = $post->object->inReplyTo->author;
$reply->url = $post->object->inReplyTo->url;
+ $reply->generator = new stdClass;
$reply->generator->displayName = "pumpio";
$reply->published = $post->object->inReplyTo->published;
$reply->received = $post->object->inReplyTo->updated;
@@ -1124,10 +1159,17 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
}
if ($post->verb == "share") {
- $postarray['body'] = "[share author='".$post->object->author->displayName.
- "' profile='".$post->object->author->url.
- "' avatar='".$post->object->author->image->url.
- "' link='".$post->links->self->href."']".$postarray['body']."[/share]";
+ if (!intval(get_config('system','wall-to-wall_share'))) {
+ $postarray['body'] = "[share author='".$post->object->author->displayName.
+ "' profile='".$post->object->author->url.
+ "' avatar='".$post->object->author->image->url.
+ "' link='".$post->links->self->href."']".$postarray['body']."[/share]";
+ } else {
+ // Let shares look like wall-to-wall posts
+ $postarray['author-name'] = $post->object->author->displayName;
+ $postarray['author-link'] = $post->object->author->url;
+ $postarray['author-avatar'] = $post->object->author->image->url;
+ }
}
if (trim($postarray['body']) == "")
@@ -1238,13 +1280,16 @@ function pumpio_fetchinbox(&$a, $uid) {
$url .= '?since='.urlencode($last_id);
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
- $posts = array_reverse($user->items);
- if (count($posts))
- foreach ($posts as $post) {
- $last_id = $post->id;
- pumpio_dopost($a, $client, $uid, $self, $post, $own_id);
- }
+ if ($user->items) {
+ $posts = array_reverse($user->items);
+
+ if (count($posts))
+ foreach ($posts as $post) {
+ $last_id = $post->id;
+ pumpio_dopost($a, $client, $uid, $self, $post, $own_id);
+ }
+ }
set_pconfig($uid,'pumpio','last_id', $last_id);
}
@@ -1342,7 +1387,7 @@ function pumpio_queue_hook(&$a,&$b) {
logger('pumpio_queue: send '.$username.': success '.$post_id);
if($post_id AND $iscomment) {
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
- q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1",
+ q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
dbesc($post_id),
intval($z['item'])
);