From: hickert Date: Thu, 29 May 2008 08:35:32 +0000 (+0000) Subject: Centralized copy & paste icon creation && permission checks X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=645f88d4feb970b4bb1cd54e7e5a26b5f7966ce5;p=gosa.git Centralized copy & paste icon creation && permission checks git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11098 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 0cabed07f..f038fbf56 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -1974,6 +1974,33 @@ class plugin } + function get_copypaste_action($base,$category,$class,$copy = TRUE, $cut = TRUE) + { + $ui = get_userinfo(); + $action = ""; + if($this->CopyPasteHandler){ + if($cut){ + if($ui->is_cutable($base,$category,$class)){ + $action .= " "; + }else{ + $action.="  "; + } + } + if($copy){ + if($ui->is_copyable($base,$category,$class)){ + $action.= " "; + }else{ + $action.="  "; + } + } + } + + return($action); + } + + function get_copypaste_header($base,$category,$copy = TRUE, $cut = TRUE) { $s = ""; @@ -2019,12 +2046,6 @@ class plugin } - function get_copypaste_action($base,$category,$class) - { - - } - - function get_used_snapshot_bases() { return(array()); diff --git a/gosa-core/plugins/admin/acl/class_divListACL.inc b/gosa-core/plugins/admin/acl/class_divListACL.inc index 9f19842eb..f1e92b2f9 100644 --- a/gosa-core/plugins/admin/acl/class_divListACL.inc +++ b/gosa-core/plugins/admin/acl/class_divListACL.inc @@ -206,21 +206,8 @@ class divListACL extends MultiSelectWindow $cn .= " [".$acl_entry['description'][0]."]"; } - /* Add copy & paste handler */ - if($ui->is_cutable($acl_entry['dn'],"aclroles","aclRole") && $this->parent->CopyPasteHandler){ - $action .= " "; - }else{ - $action.="  "; - } - - if($ui->is_copyable($acl_entry['dn'],"aclroles","aclRole") && $this->parent->CopyPasteHandler){ - $action.= " "; - }else{ - $action.="  "; - } - + /* Add copy & cut functionality */ + $action.= $this->parent->get_copypaste_action($acl_entry['dn'],"aclroles","aclRole"); /* Add actions depending on acls */ if(preg_match("/r/", $acl)){ diff --git a/gosa-core/plugins/admin/groups/class_divListGroup.inc b/gosa-core/plugins/admin/groups/class_divListGroup.inc index b2bf8fbdf..7c42291e4 100644 --- a/gosa-core/plugins/admin/groups/class_divListGroup.inc +++ b/gosa-core/plugins/admin/groups/class_divListGroup.inc @@ -282,19 +282,8 @@ class divListGroup extends MultiSelectWindow $actions= ""; - if($ui->is_cutable($val['dn'],"groups","group") && $this->parent->CopyPasteHandler){ - $actions .= " "; - }else{ - $actions.="  "; - } - - if($ui->is_copyable($val['dn'],"groups","group") && $this->parent->CopyPasteHandler){ - $actions.= " "; - }else{ - $actions.="  "; - } + /* Add copy & cut functionality */ + $actions.= $this->parent->get_copypaste_action($val['dn'],"groups","group"); /* Add edit icon */ $actions.= "get_permissions($val['dn'],"ogroups/ogroup"); $acl_all= $ui->has_complete_category_acls($val['dn'],"ogroups"); - if($ui->is_cutable($val['dn'],"ogroups","ogroup") && $this->parent->CopyPasteHandler){ - $actions .= " "; - }else{ - $actions.="  "; - } - - if($ui->is_copyable($val['dn'],"ogroups","ogroup") && $this->parent->CopyPasteHandler){ - $actions.= " "; - }else{ - $actions.="  "; - } + /* Add copy & cut functionality */ + $actions.= $this->parent->get_copypaste_action($val['dn'],"ogroups","ogroup"); $actions.= ""; diff --git a/gosa-core/plugins/admin/users/class_divListUsers.inc b/gosa-core/plugins/admin/users/class_divListUsers.inc index ae4210b2f..61aacad3f 100644 --- a/gosa-core/plugins/admin/users/class_divListUsers.inc +++ b/gosa-core/plugins/admin/users/class_divListUsers.inc @@ -285,19 +285,8 @@ class divListUsers extends MultiSelectWindow $acl = $ui->get_permissions($val['dn'],"users/user"); $acl_all = $ui->has_complete_category_acls($val['dn'],"users"); - if($ui->is_cutable($val['dn'],"users","user") && $this->parent->CopyPasteHandler){ - $action .= " "; - }else{ - $action.="  "; - } - - if($ui->is_copyable($val['dn'],"users","user") && $this->parent->CopyPasteHandler){ - $action.= " "; - }else{ - $action.="  "; - } + /* Add copy & cut functionality */ + $action.= $this->parent->get_copypaste_action($val['dn'],"users","user"); /* Add deactivate status */ $lock_status = ""; diff --git a/gosa-plugins/fai/admin/fai/class_divListFai.inc b/gosa-plugins/fai/admin/fai/class_divListFai.inc index 2c37a07bf..1544c1a64 100644 --- a/gosa-plugins/fai/admin/fai/class_divListFai.inc +++ b/gosa-plugins/fai/admin/fai/class_divListFai.inc @@ -234,10 +234,9 @@ class divListFai extends MultiSelectWindow $ui = get_userinfo(); $action =""; $acl_all = $ui->has_complete_category_acls($this->parent->fai_base,$this->module); - if($ui->is_copyable($value['dn'],"fai",$value['class']) && $this->parent->CopyPasteHandler){ - $action .= " "; - } + + /* Add copy & cut functionality */ + $action.= $this->parent->get_copypaste_action($value['dn'],"fai",$value['class'],TRUE,FALSE); if(preg_match("/^freeze/", $value['FAIstate'])){ $editlink ="%NAME%"; diff --git a/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc index c1defca28..6fea41c61 100644 --- a/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc +++ b/gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc @@ -191,19 +191,9 @@ class divListBlocklist extends MultiSelectWindow } $action =""; - if($ui->is_cutable($val['dn'],"gofaxlist","blocklist") && $this->parent->CopyPasteHandler){ - $action .= " "; - }else{ - $action.="  "; - } - if($ui->is_copyable($val['dn'],"gofaxlist","blocklist") && $this->parent->CopyPasteHandler){ - $action.= " "; - }else{ - $action.="  "; - } + /* Add copy & cut functionality */ + $action.= $this->parent->get_copypaste_action($val['dn'],"gofaxlist","blocklist"); /* Edit link ; requires read access */ $action.= ""; diff --git a/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc b/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc index 38af27bc3..8936a3d72 100644 --- a/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc +++ b/gosa-plugins/gofon/gofon/conference/class_divListConferences.inc @@ -191,19 +191,9 @@ class divListConference extends MultiSelectWindow } $actions =""; - if($ui->is_cutable($conference['dn'],"gofonconference","conference") && $this->parent->CopyPasteHandler){ - $actions .= " "; - }else{ - $actions.="  "; - } - if($ui->is_copyable($conference['dn'],"gofonconference","conference") && $this->parent->CopyPasteHandler){ - $actions.= " "; - }else{ - $actions.="  "; - } + /* Add copy & cut functionality */ + $actions.= $this->parent->get_copypaste_action($conference['dn'],"gofonconference","conference"); /* Add edit icon - This is allowed when we have at least read access. */ $actions.= "is_cutable($val['dn'],"gofonmacro","macro") && $this->parent->CopyPasteHandler){ - $action .= " "; - }else{ - $action.="  "; - } - - if($ui->is_copyable($val['dn'],"gofonmacro","macro") && $this->parent->CopyPasteHandler){ - $action.= " "; - }else{ - $action.="  "; - } - + /* Add copy & cut functionality */ + $action.= $this->parent->get_copypaste_action($val['dn'],"gofonmacro","macro"); + $action.= ""; diff --git a/gosa-plugins/goto/admin/applications/class_divListApplication.inc b/gosa-plugins/goto/admin/applications/class_divListApplication.inc index 194654d40..8940e9c20 100644 --- a/gosa-plugins/goto/admin/applications/class_divListApplication.inc +++ b/gosa-plugins/goto/admin/applications/class_divListApplication.inc @@ -213,20 +213,8 @@ class divListApplication extends MultiSelectWindow /* Create action icons */ $actions= ""; - /* Add Copy & Paste icon */ - if($ui->is_cutable($val['dn'],"application","application") && $this->parent->CopyPasteHandler){ - $actions .= " "; - }else{ - $actions.="  "; - } - - if($ui->is_copyable($val['dn'],"application","application") && $this->parent->CopyPasteHandler){ - $actions.= " "; - }else{ - $actions.="  "; - } + /* Add copy & cut functionality */ + $actions.= $this->parent->get_copypaste_action($val['dn'],"application","application"); /* Add edit icon */ $actions.= "has_complete_category_acls($val['dn'],"devices") ; $actions = ""; - if($ui->is_cutable($val['dn'],"devices","deviceGeneric") && $this->parent->CopyPasteHandler){ - $actions .= " "; - }else{ - $actions.="  "; - } - - if($ui->is_copyable($val['dn'],"devices","deviceGeneric") && $this->parent->CopyPasteHandler){ - $actions.= " "; - }else{ - $actions.="  "; - } - + + /* Add copy & cut functionality */ + $actions.= $this->parent->get_copypaste_action($val['dn'],"devices","deviceGeneric"); + $actions.= ""; diff --git a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc index 4f669c95d..b8906fd91 100644 --- a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc +++ b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc @@ -220,19 +220,9 @@ class divListMimeTypes extends MultiSelectWindow $acl_all = $ui->has_complete_category_acls($val['dn'],"mimetypes") ; $action = ""; - if($ui->is_cutable($val['dn'],"mimetypes","mimetype") && $this->parent->CopyPasteHandler){ - $action .= " "; - }else{ - $action.="  "; - } - if($ui->is_copyable($val['dn'],"mimetypes","mimetype") && $this->parent->CopyPasteHandler){ - $action.= " "; - }else{ - $action.="  "; - } + /* Add copy & cut functionality */ + $action.= $this->parent->get_copypaste_action($val['dn'],"mimetypes","mimetype"); $action.= ""; diff --git a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc index 701218be5..1b04937b0 100644 --- a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc +++ b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc @@ -168,14 +168,8 @@ class divListSudo extends MultiSelectWindow $acl = $ui->get_permissions($val['dn'],"sudo/sudo"); $acl_all= $this->ui->get_category_permissions($val['dn'],"sudo"); - /* Add edit icon */ - $actions= ""; - if($ui->is_copyable($val['dn'],"sudo","sudo") && $this->parent->CopyPasteHandler){ - $actions.= " "; - }else{ - $actions.="  "; - } + /* Add copy & cut functionality */ + $actions = $this->parent->get_copypaste_action($val['dn'],"sudo","sudo",TRUE,FALSE); $actions.= ""; diff --git a/gosa-plugins/systems/admin/systems/class_divListSystem.inc b/gosa-plugins/systems/admin/systems/class_divListSystem.inc index f6a894d21..4d39098aa 100644 --- a/gosa-plugins/systems/admin/systems/class_divListSystem.inc +++ b/gosa-plugins/systems/admin/systems/class_divListSystem.inc @@ -366,21 +366,8 @@ class divListSystem extends MultiSelectWindow /* Get specific generic acls */ $acl = $ui->get_permissions($val['dn'],$tabs[$type]['ACL']); - $action =""; - if($ui->is_cutable($val['dn'],$category,$class) && $this->parent->CopyPasteHandler){ - $action .= " "; - }else{ - $action.="  "; - } - - if($ui->is_copyable($val['dn'],$category,$class) && $this->parent->CopyPasteHandler){ - $action.= " "; - }else{ - $action.="  "; - } - + /* Add copy & cut functionality */ + $action= $this->parent->get_copypaste_action($val['dn'],$category,$class); $action.= "";