[turba] Patch: To fix admin privs in turba HEAD and REL

tom burkart turba at aussec.com
Thu Aug 21 01:43:34 PDT 2003


Recently the question was asked on the list in regard to administrator
edit privileges not working properly.

The attached patches will fix this problem for the following cases:
 - There is more than one administrator.
 - The administrator was appointed AFTER users had created their own
address book entries AND the address book was changed to read only.

HEAD is as of the snapshot on 2003-08-20.

tom.
Consultant

AUSSEC    Phone: 61 4 1768 2202
339 Blaxland Rd., Ryde NSW 2112
Email: tom at aussec.com
-------------- next part --------------
--- turba-1.2/lib/AbstractObject.php.org	Wed Mar 12 14:29:10 2003
+++ turba-1.2/lib/AbstractObject.php	Mon Jul  7 13:56:58 2003
@@ -107,7 +107,8 @@
         if ($this->source->readonly) {
             return false;
         } else if ($this->hasValue('__owner') &&
-                   $this->getValue('__owner') != Auth::getAuth()) {
+                   $this->getValue('__owner') != Auth::getAuth() &&
+		   !$this->source->administrator) {
             return false;
         }
 
--- turba-1.2/lib/Source.php.org	Wed Mar 12 14:29:10 2003
+++ turba-1.2/lib/Source.php	Mon Jul  7 13:54:55 2003
@@ -37,6 +37,9 @@
     /** Boolean indicating whether this source is read-only (not editable). */
     var $readonly = true;
 
+    /** Boolean indicating whether this user has admin privs (for isEditable) */
+    var $administrator = false;
+
     /**
      * Static method to contruct Turba_Source objects. Use this so
      * that we can return PEAR_Error objects if anything goes
@@ -78,6 +81,9 @@
             $object->readonly = $source['readonly']
                                 && (!isset($source['admin']) || !in_array(Auth::getAuth(), $source['admin']));
         }
+	if (isset($source['admin']) && in_array(Auth::getAuth(), $source['admin'])) {
+	    $object->administrator = true;
+	}
 
         return $object;
     }
-------------- next part --------------
diff -uNr turba.org/lib/AbstractObject.php turba/lib/AbstractObject.php
--- turba.org/lib/AbstractObject.php	Tue Feb 18 16:08:48 2003
+++ turba/lib/AbstractObject.php	Thu Aug 21 18:32:50 2003
@@ -120,7 +120,8 @@
         if ($this->source->readonly) {
             return false;
         } else if ($this->hasValue('__owner') &&
-                   $this->getValue('__owner') != Auth::getAuth()) {
+                   $this->getValue('__owner') != Auth::getAuth() &&
+		   !$this->source->administrator) {
             return false;
         }
 
diff -uNr turba.org/lib/Source.php turba/lib/Source.php
--- turba.org/lib/Source.php	Tue Feb 18 16:47:20 2003
+++ turba/lib/Source.php	Thu Aug 21 18:32:50 2003
@@ -35,6 +35,9 @@
     /** Boolean indicating whether this source is read-only (not editable). */
     var $readonly = true;
 
+    /** Boolean indicating whether this user has admin privs (for isEditable) */
+    var $administrator = false;
+
     /**
      * Any admins for this source.
      * @var array $admin
@@ -87,6 +90,9 @@
             $object->readonly = $source['readonly']
                                 && (!isset($source['admin']) || !in_array(Auth::getAuth(), $source['admin']));
         }
+	if (isset($source['admin']) && in_array(Auth::getAuth(), $source['admin'])) {
+	    $object->administrator = true;
+	}
 
         return $object;
     }


More information about the turba mailing list