Code

Added some comments
[gosa.git] / plugins / admin / systems / class_printGeneric.inc
index 2ed5f19c9e1fb505637876dab96dd84c876a654a..fc743ce969414ae6b89fe9511a60c69e73967518 100644 (file)
@@ -59,6 +59,9 @@ class printgeneric extends plugin
       $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
     }
 
+    if(isset($this->gotoPrinterPPD)){
+      $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
+    }
 
     /* In case of gotoWorkstation this tab is calles from workstation plugin
      * in case of gotoTerminal it is called from a terminal tab
@@ -117,7 +120,9 @@ class printgeneric extends plugin
       /* $this->members contains all members */
       $this->member[$type]=array();
 
-      unset($this->attrs[$attr]['count']);
+      if (isset($this->attrs[$attr]['count'])) {
+        unset($this->attrs[$attr]['count']);
+      }
 
       if(isset($this->attrs[$attr])){
         foreach($this->attrs[$attr] as $mem){
@@ -289,6 +294,8 @@ class printgeneric extends plugin
       $this->dialog=NULL;
     }
 
+  
+
     if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
       if(isset($this->member['AddUser'][$_POST['UserMember']])){
         unset($this->member['AddUser'][$_POST['UserMember']]);
@@ -308,7 +315,7 @@ class printgeneric extends plugin
     }
 
     if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
-      if(isset($this->member['AddAdmingroup'][$_POST['AdminMember']])){
+      if(isset($this->member['AddAdminGroup'][$_POST['AdminMember']])){
         unset($this->member['AddAdminGroup'][$_POST['AdminMember']]);
       }
     }
@@ -349,17 +356,29 @@ class printgeneric extends plugin
 
 
     require_once ("class_ppdManager.inc");
-    $ppdManager= new ppdManager('/var/spool/ppd/');
-    if(!empty($this->gotoPrinterPPD)){
-      if((!file_exists($this->gotoPrinterPPD))){
-        $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exists."),$this->gotoPrinterPPD))."</b>";
+
+    if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){
+
+      $path = $_SESSION['config']->data['MAIN']['PPD_PATH'];
+      if(!preg_match("/\/$/",$path)){
+        $path = $path."/";
+      }
+
+      $ppdManager= new ppdManager($path);
+      if(!empty($this->gotoPrinterPPD)){
+        if((!file_exists($path.$this->gotoPrinterPPD))){
+          $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$this->gotoPrinterPPD))."</b>";
+        }else{
+          $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
+        }
       }else{
-        $smarty->assign("driverInfo", $ppdManager->loadDescription($this->gotoPrinterPPD));
+        $smarty->assign("driverInfo", _("not defined"));
       }
     }else{
-      $smarty->assign("driverInfo", _("not defined"));
+      $smarty->assign("driverInfo",_("can't get ppd informations."));
     }
 
+
     $list=$this->generateList();
     $userlist   = array_merge($list['AddUser'],$list['AddGroup']);
     $adminlist  = array_merge($list['AddAdminUser'],$list['AddAdminGroup']);
@@ -463,7 +482,6 @@ class printgeneric extends plugin
     if($this->PPDdialogToSave){
       $this->PPDdialogToSave->save_ppd();
     }
-  
     $dn= $this->dn;
     plugin::save();
     $ldap= $this->config->get_ldap_link();
@@ -504,6 +522,16 @@ class printgeneric extends plugin
       $this->attrs= $attrs;
     }
 
+    if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
+      $method="https://";
+    }else{
+      $method="http://";
+    }
+  
+    if(!is_array($this->attrs['gotoPrinterPPD'])) {
+      $this->attrs['gotoPrinterPPD'] = $this->attrs['gotoPrinterPPD'];
+      $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->attrs['gotoPrinterPPD']);
+    }
 
     /* Append printer user 
      */