Merge pull request #1436 from annando/1503-global-copy-comments

The global copy now copies comments as well
This commit is contained in:
fabrixxm 2015-03-22 09:49:49 +01:00
commit c18ace5517
4 changed files with 36 additions and 3 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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));

View file

@ -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",