diff --git a/html/admin/setup.php b/html/admin/setup.php index ecddff003..374919609 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -412,7 +412,7 @@ echo '
'; echo "

Mise à jour Repository

"; $cn=new Database(); if ( DEBUG == 'false') ob_start(); - $MaxVersion=10; + $MaxVersion=DBVERSIONREPO-1; for ($i=4;$i<= $MaxVersion;$i++) { if ( $cn->get_version() <= $i ) { diff --git a/html/admin/sql/patch/ac-upgrade11.sql b/html/admin/sql/patch/ac-upgrade11.sql new file mode 100644 index 000000000..513ef2228 --- /dev/null +++ b/html/admin/sql/patch/ac-upgrade11.sql @@ -0,0 +1,25 @@ +begin; +delete from jnt_use_dos where use_id not in (select use_id from ac_users); + +delete from jnt_use_dos where dos_id not in (select dos_id from ac_dossier); + +alter table jnt_use_dos add CONSTRAINT jnt_use_dos_dos_id_fkey FOREIGN KEY (dos_id) + REFERENCES ac_dossier (dos_id) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE CASCADE; +alter table jnt_use_dos add CONSTRAINT jnt_use_dos_use_id_fkey FOREIGN KEY (use_id) + REFERENCES ac_users (use_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION; + + +delete from priv_user where priv_jnt not in (select jnt_id from jnt_use_dos); + +alter table jnt_use_dos drop constraint jnt_use_dos_pkey; + +alter table jnt_use_dos add constraint jnt_use_dos_pkey PRIMARY KEY (jnt_id); + +alter table priv_user add CONSTRAINT priv_user_priv_jnt_fkey FOREIGN KEY (priv_jnt) + REFERENCES jnt_use_dos (jnt_id) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE cascade; +alter table version add primary key (val); +update version set val=12; +commit; diff --git a/html/user_login.php b/html/user_login.php index 49508d210..201a4b1eb 100644 --- a/html/user_login.php +++ b/html/user_login.php @@ -55,7 +55,24 @@ echo <<exist_table('version') == false) { + echo '

'._("Base de donnée invalide").'

'; + $base=dirname($_SERVER['REQUEST_URI']); + exit(); +} + +/* check repo version */ +$version = $ac->get_value('select val from version'); +if ( $version < DBVERSIONREPO ) { + echo '

'._("Votre base de données n'est pas à jour").' '; + $a=_("cliquez ici pour appliquer le patch"); + $base=dirname($_SERVER['REQUEST_URI']).'/admin/setup.php'; + echo ''.$a.'

'; + +} html_page_start($_SESSION['g_theme']); include_once("user_menu.php"); diff --git a/include/constant.php b/include/constant.php index 3e96cb3d2..c63ed67cf 100644 --- a/include/constant.php +++ b/include/constant.php @@ -27,6 +27,7 @@ require_once ('config.inc.php'); require_once('constant.security.php'); define ("DBVERSION",83); +define ("DBVERSIONREPO",12); define ("MAX_COMPTE",4); define ('MAX_ARTICLE',9);