aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-19 22:21:00 -0800
committerfriendica <info@friendica.com>2013-01-19 22:21:00 -0800
commit45be26dd81a1679853763bc79c387bf0c6fdfe57 (patch)
tree306713eecc79b8bb40906454f5d01d8eb948eaf5 /include/text.php
parent994f322d471ff2271055db9344a31c7caef3c0db (diff)
downloadvolse-hubzilla-45be26dd81a1679853763bc79c387bf0c6fdfe57.tar.gz
volse-hubzilla-45be26dd81a1679853763bc79c387bf0c6fdfe57.tar.bz2
volse-hubzilla-45be26dd81a1679853763bc79c387bf0c6fdfe57.zip
more heavy lifting on API - though need to re-visit events and give them all message_ids from the origination site.
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/include/text.php b/include/text.php
index 1cfc89cae..6f2caa510 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1718,7 +1718,11 @@ function ids_to_querystr($arr,$idx = 'id') {
return(implode(',', $t));
}
-function xchan_query(&$items) {
+// Fetches xchan and hubloc data for an array of items with only an
+// author_xchan and owner_xchan. If $abook is true also include the abook info.
+// This is needed in the API to save extra per item lookups there.
+
+function xchan_query(&$items,$abook = false) {
$arr = array();
if($items && count($items)) {
foreach($items as $item) {
@@ -1729,8 +1733,14 @@ function xchan_query(&$items) {
}
}
if(count($arr)) {
- $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
- where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )");
+ if($abook) {
+ $chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash
+ where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )");
+ }
+ else {
+ $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
+ where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )");
+ }
}
if($items && count($items) && $chans && count($chans)) {
for($x = 0; $x < count($items); $x ++) {