Searching for items now always searches public entries from the central item storage with uid=0.

This commit is contained in:
Michael Vogel 2015-02-08 15:59:22 +01:00
parent 7d2da9be02
commit a97d4383a1
2 changed files with 37 additions and 8 deletions

View File

@ -20,8 +20,8 @@ function add_thread($itemid, $onlyshadow = false) {
} }
// Store a shadow copy of public items for displaying a global community page? // Store a shadow copy of public items for displaying a global community page?
if (!get_config('system', 'global_community')) //if (!get_config('system', 'global_community'))
return; // return;
// is it already a copy? // is it already a copy?
if (($itemid == 0) OR ($item['uid'] == 0)) if (($itemid == 0) OR ($item['uid'] == 0))

View File

@ -151,6 +151,7 @@ function search_content(&$a) {
// No items will be shown if the member has a blocked profile wall. // No items will be shown if the member has a blocked profile wall.
if(get_config('system', 'old_pager')) { if(get_config('system', 'old_pager')) {
/*
$r = q("SELECT distinct(`item`.`uri`) as `total` $r = q("SELECT distinct(`item`.`uri`) as `total`
FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
@ -161,7 +162,16 @@ function search_content(&$a) {
$sql_extra ", $sql_extra ",
intval(local_user()) intval(local_user())
); );
// $sql_extra group by `item`.`uri` ", */
$r = q("SELECT distinct(`item`.`uri`) as `total`
FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND ((`item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`uid` = 0)
OR (`item`.`uid` = %d))
$sql_extra ",
intval(local_user())
);
if(count($r)) if(count($r))
$a->set_pager_total(count($r)); $a->set_pager_total(count($r));
@ -172,6 +182,7 @@ function search_content(&$a) {
} }
} }
/*
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
@ -183,14 +194,32 @@ function search_content(&$a) {
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND ((`item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0) AND ((`item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0)
OR (`item`.`uid` = %d)) OR (`item`.`uid` = %d))
$sql_extra GROUP BY `item`.`uri` $sql_extra
GROUP BY `item`.`uri`
ORDER BY $sql_order DESC LIMIT %d , %d ",
intval(local_user()),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
*/
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND ((`item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`uid`=0)
OR `item`.`uid` = %d)
$sql_extra
GROUP BY `item`.`uri`
ORDER BY $sql_order DESC LIMIT %d , %d ", ORDER BY $sql_order DESC LIMIT %d , %d ",
intval(local_user()), intval(local_user()),
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])
); );
// group by `item`.`uri`
if(! count($r)) { if(! count($r)) {
info( t('No results.') . EOL); info( t('No results.') . EOL);