From 418e9bd3697e3e445169ab9d4489556df0559e60 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 23 Oct 2008 07:24:48 +0000 Subject: [PATCH] Updated ppd handling -Disable options which are not writeable, hide ppd selections and gray-out save button. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12758 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/ppd/class_printerPPDDialog.inc | 54 ++++++++++++------- .../admin/systems/ppd/printerPPDDialog.tpl | 8 +++ 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc b/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc index b9ffea903..db3d54a25 100644 --- a/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc +++ b/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc @@ -20,6 +20,7 @@ class printerPPDDialog extends plugin /* Object Info */ var $cn = "" ; // Used to tag the ppds modified by the printer object, + var $ui; /* If there is already a ppd file for the same type of printer, * remember the path to ppd file and display a dialog which allows @@ -33,6 +34,8 @@ class printerPPDDialog extends plugin plugin::plugin ($config, $dn); $this->depselect = $this->config->current['BASE']; + $this->ui = get_userinfo(); + /* Get PPD path and remove double //, and add trailing / */ $config = session::get('config'); if($config->get_cfg_value("ppdPath") != ""){ @@ -94,8 +97,11 @@ class printerPPDDialog extends plugin $smarty->assign("ppdString", _("Can't get ppd informations.")); $smarty->assign("showOptions", ""); $smarty->assign("path_valid", TRUE); + $smarty->assign("acl",$this->ui->get_permissions($this->dn,"printer/printgeneric","gotoPrinterPPD")); + + $acl = $this->ui->get_permissions($this->dn,"printer/printgeneric","gotoPrinterPPD"); - if(empty($this->ppdPath)){ + if(empty($this->pathToPPD)){ /* Print out template */ $smarty->assign("path_valid", FALSE); @@ -108,11 +114,12 @@ class printerPPDDialog extends plugin /* If one of our required paths is not available, stop here and display some info */ foreach($paths as $path){ - + /* Check if path is write/readable*/ $is_r = @is_readable($path); if(((!is_dir($path))||(empty($path)) || (!$is_r)) && (!@mkdir($path))){ - msg_dialog::display(_("Configuration error"), sprintf(_("Cannot open PPD path '%s' for reading and writing!"), $path), ERROR_DIALOG); + msg_dialog::display(_("Configuration error"), + sprintf(_("Cannot open PPD path '%s' for reading and writing!"), $path), ERROR_DIALOG); /* Print out template */ $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__))); @@ -123,14 +130,16 @@ class printerPPDDialog extends plugin // PPD selection / upload / dialog handling /* Is there a new PPD file uploaded ? */ - if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){ - $file = ($_FILES['NewPPDFile']); - if($file['size'] != 0 ){ - if($name = $this->AddPPD($file['tmp_name'])){ - $this->SelectPPD($name); + if(preg_match("/w/",$acl)){ + if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){ + $file = ($_FILES['NewPPDFile']); + if($file['size'] != 0 ){ + if($name = $this->AddPPD($file['tmp_name'])){ + $this->SelectPPD($name); + } + }else{ + msg_dialog::display(_("PPD error"), msgPool::incorrectUpload(_("file is empty")), ERROR_DIALOG); } - }else{ - msg_dialog::display(_("PPD error"), msgPool::incorrectUpload(_("file is empty")), ERROR_DIALOG); } } @@ -144,8 +153,10 @@ class printerPPDDialog extends plugin } /* Open a dialog that allow us to select different PPDs */ - if(isset($_POST['SelectPPD'])){ - $this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD); + if(preg_match("/w/",$acl)){ + if(isset($_POST['SelectPPD'])){ + $this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD); + } } /* The selection dialog fpr PPDs is canceled */ @@ -381,10 +392,12 @@ class printerPPDDialog extends plugin return; } - foreach($this->ppdConfig as $cat => $obj){ - foreach($obj as $attr => $attributes){ - if(isset($_POST[base64_encode($attributes['_name'])])){ - $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])]; + if(preg_match("/w/",$this->ui->get_permissions($this->dn,"printer/printgeneric","gotoPrinterPPD"))){ + foreach($this->ppdConfig as $cat => $obj){ + foreach($obj as $attr => $attributes){ + if(isset($_POST[base64_encode($attributes['_name'])])){ + $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])]; + } } } } @@ -482,6 +495,11 @@ class printerPPDDialog extends plugin } } + $acl =""; + if(!preg_match("/w/",$this->ui->get_permissions($this->dn,"printer/printgeneric","gotoPrinterPPD"))){ + $acl = "disabled"; + } + /* preparing Html output * Supported types are PickOne/Boolean */ @@ -489,7 +507,7 @@ class printerPPDDialog extends plugin /* If type is PickOne, create a select box */ if(($type == "PickOne")||(($type=="Boolean")&&(count($values)>1))){ - $str .= "\n"; foreach($values as $optionKey => $value){ $selected = ""; if($optionKey == $default){ @@ -502,7 +520,7 @@ class printerPPDDialog extends plugin }elseif($type == "Boolean"){ /* If type is Boolean & no values are given */ - $str .= "\n"; if($default == "False"){ $str .= "\n"; $str .= "\n"; diff --git a/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl b/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl index 8cafc3b26..e1845673d 100644 --- a/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl +++ b/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl @@ -8,12 +8,18 @@ {t}Model{/t}: {$ppdString}  + {render acl=$acl} + {/render} {t}New driver{/t}  + {render acl=$acl} + {/render} + {render acl=$acl} + {/render} @@ -26,7 +32,9 @@

{if $path_valid} + {render acl=$acl} + {/render} {/if}

-- 2.30.2