aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index a68782f2a..464396d62 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1687,4 +1687,37 @@ function ids_to_querystr($arr,$idx = 'id') {
foreach($arr as $x)
$t[] = $x[$idx];
return(implode(',', $t));
+}
+
+function xchan_query(&$items) {
+ $arr = array();
+ if($items && count($items)) {
+ foreach($items as $item) {
+ if($item['owner_xchan'] && (! in_array($item['owner_xchan'],$arr)))
+ $arr[] = "'" . dbesc($item['owner_xchan']) . "'";
+ if($item['author_xchan'] && (! in_array($item['author_xchan'],$arr)))
+ $arr[] = "'" . dbesc($item['author_xchan']) . "'";
+ }
+ }
+ if(count($arr)) {
+ $chans = q("select * from xchan where xchan_hash in (" . implode(',', $arr) . ")");
+ }
+ if($items && count($items) && $chans && count($chans)) {
+ for($x = 0; $x < count($items); $x ++) {
+ $items[$x]['owner'] = find_xchan_in_array($items[$x]['owner_xchan'],$chans);
+ $items[$x]['author'] = find_xchan_in_array($items[$x]['author_xchan'],$chans);
+ }
+ }
+
+}
+
+function find_xchan_in_array($xchan,$arr) {
+ if(count($arr)) {
+ foreach($arr as $x) {
+ if($x['xchan_hash'] === $xchan) {
+ return $x;
+ }
+ }
+ }
+ return array();
} \ No newline at end of file