From: hickert Date: Mon, 6 Jul 2009 06:50:24 +0000 (+0000) Subject: Added Copy & Paste to new role plugin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b4ccdd6dbaa2956cb67411aa5c98e28e6affed66;p=gosa.git Added Copy & Paste to new role plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13888 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc b/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc index 8aafe8ecf..630269938 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc +++ b/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc @@ -132,6 +132,9 @@ class divListRole extends MultiSelectWindow $s.= "..|". " "._("Remove")."|"."remove_multiple_roles|\n"; + /* Add Copy & Paste header */ + $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module); + /* Add snapshot icons */ $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); @@ -166,10 +169,15 @@ class divListRole extends MultiSelectWindow $acl = $ui->get_permissions($val['dn'],"roles/roleGeneric"); $acl_all= $ui->has_complete_category_acls($val['dn'],"roles"); - // Create edit and remove icon buttons - $actions = "parent->get_copypaste_action($val['dn'],"ogroups","ogroup"); + + // Create edit and remove icon buttons + $actions.= ""; + $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module); if(preg_match("/d/",$acl)){ $actions.= "roleOccupant = array(); + if (isset($source['roleOccupant'])){ + foreach ($source['roleOccupant'] as $key => $value){ + if ("$key" != "count"){ + $value= @LDAP::convert($value); + $this->roleOccupant["$value"]= "$value"; + } + } + } + $this->reload(); + } + + + function getCopyDialog() + { + $smarty = get_smarty(); + $smarty->assign("cn", $this->cn); + $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__))); + $ret = array(); + $ret['string'] = $str; + $ret['status'] = ""; + return($ret); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + static function plInfo() { diff --git a/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc b/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc index d136d398d..081705737 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc +++ b/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc @@ -68,7 +68,8 @@ class roleManagement extends plugin plugin::execute(); // Variables to restore after 'entry locked' warning was displayed - session::set('LOCK_VARS_TO_USE',array('/^role_/','/^act/','/^id/','/^menu_action/','/^item/')); + session::set('LOCK_VARS_TO_USE',array('/^copy/','/^cut/','/^role_/','/^act/', + '/^id/','/^menu_action/','/^item/')); $smarty = get_smarty(); @@ -80,6 +81,16 @@ class roleManagement extends plugin $s_action = ""; $s_entry = ""; foreach($_POST as $name => $value){ + if(preg_match("/^cut_/",$name)){ + $s_action = "cut"; + $s_entry = preg_replace("/^cut_([0-9]*)_.*$/","\\1",$name); + break; + } + if(preg_match("/^copy_/",$name)){ + $s_action = "copy"; + $s_entry = preg_replace("/^copy_([0-9]*)_.*$/","\\1",$name); + break; + } if(preg_match("/^role_edit_/",$name)){ $s_action = "edit"; $s_entry = preg_replace("/^role_edit_([0-9]*)_.*$/","\\1",$name); @@ -91,6 +102,9 @@ class roleManagement extends plugin break; } } + + print_a($_POST); + if(isset($_GET['act']) && $_GET['act'] == "edit_entry" && isset($_GET['id'])){ $id = $_GET['id']; if(isset($this->roles[$id])){ @@ -101,13 +115,26 @@ class roleManagement extends plugin // Get menu related posts if(isset($_POST['menu_action'])) { - if($_POST['menu_action'] == "role_new"){ + if($_POST['menu_action'] == "editPaste"){ + $s_action = "editPaste"; + }elseif($_POST['menu_action'] == "role_new"){ $s_action = "new"; }elseif($_POST['menu_action'] == "remove_multiple_roles"){ $s_action = "remove_multiple"; } } + /*************** + * 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); + } + + /*************** * Remove handling ***************/ @@ -382,7 +409,74 @@ class roleManagement extends plugin return(array(get_ou('roleRDN').$this->DivListRoles->selectedBase)); } - + + function copyPasteHandling_from_queue($s_action,$s_entry) + { + /* Check if Copy & Paste is disabled */ + if(!is_object($this->CopyPasteHandler)){ + return(""); + } + + $ui = get_userinfo(); + + /* Add a single entry to queue */ + if($s_action == "cut" || $s_action == "copy"){ + + /* Cleanup object queue */ + $this->CopyPasteHandler->cleanup_queue(); + $dn = $this->roles[$s_entry]['dn']; + if($s_action == "copy" && $ui->is_copyable($dn,"roles","roleGeneric")){ + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"roletabs","ROLETABS","roles"); + } + if($s_action == "cut" && $ui->is_cutable($dn,"roles","roleGeneric")){ + $this->CopyPasteHandler->add_to_queue($dn,$s_action,"roletabs","ROLETABS","roles"); + } + } + + /* 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->roles[$id]['dn']; + + if($s_action == "copy_multiple" && $ui->is_copyable($dn,"roles","roleGeneric")){ + $this->CopyPasteHandler->add_to_queue($dn,"copy","roletabs","ROLETABS","roles"); + } + if($s_action == "cut_multiple" && $ui->is_cutable($dn,"roles","roleGeneric")){ + $this->CopyPasteHandler->add_to_queue($dn,"cut","roletabs","ROLETABS","roles"); + } + } + } + + /* 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()){ + + /* Get dialog */ + $this->CopyPasteHandler->SetVar("base",$this->DivListRoles->selectedBase); + $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 save_object() { $this->DivListRoles->save_object(); diff --git a/gosa-plugins/roleManagement/admin/roleManagement/paste_generic.tpl b/gosa-plugins/roleManagement/admin/roleManagement/paste_generic.tpl new file mode 100644 index 000000000..91f84d8ae --- /dev/null +++ b/gosa-plugins/roleManagement/admin/roleManagement/paste_generic.tpl @@ -0,0 +1,14 @@ + + + + + +
+ {$must} + + +
+ +