prune all dead/blocked contacts from allowed permissions, ok to keep them in "deny" lists -

Contacts will be pruned when creating the editor. They can't be added with the ACL selector,
but we won't prevent them from being added through other means.
Allowed groups will be pruned on item submit.
This commit is contained in:
friendica 2012-12-13 21:02:14 -08:00
parent 6faadc9662
commit 6b36863dd8
3 changed files with 31 additions and 2 deletions

View file

@ -227,6 +227,23 @@ function fixacl(&$item) {
$item = intval(str_replace(array('<','>'),array('',''),$item));
}
function prune_deadguys($arr) {
if(! $arr)
return $arr;
$str = dbesc(implode(',',$arr));
$r = q("select id from contact where id in ( " . $str . ") and blocked = 0 and pending = 0 and archive = 0 ");
if($r) {
$ret = array();
foreach($r as $rr)
$ret[] = $rr['id'];
return $ret;
}
return array();
}
function populate_acl($user = null,$celeb = false) {
$allow_cid = $allow_gid = $deny_cid = $deny_gid = false;
@ -246,6 +263,14 @@ function populate_acl($user = null,$celeb = false) {
array_walk($deny_gid,'fixacl');
}
$allow_cid = prune_deadguys($allow_cid);
// We shouldn't need to prune deadguys from the block list. Either way they can't get the message.
// Also no point enumerating groups and checking them, that will take place on delivery.
// $deny_cid = prune_deadguys($deny_cid);
/*$o = '';
$o .= '<div id="acl-wrapper">';
$o .= '<div id="acl-permit-outer-wrapper">';

View file

@ -279,7 +279,7 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0
return $o;
}
function expand_groups($a) {
function expand_groups($a,$check_dead = false) {
if(! (is_array($a) && count($a)))
return array();
$groups = implode(',', $a);
@ -289,6 +289,10 @@ function expand_groups($a) {
if(count($r))
foreach($r as $rr)
$ret[] = $rr['contact-id'];
if($check_dead) {
require_once('include/acl_selectors.php');
$ret = prune_deadguys($ret);
}
return $ret;
}

View file

@ -309,7 +309,7 @@ function notifier_run(&$argv, &$argc){
}
$allow_people = expand_acl($parent['allow_cid']);
$allow_groups = expand_groups(expand_acl($parent['allow_gid']));
$allow_groups = expand_groups(expand_acl($parent['allow_gid']),true);
$deny_people = expand_acl($parent['deny_cid']);
$deny_groups = expand_groups(expand_acl($parent['deny_gid']));