From 850372fc2b6d0d11356fbc9c4297a3f27875f0fa Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 11 Jun 2007 06:16:20 +0000 Subject: [PATCH] updated User Copy & paste git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6560 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_CopyPasteHandler.inc | 30 +++++++-- plugins/admin/users/class_userManagement.inc | 62 ++++++++++--------- .../connectivity/class_connectivity.inc | 4 +- 3 files changed, 59 insertions(+), 37 deletions(-) diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc index 3fda66e33..425f2a08f 100644 --- a/include/class_CopyPasteHandler.inc +++ b/include/class_CopyPasteHandler.inc @@ -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."
"; - 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; + } } } } diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index cdd8ad2c5..0d8adba85 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -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() { diff --git a/plugins/personal/connectivity/class_connectivity.inc b/plugins/personal/connectivity/class_connectivity.inc index 7d5d89375..f66e5cecf 100644 --- a/plugins/personal/connectivity/class_connectivity.inc +++ b/plugins/personal/connectivity/class_connectivity.inc @@ -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); } } } -- 2.30.2