]> git.mxchange.org Git - friendica.git/commitdiff
The global copy now copies comments as well. This is important for the search.
authorMichael Vogel <icarus@dabo.de>
Sat, 21 Mar 2015 19:23:47 +0000 (20:23 +0100)
committerMichael Vogel <icarus@dabo.de>
Sat, 21 Mar 2015 19:23:47 +0000 (20:23 +0100)
include/diaspora.php
include/items.php
include/threads.php
mod/community.php

index 1202a3a5521bbc54fae0d0749020deaaac9012a0..5189c0e7823f4e164da0bbd49e24f864736763fd 100755 (executable)
@@ -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;
index 95ff40714f0e2d2809130ddcc3334909e85b21cd..0b8bf8fea9de84067b7490326340f2267e57b22e 100644 (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);
index cefba2d6c0519890a426485ce510a701212be577..d88307ecfb648ff1c653b0f7bfb55ab22fbf77b3 100644 (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));
 
index 3f0adff04fde219f2c25651dd8f23b1041d018e8..d6f87762bdefefda35ecdb15ec387c7711a439a9 100644 (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",