Code

Updated locking for devices.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 May 2008 07:43:27 +0000 (07:43 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 May 2008 07:43:27 +0000 (07:43 +0000)
-Fixed undefined index intro in remove.tpl
-Fixed locking.

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

gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
gosa-plugins/goto/admin/mimetypes/main.inc
gosa-plugins/goto/admin/mimetypes/remove.tpl

index 037b243439ee35e22ae66211f875ac3911c4882c..debe254ddf49d02241bce4327c278e5e2880de6b 100644 (file)
@@ -132,7 +132,7 @@ class mimetypeManagement extends plugin
     /* These vars will be stored if you try to open a locked mime, 
         to be able to perform your last requests after showing a warning message */
     session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^mime_edit_/","/^mime_del_/",
-          "/^item_selected/","/^remove_multiple_mimetypes/"));
+          "/^item_selected/","/^remove_multiple_mimetypes/","/^menu_action/"));
 
     $smarty       = get_smarty();             // Smarty instance
     $s_action     = "";                       // Contains the action to proceed
@@ -236,8 +236,7 @@ class mimetypeManagement extends plugin
 
     /* Cancel dialogs */
     if (isset($_POST['edit_cancel'])){
-      del_lock ($this->mimetabs->dn);
-      unset ($this->mimetabs);
+      $this->remove_lock();
       $this->mimetabs= NULL;
       session::un_set('objectinfo');
     }
@@ -264,7 +263,7 @@ class mimetypeManagement extends plugin
         if (!isset($_POST['edit_apply'])){
           /* Mime type has been saved successfully, remove lock from LDAP. */
           if ($this->dn != "new"){
-            del_lock ($this->dn);
+            $this->remove_lock();
           }
           unset ($this->mimetabs);
           $this->mimetabs= NULL;
@@ -323,21 +322,23 @@ class mimetypeManagement extends plugin
       if(count($ids)){
 
         foreach($ids as $id){
-          $dn = $this->mimetypes[$id]['dn'];
-          if (($user= get_lock($dn)) != ""){
-            return(gen_locked_message ($user, $dn));
-          }
-          $this->dns[$id] = $dn;
+          $this->dns[$id] = $this->mimetypes[$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("intro", msgPool::deleteInfo($dns_names,_("Mime type")));
+        $smarty->assign("info", msgPool::deleteInfo($dns_names,_("Mime type")));
         $smarty->assign("multiple", true);
         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
       }
@@ -373,10 +374,11 @@ class mimetypeManagement extends plugin
           msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
           new log("security","mimetypes/".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();
     }
 
 
@@ -386,10 +388,8 @@ class mimetypeManagement extends plugin
 
     /* Remove lock */
     if(isset($_POST['delete_multiple_mimetype_cancel'])){
-      foreach($this->dns as $key => $dn){
-        del_lock ($dn);
-        unset($this->dns[$key]);
-      }
+      $this->remove_lock();
+      $this->dns = array();
     }
 
 
@@ -460,7 +460,7 @@ class mimetypeManagement extends plugin
       }
 
       /* Remove lock file after successfull deletion */
-      del_lock ($this->dn);
+      $this->remove_lock();
     }
 
 
@@ -470,7 +470,7 @@ class mimetypeManagement extends plugin
 
     /* Delete mime type canceled? */
     if (isset($_POST['delete_cancel'])){
-      del_lock ($this->dn);
+      $this->remove_lock();
       session::un_set('objectinfo');
     }
 
@@ -671,6 +671,12 @@ class mimetypeManagement extends plugin
     if (isset($this->mimetabs->dn)){
       del_lock ($this->mimetabs->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);
+    }
   }
 
   function save_object() 
index 29870f1302e3d860823d34a5131cc67b0c426f98..a9a7b0b0557bb0f149f3ae2939752c78a36ffac9 100644 (file)
  */
 
 if ($remove_lock){
-               if(session::is_set('MimeTypeManagement')){
-                               $MimeTypeManagement = session::get('MimeTypeManagement');
-                               $MimeTypeManagement->remove_lock();
-                               del_lock ($ui->dn);
-                               session::un_set ('MimeTypeManagement');
-               }
+  if(session::is_set('MimeTypeManagement')){
+    $MimeTypeManagement = session::get('MimeTypeManagement');
+    $MimeTypeManagement->remove_lock();
+    session::un_set ('MimeTypeManagement');
+  }
 } else {
 
-               /* Create MimeTypeManagement object on demand */
-               if (!session::is_set('MimeTypeManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
-                       session::set('MimeTypeManagement',new mimetypeManagement ($config, $ui));
-               }
-
-               /* Get object */
-               $MimeTypeManagement = session::get('MimeTypeManagement');
-               $MimeTypeManagement->save_object();
-               $output= $MimeTypeManagement->execute();
-
-               /* Page header*/
-               if (session::is_set('objectinfo')){
-                               $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png')."\"> ".@LDAP::fix(session::get('objectinfo')));
-               } else {
-                               $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"));
-               }
-
-               /* Reset requested? */
-               if (isset($_GET['reset']) && $_GET['reset'] == 1){
-                               del_lock ($ui->dn);
-                               session::un_set ('MimeTypeManagement');
-               }
-
-               /* Show and save dialog */
-               $display.= $output;
-               session::set('MimeTypeManagement',$MimeTypeManagement);
+  /* Create MimeTypeManagement object on demand */
+  if (!session::is_set('MimeTypeManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+    session::set('MimeTypeManagement',new mimetypeManagement ($config, $ui));
+  }
+
+  /* Get object */
+  $MimeTypeManagement = session::get('MimeTypeManagement');
+  $MimeTypeManagement->save_object();
+  $output= $MimeTypeManagement->execute();
+
+  /* Page header*/
+  if (session::is_set('objectinfo')){
+    $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png')."\"> ".@LDAP::fix(session::get('objectinfo')));
+  } else {
+    $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"));
+  }
+
+  /* Reset requested? */
+  if (isset($_GET['reset']) && $_GET['reset'] == 1){
+    del_lock ($ui->dn);
+    session::un_set ('MimeTypeManagement');
+  }
+
+  /* Show and save dialog */
+  $display.= $output;
+  session::set('MimeTypeManagement',$MimeTypeManagement);
 }
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 68e79ad529791f7800d45f82e450068e57a700af..440fc2447539d837f2bc3f94087e39d2c0ac7ba0 100644 (file)
@@ -2,7 +2,7 @@
   <img alt="" src="images/warning.png" align=top>&nbsp;{t}Warning{/t}
 </div>
 <p>
- {$intro}
+ {$info}
  {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
 </p>
 <p>