]> git.mxchange.org Git - friendica-addons.git/commitdiff
Merge pull request #211 from tobiasd/20140622
authortobiasd <tobias.diekershoff@gmx.net>
Sat, 6 Sep 2014 21:27:31 +0000 (23:27 +0200)
committertobiasd <tobias.diekershoff@gmx.net>
Sat, 6 Sep 2014 21:27:31 +0000 (23:27 +0200)
get translations from transifex over here

25 files changed:
appnet/appnet.php
appnet/templates/admin.tpl [new file with mode: 0644]
buffer/buffer.php
convpath/convpath.php
editplain/editplain.php
fbpost/fbpost.php
fbsync/fbsync.php
fromgplus/fromgplus.php
gpluspost/.gitignore [new file with mode: 0644]
gpluspost/gpluspost.php
jappixmini/jappixmini.php
newmemberwidget/newmemberwidget.php
page/page.php
piwik.tgz
piwik/piwik.php
posterous/posterous.php
privacy_image_cache/privacy_image_cache.php
pumpio/pumpio.php
statusnet/codebird.php
statusnet/statusnet.php
tumblr/README
tumblr/templates/admin.tpl [new file with mode: 0644]
tumblr/tumblr.php
twitter/twitter.php
uhremotestorage/uhremotestorage.php

index d175ad589c0c27d610a39498aacedb5e5ed9162c..7e80c6abd2d9471aa3f31c6ece0d688f4e5526af 100644 (file)
@@ -8,7 +8,11 @@
  */
 
 /*
- Some marker in the post so that reimported posts can be treated better. (BBCode over app.net?)
+ To-Do:
+ - Use embedded pictures for the attachment information (large attachment)
+ - Sound links must be handled
+ - https://alpha.app.net/sr_rolando/post/32365203 - double pictures
+ - https://alpha.app.net/opendev/post/34396399 - location data
 */
 
 define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
@@ -20,6 +24,7 @@ function appnet_install() {
        register_hook('cron',                   'addon/appnet/appnet.php', 'appnet_cron');
        register_hook('connector_settings',     'addon/appnet/appnet.php', 'appnet_settings');
        register_hook('connector_settings_post','addon/appnet/appnet.php', 'appnet_settings_post');
+       register_hook('prepare_body',           'addon/appnet/appnet.php', 'appnet_prepare_body');
 }
 
 
@@ -28,8 +33,9 @@ function appnet_uninstall() {
        unregister_hook('notifier_normal',  'addon/appnet/appnet.php', 'appnet_send');
        unregister_hook('jot_networks',     'addon/appnet/appnet.php', 'appnet_jot_nets');
        unregister_hook('cron',                 'addon/appnet/appnet.php', 'appnet_cron');
-       unregister_hook('connector_settings',      'addon/appnet/appnet.php', 'appnet_settings');
+       unregister_hook('connector_settings',   'addon/appnet/appnet.php', 'appnet_settings');
        unregister_hook('connector_settings_post', 'addon/appnet/appnet.php', 'appnet_settings_post');
+       unregister_hook('prepare_body',         'addon/appnet/appnet.php', 'appnet_prepare_body');
 }
 
 function appnet_module() {}
@@ -58,11 +64,35 @@ function appnet_content(&$a) {
        return $o;
 }
 
