X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_CopyPasteHandler.inc;h=37e9a2e951c02c3c9d4acbbfd6295318a2c687e6;hb=987f351eef4d8d3a737d65e3588bb28641ca1827;hp=993b59342b3d00db54c0b28f3a1fe0893c3464ac;hpb=715b581c84b912164d3a6ebc7ed0b58150673b61;p=gosa.git diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc index 993b59342..37e9a2e95 100644 --- a/include/class_CopyPasteHandler.inc +++ b/include/class_CopyPasteHandler.inc @@ -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,8 +62,13 @@ 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; + + $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()){ @@ -115,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(); } @@ -193,14 +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: