Code

Updated read only handling for locks.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 10 Nov 2008 14:00:37 +0000 (14:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 10 Nov 2008 14:00:37 +0000 (14:00 +0000)
-Do not remove any locks for "read only" entries.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12984 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/functions.inc

index 8f4a91aad595ccd8138f7dccbe987170d0010eaf..ba46e840db640eba6469a22e0dd6418e9ac46c74 100644 (file)
@@ -595,10 +595,28 @@ function ldap_expired_account($config, $userdn, $username)
 }
 
 
-function add_lock ($object, $user)
+function add_lock($object, $user)
 {
   global $config;
 
+  /* Remember which entries were opened as read only, because we 
+      don't need to remove any locks for them later.
+   */
+  if(!session::is_set("LOCK_CACHE")){
+    session::set("LOCK_CACHE",array(""));
+  }
+  $cache = &session::get("LOCK_CACHE");
+  if(isset($_POST['open_readonly'])){
+    $cache['READ_ONLY'][$object] = TRUE;
+    echo "ADDED : {$user}:{$object}<br>";
+    return;
+  }
+  if(isset($cache['READ_ONLY'][$object])){
+    echo "Removed lock entry $object <br>";
+    unset($cache['READ_ONLY'][$object]);
+  }
+
+
   if(is_array($object)){
     foreach($object as $obj){
       add_lock($obj,$user);
@@ -656,6 +674,21 @@ function del_lock ($object)
     return;
   }
 
+  /* If this object was opened in read only mode then 
+      skip removing the lock entry, there wasn't any lock created.
+    */
+  if(session::is_set("LOCK_CACHE")){
+    $cache = &session::get("LOCK_CACHE");
+    if(isset($cache['READ_ONLY'][$object])){
+      if(isset($_POST['delete_lock'])){
+        unset($cache['READ_ONLY'][$object]);
+      }else{
+        echo "Skipped: $object <br>";
+        return;
+      }
+    }
+  }
+
   /* Check for existance and remove the entry */
   $ldap= $config->get_ldap_link();
   $ldap->cd ($config->get_cfg_value("config"));