+function appnet_plugin_admin(&$a, &$o){
+        $t = get_markup_template( "admin.tpl", "addon/appnet/" );
+
+        $o = replace_macros($t, array(
+                '$submit' => t('Save Settings'),
+                                                                // name, label, value, help, [extra values]
+                '$clientid' => array('clientid', t('Client ID'),  get_config('appnet', 'clientid' ), ''),
+                '$clientsecret' => array('clientsecret', t('Client Secret'),  get_config('appnet', 'clientsecret' ), ''),
+        ));
+}
+
+function appnet_plugin_admin_post(&$a){
+        $clientid     =       ((x($_POST,'clientid'))              ? notags(trim($_POST['clientid']))   : '');
+        $clientsecret =       ((x($_POST,'clientsecret'))   ? notags(trim($_POST['clientsecret'])): '');
+        set_config('appnet','clientid',$clientid);
+        set_config('appnet','clientsecret',$clientsecret);
+        info( t('Settings updated.'). EOL );
+}
+
 function appnet_connect(&$a) {
        require_once 'addon/appnet/AppDotNet.php';
 
-       $clientId     = get_pconfig(local_user(),'appnet','clientid');
-       $clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
+       $clientId     = get_config('appnet','clientid');
+       $clientSecret = get_config('appnet','clientsecret');
+
+       if (($clientId == "") OR ($clientSecret == "")) {
+               $clientId     = get_pconfig(local_user(),'appnet','clientid');
+               $clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
+       }
 
        $app = new AppDotNet($clientId, $clientSecret);
 
@@ -102,8 +132,14 @@ function appnet_settings(&$a,&$s) {
                return;
 
        $token = get_pconfig(local_user(),'appnet','token');
-       $app_clientId     = get_pconfig(local_user(),'appnet','clientid');
-       $app_clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
+
+       $app_clientId     = get_config('appnet','clientid');
+       $app_clientSecret = get_config('appnet','clientsecret');
+
+       if (($app_clientId == "") OR ($app_clientSecret == "")) {
+               $app_clientId     = get_pconfig(local_user(),'appnet','clientid');
+               $app_clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
+       }
 
        /* Add our stylesheet to the page so we can make our settings look nice */
        $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/appnet/appnet.css' . '" media="all" />' . "\r\n";
@@ -122,11 +158,11 @@ function appnet_settings(&$a,&$s) {
        $ownid =  get_pconfig(local_user(),'appnet','ownid');
 
        $s .= '<span id="settings_appnet_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_appnet_expanded\'); openClose(\'settings_appnet_inflated\');">';
-       $s .= '<img class="connector'.$css.'" src="images/appnet.png" /><h3 class="connector">'. t('App.net Export').'</h3>';
+       $s .= '<img class="connector'.$css.'" src="images/appnet.png" /><h3 class="connector">'. t('App.net Import/Export').'</h3>';
        $s .= '</span>';
        $s .= '<div id="settings_appnet_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_appnet_expanded\'); openClose(\'settings_appnet_inflated\');">';
-       $s .= '<img class="connector'.$css.'" src="images/appnet.png" /><h3 class="connector">'. t('App.net Export').'</h3>';
+       $s .= '<img class="connector'.$css.'" src="images/appnet.png" /><h3 class="connector">'. t('App.net Import/Export').'</h3>';
        $s .= '</span>';
 
        if ($token != "") {
@@ -158,7 +194,6 @@ function appnet_settings(&$a,&$s) {
                catch (AppDotNetException $e) {
                        $s .= t("<p>Error fetching user profile. Please clear the configuration and try again.</p>");
                }
-               //$s .= print_r($userdata, true);
 
        } elseif (($app_clientId == '') OR ($app_clientSecret == '')) {
                $s .= t("<p>You have two ways to connect to App.net.</p>");
@@ -167,11 +202,11 @@ function appnet_settings(&$a,&$s) {
                $s .= sprintf(t("Use '%s' as Redirect URI<p>"), $a->get_baseurl().'/appnet/connect');
                $s .= '<div id="appnet-clientid-wrapper">';
                $s .= '<label id="appnet-clientid-label" for="appnet-clientid">' . t('Client ID') . '</label>';
-               $s .= '<input id="appnet-clientid" type="text" name="clientid" value="'.$app_clientId.'" />';
+               $s .= '<input id="appnet-clientid" type="text" name="clientid" value="" />';
                $s .= '</div><div class="clear"></div>';
                $s .= '<div id="appnet-clientsecret-wrapper">';
                $s .= '<label id="appnet-clientsecret-label" for="appnet-clientsecret">' . t('Client Secret') . '</label>';
-               $s .= '<input id="appnet-clientsecret" type="text" name="clientsecret" value="'.$app_clientSecret.'" />';
+               $s .= '<input id="appnet-clientsecret" type="text" name="clientsecret" value="" />';
                $s .= '</div><div class="clear"></div>';
                $s .= "<hr />";
                $s .= t('<p>Second way: fetch a token at <a href="http://dev-lite.jonathonduerig.com/">http://dev-lite.jonathonduerig.com/</a>. ');
@@ -256,6 +291,105 @@ function appnet_post_local(&$a,&$b) {
        }
 }
 
+function appnet_create_entities($a, $b, $postdata) {
+       require_once("include/bbcode.php");
+       require_once("include/plaintext.php");
+
+       $bbcode = $b["body"];
+       $bbcode = bb_remove_share_information($bbcode, false, true);
+
+       // Change pure links in text to bbcode uris
+       $bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
+
+       $URLSearchString = "^\[\]";
+
+       $bbcode = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'#$2',$bbcode);
+       $bbcode = preg_replace("/@\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'@$2',$bbcode);
+       $bbcode = preg_replace("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$bbcode);
+       $bbcode = preg_replace("/\[video\](.*?)\[\/video\]/ism",'[url=$1]$1[/url]',$bbcode);
+       $bbcode = preg_replace("/\[youtube\]https?:\/\/(.*?)\[\/youtube\]/ism",'[url=https://$1]https://$1[/url]',$bbcode);
+       $bbcode = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
+                              '[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode);
+       $bbcode = preg_replace("/\[vimeo\]https?:\/\/(.*?)\[\/vimeo\]/ism",'[url=https://$1]https://$1[/url]',$bbcode);
+       $bbcode = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
+                               '[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode);
+       //$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode);
+
+       $bbcode = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $bbcode);
+
+
+       preg_match_all("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $bbcode, $urls, PREG_SET_ORDER);
+
+       $bbcode = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'$1',$bbcode);
+
+       $b["body"] = $bbcode;
+
+       // To-Do:
+       // Bilder
+       // https://alpha.app.net/heluecht/post/32424376
+       // https://alpha.app.net/heluecht/post/32424307
+
+       $plaintext = plaintext($a, $b, 0, false, 6);
+
+       $text = $plaintext["text"];
+
+       $start = 0;
+       $entities = array();
+
+       foreach ($urls AS $url) {
+               $lenurl = iconv_strlen($url[1], "UTF-8");
+               $len = iconv_strlen($url[2], "UTF-8");
+               $pos = iconv_strpos($text, $url[1], $start, "UTF-8");
+               $pre = iconv_substr($text, 0, $pos, "UTF-8");
+               $post = iconv_substr($text, $pos + $lenurl, 1000000, "UTF-8");
+
+               $mid = $url[2];
+               $html = bbcode($mid, false, false, 6);
+               $mid = html2plain($html, 0, true);
+
+               $mid = trim(html_entity_decode($mid,ENT_QUOTES,'UTF-8'));
+
+               $text = $pre.$mid.$post;
+
+               if ($mid != "")
+                       $entities[] = array("pos" => $pos, "len" => $len, "url" => $url[1], "text" => $mid);
+
+               $start = $pos + 1;
+       }
+
+       if (isset($postdata["url"]) AND isset($postdata["title"])) {
+               $postdata["title"] = shortenmsg($postdata["title"], 90);
+               $max = 256 - strlen($postdata["title"]);
+               $text = shortenmsg($text, $max);
+               $text .= "\n[".$postdata["title"]."](".$postdata["url"].")";
+       } elseif (isset($postdata["url"])) {
+               $postdata["url"] = short_link($postdata["url"]);
+               $max = 240;
+               $text = shortenmsg($text, $max);
+               $text .= " [".$postdata["url"]."](".$postdata["url"].")";
+       } else {
+               $max = 256;
+               $text = shortenmsg($text, $max);
+       }
+
+       if (iconv_strlen($text, "UTF-8") < $max)
+               $max = iconv_strlen($text, "UTF-8");
+
+       krsort($entities);
+       foreach ($entities AS $entity) {
+               //if (iconv_strlen($text, "UTF-8") >= $entity["pos"] + $entity["len"]) {
+               if (($entity["pos"] + $entity["len"]) <= $max) {
+                       $pre = iconv_substr($text, 0, $entity["pos"], "UTF-8");
+                       $post = iconv_substr($text, $entity["pos"] + $entity["len"], 1000000, "UTF-8");
+
+                       $text = $pre."[".$entity["text"]."](".$entity["url"].")".$post;
+               }
+       }
+
+
+       return($text);
+}
+
 function appnet_send(&$a,&$b) {
 
        logger('appnet_send: invoked for post '.$b['id']." ".$b['app']);
@@ -340,12 +474,12 @@ function appnet_send(&$a,&$b) {
                require_once("include/plaintext.php");
                require_once("include/network.php");
 
-               $post = plaintext($a, $b, 256, false);
+               $post = plaintext($a, $b, 256, false, 6);
                logger("appnet_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
 
                if (isset($post["image"])) {
                        $img_str = fetch_url($post['image'],true, $redirects, 10);
-                       $tempfile = tempnam(get_config("system","temppath"), "cache");
+                       $tempfile = tempnam(get_temppath(), "cache");
                        file_put_contents($tempfile, $img_str);
 
                        try {
@@ -362,7 +496,7 @@ function appnet_send(&$a,&$b) {
                                                                );
                        }
                        catch (AppDotNetException $e) {
-                               logger("appnet_send: Error creating file");
+                               logger("appnet_send: Error creating file ".appnet_error($e->getMessage()));
                        }
 
                        unlink($tempfile);
@@ -376,23 +510,20 @@ function appnet_send(&$a,&$b) {
                                                        );
 
                // Adding the original post
+               $attached_data = get_attached_data($b["body"]);
+               $attached_data["post-uri"] = $b["uri"];
+               $attached_data["post-title"] = $b["title"];
+               $attached_data["post-body"] = substr($b["body"], 0, 4000); // To-Do: Better shortening
+               $attached_data["post-tag"] = $b["tag"];
+               $attached_data["author-name"] = $b["author-name"];
+               $attached_data["author-link"] = $b["author-link"];
+               $attached_data["author-avatar"] = $b["author-avatar"];
+
                $data["annotations"][] = array(
                                                "type" => "com.friendica.post",
-                                               "value" => array(
-                                                               "uri" => $b["uri"],
-                                                               "title" => $b["title"],
-                                                               "body" => substr($b["body"], 0, 4000), // To-Do: Better shortening
-                                                               "tag" => $b["tag"],
-                                                               "author-name" => $b["author-name"],
-                                                               "author-link" => $b["author-link"],
-                                                               "author-avatar" => $b["author-avatar"],
-                                                               )
+                                               "value" => $attached_data
                                                );
 
-
-               // To-Do
-               // Alle Links verkürzen
-
                if (isset($post["url"]) AND !isset($post["title"])) {
                        $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $post["url"]);
                        $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
@@ -403,27 +534,17 @@ function appnet_send(&$a,&$b) {
                        $post["title"] = $display_url;
                }
 
-               if (isset($post["url"]) AND isset($post["title"])) {
-                       $post["title"] = shortenmsg($post["title"], 90);
-                       $post["text"] = shortenmsg($post["text"], 256 - strlen($post["title"]));
-                       $post["text"] .= "\n[".$post["title"]."](".$post["url"].")";
-               } elseif (isset($post["url"])) {
-                       $post["url"] = short_link($post["url"]);
-                       $post["text"] = shortenmsg($post["text"], 240);
-                       $post["text"] .= " ".$post["url"];
-               }
+               $text = appnet_create_entities($a, $b, $post);
 
-               //print_r($post);
-               $data["entities"]["parse_links"] = true;
                $data["entities"]["parse_markdown_links"] = true;
 
                if ($iscomment)
                        $data["reply_to"] = substr($orig_post["uri"], 5);
 
                try {
-                       $ret = $app->createPost($post["text"], $data);
+                       logger("appnet_send: sending message ".$b["id"]." ".$text." ".print_r($data, true), LOGGER_DEBUG);
+                       $ret = $app->createPost($text, $data);
                        logger("appnet_send: send message ".$b["id"]." result: ".print_r($ret, true), LOGGER_DEBUG);
-
                        if ($iscomment) {
                                logger('appnet_send: Update extid '.$ret["id"]." for post id ".$b['id']);
                                q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
@@ -433,7 +554,7 @@ function appnet_send(&$a,&$b) {
                        }
                }
                catch (AppDotNetException $e) {
-                       logger("appnet_send: Error sending message ".$b["id"]);
+                       logger("appnet_send: Error sending message ".$b["id"]." ".appnet_error($e->getMessage()));
                }
        }
 }
@@ -465,7 +586,7 @@ function appnet_action($a, $uid, $pid, $action) {
                logger("appnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
        }
        catch (AppDotNetException $e) {
-               logger("appnet_action: Error sending action ".$action." pid ".$pid, LOGGER_DEBUG);
+               logger("appnet_action: Error sending action ".$action." pid ".$pid." ".appnet_error($e->getMessage()), LOGGER_DEBUG);
        }
 }
 
@@ -516,7 +637,7 @@ function appnet_is_repost($a, $uid, $body) {
                return true;
        }
        catch (AppDotNetException $e) {
-               logger('appnet_is_repost: error doing repost', LOGGER_DEBUG);
+               logger('appnet_is_repost: error doing repost '.appnet_error($e->getMessage()), LOGGER_DEBUG);
                return false;
        }
 }
@@ -568,7 +689,7 @@ function appnet_fetchstream($a, $uid) {
                $stream = $app->getUserStream($param);
        }
        catch (AppDotNetException $e) {
-               logger("appnet_fetchstream: Error fetching stream for user ".$uid);
+               logger("appnet_fetchstream: Error fetching stream for user ".$uid." ".appnet_error($e->getMessage()));
        }
 
        $stream = array_reverse($stream);
@@ -595,7 +716,7 @@ function appnet_fetchstream($a, $uid) {
                                        'to_email'     => $user['email'],
                                        'uid'          => $user['uid'],
                                        'item'         => $postarray,
-                                       'link'         => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item,
+                                       'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
                                        'source_name'  => $postarray['author-name'],
                                        'source_link'  => $postarray['author-link'],
                                        'source_photo' => $postarray['author-avatar'],
@@ -622,24 +743,42 @@ function appnet_fetchstream($a, $uid) {
                $mentions = $app->getUserMentions("me", $param);
        }
        catch (AppDotNetException $e) {
-               logger("appnet_fetchstream: Error fetching mentions for user ".$uid);
+               logger("appnet_fetchstream: Error fetching mentions for user ".$uid." ".appnet_error($e->getMessage()));
        }
 
        $mentions = array_reverse($mentions);
        foreach ($mentions AS $post) {
                $postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, false);
 
-               if (isset($postarray["id"]))
+               if (isset($postarray["id"])) {
                        $item = $postarray["id"];
-               elseif (isset($postarray["body"])) {
+                       $parent_id = $postarray['parent'];
+               } elseif (isset($postarray["body"])) {
                        $item = item_store($postarray);
+                       $parent_id = 0;
                        logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
-               } else
+               } else {
                        $item = 0;
+                       $parent_id = 0;
+               }
+
+               // Fetch the parent and id
+               if (($parent_id == 0) AND ($postarray['uri'] != "")) {
+                       $r = q("SELECT `id`, `parent` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                               dbesc($postarray['uri']),
+                               intval($uid)
+                       );
+
+                       if (count($r)) {
+                               $item = $r[0]['id'];
+                               $parent_id = $r[0]['parent'];
+                       }
+               }
 
                $lastid = $post["id"];
 
-               if (($item != 0) AND ($postarray['contact-id'] != $me["id"])) {
+               //if (($item != 0) AND ($postarray['contact-id'] != $me["id"])) {
+               if ($item != 0) {
                        require_once('include/enotify.php');
                        notification(array(
                                'type'         => NOTIFY_TAGSELF,
@@ -649,12 +788,13 @@ function appnet_fetchstream($a, $uid) {
                                'to_email'     => $user['email'],
                                'uid'          => $user['uid'],
                                'item'         => $postarray,
-                               'link'         => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item,
+                               'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
                                'source_name'  => $postarray['author-name'],
                                'source_link'  => $postarray['author-link'],
                                'source_photo' => $postarray['author-avatar'],
                                'verb'         => ACTIVITY_TAG,
-                               'otype'        => 'item'
+                               'otype'        => 'item',
+                               'parent'       => $parent_id,
                        ));
                }
        }
@@ -670,7 +810,7 @@ function appnet_fetchstream($a, $uid) {
 */
 }
 
-function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true) {
+function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true, $nodupcheck = false) {
        require_once('include/items.php');
 
        if ($post["machine_only"])
@@ -685,35 +825,45 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
        $postarray['wall'] = 0;
        $postarray['verb'] = ACTIVITY_POST;
        $postarray['network'] =  dbesc(NETWORK_APPNET);
-       $postarray['uri'] = "adn::".$post["id"];
+       if (is_array($post["repost_of"])) {
+               // You can't reply to reposts. So use the original id and thread-id
+               $postarray['uri'] = "adn::".$post["repost_of"]["id"];
+               $postarray['parent-uri'] = "adn::".$post["repost_of"]["thread_id"];
+       } else {
+               $postarray['uri'] = "adn::".$post["id"];
+               $postarray['parent-uri'] = "adn::".$post["thread_id"];
+       }
 
-       $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
-               dbesc($postarray['uri']),
-               intval($uid)
-               );
+       if (!$nodupcheck) {
+               $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                       dbesc($postarray['uri']),
+                       intval($uid)
+                       );
 
-       if (count($r))
-               return($r[0]);
+               if (count($r))
+                       return($r[0]);
 
-       $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
-               dbesc($postarray['uri']),
-               intval($uid)
-               );
+               $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
+                       dbesc($postarray['uri']),
+                       intval($uid)
+                       );
 
-       if (count($r))
-               return($r[0]);
+               if (count($r))
+                       return($r[0]);
+       }
 
-       $postarray['parent-uri'] = "adn::".$post["thread_id"];
        if (isset($post["reply_to"]) AND ($post["reply_to"] != "")) {
                $postarray['thr-parent'] = "adn::".$post["reply_to"];
 
-               // Complete the thread if the parent doesn't exists
+               // Complete the thread (if the parent doesn't exists)
                if ($threadcompletion) {
-                       $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
-                               dbesc($postarray['thr-parent']),
-                               intval($uid)
-                               );
-                       if (!count($r)) {
+                       //$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+                       //      dbesc($postarray['thr-parent']),
+                       //      intval($uid)
+                       //      );
+                       //if (!count($r)) {
+                               logger("appnet_createpost: completing thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG);
+
                                require_once("addon/appnet/AppDotNet.php");
 
                                $token = get_pconfig($uid,'appnet','token');
@@ -729,19 +879,27 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
                                        $thread = $app->getPostReplies($post["thread_id"], $param);
                                }
                                catch (AppDotNetException $e) {
-                                       logger("appnet_createpost: Error fetching thread for user ".$uid);
+                                       logger("appnet_createpost: Error fetching thread for user ".$uid." ".appnet_error($e->getMessage()));
                                }
                                $thread = array_reverse($thread);
+
+                               logger("appnet_createpost: fetched ".count($thread)." items for thread ".$post["thread_id"]." for user ".$uid, LOGGER_DEBUG);
+
                                foreach ($thread AS $tpost) {
-                                       $threadpost = appnet_createpost($a, $uid, $tpost, $me, $user, $ownid, $createuser, false);
+                                       $threadpost = appnet_createpost($a, $uid, $tpost, $me, $user, $ownid, false, false);
                                        $item = item_store($threadpost);
+                                       logger("appnet_createpost: stored post ".$post["id"]." thread ".$post["thread_id"]." in item ".$item, LOGGER_DEBUG);
                                }
-                       }
+                       //}
                }
-       } else
-               $postarray['thr-parent'] = $postarray['uri'];
+               // Don't create accounts of people who just comment something
+               $createuser = false;
 
-       $postarray['plink'] = $post["canonical_url"];
+               $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
+       } else {
+               $postarray['thr-parent'] = $postarray['uri'];
+               $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+       }
 
        if (($post["user"]["id"] != $ownid) OR ($postarray['thr-parent'] == $postarray['uri'])) {
                $postarray['owner-name'] = $post["user"]["name"];
@@ -771,6 +929,8 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
                $content = $post;
        }
 
+       $postarray['plink'] = $content["canonical_url"];
+
        if (is_array($content["entities"])) {
                $converted = appnet_expand_entities($a, $content["text"], $content["entities"]);
                $postarray['body'] = $converted["body"];
@@ -778,16 +938,13 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
        } else
                $postarray['body'] = $content["text"];
 
-       if (is_array($content["annotations"]))
-               $postarray['body'] = appnet_expand_annotations($a, $postarray['body'], $content["annotations"]);
-
        if (sizeof($content["entities"]["links"]))
                foreach($content["entities"]["links"] AS $link) {
                        $url = normalise_link($link["url"]);
                        $links[$url] = $link["url"];
                }
 
-       if (sizeof($content["annotations"]))
+       /* if (sizeof($content["annotations"]))
                foreach($content["annotations"] AS $annotation) {
                        if ($annotation[type] == "net.app.core.oembed") {
                                if (isset($annotation["value"]["embeddable_url"])) {
@@ -796,15 +953,15 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
                                                unset($links[$url]);
                                }
                        } elseif ($annotation[type] == "com.friendica.post") {
-                               $links = array();
-                               if (isset($annotation["value"]["embeddable_url"]))
-                                       $postarray['title'] = $annotation["value"]["title"];
+                               //$links = array();
+                               //if (isset($annotation["value"]["post-title"]))
+                               //      $postarray['title'] = $annotation["value"]["post-title"];
 
-                               if (isset($annotation["value"]["body"]))
-                                       $postarray['body'] = $annotation["value"]["body"];
+                               //if (isset($annotation["value"]["post-body"]))
+                               //      $postarray['body'] = $annotation["value"]["post-body"];
 
-                               if (isset($annotation["value"]["tag"]))
-                                       $postarray['tag'] = $annotation["value"]["tag"];
+                               //if (isset($annotation["value"]["post-tag"]))
+                               //      $postarray['tag'] = $annotation["value"]["post-tag"];
 
                                if (isset($annotation["value"]["author-name"]))
                                        $postarray['author-name'] = $annotation["value"]["author-name"];
@@ -816,28 +973,44 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
                                        $postarray['author-avatar'] = $annotation["value"]["author-avatar"];
                        }
 
-               }
+               } */
+
+       $page_info = "";
+
+       if (is_array($content["annotations"])) {
+               $photo = appnet_expand_annotations($a, $content["annotations"]);
+               if (($photo["large"] != "") AND ($photo["url"] != ""))
+                       $page_info = "\n[url=".$photo["url"]."][img]".$photo["large"]."[/img][/url]";
+               elseif ($photo["url"] != "")
+                       $page_info = "\n[img]".$photo["url"]."[/img]";
+
+               if ($photo["url"] != "")
+                       $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
+
+       } else
+               $photo = array("url" => "", "large" => "");
 
        if (sizeof($links)) {
                $link = array_pop($links);
-               $url = "[url=".$link."]".$link."[/url]";
-
-               $removedlink = trim(str_replace($url, "", $postarray['body']));
+               $url = str_replace(array('/', '.'), array('\/', '\.'), $link);
 
-               if (($removedlink == "") OR strstr($postarray['body'], $removedlink))
-                       $postarray['body'] = $removedlink;
+               $page_info = add_page_info($link, false, $photo["url"]);
 
-               $postarray['body'] .= add_page_info($link);
+               if (trim($page_info) != "") {
+                       $removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']);
+                       if (($removedlink == "") OR strstr($postarray['body'], $removedlink))
+                               $postarray['body'] = $removedlink;
+               }
        }
 
+       $postarray['body'] .= $page_info;
+
        $postarray['created'] = datetime_convert('UTC','UTC',$post["created_at"]);
        $postarray['edited'] = datetime_convert('UTC','UTC',$post["created_at"]);
 
        $postarray['app'] = $post["source"]["name"];
 
        return($postarray);
-       //print_r($postarray);
-       //print_r($post);
 }
 
 function appnet_expand_entities($a, $body, $entities) {
@@ -866,7 +1039,10 @@ function appnet_expand_entities($a, $body, $entities) {
 
        foreach ($entities["links"] AS $links) {
                $url = "[url=".$links["url"]."]".$links["text"]."[/url]";
-               $replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["len"], "replace"=> $url);
+               if (isset($links["amended_len"]) AND ($links["amended_len"] > $links["len"]))
+                       $replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["amended_len"], "replace"=> $url);
+               else
+                       $replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["len"], "replace"=> $url);
        }
 
 
@@ -875,6 +1051,8 @@ function appnet_expand_entities($a, $body, $entities) {
                foreach ($replace AS $entity) {
                        $pre = substr_unicode($body, 0, $entity["pos"]);
                        $post = substr_unicode($body, $entity["pos"] + $entity["len"]);
+                       //$pre = iconv_substr($body, 0, $entity["pos"], "UTF-8");
+                       //$post = iconv_substr($body, $entity["pos"] + $entity["len"], "UTF-8");
 
                        $body = $pre.$entity["replace"].$post;
                }
@@ -883,16 +1061,24 @@ function appnet_expand_entities($a, $body, $entities) {
        return(array("body" => $body, "tags" => implode($tags_arr, ",")));
 }
 
-function appnet_expand_annotations($a, $body, $annotations) {
+function appnet_expand_annotations($a, $annotations) {
+       $photo = array("url" => "", "large" => "");
        foreach ($annotations AS $annotation) {
-               if ($annotation["value"]["type"] == "photo") {
-                       if (($annotation["value"]["thumbnail_large_url"] != "") AND ($annotation["value"]["url"] != ""))
-                               $body .= "\n[url=".$annotation["value"]["url"]."][img]".$annotation["value"]["thumbnail_large_url"]."[/img][/url]";
-                       elseif ($annotation["value"]["url"] != "")
-                               $body .= "\n[img]".$annotation["value"]["url"]."[/img]";
+               if (($annotation[type] == "net.app.core.oembed") AND
+                       ($annotation["value"]["type"] == "photo")) {
+                       if ($annotation["value"]["url"] != "")
+                               $photo["url"] = $annotation["value"]["url"];
+
+                       if ($annotation["value"]["thumbnail_large_url"] != "")
+                               $photo["large"] = $annotation["value"]["thumbnail_large_url"];
+
+                       //if (($annotation["value"]["thumbnail_large_url"] != "") AND ($annotation["value"]["url"] != ""))
+                       //      $embedded = "\n[url=".$annotation["value"]["url"]."][img]".$annotation["value"]["thumbnail_large_url"]."[/img][/url]";
+                       //elseif ($annotation["value"]["url"] != "")
+                       //      $embedded = "\n[img]".$annotation["value"]["url"]."[/img]";
                }
        }
-       return $body;
+       return $photo;
 }
 
 function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
@@ -900,8 +1086,10 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
                intval($uid), dbesc("adn::".$contact["id"]));
 
        if(!count($r) AND !$create_user)
-               return($me);
+               return($me["id"]);
 
+       if ($contact["canonical_url"] == "")
+               return($me["id"]);
 
        if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) {
                logger("appnet_fetchcontact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
@@ -909,6 +1097,13 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
        }
 
        if(!count($r)) {
+
+               if ($contact["name"] == "")
+                       $contact["name"] = $contact["username"];
+
+               if ($contact["username"] == "")
+                       $contact["username"] = $contact["name"];
+
                // create contact record
                q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
                                        `name`, `nick`, `photo`, `network`, `rel`, `priority`,
@@ -975,7 +1170,7 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
 
                //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false);
                $update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
-$update_photo = true;
+
                // check that we have all the photos, this has been known to fail on occasion
 
                if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
@@ -1017,6 +1212,43 @@ $update_photo = true;
        return($r[0]["id"]);
 }
 
+function appnet_prepare_body(&$a,&$b) {
+        if ($b["item"]["network"] != NETWORK_APPNET)
+                return;
+
+        if ($b["preview"]) {
+                $max_char = 256;
+                require_once("include/plaintext.php");
+                $item = $b["item"];
+                $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
+
+                $r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
+                        dbesc($item["thr-parent"]),
+                        intval(local_user()));
+
+                if(count($r)) {
+                        $orig_post = $r[0];
+
+                       $nicknameplain = preg_replace("=https?://alpha.app.net/(.*)=ism", "$1", $orig_post["author-link"]);
+                       $nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
+                       $nicknameplain = "@".$nicknameplain;
+
+                       if ((strpos($item["body"], $nickname) === false) AND (strpos($item["body"], $nicknameplain) === false))
+                               $item["body"] = $nickname." ".$item["body"];
+                }
+
+
+
+                $msgarr = plaintext($a, $item, $max_char, true);
+               $msg = appnet_create_entities($a, $item, $msgarr);
+
+               require_once("library/markdown.php");
+               $msg = Markdown($msg);
+
+                $b['html'] = $msg;
+        }
+}
+
 function appnet_cron($a,$b) {
        $last = get_config('appnet','last_poll');
 
@@ -1045,3 +1277,23 @@ function appnet_cron($a,$b) {
 
        set_config('appnet','last_poll', time());
 }
+
+function appnet_error($msg) {
+        $msg = trim($msg);
+        $pos = strrpos($msg, "\r\n\r\n");
+
+        if (!$pos)
+                return($msg);
+
+        $msg = substr($msg, $pos + 4);
+
+        $error = json_decode($msg);
+
+        if ($error == NULL)
+                return($msg);
+
+       if (isset($error->meta->error_message))
+               return($error->meta->error_message);
+        else
+                return(print_r($error));
+}
diff --git a/appnet/templates/admin.tpl b/appnet/templates/admin.tpl
new file mode 100644 (file)
index 0000000..a933f3d
--- /dev/null
@@ -0,0 +1,3 @@
+{{include file="field_input.tpl" field=$clientid}}
+{{include file="field_input.tpl" field=$clientsecret}}
+<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
index 4b81fb31a82c94369d264bab9f3a705467a97728..595dba43d9fcce41ab84bf9d63e8e5416e98280b 100644 (file)
@@ -60,6 +60,13 @@ function buffer_plugin_admin(&$a, &$o){
                '$client_secret' => array('client_secret', t('Client Secret'),  get_config('buffer', 'client_secret' ), ''),
        ));
 }
+function buffer_plugin_admin_post(&$a){
+        $client_id     =       ((x($_POST,'client_id'))              ? notags(trim($_POST['client_id']))   : '');
+        $client_secret =       ((x($_POST,'client_secret'))   ? notags(trim($_POST['client_secret'])): '');
+        set_config('buffer','client_id',$client_id);
+        set_config('buffer','client_secret',$client_secret);
+        info( t('Settings updated.'). EOL );
+}
 
 function buffer_connect(&$a) {
 
@@ -246,9 +253,6 @@ function buffer_send(&$a,&$b) {
        if($access_token) {
                $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token);
 
-               $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'privacy_image_cache' AND `installed`");
-               $image_cache = (count($result) > 0);
-
                require_once("include/plaintext.php");
                require_once("include/network.php");
 
@@ -301,15 +305,13 @@ function buffer_send(&$a,&$b) {
                                $post = plaintext($a, $item, $limit, $includedlinks);
                                logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
 
-                               // The image cache is used as a sanitizer. Buffer seems to be really picky about pictures
-                               if ($image_cache) {
-                                       require_once("addon/privacy_image_cache/privacy_image_cache.php");
-                                       if (isset($post["image"]))
-                                               $post["image"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($post["image"]);
+                               // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures
+                               require_once("mod/proxy.php");
+                               if (isset($post["image"]))
+                                       $post["image"] = proxy_url($post["image"]);
 
-                                       if (isset($post["preview"]))
-                                               $post["preview"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($post["preview"]);
-                               }
+                               if (isset($post["preview"]))
+                                       $post["preview"] = proxy_url($post["preview"]);
 
                                //if ($profile->service == "twitter") {
                                if ($includedlinks) {
index 9509369420fc4fbbcb5f18c0060dccd8c7587749..8deb46cf346cbc09c6a2e979f28b3476f8ed258f 100644 (file)
@@ -34,7 +34,8 @@ function convpath_page_header(&$a, &$o){
 
 function convpath_page_end(&$a, &$o){
        $o = convpath_convert($o);
-       $a->page['aside'] = convpath_convert($a->page['aside']);
+       if (isset($a->page['aside']))
+               $a->page['aside'] = convpath_convert($a->page['aside']);
 }
 
 function convpath_prepare_body_hook(&$a, &$o) {
index caa0f29d4c16c644a6502f32535422b600676e81..3aa2149153be6ed1151a1fa9f510ab61cc1b3a59 100755 (executable)
@@ -4,7 +4,7 @@
  * Description: This addon is deprecated and has been replaced with the "Advanced Features" setting.  Admins should remove this addon when their core code is updated to include advanced feature settings.
  * Version: 1.0
  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
- * 
+ * Status: Unsupported
  *
  */
 
index b554453fa7d498bc7200757199dc074e0c0f545f..2ac558ea8def501329e32c1b58dafceffebadb4f 100644 (file)
@@ -34,6 +34,7 @@ function fbpost_install() {
        register_hook('enotify',          'addon/fbpost/fbpost.php', 'fbpost_enotify');
        register_hook('queue_predeliver', 'addon/fbpost/fbpost.php', 'fbpost_queue_hook');
        register_hook('cron',             'addon/fbpost/fbpost.php', 'fbpost_cron');
+       register_hook('prepare_body',     'addon/fbpost/fbpost.php', 'fbpost_prepare_body');
 }
 
 
@@ -45,6 +46,7 @@ function fbpost_uninstall() {
        unregister_hook('enotify',          'addon/fbpost/fbpost.php', 'fbpost_enotify');
        unregister_hook('queue_predeliver', 'addon/fbpost/fbpost.php', 'fbpost_queue_hook');
        unregister_hook('cron',             'addon/fbpost/fbpost.php', 'fbpost_cron');
+       unregister_hook('prepare_body',     'addon/fbpost/fbpost.php', 'fbpost_prepare_body');
 }
 
 
@@ -562,12 +564,14 @@ function fbpost_post_hook(&$a,&$b) {
 
                                if ($toplevel) {
                                        require_once("include/plaintext.php");
-                                       $msgarr = plaintext($a, $b, 0, false);
+                                       $msgarr = plaintext($a, $b, 0, false, 9);
                                        $msg = $msgarr["text"];
                                        $link = $msgarr["url"];
-                                       $image = $msgarr["image"];
                                        $linkname = $msgarr["title"];
 
+                                       if ($msgarr["type"] != "video")
+                                               $image = $msgarr["image"];
+
                                        // Fallback - if message is empty
                                        if(!strlen($msg))
                                                $msg = $linkname;
@@ -917,6 +921,23 @@ function fbpost_get_app_access_token() {
        }
 }
 
+function fbpost_prepare_body(&$a,&$b) {
+        if ($b["item"]["network"] != NETWORK_FACEBOOK)
+                return;
+
+        if ($b["preview"]) {
+                $msg = $b["item"]["body"];
+
+               require_once("include/bbcode.php");
+               require_once("include/html2plain.php");
+               $msg = bb_CleanPictureLinks($msg);
+               $msg = bbcode($msg, false, false, 2, true);
+               $msg = trim(html2plain($msg, 0));
+
+                $b['html'] = nl2br(htmlspecialchars($msg));
+        }
+}
+
 function fbpost_cron($a,$b) {
        $last = get_config('facebook','last_poll');
 
@@ -1011,6 +1032,13 @@ function fbpost_fetchwall($a, $uid) {
                        $oembed_data = oembed_fetch_url($item->link);
                        $type = $oembed_data->type;
                        $content = "[bookmark=".$item->link."]".$item->name."[/bookmark]";
+
+                       // If a link is not only attached but also added in the body, look if it can be removed in the body.
+                       $removedlink = trim(str_replace($item->link, "", $_REQUEST["body"]));
+
+                       if (($removedlink == "") OR strstr($_REQUEST["body"], $removedlink))
+                               $_REQUEST["body"] = $removedlink;
+
                } elseif (isset($item->name))
                        $content .= "[b]".$item->name."[/b]";
 
@@ -1029,11 +1057,25 @@ function fbpost_fetchwall($a, $uid) {
 
                        $type = $item->type;
 
-                       if(isset($item->picture) && isset($item->link))
-                               $content .= "\n".'[url='.$item->link.'][img]'.fpost_cleanpicture($item->picture).'[/img][/url]';
+                       if (isset($item->picture))
+                               $picture = $item->picture;
+
+                       if (($type == "photo") AND isset($item->object_id)) {
+                                logger('fbpost_fetchwall: fetching fbid '.$item->object_id, LOGGER_DEBUG);
+                               $url = "https://graph.facebook.com/".$item->object_id."?access_token=".$access_token;
+                               $feed = fetch_url($url);
+                               $data = json_decode($feed);
+                               if (isset($data->images)) {
+                                       $picture = $data->images[0]->source;
+                                       logger('fbpost_fetchwall: got fbid image '.$preview, LOGGER_DEBUG);
+                               }
+                       }
+
+                       if(($picture != "") && isset($item->link))
+                               $content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]';
                        else {
-                               if (isset($item->picture))
-                                       $content .= "\n".'[img]'.fpost_cleanpicture($item->picture).'[/img]';
+                               if ($picture != "")
+                                       $content .= "\n".'[img]'.$picture.'[/img]';
                                // if just a link, it may be a wall photo - check
                                if(isset($item->link))
                                        $content .= fbpost_get_photo($uid,$item->link);
@@ -1104,7 +1146,7 @@ function fbpost_get_photo($uid,$link) {
        $x = fetch_url('https://graph.facebook.com/'.$photo_id.'?access_token='.$access_token);
        $j = json_decode($x);
        if($j->picture)
-               return "\n\n".'[url='.$link.'][img]'.fpost_cleanpicture($j->picture).'[/img][/url]';
+               return "\n\n".'[url='.$link.'][img]'.$j->picture.'[/img][/url]';
 
        return "";
 }
index 858591519b32fd9bd801ee71437394da5e1ecd4a..51d2747f93d8640570032d8eda81f575c796b412 100644 (file)
@@ -213,6 +213,8 @@ function fbsync_expire($a,$b) {
 
 function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) {
 
+       $access_token = get_pconfig($uid,'facebook','access_token');
+
        require_once("include/oembed.php");
 
        // check if it was already imported
@@ -229,6 +231,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
        $postarray['wall'] = 0;
 
        $postarray['verb'] = ACTIVITY_POST;
+       $postarray['object-type'] = ACTIVITY_OBJ_NOTE; // default value - is maybe changed later when media is attached
        $postarray['network'] =  dbesc(NETWORK_FACEBOOK);
 
        $postarray['uri'] = "fb::".$post->post_id;
@@ -278,7 +281,19 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
        }
 
        if ($contact_id <= 0) {
-               $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], $create_user);
+               if ($post->actor_id != $post->source_id) {
+                       // Testing if we know the source or the actor
+                       $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], false);
+
+                       if (($contact_id == 0) and array_key_exists($post->actor_id, $contacts))
+                               $contact_id = fbsync_fetch_contact($uid, $contacts[$post->actor_id], false);
+
+                       // If we don't know anyone, we guess we should know the source. Could be the wrong decision
+                       if ($contact_id == 0)
+                               $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], $create_user);
+               } else
+                       $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], $create_user);
+
 
                if ($contact_id == -1) {
                        logger('fbsync_createpost: Contact is blocked. Post not imported '.print_r($post, true), LOGGER_DEBUG);
@@ -302,6 +317,24 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
        $postarray["body"] = $msgdata["body"];
        $postarray["tag"] = $msgdata["tags"];
 
+       // 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;
+               }
+
        $content = "";
        $type = "";
 
@@ -312,47 +345,68 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
                        $type = "link";
 
                $content = "[bookmark=".$post->attachment->href."]".$post->attachment->name."[/bookmark]";
+
+               // If a link is not only attached but also added in the body, look if it can be removed in the body.
+               $removedlink = trim(str_replace($post->attachment->href, "", $postarray["body"]));
+
+               if (($removedlink == "") OR strstr($postarray["body"], $removedlink))
+                       $postarray["body"] = $removedlink;
+
        } elseif (isset($post->attachment->name) AND ($post->attachment->name != ""))
                $content = "[b]" . $post->attachment->name."[/b]";
 
        $quote = "";
-       if(isset($post->attachment->description) and ($post->attachment->fb_object_type != "photo"))
+       if (isset($post->attachment->description) and ($post->attachment->fb_object_type != "photo"))
                $quote = $post->attachment->description;
 
-       if(isset($post->attachment->caption) and ($post->attachment->fb_object_type == "photo"))
+       if (isset($post->attachment->caption) and ($post->attachment->fb_object_type == "photo"))
                $quote = $post->attachment->caption;
 
        if ($quote.$post->attachment->href.$content.$postarray["body"] == "")
                return;
 
-       if (isset($post->attachment->media) // AND !strstr($post->attachment->href, "://www.youtube.com/")
-               //AND !strstr($post->attachment->href, "://youtu.be/")
-               //AND !strstr($post->attachment->href, ".vimeo.com/"))
-               AND (($type == "") OR ($type == "link"))) {
+       if (isset($post->attachment->media) AND (($type == "") OR ($type == "link"))) {
                foreach ($post->attachment->media AS $media) {
-                       //$media->photo->owner = number_format($media->photo->owner, 0, '', '');
-                       //if ($media->photo->owner != '') {
-                       //      $postarray['author-name'] = $contacts[$media->photo->owner]->name;
-                       //      $postarray['author-link'] = $contacts[$media->photo->owner]->url;
-                       //      $postarray['author-avatar'] = $contacts[$media->photo->owner]->pic_square;
-                       //}
 
                        if (isset($media->type))
                                $type = $media->type;
 
-                       if(isset($media->src) && isset($media->href) AND ($media->src != "") AND ($media->href != ""))
-                               $content .= "\n".'[url='.$media->href.'][img]'.fpost_cleanpicture($media->src).'[/img][/url]';
+                       if (isset($media->src))
+                               $preview = $media->src;
+
+                       if (isset($media->photo)) {
+                               if (isset($media->photo->images) AND (count($media->photo->images) > 1))
+                                       $preview = $media->photo->images[1]->src;
+
+                               if (isset($media->photo->fbid)) {
+                                       logger('fbsync_createpost: fetching fbid '.$media->photo->fbid, LOGGER_DEBUG);
+                                       $url = "https://graph.facebook.com/".$media->photo->fbid."?access_token=".$access_token;
+                                       $feed = fetch_url($url);
+                                       $data = json_decode($feed);
+                                       if (isset($data->images)) {
+                                               $preview = $data->images[0]->source;
+                                               logger('fbsync_createpost: got fbid '.$media->photo->fbid.' image '.$preview, LOGGER_DEBUG);
+                                       } else
+                                               logger('fbsync_createpost: error fetching fbid '.$media->photo->fbid.' '.print_r($data, true), LOGGER_DEBUG);
+                               }
+                       }
+
+                       if (isset($media->href) AND ($preview != "") AND ($media->href != ""))
+                               $content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]';
                        else {
-                               if (isset($media->src) AND ($media->src != ""))
-                                       $content .= "\n".'[img]'.fpost_cleanpicture($media->src).'[/img]';
+                               if ($preview != "")
+                                       $content .= "\n".'[img]'.$preview.'[/img]';
 
                                // if just a link, it may be a wall photo - check
-                               if(isset($post->link))
+                               if (isset($post->link))
                                        $content .= fbpost_get_photo($media->href);
                        }
                }
        }
 
+       if ($type == "link")
+               $postarray["object-type"] = ACTIVITY_OBJ_BOOKMARK;
+
        if ($content)
                $postarray["body"] .= "\n";
 
@@ -478,6 +532,7 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
        $postarray['wall'] = 0;
 
        $postarray['verb'] = ACTIVITY_POST;
+       $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
        $postarray['network'] =  dbesc(NETWORK_FACEBOOK);
 
        $postarray['uri'] = "fb::".$comment->id;
@@ -577,7 +632,7 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
                                        'to_email'     => $user[0]['email'],
                                        'uid'          => $user[0]['uid'],
                                        'item'         => $postarray,
-                                       'link'             => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $item,
+                                       'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
                                        'source_name'  => $postarray['author-name'],
                                        'source_link'  => $postarray['author-link'],
                                        'source_photo' => $postarray['author-avatar'],
@@ -629,8 +684,11 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
 
        $likedata = array();
        $likedata['parent'] = $orig_post['id'];
+
        $likedata['verb'] = ACTIVITY_LIKE;
+       $likedata['object-type'] = ACTIVITY_OBJ_NOTE;
        $likedate['network'] =  dbesc(NETWORK_FACEBOOK);
+
        $likedata['gravity'] = 3;
        $likedata['uid'] = $uid;
        $likedata['wall'] = 0;
@@ -680,6 +738,9 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
 
 function fbsync_fetch_contact($uid, $contact, $create_user) {
 
+       if($contact->url == "")
+               return(0);
+
        // Check if the unique contact is existing
        // To-Do: only update once a while
        $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
index 5c7e1e2877f7d1db6b56c8fac7935994f0a05a31..9699ba9b32d8c3059297a0564138f1c0a2021167 100644 (file)
@@ -195,14 +195,15 @@ function fromgplus_parse_query($var)
 }
 
 function fromgplus_cleanupgoogleproxy($fullImage, $image) {
+       //$preview = "/w".$fullImage->width."-h".$fullImage->height."/";
+       //$preview2 = "/w".$fullImage->width."-h".$fullImage->height."-p/";
+       //$fullImage = str_replace(array($preview, $preview2), array("/", "/"), $fullImage->url);
+       $fullImage = $fullImage->url;
 
-       $preview = "/w".$fullImage->width."-h".$fullImage->height."/";
-       $preview2 = "/w".$fullImage->width."-h".$fullImage->height."-p/";
-       $fullImage = str_replace(array($preview, $preview2), array("/", "/"), $fullImage->url);
-
-       $preview = "/w".$image->width."-h".$image->height."/";
-       $preview2 = "/w".$image->width."-h".$image->height."-p/";
-       $image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
+       //$preview = "/w".$image->width."-h".$image->height."/";
+       //$preview2 = "/w".$image->width."-h".$image->height."-p/";
+       //$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
+       $image = $image->url;
 
                $cleaned = array();
 
@@ -227,7 +228,23 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
                $cleaned["preview"] = "";
        }
 
-       if ($cleaned["full"] == $cleaned["preview"])
+       if ($cleaned["full"] != "")
+               $infoFull = get_photo_info($cleaned["full"]);
+       else
+               $infoFull = array("0" => 0, "1" => 0);
+
+       if ($cleaned["preview"] != "")
+               $infoPreview = get_photo_info($cleaned["preview"]);
+       else
+               $infoFull = array("0" => 0, "1" => 0);
+
+       if (($infoPreview[0] >= $infoFull[0]) AND ($infoPreview[1] >= $infoFull[1])) {
+               $temp = $cleaned["full"];
+               $cleaned["full"] = $cleaned["preview"];
+               $cleaned["preview"] = $temp;
+       }
+
+       if (($cleaned["full"] == $cleaned["preview"]) OR (($infoPreview[0] == $infoFull[0]) AND ($infoPreview[1] == $infoFull[1])))
                $cleaned["preview"] = "";
 
        if ($cleaned["full"] == "")
@@ -236,7 +253,10 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
 
        if ($cleaned["full"] == "")
                if (@exif_imagetype($image) != 0)
-                       $cleaned["full"] = $fullImage;
+                       $cleaned["full"] = $image;
+
+       // Could be changed in the future to a link to the album
+       $cleaned["page"] = $cleaned["full"];
 
        return($cleaned);
 }
@@ -253,7 +273,9 @@ function fromgplus_cleantext($text) {
        return($text);
 }
 
-function fromgplus_handleattachments($item, $displaytext) {
+function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
+       require_once("include/Photo.php");
+
        $post = "";
        $quote = "";
        $type = "";
@@ -279,9 +301,18 @@ function fromgplus_handleattachments($item, $displaytext) {
                                break;
 
                        case "photo":
-                               $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
+                               // Don't store shared pictures in your wall photos (to prevent a possible violating of licenses)
+                               if ($shared)
+                                       $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
+                               else {
+                                       if ($attachment->fullImage->url != "")
+                                               $images = store_photo($a, $uid, "", $attachment->fullImage->url);
+                                       elseif ($attachment->image->url != "")
+                                               $images = store_photo($a, $uid, "", $attachment->image->url);
+                               }
+
                                if ($images["preview"] != "")
-                                       $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
+                                       $post .= "\n[url=".$images["page"]."][img]".$images["preview"]."[/img][/url]\n";
                                elseif ($images["full"] != "")
                                        $post .= "\n[img]".$images["full"]."[/img]\n";
 
@@ -360,6 +391,12 @@ function fromgplus_fetch($a, $uid) {
                if (strtotime($item->published) <= $initiallastdate)
                        continue;
 
+               // Don't publish items that are too young
+               if (strtotime($item->published) > (time() - 3*60)) {
+                       logger('fromgplus_fetch: item too new '.$item->published);
+                       continue;
+               }
+
                if ($lastdate < strtotime($item->published))
                        $lastdate = strtotime($item->published);
 
@@ -381,7 +418,7 @@ function fromgplus_fetch($a, $uid) {
                                        $post = fromgplus_html2bbcode($item->object->content);
 
                                        if (is_array($item->object->attachments))
-                                               $post .= fromgplus_handleattachments($item, $item->object->content);
+                                               $post .= fromgplus_handleattachments($a, $uid, $item, $item->object->content, false);
 
                                        // geocode, placeName
                                        if (isset($item->address))
@@ -406,7 +443,7 @@ function fromgplus_fetch($a, $uid) {
                                                $post .= fromgplus_html2bbcode($item->object->content);
 
                                                if (is_array($item->object->attachments))
-                                                       $post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
+                                                       $post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
 
                                                $post .= "[/share]";
                                        } else {
@@ -415,7 +452,7 @@ function fromgplus_fetch($a, $uid) {
                                                $post .= fromgplus_html2bbcode($item->object->content);
 
                                                if (is_array($item->object->attachments))
-                                                       $post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
+                                                       $post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
                                        }
 
                                        if (isset($item->address))
@@ -431,22 +468,3 @@ function fromgplus_fetch($a, $uid) {
        if ($lastdate != 0)
                set_pconfig($uid,'fromgplus','lastdate', $lastdate);
 }
-
-/*
-// Test
-require_once("boot.php");
-
-if(@is_null($a)) {
-        $a = new App;
-}
-
-if(@is_null($db)) {
-        @include(".htconfig.php");
-        require_once("include/dba.php");
-        $db = new dba($db_host, $db_user, $db_pass, $db_data);
-        unset($db_host, $db_user, $db_pass, $db_data);
-};
-
-$test = array();
-fromgplus_cron($a, $test);
-*/
diff --git a/gpluspost/.gitignore b/gpluspost/.gitignore
new file mode 100644 (file)
index 0000000..4e76a24
--- /dev/null
@@ -0,0 +1,2 @@
+postToGooglePlus.php
+nxs-http.php
index 415e031b2629780a43f5cf75bfcae567922cd052..5b2b3bf6ee45e4a924fe381e54cb9037f88003d3 100644 (file)
@@ -233,24 +233,25 @@ function gpluspost_send(&$a,&$b) {
        if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') and ($b['app'] == "Google+"))
                return;
 
-       // Always do the export via RSS-Feed (even if NextScripts is enabled), since it doesn't hurt
-       $itemlist = get_pconfig($b["uid"],'gpluspost','itemlist');
-       $items = explode(",", $itemlist);
+       if (!gpluspost_nextscripts()) {
+               // Posting via RSS-Feed and Hootsuite
+               $itemlist = get_pconfig($b["uid"],'gpluspost','itemlist');
+               $items = explode(",", $itemlist);
 
-       $i = 0;
-       $newitems = array($b['id']);
-       foreach ($items AS $item)
-               if ($i++ < 9)
-                       $newitems[] = $item;
+               $i = 0;
+               $newitems = array($b['id']);
+               foreach ($items AS $item)
+                       if ($i++ < 9)
+                               $newitems[] = $item;
 
-       $itemlist = implode(",", $newitems);
+               $itemlist = implode(",", $newitems);
 
-       logger('gpluspost_send: new itemlist: '.$itemlist." for uid ".$b["uid"]);
+               logger('gpluspost_send: new itemlist: '.$itemlist." for uid ".$b["uid"]);
 
-       set_pconfig($b["uid"],'gpluspost','itemlist', $itemlist);
+               set_pconfig($b["uid"],'gpluspost','itemlist', $itemlist);
 
-       // Posting via NextScripts
-       if (gpluspost_nextscripts()) {
+       } else {
+               // Posting via NextScripts
                $username = get_pconfig($b['uid'],'gpluspost','username');
                $password = get_pconfig($b['uid'],'gpluspost','password');
                $page = get_pconfig($b['uid'],'gpluspost','page');
@@ -271,7 +272,7 @@ function gpluspost_send(&$a,&$b) {
                        $item["body"] = preg_replace("(\[i\](.*?)\[\/i\])ism",'_$1_',$item["body"]);
                        $item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]);
 
-                       $data = plaintext($a, $item, 0, false);
+                       $data = plaintext($a, $item, 0, false, 9);
 
                        logger('gpluspost_send: data: '.print_r($data, true), LOGGER_DEBUG);
 
index f998acd13646a3f3937f50a474d289ae94d0db26..73062aae2050caa9d0a6d027083955e38883b2cf 100644 (file)
@@ -485,7 +485,8 @@ function jappixmini_script(&$a,&$s) {
                dbesc($dfrn_id),
                dbesc($dfrn_id)
        );
-       $name = $r[0]["name"];
+       if (count($r))
+               $name = $r[0]["name"];
 
         $value = $row['v'];
         $pos = strpos($value, ":");
index 59e102af8f25c76d66f92b0945baa04c9a52e32f..437b47b1d2b2cc8fdd7dff7bfba441fc7a345f40 100644 (file)
@@ -51,7 +51,7 @@ function newmemberwidget_plugin_admin(&$a, &$o){
        '$submit' => t('Save Settings'),
        '$freetext' => array( "freetext", t("Message"), get_config( "newmemberwidget", "freetext" ), t("Your message for new members. You can use bbcode here.")),
        '$linkglobalsupport' => array( "linkglobalsupport", t('Add a link to global support forum'), get_config( 'newmemberwidget', 'linkglobalsupport'), t('Should a link to the global support forum be displayed?')." (<a href='https://helpers.pyxis.uberspace.de/profile/helpers'>@helpers</a>)"),
-       '$linklocalsupport' => array( "linklocalsupport", t('Add a link to the local support forum'), get_config( 'newmemberwidget', 'linklocalsupport'), t('If you have a local support forum and wand to have a link displayed in the widget, check this box.')),
+       '$linklocalsupport' => array( "linklocalsupport", t('Add a link to the local support forum'), get_config( 'newmemberwidget', 'linklocalsupport'), t('If you have a local support forum and want to have a link displayed in the widget, check this box.')),
        '$localsupportname' => array( "localsupportname", t('Name of the local support group'), get_config( 'newmemberwidget', 'localsupport'), t('If you checked the above, specify the <em>nickname</em> of the local support group here (i.e. helpers)')),
     ));
 }
index e1ca90703fd3374f6eee689c696c10bb2814a2ad..f81b011431bd268713a2b9da309e11508259dc4b 100755 (executable)
@@ -6,6 +6,7 @@
  * Author: Mike Macgirvin <mike@macgirvin.com>
  * based on pages plugin by
  * Author: Michael Vogel <ike@piratenpartei.de>
+ * Status: Unsupported
  *
  */
 
index aaaf43758066a539b8e9241df5ae8c176b0a5081..4099e2de1931ec72fceffb1c7713f5bc1e97911a 100755 (executable)
Binary files a/piwik.tgz and b/piwik.tgz differ
index 21bc7af204940dd63b6e678325752bf77cba38e1..7a1cb5813776a001100e333a31122f2db2f1f42b 100755 (executable)
@@ -2,7 +2,7 @@
 /**
  * Name: Piwik Analytics
  * Description: Piwik Analytics Plugin for Friendica
- * Version: 1.1
+ * Version: 1.2
  * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
  * Author: Klaus Weidenbach
  */
@@ -15,7 +15,9 @@
  *   License: 3-clause BSD license
  *
  *   Configuration:
- *     Add the following lines to your .htconfig.php file:
+ *     Use the administration panel to configure the Piwik tracking addon, or
+ *     in case you don't use this add the following lines to your .htconfig.php
+ *     file:
  *
  *     $a->config['piwik']['baseurl'] = 'www.example.com/piwik/';
  *     $a->config['piwik']['siteid'] = '1';
@@ -62,10 +64,10 @@ function piwik_analytics($a,&$b) {
         *   If async is set to true use asynchronous tracking
         */
        if ($async) {
-         $a->page['htmlhead'] .= "<!-- Piwik --> <script type=\"text/javascript\">\r\nvar _paq = _paq || [];\r\n(function(){ var u=((\"https:\" == document.location.protocol) ? \"https://".$baseurl."\" : \"http://".$baseurl."\");\r\n_paq.push(['setSiteId', ".$siteid."]);\r\n_paq.push(['setTrackerUrl', u+'piwik.php']);\r\n_paq.push(['trackPageView']);\r\n_paq.push(['enableLinkTracking']);\r\nvar d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';\r\ng.defer=true; g.async=true; g.src=u+'piwik.js';\r\ns.parentNode.insertBefore(g,s); })();\r\n </script>\r\n<!-- End Piwik Code -->\r\n";
+         $b .= "<!-- Piwik --> <script type=\"text/javascript\"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://".$baseurl."\"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', ".$siteid."]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Piwik Code -->\r\n";
          $b .= "<div id='piwik-code-block'> <!-- Piwik -->\r\n<noscript><p><img src=\"//".$baseurl."piwik.php?idsite=".$siteid."\" style=\"border:0\" alt=\"\" /></p></noscript>\r\n <!-- End Piwik Tracking Tag --> </div>";
        } else {
-               $b .= "<div id='piwik-code-block'> <!-- Piwik -->\r\n <script type=\"text/javascript\">\r\n var pkBaseURL = ((\"https:\" == document.location.protocol) ? \"https://".$baseurl."\" : \"http://".$baseurl."\");\r\n document.write(unescape(\"%3Cscript src='\" + pkBaseURL + \"piwik.js' type='text/javascript'%3E%3C/script%3E\"));\r\n </script>\r\n<script type=\"text/javascript\">\r\n try {\r\n var piwikTracker = Piwik.getTracker(pkBaseURL + \"piwik.php\", ".$siteid.");\r\n piwikTracker.trackPageView();\r\n piwikTracker.enableLinkTracking();\r\n }\r\n catch( err ) {}\r\n </script>\r\n<noscript><p><img src=\"//".$baseurl."piwik.php?idsite=".$siteid."\" style=\"border:0\" alt=\"\" /></p></noscript>\r\n <!-- End Piwik Tracking Tag --> </div>";
+         $b .= "<!-- Piwik --> <script type=\"text/javascript\"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://".$baseurl."\"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', ".$siteid."]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=false; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Piwik Code -->\r\n";
        }
 
        /*
@@ -77,7 +79,7 @@ function piwik_analytics($a,&$b) {
                $b .= t("This website is tracked using the <a href='http://www.piwik.org'>Piwik</a> analytics tool.");
                $b .= " ";
                $the_url =  "http://".$baseurl ."index.php?module=CoreAdminHome&action=optOut";
-               $b .= sprintf(t("If you do not want that your visits are logged this way you <a href='%s'>can set a cookie to prevent Piwik from tracking further visits of the site</a> (opt-out)."), $the_url);
+               $b .= sprintf(t("If you do not want that your visits are logged in this way you <a href='%s'>can set a cookie to prevent Piwik from tracking further visits of the site</a> (opt-out)."), $the_url);
                $b .= "</div>";
        }
 }
index af8e72b9cb1f47e5dca7ae7a7b17aeedab31db3c..76eaf77ad338eab352c4b78b9913b22cae632c6f 100755 (executable)
@@ -6,6 +6,7 @@
  * Version: 1.0
  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
  * Author: Tony Baldwin <https://free-haven.org/u/tony>
+ * Status: Unsupported
  */
 
 function posterous_install() {
index b7c8fc7a97bf127efd91958332ada54df6269bd2..8a303e7b069f14afa0adfe1eb468bbadf22e735b 100644 (file)
@@ -4,6 +4,7 @@
  * Name: Privacy Image Cache
  * Version: 0.1
  * Author: Tobias Hößl <https://github.com/CatoTH/>
+ * Status: Unsupported
  */
 
 define("PRIVACY_IMAGE_CACHE_DEFAULT_TIME", 86400); // 1 Day
@@ -61,6 +62,7 @@ function privacy_image_cache_init() {
        }
 
        $thumb = false;
+       $size = 1024;
 
        // If the cache path isn't there, try to create it
        if (!is_dir($_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache"))
@@ -79,6 +81,20 @@ function privacy_image_cache_init() {
                else
                        $url = $a->argv[1];
 
+               //$thumb = (isset($a->argv[3]) and ($a->argv[3] == "thumb"));
+               if (isset($a->argv[3]) and ($a->argv[3] == "thumb"))
+                       $size = 200;
+
+               // thumb, small, medium and large.
+               if (substr($url, -6) == ":thumb")
+                       $size = 150;
+               if (substr($url, -6) == ":small")
+                       $size = 340;
+               if (substr($url, -7) == ":medium")
+                       $size = 600;
+               if (substr($url, -6) == ":large")
+                       $size = 1024;
+
                $pos = strrpos($url, "=.");
                if ($pos)
                        $url = substr($url, 0, $pos+1);
@@ -89,7 +105,6 @@ function privacy_image_cache_init() {
 
                if ($url)
                        $_REQUEST['url'] = $url;
-               $thumb = (isset($a->argv[3]) and ($a->argv[3] == "thumb"));
        }
 
        if (!$direct_cache) {
@@ -142,7 +157,7 @@ function privacy_image_cache_init() {
                $redirects = 0;
                $img_str = fetch_url($_REQUEST['url'],true, $redirects, 10);
 
-               $tempfile = tempnam(get_config("system","temppath"), "cache");
+               $tempfile = tempnam(get_temppath(), "cache");
                file_put_contents($tempfile, $img_str);
                $mime = image_type_to_mime_type(exif_imagetype($tempfile));
                unlink($tempfile);
@@ -186,10 +201,10 @@ function privacy_image_cache_init() {
                                if (!$direct_cache AND ($cachefile == ""))
                                        $img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
 
-                               if ($thumb) {
-                                       $img->scaleImage(200); // Test
-                                       $img_str = $img->imageString();
-                               }
+                               //if ($thumb) {
+                               //      $img->scaleImage(200); // Test
+                               //      $img_str = $img->imageString();
+                               //}
                        }
                        //$mime = "image/jpeg";
                }
@@ -199,7 +214,8 @@ function privacy_image_cache_init() {
        if ($mime != "image/gif") {
                $img = new Photo($img_str, $mime);
                if($img->is_valid()) {
-                       $img->scaleImage(1024); // Test
+                       //$img->scaleImage(1024); // Test
+                       $img->scaleImage($size);
                        $img_str = $img->imageString();
                }
        }
@@ -292,8 +308,8 @@ function privacy_image_cache_img_cb($matches) {
                $matches[2] = urldecode($queryvar['url']);
 
        // if fetching facebook pictures don't fetch the thumbnail but the big one
-       if (((strpos($matches[2], ".fbcdn.net/") OR strpos($matches[2], "/fbcdn-photos-"))) and (substr($matches[2], -6) == "_s.jpg"))
-               $matches[2] = substr($matches[2], 0, -6)."_n.jpg";
+       //if (((strpos($matches[2], ".fbcdn.net/") OR strpos($matches[2], "/fbcdn-photos-"))) and (substr($matches[2], -6) == "_s.jpg"))
+       //      $matches[2] = substr($matches[2], 0, -6)."_n.jpg";
 
        // following line changed per bug #431
        if (privacy_image_cache_is_local_image($matches[2]))
index 624674144f39033d8ca3b741c0b952f553f07cd1..55d0433a1b4295e3060da314c3be365f52e768d1 100644 (file)
@@ -472,6 +472,9 @@ function pumpio_send(&$a,&$b) {
                        $inReplyTo = array("id" => $orig_post["uri"],
                                        "objectType" => "note");
 
+                       if (($orig_post["object-type"] != "") AND (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
+                               $inReplyTo["objectType"] = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
+
                        $params["object"] = array(
                                                'objectType' => "comment",
                                                'content' => $title.$content,
@@ -518,7 +521,7 @@ function pumpio_send(&$a,&$b) {
        }
 }
 
-function pumpio_action(&$a, $uid, $uri, $action, $content) {
+function pumpio_action(&$a, $uid, $uri, $action, $content = "") {
 
        // Don't do likes and other stuff if you don't import the timeline
        if (!get_pconfig($uid,'pumpio','import'))
@@ -546,7 +549,9 @@ function pumpio_action(&$a, $uid, $uri, $action, $content) {
        else
                $uri = $orig_post["uri"];
 
-       if (strstr($uri, "/api/comment/"))
+       if (($orig_post["object-type"] != "") AND (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
+               $objectType = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
+       elseif (strstr($uri, "/api/comment/"))
                $objectType = "comment";
        elseif (strstr($uri, "/api/note/"))
                $objectType = "note";
@@ -865,7 +870,6 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id) {
        $likedata['parent-uri'] = $orig_post["uri"];
        $likedata['contact-id'] = $contactid;
        $likedata['app'] = $post->generator->displayName;
-       $likedata['verb'] = ACTIVITY_LIKE;
        $likedata['author-name'] = $post->actor->displayName;
        $likedata['author-link'] = $post->actor->url;
        $likedata['author-avatar'] = $post->actor->image->url;
@@ -1081,6 +1085,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
        $postarray['uid'] = $uid;
        $postarray['wall'] = 0;
        $postarray['uri'] = $post->object->id;
+       $postarray['object-type'] = NAMESPACE_ACTIVITY_SCHEMA.strtolower($post->object->objectType);
 
        if ($post->object->objectType != "comment") {
                $contact_id = pumpio_get_contact($uid, $post->actor);
@@ -1238,7 +1243,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
                                        'to_email'     => $user[0]['email'],
                                        'uid'          => $user[0]['uid'],
                                        'item'         => $postarray,
-                                       'link'             => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item,
+                                       'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
                                        'source_name'  => $postarray['author-name'],
                                        'source_link'  => $postarray['author-link'],
                                        'source_photo' => $postarray['author-avatar'],
index 14d231d7f5790da37e8714af72fd1a0a410b85b2..cba5f9360f2cf794f53dc539ba5de2f83aa29d85 100644 (file)
@@ -820,7 +820,7 @@ class CodebirdSN
                 }
 
                // To-Do
-               $tempfile = tempnam(get_config("system","temppath"), "mimecheck");
+               $tempfile = tempnam(get_temppath(), "mimecheck");
                file_put_contents($tempfile, $data);
                $mime = image_type_to_mime_type(exif_imagetype($tempfile));
                unlink($tempfile);
index b619a0421c5ffac5a6a60b1754e838422f0880f4..c3591356b6237c035b79edea23bc934b58e8a533 100644 (file)
@@ -118,6 +118,7 @@ function statusnet_install() {
        register_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
        register_hook('jot_networks',    'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
        register_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
+       register_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
        logger("installed statusnet");
 }
 
@@ -129,6 +130,7 @@ function statusnet_uninstall() {
        unregister_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
        unregister_hook('jot_networks',    'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
        unregister_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
+       unregister_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
 
        // old setting - remove only
        unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
@@ -306,7 +308,7 @@ function statusnet_settings(&$a,&$s) {
                 */
                if (! $globalsn == null) {
                        $s .= '<h4>' . t('Globally Available StatusNet OAuthKeys') . '</h4>';
-                       $s .= '<p>'. t("There are preconfigured OAuth key pairs for some StatusNet servers available. If you are useing one of them, please use these credentials. If not feel free to connect to any other StatusNet instance \x28see below\x29.") .'</p>';
+                       $s .= '<p>'. t("There are preconfigured OAuth key pairs for some StatusNet servers available. If you are using one of them, please use these credentials. If not feel free to connect to any other StatusNet instance \x28see below\x29.") .'</p>';
                        $s .= '<div id="statusnet-preconf-wrapper">';
                        foreach ($globalsn as $asn) {
                                $s .= '<input type="radio" name="statusnet-preconf-apiurl" value="'. $asn['apiurl'] .'">'. $asn['sitename'] .'<br />';
@@ -494,8 +496,13 @@ function statusnet_post_hook(&$a,&$b) {
                        $orig_post = $r[0];
                }
 
-               $nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]";
-               $nicknameplain = "@".$orig_post["contact_nick"];
+               //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]";
+               //$nicknameplain = "@".$orig_post["contact_nick"];
+
+               $nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
+
+               $nickname = "@[url=".$orig_post["author-link"]."]".$nick."[/url]";
+               $nicknameplain = "@".$nick;
 
                logger("statusnet_post_hook: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
                if ((strpos($b["body"], $nickname) === false) AND (strpos($b["body"], $nicknameplain) === false))
@@ -548,10 +555,12 @@ function statusnet_post_hook(&$a,&$b) {
                $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
                $max_char = $dent->get_maxlength(); // max. length for a dent
 
+               set_pconfig($b['uid'], 'statusnet', 'max_char', $max_char);
+
                $tempfile = "";
                require_once("include/plaintext.php");
                require_once("include/network.php");
-               $msgarr = plaintext($a, $b, $max_char, true);
+               $msgarr = plaintext($a, $b, $max_char, true, 7);
                $msg = $msgarr["text"];
 
                if (($msg == "") AND isset($msgarr["title"]))
@@ -565,12 +574,12 @@ function statusnet_post_hook(&$a,&$b) {
                                $msg .= " \n".short_link($msgarr["url"]);
                        else
                                $msg .= " \n".$msgarr["url"];
-               } elseif (isset($msgarr["image"]))
+               } elseif (isset($msgarr["image"]) AND ($msgarr["type"] != "video"))
                        $image = $msgarr["image"];
 
                if ($image != "") {
                        $img_str = fetch_url($image);
-                       $tempfile = tempnam(get_config("system","temppath"), "cache");
+                       $tempfile = tempnam(get_temppath(), "cache");
                        file_put_contents($tempfile, $img_str);
                        $postdata = array("status" => $msg, "media[]" => $tempfile);
                } else
@@ -675,6 +684,53 @@ function statusnet_plugin_admin(&$a, &$o){
        ));
 }
 
+function statusnet_prepare_body(&$a,&$b) {
+        if ($b["item"]["network"] != NETWORK_STATUSNET)
+                return;
+
+        if ($b["preview"]) {
+               $max_char = get_pconfig(local_user(),'statusnet','max_char');
+               if (intval($max_char) == 0)
+                       $max_char = 140;
+
+                require_once("include/plaintext.php");
+                $item = $b["item"];
+                $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
+
+               $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick
+                        FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+                        WHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1",
+                        dbesc($item["thr-parent"]),
+                        intval(local_user()));
+
+                if(count($r)) {
+                        $orig_post = $r[0];
+                       //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]";
+                       //$nicknameplain = "@".$orig_post["contact_nick"];
+
+                       $nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
+
+                       $nickname = "@[url=".$orig_post["author-link"]."]".$nick."[/url]";
+                       $nicknameplain = "@".$nick;
+
+                       if ((strpos($item["body"], $nickname) === false) AND (strpos($item["body"], $nicknameplain) === false))
+                               $item["body"] = $nickname." ".$item["body"];
+                }
+
+
+                $msgarr = plaintext($a, $item, $max_char, true, 7);
+                $msg = $msgarr["text"];
+
+                if (isset($msgarr["url"]))
+                        $msg .= " ".$msgarr["url"];
+
+                if (isset($msgarr["image"]))
+                        $msg .= " ".$msgarr["image"];
+
+                $b['html'] = nl2br(htmlspecialchars($msg));
+        }
+}
+
 function statusnet_cron($a,$b) {
        $last = get_config('statusnet','last_poll');
 
@@ -998,6 +1054,8 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
 
        require_once("include/html2bbcode.php");
 
+       logger("statusnet_createpost: start", LOGGER_DEBUG);
+
        $api = get_pconfig($uid, 'statusnet', 'baseapi');
        $hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
 
@@ -1006,7 +1064,14 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
        $postarray['gravity'] = 0;
        $postarray['uid'] = $uid;
        $postarray['wall'] = 0;
-       $postarray['uri'] = $hostname."::".$post->id;
+
+       if (is_object($post->retweeted_status)) {
+               $content = $post->retweeted_status;
+               statusnet_fetch_contact($uid, $content->user, false);
+       } else
+               $content = $post;
+
+       $postarray['uri'] = $hostname."::".$content->id;
 
        $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
                        dbesc($postarray['uri']),
@@ -1018,9 +1083,9 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
 
        $contactid = 0;
 
-       if ($post->in_reply_to_status_id != "") {
+       if ($content->in_reply_to_status_id != "") {
 
-               $parent = $hostname."::".$post->in_reply_to_status_id;
+               $parent = $hostname."::".$content->in_reply_to_status_id;
 
                $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
                                dbesc($parent),
@@ -1029,6 +1094,8 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
                if (count($r)) {
                        $postarray['thr-parent'] = $r[0]["uri"];
                        $postarray['parent-uri'] = $r[0]["parent-uri"];
+                       $postarray['parent'] = $r[0]["parent"];
+                       $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
                } else {
                        $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
                                        dbesc($parent),
@@ -1037,16 +1104,19 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
                        if (count($r)) {
                                $postarray['thr-parent'] = $r[0]['uri'];
                                $postarray['parent-uri'] = $r[0]['parent-uri'];
+                               $postarray['parent'] = $r[0]['parent'];
+                               $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
                        } else {
                                $postarray['thr-parent'] = $postarray['uri'];
                                $postarray['parent-uri'] = $postarray['uri'];
+                               $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
                        }
                }
 
                // Is it me?
                $own_url = get_pconfig($uid, 'statusnet', 'own_url');
 
-               if ($post->user->id == $own_url) {
+               if ($content->user->id == $own_url) {
                        $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
                                intval($uid));
 
@@ -1059,8 +1129,12 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
                        } else
                                return(array());
                }
-       } else
+               // Don't create accounts of people who just comment something
+               $create_user = false;
+       } else {
                $postarray['parent-uri'] = $postarray['uri'];
+               $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+       }
 
        if ($contactid == 0) {
                $contactid = statusnet_fetch_contact($uid, $post->user, $create_user);
@@ -1076,43 +1150,44 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
        $postarray['contact-id'] = $contactid;
 
        $postarray['verb'] = ACTIVITY_POST;
-       $postarray['author-name'] = $postarray['owner-name'];
-       $postarray['author-link'] = $postarray['owner-link'];
-       $postarray['author-avatar'] = $postarray['owner-avatar'];
+
+       $postarray['author-name'] = $content->user->name;
+       $postarray['author-link'] = $content->user->statusnet_profile_url;
+       $postarray['author-avatar'] = $content->user->profile_image_url;
 
        // To-Do: Maybe unreliable? Can the api be entered without trailing "/"?
        $hostname = str_replace("/api/", "/notice/", get_pconfig($uid, 'statusnet', 'baseapi'));
 
-       $postarray['plink'] = $hostname.$post->id;
-       $postarray['app'] = strip_tags($post->source);
+       $postarray['plink'] = $hostname.$content->id;
+       $postarray['app'] = strip_tags($content->source);
 
-       if ($post->user->protected) {
+       if ($content->user->protected) {
                $postarray['private'] = 1;
                $postarray['allow_cid'] = '<' . $self['id'] . '>';
        }
 
-       $postarray['body'] = html2bbcode($post->statusnet_html);
+       $postarray['body'] = html2bbcode($content->statusnet_html);
 
        $converted = statusnet_convertmsg($a, $postarray['body'], false);
        $postarray['body'] = $converted["body"];
        $postarray['tag'] = $converted["tags"];
 
-       $postarray['created'] = datetime_convert('UTC','UTC',$post->created_at);
-       $postarray['edited'] = datetime_convert('UTC','UTC',$post->created_at);
+       $postarray['created'] = datetime_convert('UTC','UTC',$content->created_at);
+       $postarray['edited'] = datetime_convert('UTC','UTC',$content->created_at);
 
-       if (is_string($post->place->name))
-               $postarray["location"] = $post->place->name;
+       if (is_string($content->place->name))
+               $postarray["location"] = $content->place->name;
 
-       if (is_string($post->place->full_name))
-               $postarray["location"] = $post->place->full_name;
+       if (is_string($content->place->full_name))
+               $postarray["location"] = $content->place->full_name;
 
-       if (is_array($post->geo->coordinates))
-               $postarray["coord"] = $post->geo->coordinates[0]." ".$post->geo->coordinates[1];
+       if (is_array($content->geo->coordinates))
+               $postarray["coord"] = $content->geo->coordinates[0]." ".$content->geo->coordinates[1];
 
-       if (is_array($post->coordinates->coordinates))
-               $postarray["coord"] = $post->coordinates->coordinates[1]." ".$post->coordinates->coordinates[0];
+       if (is_array($content->coordinates->coordinates))
+               $postarray["coord"] = $content->coordinates->coordinates[1]." ".$content->coordinates->coordinates[0];
 
-       if (is_object($post->retweeted_status)) {
+       /*if (is_object($post->retweeted_status)) {
                $postarray['body'] = html2bbcode($post->retweeted_status->statusnet_html);
 
                $converted = statusnet_convertmsg($a, $postarray['body'], false);
@@ -1125,12 +1200,15 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
                $postarray['author-name'] = $post->retweeted_status->user->name;
                $postarray['author-link'] = $post->retweeted_status->user->statusnet_profile_url;
                $postarray['author-avatar'] = $post->retweeted_status->user->profile_image_url;
-       }
+       }*/
+       logger("statusnet_createpost: end", LOGGER_DEBUG);
        return($postarray);
 }
 
 function statusnet_checknotification($a, $uid, $own_url, $top_item, $postarray) {
 
+       // This function necer worked and need cleanup
+
        $user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                        intval($uid)
                );
@@ -1179,7 +1257,7 @@ function statusnet_checknotification($a, $uid, $own_url, $top_item, $postarray)
                                'to_email'     => $user[0]['email'],
                                'uid'          => $user[0]['uid'],
                                'item'         => $postarray,
-                               'link'             => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item,
+                               'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
                                'source_name'  => $postarray['author-name'],
                                'source_link'  => $postarray['author-link'],
                                'source_photo' => $postarray['author-avatar'],
@@ -1347,8 +1425,10 @@ function statusnet_fetchhometimeline($a, $uid) {
                                dbesc($postarray['uri']),
                                intval($uid)
                        );
-                       if (count($r))
+                       if (count($r)) {
                                $item = $r[0]['id'];
+                               $parent_id = $r[0]['parent'];
+                       }
 
                        if ($item != 0) {
                                require_once('include/enotify.php');
@@ -1360,12 +1440,13 @@ function statusnet_fetchhometimeline($a, $uid) {
                                        'to_email'     => $u[0]['email'],
                                        'uid'          => $u[0]['uid'],
                                        'item'         => $postarray,
-                                       'link'         => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
+                                       'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
                                        'source_name'  => $postarray['author-name'],
                                        'source_link'  => $postarray['author-link'],
                                        'source_photo' => $postarray['author-avatar'],
                                        'verb'         => ACTIVITY_TAG,
-                                       'otype'        => 'item'
+                                       'otype'        => 'item',
+                                       'parent'       => $parent_id,
                                ));
                        }
                }
@@ -1392,7 +1473,7 @@ function statusnet_complete_conversation($a, $uid, $self, $create_user, $nick, $
                $posts = array_reverse($items);
 
                foreach($posts AS $post) {
-                       $postarray = statusnet_createpost($a, $uid, $post, $self, $create_user, true);
+                       $postarray = statusnet_createpost($a, $uid, $post, $self, false, false);
 
                        if (trim($postarray['body']) == "")
                                continue;
@@ -1414,6 +1495,8 @@ function statusnet_convertmsg($a, $body, $no_tags = false) {
        require_once("include/items.php");
        require_once("include/network.php");
 
+       $body = preg_replace("=\[url\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\](.*?)\[\/url\]=ism","$1.$2.$3.$4/$5",$body);
+
        $URLSearchString = "^\[\]";
        $links = preg_match_all("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $body,$matches,PREG_SET_ORDER);
 
@@ -1426,10 +1509,16 @@ function statusnet_convertmsg($a, $body, $no_tags = false) {
                foreach ($matches AS $match) {
                        $search = "[url=".$match[1]."]".$match[2]."[/url]";
 
+                       logger("statusnet_convertmsg: expanding url ".$match[1], LOGGER_DEBUG);
+
                        $expanded_url = original_url($match[1]);
 
+                       logger("statusnet_convertmsg: fetching data for ".$expanded_url, LOGGER_DEBUG);
+
                        $oembed_data = oembed_fetch_url($expanded_url, true);
 
+                       logger("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG);
+
                        if ($type == "")
                                $type = $oembed_data->type;
                        if ($oembed_data->type == "video") {
@@ -1446,7 +1535,7 @@ function statusnet_convertmsg($a, $body, $no_tags = false) {
                        else {
                                $img_str = fetch_url($expanded_url, true, $redirects, 4);
 
-                               $tempfile = tempnam(get_config("system","temppath"), "cache");
+                               $tempfile = tempnam(get_temppath(), "cache");
                                file_put_contents($tempfile, $img_str);
                                $mime = image_type_to_mime_type(exif_imagetype($tempfile));
                                unlink($tempfile);
@@ -1470,7 +1559,7 @@ function statusnet_convertmsg($a, $body, $no_tags = false) {
                if (($footerlink != "") AND (trim($footer) != "")) {
                        $removedlink = trim(str_replace($footerlink, "", $body));
 
-                       if (strstr($body, $removedlink))
+                       if (($removedlink == "") OR strstr($body, $removedlink))
                                $body = $removedlink;
 
                        $body .= $footer;
index 62d7fd0456a8e2d9f8fbca63a60463893362e1f1..9b77bdcde99abe0a945e9d5bbb319f2775547d6c 100644 (file)
@@ -1,9 +1,7 @@
-Define in your .htconfig.php:
-$a->config['tumblr']['consumer_key'] = "your-consumer-key";
-$a->config['tumblr']['consumer_secret'] = "your-consumer-secret";
-
-You can get it here:
+Register an application at this address:
 http://www.tumblr.com/oauth/apps
 
+use (your server name)addon/tumblr/callback.php as callback URL
+
 Tumblr-OAuth-Library:
 https://groups.google.com/d/msg/tumblr-api/g6SeIBWvsnE/gnWqT9jFSlEJ
diff --git a/tumblr/templates/admin.tpl b/tumblr/templates/admin.tpl
new file mode 100644 (file)
index 0000000..b361f18
--- /dev/null
@@ -0,0 +1,3 @@
+{{include file="field_input.tpl" field=$consumer_key}}
+{{include file="field_input.tpl" field=$consumer_secret}}
+<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
index cd9713cf89f133e3406b72e1a034f268ac45c5a8..619ff16e807f43611f6b7af7c963adca9372da99 100644 (file)
@@ -54,6 +54,25 @@ function tumblr_content(&$a) {
        return $o;
 }
 
+function tumblr_plugin_admin(&$a, &$o){
+        $t = get_markup_template( "admin.tpl", "addon/tumblr/" );
+
+        $o = replace_macros($t, array(
+                '$submit' => t('Save Settings'),
+                                                                // name, label, value, help, [extra values]
+                '$consumer_key' => array('consumer_key', t('Consumer Key'),  get_config('tumblr', 'consumer_key' ), ''),
+                '$consumer_secret' => array('consumer_secret', t('Consumer Secret'),  get_config('tumblr', 'consumer_secret' ), ''),
+        ));
+}
+
+function tumblr_plugin_admin_post(&$a){
+        $consumer_key     =       ((x($_POST,'consumer_key'))              ? notags(trim($_POST['consumer_key']))   : '');
+        $consumer_secret =       ((x($_POST,'consumer_secret'))   ? notags(trim($_POST['consumer_secret'])): '');
+        set_config('tumblr','consumer_key',$consumer_key);
+        set_config('tumblr','consumer_secret',$consumer_secret);
+        info( t('Settings updated.'). EOL );
+}
+
 function tumblr_connect($a) {
        // Start a session.  This is necessary to hold on to  a few keys the callback script will also need
        session_start();
index 7c1674590f64cb880fd65f4a139e2a34fad379bc..1919e28cf536293bcaad3c7d41cdf2e0933bea1c 100644 (file)
@@ -73,6 +73,7 @@ function twitter_install() {
        register_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
        register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
        register_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+       register_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
        logger("installed twitter");
 }
 
@@ -87,6 +88,7 @@ function twitter_uninstall() {
        unregister_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
        unregister_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
        unregister_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+       unregister_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
 
        // old setting - remove only
        unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
@@ -462,7 +464,7 @@ function twitter_post_hook(&$a,&$b) {
 
                $max_char = 140;
                require_once("include/plaintext.php");
-               $msgarr = plaintext($a, $b, $max_char, true);
+               $msgarr = plaintext($a, $b, $max_char, true, 8);
                $msg = $msgarr["text"];
 
                if (($msg == "") AND isset($msgarr["title"]))
@@ -472,14 +474,14 @@ function twitter_post_hook(&$a,&$b) {
 
                if (isset($msgarr["url"]))
                        $msg .= "\n".$msgarr["url"];
-               elseif (isset($msgarr["image"]))
+               elseif (isset($msgarr["image"]) AND ($msgarr["type"] != "video"))
                        $image = $msgarr["image"];
 
                // and now tweet it :-)
                if(strlen($msg) and ($image != "")) {
                        $img_str = fetch_url($image);
 
-                       $tempfile = tempnam(get_config("system","temppath"), "cache");
+                       $tempfile = tempnam(get_temppath(), "cache");
                        file_put_contents($tempfile, $img_str);
 
                        // Twitter had changed something so that the old library doesn't work anymore
@@ -652,6 +654,45 @@ function twitter_expire($a,$b) {
        logger('twitter_expire: expire_end');
 }
 
+function twitter_prepare_body(&$a,&$b) {
+       if ($b["item"]["network"] != NETWORK_TWITTER)
+               return;
+
+       if ($b["preview"]) {
+               $max_char = 140;
+               require_once("include/plaintext.php");
+               $item = $b["item"];
+               $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
+
+               $r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
+                       dbesc($item["thr-parent"]),
+                       intval(local_user()));
+
+               if(count($r)) {
+                       $orig_post = $r[0];
+
+                       $nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
+                       $nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
+                       $nicknameplain = "@".$nicknameplain;
+
+                       if ((strpos($item["body"], $nickname) === false) AND (strpos($item["body"], $nicknameplain) === false))
+                               $item["body"] = $nickname." ".$item["body"];
+               }
+
+
+               $msgarr = plaintext($a, $item, $max_char, true, 8);
+               $msg = $msgarr["text"];
+
+               if (isset($msgarr["url"]))
+                       $msg .= " ".$msgarr["url"];
+
+               if (isset($msgarr["image"]))
+                       $msg .= " ".$msgarr["image"];
+
+                $b['html'] = nl2br(htmlspecialchars($msg));
+       }
+}
+
 function twitter_fetchtimeline($a, $uid) {
        $ckey    = get_config('twitter', 'consumerkey');
        $csecret = get_config('twitter', 'consumersecret');
@@ -712,19 +753,23 @@ function twitter_fetchtimeline($a, $uid) {
 
                                $_REQUEST['body'] = $post->retweeted_status->text;
 
+                               $picture = "";
+
                                // media
                                if (is_array($post->retweeted_status->entities->media)) {
                                        foreach($post->retweeted_status->entities->media AS $media) {
                                                switch($media->type) {
                                                        case 'photo':
-                                                               $_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']);
-                                                               $has_picture = true;
+                                                               //$_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']);
+                                                               //$has_picture = true;
+                                                               $_REQUEST['body'] = str_replace($media->url, "", $_REQUEST['body']);
+                                                               $picture = $media->media_url_https;
                                                                break;
                                                }
                                        }
                                }
 
-                               $converted = twitter_expand_entities($a, $_REQUEST['body'], $post->retweeted_status, true, $has_picture);
+                               $converted = twitter_expand_entities($a, $_REQUEST['body'], $post->retweeted_status, true, $picture);
                                $_REQUEST['body'] = $converted["body"];
 
                                $_REQUEST['body'] = "[share author='".$post->retweeted_status->user->name.
@@ -736,18 +781,22 @@ function twitter_fetchtimeline($a, $uid) {
                        } else {
                                $_REQUEST["body"] = $post->text;
 
+                               $picture = "";
+
                                if (is_array($post->entities->media)) {
                                        foreach($post->entities->media AS $media) {
                                                switch($media->type) {
                                                        case 'photo':
-                                                               $_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']);
-                                                               $has_picture = true;
+                                                               //$_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']);
+                                                               //$has_picture = true;
+                                                               $_REQUEST['body'] = str_replace($media->url, "", $_REQUEST['body']);
+                                                               $picture = $media->media_url_https;
                                                                break;
                                                }
                                        }
                                }
 
-                               $converted = twitter_expand_entities($a, $_REQUEST["body"], $post, true, $has_picture);
+                               $converted = twitter_expand_entities($a, $_REQUEST["body"], $post, true, $picture);
                                $_REQUEST['body'] = $converted["body"];
                        }
 
@@ -841,6 +890,13 @@ function twitter_queue_hook(&$a,&$b) {
 }
 
 function twitter_fetch_contact($uid, $contact, $create_user) {
+       require_once("include/Photo.php");
+
+       $avatar = str_replace("_normal.", ".", $contact->profile_image_url_https);
+
+       $info = get_photo_info($avatar);
+       if (!$info)
+               $avatar = $contact->profile_image_url_https;
 
        // Check if the unique contact is existing
        // To-Do: only update once a while
@@ -852,12 +908,12 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
                        dbesc(normalise_link("https://twitter.com/".$contact->screen_name)),
                        dbesc($contact->name),
                        dbesc($contact->screen_name),
-                       dbesc($contact->profile_image_url_https));
+                       dbesc($avatar));
        else
                q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
                        dbesc($contact->name),
                        dbesc($contact->screen_name),
-                       dbesc($contact->profile_image_url_https),
+                       dbesc($avatar),
                        dbesc(normalise_link("https://twitter.com/".$contact->screen_name)));
 
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
@@ -887,7 +943,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
                        dbesc("twitter::".$contact->id_str),
                        dbesc($contact->name),
                        dbesc($contact->screen_name),
-                       dbesc($contact->profile_image_url_https),
+                       dbesc($avatar),
                        dbesc(NETWORK_TWITTER),
                        intval(CONTACT_IS_FRIEND),
                        intval(1),
@@ -915,7 +971,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
 
                require_once("Photo.php");
 
-               $photos = import_profile_photo($contact->profile_image_url_https,$uid,$contact_id);
+               $photos = import_profile_photo($avatar,$uid,$contact_id);
 
                q("UPDATE `contact` SET `photo` = '%s',
                                        `thumb` = '%s',
@@ -947,7 +1003,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
 
                        require_once("Photo.php");
 
-                       $photos = import_profile_photo($contact->profile_image_url_https, $uid, $r[0]['id']);
+                       $photos = import_profile_photo($avatar, $uid, $r[0]['id']);
 
                        q("UPDATE `contact` SET `photo` = '%s',
                                                `thumb` = '%s',
@@ -1019,7 +1075,7 @@ function twitter_fetchuser($a, $uid, $screen_name = "", $user_id = "") {
        return $contact_id;
 }
 
-function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontincludemedia) {
+function twitter_expand_entities($a, $body, $item, $no_tags = false, $picture) {
        require_once("include/oembed.php");
        require_once("include/network.php");
 
@@ -1054,11 +1110,12 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
                                        $footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
 
                                        $body = str_replace($url->url, $footerlink, $body);
-                               } elseif (($oembed_data->type == "photo") AND isset($oembed_data->url) AND !$dontincludemedia) {
+                               //} elseif (($oembed_data->type == "photo") AND isset($oembed_data->url) AND !$dontincludemedia) {
+                               } elseif (($oembed_data->type == "photo") AND isset($oembed_data->url)) {
                                        $body = str_replace($url->url,
                                                        "[url=".$expanded_url."][img]".$oembed_data->url."[/img][/url]",
                                                        $body);
-                                       $dontincludemedia = true;
+                                       //$dontincludemedia = true;
                                } elseif ($oembed_data->type != "link")
                                        $body = str_replace($url->url,
                                                        "[url=".$expanded_url."]".$expanded_url."[/url]",
@@ -1066,7 +1123,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
                                else {
                                        $img_str = fetch_url($expanded_url, true, $redirects, 4);
 
-                                       $tempfile = tempnam(get_config("system","temppath"), "cache");
+                                       $tempfile = tempnam(get_temppath(), "cache");
                                        file_put_contents($tempfile, $img_str);
                                        $mime = image_type_to_mime_type(exif_imagetype($tempfile));
                                        unlink($tempfile);
@@ -1074,7 +1131,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
                                        if (substr($mime, 0, 6) == "image/") {
                                                $type = "photo";
                                                $body = str_replace($url->url, "[img]".$expanded_url."[/img]", $body);
-                                               $dontincludemedia = true;
+                                               //$dontincludemedia = true;
                                        } else {
                                                $type = $oembed_data->type;
                                                $footerurl = $expanded_url;
@@ -1087,17 +1144,20 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
                }
 
                if ($footerurl != "")
-                       $footer = add_page_info($footerurl);
+                       $footer = add_page_info($footerurl, false, $picture);
 
                if (($footerlink != "") AND (trim($footer) != "")) {
                        $removedlink = trim(str_replace($footerlink, "", $body));
 
-                       if (strstr($body, $removedlink))
+                       if (($removedlink == "") OR strstr($body, $removedlink))
                                $body = $removedlink;
 
                        $body .= $footer;
                }
 
+               if (($footer == "") AND ($picture != ""))
+                       $body .= "\n\n[img]".$picture."[/img]\n";
+
                if ($no_tags)
                        return(array("body" => $body, "tags" => ""));
 
@@ -1190,6 +1250,8 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
                if (count($r)) {
                        $postarray['thr-parent'] = $r[0]["uri"];
                        $postarray['parent-uri'] = $r[0]["parent-uri"];
+                       $postarray['parent'] = $r[0]["parent"];
+                       $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
                } else {
                        $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
                                        dbesc($parent),
@@ -1198,9 +1260,12 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
                        if (count($r)) {
                                $postarray['thr-parent'] = $r[0]['uri'];
                                $postarray['parent-uri'] = $r[0]['parent-uri'];
+                               $postarray['parent'] = $r[0]['parent'];
+                               $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
                        } else {
                                $postarray['thr-parent'] = $postarray['uri'];
                                $postarray['parent-uri'] = $postarray['uri'];
+                               $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
                        }
                }
 
@@ -1220,8 +1285,12 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
                        } else
                                return(array());
                }
-       } else
+               // Don't create accounts of people who just comment something
+               $create_user = false;
+       } else {
                $postarray['parent-uri'] = $postarray['uri'];
+               $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+       }
 
        if ($contactid == 0) {
                $contactid = twitter_fetch_contact($uid, $post->user, $create_user);
@@ -1252,13 +1321,18 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
 
        $postarray['body'] = $post->text;
 
+       $picture = "";
+
        // media
        if (is_array($post->entities->media)) {
                foreach($post->entities->media AS $media) {
                        switch($media->type) {
                                case 'photo':
-                                       $postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
-                                       $has_picture = true;
+                                       //$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
+                                       //$has_picture = true;
+                                       $postarray['body'] = str_replace($media->url, "", $postarray['body']);
+                                       $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
+                                       $picture = $media->media_url_https;
                                        break;
                                default:
                                        $postarray['body'] .= print_r($media, true);
@@ -1266,7 +1340,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
                }
        }
 
-       $converted = twitter_expand_entities($a, $postarray['body'], $post, false, $has_picture);
+       $converted = twitter_expand_entities($a, $postarray['body'], $post, false, $picture);
        $postarray['body'] = $converted["body"];
        $postarray['tag'] = $converted["tags"];
 
@@ -1289,13 +1363,18 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
 
                $postarray['body'] = $post->retweeted_status->text;
 
+               $picture = "";
+
                // media
                if (is_array($post->retweeted_status->entities->media)) {
                        foreach($post->retweeted_status->entities->media AS $media) {
                                switch($media->type) {
                                        case 'photo':
-                                               $postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
-                                               $has_picture = true;
+                                               //$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
+                                               //$has_picture = true;
+                                               $postarray['body'] = str_replace($media->url, "", $postarray['body']);
+                                               $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
+                                               $picture = $media->media_url_https;
                                                break;
                                        default:
                                                $postarray['body'] .= print_r($media, true);
@@ -1303,7 +1382,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
                        }
                }
 
-               $converted = twitter_expand_entities($a, $postarray['body'], $post->retweeted_status, false, $has_picture);
+               $converted = twitter_expand_entities($a, $postarray['body'], $post->retweeted_status, false, $picture);
                $postarray['body'] = $converted["body"];
                $postarray['tag'] = $converted["tags"];
 
@@ -1334,6 +1413,8 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
 
 function twitter_checknotification($a, $uid, $own_id, $top_item, $postarray) {
 
+       // this whole function doesn't seem to work. Needs complete check
+
        $user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                        intval($uid)
                );
@@ -1382,7 +1463,7 @@ function twitter_checknotification($a, $uid, $own_id, $top_item, $postarray) {
                                'to_email'     => $user[0]['email'],
                                'uid'          => $user[0]['uid'],
                                'item'         => $postarray,
-                               'link'             => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item,
+                               'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
                                'source_name'  => $postarray['author-name'],
                                'source_link'  => $postarray['author-link'],
                                'source_photo' => $postarray['author-avatar'],
@@ -1522,6 +1603,9 @@ function twitter_fetchhometimeline($a, $uid) {
 
                        $item = item_store($postarray);
 
+                       if (!isset($postarray["parent"]) OR ($postarray["parent"] == 0))
+                               $postarray["parent"] = $item;
+
                        logger('twitter_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
 
                        if ($item == 0) {
@@ -1529,9 +1613,12 @@ function twitter_fetchhometimeline($a, $uid) {
                                        dbesc($postarray['uri']),
                                        intval($uid)
                                );
-                               if (count($r))
+                               if (count($r)) {
                                        $item = $r[0]['id'];
-                       }
+                                       $parent_id = $r[0]['parent'];
+                               }
+                       } else
+                               $parent_id = $postarray['parent'];
 
                        if ($item != 0) {
                                require_once('include/enotify.php');
@@ -1543,12 +1630,13 @@ function twitter_fetchhometimeline($a, $uid) {
                                        'to_email'     => $u[0]['email'],
                                        'uid'          => $u[0]['uid'],
                                        'item'         => $postarray,
-                                       'link'         => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
+                                       'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
                                        'source_name'  => $postarray['author-name'],
                                        'source_link'  => $postarray['author-link'],
                                        'source_photo' => $postarray['author-avatar'],
                                        'verb'         => ACTIVITY_TAG,
-                                       'otype'        => 'item'
+                                       'otype'        => 'item',
+                                       'parent'       => $parent_id
                                ));
                        }
                }
index 8dfecc74e1f6c2072b261bb319b8b29142fa201e..76320f5cfa428808b57a95719197d1a32ce73e94 100755 (executable)
@@ -4,6 +4,7 @@
  * Description: Expose in user XRD the link to external user's unhosted-enabled storage
  * Version: 1.0
  * Author: Fabio Comuni <http://kirgroup.com/profile/fabrixxm>
+ * Status: Unsupported
  */
  
  function uhremotestorage_install() {