mirror of
https://github.com/friendica/friendica
synced 2025-04-27 15:10:11 +00:00
Add user meta-groups for followers and mutual contacts
- Both Group::expand and Item::enumeratePermissions now have a user id parameter to expand meta-groups
This commit is contained in:
parent
c6a806b9e1
commit
0579252362
7 changed files with 89 additions and 31 deletions
|
@ -2799,12 +2799,12 @@ class Item extends BaseObject
|
|||
*/
|
||||
if (self::hasPermissions($photo)) {
|
||||
if ($cid) {
|
||||
$recips = self::enumeratePermissions($photo);
|
||||
$recips = self::enumeratePermissions($uid, $photo);
|
||||
if (in_array($cid, $recips)) {
|
||||
$replace = true;
|
||||
}
|
||||
} elseif ($item) {
|
||||
if (self::samePermissions($item, $photo)) {
|
||||
if (self::samePermissions($uid, $item, $photo)) {
|
||||
$replace = true;
|
||||
}
|
||||
}
|
||||
|
@ -2854,7 +2854,7 @@ class Item extends BaseObject
|
|||
!empty($obj['deny_cid']) || !empty($obj['deny_gid']);
|
||||
}
|
||||
|
||||
private static function samePermissions($obj1, $obj2)
|
||||
private static function samePermissions($uid, $obj1, $obj2)
|
||||
{
|
||||
// first part is easy. Check that these are exactly the same.
|
||||
if (($obj1['allow_cid'] == $obj2['allow_cid'])
|
||||
|
@ -2865,8 +2865,8 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// This is harder. Parse all the permissions and compare the resulting set.
|
||||
$recipients1 = self::enumeratePermissions($obj1);
|
||||
$recipients2 = self::enumeratePermissions($obj2);
|
||||
$recipients1 = self::enumeratePermissions($uid, $obj1);
|
||||
$recipients2 = self::enumeratePermissions($uid, $obj2);
|
||||
sort($recipients1);
|
||||
sort($recipients2);
|
||||
|
||||
|
@ -2875,12 +2875,12 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// returns an array of contact-ids that are allowed to see this object
|
||||
public static function enumeratePermissions($obj)
|
||||
public static function enumeratePermissions($uid, array $obj)
|
||||
{
|
||||
$allow_people = expand_acl($obj['allow_cid']);
|
||||
$allow_groups = Group::expand(expand_acl($obj['allow_gid']));
|
||||
$allow_groups = Group::expand($uid, expand_acl($obj['allow_gid']));
|
||||
$deny_people = expand_acl($obj['deny_cid']);
|
||||
$deny_groups = Group::expand(expand_acl($obj['deny_gid']));
|
||||
$deny_groups = Group::expand($uid, expand_acl($obj['deny_gid']));
|
||||
$recipients = array_unique(array_merge($allow_people, $allow_groups));
|
||||
$deny = array_unique(array_merge($deny_people, $deny_groups));
|
||||
$recipients = array_diff($recipients, $deny);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue