diff --git a/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc b/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc
index 377f6c4b1c5029e83c90211e85d3f3ceac232bd4..97820940f162e7759ac82e3bb59e10c580fea1d2 100644 (file)
var $cn = "";
var $l = "";
var $description = "";
+ var $printer_description = "";
var $labeledURI = "";
var $gotoPrinterPPD = "";
var $initial_PPD = "";
+ var $initial_PPD_URL = "";
var $orig_dn = "";
var $orig_cn = "";
var $orig_base = "";
}
}
+ $this->initial_PPD_URL = $this->gotoPrinterPPD;
/* Extract selected ppd */
if(isset($this->gotoPrinterPPD)){
$this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
}
$this->orig_cn = $this->cn;
$this->orig_base = $this->base;
+
+ if (!preg_match('/Printer/i', $this->BelongsTo)) {
+ $this->printer_description = $this->description;
+ }
}
function set_acl_base($base)
/* Assign attributes */
foreach ($this->attributes as $attr){
- $smarty->assign("$attr", $this->$attr);
+ $smarty->assign("$attr", $this->$attr);
+ }
+
+ if (!preg_match("/Printer/", $this->BelongsTo)) {
+ $smarty->assign("printer_description", $this->printer_description);
}
if(isset($_POST['AddUser'])){
if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){
$this->dialog = $this->PPDdialogToSave;
}else{
+ $this->initial_PPD_URL = "";
$this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
$this->dialog->cn= $this->cn;
}
return $display;
}
+ /* Get servername */
+ $server = $_SERVER['SERVER_NAME'];
+ if(tests::is_ip($server)){
+ $server_name = gethostbyaddr($server);
+ }else{
+ $server_name = gethostbyaddr(gethostbyname($server));
+ }
+ $orig_server_name = "";
+ if ($this->initial_PPD_URL != "") {
+ $ppd_server = preg_replace("/^http.*:../i","",$this->initial_PPD_URL);
+ $ppd_server = preg_replace("/\/.*/i","",$ppd_server);
+ if(tests::is_ip($ppd_server)){
+ $orig_server_name = gethostbyaddr($ppd_server);
+ }else{
+ $orig_server_name = $ppd_server;
+ }
+ }
+
/* Parse selected ppd file */
$config = session::get('config');
if ($config->get_cfg_value("ppdPath") != ""){
$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."),$path.$this->gotoPrinterPPD)."</b>");
+ if($orig_server_name != "" && $server_name != $orig_server_name) {
+ $smarty->assign("driverInfo", "<b>".sprintf(_("Printer got configured on remote server '%s', Editing Driver will overwrite settings."),$orig_server_name)."</b>");
}else{
- $ppdDesc = $ppdManager->loadDescription($path.$this->gotoPrinterPPD);
- $smarty->assign("driverInfo", $ppdDesc['name']);
+ if((!file_exists($path.$this->gotoPrinterPPD))){
+ $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD)."</b>");
+ }else{
+ $ppdDesc = $ppdManager->loadDescription($path.$this->gotoPrinterPPD);
+ $smarty->assign("driverInfo", $ppdDesc['name']);
+ }
}
}else{
$smarty->assign("driverInfo", _("Not defined"));
if(is_object($this->netConfigDNS)){
$this->netConfigDNS->save_object();
}
+
+ if (!isset($_POST['edit_cancel']) && isset($_POST['printer_description'])) {
+ $this->printer_description = get_post('printer_description');
+ }
/* Set new base if allowed */
$tmp = $this->get_allowed_bases();
if(preg_match("/workstation/i",$this->BelongsTo)){
$this->dn= preg_replace("/".preg_quote(get_ou('workstationRDN'), '/')."/",get_ou('printerRDN'),$this->dn);
}
-
+
if(!$this->is_account) return;
if(isset($this->parent->by_object['workgeneric'])){
if($this->parent->by_object['workgeneric']->cn == "wdefault"){
if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){
$this->PPDdialogToSave->save_ppd();
}
- if($this->orig_dn != $this->dn){
+ if($this->orig_dn != "new" && $this->orig_cn != $this->cn){
if(!empty($this->gotoPrinterPPD)) {
$this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
$this->PPDdialogToSave->cn = $this->cn;
}
/* If no ppd is selected, remove this attribute */
- if(!empty($this->gotoPrinterPPD) && $this->initially_was_account) {
- $this->gotoPrinterPPD = $method.str_replace("//","/",$server_name."/ppd/".$this->gotoPrinterPPD);
+ if(!empty($this->gotoPrinterPPD)) {
+ if (($this->gotoPrinterPPD != $this->initial_PPD) || ($this->initial_PPD_URL == "")) {
+ /* PPD has changed, update it */
+ if (!preg_match('/^http[s]+:\/\/.*/', $this->gotoPrinterPPD)) {
+ /* ppd is not an url */
+ $this->gotoPrinterPPD = $method.str_replace("//","/",$server_name."/ppd/".$this->gotoPrinterPPD);
+ }
+ } else {
+ /* Restore original PPD URL */
+ $this->gotoPrinterPPD = $this->initial_PPD_URL;
+ }
}else{
$this->gotoPrinterPPD = array();
}
$this->attrs= $attrs;
}
+ if (!empty($this->printer_description)) {
+ $this->attrs['description'] = $this->printer_description;
+ }
+
/* Append printer user
*/
$this->attrs['gotoUserPrinter']=array();