mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-07 07:34:58 +00:00
add cleanNotifyList() which removes users/groups with read access
also adds an optional parameter $noclean to setDefaultAccess and setInheritAccess which keeps the methods from cleaning up the notifier list
This commit is contained in:
parent
ee8ad500ce
commit
75c8129185
|
@ -493,8 +493,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* will not have read access anymore.
|
* will not have read access anymore.
|
||||||
*
|
*
|
||||||
* @param integer $mode access mode
|
* @param integer $mode access mode
|
||||||
|
* @param boolean $noclean set to true if notifier list shall not be clean up
|
||||||
*/
|
*/
|
||||||
function setDefaultAccess($mode) { /* {{{ */
|
function setDefaultAccess($mode, $noclean="false") { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$queryStr = "UPDATE tblDocuments set defaultAccess = " . (int) $mode . " WHERE id = " . $this->_id;
|
$queryStr = "UPDATE tblDocuments set defaultAccess = " . (int) $mode . " WHERE id = " . $this->_id;
|
||||||
|
@ -503,26 +504,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
$this->_defaultAccess = $mode;
|
$this->_defaultAccess = $mode;
|
||||||
|
|
||||||
// If any of the notification subscribers no longer have read access,
|
if(!$noclean)
|
||||||
// remove their subscription.
|
self::cleanNotifyList();
|
||||||
if (empty($this->_notifyList))
|
|
||||||
$this->getNotifyList();
|
|
||||||
|
|
||||||
/* 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 ($this->_notifyList["users"] as $u) {
|
|
||||||
if ($this->getAccessMode($u) < M_READ) {
|
|
||||||
$this->removeNotify($u->getID(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($ngroups as $g) {
|
|
||||||
if ($this->getGroupAccessMode($g) < M_READ) {
|
|
||||||
$this->removeNotify($g->getID(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -540,9 +523,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
*
|
*
|
||||||
* @param boolean $inheritAccess set to true for setting and false for
|
* @param boolean $inheritAccess set to true for setting and false for
|
||||||
* unsetting inherited access mode
|
* unsetting inherited access mode
|
||||||
|
* @param boolean $noclean set to true if notifier list shall not be clean up
|
||||||
* @return boolean true if operation was successful otherwise false
|
* @return boolean true if operation was successful otherwise false
|
||||||
*/
|
*/
|
||||||
function setInheritAccess($inheritAccess) { /* {{{ */
|
function setInheritAccess($inheritAccess, $noclean=false) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$queryStr = "UPDATE tblDocuments SET inheritAccess = " . ($inheritAccess ? "1" : "0") . " WHERE id = " . $this->_id;
|
$queryStr = "UPDATE tblDocuments SET inheritAccess = " . ($inheritAccess ? "1" : "0") . " WHERE id = " . $this->_id;
|
||||||
|
@ -551,22 +535,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
$this->_inheritAccess = ($inheritAccess ? "1" : "0");
|
$this->_inheritAccess = ($inheritAccess ? "1" : "0");
|
||||||
|
|
||||||
// If any of the notification subscribers no longer have read access,
|
if(!$noclean)
|
||||||
// remove their subscription.
|
self::cleanNotifyList();
|
||||||
if(isset($this->_notifyList["users"])) {
|
|
||||||
foreach ($this->_notifyList["users"] as $u) {
|
|
||||||
if ($this->getAccessMode($u) < M_READ) {
|
|
||||||
$this->removeNotify($u->getID(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isset($this->_notifyList["groups"])) {
|
|
||||||
foreach ($this->_notifyList["groups"] as $g) {
|
|
||||||
if ($this->getGroupAccessMode($g) < M_READ) {
|
|
||||||
$this->removeNotify($g->getID(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -1252,6 +1222,33 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return $this->_notifyList;
|
return $this->_notifyList;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure only users/groups with read access are in the notify list
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function cleanNotifyList() { /* {{{ */
|
||||||
|
// If any of the notification subscribers no longer have read access,
|
||||||
|
// remove their subscription.
|
||||||
|
if (empty($this->_notifyList))
|
||||||
|
$this->getNotifyList();
|
||||||
|
|
||||||
|
/* 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 ($ngroups as $g) {
|
||||||
|
if ($this->getGroupAccessMode($g) < M_READ) {
|
||||||
|
$this->removeNotify($g->getID(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a user/group to the notification list
|
* Add a user/group to the notification list
|
||||||
* This function does not check if the currently logged in user
|
* This function does not check if the currently logged in user
|
||||||
|
|
|
@ -340,8 +340,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* will not have read access anymore.
|
* will not have read access anymore.
|
||||||
*
|
*
|
||||||
* @param integer $mode access mode
|
* @param integer $mode access mode
|
||||||
|
* @param boolean $noclean set to true if notifier list shall not be clean up
|
||||||
*/
|
*/
|
||||||
function setDefaultAccess($mode) { /* {{{ */
|
function setDefaultAccess($mode, $noclean=false) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$queryStr = "UPDATE tblFolders set defaultAccess = " . (int) $mode . " WHERE id = " . $this->_id;
|
$queryStr = "UPDATE tblFolders set defaultAccess = " . (int) $mode . " WHERE id = " . $this->_id;
|
||||||
|
@ -350,33 +351,29 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
|
|
||||||
$this->_defaultAccess = $mode;
|
$this->_defaultAccess = $mode;
|
||||||
|
|
||||||
// If any of the notification subscribers no longer have read access,
|
if(!$noclean)
|
||||||
// remove their subscription.
|
self::cleanNotifyList();
|
||||||
if (empty($this->_notifyList))
|
|
||||||
$this->getNotifyList();
|
|
||||||
|
|
||||||
/* 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 ($ngroups as $g) {
|
|
||||||
if ($this->getGroupAccessMode($g) < M_READ) {
|
|
||||||
$this->removeNotify($g->getID(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function inheritsAccess() { return $this->_inheritAccess; }
|
function inheritsAccess() { return $this->_inheritAccess; }
|
||||||
|
|
||||||
function setInheritAccess($inheritAccess) { /* {{{ */
|
/**
|
||||||
|
* Set inherited access mode
|
||||||
|
* Setting inherited access mode will set or unset the internal flag which
|
||||||
|
* controls if the access mode is inherited from the parent folder or not.
|
||||||
|
* It will not modify the
|
||||||
|
* access control list for the current object. It will remove all
|
||||||
|
* notifications of users which do not even have read access anymore
|
||||||
|
* after setting or unsetting inherited access.
|
||||||
|
*
|
||||||
|
* @param boolean $inheritAccess set to true for setting and false for
|
||||||
|
* unsetting inherited access mode
|
||||||
|
* @param boolean $noclean set to true if notifier list shall not be clean up
|
||||||
|
* @return boolean true if operation was successful otherwise false
|
||||||
|
*/
|
||||||
|
function setInheritAccess($inheritAccess, $noclean=false) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$inheritAccess = ($inheritAccess) ? "1" : "0";
|
$inheritAccess = ($inheritAccess) ? "1" : "0";
|
||||||
|
@ -387,20 +384,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
|
|
||||||
$this->_inheritAccess = $inheritAccess;
|
$this->_inheritAccess = $inheritAccess;
|
||||||
|
|
||||||
// If any of the notification subscribers no longer have read access,
|
if(!$noclean)
|
||||||
// remove their subscription.
|
self::cleanNotifyList();
|
||||||
if (empty($this->_notifyList))
|
|
||||||
$this->getNotifyList();
|
|
||||||
foreach ($this->_notifyList["users"] as $u) {
|
|
||||||
if ($this->getAccessMode($u) < M_READ) {
|
|
||||||
$this->removeNotify($u->getID(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($this->_notifyList["groups"] as $g) {
|
|
||||||
if ($this->getGroupAccessMode($g) < M_READ) {
|
|
||||||
$this->removeNotify($g->getID(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -1187,6 +1172,33 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return $this->_notifyList;
|
return $this->_notifyList;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure only users/groups with read access are in the notify list
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function cleanNotifyList() { /* {{{ */
|
||||||
|
// If any of the notification subscribers no longer have read access,
|
||||||
|
// remove their subscription.
|
||||||
|
if (empty($this->_notifyList))
|
||||||
|
$this->getNotifyList();
|
||||||
|
|
||||||
|
/* 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 ($ngroups as $g) {
|
||||||
|
if ($this->getGroupAccessMode($g) < M_READ) {
|
||||||
|
$this->removeNotify($g->getID(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a user/group to the notification list
|
* Add a user/group to the notification list
|
||||||
* This function does not check if the currently logged in user
|
* This function does not check if the currently logged in user
|
||||||
|
|
Loading…
Reference in New Issue
Block a user