// Let's assume we've just created a list which we once deleted
// all the old members are gone, but the list remains so we don't break any security
// access lists. What we're doing here is reviving the dead list, but old content which
// was restricted to this list may now be seen by the new list members.
// was restricted to this list may now be seen by the new list members.
$z=q("SELECT * FROM pgrp WHERE id = %d LIMIT 1",
intval($r)
);
if(($z)&&$z[0]['deleted']){
if(($z)&&$z[0]['deleted']){
q('UPDATE pgrp SET deleted = 0 WHERE id = %d',intval($z[0]['id']));
notice(t('A deleted list with this name was revived. Existing item permissions <strong>may</strong> apply to this list and any future members. If this is not what you intended, please create another list with a different name.').EOL);
notice(t('A deleted privacy group with this name was revived. Existing item permissions <strong>may</strong> apply to this privacy group and any future members. If this is not what you intended, please create another privacy group with a different name.').EOL);
}
returntrue;
$hash=self::by_id($uid,$r);
return$hash;
}
$hash=new_uuid();
$r=q("INSERT INTO pgrp ( hash, uid, visible, gname )
$r=q("INSERT INTO pgrp ( hash, uid, visible, gname )
VALUES( '%s', %d, %d, '%s' ) ",
dbesc($hash),
intval($uid),
...
...
@@ -42,12 +41,12 @@ class AccessList {
$ret=$r;
}
Libsync::build_sync_packet($uid,null,true);
return$ret;
}
Libsync::build_sync_packet($uid,null,true);
return(($ret)?$hash:$ret);
}
staticfunctionremove($uid,$name){
staticfunctionremove($uid,$name){
$ret=false;
if($uid&&$name){
$r=q("SELECT id, hash FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1",
...
...
@@ -55,36 +54,36 @@ class AccessList {
dbesc($name)
);
if($r){
$group_id=$r[0]['id'];
$group_id=$r[0]['id'];
$group_hash=$r[0]['hash'];
}
else{
returnfalse;
}
// remove group from default posting lists
$r=q("SELECT channel_default_group, channel_allow_gid, channel_deny_gid FROM channel WHERE channel_id = %d LIMIT 1",
$r=q("SELECT * FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1",
$r=q("SELECT * FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1",
intval($uid),
intval($gid),
dbesc($member)
);
if($r){
returntrue;// You might question this, but
// we indicate success because the group member was in fact created
// -- It was just created at another time
returntrue;// You might question this, but
// we indicate success because the group member was in fact created
// -- It was just created at another time
}
else{
else{
$r=q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ",
intval($uid),
...
...
@@ -210,15 +204,14 @@ class AccessList {
dbesc($member)
);
}
Libsync::build_sync_packet($uid,null,true);
Libsync::build_sync_packet($uid,null,true);
return$r;
}
staticfunctionmembers($uid,$gid){
$ret=[];
if(intval($gid)){
$r=q("SELECT * FROM pgrp_member
$r=q("SELECT * FROM pgrp_member
LEFT JOIN abook ON abook_xchan = pgrp_member.xchan left join xchan on xchan_hash = abook_xchan
WHERE gid = %d AND abook_channel = %d and pgrp_member.uid = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ",
intval($gid),
...
...
@@ -232,7 +225,7 @@ class AccessList {
return$ret;
}
staticfunctionmembers_xchan($uid,$gid){
staticfunctionmembers_xchan($uid,$gid){
$ret=[];
if(intval($gid)){
$r=q("SELECT xchan FROM pgrp_member WHERE gid = %d AND uid = %d",
...
...
@@ -248,99 +241,124 @@ class AccessList {
return$ret;
}
staticfunctionmembers_profile_xchan($uid,$gid){
staticfunctionprofile_members_xchan($uid,$gid){
$ret=[];
if(intval($gid)){
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",