From 6f0728cd9dd16dc7417bc576681735e7283f3e63 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 6 Mar 2016 16:09:58 +0000 Subject: [PATCH] fix for different return values of accounts->member(s) / membership(s) --- calendar/inc/class.calendar_bo.inc.php | 25 ++++++++++---------- calendar/inc/class.calendar_boupdate.inc.php | 17 +++++++------ calendar/inc/class.calendar_ui.inc.php | 3 +-- calendar/inc/class.calendar_uiviews.inc.php | 3 +-- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 5d56ad197e..bfb5e2827d 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -337,11 +337,10 @@ class calendar_bo foreach(array_keys($event['participants']) as $uid) { if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' && - ($members = $GLOBALS['egw']->accounts->members($uid))) + ($members = $GLOBALS['egw']->accounts->members($uid, true))) { foreach($members as $member) { - $member = $member['account_id']; if (!isset($event['participants'][$member])) { $event['participants'][$member] = 'G'; @@ -392,30 +391,30 @@ class calendar_bo { if ($no_enum_groups) continue; - $members = $GLOBALS['egw']->accounts->members($user); + $members = $GLOBALS['egw']->accounts->members($user, true); if (is_array($members)) { foreach($members as $member) { // use only members which gave the user a read-grant - if (!in_array($member['account_id'],$users) && - ($ignore_acl || $this->check_perms(EGW_ACL_READ|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$member['account_id']))) + if (!in_array($member, $users) && + ($ignore_acl || $this->check_perms(EGW_ACL_READ|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$member))) { - $users[] = $member['account_id']; + $users[] = $member; } } } } else // for users we have to include all the memberships, to get the group-events { - $memberships = $GLOBALS['egw']->accounts->memberships($user); + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); if (is_array($memberships)) { foreach($memberships as $group) { - if (!in_array($group['account_id'],$users)) + if (!in_array($group,$users)) { - $users[] = $group['account_id']; + $users[] = $group; } } } @@ -1693,13 +1692,13 @@ class calendar_bo { self::_list_cals_add($id,$users,$groups); } - if (($memberships = $GLOBALS['egw']->accounts->memberships($user))) + if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true))) { - foreach($memberships as $group_info) + foreach($memberships as $group) { - self::_list_cals_add($group_info['account_id'],$users,$groups); + self::_list_cals_add($group,$users,$groups); - if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group_info['account_id'],EGW_ACL_READ,'calendar'))) + if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,EGW_ACL_READ,'calendar'))) { foreach($account_perms as $id) { diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index de33ca24c8..4e7b635c71 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -759,11 +759,10 @@ class calendar_boupdate extends calendar_bo foreach($to_notify as $userid => $statusid) { if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && - ($members = $GLOBALS['egw']->accounts->members($userid))) + ($members = $GLOBALS['egw']->accounts->members($userid, true))) { foreach($members as $member) { - $member = $member['account_id']; if (!isset($to_notify[$member])) { $to_notify[$member] = 'G'; // Group-invitation @@ -2084,30 +2083,30 @@ class calendar_boupdate extends calendar_bo // for groups we have to include the members if ($GLOBALS['egw']->accounts->get_type($user) == 'g') { - $members = $GLOBALS['egw']->accounts->members($user); + $members = $GLOBALS['egw']->accounts->members($user, true); if (is_array($members)) { foreach($members as $member) { // use only members which gave the user a read-grant - if (!in_array($member['account_id'],$users) && - $this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY,0,$member['account_id'])) + if (!in_array($member, $users) && + $this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY, 0, $member)) { - $users[] = $member['account_id']; + $users[] = $member; } } } } else // for users we have to include all the memberships, to get the group-events { - $memberships = $GLOBALS['egw']->accounts->memberships($user); + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); if (is_array($memberships)) { foreach($memberships as $group) { - if (!in_array($group['account_id'],$users)) + if (!in_array($group, $users)) { - $users[] = $group['account_id']; + $users[] = $group; } } } diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index f323a206f2..b240b632a4 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -186,9 +186,8 @@ class calendar_ui $owner = trim($owner); if (is_numeric($owner) && $GLOBALS['egw']->accounts->get_type($owner) == 'g') { - foreach($GLOBALS['egw']->accounts->members($owner) as $member) + foreach($GLOBALS['egw']->accounts->members($owner, true) as $member) { - $member = $member['account_id']; if (!$this->bo->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$member)) { $no_access_group[$member] = $this->bo->participant_name($member); diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index 3f391e7004..16fe82f976 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -2200,9 +2200,8 @@ class calendar_uiviews extends calendar_ui } elseif ($enum_groups && $GLOBALS['egw']->accounts->get_type($user) == 'g') // groups { - foreach((array) $GLOBALS['egw']->accounts->members($user) as $data) + foreach((array) $GLOBALS['egw']->accounts->members($user, true) as $user) { - $user = $data['account_id']; if ($this->bo->check_perms(EGW_ACL_READ | EGW_ACL_FREEBUSY,0,$user)) { $users[$user] = $this->bo->participant_name($user);