Code

Added RDN support for users
[gosa.git] / plugins / admin / systems / class_printerPPDDialog.inc
index c63a68a1d6b8af77398954e14feb1a6df1d70c6f..103825ac47b7c51aec9fbc4be19339de542ffe6b 100644 (file)
@@ -2,11 +2,6 @@
 
 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");
@@ -95,9 +90,8 @@ class printerPPDDialog extends plugin
     
       /* 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);
@@ -313,24 +307,26 @@ class printerPPDDialog extends plugin
    */
   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;
     }
   }
 
@@ -476,8 +472,32 @@ class printerPPDDialog extends plugin
     }
     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:
 ?>