diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc
index d35eccbc965777bc1d6c2249b46d5ac209d493e9..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;
var $attributes = array("cn");
/* attribute list for save action */
var $ignore_account = TRUE;
var $attributes = array("cn");
/* Load all available PPD files and sort them into an array */
require_once ("class_ppdManager.inc");
$this->ppdManager= new ppdManager($this->pathToPPD);
/* 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;
- }
- $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;
- }
+ $this->getPrinterReload ();
/* The user has already a valid PPD assigned
* Get some informations about this PPD
/* The user has already a valid PPD assigned
* Get some informations about this PPD
}
}
-
function execute()
{
/* Call parent execute */
function execute()
{
/* Call parent execute */
/* Check if path is write/readable*/
$is_r = @is_readable($path);
/* Check if path is write/readable*/
$is_r = @is_readable($path);
- if((!is_dir($path))||(empty($path)) || (!$is_r)){
- 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));
+ 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);
}
}
/* 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']);
/* Is there a new PPD file uploaded ? */
if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){
$file = ($_FILES['NewPPDFile']);
}
}
}
}
-
- /* 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->SelectPPD($_POST['PPDselection']);
- unset($this->dialog);
- $this->dialog=NULL;
- }
- }
-
/* Div Selection */
if((isset($_GET['act']))&&($_GET['act']=="use")){
$this->SelectPPD(base64_decode($_GET['id']));
/* Div Selection */
if((isset($_GET['act']))&&($_GET['act']=="use")){
$this->SelectPPD(base64_decode($_GET['id']));
}
}
- /* 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();
*/
function getPrinterReload()
{
*/
function getPrinterReload()
{
- $tmp = $this->ppdManager->getPrinterList(true);
+ if(is_readable($this->pathToPPD)){
+ $tmp = $this->ppdManager->getPrinterList(true);
- $this->ppdListHeader = $this->ppdList = array();
+ $this->ppdListHeader = $this->ppdList = array();
- /* Sort all available files, and create header (Vendor index) */
- foreach($tmp as $file=>$ppd){
+ /* Sort all available files, and create header (Vendor index) */
+ foreach($tmp as $file=>$ppd){
- if(preg_match("#".$this->pathToModified."#",$file)) continue;
+ if(preg_match("#".$this->pathToModified."#",$file)) continue;
- $tmp2 = split("\n",$ppd);
- if(!isset($this->ppdListHeader[$tmp2[0]])){
- $this->ppdListHeader[$tmp2[0]]=0;
+ $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;
}
}
- $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;
}
}
}
}
}
}
}
}
+
/* Return selected ppd path, if none is selected then false */
function save()
{
/* Return selected ppd path, if none is selected then false */
function save()
{
return($this->pathToModified.$this->selectedPPD['link']);
}
return($this->pathToModified.$this->selectedPPD['link']);
}
+
/* Get Information for a single PPD entry
* This will be shown on top of template
*/
/* Get Information for a single PPD entry
* This will be shown on top of template
*/
return($str) ;
}
return($str) ;
}
+
/* Display all options from the selected ppd file */
function generateProperties()
{
/* Display all options from the selected ppd file */
function generateProperties()
{
/* 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;
/* Prepare data */
$values = array();
$name = $settings['_name'];
/* Skip all entries beginning with _ */
if($attr[0] == "_") continue;
/* Prepare data */
$values = array();
$name = $settings['_name'];
- $default = $settings['_default'];
+ if (!isset($settings['_default'])){
+ $default = "";
+ } else {
+ $default = $settings['_default'];
+ }
$type = $settings['_type'];
/* Add name to table */
$type = $settings['_type'];
/* Add name to table */
}
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(){ return(plugin::check()); }
+ 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:
?>