From: hickert Date: Wed, 26 Apr 2006 04:42:22 +0000 (+0000) Subject: Moved copy&paste into a seperate function X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ad5093a212a7de9a87540453626678ce409d72fc;p=gosa.git Moved copy&paste into a seperate function git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3111 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/applications/class_applicationManagement.inc b/plugins/admin/applications/class_applicationManagement.inc index 2eaa67e21..f82a5013e 100644 --- a/plugins/admin/applications/class_applicationManagement.inc +++ b/plugins/admin/applications/class_applicationManagement.inc @@ -31,12 +31,11 @@ class applicationManagement extends plugin var $ui= NULL; var $acl= ""; - var $CopyPasteHandler ; + var $CopyPasteHandler = NULL; var $Release = ""; var $Releases = array(); - var $enableCopyPaste = false; var $enableReleaseManagement = false; @@ -46,14 +45,12 @@ class applicationManagement extends plugin $this->config= $config; $this->ui= $ui; - if( (isset($this->config->data['MAIN']['ENABLECOPYPASTE'])) + if((isset($this->config->data['MAIN']['ENABLECOPYPASTE'])) && (preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE'] ))){ - $this->enableCopyPaste = true; + $this->CopyPasteHandler = new CopyPasteHandler($this->config); } - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - /* Check if we should enable the release selection */ $tmp = search_config($this->config->data,"faiManagement","CLASS"); if(!empty($tmp)){ @@ -238,39 +235,10 @@ class applicationManagement extends plugin /* Only perform copy / paste if it is enabled */ - if($this->enableCopyPaste){ - - /* Paste copied/cutted object in here - */ - if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){ - $this->CopyPasteHandler->save_object(); - $this->CopyPasteHandler->SetVar("base", $_SESSION['CurrentMainBase']); - - if($str = $this->CopyPasteHandler->execute()) { - return($str); - } - } - - - /* Copy current object to CopyHandler - */ - if($s_action == "copy"){ - $this->CopyPasteHandler->Clear(); - $dn = $this->applications[$s_entry]['dn']; - $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn); - $objNew = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], "new"); - $this->CopyPasteHandler->Copy($obj,$objNew); - } - - - /* Copy current object to CopyHandler - */ - if($s_action == "cut"){ - $this->CopyPasteHandler->Clear(); - $dn = $this->applications[$s_entry]['dn']; - $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn); - $this->CopyPasteHandler->Cut($obj); - } + if($this->CopyPasteHandler){ + if($str = $this->copyPasteHandling($s_action,$s_entry)){ + return($str); + }; } /* New application? */ @@ -452,7 +420,7 @@ class applicationManagement extends plugin } } - if($this->enableCopyPaste){ + if($this->CopyPasteHandler){ $Copy_Paste = "  "; if($this->CopyPasteHandler->isCurrentObjectPastAble()){ @@ -488,7 +456,7 @@ class applicationManagement extends plugin - if($this->enableCopyPaste){ + if($this->CopyPasteHandler){ $actions = " "; $actions.= "CopyPasteHandler->stillOpen())){ + $this->CopyPasteHandler->save_object(); + $this->CopyPasteHandler->SetVar("base", $_SESSION['CurrentMainBase']); + + if($str = $this->CopyPasteHandler->execute()) { + return($str); + } + } + + /* Copy current object to CopyHandler + */ + if($s_action == "copy"){ + $this->CopyPasteHandler->Clear(); + $dn = $this->applications[$s_entry]['dn']; + $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn); + $objNew = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], "new"); + $this->CopyPasteHandler->Copy($obj,$objNew); + } + + /* Copy current object to CopyHandler + */ + if($s_action == "cut"){ + $this->CopyPasteHandler->Clear(); + $dn = $this->applications[$s_entry]['dn']; + $obj = new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn); + $this->CopyPasteHandler->Cut($obj); + } + } + /* Save data to object */ function save_object() { diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc index 70bb5499a..75b1dbf67 100644 --- a/plugins/admin/groups/class_groupManagement.inc +++ b/plugins/admin/groups/class_groupManagement.inc @@ -32,8 +32,7 @@ class groupManagement extends plugin var $ui= NULL; var $acl= ""; - var $CopyPasteHandler ; - var $enableCopyPaste = false; + var $CopyPasteHandler = NULL; function groupManagement ($config, $ui) { @@ -42,9 +41,8 @@ class groupManagement extends plugin $this->ui= $ui; if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){ - $this->enableCopyPaste = true; + $this->CopyPasteHandler = new CopyPasteHandler($this->config); } - $this->CopyPasteHandler = new CopyPasteHandler($this->config); /* Get global filter config */ if (!is_global("groupfilter")){ @@ -202,54 +200,14 @@ class groupManagement extends plugin return($message); } - /* Only perform copy / paste if it is enabled + /* Only perform copy&paste requests if it is enabled */ - if($this->enableCopyPaste){ - - /* Paste copied/cutted object in here - */ - if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){ - $this->CopyPasteHandler->save_object(); - $this->CopyPasteHandler->SetVar("base",$_SESSION['CurrentMainBase']); - if($str = $this->CopyPasteHandler->execute()){ - return( $str); - }; - /* Ensure that the new object is shown in the list now */ - $this->relaod(); - } - - - /* Copy current object to CopyHandler - */ - if($s_action == "copy"){ - $this->CopyPasteHandler->Clear(); - - $dn = $this->grouplist[trim($s_entry)]['dn']; - $acl = get_permissions ($dn, $this->ui->subtreeACL); - - $obj = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn); - $objNew = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], "new"); - $obj->set_acl($acl); - $objNew->set_acl($acl); - $this->CopyPasteHandler->Copy($obj,$objNew); - } - - - /* Copy current object to CopyHandler - */ - if($s_action == "cut"){ - $this->CopyPasteHandler->Clear(); - $dn = $this->grouplist[trim($s_entry)]['dn']; - $acl= get_permissions ($dn, $this->ui->subtreeACL); - - $obj= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn); - $obj->set_acl($acl); - - $this->CopyPasteHandler->Cut($obj); + if($this->CopyPasteHandler){ + if($str = $this->copyPasteHandling($s_action,$s_entry)){ + echo $str; } } - /* New group? */ if ($s_action=="new"){ @@ -431,7 +389,7 @@ class groupManagement extends plugin /* Create paste icon */ - if($this->enableCopyPaste){ + if($this->CopyPasteHandler){ $Copy_Paste = "  "; if($this->CopyPasteHandler->isCurrentObjectPastAble()){ if($this->CopyPasteHandler->isCurrentCutted()){ @@ -463,7 +421,7 @@ class groupManagement extends plugin ""; - if($this->enableCopyPaste){ + if($this->CopyPasteHandler){ $actions = " "; $actions.= "CopyPasteHandler->stillOpen())){ + $this->CopyPasteHandler->save_object(); + $this->CopyPasteHandler->SetVar("base",$_SESSION['CurrentMainBase']); + if($str = $this->CopyPasteHandler->execute()){ + return( $str); + }; + /* Ensure that the new object is shown in the list now */ + $this->relaod(); + } + + + /* Copy current object to CopyHandler + */ + if($s_action == "copy"){ + $this->CopyPasteHandler->Clear(); + + $dn = $this->grouplist[trim($s_entry)]['dn']; + $acl = get_permissions ($dn, $this->ui->subtreeACL); + + $obj = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn); + $objNew = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], "new"); + $obj->set_acl($acl); + $objNew->set_acl($acl); + $this->CopyPasteHandler->Copy($obj,$objNew); + } + + + /* Copy current object to CopyHandler + */ + if($s_action == "cut"){ + $this->CopyPasteHandler->Clear(); + $dn = $this->grouplist[trim($s_entry)]['dn']; + $acl= get_permissions ($dn, $this->ui->subtreeACL); + + $obj= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn); + $obj->set_acl($acl); + + $this->CopyPasteHandler->Cut($obj); + } + } + /* Save data to object */ function save_object() {