From 9f9f1f666de9c2cde21f2e675e2034e98fc86344 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 16 Mar 2006 12:53:47 +0000 Subject: [PATCH] Added copy & paste for ogroups git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2850 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/ogroups/class_mailogroup.inc | 16 +++ plugins/admin/ogroups/class_ogroup.inc | 14 +++ .../admin/ogroups/class_ogroupManagement.inc | 107 ++++++++++++++++-- plugins/admin/ogroups/class_phonequeue.inc | 18 +++ 4 files changed, 148 insertions(+), 7 deletions(-) diff --git a/plugins/admin/ogroups/class_mailogroup.inc b/plugins/admin/ogroups/class_mailogroup.inc index b99206146..cfed78cf4 100644 --- a/plugins/admin/ogroups/class_mailogroup.inc +++ b/plugins/admin/ogroups/class_mailogroup.inc @@ -130,6 +130,22 @@ $ldap->modify ($this->attrs); show_ldap_error($ldap->get_error()); } + + function getCopyDialog() + { + $str = ""; + $str .= _("Phone number"); + $str .= " "; + return($str); + } + + + function saveCopyDialog() + { + if(isset($_POST['mail'])){ + $this->mail = $_POST['mail']; + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/ogroups/class_ogroup.inc b/plugins/admin/ogroups/class_ogroup.inc index 169e82939..b961cf339 100644 --- a/plugins/admin/ogroups/class_ogroup.inc +++ b/plugins/admin/ogroups/class_ogroup.inc @@ -730,6 +730,20 @@ class ogroup extends plugin $this->handle_post_events("remove"); } + function getCopyDialog() + { + $str = ""; + $str .= _("Group name"); + $str .= " "; + return($str); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/ogroups/class_ogroupManagement.inc b/plugins/admin/ogroups/class_ogroupManagement.inc index f84780301..ab4360eab 100644 --- a/plugins/admin/ogroups/class_ogroupManagement.inc +++ b/plugins/admin/ogroups/class_ogroupManagement.inc @@ -31,12 +31,25 @@ class ogroupManagement extends plugin var $obtypes= array(); var $ogroup; + var $CopyPasteHandler ; + + var $enableCopyPaste = false; + + function ogroupManagement ($config, $dn= NULL) { /* Include config object */ $this->config= $config; $this->ui= get_userinfo(); + /* Copy & Paste enabled ? + */ + 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); + /* Fill translation array */ $this->obtypes= array( "posixAccount" => _("UNIX accounts"), "posixGroup" => _("Groups"), @@ -130,16 +143,23 @@ class ogroupManagement extends plugin $s_entry = preg_replace("/group_chgpw_/i","",$key); }elseif(preg_match("/^dep_root.*/i",$key)){ $s_action="root"; + }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); }elseif(preg_match("/_group_edit_/",$key)){ $type = preg_replace("/_group_edit_.*$/","",$key); $s_action="edit"; $s_entry = preg_replace("/".$type."_group_edit_/i","",$key); $_POST['arg'] = $type; } - } $s_entry = preg_replace("/_.$/","",$s_entry); - + /* Department changed? */ if(isset($_POST['depselect']) && $_POST['depselect']){ $ogroupfilter['depselect']= $_POST['depselect']; @@ -191,6 +211,40 @@ class ogroupManagement extends plugin return($message); } + /* 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",$ogroupfilter['depselect']); + return($this->CopyPasteHandler->execute()); + } + + + /* Copy current object to CopyHandler + */ + if($s_action == "copy"){ + $this->CopyPasteHandler->Clear(); + $dn = $this->ogrouplist[$s_entry]['dn']; + $obj = new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn); + $objNew = new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], "new"); + $this->CopyPasteHandler->Copy($obj,$objNew); + } + + + /* Copy current object to CopyHandler + */ + if($s_action == "cut"){ + $this->CopyPasteHandler->Clear(); + $dn = $this->ogrouplist[$s_entry]['dn']; + $obj = new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn); + $this->CopyPasteHandler->Cut($obj); + } + } + /* New group? */ if ($s_action=="new"){ @@ -361,6 +415,28 @@ class ogroupManagement extends plugin } } + + /* Create paste icon + * This icon is only displayed if copy & paste is enabled + */ + if($this->enableCopyPaste){ + $Copy_Paste = "  "; + if($this->CopyPasteHandler->isCurrentObjectPastAble()){ + if($this->CopyPasteHandler->isCurrentCutted()){ + $img = "images/cutpaste.png"; + }else{ + $img = "images/copypaste.png"; + } + $Copy_Paste .= " "; + }else{ + $Copy_Paste .= ""._("Can "; + } + }else{ + $Copy_Paste =""; + } + + // Managment $listhead = "
". "  ". @@ -370,14 +446,31 @@ name='dep_root' alt='"._("Root")."'> ". alt='"._("Home")."' name='dep_home'> ". "  ". " ". + $Copy_Paste. "  ". _("Base")." ". "  ". "
"; - $actions = ""; - $actions.= ""; + /* Add Copy & Paste buttons if copy&paste is enabled + */ + if($this->enableCopyPaste){ + $actions = " "; + $actions.= " "; + $actions.= ""; + $actions.= ""; + }else{ + $actions = ""; + $actions.= ""; + } + // Defining Links $linkopen = "%s"; @@ -398,7 +491,7 @@ name='dep_root' alt='"._("Root")."'> ". array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''"), array("string" => _("Properties"), "attach" => "style='width:136px;'"), - array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'") + array("string" => _("Actions"), "attach" => "style='width:80;border-right:0px;text-align:right;'") )); @@ -424,7 +517,7 @@ name='dep_root' alt='"._("Root")."'> ". $field1 = array("string" => ""._("Department")."", "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''"); $field3 = array("string" => " ", "attach" => "style='width:136px;'"); - $field4 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $field4 = array("string" => " ", "attach" => "style='width:80;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3,$field4)); } @@ -448,7 +541,7 @@ name='dep_root' alt='"._("Root")."'> ". $field1 = array("string" => ""._("Object group")."", "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title); $field3 = array("string" => preg_replace("/%KEY/", $key, $this->convert_list($val))." ".$mail, "attach" => "style='width:136px;'"); - $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3,$field4)); } diff --git a/plugins/admin/ogroups/class_phonequeue.inc b/plugins/admin/ogroups/class_phonequeue.inc index c0e669b03..4917f27df 100644 --- a/plugins/admin/ogroups/class_phonequeue.inc +++ b/plugins/admin/ogroups/class_phonequeue.inc @@ -683,6 +683,24 @@ $ldap->modify ($this->attrs); show_ldap_error($ldap->get_error()); } + + function getCopyDialog() + { + $str = ""; + $str .= _("Phone number"); + $str .= " "; + return($str); + } + + + function saveCopyDialog() + { + if(isset($_POST['telephoneNumber'])){ + $this->telephoneNumber = $_POST['telephoneNumber']; + } + } + + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -- 2.30.2