Code

Added acls for printer glpi
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Sep 2006 09:28:59 +0000 (09:28 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Sep 2006 09:28:59 +0000 (09:28 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4725 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_glpiPrinterAccount.inc
plugins/admin/systems/glpiPrinter.tpl

index b9a009d04f10f93887eff813c3efb73818541f0f..61fd547884a18e17ba2edeb84ffd1ef2837f94a7 100644 (file)
@@ -136,18 +136,23 @@ class glpiPrinterAccount extends plugin
     $smarty= get_smarty();
     $display= "";
 
-    $smarty->assign("CartridgesACL",chkacl($this->acl,"Cartridges"));
+    $smarty->assign("CartridgesACL",$this->getacl("Cartridges"));
 
     /*  Assign smarty defaults 
         To avoid undefined indexes, if there is an error with the glpi db
      */ 
-    foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers","Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
+    foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers",
+                  "Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
       $smarty->assign($attr,array());
-      $smarty->assign($attr."ACL"," disabled ");
     }
     foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){
       $smarty->assign($attr,"");
-      $smarty->assign($attr."ACL"," disabled ");
+    }
+
+    /* Assign acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
     }
 
     /* Check if there is a glpi database server defined 
@@ -190,8 +195,12 @@ class glpiPrinterAccount extends plugin
      */
 
     /* Do we need to flip is_account state? */
-    if (isset($_POST['modify_state'])){
-      $this->is_account= !$this->is_account;
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
     }
 
     /* Show tab dialog headers */
@@ -211,7 +220,7 @@ class glpiPrinterAccount extends plugin
      */
 
     /* Rename was requested */
-    if(isset($_POST['Rename_PType_OK'])){
+    if(isset($_POST['Rename_PType_OK']) && $this->acl_is_writeable("type")){
       $tmp = $this->handle->getPrinterTypes();
       $allok = true;
       foreach($tmp as $id => $name){
@@ -235,7 +244,7 @@ class glpiPrinterAccount extends plugin
 
     /* Printer type management
      */
-    if(isset($_POST['edit_type'])){
+    if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
       $this->dialog = true;
       $this->edit_type=true;
     }
@@ -249,7 +258,7 @@ class glpiPrinterAccount extends plugin
 
     /* This appends a new printer to our sytem types
      */
-    if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){
+    if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
     
       $tmp = $this->handle->getPrinterTypes();
       $allok = true;
@@ -267,7 +276,7 @@ class glpiPrinterAccount extends plugin
 
     /* Remove selected type from our printer types list
      */
-    if((isset($_POST['del_type']))&&(!empty($_POST['select_type']))){
+    if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
       $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']);
       if(count($tmp)){
         $str = "";
@@ -283,7 +292,7 @@ class glpiPrinterAccount extends plugin
 
     /* Rename selected printer type to given string
      */
-    if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename)){
+    if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename) && $this->acl_is_writeable("type")){
       $this->rename = true;
 
       $smarty->assign("Method","rename");
@@ -321,7 +330,7 @@ class glpiPrinterAccount extends plugin
 
     /* Open dialog which allows to edit the manufacturers
      */
-    if(isset($_POST['edit_manufacturer'])){
+    if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
       $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
       $this->dialog = true;
       $this->editManufacturer =true;
@@ -345,14 +354,14 @@ class glpiPrinterAccount extends plugin
     /* Show dialog to select a new contact person
      * Select a contact person
      */
-    if(isset($_POST['SelectContactPerson'])){
+    if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
       $this->addUser = "contact";
       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
     }
 
     /* Selecte technical responsible person
      */
-    if(isset($_POST['SelectTechPerson'])){
+    if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
       $this->addUser ="tech";
       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
     }
@@ -418,7 +427,7 @@ class glpiPrinterAccount extends plugin
     
     /* Attachment pool was closed with use
      */
-    if(isset($_POST['UseAttachment'])){
+    if(isset($_POST['UseAttachment']) && $this->acl_is_writeable("Attachments")){
       if(count($this->cur_dialog->check())){
         foreach($this->cur_dialog->check() as $msg){
           print_red($msg);
@@ -440,7 +449,7 @@ class glpiPrinterAccount extends plugin
 
     /* Open Attachment pool to add/edit Attachments
      */
-    if(isset($_POST['AddAttachment'])){
+    if(isset($_POST['AddAttachment']) && $this->acl_is_writeable("Attachments")){
       $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
       $this->dialog = true;
     }
@@ -449,7 +458,7 @@ class glpiPrinterAccount extends plugin
      */
     $once = true;
     foreach($_POST as $name => $value){
-      if((preg_match("/^delAttachment_/",$name))&&($once)){
+      if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
         $once= false;
         $name = preg_replace("/^delAttachment_/","",$name);
         $entry = preg_replace("/_.*$/","",$name);
@@ -458,7 +467,7 @@ class glpiPrinterAccount extends plugin
         }
       }
     }
-    if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments']))){
+    if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && $this->acl_is_writeable("Attachments")){
       if(isset($this->usedAttachments[$_POST['Attachments']])){
         unset($this->usedAttachments[$_POST['Attachments']]);
       }
@@ -490,7 +499,7 @@ class glpiPrinterAccount extends plugin
 
     /* Remove cartridge  
      */
-    if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges']))){
+    if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges'])) && $this->acl_is_writeable("ManageCartridges")){
 
       foreach($_POST['Cartridges'] as $cartID){
 
@@ -506,7 +515,7 @@ class glpiPrinterAccount extends plugin
 
     /* Open Attachment pool to add/edit Attachments
      */
-    if(isset($_POST['AddCartridge'])){
+    if(isset($_POST['AddCartridge']) && $this->acl_is_writeable("ManageCartridges")){
       $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
       $this->dialog = true;
     }
@@ -534,20 +543,12 @@ class glpiPrinterAccount extends plugin
     /* Assign smarty defaults */ 
     foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){
       $smarty->assign($attr,array());
-      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
     }
 
     /* Assign some vars to smarty 
      */
     foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){
       $smarty->assign($attr,"");
-      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
-    }
-
-
-    /* Assign ACLs to smarty*/
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
     }
 
     $smarty->assign("comments",               $this->comments);
@@ -636,7 +637,7 @@ class glpiPrinterAccount extends plugin
       }
     }
     if($disp==false){
-      $smarty->assign("typeACL","disabled");
+      $smarty->assign("typeACL", $this->getacl("type",true));
     }
 
     $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
@@ -664,10 +665,12 @@ class glpiPrinterAccount extends plugin
       }
 
       foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
-        if(isset($_POST[$checkboxes])){
-          $this->$checkboxes = 1;
-        }else{
-          $this->$checkboxes = 0;
+        if($this->acl_is_writeable($checkboxes)){
+          if(isset($_POST[$checkboxes])){
+            $this->$checkboxes = 1;
+          }else{
+            $this->$checkboxes = 0;
+          }
         }
       }
     }
@@ -780,10 +783,7 @@ class glpiPrinterAccount extends plugin
             "type"                 => _("Type"),
             "FK_glpi_enterprise"   => _("Manufacturer"),
 
-            "Attachment_name"             => _("Attachment name"),
-            "Attachment_comment"          => _("Attachment comment"),
-            "Attachment_mime"             => _("Attachment mime type"),
-            "Attachment_filename"         => _("Attachment filename"),
+            "Attachments"          => _("Attachments"),
         
             "ManageCartridges"            => _("Cartridge settings"))
           ));
index f47f88b5c1aa2328d8e02657d690d9fd8d01ebe5..225f52e7c06b4802f39c7d01be8e366d468db857 100644 (file)
@@ -9,20 +9,28 @@
                                        <td width="150">{t}Printer type{/t}
                                        </td>
                                        <td>
-                                               <select name="type" {$typeACL}>
+{render acl=$typeACL}
+                                               <select name="type" >
                                                        {html_options values=$PrinterTypeKeys output=$PrinterTypes selected=$type}
                                                </select>
-                                               <input type="submit" value="{t}edit{/t}" name="edit_type" {$typeACL}>   
+{/render}
+{render acl=$typeACL}
+                                               <input type="submit" value="{t}edit{/t}" name="edit_type" >     
+{/render}
                                        </td>
                                </tr>
                                <tr>
                                        <td>{t}Manufacturer{/t}
                                        </td>
                                        <td>
-                                               <select name="FK_glpi_enterprise" {$FK_glpi_enterpriseACL}>
+{render acl=$FK_glpi_enterpriseACL}
+                                               <select name="FK_glpi_enterprise" >
                                                        {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
                                                </select>       
-                                               <input type="submit" value="{t}edit{/t}" name="edit_manufacturer" {$FK_glpi_enterpriseACL}>     
+{/render}
+{render acl=$FK_glpi_enterpriseACL}
+                                               <input type="submit" value="{t}edit{/t}" name="edit_manufacturer" >     
+{/render}
                                        </td>
                                </tr>
                        </table>
@@ -32,7 +40,9 @@
                        <table summary="" width="100%">
                                <tr>
                                        <td width="20">
-                                               <input type="checkbox" name="flags_serial" {if $flags_serial=="1"} checked {/if} value="1" {$flags_serialACL}>
+{render acl=$flags_serialACL}
+                                               <input type="checkbox" name="flags_serial" {if $flags_serial=="1"} checked {/if} value="1" >
+{/render}
                                        </td>
                                        <td>
                                                {t}Serial{/t}
@@ -40,7 +50,9 @@
                                </tr>
                                <tr>
                                        <td width="20">
-                                               <input type="checkbox" name="flags_par" {if $flags_par=="1"} checked {/if} value="1" {$flags_parACL}>
+{render acl=$flags_parACL}
+                                               <input type="checkbox" name="flags_par" {if $flags_par=="1"} checked {/if} value="1" >
+{/render}
                                        </td>
                                        <td>
                                                {t}Parallel{/t}
@@ -48,7 +60,9 @@
                                </tr>
                                <tr>
                                        <td width="20">
-                                               <input type="checkbox" name="flags_usb" {if $flags_usb=="1"} checked {/if} value="1" {$flags_usbACL}>
+{render acl=$flags_usbACL}
+                                               <input type="checkbox" name="flags_usb" {if $flags_usb=="1"} checked {/if} value="1" >
+{/render}
                                        </td>
                                        <td>
                                                {t}USB{/t}
@@ -70,7 +84,9 @@
                                        </td>
                                        <td>
                                                <i>{$tech_num}&nbsp; </i>&nbsp;
-                                               <input type="submit" value="{t}Edit{/t}" name="SelectTechPerson" {$tech_numACL}>
+{render acl=$tech_numACL}
+                                               <input type="submit" value="{t}Edit{/t}" name="SelectTechPerson" >
+{/render}
                                        </td>
                                </tr>
                                <tr>
                                        </td>
                                        <td>
                                                <i>{$contact_num}&nbsp; </i>&nbsp;
-                                               <input {$contact_numACL} type="submit" name="SelectContactPerson" value="{t}Edit{/t}">
+{render acl=$contact_numACL}
+                                               <input type="submit" name="SelectContactPerson" value="{t}Edit{/t}">
+{/render}
+
                                        </td>
                                </tr>
                        </table>
                        <table summary="" width="100%"> 
                                <tr>
                                        <td>
+{render acl=$AttachmentsACL}
                                                {$AttachmentsDiv}
-                                               <input name="AddAttachment"     value="{t}Add{/t}" type="submit" {$AttachmentsACL}>     
+{/render}
+{render acl=$AttachmentsACL}
+                                               <input name="AddAttachment"     value="{t}Add{/t}" type="submit" >      
+{/render}
                                        </td>
                                </tr>
                        </table>
                        <table summary="" width="100%">
                                <tr>
                                        <td width="100%">
-                                               <textarea name="comments" style="width:100%;height:100px;" {$commentsACL}>{$comments}</textarea>
+{render acl=$commentsACL}
+                                               <textarea name="comments" style="width:100%;height:100px;" >{$comments}</textarea>
+{/render}
                                        </td>
                                </tr>
                        </table>
                        <table summary="" width="100%"> 
                                <tr>
                                        <td>
-                                               <select name="Cartridges[]" {$CartridgesACL} style="height:100px;width:100%;" multiple>
+{render acl=$CartridgesACL}
+                                               <select name="Cartridges[]"  style="height:100px;width:100%;" multiple>
                                                        {html_options values=$CartridgeKeys output=$Cartridges}
                                                </select>
-                                               <input name="AddCartridge"      value="{t}Add{/t}" type="submit" {$CartridgesACL}>      
-                                               <input name="RemoveCartridge"   value="{t}Remove{/t}" type="submit" {$CartridgesACL}>   
+{/render}
+{render acl=$CartridgesACL}
+                                               <input name="AddCartridge"      value="{t}Add{/t}" type="submit" >      
+{/render}
+{render acl=$CartridgesACL}
+                                               <input name="RemoveCartridge"   value="{t}Remove{/t}" type="submit" >   
+{/render}
                                        </td>
                                </tr>
                        </table>