From c579347ad1005491828e2790c820fe06f83d7788 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 3 Aug 2018 11:53:20 +0200 Subject: [PATCH] allow to identify real changes --- api/src/Accounts.php | 21 ++++++++++++--------- api/src/Acl.php | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/api/src/Accounts.php b/api/src/Accounts.php index 39ffd224a9..bc76d83862 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -890,6 +890,7 @@ class Accounts * * @param array $groups array with gidnumbers * @param int $account_id uidnumber + * @return boolean true: membership changed, false: no change necessary */ function set_memberships($groups,$account_id) { @@ -897,17 +898,19 @@ class Accounts { $account_id = $this->name2id($account_id); } - if (($old_memberships = $this->memberships($account_id, true)) != $groups) + if (($old_memberships = $this->memberships($account_id, true)) == $groups) { - $this->backend->set_memberships($groups, $account_id); - - if (!$old_memberships) $old_memberships = array(); - self::cache_invalidate(array_unique(array_merge( - array($account_id), - array_diff($old_memberships, $groups), - array_diff($groups, $old_memberships) - ))); + return false; // nothing changed } + $this->backend->set_memberships($groups, $account_id); + + if (!$old_memberships) $old_memberships = array(); + self::cache_invalidate(array_unique(array_merge( + array($account_id), + array_diff($old_memberships, $groups), + array_diff($groups, $old_memberships) + ))); + return true; } /** diff --git a/api/src/Acl.php b/api/src/Acl.php index 0a524da959..48c77fbda2 100644 --- a/api/src/Acl.php +++ b/api/src/Acl.php @@ -348,7 +348,7 @@ class Acl * @param int $account_id account id * @param int $rights rights * @param boolean $invalidate_session =true false: do NOT invalidate session - * @return boolean allways true + * @return int number of affected rows: 0: no change, 1: acl changed */ function add_repository($app, $location, $account_id, $rights, $invalidate_session=true) { @@ -366,7 +366,7 @@ class Acl { $GLOBALS['egw']->invalidate_session_cache(); } - return True; + return $this->db->affected_rows(); } /**