From 92299df0ea001b6d7670d155e346b0284393a5cb Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 19 Jun 2015 12:47:30 +0200 Subject: [PATCH] setDefaultAccess() cleanly removes als notifiers without read access This failed because the first call of removeNotify() has invalidated the list of notifiers --- SeedDMS_Core/Core/inc.ClassFolder.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index 2c30c7fb7..257e56ef8 100644 --- a/SeedDMS_Core/Core/inc.ClassFolder.php +++ b/SeedDMS_Core/Core/inc.ClassFolder.php @@ -284,6 +284,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $this->_defaultAccess; } /* }}} */ + /** + * Set default access mode + * + * This method sets the default access mode and also removes all notifiers which + * will not have read access anymore. + * + * @param integer $mode access mode + */ function setDefaultAccess($mode) { /* {{{ */ $db = $this->_dms->getDB(); @@ -297,12 +305,18 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { // remove their subscription. if (empty($this->_notifyList)) $this->getNotifyList(); - foreach ($this->_notifyList["users"] as $u) { + + /* Make a copy of both notifier lists because removeNotify will empty + * $this->_notifyList and the second foreach will not work anymore. + */ + $nusers = $this->_notifyList["users"]; + $ngroups = $this->_notifyList["groups"]; + foreach ($nusers as $u) { if ($this->getAccessMode($u) < M_READ) { $this->removeNotify($u->getID(), true); } } - foreach ($this->_notifyList["groups"] as $g) { + foreach ($ngroups as $g) { if ($this->getGroupAccessMode($g) < M_READ) { $this->removeNotify($g->getID(), false); }