$r = q("SELECT STRAIGHT_JOIN `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM `item`, `contact`
WHERE `item`.`uid` = %d AND `verb` = '%s'
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
+ `contact`.`id` AS `cid`,
`user`.`nickname`, `user`.`hidewall`
FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM `item`, `contact`
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
AND `contact`.`id` = `item`.`contact-id` AND `item`.`uid` = %d AND `item`.`verb` = '%s'
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`parent` = %d AND `item`.`visible`
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`nick` as `reply_author`,
`contact`.`name`, `contact`.`photo` as `reply_photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM `item`, `contact`
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
AND `contact`.`id` = `item`.`contact-id`
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM `item` FORCE INDEX (`uid_id`), `contact`
WHERE `item`.`uid` = %d AND `verb` = '%s'
AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s'))
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM `item`, `contact`
WHERE `item`.`uid` = %d AND `verb` = '%s'
AND `item`.`contact-id` = %d
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM `item`, `contact`
WHERE `item`.`uid` = %d
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
return true;
}
+/**
+ * @brief List of all contact fields that are needed for the conversation function
+ */
+function contact_fieldlist() {
+
+ $fieldlist = "`contact`.`network`, `contact`.`url`, `contact`.`name`, `contact`.`writable`,
+ `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`alias`";
+
+ return $fieldlist;
+}
+
+/**
+ * @brief SQL condition for contacts
+ */
+function contact_condition() {
+
+ $condition = "NOT `contact`.`blocked` AND NOT `contact`.`pending`";
+
+ return $condition;
+}
+
+/**
+ * @brief SQL condition for items
+ */
+function item_condition() {
+
+ $condition = "`item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`";
+
+ return $condition;
+}
+
+/**
+ * @brief List of all item fields that are needed for the conversation function
+ */
+function item_fieldlist() {
+
+ $fieldlist = "`item`.`author-link`, `item`.`verb`, `item`.`id`, `item`.`parent`,
+ `item`.`uid`, `item`.`author-name`, `item`.`tag`, `item`.`location`, `item`.`coord`,
+ `item`.`title`, `item`.`uri`, `item`.`created`, `item`.`app`, `item`.`guid`,
+ `item`.`contact-id`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`rendered-hash`,
+ `item`.`body`, `item`.`rendered-html`, `item`.`private`, `item`.`edited`,
+ `item`.`allow_cid`, `item`.`allow_gid`, `item`.`deny_cid`, `item`.`deny_gid`,
+ `item`.`event-id`, `item`.`object-type`, `item`.`starred`, `item`.`created`,
+ `item`.`postopts`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
+ `item`.`plink`, `item`.`wall`,
+ `item`.`id` AS `item_id`, `item`.`network` AS `item_network`";
+
+ return $fieldlist;
+}
/**
* "Render" a conversation or list of items for HTML display.
`contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`,
`sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
FROM `item` $sql_post_table
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
*
*/
+$stamp1 = microtime(true);
session_start();
+$a->save_timestamp($stamp1, "parser");
/**
* Language was set earlier, but we can over-ride it in the session.
if (get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
return(community_getpublicitems($start, $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`,
- `user`.`nickname`, `user`.`hidewall`
+ $r = q("SELECT %s, %s, `user`.`nickname`
FROM `thread` FORCE INDEX (`wall_private_received`)
- INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND `user`.`hidewall` = 0
+ INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
- WHERE `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0
- AND `thread`.`private` = 0 AND `thread`.`wall` = 1
- ORDER BY `thread`.`received` DESC LIMIT %d, %d ",
- intval($start),
- intval($itemspage)
+ AND %s AND `contact`.`self`
+ WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
+ AND NOT `thread`.`private` AND `thread`.`wall`
+ ORDER BY `thread`.`received` DESC LIMIT %d, %d",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(),
+ intval($start), intval($itemspage)
);
return($r);
}
function community_getpublicitems($start, $itemspage) {
- $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
- `author-name` AS `name`, `owner-avatar` AS `photo`,
+
+ $r = q("SELECT %s, `author-name` AS `name`, `owner-avatar` AS `photo`,
`owner-link` AS `url`, `owner-avatar` AS `thumb`
FROM `thread`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
WHERE `thread`.`uid` = 0
ORDER BY `thread`.`created` DESC LIMIT %d, %d",
- intval($start),
+ item_fieldlist(), intval($start),
intval($itemspage)
);
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1
AND `item`.`deleted` = 0 and `item`.`moderated` = 0
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ `contact`.`id` AS `cid`
FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `item`.`moderated` = 0
return '';
}
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
- WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted`
- AND NOT `item`.`moderated`
+ $r = q("SELECT %s, %s FROM `item`
+ INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND `item`.`uid` = %d
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
$sql_extra
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
intval($a->profile['uid']),
intval($item_id)
);
if($r) {
$item_uri = $r[0]['uri'];
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
- WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted`
- AND NOT `item`.`moderated`
+ $r = q("SELECT %s, %s FROM `item`
+ INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND `item`.`uid` = %d
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d)
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
intval(local_user()),
dbesc($item_uri),
intval(local_user())
$sql_order = "`item`.`received`";
// "New Item View" - show all items unthreaded in reverse created date order
- $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1
- AND `item`.`deleted` = 0 AND `item`.`moderated` = 0
+ $items = q("SELECT %s, %s FROM $sql_table $sql_post_table
+ INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND `item`.`uid` = %d
$simple_update
$sql_extra $sql_nets
ORDER BY $sql_order DESC $pager_sql ",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
intval($_SESSION['uid'])
);
foreach ($parents_arr AS $parents) {
// $sql_extra ORDER BY `item`.`commented` DESC LIMIT %d",
- $thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `item`.`moderated` = 0
+ $thread_items = q("SELECT %s, %s FROM `item`
+ INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND `item`.`uid` = %d
AND `item`.`parent` = %d
ORDER BY `item`.`commented` DESC LIMIT %d",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
intval(local_user()),
intval($parents),
intval($max_comments + 1)
// Construct permissions
// default permissions - anonymous user
-
+
$sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
$r = q("SELECT COUNT(*) AS `total`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0
- AND `item`.`deleted` = 0 AND `item`.`type` = 'note'
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1
- AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
+ FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
+ AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
$sql_extra ",
+ contact_condition(), item_condition(),
intval(local_user())
);
$a->set_pager_itemspage(40);
}
- $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- and `item`.`moderated` = 0 AND `item`.`type` = 'note'
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1
- AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
+ $r = q("SELECT `item`.`id` AS `item_id` FROM `item`
+ LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s AND `contact`.`self`
+ WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
+ AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
$sql_extra
ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
+ contact_condition(), item_condition(),
intval(local_user()),
intval($a->pager['start']),
intval($a->pager['itemspage'])
foreach($r as $rr)
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
-
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`,
- `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` IN ( %s )
+
+ $r = q("SELECT %s, %s FROM `item`
+ LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
$sql_extra
ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
intval(local_user()),
dbesc($parents_str)
);
if($update) {
- $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`,
- `contact`.`uid` AS `contact-uid`
+ $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
- $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`,
- `thread`.`uid` AS `contact-uid`
+ $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`
FROM `thread` FORCE INDEX (`uid_created`) INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
$sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
- $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`,
- `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, `contact`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- and `item`.`moderated` = 0
- AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` IN ( %s )
+ $items = q("SELECT %s, %s FROM `item`
+ INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND `item`.`uid` = %d
+ AND `item`.`parent` IN (%s)
$sql_extra ",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
intval($a->profile['profile_uid']),
dbesc($parents_str)
);
if($tag) {
logger("Start tag search for '".$search."'", LOGGER_DEBUG);
- $r = q("SELECT STRAIGHT_JOIN `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`
+ $r = q("SELECT STRAIGHT_JOIN %s, %s
FROM `term`
INNER JOIN `item` ON `item`.`id`=`term`.`oid`
- INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
- WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
- AND (`term`.`uid` = 0 OR (`term`.`uid` = %d AND NOT `term`.`global`)) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s'
+ INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND (`term`.`uid` = 0 OR (`term`.`uid` = %d AND NOT `term`.`global`)) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s'
ORDER BY term.created DESC LIMIT %d , %d ",
- intval(local_user()), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)),
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
+ intval(local_user()),
+ intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)),
intval($a->pager['start']), intval($a->pager['itemspage']));
} else {
logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
}
- $r = q("SELECT STRAIGHT_JOIN `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`
+ $r = q("SELECT STRAIGHT_JOIN %s, %s
FROM `item`
- INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
- WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
- AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
+ INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
+ WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
$sql_extra
- GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d ",
- intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
+ GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d",
+ item_fieldlist(), contact_fieldlist(),
+ contact_condition(), item_condition(),
+ intval(local_user()),
+ intval($a->pager['start']), intval($a->pager['itemspage']));
}
if(! count($r)) {