diff --git a/include/bbcode.php b/include/bbcode.php index 3cf67af69..63406689a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -42,7 +42,7 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $title = $matches[1]; //$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false); - $title = bbcode(html_entity_decode($title), false, false, true); + $title = bbcode(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, false, true); $title = str_replace(array("[", "]"), array("[", "]"), $title); $image = ""; diff --git a/include/diaspora.php b/include/diaspora.php index 1202a3a55..5189c0e78 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -6,6 +6,7 @@ require_once('include/bb2diaspora.php'); require_once('include/contact_selectors.php'); require_once('include/queue_fn.php'); require_once('include/lock.php'); +require_once('include/threads.php'); function diaspora_dispatch_public($msg) { @@ -1855,11 +1856,12 @@ function diaspora_photo($importer,$xml,$msg,$attempt=1) { array($remote_photo_name, 'scaled_full_' . $remote_photo_name)); if(strpos($parent_item['body'],$link_text) === false) { - $r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d", + $r = q("UPDATE `item` SET `body` = '%s', `visible` = 1 WHERE `id` = %d AND `uid` = %d", dbesc($link_text . $parent_item['body']), intval($parent_item['id']), intval($parent_item['uid']) ); + update_thread($parent_item['id']); } return; diff --git a/include/items.php b/include/items.php index 95ff40714..0b8bf8fea 100644 --- a/include/items.php +++ b/include/items.php @@ -1561,8 +1561,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa )); logger('item_store: Notification sent for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG); } - } else + } else { update_thread($parent_id); + add_shadow_entry($arr); + } if ($notify) proc_run('php', "include/notifier.php", $notify_type, $current_post); diff --git a/include/threads.php b/include/threads.php index cefba2d6c..d88307ecf 100644 --- a/include/threads.php +++ b/include/threads.php @@ -74,6 +74,35 @@ function add_thread($itemid, $onlyshadow = false) { } } +function add_shadow_entry($item) { + + // Is this a shadow entry? + if ($item['uid'] == 0) + return; + + // Is there a shadow parent? + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['parent-uri'])); + if (!count($r)) + return; + + // Is there already a shadow entry? + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri'])); + + if (count($r)) + return; + + // Preparing public shadow (removing user specific data) + require_once("include/items.php"); + require_once("include/Contact.php"); + + unset($item['id']); + $item['uid'] = 0; + $item['contact-id'] = get_contact($item['author-link'], 0); + $public_shadow = item_store($item, false, false, true); + + logger("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG); +} + function update_thread_uri($itemuri, $uid) { $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid)); diff --git a/mod/community.php b/mod/community.php index 3f0adff04..d6f87762b 100644 --- a/mod/community.php +++ b/mod/community.php @@ -143,7 +143,7 @@ function community_getpublicitems($start, $itemspage) { $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, `author-name` AS `name`, `owner-avatar` AS `photo`, `owner-link` AS `url`, `owner-avatar` AS `thumb` - FROM `item` WHERE `item`.`uid` = 0 + FROM `item` WHERE `item`.`uid` = 0 AND `item`.`id` = `item`.`parent` AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' ORDER BY `item`.`received` DESC LIMIT %d, %d",