]> git.mxchange.org Git - friendica.git/commitdiff
prune all dead/blocked contacts from allowed permissions, ok to keep them in "deny...
authorfriendica <info@friendica.com>
Fri, 14 Dec 2012 05:02:14 +0000 (21:02 -0800)
committerfriendica <info@friendica.com>
Fri, 14 Dec 2012 05:02:14 +0000 (21:02 -0800)
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.

include/acl_selectors.php
include/group.php
include/notifier.php

index 461ad0c3640c276d449169490e01556eb47ce5d5..675339559b6d7cca29bd77d2dba33067841c75d1 100644 (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">';
index 7ede242c087073b326a1d5de296d398d806cf00f..aa226688ae5242dae6220b0a00062acef44911ce 100644 (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;
 }
 
index 091d09b56211ac7714f2a796ebe74b807e86af67..3398254b6a43961f241ff1a69ac937a5c6eae8da 100644 (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']));