From: hickert Date: Tue, 12 Jun 2007 13:23:15 +0000 (+0000) Subject: Added copy & paste to systems X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3528a205da3c30680c8a714247624f9918d1eda4;p=gosa.git Added copy & paste to systems git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6572 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc index 09a89297c..7fe75e3d2 100644 --- a/plugins/admin/groups/class_groupManagement.inc +++ b/plugins/admin/groups/class_groupManagement.inc @@ -655,8 +655,6 @@ class groupManagement extends plugin } - - /* Save data to object */ function save_object() { diff --git a/plugins/admin/systems/class_divListSystem.inc b/plugins/admin/systems/class_divListSystem.inc index f7b1ffac7..99aaf9d0d 100644 --- a/plugins/admin/systems/class_divListSystem.inc +++ b/plugins/admin/systems/class_divListSystem.inc @@ -53,7 +53,7 @@ class divListSystem extends MultiSelectWindow $this->EnableSaveButton (false); /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 70; + $action_col_size = 110; if($this->parent->snapshotEnabled()){ $action_col_size += 38; } @@ -161,7 +161,14 @@ class divListSystem extends MultiSelectWindow /* Must we add an additional seperator */ $add_sep = false; - + + /* Get copy & paste icon */ + $Copy_Paste =""; + if(preg_match("/(c.*w|w.*c)/",$all_module_acls) && $this->parent->CopyPasteHandler){ + $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon(); + $addsep = true; + } + /* Add default header */ $listhead = MultiSelectWindow::get_default_header(); @@ -171,6 +178,9 @@ class divListSystem extends MultiSelectWindow $add_sep = true; } + /* Assign copy & paste icons */ + $listhead.= $Copy_Paste; + /* Handle create icons */ if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"terminal/termgeneric"))){ $add_sep = true; @@ -222,6 +232,11 @@ class divListSystem extends MultiSelectWindow $listhead .= "  "; + $listhead .= "  "; + $listhead .= "  "; + $listhead .=""; $this->SetListHeader($listhead); @@ -250,7 +265,7 @@ class divListSystem extends MultiSelectWindow $empty =""; /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 70; + $action_col_size = 110; if($this->parent->snapshotEnabled()){ $action_col_size += 38; } @@ -295,7 +310,14 @@ class divListSystem extends MultiSelectWindow /* Get specific generic acls */ $acl = $ui->get_permissions($val['dn'],$tabs[$type]['ACL']); - $action= "parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){ + $action.= " "; + $action.= " "; + } + $action.= ""; if(preg_match("/(c.*w|w.*c)/",$acl_all)){ $action.= $this->GetSnapShotActions($val['dn']); @@ -303,6 +325,7 @@ class divListSystem extends MultiSelectWindow $action.= $empty." ".$empty." "; } + if(preg_match("/d/",$acl)){ $action.= ""; diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc index 232788361..704bfee50 100644 --- a/plugins/admin/systems/class_systemManagement.inc +++ b/plugins/admin/systems/class_systemManagement.inc @@ -38,6 +38,8 @@ class systems extends plugin var $terminals= array(); var $ui = NULL; var $DivListSystem; + var $start_pasting_copied_objects = FALSE; + var $CopyPasteHandler = NULL; function systems ($config, $ui) { @@ -47,8 +49,14 @@ class systems extends plugin /* Creat dialog object */ $this->DivListSystem = new divListSystem($this->config,$this); + + /* Copy & Paste enabled ?*/ + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ + $this->CopyPasteHandler = new CopyPasteHandler($this->config); + } } + function execute() { /* Call parent execute */ @@ -90,9 +98,22 @@ class systems extends plugin }elseif(preg_match("/newsystem_.*/i",$key)){ $s_action="newsystem"; $s_entry = preg_replace("/newsystem_/i","",$key); + }elseif(preg_match("/^multiple_copy_systems/",$key)){ + $s_action = "copy_multiple"; + }elseif(preg_match("/^multiple_cut_systems/",$key)){ + $s_action = "cut_multiple"; + }elseif(preg_match("/^editPaste.*/i",$key)){ + $s_action="editPaste"; + }elseif(preg_match("/^copy_.*/",$key)){ + $s_action="copy"; + $s_entry = preg_replace("/^copy_/i","",$key); + }elseif(preg_match("/^cut_.*/",$key)){ + $s_action="cut"; + $s_entry = preg_replace("/^cut_/i","",$key); } } - + + /* Incoming handling * If someone made a systemtype and ogroup selection * Display the new requested entry type ... servtab in case of server and so on. @@ -124,6 +145,17 @@ class systems extends plugin } + /******************** + Copy & Paste Handling ... + ********************/ + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); + if($ret){ + return($ret); + } + + /******************** Create FAI CD ... ********************/ @@ -1109,6 +1141,93 @@ class systems extends plugin } + function copyPasteHandling_from_queue($s_action,$s_entry) + { + + $tabs = array( + "terminal" => array( "CLASS" =>"TERMTABS", "TABNAME" =>"termgeneric", + "TABCLASS" =>"termtabs", "ACL" =>"terminal"), + "workstation" => array( "CLASS" =>"WORKTABS", "TABNAME" =>"workgeneric", + "TABCLASS" =>"worktabs", "ACL" =>"workstation"), + "server" => array( "CLASS" =>"SERVTABS", "TABNAME" =>"servgeneric", + "TABCLASS" =>"servtabs", "ACL" =>"server"), + "printer" => array( "CLASS" =>"PRINTTABS", "TABNAME" =>"printgeneric", + "TABCLASS" =>"printtabs", "ACL" =>"printer"), + "phone" => array( "CLASS" =>"PHONETABS", "TABNAME" =>"phonegeneric", + "TABCLASS" =>"phonetabs", "ACL" =>"phone"), + "component" => array( "CLASS" =>"COMPONENTTABS","TABNAME" =>"componentgeneric", + "TABCLASS" =>"componenttabs","ACL" =>"component")); + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->terminals[$s_entry]['dn']; + $oc = $this->terminals[$s_entry]['objectClass']; + $type = $this->get_system_type($oc); + + $tab_o = $tabs[$type]['CLASS']; + $tab_c = $tabs[$type]['TABCLASS']; + $acl = $tabs[$type]['ACL']; + + $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl); + } + + /* Add entries to queue */ + if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + + /* Add new entries to CP queue */ + foreach($this->list_get_selected_items() as $id){ + $dn = $this->terminals[$id]['dn']; + $oc = $this->terminals[$id]['objectClass']; + $type = $this->get_system_type($oc); + + $tab_o = $tabs[$type]['CLASS']; + $tab_c = $tabs[$type]['TABCLASS']; + $acl = $tabs[$type]['ACL']; + + if($s_action == "copy_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl); + } + if($s_action == "cut_multiple"){ + $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl); + } + } + } + + /* 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->DivListSystem->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(""); + } + + function get_system_type($classes) { $type= "";