Code

Updated posix user add
[gosa.git] / include / class_CopyPasteHandler.inc
index a6d1a8a30fce48c022b6167f1d6697ae159a7fbf..37e9a2e951c02c3c9d4acbbfd6295318a2c687e6 100644 (file)
@@ -10,6 +10,10 @@ class CopyPasteHandler {
   var $dialogOpen  = false;
   var $objectdn    = false;
 
+  var $lastdn      = "";
+
+  var $was_successfull = false;
+
   /* Create CP handler
    */
   function CopyPasteHandler($config){
@@ -58,15 +62,14 @@ class CopyPasteHandler {
     $this->objectdn    = $obj->dn;
     $this->current = $emptyObj;
     foreach($obj->by_object as $name => $obj){
-      foreach($obj->attributes as $attr){
-        $this->current->by_object[$name]->$attr = $obj->$attr;
-      }
-      foreach(array('is_account','gotoHotplugDevices','gotoLogonScripts','gotoProfileServers','gotoProfileFlag_C','gotoProfileFlag_L','gotoPrinter','useProfile','OrigCn','Categories') as $attr){
+      
+      $this->current->by_object[$name]->PrepareForCopyPaste($obj);
+  
+      foreach(array("is_account") as $attr){
         if(isset($obj->$attr)){
           $this->current->by_object[$name]->$attr = $obj->$attr;
         }
       }
-
     }
     if($this->isCurrentObjectPastAble()){
       return(true);
@@ -121,77 +124,86 @@ class CopyPasteHandler {
   }
 
 
-       /* Displays a dialog which allows the user to fix all dependencies of this object.
-          Create unique names, ids, or what ever
-        */
-       function execute()
-       {
-               $this->dialogOpen = true;
-
-               /* Cut & paste
-         */
-               if($this->cutCurrent){
-                       $this->current->save();
-                       $this->dialogOpen =false;
-                       $smarty = get_smarty();
-                       $smarty->assign("Complete",true);
-                       $this->Clear();
-                       return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
-
-               /* Copy & paste
-         */
-               }else{
-                       if(isset($_POST['PerformCopyPaste'])){
-                               $msgs = $this->check(); 
-                               if(count ($msgs) ){
-                                       foreach( $msgs as $msg){
-                                               print_red($msg);
-                                       }
-                               }else{
-                                       $this->current->save();
-                                       $this->dialogOpen =false;
-                                       $smarty = get_smarty(); 
-                                       $smarty->assign("Complete",true);
-                                       $this->Clear();
-                                       return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
-                               }
-                       }
-                       $smarty = get_smarty(); 
-                       $smarty->assign("Complete",false);
-                       $smarty->assign("AttributesToFix",$this->generateAttributesToFix());    
-                       $smarty->assign("objectDN"               ,$this->objectdn);     
-                       return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
-               }
-       }
+  /* Displays a dialog which allows the user to fix all dependencies of this object.
+     Create unique names, ids, or what ever
+   */
+  function execute($displayMessageOnSuccess = true)
+  {
+    $this->dialogOpen = true;
+
+    /* Cut & paste
+     */
+    if($this->cutCurrent){
+      $this->current->save();
+      $this->dialogOpen =false;
+      $smarty = get_smarty();
+      $smarty->assign("Complete",true);
+      $this->lastdn= $this->current->dn;
+      $this->Clear();
+      return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
+
+      /* Copy & paste
+       */
+    }else{
+      if(isset($_POST['PerformCopyPaste'])){
+        $msgs = $this->check();        
+        if(count ($msgs) ){
+          foreach( $msgs as $msg){
+            print_red($msg);
+          }
+        }else{
+          $this->current->save();
+          $this->dialogOpen =false;
+          $smarty = get_smarty();      
+          $smarty->assign("Complete",true);
+          $this->lastdn = $this->current->dn;
+          $this->Clear();
+          if($displayMessageOnSuccess){
+            return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
+          }else{
+            return( false);
+          }
+        }
+      }
+      $smarty = get_smarty();  
+      $smarty->assign("Complete",false);
+      $smarty->assign("AttributesToFix",$this->generateAttributesToFix());     
+      $smarty->assign("SubDialog",$this->current->SubDialog);
+    
+      $smarty->assign("objectDN"                ,$this->objectdn);     
+      $smarty->assign("message", sprintf(_("You are going to copy the entry '%s'."), $this->objectdn));        
+      return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
+    }
+  }
 
   /* Create dialog which asks unique attributes values ... 
    *  calls tabs -> getCopyDialog() 
    *    which calls tab -> getCopyDialog()
    */
-       function generateAttributesToFix()
-       {
-               return($this->current->getCopyDialog());
-       }
+  function generateAttributesToFix()
+  {
+    return($this->current->getCopyDialog());
+  }
 
 
   /* Set a single attribute to specified value
    *  example :   ("base", $newBase );
    */
-       function SetVar($name,$value)
-       {
-               foreach($this-> current->by_object as $key => $obj){
-                       if(isset($this->current->by_object[$key]->$name)){
-                               $this->current->by_object[$key]->$name = $value;
-                       }
-               }
-       }
+  function SetVar($name,$value)
+  {
+    foreach($this->    current->by_object as $key => $obj){
+      if(isset($this->current->by_object[$key]->$name)){
+        $this->current->by_object[$key]->$name = $value;
+      }
+    }
+  }
 
 
   /* Save new values posted by copy & paste dialog
-  */
-       function save_object()
-       {
-               /* Assign posted var to all tabs
+   */
+  function save_object()
+  {
+    /* Assign posted var to all tabs
      */
     $this->current->saveCopyDialog();
   }
@@ -199,15 +211,17 @@ class CopyPasteHandler {
 
   /* Returns possible errors returned from all including tabs ..
    */
-       function check()
-       {
-               $ret = array();
-               foreach($this-> current->by_object as $obj){
-                       $ret = array_merge($ret , $obj->check());
-               }
-    
-               return($ret);
-       }
+  function check()
+  {
+    $ret = array();
+    foreach($this->    current->by_object as $obj){
+      if($obj->is_account){
+        $ret = array_merge($ret , $obj->check());
+      }
+    }
+
+    return($ret);
+  }
 
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: