Code

Centralized copy & paste icon creation && permission checks
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 May 2008 08:35:32 +0000 (08:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 May 2008 08:35:32 +0000 (08:35 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11098 594d385d-05f5-0310-b6e9-bd551577e9d8

14 files changed:
gosa-core/include/class_plugin.inc
gosa-core/plugins/admin/acl/class_divListACL.inc
gosa-core/plugins/admin/groups/class_divListGroup.inc
gosa-core/plugins/admin/ogroups/class_divListOGroup.inc
gosa-core/plugins/admin/users/class_divListUsers.inc
gosa-plugins/fai/admin/fai/class_divListFai.inc
gosa-plugins/gofax/gofax/blocklists/class_divListBlocklists.inc
gosa-plugins/gofon/gofon/conference/class_divListConferences.inc
gosa-plugins/gofon/gofon/macro/class_divListMacros.inc
gosa-plugins/goto/admin/applications/class_divListApplication.inc
gosa-plugins/goto/admin/devices/class_divListDevices.inc
gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc
gosa-plugins/sudo/admin/sudo/class_divListSudo.inc
gosa-plugins/systems/admin/systems/class_divListSystem.inc

index 0cabed07fa4c55900da79fd9fe53687ead199274..f038fbf56d858f51b120db60966f3be939cf08e9 100644 (file)
@@ -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 .= "<input class='center' type='image'
+            src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+        }else{
+          $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
+        }
+      }
+      if($copy){
+        if($ui->is_copyable($base,$category,$class)){
+          $action.= "<input class='center' type='image'
+            src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+        }else{
+          $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
+        }
+      }
+    }
+
+    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());
index 9f19842eb1301c642eecba13c527fefd6ba6f7ff..f1e92b2f9e2da4693cc17f75c8f2160569246dd8 100644 (file)
@@ -206,21 +206,8 @@ class divListACL extends MultiSelectWindow
           $cn .= "&nbsp;[".$acl_entry['description'][0]."]";
         }
 
-        /* Add copy & paste handler */
-        if($ui->is_cutable($acl_entry['dn'],"aclroles","aclRole") && $this->parent->CopyPasteHandler){
-          $action .= "<input class='center' type='image'
-            src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-        }else{
-          $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-        }
-
-        if($ui->is_copyable($acl_entry['dn'],"aclroles","aclRole") && $this->parent->CopyPasteHandler){
-          $action.= "<input class='center' type='image'
-            src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-        }else{
-          $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-        }
-
+        /* 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)){
index b2bf8fbdfa82e191db0491d35e0935aae15d367d..7c42291e4ce1c156a62ffbba5e21b35aee96da34 100644 (file)
@@ -282,19 +282,8 @@ class divListGroup extends MultiSelectWindow
 
       $actions= "";
 
-      if($ui->is_cutable($val['dn'],"groups","group") && $this->parent->CopyPasteHandler){
-        $actions .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
-      if($ui->is_copyable($val['dn'],"groups","group") && $this->parent->CopyPasteHandler){
-        $actions.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* Add copy & cut functionality */
+      $actions.= $this->parent->get_copypaste_action($val['dn'],"groups","group");
 
       /* Add edit icon */
       $actions.= "<input class='center' type='image'
index d5247015951e4a3a0922a5d5a6b1435d5288b9a2..74e7c7447ad33546e4a47e2b6b0b170943cfb673 100644 (file)
@@ -264,19 +264,8 @@ class divListOGroup extends MultiSelectWindow
       $acl    = $ui->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 .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
