diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc
index ead6e8de243397fc245a703fbf61960c3c116b7e..f30c50e5f4e3dbdd8fa912d81be6405c81f7e219 100644 (file)
class printerPPDDialog extends plugin
{
class printerPPDDialog extends plugin
{
- /* CLI vars */
- var $cli_summary = "Manage server basic objects";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* attribute list for save action */
var $ignore_account = TRUE;
/* attribute list for save action */
var $ignore_account = TRUE;
- var $attributes = array();
+ var $attributes = array("cn");
var $objectclasses = array("whatever");
var $objectclasses = array("whatever");
- var $ppdList = array(); // Contains all Printer models
- var $ppdListHeader = array(); // Contains all printer vendors
-
- var $dialog = NULL;
- var $selectedPPD = false; // e.g. /var/spool/ppd/vendor/device.ppd
+ /* PPD Handling */
+ var $selectedPPD = false; // e.g. /vendor/device.ppd
+ var $ppdManager = false; // new ppdManager;
+ var $ppdConfig = false; // $this->ppdManager->loadProperties($this->selectedPPD['link']);
+ var $ppdList = array(); // Contains all Printer models
+ var $ppdListHeader = array(); // Contains all printer vendors
- var $ppdManager = false; // new ppdManager;
- var $ppdConfig = false; // $this->ppdManager->loadProperties($this->selectedPPD['link']);
-
- var $pathToPPD = "/var/spool/ppd/";
+ /* Paths */
+ var $pathToPPD = ""; // Base path, defined in gosa.conf e.g. "/var/spool/ppd/"
+ var $pathToModified = "modified/"; // used to store the modified ppds
+
+ /* Object Info */
+ var $cn = "" ; // Used to tag the ppds modified by the printer object,
+ var $dialog = NULL; // Contains sub dialogs
function printerPPDDialog ($config, $dn= NULL,$ppdfile=NULL )
{
plugin::plugin ($config, $dn);
$this->depselect = $this->config->current['BASE'];
function printerPPDDialog ($config, $dn= NULL,$ppdfile=NULL )
{
plugin::plugin ($config, $dn);
$this->depselect = $this->config->current['BASE'];
- /* Load all available PPD files and sort them into an array
- */
- require_once ("class_ppdManager.inc");
- $this->ppdManager= new ppdManager($this->pathToPPD);
- $tmp = $this->ppdManager->getPrinterList();
-
- /* Sort all available files, and create header (Vendor index) */
- foreach($tmp as $file=>$ppd){
- $tmp2 = split("\n",$ppd);
- if(!isset($this->ppdListHeader[$tmp2[0]])){
- $this->ppdListHeader[$tmp2[0]]=0;
+ /* Get PPD path and remove double //, and add trailing / */
+ if(isset($_SESSION['config']->data['MAIN']['PPD_PATH'])){
+ $this->pathToPPD = $_SESSION['config']->data['MAIN']['PPD_PATH'];
+ $this->pathToPPD= preg_replace("/\/\//", "/", $this->pathToPPD);
+ if(!preg_match("/\/$/",$this->pathToPPD)){
+ $this->pathToPPD = $this->pathToPPD."/";
}
}
- $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]);
- $tmp3['link'] =preg_replace("/".str_replace("/","\/",$this->pathToPPD)."/i","",$file);
- $tmp3['ppd'] =$ppd;
- $this->ppdListHeader[$tmp2[0]]++;
- $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3;
+ }else{
+ $this->pathToPPD = "";
}
}
- /* The user has already a valid PPD assigned
- * Get some informations about this PPD
- */
- if(($ppdfile!= NULL)&&(strlen($ppdfile)>0)){
- if(!file_exists($this->pathToPPD.$ppdfile)){
- print_red(sprintf(_("Can't open '%s', ppd settings resetted."),$ppdfile));
- }else{
- $tmp2= split("\n", $this->ppdManager->loadDescription($this->pathToPPD.$ppdfile));
- $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]);
- $tmp3['link'] =$ppdfile;
- $tmp3['ppd'] =$this->ppdManager->loadDescription($this->pathToPPD.$ppdfile);
- $this->selectedPPD = $tmp3;
+ /* It seams that we have an existing PPD path, so go on */
+ if(!((!is_dir($this->pathToPPD))||(empty($this->pathToPPD)))){
+
+ /* Load all available PPD files and sort them into an array */
+ require_once ("class_ppdManager.inc");
+ $this->ppdManager= new ppdManager($this->pathToPPD);
+ $this->getPrinterReload ();
+
+ /* The user has already a valid PPD assigned
+ * Get some informations about this PPD
+ * and set it as selected.
+ * The ppdpath ['link'] should be relative from .../ppd/modified/
+ * e.g. "/Compaq/Compaq-J1200.ppd" */
+ if(($ppdfile!= NULL)&&(strlen($ppdfile)>0)){
+ $ppdfile = preg_replace("#".$this->pathToModified."#","",$ppdfile);
+ if(!file_exists($this->pathToPPD.$this->pathToModified.$ppdfile)){
+ print_red(sprintf(_("Can't open '%s', ppd settings resetted."),$ppdfile));
+ }else{
+ $res = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$ppdfile);
+ if($res){
+ $tmp = split("\n",$res);
+ $tmp3 = array();
+ $tmp3['name'] = trim(preg_replace("/^\-/","",trim($tmp[1])));
+ $tmp3['link'] = $ppdfile;
+ $tmp3['ppd'] = $res;
+ }
+ $this->selectedPPD = $tmp3;
+ }
}
}
}
}
}
}
- function getPrinterReload()
- {
- $tmp = $this->ppdManager->getPrinterList(true);
-
- /* Sort all available files, and create header (Vendor index) */
- foreach($tmp as $file=>$ppd){
- $tmp2 = split("\n",$ppd);
- if(!isset($this->ppdListHeader[$tmp2[0]])){
- $this->ppdListHeader[$tmp2[0]]=0;
- }
- $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]);
- $tmp3['link'] =$file;
- $tmp3['ppd'] =$ppd;
- $this->ppdListHeader[$tmp2[0]]++;
- $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3;
- }
-
- }
function execute()
{
function execute()
{
- /* Call parent execute */
- plugin::execute();
+ /* Call parent execute */
+ plugin::execute();
/* Fill templating stuff */
/* Fill templating stuff */
- $smarty= get_smarty();
$display= "";
$display= "";
+ $smarty= get_smarty();
+ $smarty->assign("ppdString", _("Can't get ppd informations."));
+ $smarty->assign("showOptions", "");
+
+ /* Check these paths */
+ $paths = array($this->pathToPPD, $this->pathToPPD.$this->pathToModified);
+
+ /* 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))){
+ print_red(sprintf(_("The specified path '%s' which results from PPD_PATH in your gosa.conf is invalid, can't read/write any ppd informations."),$path));
+ /* Print out template */
+ $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__)));
+ return($display);
+ }
+ }
+
+ // 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 ){
/* Is there a new PPD file uploaded ? */
if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){
$file = ($_FILES['NewPPDFile']);
if($file['size'] != 0 ){
- $res = @$this->ppdManager->loadDescription($file['tmp_name']);
- $name = (trim(preg_replace("/-/","",$res)));
- if(!empty($name)){
- $vendor = trim(preg_replace("/-.*$/i","",$res));
- $model = trim(preg_replace("/".$vendor."/","",$name));
- if(!is_dir($this->pathToPPD.$vendor)){
- if(!(@mkdir($this->pathToPPD.$vendor))){
- print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$vendor));
- }
- }
-
- if(!isset($this->ppdList[$vendor])){
- $this->ppdList[$vendor] = array();
- }
-
- if(is_dir($this->pathToPPD.$vendor)){
- $found = false;
- foreach($this->ppdList[$vendor] as $key => $val){
- if(preg_match("/".$model.".*/i",$key)){
- $found = true;
- print_red(sprintf(_("There is already a ppd file for this kind of printer.")));
- }
- }// Foreach
- if(!$found){
- $filename = $this->pathToPPD.$vendor."/".$vendor."-".preg_replace("/^[^ ]/","",str_replace("-","",$model)).".ppd";
- $fp = @fopen($filename,"w+");
- if(!$fp){
- print_red(sprintf(_("Can't save file '%s'."),$filename));
- }else{
- $str = file_get_contents($file['tmp_name']);
- fputs($fp,$str);
- @fclose($fp);
-
- $tmp2= split("\n", $res);
- $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]);
- $tmp3['link'] =$filename;
- $tmp3['ppd'] =$res;
- $this->selectedPPD = $tmp3;
- $this->getPrinterReload();
- }
- }
- }// If dir
- }else{
- print_red(_("Please specify a valid ppd file."));
+ if($name = $this->AddPPD($file['tmp_name'])){
+ $this->SelectPPD($name);
}
}else{
print_red(_("Please specify a valid ppd file."));
}
}
}else{
print_red(_("Please specify a valid ppd file."));
}
-
}
}
-
- /* Open a dialog that allow us to select different PPDs
- */
+ /* 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(isset($_POST['SelectPPD'])){
$this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD);
}
- /* The selection dialog fpr PPDs is canceled
- */
+ /* The selection dialog fpr PPDs is canceled */
if(isset($_POST['ClosePPDSelection'])){
unset($this->dialog);
$this->dialog=NULL;
}
if(isset($_POST['ClosePPDSelection'])){
unset($this->dialog);
$this->dialog=NULL;
}
-
- /* A new PPDs was selected in the PPDs selection Dialog
- * Perform a Check. If everything is fine, use the new PPD.
- */
- if(isset($_POST['SavePPDSelection'])){
- if(!isset($_POST['PPDselection'])){
- print_red(_("Please select a valid ppd."));
- }else{
- $this->selectedPPD['link'] = $_POST['PPDselection'];
- $this->ppdConfig = false;
- unset($this->dialog);
- $this->dialog=NULL;
- }
+
+ /* Div Selection */
+ if((isset($_GET['act']))&&($_GET['act']=="use")){
+ $this->SelectPPD(base64_decode($_GET['id']));
+ unset($this->dialog);
+ $this->dialog=NULL;
+
}
}
-
- /* if a dialog is open, print the dialog instead of this class
- */
+
+ /* if a dialog is open, print the dialog instead of this class */
if($this->dialog!=NULL){
$display = $this->dialog->execute();
return($display);
}
if($this->dialog!=NULL){
$display = $this->dialog->execute();
return($display);
}
+ // ENDE PPD selection / upload / dialog handling
+
/* Give smarty the information it needs */
$smarty->assign("ppdString" ,$this->getPPDInformation());
$tmp= $this->generateProperties();
/* Give smarty the information it needs */
$smarty->assign("ppdString" ,$this->getPPDInformation());
$tmp= $this->generateProperties();
$smarty->assign("showOptions", 1);
$smarty->assign("properties",$this->generateProperties());
}
$smarty->assign("showOptions", 1);
$smarty->assign("properties",$this->generateProperties());
}
-
+
/* Print out template */
$display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__)));
return($display);
}
/* Print out template */
$display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__)));
return($display);
}
- function check(){
- /* Check the given data
- */
- $message=array();
- return $message;
+
+ /* Select PPD */
+ function SelectPPD($name)
+ {
+ /* Replace base path we don't need it here
+ The path we need looks like this : "/Vendor/ModellName.ppd";
+ thats all */
+ $name = preg_replace("#".$this->pathToPPD."#","",$name);
+
+ /* Intialise some base vars */
+ $AbsoluteSourceName = $this->pathToPPD.$name;
+ $AbsoluteDestinationPath = $this->pathToPPD.$this->pathToModified;
+ $Vendor = ""; // Vendor
+ $Name = ""; // Name
+ $Modell = ""; // Modell
+ $PrinterName = ""; // The new name of the printer
+ $PPDName = "";
+
+ /* Force reload of config dialog */
+ $this->ppdConfig = false;
+ $this->selectedPPD['link'] = false;
+
+ /* Get PPD informations and set vendor / modell / name */
+ if((!file_exists($AbsoluteSourceName)) || (!is_readable($AbsoluteSourceName))){
+ print_red(sprintf(_("Can't select PPD file '%s', the file is not readable"),$AbsoluteSourceName));
+ return;
+ }
+ $res = $this->ppdManager->loadDescription($AbsoluteSourceName);
+ if($res){
+ $tmp = split("\n",$res);
+ $Name = trim(preg_replace("/^\-/","",trim($tmp[1])));
+ $Vendor = trim($tmp[0]);
+ $Model = trim(preg_replace("/".$Vendor."/","",$Name));
+ }
+
+ $PrinterName = $this->cn."-".$Name;
+ $PPDName = $Vendor."/".$PrinterName.".ppd";
+
+ /* Create the vendors path, if it doesn't exists already */
+ if(!is_dir($AbsoluteDestinationPath.$Vendor)){
+ if(!(@mkdir($AbsoluteDestinationPath.$Vendor))){
+ print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$AbsoluteDestinationPath.$Vendor));
+ return(false);
+ }
+ }
+
+ /* Create destination file handle */
+ $fp = @fopen($AbsoluteDestinationPath.$PPDName,"w+");
+ if(!$fp){
+ print_red(sprintf(_("Can't create file '%s' to store modifed ppd informations."),$AbsoluteDestinationPath.$PPDName));
+ return(false);
+ }
+
+ $str = file_get_contents($AbsoluteSourceName);
+ fputs($fp,$str);
+ @fclose($fp);
+
+ //$this->ppdManager->updateAttribute($filename,"NO_SECTION","ModelName",$printerName);
+
+ $tmp3['link'] =$PPDName;
+ $this->selectedPPD = $tmp3;
+ $this->getPrinterReload();
+ return($PPDName);
}
}
- function save_object()
+
+ /* This function adds a new ppd file to the list of available ppds.
+ All required paths and files will be created
+ $_PathOnHdd e.g. = /tmp/PHP_tmpfile213452 */
+ function AddPPD($_PathOnHdd)
{
{
- if(isset($_POST['PPDDisSubmitted'])){
- if(is_array($this->ppdConfig)){
- 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'])];
- }
- }
+ /* Check if file exists && is readable */
+ if((!is_file($_PathOnHdd)) || (!is_readable($_PathOnHdd))){
+ print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd));
+ return(false);
+ }
+
+ /* Reload list to detect changes e.g. a file has been deleted */
+ $this->getPrinterReload();
+
+ /* Get Description from ppd, & parse out some informations */
+ $res = @$this->ppdManager->loadDescription($_PathOnHdd);
+ if($res){
+ $tmp = split("\n",$res);
+ $name = trim(preg_replace("/^\-/","",trim($tmp[1])));
+ $vendor = trim($tmp[0]);
+ $model = trim(preg_replace("/".$vendor."/","",$name));
+ }
+
+ /* Check if parse was successfull */
+ if(empty($name) || empty($vendor)){
+ print_red(sprintf(_("The given ppd file '%s' seams to be invalid, can't get any modell or vendor informations."),$_PathOnHdd));
+ return(false);
+ }
+
+ /* Prepare list of ppds */
+ if(!isset($this->ppdList[$vendor])){
+ $this->ppdList[$vendor] = array();
+ }
+
+ /* Check if this ppd already exists */
+ $found = false;
+ foreach($this->ppdList[$vendor] as $key => $val){
+ if(preg_match("/".$model.".*/i",$key)){
+ $found = true;
+ print_red(sprintf(_("There is already a ppd file for this kind of printer.")));
+ return;
+ }
+ }
+
+ /* Create the vendors path, if it doesn't exists already */
+ if(!is_dir($this->pathToPPD.$vendor)){
+ if(!(@mkdir($this->pathToPPD.$vendor))){
+ print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$this->pathToPPD.$vendor));
+ return(false);
+ }
+ }
+
+ /* Create ppd file and fill in the source contents */
+ $ppdname = $vendor."/".$name.".ppd";
+ $filename = $this->pathToPPD.$ppdname;
+ $fp = fopen($filename,"w+");
+ $contents = file_get_contents($_PathOnHdd);
+
+ /* Check file handle & contents */
+ if(!$fp){
+ print_red(sprintf(_("Can't save file '%s'."),$filename));
+ return;
+ }
+ if(empty($contents)){
+ print_red(_("Uploaded ppd file is empty, can't create new ppd file."));
+ return;
+ }
+
+ /* Fille file with data */
+ fputs($fp,$contents);
+ @fclose($fp);
+
+ /* Our job is done here */
+ return($ppdname);
+ }
+
+
+ /* This function reloads the list of available printers/vendors
+ $this->ppdListHeader
+ Compaq => 1
+ $this->ppdList
+ Compaq => Compaq IJ1200 => name => Compaq IJ1200
+ link => /var/spool/ppd/Compaq/Compaq-J1200.ppd
+ ppd => Compaq - Co
+ */
+ function getPrinterReload()
+ {
+ if(is_readable($this->pathToPPD)){
+ $tmp = $this->ppdManager->getPrinterList(true);
+
+ $this->ppdListHeader = $this->ppdList = array();
+
+ /* Sort all available files, and create header (Vendor index) */
+ foreach($tmp as $file=>$ppd){
+
+ if(preg_match("#".$this->pathToModified."#",$file)) continue;
+
+ $tmp2 = split("\n",$ppd);
+ if(!isset($this->ppdListHeader[$tmp2[0]])){
+ $this->ppdListHeader[$tmp2[0]]=0;
}
}
+ $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]);
+ $tmp3['link'] =$file;
+ $tmp3['ppd'] =$ppd;
+ $this->ppdListHeader[$tmp2[0]]++;
+ $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3;
}
}
}
}
+ }
+
+
+ /* Save all options posted from ppd dialog */
+ function save_object()
+ {
+ if(!((isset($_POST['PPDDisSubmitted'])) && (is_array($this->ppdConfig)))){
+ 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'])];
+ }
+ }
+ }
}
}
-
+
+
+ /* Save modified ppd */
function save_ppd(){
function save_ppd(){
- $this->ppdManager->saveProperties($this->pathToPPD.$this->selectedPPD['link'],$this->ppdConfig);
+ if($this->ppdManager){
+ $this->ppdManager->saveProperties($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'],$this->ppdConfig);
+ }
}
}
- /* Save to LDAP */
+
+ /* Return selected ppd path, if none is selected then false */
function save()
{
/* return the selected PPD, and in future the selected options too */
function save()
{
/* return the selected PPD, and in future the selected options too */
- return($this->selectedPPD['link']);
+ return($this->pathToModified.$this->selectedPPD['link']);
}
}
+
+ /* Get Information for a single PPD entry
+ * This will be shown on top of template
+ */
function getPPDInformation()
{
function getPPDInformation()
{
- /* Get Information for a single PPD entry
- * This will be shown on top of template
- */
$str = "none";
if(!empty($this->selectedPPD)){
$str = "none";
if(!empty($this->selectedPPD)){
- $str = $this->ppdManager->loadDescription($this->pathToPPD.$this->selectedPPD['link']);
+ $str = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']);
}
return($str) ;
}
}
return($str) ;
}
+
+ /* Display all options from the selected ppd file */
function generateProperties()
{
function generateProperties()
{
- /* In future there will be a schema parser that provide us all settings that can be made in the selected PPD file.
- * This function will generate a userfriendly post based form with this informations
- */
-
/* Set Headline */
$str = "";
$feed= "";
/* Set Headline */
$str = "";
$feed= "";
- $s_ppd = $this->pathToPPD.$this->selectedPPD['link'];
+ $s_ppd = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'];
/* If ppd exists and is readable */
if((!empty($this->selectedPPD['link']))&&(file_exists($s_ppd))){
/* If ppd exists and is readable */
if((!empty($this->selectedPPD['link']))&&(file_exists($s_ppd))){
-
+
/* If there is no initial Configuration, load it */
if($this->ppdConfig == false){
$this->ppdConfig = $this->ppdManager->loadProperties($s_ppd);
}
/* Create a table */
/* If there is no initial Configuration, load it */
if($this->ppdConfig == false){
$this->ppdConfig = $this->ppdManager->loadProperties($s_ppd);
}
/* Create a table */
- $str .= "<div style='padding-left:30px;'><table>";
+ $str .= "<div style='padding-left:30px;'><table summary=''>";
/* Input all data to the table */
foreach($this->ppdConfig as $cat => $obj){
/* Input all data to the table */
foreach($this->ppdConfig as $cat => $obj){
-
+
/* Add new category */
$str .= "<tr><td colspan='2'>$feed";
if ($feed == ""){
$feed= "<br>";
}
$str .= "<b>"._("Section")." '".$cat."' </b><br>";
/* Add new category */
$str .= "<tr><td colspan='2'>$feed";
if ($feed == ""){
$feed= "<br>";
}
$str .= "<b>"._("Section")." '".$cat."' </b><br>";
- $str .= "</tr></td>";
+ $str .= "</td></tr>";
/* Add attributes of the current category */
foreach($obj as $attr => $settings){
/* Add attributes of the current category */
foreach($obj as $attr => $settings){
-
-
+
/* Skip all entries beginning with _ */
if($attr[0] == "_") continue;
/* Skip all entries beginning with _ */
if($attr[0] == "_") continue;
-
+
/* Prepare data */
$values = array();
$name = $settings['_name'];
/* Prepare data */
$values = array();
$name = $settings['_name'];
- $default = $settings['_default'];
+ if (!isset($settings['_default'])){
+ $default = "";
+ } else {
+ $default = $settings['_default'];
+ }
$type = $settings['_type'];
$type = $settings['_type'];
-
+
/* Add name to table */
$str .= "<tr><td style='padding-left:40px;'>\n";
$str .= $name."<br>\n";
$str .= "</td><td>\n";
/* Add name to table */
$str .= "<tr><td style='padding-left:40px;'>\n";
$str .= $name."<br>\n";
$str .= "</td><td>\n";
-
+
/* Get all values */
foreach( $settings as $vname => $value){
if($vname[0] != "_"){
/* Get all values */
foreach( $settings as $vname => $value){
if($vname[0] != "_"){
if(($type == "PickOne")||(($type=="Boolean")&&(count($values)>1))){
$str .= "<select name='".base64_encode($name)."'>\n";
if(($type == "PickOne")||(($type=="Boolean")&&(count($values)>1))){
$str .= "<select name='".base64_encode($name)."'>\n";
- foreach($values as $value){
+ foreach($values as $optionKey => $value){
$selected = "";
$selected = "";
- if($value == $default){
+ if($optionKey == $default){
$selected = " selected ";
}
$selected = " selected ";
}
- $str .= "<option value='".$value."' ".$selected.">".$value."</option>\n";
+ $str .= "<option value='".$optionKey."' ".$selected.">".$value."</option>\n";
}
$str .= "</select>\n";
}
$str .= "</select>\n";
}
}
$str .= "</table></div>\n";
}
}
$str .= "</table></div>\n";
-
}
return($str);
}
}
return($str);
}
+
+ function removeModifiedPPD()
+ {
+ $path = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'];
+
+ if(file_exists($path)){
+ if(is_writeable($path)){
+ if(!@unlink($path)){
+ print_red(sprintf(_("Removing old ppd file '%s' failed."),$path));
+ }
+ }else{
+ print_red(sprintf(_("Removing old ppd file '%s' failed. File is not accessible."),$path));
+ }
+ }else{
+ print_red(sprintf(_("Removing old ppd file '%s' failed. File does not exists or is not accessible."),$path));
+ }
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ if(empty($this->selectedPPD['link'])){
+ $message[] = _("Please select a valid ppd file or use 'Cancel' to go back to printer configuration.");
+ }
+ return($message);
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>