File HK-GW-turba_2.2_RC1-Ldap_read_only_fix.patch of Package horde3-turba
This is a temporary fix to mark the ldap addressbook as read-only. This should be solved with the Horde Perms package but this needs a new driver.
diff -r 449ef255c5ff turba/lib/Driver/ldap.php
--- a/turba/lib/Driver/ldap.php Wed Nov 28 17:24:17 2007 +0100
+++ b/turba/lib/Driver/ldap.php Wed Nov 28 17:26:17 2007 +0100
@@ -53,6 +53,9 @@ class Turba_Driver_ldap extends Turba_Dr
}
if (empty($params['deref'])) {
$params['deref'] = LDAP_DEREF_NEVER;
+ }
+ if (empty($params['read_only'])) {
+ $params['read_only'] = false;
}
parent::Turba_Driver($params);
@@ -749,4 +752,25 @@ class Turba_Driver_ldap extends Turba_Dr
return $dn;
}
+ /**
+ * Checks if the current user has the requested permission
+ * on this source.
+ *
+ * @param integer $perm The permission to check for.
+ *
+ * @return boolean true if user has permission, false otherwise.
+ */
+ function hasPermission($perm)
+ {
+ if ($this->_params['read_only'] === false) {
+ return parent::hasPermission($perm);
+ } else {
+ switch ($perm) {
+ case PERMS_EDIT: return false;
+ case PERMS_DELETE: return false;
+ default: return parent::hasPermission($perm);
+ }
+ }
+ }
+
}