Code

updated User Copy & paste
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 Jun 2007 06:16:20 +0000 (06:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 Jun 2007 06:16:20 +0000 (06:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6560 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_CopyPasteHandler.inc
plugins/admin/users/class_userManagement.inc
plugins/personal/connectivity/class_connectivity.inc

index 3fda66e3397645bf20c37e63868c42398ad39215..425f2a08f6283d586cc35f339e070685998672ab 100644 (file)
@@ -37,7 +37,20 @@ class CopyPasteHandler {
    */
   function add_to_queue($dn,$action,$tab_class,$tab_object)
   {
-    echo "validate given data here !!!!!!!";
+    if(!class_exists($tab_class)){
+      trigger_error(sprintf("Specified class object '%s' does not exists.",$tab_class));
+      return(FALSE);
+    }
+
+    if(!isset($this->config->data['TABS'][$tab_object])){
+      trigger_error(sprintf("Specified tab object '%s' does not exists.",$tab_object));
+      return(FALSE);
+    }
+    if(!in_array($action,array("cut","copy"))){
+      trigger_error(sprintf("Specified action '%s' does not exists for copy & paste.",$action));
+      return(FALSE);
+    } 
 
     if($file_name = $this->save_dn_attributes_to_hdd($dn)){
       $tmp = array();
@@ -233,6 +246,12 @@ class CopyPasteHandler {
   }
 
 
+  function last_entry()
+  {
+    return($this->lastdn);
+  }
+
+
   /* Save new values posted by copy & paste dialog */
   function save_object()
   {
@@ -268,10 +287,11 @@ class CopyPasteHandler {
    *  example :   ("base", $newBase );    */
   function SetVar($name,$value)
   {
-    echo $name.$value."<br>";
-    foreach($this->    current->by_object as $key => $obj){
-      if(isset($this->current->by_object[$key]->$name)){
-        $this->current->by_object[$key]->$name = $value;
+    if($this->current){
+      foreach($this->current['object']->by_object as $key => $obj){
+        if(isset($this->current['object']->by_object[$key]->$name)){
+          $this->current['object']->by_object[$key]->$name = $value;
+        }
       }
     }
   }
index cdd8ad2c5313e49c36a820b0472643717861deea..0d8adba855935651c6fba664503434dfdc53aebe 100644 (file)
@@ -114,15 +114,8 @@ class userManagement extends plugin
       $s_tab = "user";
     }
 
-
-    $ret = $this->copyPasteHandling_from_queue($s_action);
-    if($ret){
-      return($ret);
-    }
-
-
     /* Display the copy & paste dialog, if it is currently open */
-    $ret = $this->copyPasteHandling($s_action,$s_entry);
+    $ret = $this->copyPasteHandling_from_queue($s_action);
     if($ret){
       return($ret);
     }
@@ -888,17 +881,14 @@ class userManagement extends plugin
       $this->CopyPasteHandler->cleanup_queue();
 
       /* Add new entries to CP queue */
-      foreach($_POST as $name => $value){
-        if(preg_match("/^item_selected_[0-9]*$/",$name)){
-          $id = preg_replace("/^item_selected_/","",$name);
-          $dn = $this->list[$id]['dn'];
+      foreach($this->list_get_selected_items() as $id){
+        $dn = $this->list[$id]['dn'];
 
-          if($s_action == "copy_multiple"){
-            $this->CopyPasteHandler->add_to_queue($dn,"copy","usertabs","USERTABS");
-          }
-          if($s_action == "cut_multiple"){
-            $this->CopyPasteHandler->add_to_queue($dn,"cut","usertabs","USERTABS");
-          }
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy","usertabs","USERTABS");
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut","usertabs","USERTABS");
         }
       }
     }
@@ -907,22 +897,34 @@ class userManagement extends plugin
       $this->start_pasting_copied_objects = TRUE;
     }
 
-    if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
-      return($this->CopyPasteHandler->paste_entries());
+    /* Return C&P dialog */ 
+    if($this->start_pasting_copied_objects && 
+        ($this->CopyPasteHandler->entries_queued() || $this->CopyPasteHandler->current)){
+   
+      $this->CopyPasteHandler->SetVar("base",$this->DivListUsers->selectedBase); 
+      $data = $this->CopyPasteHandler->paste_entries();
+
+      /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
+      if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
+        $s_entry = $this->CopyPasteHandler->last_entry();
+        $this->reload();
+        foreach($this->list as $key => $entry){
+          if($entry['dn'] == $s_entry){
+            $this->CPPasswordChange = $key;
+          }
+        }
+      }
+
+      /* Return dialog data */
+      if(!empty($data)){
+        return($data);
+      }
     }
-    
+  
     $this->start_pasting_copied_objects = FALSE;
+    return("");
   }
 
-  /* Perform copy & paste requests
-      If copy&paste is in progress this returns a dialog to fix required attributes 
-   */ 
-  function copyPasteHandling($s_action,$s_entry)
-  { 
-    echo "replaced";
-    return;
-  }
 
   function save_object()
   {
index 7d5d893752c7f5aa6e65bf63068688433c41750c..f66e5cecf250bcbb13f93c582025bf8c9a20c9c9 100644 (file)
@@ -180,8 +180,8 @@ class connectivity extends plugin
     $tmp = $this->plugin;
     plugin::PrepareForCopyPaste($obj);
     $this->plugin = $tmp;
-    foreach($obj->plugin as $key => $plug){
-      $this->plugin[$key]->PrepareForCopyPaste($plug);
+    foreach( $this->plugin as $key => $plug){
+      $this->plugin[$key]->PrepareForCopyPaste($obj);
     }
   }
 }