From b0410faf8739998a7c99d0e26a8252d34b703f0c Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 26 Oct 2007 06:13:45 +0000 Subject: [PATCH] Ported changes from yesterday. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7668 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_hostActionQueue.inc | 14 +++++++------- include/functions.inc | 4 ++++ .../addons/gotomasses/class_divListMasses.inc | 2 -- plugins/admin/ogroups/tabs_ogroups.inc | 2 ++ .../admin/systems/class_componentGeneric.inc | 5 +++++ plugins/admin/systems/class_phoneGeneric.inc | 5 +++++ plugins/admin/systems/class_printGeneric.inc | 19 +++++++++++++------ .../admin/systems/class_printerPPDDialog.inc | 2 +- plugins/admin/systems/class_servGeneric.inc | 5 +++++ .../admin/systems/class_terminalGeneric.inc | 5 +++++ .../systems/class_workstationGeneric.inc | 5 +++++ .../systems/class_workstationStartup.inc | 2 +- 12 files changed, 53 insertions(+), 17 deletions(-) diff --git a/include/class_hostActionQueue.inc b/include/class_hostActionQueue.inc index 59ca97dde..c32be66ae 100644 --- a/include/class_hostActionQueue.inc +++ b/include/class_hostActionQueue.inc @@ -110,20 +110,20 @@ class hostActionQueue { continue; } - $entry_id = $task_id= 0; + $entry_id = $task_id= ""; /* Comment must be set correctly */ if(empty($comment)){ $desc = ""; }else{ - $task_id =preg_replace("/^.*taskid:([0-9]*).*$/","\\1",$comment); - $entry_id=preg_replace("/^.*entryid:([0-9]*).*$/","\\1",$comment); + $task_id =preg_replace("/^.*taskid:([0-9a-z]*).*$/i","\\1",$comment); + $entry_id=preg_replace("/^.*entryid:([0-9a-z]*).*$/i","\\1",$comment); $desc =preg_replace("/^.*desc:(.*)$/","\\1",$comment); } - if($task_id == 0 || empty($task_id)){ + if($task_id == "" || empty($task_id)){ $task_id = $this->get_new_id(); } - if($entry_id == 0 || empty($entry_id)){ + if($entry_id == "" || empty($entry_id)){ $entry_id = $this->get_new_id(); } @@ -254,9 +254,9 @@ class hostActionQueue { return(TRUE); } - private function _add_entry($entry,$task_id = 0) + private function _add_entry($entry,$task_id = "") { - if($task_id == 0 || empty($task_id)){ + if($task_id == "" || empty($task_id)){ $task_id = $this->get_new_id(); } $entry['TASK_ID'] = $task_id; diff --git a/include/functions.inc b/include/functions.inc index 423fb28e3..adf7cf60a 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -905,6 +905,10 @@ function is_phone_nr($nr) return preg_match ("/^[\/0-9 ()+*-]+$/", $nr); } +function is_dns_name($str) +{ + return(preg_match("/^[a-z0-9\.\-]*$/i",$str)); +} function is_url($url) { diff --git a/plugins/addons/gotomasses/class_divListMasses.inc b/plugins/addons/gotomasses/class_divListMasses.inc index 9a17bffdc..f32f76b51 100644 --- a/plugins/addons/gotomasses/class_divListMasses.inc +++ b/plugins/addons/gotomasses/class_divListMasses.inc @@ -113,8 +113,6 @@ class divListMasses extends MultiSelectWindow continue; } - - /* Handle coloring */ $color=""; if($this->parent->sort_by == "TaskID"){ diff --git a/plugins/admin/ogroups/tabs_ogroups.inc b/plugins/admin/ogroups/tabs_ogroups.inc index b87ff78f6..d820aa5b8 100644 --- a/plugins/admin/ogroups/tabs_ogroups.inc +++ b/plugins/admin/ogroups/tabs_ogroups.inc @@ -101,11 +101,13 @@ class ogrouptabs extends tabs $this->by_object['workservice']= new workservice($this->config, $this->dn); $this->by_object['workservice']->inheritTimeServer = false; $this->by_object['workservice']->parent= &$this; + $this->by_object['workservice']->acl = "#all#"; } if((preg_match("/S/",$objects) || preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){ $this->by_name['workstartup']= _("Startup"); $this->by_object['workstartup']= new workstartup($this->config, $this->dn); $this->by_object['workstartup']->parent= &$this; + $this->by_object['workstartup']->acl = "#all#"; $this->by_name['faiSummary']= _("Summary"); $this->by_object['faiSummary']= new faiSummaryTab($this->config, $this->dn); $this->by_object['faiSummary']->parent= &$this; diff --git a/plugins/admin/systems/class_componentGeneric.inc b/plugins/admin/systems/class_componentGeneric.inc index 3bd61a220..4306494b3 100644 --- a/plugins/admin/systems/class_componentGeneric.inc +++ b/plugins/admin/systems/class_componentGeneric.inc @@ -186,6 +186,11 @@ class componentGeneric extends plugin $message[]= _("The required field 'Component name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + /* To check for valid ip*/ if($this->netConfigDNS->ipHostNumber == ""){ $message[]= _("The required field IP address is empty."); diff --git a/plugins/admin/systems/class_phoneGeneric.inc b/plugins/admin/systems/class_phoneGeneric.inc index a505fa931..021990c8a 100644 --- a/plugins/admin/systems/class_phoneGeneric.inc +++ b/plugins/admin/systems/class_phoneGeneric.inc @@ -334,6 +334,11 @@ class phoneGeneric extends plugin } } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + if ($this->cn == ""){ $message[]= _("The required field 'Phone name' is not set."); } diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index 55407a07e..ec922b9fe 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -666,8 +666,13 @@ class printgeneric extends plugin $dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base; /* must: cn */ - if(preg_match("/printer/i",$this->BelongsTo) && (empty($this->cn))){ - $message[]= "The required field 'Printer name' is not set."; + if(($this->BelongsTo == "Printer") && (empty($this->cn))){ + $message[]= _("The required field 'Printer name' is not set."); + } + + /* must: cn */ + if(($this->BelongsTo == "Printer") && !is_dns_name($this->cn)){ + $message[]= _("Invalid character in printer name."); } /* must: labeledURI */ @@ -731,10 +736,12 @@ class printgeneric extends plugin $this->PPDdialogToSave->save_ppd(); } if($this->orig_dn != $this->dn){ - $this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); - $this->PPDdialogToSave->cn = $this->cn; - $this->PPDdialogToSave->generateProperties(); - $this->PPDdialogToSave->update_ppd_url(); + if(!empty($this->gotoPrinterPPD)) { + $this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); + $this->PPDdialogToSave->cn = $this->cn; + $this->PPDdialogToSave->generateProperties(); + $this->PPDdialogToSave->update_ppd_url(); + } } /* Remove previously selected ppd file.*/ diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc index 1863d8deb..a867c7075 100644 --- a/plugins/admin/systems/class_printerPPDDialog.inc +++ b/plugins/admin/systems/class_printerPPDDialog.inc @@ -339,7 +339,7 @@ class printerPPDDialog extends plugin function getPrinterReload() { if(is_readable($this->pathToPPD)){ - $tmp = $this->ppdManager->getPrinterList(true); + $tmp = @$this->ppdManager->getPrinterList(true); $this->ppdListHeader = $this->ppdList = array(); diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index de16b1d52..cf0eeffd9 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -296,6 +296,11 @@ class servgeneric extends plugin $message[]= _("The required field 'Server name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + if ($this->orig_dn != $this->dn){ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->base); diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index b0c2e4c67..f10770f3e 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -454,6 +454,11 @@ class termgeneric extends plugin $message[]= _("The required field 'Terminal name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + if ($this->orig_dn == 'new'){ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->base); diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 5b5a58a6c..a19cd8617 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -435,6 +435,11 @@ class workgeneric extends plugin $message[]= _("The required field 'Workstation name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + if ($this->orig_dn != $this->dn){ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->base); diff --git a/plugins/admin/systems/class_workstationStartup.inc b/plugins/admin/systems/class_workstationStartup.inc index 6e72439f9..4105b26bc 100644 --- a/plugins/admin/systems/class_workstationStartup.inc +++ b/plugins/admin/systems/class_workstationStartup.inc @@ -949,7 +949,7 @@ class workstartup extends plugin }else{ $tmp = $this->getFAIreleases(); foreach($tmp as $release => $data){ - if(isset($rest['RELEASE'][$release])){ + if(isset($rest['RELEASE'][$release]) && $release == $this->FAIrelease){ $use = $data['USE']; } } -- 2.30.2