aboutsummaryrefslogtreecommitdiffstats
path: root/include/connections.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-07-01 11:03:26 +0000
committerMario <mario@mariovavti.com>2023-07-01 11:03:26 +0000
commit4f03272a5f4c33f6c893b6f56f43fe5e839173b3 (patch)
tree98c13a7fabccf9aa1dbe164532db68703d7d6dbf /include/connections.php
parent7755936a2ef31d8ad9976d6fe80eb85f0b816f70 (diff)
downloadvolse-hubzilla-4f03272a5f4c33f6c893b6f56f43fe5e839173b3.tar.gz
volse-hubzilla-4f03272a5f4c33f6c893b6f56f43fe5e839173b3.tar.bz2
volse-hubzilla-4f03272a5f4c33f6c893b6f56f43fe5e839173b3.zip
unify code for selecting deliverable abook xchans
Diffstat (limited to 'include/connections.php')
-rw-r--r--include/connections.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/connections.php b/include/connections.php
index e8415bb25..9a6ee7d8d 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -67,6 +67,35 @@ function rconnect_url($channel_id,$xchan) {
}
+function deliverable_abook_xchans($channel_id, $filter = [], $flatten = true) {
+ $filter_sql = '';
+
+ if ($filter) {
+ $filter_sql = " AND abook_xchan IN (" . protect_sprintf(stringify_array($filter, true)) . ") ";
+ }
+
+ $r = q("SELECT abook_xchan, xchan_network FROM abook LEFT JOIN xchan ON abook_xchan = xchan_hash WHERE
+ abook_channel = %d $filter_sql
+ AND abook_self = 0
+ AND abook_pending = 0
+ AND abook_archived = 0
+ AND abook_not_here = 0
+ AND xchan_network NOT IN ('anon', 'token', 'rss')",
+ intval($channel_id)
+ );
+
+ if (!$r) {
+ return [];
+ }
+
+ if ($flatten) {
+ return ids_to_array($r, 'abook_xchan');
+ }
+
+ return $r;
+}
+
+
function abook_connections($channel_id, $sql_conditions = '') {
$r = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d
and abook_self = 0 $sql_conditions",