From 29cd9131a3f0781a231b22d508f8ad0e5848b63b Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 12 Jun 2007 10:34:03 +0000 Subject: [PATCH] Updated Copy & Paste for Workstations git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6568 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/ogroups/class_divListOGroup.inc | 5 +- plugins/admin/ogroups/class_ogroup.inc | 30 +++++++ .../admin/ogroups/class_ogroupManagement.inc | 85 ++++++++++--------- plugins/admin/ogroups/class_termgroup.inc | 25 ++++++ .../systems/class_workstationStartup.inc | 17 ++++ 5 files changed, 121 insertions(+), 41 deletions(-) diff --git a/plugins/admin/ogroups/class_divListOGroup.inc b/plugins/admin/ogroups/class_divListOGroup.inc index 32276f896..8489aed06 100755 --- a/plugins/admin/ogroups/class_divListOGroup.inc +++ b/plugins/admin/ogroups/class_divListOGroup.inc @@ -185,7 +185,10 @@ class divListOGroup extends MultiSelectWindow /* Multiple options */ $listhead .= "  "; - + $listhead .= "  "; + $listhead .= "  "; $listhead .=""; $this->SetListHeader($listhead); diff --git a/plugins/admin/ogroups/class_ogroup.inc b/plugins/admin/ogroups/class_ogroup.inc index db39046c4..1a5db9bca 100644 --- a/plugins/admin/ogroups/class_ogroup.inc +++ b/plugins/admin/ogroups/class_ogroup.inc @@ -684,6 +684,36 @@ class ogroup extends plugin $this->handle_post_events("remove"); } + + function PrepareForCopyPaste($source) + { + /* Update available object types */ + if(isset($source['gosaGroupObjects'][0])){ + $this->gosaGroupObjects = $source['gosaGroupObjects'][0]; + } + + /* Reload tabs */ + $this->parent->reload($this->gosaGroupObjects ); + + /* Reload plugins */ + foreach($this->parent->by_object as $name => $class ){ + if(get_class($this) != $name) { + $this->parent->by_object[$name]->PrepareForCopyPaste($source); + } + } + + /* Load member objects */ + if (isset($source['member'])){ + foreach ($source['member'] as $key => $value){ + if ("$key" != "count"){ + $value= @LDAP::convert($value); + $this->member["$value"]= "$value"; + } + } + } + + } + function getCopyDialog() { diff --git a/plugins/admin/ogroups/class_ogroupManagement.inc b/plugins/admin/ogroups/class_ogroupManagement.inc index 14f9d9f97..34cf7b7b2 100644 --- a/plugins/admin/ogroups/class_ogroupManagement.inc +++ b/plugins/admin/ogroups/class_ogroupManagement.inc @@ -33,6 +33,7 @@ class ogroupManagement extends plugin var $CopyPasteHandler = NULL; var $DivListOGroup = NULL; + var $start_pasting_copied_objects = FALSE; function ogroupManagement ($config, $dn= NULL) { @@ -88,6 +89,10 @@ class ogroupManagement extends plugin $s_entry = preg_replace("/^cut_/i","",$key); }elseif(preg_match("/^remove_multiple_ogroups/",$key)){ $s_action="del_multiple"; + }elseif(preg_match("/^multiple_cut_ogroups/",$key)){ + $s_action = "cut_multiple"; + }elseif(preg_match("/^multiple_copy_ogroups/",$key)){ + $s_action = "copy_multiple"; }elseif(preg_match("/_group_edit_/",$key)){ $type = preg_replace("/_group_edit_.*$/","",$key); $s_action="edit"; @@ -109,12 +114,13 @@ class ogroupManagement extends plugin ****************/ /* 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); } - /**************** + + /*************** Create a new object group ****************/ @@ -529,54 +535,53 @@ class ogroupManagement extends plugin } - function copyPasteHandling($s_action,$s_entry) + function copyPasteHandling_from_queue($s_action) { - if($this->CopyPasteHandler){ - - /* Paste copied/cutted object in here - */ - if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){ - $this->CopyPasteHandler->save_object(); - $this->CopyPasteHandler->SetVar("base", $this->DivListOGroup->selectedBase); - return($this->CopyPasteHandler->execute()); - } - /* Copy current object to CopyHandler - */ - if($s_action == "copy"){ - + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - $this->CopyPasteHandler->Clear(); - $dn = $this->ogrouplist[$s_entry]['dn']; + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); - /* Check acls */ - $acl_all= $this->ui->has_complete_category_acls($dn,"ogroups"); - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $obj = new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn); - $objNew = new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], "new"); + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->ogrouplist[$id]['dn']; - $types_of_tabs = $obj->by_object['ogroup']->gosaGroupObjects; - $objNew->by_object['ogroup']->gosaGroupObjects = $types_of_tabs; - $objNew->reload($types_of_tabs); - - $this->CopyPasteHandler->Copy($obj,$objNew); + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","ogrouptabs","OGROUPTABS","ogroups"); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","ogrouptabs","OGROUPTABS","ogroups"); } } + } - /* Copy current object to CopyHandler - */ - if($s_action == "cut"){ - $this->CopyPasteHandler->Clear(); - $dn = $this->ogrouplist[$s_entry]['dn']; - - /* Check acls */ - $acl_all= $this->ui->has_complete_category_acls($dn,"ogroups"); - if(preg_match("/(c.*w|w.*c)/",$acl_all)){ - $obj = new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn); - $this->CopyPasteHandler->Cut($obj); - } + /* Start pasting entries */ + if($s_action == "editPaste"){ + $this->start_pasting_copied_objects = TRUE; + } + + /* Return C&P dialog */ + if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ + + /* Load entry from queue and set base */ + $this->CopyPasteHandler->load_entry_from_queue(); + $this->CopyPasteHandler->SetVar("base",$this->DivListOGroup->selectedBase); + + /* Get dialog */ + $data = $this->CopyPasteHandler->execute(); + + /* Return dialog data */ + if(!empty($data)){ + return($data); } } + /* Automatically disable status for pasting */ + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; + } + return(""); } diff --git a/plugins/admin/ogroups/class_termgroup.inc b/plugins/admin/ogroups/class_termgroup.inc index aa913640d..2c759829e 100644 --- a/plugins/admin/ogroups/class_termgroup.inc +++ b/plugins/admin/ogroups/class_termgroup.inc @@ -399,8 +399,33 @@ class termgroup extends plugin )); } + function PrepareForCopyPaste($source) + { + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + if(isset($source['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($source['gotoNtpServer']['count']); + foreach($source['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + /* Set inherit checkbox state */ + if(in_array("default",$this->gotoNtpServer)){ + $this->inheritTimeServer = true; + $this->gotoNtpServer=array(); + } + + /* Create available ntp options */ + $this->gotoNtpServers = $this->config->data['SERVERS']['NTP']; + foreach($this->gotoNtpServers as $key => $server){ + if($server == "default"){ + unset($this->gotoNtpServers[$key]); + } + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/systems/class_workstationStartup.inc b/plugins/admin/systems/class_workstationStartup.inc index 6991b3bb7..ab20b1b9e 100644 --- a/plugins/admin/systems/class_workstationStartup.inc +++ b/plugins/admin/systems/class_workstationStartup.inc @@ -1159,6 +1159,23 @@ class workstartup extends plugin } + function PrepareForCopyPaste($source) + { + /* Get arrays */ + foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){ + if (isset($source["$val"]["count"])){ + for ($i= 0; $i<$source["count"]; $i++){ + if (isset($source["$val"][$i])){ + array_push($this->$val, $source["$val"][$i]); + } + } + } + sort ($this->$val); + $this->$val= array_unique($this->$val); + } + + } + /* Return plugin informations for acl handling */ function plInfo() { -- 2.30.2