aboutsummaryrefslogtreecommitdiffstats
path: root/include/group.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-02-12 15:56:33 -0800
committerzotlabs <mike@macgirvin.com>2017-02-12 15:56:33 -0800
commitccdfbc721fa0cf6710cce262cbaa219e2803e8c2 (patch)
tree3ff4e912a8496d6e6ae7abb530afc80eeba8b24c /include/group.php
parentbc3605a5025908ae0835c057cb7caa1bc26d9c37 (diff)
downloadvolse-hubzilla-ccdfbc721fa0cf6710cce262cbaa219e2803e8c2.tar.gz
volse-hubzilla-ccdfbc721fa0cf6710cce262cbaa219e2803e8c2.tar.bz2
volse-hubzilla-ccdfbc721fa0cf6710cce262cbaa219e2803e8c2.zip
Create virtual privacy groups for private profile member lists
Diffstat (limited to 'include/group.php')
-rw-r--r--include/group.php68
1 files changed, 57 insertions, 11 deletions
diff --git a/include/group.php b/include/group.php
index 38d9d190f..3b208ef95 100644
--- a/include/group.php
+++ b/include/group.php
@@ -227,6 +227,26 @@ function group_get_members_xchan($gid) {
return $ret;
}
+function group_get_profile_members_xchan($uid,$gid) {
+ $ret = [];
+
+ if(intval($gid)) {
+ $r = q("SELECT abook_xchan as xchan from abook left join profile on abook_profile = profile_guid where profile.id = %d and profile.uid = %d",
+ intval($gid),
+ intval($uid)
+ );
+ if($r) {
+ foreach($r as $rr) {
+ $ret[] = $rr['xchan'];
+ }
+ }
+ }
+ return $ret;
+}
+
+
+
+
function mini_group_select($uid,$group = '') {
$grps = array();
@@ -320,20 +340,46 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
return $o;
}
-function expand_groups($a) {
- if(! (is_array($a) && count($a)))
+function expand_groups($g) {
+ if(! (is_array($g) && count($g)))
return array();
- $x = $a;
- stringify_array_elms($x,true);
- $groups = implode(',', $x);
- if($groups)
- $r = q("SELECT xchan FROM group_member WHERE gid IN ( select id from groups where hash in ( $groups ))");
- $ret = array();
+ $ret = [];
+ $x = [];
- if($r)
- foreach($r as $rr)
- $ret[] = $rr['xchan'];
+ // private profile linked virtual groups
+
+ foreach($g as $gv) {
+ if(substr($gv,0,3) === 'vp.') {
+ $profile_hash = substr($gv,3);
+ if($profile_hash) {
+ $r = q("select abook_xchan from abook where abook_profile = '%s'",
+ dbesc($profile_hash)
+ );
+ if($r) {
+ foreach($r as $rv) {
+ $ret[] = $rv['abook_xchan'];
+ }
+ }
+ }
+ }
+ else {
+ $x[] = $gv;
+ }
+ }
+
+ if($x) {
+ stringify_array_elms($x,true);
+ $groups = implode(',', $x);
+ if($groups) {
+ $r = q("SELECT xchan FROM group_member WHERE gid IN ( select id from groups where hash in ( $groups ))");
+ if($r) {
+ foreach($r as $rr) {
+ $ret[] = $rr['xchan'];
+ }
+ }
+ }
+ }
return $ret;
}