-      if($ui->is_copyable($val['dn'],"ogroups","ogroup") && $this->parent->CopyPasteHandler){
-        $actions.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* Add copy & cut functionality */
+      $actions.= $this->parent->get_copypaste_action($val['dn'],"ogroups","ogroup");
 
       $actions.= "<input class='center' type='image'
         src='images/lists/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
index ae4210b2fb0afb9f0f9d9776c653c29101184b5a..61aacad3f116284072940b636bc79d88275dd0b7 100644 (file)
@@ -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 .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
-      if($ui->is_copyable($val['dn'],"users","user") && $this->parent->CopyPasteHandler){
-        $action.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* Add copy & cut functionality */
+      $action.= $this->parent->get_copypaste_action($val['dn'],"users","user");
 
       /* Add deactivate status */
       $lock_status = "";
index 2c37a07bf0996095d67ea7bd9e16109a96bafe49..1544c1a648565eee71b57da4547c052151c7aea8 100644 (file)
@@ -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 .= "<input class='center' type='image'
-           src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-       }
+
+       /* Add copy & cut functionality */
+       $action.= $this->parent->get_copypaste_action($value['dn'],"fai",$value['class'],TRUE,FALSE);
 
        if(preg_match("/^freeze/", $value['FAIstate'])){
          $editlink ="<a href='?plug=".$_GET['plug']."&amp;edit_freeze_entry=%KEY%' title='%TITLE%'>%NAME%</a>";
index c1defca282d1dedea244a0f0ea36c2544224ac56..6fea41c613cd98a98bbd43ae4a89a343428a2250 100644 (file)
@@ -191,19 +191,9 @@ class divListBlocklist extends MultiSelectWindow
       }  
 
       $action ="";
-      if($ui->is_cutable($val['dn'],"gofaxlist","blocklist") && $this->parent->CopyPasteHandler){
-        $action .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
 
-      if($ui->is_copyable($val['dn'],"gofaxlist","blocklist") && $this->parent->CopyPasteHandler){
-        $action.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* Add copy & cut functionality */
+      $action.= $this->parent->get_copypaste_action($val['dn'],"gofaxlist","blocklist");
 
       /* Edit link ; requires read access */
       $action.= "<input class='center' type='image' src='images/lists/edit.png' alt='"._("edit")."'     name='goFaxBlocklist_edit_%KEY%' title='"._("Edit user")."'>";
index 38af27bc3b71f66a1450416bca073fa644510b2f..8936a3d72e11e229cebb971b7e22c5cc5d750f94 100644 (file)
@@ -191,19 +191,9 @@ class divListConference extends MultiSelectWindow
       }
 
       $actions ="";
-      if($ui->is_cutable($conference['dn'],"gofonconference","conference") && $this->parent->CopyPasteHandler){
-        $actions .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
 
-      if($ui->is_copyable($conference['dn'],"gofonconference","conference") && $this->parent->CopyPasteHandler){
-        $actions.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* 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.= "<input class='center' type='image' src='images/lists/edit.png'     
index 4b29021c29b177da61dc1619705dd2f24357b2d5..172e636d1dbb39e28653685bae0ab86cbc8d4e74 100644 (file)
@@ -189,20 +189,9 @@ class divListMacro extends MultiSelectWindow
         continue;
       }
 
-      if($ui->is_cutable($val['dn'],"gofonmacro","macro") && $this->parent->CopyPasteHandler){
-        $action .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
-      if($ui->is_copyable($val['dn'],"gofonmacro","macro") && $this->parent->CopyPasteHandler){
-        $action.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
+      /* Add copy & cut functionality */
+      $action.= $this->parent->get_copypaste_action($val['dn'],"gofonmacro","macro");
+  
       $action.= "<input class='center' type='image' src='images/lists/edit.png' alt='"._("edit")."'     
         name='goFonMacro_edit_%KEY%' title='"._("Edit macro")."'>";
 
index 194654d40fc17eed2f47b17df56852c3cb37856e..8940e9c202aa8b9490567426c80c70fa21a2c27f 100644 (file)
@@ -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 .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
-      if($ui->is_copyable($val['dn'],"application","application") && $this->parent->CopyPasteHandler){
-        $actions.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* Add copy & cut functionality */
+      $actions.= $this->parent->get_copypaste_action($val['dn'],"application","application");
 
       /* Add edit icon */
       $actions.= "<input class='center' type='image'
index 7ff3b2b2aa7537000f198c16ecf3abcb3b6eccba..200fe2d8b61cb22490f2a95d1b32b679a7a92652 100644 (file)
@@ -197,20 +197,10 @@ class divListDevices extends MultiSelectWindow
       $acl_all  = $ui->has_complete_category_acls($val['dn'],"devices") ;
 
       $actions = "";
-      if($ui->is_cutable($val['dn'],"devices","deviceGeneric") && $this->parent->CopyPasteHandler){
-        $actions .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
-      if($ui->is_copyable($val['dn'],"devices","deviceGeneric") && $this->parent->CopyPasteHandler){
-        $actions.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
+      
+      /* Add copy & cut functionality */
+      $actions.= $this->parent->get_copypaste_action($val['dn'],"devices","deviceGeneric");
+      
       $actions.= "<input class='center' type='image'
         src='images/lists/edit.png' alt='"._("edit")."' name='device_edit_%KEY%' title='"._("Edit this entry")."'>";
 
index 4f669c95dc8796183ca115995ca3d000008a00cd..b8906fd912d73f5f4045de9f5dc3d562176b44cb 100644 (file)
@@ -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 .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
 
-      if($ui->is_copyable($val['dn'],"mimetypes","mimetype") && $this->parent->CopyPasteHandler){
-        $action.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* Add copy & cut functionality */
+      $action.= $this->parent->get_copypaste_action($val['dn'],"mimetypes","mimetype");
 
       $action.= "<input class='center' type='image'
         src='images/lists/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
index 701218be50f4296a0940801ec00b77c53f2aa406..1b04937b0a30a73bcf539d4faa9e193e006f3f47 100644 (file)
@@ -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.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $actions.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
+      /* Add copy & cut functionality */
+      $actions = $this->parent->get_copypaste_action($val['dn'],"sudo","sudo",TRUE,FALSE);
 
       $actions.= "<input class='center' type='image'
         src='images/lists/edit.png' alt='".msgPool::editButton()."' name='sudo_edit_%KEY%' title='"._("Edit this entry")."'>";
index f6a894d2147f4d8c35912ef4a9afd0e68c60e551..4d39098aaa52f52c716d227185b372c8f07fcb7b 100644 (file)
@@ -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 .= "<input class='center' type='image'
-          src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
-      if($ui->is_copyable($val['dn'],$category,$class) && $this->parent->CopyPasteHandler){
-        $action.= "<input class='center' type='image'
-          src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
-      }else{
-        $action.="<img src='images/empty.png' alt=' ' class='center'>&nbsp;";
-      }
-
+      /* Add copy & cut functionality */
+      $action= $this->parent->get_copypaste_action($val['dn'],$category,$class);
 
       $action.= "<input class='center' type='image' src='images/lists/edit.png' 
                     alt='"._("edit")."'     name='system_edit_%KEY%' title='"._("Edit system")."'>";