Code

Updated locking for groups.-
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 May 2008 09:16:15 +0000 (09:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 May 2008 09:16:15 +0000 (09:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10908 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/groups/class_groupManagement.inc
gosa-core/plugins/admin/groups/main.inc

index 5cd2c527c7219599b3895f028dca35b61b3228a3..bcb71bd1a624236b73c6d8833bdedb25cadc5a4b 100644 (file)
@@ -35,6 +35,8 @@ class groupManagement extends plugin
   var $ShowPrimaryCheckBox= false; 
   var $start_pasting_copied_objects = FALSE;
 
+  var $dns = array();
+
   function groupManagement (&$config, &$ui)
   {
     /* Save configuration for internal use */
@@ -262,7 +264,7 @@ class groupManagement extends plugin
         if (!isset($_POST['edit_apply'])){
           /* Group has been saved successfully, remove lock from LDAP. */
           if ($this->dn != "new"){
-            del_lock ($this->dn);
+            $this->remove_lock();
           }
 
           /* There's no page reload so we have to read new groups at this point. */
@@ -342,19 +344,21 @@ class groupManagement extends plugin
 
       if(count($ids)){
 
+        $this->dns = array();
         foreach($ids as $id){
-          $dn = $this->grouplist[$id]['dn'];
-          if (($user= get_lock($dn)) != ""){
-            return(gen_locked_message ($user, $dn));
-          }
-          $this->dns[$id] = $dn;
+          $this->dns[$id] =  $this->grouplist[$id]['dn'];
+        }
+
+        /* Check locks */
+        if ($user= get_multiple_locks($this->dns)){
+          return(gen_locked_message($user,$this->dns));
         }
 
         $dns_names = array();
         foreach($this->dns as $dn){
-          add_lock ($dn, $this->ui->dn);
           $dns_names[] =@LDAP::fix($dn);
         }
+        add_lock ($this->dns, $this->ui->dn);
 
         /* Lock the current entry, so nobody will edit it during deletion */
         $smarty->assign("info", msgPool::deleteInfo($dns_names,_("group")));
@@ -393,10 +397,11 @@ class groupManagement extends plugin
             msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
             new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
           }
-          /* Remove lock file after successfull deletion */
-          del_lock ($dn);
-          unset($this->dns[$key]);
         }
+
+        /* Remove lock file after successfull deletion */
+        $this->remove_lock();
+        $this->dns = array();
       }
 
 
@@ -406,10 +411,10 @@ class groupManagement extends plugin
 
       /* Remove lock */
     if(isset($_POST['delete_multiple_user_cancel'])){
-      foreach($this->dns as $key => $dn){
-        del_lock ($dn);
-        unset($this->dns[$key]);
-      }
+
+      /* Remove lock file after successfull deletion */
+      $this->remove_lock();
+      $this->dns = array();
     }
 
 
@@ -479,7 +484,7 @@ class groupManagement extends plugin
       }
 
       /* Remove lock file after successfull deletion */
-      del_lock ($this->dn);
+      $this->remove_lock();
       session::un_set('objectinfo');
     }
 
@@ -490,7 +495,7 @@ class groupManagement extends plugin
 
     /* Delete group canceled? */
     if (isset($_POST['delete_cancel'])){
-      del_lock ($this->dn);
+      $this->remove_lock();
       session::un_set('objectinfo');
     }
     
@@ -502,9 +507,8 @@ class groupManagement extends plugin
     /* Cancel dialogs */
     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
       if(isset($this->grouptab->dn)){
-        del_lock ($this->grouptab->dn);
+        $this->remove_lock();
       }
-      unset ($this->grouptab);
       $this->grouptab= NULL;
       session::un_set('objectinfo');
     }
@@ -778,6 +782,12 @@ class groupManagement extends plugin
     if (isset($this->grouptab->dn)){
       del_lock ($this->grouptab->dn);
     }
+    if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
+      del_lock($this->dn);
+    }
+    if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
+      del_lock($this->dns);
+    }
   }
 
 
index 6bbaeb9ef4e1d7bb148bae764ccee59ff3d00f30..aeb3b0febfc9ad975dbff88e6b933923c4f792df 100644 (file)
@@ -24,7 +24,6 @@ if ($remove_lock){
   if(session::is_set('groupManagement')){
     $groupManagement = session::get('groupManagement');
     $groupManagement->remove_lock();
-    del_lock ($ui->dn);
     session::un_set ('groupManagement');
   }
 } else {