cvs: pear /LiveUser/Perm Medium.php
| From: | Lukas Smith | Date: | Tue, 21 Feb 2006 17:19:21 +0000 |
| Subject: | cvs: pear /LiveUser/Perm Medium.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38460@lists.php.net to get a copy of this message | ||
lsmith Tue Feb 21 17:19:21 2006 UTC
Modified files:
/pear/LiveUser/Perm Medium.php
Log:
- reworked handling of merging user with group rights *BC BREAK* (needs more testing)
http://cvs.php.net/viewcvs.cgi/pear/LiveUser/Perm/Medium.php?r1=1.19&r2=1.20&diff_format=u
Index: pear/LiveUser/Perm/Medium.php
diff -u pear/LiveUser/Perm/Medium.php:1.19 pear/LiveUser/Perm/Medium.php:1.20
--- pear/LiveUser/Perm/Medium.php:1.19 Mon Jan 23 12:40:26 2006
+++ pear/LiveUser/Perm/Medium.php Tue Feb 21 17:19:21 2006
@@ -40,7 +40,7 @@
* @author Bjoern Kraus <krausbn@php.net>
* @copyright 2002-2005 Markus Wolff
* @license http://www.gnu.org/licenses/lgpl.txt
- * @version CVS: $Id: Medium.php,v 1.19 2006/01/23 12:40:26 lsmith Exp $
+ * @version CVS: $Id: Medium.php,v 1.20 2006/02/21 17:19:21 lsmith Exp $
* @link http://pear.php.net/LiveUser
*/
@@ -137,11 +137,11 @@
foreach ($this->user_rights as $right => $level) {
if (isset($tmpRights[$right])) {
if ($level < 0) {
- // Revoking rights: A negative value indicates that the
- // right level is lowered or the right is even revoked
- // despite the group memberships of this user
- $tmpRights[$right] = $tmpRights[$right] + $level;
- } else {
+ // Revoking rights: A negative value indicates a maximum
+ // possible right level
+ $max_allowed_level = LIVEUSER_MAX_LEVEL + $level;
+ $tmpRights[$right] = min($tmpRights[$right], $max_allowed_level);
+ } elseif ($level > 0) {
$tmpRights[$right] = max($tmpRights[$right], $level);
}
} else {
@@ -153,9 +153,23 @@
// Strip values from array if level is not greater than zero
if (is_array($tmpRights)) {
foreach ($tmpRights as $right => $level) {
- if ($level > 0) {
- $this->rights[$right] = $level;
- }
+ if ($level < 0) {
+ $this->rights[$right] = (LIVEUSER_MAX_LEVEL + $level);
+ } elseif ($level > 0) {
+ $this->rights[$right] = $level;
+ }
+ }
+ }
+
+ // Strip values from array if level is equal to zero
+ // and shift negativ level to positive
+ if (is_array($this->user_rights)) {
+ foreach ($this->user_rights as $right => $level) {
+ if ($level < 0) {
+ $this->user_rights[$right] = LIVEUSER_MAX_LEVEL + $level;
+ } elseif ($level == 0) {
+ unset($this->user_rights[$right]);
+ }
}
}