From 49600d14232583a7bacce3cc6f7caf4e807587e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Mar 2010 13:06:29 +0000 Subject: [PATCH] Fix: Postgres compatibility --- htdocs/admin/external_rss.php | 2 +- htdocs/admin/ftpclient.php | 10 +++++----- htdocs/includes/modules/modSociete.class.php | 12 +++++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 0f390977209..3030dc6fcb9 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -40,7 +40,7 @@ $def = array(); $lastexternalrss=0; // positionne la variable pour le nombre de rss externes -$sql ="select MAX(name) name from ".MAIN_DB_PREFIX."const"; +$sql ="select MAX(name) as name from ".MAIN_DB_PREFIX."const"; $sql.=" WHERE name like 'EXTERNAL_RSS_URLRSS_%'"; $result=$db->query($sql); if ($result) diff --git a/htdocs/admin/ftpclient.php b/htdocs/admin/ftpclient.php index 94bcb8eb544..4251f647e25 100644 --- a/htdocs/admin/ftpclient.php +++ b/htdocs/admin/ftpclient.php @@ -35,7 +35,7 @@ $def = array(); $lastftpentry=0; // Positionne la variable pour le nombre de rss externes -$sql ="select MAX(name) name from ".MAIN_DB_PREFIX."const"; +$sql ="select MAX(name) as name from ".MAIN_DB_PREFIX."const"; $sql.=" WHERE name like 'FTP_SERVER_%'"; $result=$db->query($sql); if ($result) @@ -56,19 +56,19 @@ if ($_POST["action"] == 'add' || $_POST["modify"]) $error=0; $mesg=''; - + if (empty($_POST[$ftp_name])) { $error=1; $mesg.='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Label")).'
'; } - + if (empty($_POST[$ftp_server])) { $error=1; $mesg.='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Server")).'
'; } - + if (! $error) { $ftp_port = "FTP_PORT_" . $_POST["numero_entry"]; @@ -143,7 +143,7 @@ if (! function_exists('ftp_connect')) else { if ($mesg) print $mesg; - + // Formulaire ajout print '
'; print ''; diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index af43154a4d9..a599a8a2a68 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -264,6 +264,8 @@ class modSociete extends DolibarrModules */ function init($options='') { + global $conf; + require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); // Prevent pb of modules not correctly disabled @@ -273,9 +275,13 @@ class modSociete extends DolibarrModules create_exdir($dirodt); dol_copy(DOL_DOCUMENT_ROOT.'/install/odttemplates/thirdparties/template_thirdparty.odt',$dirodt,0,0); - $sql = array( - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."const set name='COMPANY_ADDON_PDF_ODT_PATH', value='DOL_DATA_ROOT/odttemplates/thirdparties'",'ignoreerror'=>1) - ); + $sql = array(); + if ($this->db->type != 'pgsql') // TODO For the moment, we can't execute SQL that may fail with Postgres + { + $sql=array( + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible,entity) VALUES ('COMPANY_ADDON_PDF_ODT_PATH', 'DOL_DATA_ROOT/odttemplates/thirdparties', 0, '".$conf->entity."')",'ignoreerror'=>1) + ); + } return $this->_init($sql,$options); }