Code

Added multiple edit to user (initial)
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 17 Oct 2007 12:36:08 +0000 (12:36 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 17 Oct 2007 12:36:08 +0000 (12:36 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7584 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_plugin.inc
include/class_tabs.inc
plugins/admin/users/class_divListUsers.inc
plugins/admin/users/class_userManagement.inc
plugins/personal/generic/class_user.inc

index 85082ed23503f08d30d76bca1fce86cb3b8a3c8c..ccb7e5406d772e97cd0eb290aec7ba1a32215e1e 100644 (file)
@@ -118,6 +118,10 @@ class plugin
   /* This can be set to render the tabulators in another stylesheet */
   var $pl_notify= FALSE;
 
+
+  /* This variable indicates that this class can handle multiple dns at once. */
+  var $multiple_support = FALSE; 
+
   /*! \brief plugin constructor
 
     If 'dn' is set, the node loads the given 'dn' from LDAP
index c543065b22dee48da42e42047218e2cc3695155f..c7be1b78462ceddbb2109e8db8c5609e1a66559b 100644 (file)
@@ -33,6 +33,8 @@ class tabs
   var $by_object= array();
   var $SubDialog = false;
 
+  var $multiple_entries = FALSE;
+
   function tabs(&$config, $data, $dn, $acl_category= "")
   {
     /* Save dn */
@@ -41,7 +43,27 @@ class tabs
 
     $baseobject= NULL;
 
+    /* Check specified dn 
+     */
+    if(is_string($dn)){
+
+    }elseif(is_array($dn)&&count($dn) == 1){
+      $this->dn = $dn[key($dn)];
+    }elseif(is_array($dn)&&count($dn) > 1){
+      $this->multiple_entries = TRUE;
+    }
+
+
     foreach ($data as &$tab){
+
+      /* Check we want to handle multiple obejcts at once 
+       *  and if this is supported by enabled plugins 
+       */
+      $tmp = get_class_vars($tab['CLASS']);
+      if($this->multiple_entries  && !$tmp['multiple_support']){
+        continue;
+      } 
+
       $this->by_name[$tab['CLASS']]= $tab['NAME'];
 
       if ($baseobject === NULL){
@@ -59,6 +81,11 @@ class tabs
         $this->current= $tab['CLASS'];
       }
     }
+
+    /* Return false if tabs */
+    if(!count($this->by_object)){
+      return(FALSE);
+    }
   }
 
   function execute()
@@ -310,12 +337,14 @@ class tabs
 
   function addSpecialTabs()
   {
-    $this->by_name['acl']= _("ACL");
-    $this->by_object['acl']= new acl($this->config, $this, $this->dn);
-    $this->by_object['acl']->parent= &$this;
-    $this->by_name['reference']= _("References");
-    $this->by_object['reference']= new reference($this->config, $this->dn);
-    $this->by_object['reference']->parent= &$this;
+    if(!is_array($this->dn)){
+      $this->by_name['acl']= _("ACL");
+      $this->by_object['acl']= new acl($this->config, $this, $this->dn);
+      $this->by_object['acl']->parent= &$this;
+      $this->by_name['reference']= _("References");
+      $this->by_object['reference']= new reference($this->config, $this->dn);
+      $this->by_object['reference']->parent= &$this;
+    }
   }
 
 
index 5a1c550d7edd371af5f82ef951aebd9957e51932..5f4639e8e5ac5535ff0914989ebd6d01fbce6042 100644 (file)
@@ -168,6 +168,8 @@ class divListUsers extends MultiSelectWindow
         title='"._("Remove selected user")."' alt='"._("Remove user")."' name='remove_multiple_users'>&nbsp;";
     $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/list_password.png'
         title='"._("Change password")."' alt='"._("Change password")."' name='multiple_password_change'>&nbsp;";
+    $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/edit.png'
+        title='"._("Edit")."' alt='"._("Edit")."' name='multiple_edit'>&nbsp;";
 
     /* Add multiple copy & cut icons */
     if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
index 44c6dc30ad0d2d217558d87ffa2030ef57b32f80..1f12ef09915f27b0c2e1d73c44cf61769e2f9ecf 100644 (file)
@@ -62,7 +62,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_users/");
+    $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_users/","/^multiple_edit/");
 
     $smarty       = get_smarty();                 // Smarty instance
     $s_action     = "";                           // Contains the action to be taken
@@ -78,7 +78,8 @@ class userManagement extends plugin
     foreach($_POST as $key => $val){
 
       /* Get every possible POST combination and set s_action/s_entry accordingly */
-      foreach(array("del"       => "user_del",    "edit"      => "user_edit",
+      foreach(array("del"       => "user_del",    
+                    "edit"      => "user_edit",
                     "new"       => "user_new",
                     "new_tpl"   => "user_tplnew",
                     "del_multiple" => "^remove_multiple_users",
@@ -86,6 +87,7 @@ class userManagement extends plugin
                     "change_pw" => "user_chgpw", 
                     "editPaste" => "editPaste",  
                     "copy_multiple" => "multiple_copy_users",
+                    "multiple_edit" => "multiple_edit",
                     "cut_multiple" => "multiple_cut_users",
                     "multiple_password_change" => "multiple_password_change",
                     "copy"      => "^copy",
@@ -269,15 +271,23 @@ class userManagement extends plugin
      ********************/
 
     /* User wants to edit data? */
-    if (($s_action=="edit") && (!isset($this->usertab->config))){
+    if (($s_action == "multiple_edit" || $s_action=="edit") && (!isset($this->usertab->config))){
 
+      $this->dn = array();
       /* Get 'dn' from posted 'uid', must be unique */
-      $this->dn= $this->list[trim($s_entry)]['dn'];
+      if($s_action == "multiple_edit"){
+        foreach($this->list_get_selected_items() as $id){
+          $this->dn[] = $this->list[trim($id)]['dn'];
+        }
+      }else{
+        $this->dn= array($this->list[trim($s_entry)]['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));
+      $users= get_multiple_locks($this->dn);
+      if (count($users)){
+        return(gen_locked_message($users, $this->dn));
       }
 
       /* Lock the current entry, so everyone will get the
@@ -285,15 +295,18 @@ class userManagement extends plugin
       add_lock ($this->dn, $this->ui->dn);
 
       /* Register usertab to trigger edit dialog */
-      $this->usertab= new usertabs($this->config, 
-          $this->config->data['TABS']['USERTABS'], $this->dn);
+      $tbs = new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn);
 
-      /* Switch tab, if it was requested by the user */
-      $this->usertab->current = $s_tab;
+      if($tbs){
+        $this->usertab = $tbs;
 
-      /* Set ACL and move DN to the headline */
-      $this->usertab->set_acl_base($this->dn);
-      $_SESSION['objectinfo']= $this->dn;
+        /* Switch tab, if it was requested by the user */
+        $this->usertab->current = $s_tab;
+
+        /* Set ACL and move DN to the headline */
+#        $this->usertab->set_acl_base($this->dn);
+         $_SESSION['objectinfo']= _("Multiple edit");
+      }
     }
 
 
index 0171a3c1117b86ea88acdc359cce507e79d11c33..4cec1ec537285b1e79129c5590825e66588ce6dc 100644 (file)
@@ -105,17 +105,25 @@ class user extends plugin
       "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
       "postalCode");
 
+  var $multiple_support =TRUE;
+
 
   /* constructor, if 'dn' is set, the node loads the given
      'dn' from LDAP */
   function user (&$config, $dn= NULL)
   {
+
     $this->config= $config;
     /* Configuration is fine, allways */
     if ($this->config->current['GOVERNMENTMODE']){
       $this->attributes=array_merge($this->attributes,$this->govattrs);
     }
 
+    $this->dn = $dn;
+    if(is_array($dn)){
+      return;
+    }
+
     /* Load base attributes */
     plugin::plugin ($config, $dn);
 
@@ -223,6 +231,9 @@ class user extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    if(is_array($this->dn)){
+      return("Still not supported.");
+    }
     /* Log view */
     if($this->is_account && !$this->view_logged){
       $this->view_logged = TRUE;