Code

Updated userManagement -> Remove user(s)
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Apr 2008 07:07:48 +0000 (07:07 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Apr 2008 07:07:48 +0000 (07:07 +0000)
-Removed notification that user was successfully removed
-Simplified code, we don't need seperate handling for single or multiple user deletion

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

gosa-core/plugins/admin/users/class_userManagement.inc
gosa-core/plugins/admin/users/remove.tpl

index 6e30cb359b6eba8ca39fd618913674b327bcff35..e459784b26451d60537dcdfdbe38372d750ffc4d 100644 (file)
@@ -38,7 +38,6 @@ class userManagement extends plugin
   var $pwd_change_queue     = array();
 
   var $start_pasting_copied_objects = FALSE;
-  var $current_action ="";
   var $msg_dialog= NULL;
   
   function userManagement(&$config, $ui)
@@ -541,11 +540,19 @@ class userManagement extends plugin
       Delete MULTIPLE entries requested, display confirm dialog
      ********************/
 
-    if ($s_action=="del_multiple"){
-      $ids = $this->list_get_selected_items();
+    if ($s_action=="del_multiple" || $s_action == "del"){
+
+      if($s_action == "del"){
+
+        /* Get 'dn' from posted 'uid' */
+        $ids = array($s_entry);
+      }else{
+        $ids = $this->list_get_selected_items();
+      }
+
       $this->dns = array();
-      if(count($ids)){
 
+      if(count($ids)){
         foreach($ids as $id){
           $dn = $this->list[$id]['dn'];
           if (($user= get_lock($dn)) != ""){
@@ -561,8 +568,12 @@ class userManagement extends plugin
 
         /* Lock the current entry, so nobody will edit it during deletion */
         $info = sprintf(msgPool::deleteInfo($dns_names,_("user")));
-        $this->msg_dialog = new msg_dialog(_("Delete users"),$info,CONFIRM_DIALOG);
-        $this->current_action = $s_action;
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        $smarty->assign("info", msgPool::deleteInfo($dns_names));
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+
+
       }
     }
 
@@ -571,10 +582,7 @@ class userManagement extends plugin
       Delete MULTIPLE entries confirmed 
      ********************/
 
-      /* Confirmation for deletion has been passed. Users should be deleted. */
-      if ($this->current_action == "del_multiple" && is_object($this->msg_dialog) && $this->msg_dialog->is_confirmed()){
-        
-        $this->current_action = "";  
+      if(isset($_POST['delete_user_confirm'])){
         
         /* Remove user by user and check acls before removeing them */
         foreach($this->dns as $key => $dn){
@@ -600,19 +608,6 @@ class userManagement extends plugin
       }
     }
 
-
-    /********************
-      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]);
-      }
-    }
-  
   
     /********************
       Toggle lock status for user
@@ -652,76 +647,16 @@ class userManagement extends plugin
     }
 
 
-    /********************
-      Delete entry requested, display confirm dialog
-     ********************/
-
-    /* Remove user was requested */
-    if ($s_action=="del"){
-
-      /* Get 'dn' from posted 'uid' */
-      $this->dn= $this->list[trim($s_entry)]['dn'];
-
-      /* Load permissions for selected 'dn' and check if
-         we're allowed to remove this 'dn' */
-
-      /* Check locking, save current plugin in 'back_plugin', so
-         the dialog knows where to return. */
-      if (($user= get_lock($this->dn)) != ""){
-        return(gen_locked_message ($user, $this->dn));
-      }
-
-      $this->msg_dialog = new msg_dialog( _("Delete user"),msgPool::deleteInfo(@LDAP::fix($this->dn),_("user")),CONFIRM_DIALOG);
-      $this->current_action = $s_action;
-    }
-
-
-    /********************
-      Delete entry confirmed 
-     ********************/
-
-    /* Confirmation for deletion has been passed. User should be deleted. */
-    if ($this->current_action == "del" && is_object($this->msg_dialog) && $this->msg_dialog->is_confirmed()){
-
-      $this->current_action = ""; 
-      /* Some nice guy may send this as POST, so we've to check
-         for the permissions again. */
-
-      $acl = $this->ui->get_permissions($this->dn, "users/user"); 
-      if (preg_match('/d/', $acl)){
-
-        /* Delete request is permitted, perform LDAP action */
-        $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$this->dn);
-        $this->usertab->set_acl_base();
-        $this->usertab->delete ();
-        unset ($this->usertab);
-        $this->usertab= NULL;
-        msg_dialog::display(_("Information"),_("User successfully removed."),INFO_DIALOG);
-      } else {
-
-        /* Normally this shouldn't be reached, send some extra
-           logs to notify the administrator */
-        msg_dialog::display(_("Warning"),msgPool::permDelete(),WARNING_DIALOG);
-
-        if(isset($this->ui->uid)){
-          new log("security","users/".get_class($this),$this->dn,array(),"Tried to trick deletion.");
-        }
-      }
-
-      /* Remove lock file after successfull deletion */
-      del_lock ($this->dn);
-    }
-
-    
     /********************
       Delete entry Canceled 
      ********************/
 
     /* Delete user canceled? */
     if (isset($_POST['delete_cancel'])){
-      del_lock ($this->dn);
+      foreach($this->dns as $key => $dn){
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
     }
 
 
index 8424e740118ed9109f38d56a435dc569e825da35..644c7352a53595c2bd2d6f155b68ad073af3b434 100644 (file)
 </p>
 
 <p class="plugbottom">
-  {if $multiple}
-  <input type=submit name="delete_multiple_user_confirm" value="{msgPool type=delButton}">
-  <input type=submit name="delete_multiple_user_cancel" value="{msgPool type=cancelButton}">
-  {else}
   <input type=submit name="delete_user_confirm" value="{msgPool type=delButton}">
   <input type=submit name="delete_cancel" value="{msgPool type=cancelButton}">
-  {/if}
   &nbsp;
 </p>