From b27df594fd0241994ba08edce1d11cd66ad9fd02 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 10 Oct 2005 09:13:19 +0000 Subject: [PATCH] Fix : permit to see the detail of an operation if the user has access to at least one legder --- html/modify_op.php | 4 ++-- include/check_priv.php | 28 ++++++++++++++++++++-------- include/jrn.php | 1 + 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/html/modify_op.php b/html/modify_op.php index fb7a21dd7..78d957cd9 100644 --- a/html/modify_op.php +++ b/html/modify_op.php @@ -68,7 +68,7 @@ if ( ! isset ( $action )) { echo JS_VIEW_JRN_MODIFY; ////////////////////////////////////////////////////////////////////// if ( $action == 'update' ) { - if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn'])) < 1 ) { + if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn'],true)) < 1 ) { NoAccess(); exit -1; @@ -95,7 +95,7 @@ if ( $action == 'update' ) { // echo ''; } if ( isset($_POST['update_record']) ) { - if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$p_jrn)) !=2 ) { + if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$p_jrn,true)) !=2 ) { NoAccess(); exit -1; diff --git a/include/check_priv.php b/include/check_priv.php index 9725715da..de0b08379 100644 --- a/include/check_priv.php +++ b/include/check_priv.php @@ -40,23 +40,35 @@ include_once("postgres.php"); * */ -function CheckJrn($p_dossier,$p_user,$p_jrn) +function CheckJrn($p_dossier,$p_user,$p_jrn,$p_detail=False) { if ( CheckIsAdmin( $p_user) == 1 ) return 2; $cn=DbConnect($p_dossier); // Special // p_jrn = 0 ==> grand livre access if there is no uj_prix=X + // or detail if ( $p_jrn == 0 ) { - // $n_jrn=CountSql($cn,"select jrn_def_id from jrn_def"); - $n_for=CountSql($cn,"select jrn_def_id,uj_priv + if ( $p_detail == false) { + // $n_jrn=CountSql($cn,"select jrn_def_id from jrn_def"); + $n_for=CountSql($cn,"select jrn_def_id,uj_priv from jrn_def left join user_sec_jrn on uj_jrn_id=jrn_def_id where uj_login='$p_user' and uj_priv='X'"); - if ( $n_for == 0 ) - return 2; - else - return 0; + if ( $n_for == 0 ) + return 2; + else + return 0; + } else { + // For a detail, at least one jrn must be accessible + $n_for=CountSql($cn, " select jrn_def_id,uj_priv + from jrn_def left join user_sec_jrn on uj_jrn_id=jrn_def_id + where uj_login='$p_user' and uj_priv !='X'"); + if ( $n_for == 0 ) + return 0; + else + return 2; + } - + } // droit spécifique diff --git a/include/jrn.php b/include/jrn.php index 7696b30eb..d4304dca2 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -992,6 +992,7 @@ function GetDataJrnJrId ($p_cn,$p_jr_id) { jr_id=$p_jr_id order by j_debit desc"); $MaxLine=pg_NumRows($Res); + echo_debug(__FILE__,__LINE__,"Found $MaxLine lines"); if ( $MaxLine == 0 ) return null; for ( $i=0; $i < $MaxLine; $i++) {