From 844ab453f272569135b2cc9014b81e8567e8978c Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 10 Nov 2008 14:00:37 +0000 Subject: [PATCH] Updated read only handling for locks. -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 | 35 ++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 8f4a91aad..ba46e840d 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -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}
"; + return; + } + if(isset($cache['READ_ONLY'][$object])){ + echo "Removed lock entry $object
"; + 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
"; + return; + } + } + } + /* Check for existance and remove the entry */ $ldap= $config->get_ldap_link(); $ldap->cd ($config->get_cfg_value("config")); -- 2.30.2