From 31bd0987a98b67ff4cf082c21d03df7958785711 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 29 May 2008 08:19:12 +0000 Subject: [PATCH] Updated copy & paste acls, centralized checks git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11097 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_plugin.inc | 54 ++++++++++++++++++- gosa-core/include/class_userinfo.inc | 2 +- .../plugins/admin/acl/class_divListACL.inc | 17 +----- .../admin/groups/class_divListGroup.inc | 19 ++----- .../admin/ogroups/class_divListOGroup.inc | 18 +------ .../admin/users/class_divListUsers.inc | 18 +------ .../fai/admin/fai/class_divListFai.inc | 20 +------ .../blocklists/class_divListBlocklists.inc | 18 +------ .../conference/class_divListConferences.inc | 18 +------ .../gofon/gofon/macro/class_divListMacros.inc | 18 +------ .../applications/class_divListApplication.inc | 18 +------ .../admin/devices/class_divListDevices.inc | 18 +------ .../mimetypes/class_divListMimeTypes.inc | 18 +------ .../sudo/admin/sudo/class_divListSudo.inc | 16 +----- .../admin/systems/class_divListSystem.inc | 18 +------ 15 files changed, 80 insertions(+), 210 deletions(-) diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 6f6a6e52b..0cabed07f 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -1966,13 +1966,65 @@ class plugin } $str.= " "; + alt='"._("Create snapshot")."' name='CreateSnapShotDialog_".base64_encode($base)."' + title='"._("Create a new snapshot from this object")."'> "; } return($str); } + function get_copypaste_header($base,$category,$copy = TRUE, $cut = TRUE) + { + $s = ""; + $ui =get_userinfo(); + + if(!is_array($category)){ + $category = array($category); + } + + /* Check permissions for each category, if there is at least one category which + support read or paste permissions for the given base, then display the specific actions. + */ + $readable = $pasteable = TRUE; + foreach($category as $cat){ + $readable |= $ui->get_category_permissions($base,$cat); + $pasteable|= $ui->is_pasteable($base,$cat); + } + + if(($cut || $copy) && isset($this->CopyPasteHandler) && is_object($this->CopyPasteHandler)){ + if($readable){ + $s.= "..|---|\n"; + if($copy){ + $s.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + } + if($cut){ + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + } + } + + if($pasteable){ + if($this->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("Paste")."\n"; + } + } + } + return($s); + } + + + function get_copypaste_action($base,$category,$class) + { + + } + + function get_used_snapshot_bases() { return(array()); diff --git a/gosa-core/include/class_userinfo.inc b/gosa-core/include/class_userinfo.inc index 86f1bbada..3c9d363cb 100644 --- a/gosa-core/include/class_userinfo.inc +++ b/gosa-core/include/class_userinfo.inc @@ -230,7 +230,7 @@ class userinfo @param String The acl class (e.g. user) @return Boolean TRUE if we are allowed to paste an object. */ - function is_pasteable($dn, $object, $class) + function is_pasteable($dn, $object) { return(preg_match("/w/",$this->has_complete_category_acls($dn, $object))); } diff --git a/gosa-core/plugins/admin/acl/class_divListACL.inc b/gosa-core/plugins/admin/acl/class_divListACL.inc index b1c3734e8..9f19842eb 100644 --- a/gosa-core/plugins/admin/acl/class_divListACL.inc +++ b/gosa-core/plugins/admin/acl/class_divListACL.inc @@ -168,22 +168,9 @@ class divListACL extends MultiSelectWindow $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } + /* Add Copy & Paste header */ + $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module); $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); diff --git a/gosa-core/plugins/admin/groups/class_divListGroup.inc b/gosa-core/plugins/admin/groups/class_divListGroup.inc index c3e1fb78c..b2bf8fbdf 100644 --- a/gosa-core/plugins/admin/groups/class_divListGroup.inc +++ b/gosa-core/plugins/admin/groups/class_divListGroup.inc @@ -207,22 +207,9 @@ class divListGroup extends MultiSelectWindow /* Add multiple copy & cut icons */ $acl_all= $ui->has_complete_category_acls($this->selectedBase,"groups"); - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - + /* Add Copy & Paste header */ + $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module); + /* Add snapshot functionality */ $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); diff --git a/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc b/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc index 4894f9b13..d52470159 100644 --- a/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_divListOGroup.inc @@ -219,22 +219,8 @@ class divListOGroup extends MultiSelectWindow } } - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); diff --git a/gosa-core/plugins/admin/users/class_divListUsers.inc b/gosa-core/plugins/admin/users/class_divListUsers.inc index 9e2d725e4..ae4210b2f 100644 --- a/gosa-core/plugins/admin/users/class_divListUsers.inc +++ b/gosa-core/plugins/admin/users/class_divListUsers.inc @@ -199,23 +199,7 @@ class divListUsers extends MultiSelectWindow } } - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - + $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module); $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); diff --git a/gosa-plugins/fai/admin/fai/class_divListFai.inc b/gosa-plugins/fai/admin/fai/class_divListFai.inc index 8820af5f8..2c37a07bf 100644 --- a/gosa-plugins/fai/admin/fai/class_divListFai.inc +++ b/gosa-plugins/fai/admin/fai/class_divListFai.inc @@ -157,24 +157,8 @@ class divListFai extends MultiSelectWindow " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - } - - /* Add copy & paste icons, currently disabled, this ability is not implemeneted yet */ - if(!($this->parent->lock_type == "freeze" && !$this->parent->allow_freeze_object_attach) && - preg_match("/(c.*w|w.*c)/",$acl_all) && isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler){ - $s .= "..|---|\n"; - if($this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } - } + /* Add Copy & Paste header */ + $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module,TRUE,FALSE); # /* Add snapshot icons, if we are allowed to write and create the complete fai module ($ui->has_complete_category_acls) */ # $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); diff --git a/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc index 234625466..c1defca28 100644 --- a/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc +++ b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc @@ -151,22 +151,8 @@ class divListBlocklist extends MultiSelectWindow $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); diff --git a/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc b/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc index b116eacdf..38af27bc3 100644 --- a/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc +++ b/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc @@ -148,22 +148,8 @@ class divListConference extends MultiSelectWindow $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\n"; - } + /* Add Copy & Paste header */ + $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module); $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); diff --git a/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc b/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc index 8420ead27..4b29021c2 100644 --- a/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc +++ b/gosa-plugins/gofon/gofon/macro/class_divListMacros.inc @@ -146,22 +146,8 @@ class divListMacro extends MultiSelectWindow " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); diff --git a/gosa-plugins/goto/admin/applications/class_divListApplication.inc b/gosa-plugins/goto/admin/applications/class_divListApplication.inc index de0e1263b..194654d40 100644 --- a/gosa-plugins/goto/admin/applications/class_divListApplication.inc +++ b/gosa-plugins/goto/admin/applications/class_divListApplication.inc @@ -162,22 +162,8 @@ class divListApplication extends MultiSelectWindow $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); diff --git a/gosa-plugins/goto/admin/devices/class_divListDevices.inc b/gosa-plugins/goto/admin/devices/class_divListDevices.inc index 7c4b39e2f..7ff3b2b2a 100644 --- a/gosa-plugins/goto/admin/devices/class_divListDevices.inc +++ b/gosa-plugins/goto/admin/devices/class_divListDevices.inc @@ -147,22 +147,8 @@ class divListDevices extends MultiSelectWindow $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); diff --git a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc index 53b9a1bd7..4f669c95d 100644 --- a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc +++ b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc @@ -171,22 +171,8 @@ class divListMimeTypes extends MultiSelectWindow $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); diff --git a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc index 98259d9fd..701218be5 100644 --- a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc +++ b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc @@ -123,20 +123,8 @@ class divListSudo extends MultiSelectWindow " "._("Remove")."|"."del_role|\n"; } - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); diff --git a/gosa-plugins/systems/admin/systems/class_divListSystem.inc b/gosa-plugins/systems/admin/systems/class_divListSystem.inc index 8f549172f..f6a894d21 100644 --- a/gosa-plugins/systems/admin/systems/class_divListSystem.inc +++ b/gosa-plugins/systems/admin/systems/class_divListSystem.inc @@ -260,22 +260,8 @@ class divListSystem extends MultiSelectWindow $s.= "..|". " "._("Activate systems")."|activate_multiple|\n"; - if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$all_module_acls)){ - $s.= "..|---|\n"; - $s.= "..|". - " "._("Copy")."|"."multiple_copy_systems|\n"; - $s.= "..|". - " "._("Cut")."|"."multiple_cut_systems|\n"; - } - - /* Copy & paste icons */ - if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){ - $img = ""; - $s.="..|".$img." "._("Paste")."|editPaste|\n"; - }else{ - $img = ""; - $s.="..|".$img." "._("Paste")."\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); -- 2.30.2