Code

Added handler for multiple edit
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 19 Oct 2007 08:30:55 +0000 (08:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 19 Oct 2007 08:30:55 +0000 (08:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7595 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_multi_plug.inc [new file with mode: 0644]
plugins/admin/users/class_userManagement.inc

diff --git a/include/class_multi_plug.inc b/include/class_multi_plug.inc
new file mode 100644 (file)
index 0000000..021bb28
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+class multi_plug
+{
+  /* Tab handler for each given dn entry */
+       public $a_handles = array();
+
+  /* Dummy handler which collects the data */
+  private $o_tab     = NULL;  
+
+  private $a_dns    = array();
+  private $o_config = NULL;
+  private $s_class  = "";
+
+  public function __construct($config,$class,$tab,$dns)
+  {
+    $this->a_dns = $dns;
+    $this->o_config = $config;
+    $this->s_class = $class;
+    $this->o_tab = new $class($config,$tab,"new");
+
+    if($this->o_tab->multiple_support_available()){
+      $this->o_tab->enable_multiple_support();
+    
+      foreach($dns as $dn){
+        $this->a_handles[] = new $class($config,$tab,$dn);
+      }
+    }
+  }
+
+  public function entries_locked()
+  {
+    return(FALSE);
+  }
+
+  public function display_lock_message()
+  {
+    return("");
+  }
+
+  public function lock_entries($uid)
+  {
+    return(TRUE);
+  }
+
+  public function multiple_available()
+  {
+    return(TRUE);
+  }
+
+  public function set_active_tab($str)
+  {
+  }
+
+  public function get_object_info()
+  {
+    return("Oi");
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index 77cd106fe4a9f0d2e5250cd6ff80601196113665..af39e5f4832c272da215f8715cb6b9b4a01c2cc0 100644 (file)
@@ -265,29 +265,20 @@ class userManagement extends plugin
 
 
 
-
-    /********************
-      Edit existing entry 
+     /********************
+      Edit existing entry
      ********************/
 
     /* User wants to edit data? */
-    if (($s_action == "multiple_edit" || $s_action=="edit") && (!isset($this->usertab->config))){
+    if (($s_action=="edit") && (!isset($this->usertab->config))){
 
-      $this->dn = array();
       /* Get 'dn' from posted 'uid', must be unique */
-      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']);
-      }
+      $this->dn= $this->list[trim($s_entry)]['dn'];
 
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
-      $users= get_multiple_locks($this->dn);
-      if (count($users)){
-        return(gen_locked_message($users, $this->dn));
+      if (($user= get_lock($this->dn)) != ""){
+        return(gen_locked_message ($user, $this->dn));
       }
 
       /* Lock the current entry, so everyone will get the
@@ -295,23 +286,39 @@ class userManagement extends plugin
       add_lock ($this->dn, $this->ui->dn);
 
       /* Register usertab to trigger edit dialog */
-      $tbs = new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn);
+      $this->usertab= new usertabs($this->config,
+          $this->config->data['TABS']['USERTABS'], $this->dn);
 
-      if($tbs){
-        $this->usertab = $tbs;
+      /* Switch tab, if it was requested by the user */
+      $this->usertab->current = $s_tab;
 
-        /* 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']= $this->dn;
+    }
 
-        /* Set ACL and move DN to the headline */
-        if(count($this->dn) == 1){  
-          reset($this->dn) ;
-          $dn = current($this->dn);
-          $this->usertab->set_acl_base($dn);
-          $_SESSION['objectinfo'] = $dn;
-        }else{
-          $_SESSION['objectinfo']= _("Multiple edit");
-        }
+
+    /********************
+      Edit multiple entries
+     ********************/
+
+    /* User wants to edit data? */
+    if ($s_action == "multiple_edit" && !isset($this->usertab->config)){
+
+      $this->dn = array();
+      foreach($this->list_get_selected_items() as $id){
+        $this->dn[] = $this->list[$id]['dn'];;
+      }
+      $tmp = new multi_plug($this->config,"usertabs",$this->config->data['TABS']['USERTABS'],$this->dn);
+      if ($tmp->entries_locked()){
+        return($tmp->display_lock_message());
+      }
+      $tmp->lock_entries($this->ui->dn);
+      if($tmp->multiple_available()){
+        $this->usertab = $tmp;
+        $this->usertab->set_active_tab($s_tab);
+        $_SESSION['objectinfo']= $this->usertab->get_object_info();
       }
     }