Code

Added some logging
[gosa.git] / plugins / admin / users / class_userManagement.inc
index 2a79cf9b64e7c4d045d127ee380c527c59db16f4..d11e22d654f7f57f63139e151413e461c0e37e69 100644 (file)
@@ -60,7 +60,7 @@ class userManagement extends plugin
     plugin::execute();
 
     /* LOCK MESSAGE Vars */
-    $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_user/");
+    $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_users/");
 
     $smarty       = get_smarty();                 // Smarty instance
     $s_action     = "";                           // Contains the action to be taken
@@ -79,7 +79,7 @@ class userManagement extends plugin
       foreach(array("del"       => "user_del",    "edit"      => "user_edit",
                     "new"       => "user_new",
                     "new_tpl"   => "user_tplnew",
-                    "del_multiple" => "^remove_multiple_user",
+                    "del_multiple" => "^remove_multiple_users",
                     "create_user_from_tpl"          => "userfrom_tpl",
                     "change_pw" => "user_chgpw", 
                     "editPaste" => "editPaste",   "copy"      => "copy",
@@ -295,25 +295,32 @@ class userManagement extends plugin
     if ($s_action=="del_multiple"){
       $ids = $this->list_get_selected_items();
 
-      foreach($ids as $id){
-        $dn = $this->list[$id]['dn'];
-        if (($user= get_lock($dn)) != ""){
-          return(gen_locked_message ($user, $dn));
+      if(count($ids)){
+
+        foreach($ids as $id){
+          $dn = $this->list[$id]['dn'];
+          if (($user= get_lock($dn)) != ""){
+            return(gen_locked_message ($user, $dn));
+          }
+          $this->dns[$id] = $dn; 
         }
-        $this->dns[$id] = $dn; 
-      }
 
-      $dns_names = "<br><pre>";
-      foreach($this->dns as $dn){
-        add_lock ($dn, $this->ui->dn);
-        $dns_names .= $dn."\n";
-      }
-      $dns_names .="</pre>";
+        $dns_names = "<br><pre>";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="</pre>";
 
-      /* Lock the current entry, so nobody will edit it during deletion */
-      $smarty->assign("info",     sprintf(_("You're about to delete the following user(s) %s"), @LDAP::fix($dns_names)));
-      $smarty->assign("multiple", true);
-      return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+        /* Lock the current entry, so nobody will edit it during deletion */
+        if (count($this->dns) == 1){
+          $smarty->assign("info",     sprintf(_("You're about to delete the following entry: %s"), @LDAP::fix($dns_names)));
+        } else {
+          $smarty->assign("info",     sprintf(_("You're about to delete the following entries: %s"), @LDAP::fix($dns_names)));
+        }
+        $smarty->assign("multiple", true);
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+      }
     }
 
 
@@ -345,10 +352,24 @@ class userManagement extends plugin
           }
           /* Remove lock file after successfull deletion */
           del_lock ($dn);
+          unset($this->dns[$key]);
       }
     }
 
 
+    /********************
+      Delete MULTIPLE entries Canceled 
+     ********************/
+
+    /* Remove lock */
+    if(isset($_POST['delete_multiple_user_cancel'])){
+      foreach($this->dns as $key => $dn){
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+  
+
     /********************
       Delete entry requested, display confirm dialog
      ********************/