From 4253bedcf559dfb61d569ba964b6679f9df2b313 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 5 Jul 2010 18:05:41 +0000 Subject: [PATCH] Merged revisions 3431-3432 via svnmerge from svn+ssh://danydb@svn/svn/phpcompta/branches/rel510 ........ r3431 | danydb | 2010-07-05 19:56:48 +0200 (Mon, 05 Jul 2010) | 2 lines the plugin can check the version of phpcompta ........ r3432 | danydb | 2010-07-05 19:57:34 +0200 (Mon, 05 Jul 2010) | 2 lines Update : check the version for plugin , new global variable $version_phpcompta ........ --- include/class_database.php | 19 +++++++++++++++++-- include/class_extension.php | 8 ++++++++ include/constant.php | 3 +++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/class_database.php b/include/class_database.php index 5d7f8cc20..457f3c5fc 100644 --- a/include/class_database.php +++ b/include/class_database.php @@ -423,14 +423,29 @@ de données"); return true; } /*!\brief test if a table exist + *\param $p_name table name + *\param $schema name of the schema default public * \return true if a table exist otherwise false */ - function exist_table($p_name) { - $r=$this->count_sql("select tablename from pg_tables where tablename=lower($1)", array($p_name)); + function exist_table($p_name,$p_schema='public') { + $r=$this->count_sql("select table_name from information_schema.tables where table_schema=$1 and table_name=lower($2)", array($p_schema,$p_name)); if ( $r==0) return false; return true; } + /** + * Check if a column exists in a table + * @param $col : column name + * @param $table :table name + * @param $schema :schema name, default public + *@return true or false + */ + function exist_column($col,$table,$schema) { + $r=$this->get_value('select count(*) from information_schema.columns where table_name=lower($1) and column_name=lower($2) and table_schema=lower($3)', + array($col,$table,$schema)); + if ( $r > 0 ) return true; + return false; + } /** *@brief check if the large object exists *@param $p_oid of the large object diff --git a/include/class_extension.php b/include/class_extension.php index 6c752a2b0..6ccf95554 100644 --- a/include/class_extension.php +++ b/include/class_extension.php @@ -246,6 +246,14 @@ ex_id=>'' $a=$cn->get_array($sql,array($_SESSION['g_user'])); return $a; } + static function check_version($i) { + global $version_phpcompta; + if ( ! isset ($version_phpcompta) || $version_phpcompta < $i ) { + alert('Cette extension ne fonctionne pas sur cett version de PhpCompta'. + ' Veuillez mettre votre programme a jour'); + exit(); + } + } /*!\brief test this class */ static function test_me() { diff --git a/include/constant.php b/include/constant.php index 098137fea..d46a29280 100644 --- a/include/constant.php +++ b/include/constant.php @@ -25,6 +25,9 @@ */ require_once ('config.inc.php'); require_once('constant.security.php'); +// SVNVERSION +global $version_phpcompta; +$version_phpcompta=3428; define ("DBVERSION",85); define ("DBVERSIONREPO",12);