/* * This file is part of PhpCompta. * * PhpCompta is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * PhpCompta is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr /* $Revision$ */ include_once("postgres.php"); /* function CheckJrn * Purpose : * Vérifie les acces d'un utilisateur * sur un journal * * parm : * - $p_dossier le dossier * - $p_user le login user * - $p_jrn le journal * gen : * - rien * return: * - 0 pas d'acces * - 1 Lecture * - 2 écriture * */ function CheckJrn($p_dossier,$p_user,$p_jrn) { if ( CheckIsAdmin( $p_user) == 1 ) return 2; $l_Db=sprintf("dossier%d",$p_dossier); $cn=DbConnect($l_Db); // droit spécifique $Res2=ExecSql($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 jrn_def_id=$p_jrn"); $PrivJrn=pg_NumRows($Res2); $cn=DbConnect(); // droit par défaut $Res=ExecSql($cn," select * from ac_users left join jnt_use_dos using (use_id) left join priv_user on (priv_jnt=jnt_id) where use_login='$p_user' and dos_id=$p_dossier"); $DefRight=pg_NumRows($Res); echo_debug ("PrivJrn = $PrivJrn DefRight $DefRight"); // Si les droits par défaut == 0, alors user n'a pas accès au dossier if ( $DefRight == 0 ) return 0; $Def=pg_fetch_array($Res,0); // Si les droits par défaut == NO, alors user n'a pas accès au dossier if ( $Def['priv_priv'] == "NO" ) return 0; if ( $Def['priv_priv'] == "W") { // Si droit pas défaut == écriture if ( $PrivJrn == 0 ) { // Pas de droit spécifique sur jrn => droit par défaut = W return 2; } $Priv=pg_fetch_array($Res2,0); if ( $Priv['uj_priv'] == "X" ) return 0; if ( $Priv['uj_priv'] == "R" ) return 1; if ( $Priv['uj_priv'] == "W" ) return 2; echo '