Code

Fixed lock handling for blocklists.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 14 May 2008 11:37:22 +0000 (11:37 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 14 May 2008 11:37:22 +0000 (11:37 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10889 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc
gosa-plugins/gofax/gofax/blocklists/main.inc

index 8d2d9b6fe4190761db61b0782a34c983d2f9e4cc..51bdd3da38ea4f36d0cab06a89a40ba1493a942f 100644 (file)
@@ -31,7 +31,7 @@ class blocklist extends plugin
     /* Call parent execute */
     plugin::execute();
 
-    session::set('LOCK_VARS_TO_USE',array("/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/"));
+    session::set('LOCK_VARS_TO_USE',array("/^menu_action/","/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/"));
 
     /***************
       Init vars 
@@ -122,7 +122,7 @@ class blocklist extends plugin
         isset($_POST['delete_blocklist_cancel']) ||
         isset($_POST['delete_lock'])){
 
-      del_lock ($this->dn);
+      $this->remove_lock();
       $this->dialog = NULL;
       session::un_set('objectinfo');
     }
@@ -143,7 +143,7 @@ class blocklist extends plugin
         $this->dialog->save ();
 
         if (!isset($_POST['edit_apply'])){
-          del_lock ($this->dn);
+          $this->remove_lock();
           $this->dn= "";
           $this->dialog = NULL;
           session::un_set('objectinfo');
@@ -212,19 +212,19 @@ class blocklist extends plugin
       $ids = $this->list_get_selected_items();
 
       if(count($ids)){
+
         foreach($ids as $id){
-          $dn = $this->blocklists[$id]['dn'];
-          if (($user= get_lock($dn)) != ""){
-            return(gen_locked_message ($user, $dn));
-          }
-          $this->dns[$id] = $dn;
+          $this->dns[$id]  = $this->blocklists[$id]['dn'];
+        }
+        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,_("blocklist")));
@@ -252,9 +252,9 @@ class blocklist extends plugin
           msg_dialog::display(_("Permission error"), msgPool::permDelete($dn), ERROR_DIALOG);
         }
         /* Remove lock file after successfull deletion */
-        del_lock ($dn);
-        unset($this->dns[$key]);
       }
+      $this->remove_lock();
+      $this->dns = array();
       $this->reload();
     }
 
@@ -266,7 +266,7 @@ class blocklist extends plugin
     /* Remove lock */
     if(isset($_POST['delete_multiple_blocklist_cancel'])){
       foreach($this->dns as $key => $dn){
-        del_lock ($dn);
+        $this->remove_lock();
         unset($this->dns[$key]);
       }
     }
@@ -305,7 +305,7 @@ class blocklist extends plugin
         $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn);
         $this->dialog->delete();
         $this->dialog = NULL;
-        del_lock ($this->dn);
+        $this->remove_lock();
       } else {
         msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
       }
@@ -477,6 +477,14 @@ class blocklist extends plugin
     return("");
   }
 
+
+  /*! \brief Remove entry locks if the plugin was aborted. 
+   */
+  function remove_lock()
+  {
+    if($this->dn) del_lock($this->dn);
+    if(is_array($this->dns) && count($this->dns)) del_lock($this->dns);
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index e39ced2a9384db365b3a0cf89a94590b23852924..745800383f71860102cbe1679f5725644b3d2c75 100644 (file)
@@ -2,7 +2,7 @@
 if ($remove_lock){
         if(session::is_set('blocklist')){
                 $blocklist = session::get('blocklist');
-                del_lock ($ui->dn);
+                $blocklist->remove_lock ($ui->dn);
                 session::un_set ('blocklist');
         }
 } else {