diff --git a/doc/makedoc b/doc/makedoc
new file mode 100755
index 000000000..d23ee7480
--- /dev/null
+++ b/doc/makedoc
@@ -0,0 +1,21 @@
+BASE_DIR=`pwd`
+
+ext_dir ()
+{
+ for i in *.php; do
+ ( echo $i
+ awk '/\/\* function/,/\*\// {print $0;}' $i
+ ) >> $BASE_DIR/function.txt
+ done
+}
+
+cd ../html
+
+ext_dir
+cd $BASE_DIR
+
+cd ../include
+
+ext_dir
+
+
diff --git a/html/admin_repo.php b/html/admin_repo.php
index b610b5933..5bc6d68f2 100644
--- a/html/admin_repo.php
+++ b/html/admin_repo.php
@@ -24,15 +24,15 @@ include_once("postgres.php");
include_once("debug.php");
html_page_start();
echo_debug("entering admin_repo");
-echo_debug("user $user");
+//echo_debug("user $g_user");
CheckUser();
-if (CheckAdmin() != 1) {
+if ($g_UserProperty['use_admin'] != 1) {
html_page_stop();
return;
}
include ("top_menu_compta.php");
-//ShowMenu(0," Dossier ");
+
echo '
Administration Globale
';
if ( ! isset ($g_dossier) ) $g_dossier=0;
ShowMenuAdminGlobalRight($g_dossier);
diff --git a/html/central.php b/html/central.php
index ca21add1e..49898b365 100644
--- a/html/central.php
+++ b/html/central.php
@@ -35,8 +35,9 @@ include_once("preference.php");
include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,CENTRALIZE);
+
+if ( $g_UserProperty['use_admin']==0 ) {
+ $r=CheckAction($g_dossier,$g_user,CENTRALIZE);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/compta.php b/html/compta.php
index 46eecd1f3..b6a495f47 100644
--- a/html/compta.php
+++ b/html/compta.php
@@ -19,6 +19,7 @@
// Auteur Dany De Bontridder ddebontridder@yahoo.fr
include ("ac_common.php");
/* $Revision$ */
+session_start();
html_page_start();
if ( isset ( $dos ) ) {
$g_dossier=$dos;
@@ -26,24 +27,28 @@ if ( isset ( $dos ) ) {
echo_debug("admin_dossier = $g_dossier ");
} else {
echo "You must choose a Dossier ";
- phpinfo();
+ // phpinfo();
exit -2;
}
include ("postgres.php");
+echo_debug ("user is $g_user");
/* CheckUser */
CheckUser();
-if ( CheckAdmin() == 0 ) {
+
+echo_debug("theme ".$g_UserProperty['use_theme']);
+
+if ( $g_UserProperty['use_admin'] == 0 ) {
- $r=GetPriv($g_dossier,$user);
+ $r=GetPriv($g_dossier,$g_user);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
}
}
-SyncRight($g_dossier,$user);
+SyncRight($g_dossier,$g_user);
-$g_UserType=GetUserType($user);
+$g_UserType=GetUserType($g_user);
session_register($g_UserType);
switch ($g_UserType) {
diff --git a/html/dossier_prefs.php b/html/dossier_prefs.php
index d130019f8..09dff1dfe 100644
--- a/html/dossier_prefs.php
+++ b/html/dossier_prefs.php
@@ -37,8 +37,8 @@ ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
include_once ("check_priv.php");
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,PARM);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,PARM);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/enc_jrn.php b/html/enc_jrn.php
index 7fad83089..fa675f820 100644
--- a/html/enc_jrn.php
+++ b/html/enc_jrn.php
@@ -16,6 +16,7 @@
* along with WCOMPTA; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/* $Revision$ */
// Auteur Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
include_once ("ac_common.php");
@@ -46,33 +47,35 @@ include_once("poste.php");
include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,ENCJRN);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,ENCJRN);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
}
- $right=CheckJrn($g_dossier,$user,$g_jrn);
- if ($right == 0 ){
- /* Cannot Access */
- NoAccess();
- exit -1;
- }
+ if ( isset ($g_jrn)) {
+ $right=CheckJrn($g_dossier,$g_user,$g_jrn);
+ if ($right == 0 ){
+ /* Cannot Access */
+ NoAccess();
+ exit -1;
+ }
+ } // if isset g_jrn
}
-ShowMenuJrnUser($g_dossier,$user);
+ShowMenuJrnUser($g_dossier,$g_user);
if ( isset ( $_GET["action"] )) {
if ( $_GET["action"] == "view" ) {
ShowMenuRecherche($g_dossier,$g_jrn);
echo '';
- ViewJrn($g_dossier,$user,$g_jrn);
+ ViewJrn($g_dossier,$g_user,$g_jrn);
echo '
';
}
if ( $_GET["action"] == "record" ) {
- if ( CheckJrn($g_dossier,$user,$g_jrn) < 2 ) {
+ if ( CheckJrn($g_dossier,$g_user,$g_jrn) < 2 ) {
NoAccess();
exit -1;
@@ -80,10 +83,10 @@ if ( isset ( $_GET["action"] )) {
echo_debug("record");
$max_deb=$_GET["max_deb"];
$max_cred=$_GET["max_cred"];
- RecordJrn($g_dossier,$user,$g_jrn,$max_deb,$max_cred);
+ RecordJrn($g_dossier,$g_user,$g_jrn,$max_deb,$max_cred);
}
if ($_GET["action"]=="update" ) {
- if ( CheckJrn($g_dossier,$user,$g_jrn) < 2 ) {
+ if ( CheckJrn($g_dossier,$g_user,$g_jrn) < 2 ) {
NoAccess();
exit -1;
@@ -109,8 +112,8 @@ if ( isset ( $_GET["action"] )) {
}
$p_MaxDeb+=2;
echo "";
- CorrectRecord($g_dossier,$user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);
- echo_debug("CorrectRecord($g_dossier,$user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);");
+ CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);
+ echo_debug("CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);");
}
if ( isset ($_POST['add_line_cred']) ) {
@@ -120,15 +123,15 @@ if ( isset ( $_GET["action"] )) {
}
$p_MaxCred+=2;
echo "";
- CorrectRecord($g_dossier,$user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);
- echo_debug("CorrectRecord($g_dossier,$user,$g_jrn,$p_MaxDeb,$p_MaxCred+10,$HTTP_POST_VARS);");
+ CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);
+ echo_debug("CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred+10,$HTTP_POST_VARS);");
}
if ( isset ($_POST['viewsearch']) ) {
reset($HTTP_POST_VARS);
ShowMenuRecherche($g_dossier,$g_jrn,$HTTP_POST_VARS);
echo '';
- ViewJrn($g_dossier,$user,$g_jrn,$HTTP_POST_VARS);
+ ViewJrn($g_dossier,$g_user,$g_jrn,$HTTP_POST_VARS);
echo '
';
}
@@ -142,7 +145,7 @@ if ( isset($_POST['add_record']) ) {
}
- $result=VerifData($cn,$HTTP_POST_VARS,$user);
+ $result=VerifData($cn,$HTTP_POST_VARS,$g_user);
switch( $result) {
case NOERROR:
@@ -176,12 +179,12 @@ if ( isset($_POST['add_record']) ) {
}
if ($result != NOERROR) {
echo "";
- CorrectRecord($g_dossier,$user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);
+ CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);
return;
}
$Res=StartSql($cn);
- $userPref=GetUserPeriode($cn,$user);
+ $userPref=GetUserPeriode($cn,$g_user);
$seq=GetNextId($cn,'j_grpt')+1;
$s_op=GetNextId($cn,'j_id')+1;
$tot_cred=0;
@@ -196,7 +199,7 @@ if ( isset($_POST['add_record']) ) {
j_jrn_def,j_debit,j_tech_user,j_tech_per)
values ( $s_op,to_date('$p_op_date','DD.MM.YYYY'), ".$montant.",'$p_text',
$l_class,$seq,
- $g_jrn,true,'$user',$userPref)";
+ $g_jrn,true,'$g_user',$userPref)";
echo_debug("sql $Sql");
$s_op++;
$tot_deb+=$montant;
@@ -214,7 +217,7 @@ if ( isset($_POST['add_record']) ) {
j_jrn_def,j_debit,j_tech_user,j_tech_per)
values ( $s_op,to_date('$p_op_date','DD.MM.YYYY'), $montant,'$p_text',
$l_class,$seq,
- $g_jrn,false,'$user',$userPref)";
+ $g_jrn,false,'$g_user',$userPref)";
echo_debug("sql $Sql");
$s_op++;
$tot_cred+=$montant;
@@ -313,7 +316,7 @@ if ( isset($_POST['update_record']) ) {
${"p_$name"}=$element;
}
reset($HTTP_POST_VARS);
- $result=VerifData($cn,$HTTP_POST_VARS,$user);
+ $result=VerifData($cn,$HTTP_POST_VARS,$g_user);
switch( $result) {
case NOERROR:
@@ -365,7 +368,7 @@ if ( isset($_POST['update_record']) ) {
${"p_$name"}=$element;
echo_debug("p_name p_$name = $element");
}
- $userPref=GetUserPeriode($cn,$user);
+ $userPref=GetUserPeriode($cn,$g_user);
for ( $i = 0; $i < $p_MaxDeb; $i++) {
$j_id=${"p_op_deb$i"};
@@ -374,9 +377,8 @@ if ( isset($_POST['update_record']) ) {
if ( strlen(trim($montant)) == 0) $montant=0;
$p_text=(FormatString(${"p_text_deb$i"})==null)?GetPosteLibelle($g_dossier,$l_class):FormatString(${"p_text_deb$i"});
- $Sql=sprintf("update jrnx set j_montant=%f, j_poste=%d,j_tech_user='%s',j_date=to_date('%s','DD.MM.YYYY'),j_text='%s',j_tech_per=%s
- where j_id=%d",
- $montant,$l_class,$user,$p_op_date,$p_text,$userPref,$j_id);
+ $Sql=sprintf("update jrnx set j_montant=%f, j_poste=%d,j_tech_user='%s',j_date=to_date('%s','DD.MM.YYYY'),j_text='%s' where j_id=%d",
+ $montant,$l_class,$g_user,$p_op_date,$p_text,$j_id);
echo_debug("sql $Sql");
$Res=ExecSql($cn,$Sql);
if ( $Res == false ) { Rollback($cn); EndSql($cn); return;}
@@ -391,9 +393,8 @@ if ( isset($_POST['update_record']) ) {
if ( strlen(trim($montant)) == 0 ) $montant=0;
$p_text=(FormatString(${"p_text_cred$i"})==null)?GetPosteLibelle($g_dossier,$l_class):FormatString(${"p_text_cred$i"});
- $Sql=sprintf("update jrnx set j_montant=%f,j_poste=%d,j_tech_user='%s', j_date=to_date('%s','DD.MM.YYYY'),j_text='%s',".
- " j_tech_per=%s where j_id=%d",
- $montant,$l_class,$user,$p_op_date,$p_text,$userPref,$j_id);
+ $Sql=sprintf("update jrnx set j_montant=%f,j_poste=%d,j_tech_user='%s', j_date=to_date('%s','DD.MM.YYYY'),j_text='%s' where j_id=%d",
+ $montant,$l_class,$g_user,$p_op_date,$p_text,$j_id);
echo_debug("sql $Sql");
// $s_op++;
$Res=ExecSql($cn,$Sql);
@@ -425,14 +426,15 @@ if ( isset($_POST['update_record']) ) {
$comment=FormatString($_POST["comment"]);
$Sql=sprintf("update jrn set jr_comment='%s',jr_date=%s,jr_rapt='%s',".
- "jr_montant=%f,jr_tech_per where
+ "jr_montant=%f j_tech_per=%d where
jr_id=%d",
$comment,
$l_date,
$p_rapt,
$p_sum_deb,
$userPref,
- $p_jr_id);
+ $p_jr_id
+ );
$Res=ExecSql($cn,$Sql);
$current_internal=GetInternal($cn,$p_jr_id);
@@ -445,10 +447,9 @@ if ( isset($_POST['update_record']) ) {
} else {
$comment=FormatString($_POST["comment"]);
$Sql=sprintf("update jrn set jr_comment='%s',
- jr_date=%s,jr_rapt=null,jr_montant=%f,jr_tech_per=%s where jr_id=%d",
+ jr_date=%s,jr_rapt=null,jr_montant=%f,jr_tech_per=%d where jr_id=%d",
$comment,
- $l_date,$p_sum_deb,
- $userPref,
+ $l_date,$p_sum_deb,$userPref,
$p_jr_id);
$Res=ExecSql($cn,$Sql);
@@ -463,7 +464,7 @@ if ( isset($_POST['update_record']) ) {
Rollback($cn);
EndSql($cn);
}
- ViewJrn($g_dossier,$user,$g_jrn);
+ ViewJrn($g_dossier,$g_user,$g_jrn);
} // if update_record
diff --git a/html/facturation.php b/html/facturation.php
index 4731f0017..a15c26b22 100644
--- a/html/facturation.php
+++ b/html/facturation.php
@@ -31,8 +31,8 @@ CheckUser();
include ("top_menu_compta.php");
ShowMenuCompta($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,FACT);
+if ( $g_UserProperty['use_admin']==0 ) {
+ $r=CheckAction($g_dossier,$g_user,FACT);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/fiche.php b/html/fiche.php
index b8724aa4f..45d713d34 100644
--- a/html/fiche.php
+++ b/html/fiche.php
@@ -53,8 +53,8 @@ if ( isset($_POST['add_modele']) ) {
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,FICHE);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,FICHE);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/form.php b/html/form.php
index b1900142f..6e55e2690 100644
--- a/html/form.php
+++ b/html/form.php
@@ -38,8 +38,8 @@ include ("check_priv.php");
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,FORM);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,FORM);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/impress.php b/html/impress.php
index b14cfbb08..04383ba0c 100644
--- a/html/impress.php
+++ b/html/impress.php
@@ -34,15 +34,15 @@ ShowMenuCompta($g_dossier);
include_once("impress_inc.php");
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,IMP);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,IMP);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
}
if (isset ($_GET["p_id"]) && isset ($_GET["type"])) {
if ( $type="jrn") {
- $right=CheckJrn($g_dossier,$user,$_GET['p_id']);
+ $right=CheckJrn($g_dossier,$g_user,$_GET['p_id']);
if ($right == 0 ){
/* Cannot Access */
NoAccess();
@@ -54,7 +54,7 @@ if ( CheckAdmin() == 0 ) {
$l_Db=sprintf("dossier%d",$g_dossier);
$cn=DbConnect($l_Db);
-ShowMenuJrnUserImp($cn,$user,$g_dossier);
+ShowMenuJrnUserImp($cn,$g_user,$g_dossier);
diff --git a/html/jrn_add.php b/html/jrn_add.php
index 2a11f960a..2dc5fc94d 100644
--- a/html/jrn_add.php
+++ b/html/jrn_add.php
@@ -34,8 +34,8 @@ include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,SECU);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,SECU);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/jrn_detail.php b/html/jrn_detail.php
index 1d3df124f..86db2be24 100644
--- a/html/jrn_detail.php
+++ b/html/jrn_detail.php
@@ -33,10 +33,10 @@ ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
include_once("check_priv.php");
-if ( CheckAdmin() == 0 ) {
+if ( $g_UserProperty['use_admin'] == 0 ) {
include_once("check_priv.php");
- $r=CheckAction($g_dossier,$user,SECU);
+ $r=CheckAction($g_dossier,$g_user,SECU);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/jrn_update.php b/html/jrn_update.php
index aed07e0f1..9e97f7847 100644
--- a/html/jrn_update.php
+++ b/html/jrn_update.php
@@ -34,8 +34,8 @@ include_once ("check_priv.php");
include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,GJRN);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,GJRN);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/line_update.php b/html/line_update.php
index d81060d1b..f48af24f8 100644
--- a/html/line_update.php
+++ b/html/line_update.php
@@ -31,8 +31,8 @@ include_once("check_priv.php");
/* Admin. Dossier */
CheckUser();
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,SECU);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,SECU);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/login.php b/html/login.php
index ef9fa0401..b730d0588 100644
--- a/html/login.php
+++ b/html/login.php
@@ -28,12 +28,15 @@ include_once("debug.php");
if ( isset ($_POST["p_user"] ) ) {
echo_debug("user is set");
- $user=$_POST["p_user"];
- $pass=$_POST["p_pass"];
+ $g_user=$_POST["p_user"];
+ $g_pass=$_POST["p_pass"];
+ session_register("g_user");
+ session_register("g_pass");
html_page_start();
+
} else
{
- if ( strlen($user) != 0 ) {
+ if ( strlen($g_user) != 0 ) {
echo_debug("user is not null");
html_page_start();
} else
@@ -52,8 +55,8 @@ if ( isset ($db_page) ) {
}
-echo_debug("USER=$user - ");
-echo_debug($HTTP_SESSION_VARS["user"]);
+echo_debug("USER=$g_user - ");
+//echo_debug($HTTP_SESSION_VARS["user"]);
echo_debug("PAGE = $db_page");
$cn=pg_connect("dbname=account_repository user='webcompta' ");
@@ -61,18 +64,14 @@ $IsValid=0;
// Verif if User and Pass match DB
// if no, then redirect to the login page
CheckUser();
+$g_UserProperty=GetUserProperty($cn,$g_user);
+session_register("g_UserProperty");
+echo_debug("theme =".$g_UserProperty['use_theme']);
-
-if ( $user != 'webcompta') {
- $sql="select use_id from ac_users where use_login='$user'
- and use_active=1 and use_admin=1";
-
- $rs=pg_exec($cn,$sql);
- $isAdmin=pg_NumRows($rs);
- } else $isAdmin=1;
include("top_menu_compta.php");
-ShowMenu();
-if ( $isAdmin != 0 ) {
+// Show the first menu
+ShowMenu($g_UserProperty['use_admin']);
+if ( $g_UserProperty['use_admin'] != 0 || $g_user=='webcompta' ) {
/* Administrator */
$l_MaxLine=0;
$r_database=ShowDossier('all',$db_page,$db_page+15,&$l_MaxLine);
diff --git a/html/pcmn_update.php b/html/pcmn_update.php
index 4981646a5..1d82c3348 100644
--- a/html/pcmn_update.php
+++ b/html/pcmn_update.php
@@ -35,8 +35,8 @@ include_once ("check_priv.php");
ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,MPCMN);
+if ( $g_UserProperty['use_admin'] == 0 ) {
+ $r=CheckAction($g_dossier,$g_user,MPCMN);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/html/priv_user.php b/html/priv_user.php
index 2c01006b5..f11b9b38c 100644
--- a/html/priv_user.php
+++ b/html/priv_user.php
@@ -26,7 +26,7 @@ echo_debug("entering priv_users");
CheckUser();
-if (CheckAdmin() != 1) {
+if ($g_UserProperty['use_admin'] != 1) {
html_page_stop();
return;
}
diff --git a/html/rate_chg.php b/html/rate_chg.php
index 229379838..a01b0861d 100644
--- a/html/rate_chg.php
+++ b/html/rate_chg.php
@@ -36,7 +36,7 @@ function SaveRate(p_code,p_rate)
CheckUser();
-if ( CheckAdmin()==0 ) return;
+if ( $g_UserProperty['use_admin'] ) return;
$dossier=sprint("dossier%d",$g_dossier);
$cn=DbConnect($dossier);
$Res=ExecSql($cn,"select pm_code, pm_rate from parm_money where pm_code='$p_code'");
diff --git a/html/user_pref.php b/html/user_pref.php
index 834725027..699ae452c 100644
--- a/html/user_pref.php
+++ b/html/user_pref.php
@@ -46,7 +46,7 @@ if ( isset ($spass) ) {
else {
$Cn=DbConnect();
$l_pass=md5($pass_1);
- $Res=ExecSql($Cn,"update ac_users set use_pass='$l_pass' where use_login='$user'");
+ $Res=ExecSql($Cn,"update ac_users set use_pass='$l_pass' where use_login='$g_user'");
$pass=$pass_1;
echo ' Mot de passe changé ';
}
@@ -70,10 +70,10 @@ if ( isset ($g_dossier) ) {
if ( isset ($_POST["sub_periode"] ) ) {
$periode=$_POST["periode"];
- SetUserPeriode($cn,$periode,$user);
+ SetUserPeriode($cn,$periode,$g_user);
}
- $l_user_per=GetUserPeriode($cn,$user);
+ $l_user_per=GetUserPeriode($cn,$g_user);
$l_form_per=FormPeriode($cn,$l_user_per);
?>
diff --git a/html/user_sec.php b/html/user_sec.php
index 0bcf35332..31123f991 100644
--- a/html/user_sec.php
+++ b/html/user_sec.php
@@ -33,8 +33,8 @@ CheckUser();
include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier);
ShowMenuComptaRight($g_dossier);
-if ( CheckAdmin() == 0 ) {
- $r=CheckAction($g_dossier,$user,SECU);
+if ( $g_UserProperty['use_admin']== 0 ) {
+ $r=CheckAction($g_dossier,$g_user,SECU);
if ($r == 0 ){
/* Cannot Access */
NoAccess();
diff --git a/include/ac_common.php b/include/ac_common.php
index a7a694c3c..1b46f103c 100644
--- a/include/ac_common.php
+++ b/include/ac_common.php
@@ -95,16 +95,17 @@ function formatDate($p_date) {
}
function html_page_start($p_first=0,$p_script="")
{
- global $user,$pass;
+ /*global $user,$pass;
if ($p_first == 1 ) {
echo_debug("Start session explicit");
session_start();
}
session_register("user");
session_register("pass");
-
+
echo_debug("user = ".$user." pass=".$pass);
+ */
echo '';
echo "";
echo "
diff --git a/include/postgres.php b/include/postgres.php
index 88b3739b9..8f91ff415 100644
--- a/include/postgres.php
+++ b/include/postgres.php
@@ -33,16 +33,16 @@
++*/
function CheckUser()
{
- global $user,$pass,$IsValid;
+ global $g_user,$g_pass,$IsValid;
echo_debug("CheckUser");
$res=0;
- $pass5=md5($pass);
+ $pass5=md5($g_pass);
if ( $IsValid == 1 ) { return; }
$cn=pg_connect("dbname=account_repository host=127.0.0.1 user='webcompta'");
if ( $cn != false ) {
$sql="select ac_users.use_login,ac_users.use_active, ac_users.use_pass
from ac_users
- where ac_users.use_login='$user'
+ where ac_users.use_login='$g_user'
and ac_users.use_active=1
and ac_users.use_pass='$pass5'";
echo_debug("Sql = $sql");
@@ -75,7 +75,7 @@ function CheckUser()
* Show the folder where user have access
++*/
function ShowDossier($p_type,$p_first=0,$p_max=10,$p_Num=0) {
- global $user;
+ global $g_user;
if ( $p_max == 0 ) {
$l_step="";
} else {
@@ -90,7 +90,7 @@ function ShowDossier($p_type,$p_first=0,$p_max=10,$p_Num=0) {
natural join ac_dossier
natural join ac_users
inner join priv_user on priv_jnt=jnt_id where
- use_login='".$user."' and priv_priv !='NO'
+ use_login='".$g_user."' and priv_priv !='NO'
order by dos_name ";
$p_Num=CountSql($cn,$l_sql);
}
@@ -107,44 +107,16 @@ function ShowDossier($p_type,$p_first=0,$p_max=10,$p_Num=0) {
//echo $row[dossier];
}
return $row;
-}
-/*++
- * function : CheckAccess
- * Parameter : $p_right (user or admin)
- * $p_database (name of the database)
- * Return : 1 if ok
- * Description :
- * Check user's access right to the given database
-++*/
-function CheckAccess($p_right,$p_database)
-{
-// global $user,$pass;
-// echo "User is $user";
-// $cn=pg_connect("host=127.0.0.1 dbname=$p_database user='webcompta' ");
-// $ret=pg_exec($cn,"select name from ac_dossier where name='$user' and dossier='$p_database' and priv='$p_right'");
-// if ( pg_NumRows($ret) == 0 ) {
-// /* echo '';*/
-// echo "
";
-// echo "
";
-// session_unset();
-// return 0;
-// }
-
-// return $ret;
-
}
// Check if the user has admin right
// to be complete
function CheckAdmin() {
- global $user,$pass;
+ global $g_user,$g_pass;
$res=0;
- if ( $user != 'webcompta') {
- $pass5=md5($pass);
- $sql="select use_id from ac_users where use_login='$user'
+ if ( $g_user != 'webcompta') {
+ $pass5=md5($g_pass);
+ $sql="select use_id from ac_users where use_login='$g_user'
and use_active=1 and use_admin=1 and use_pass='$pass5'";
$cn=DbConnect();
@@ -154,11 +126,24 @@ function CheckAdmin() {
return $isAdmin;
}
+/* function DbConnect
+ * purpose : connect to the database
+ * parameter : p_db : db_name
+ * return the connection
+ * todo : replace hardcoded by variable placed in
+ * constant.php
+ */
function DbConnect($p_db="account_repository") {
$a=pg_connect("dbname=$p_db host=127.0.0.1 user='webcompta'");
echo_debug ("connect to $p_db");
return $a;
}
+/* function ExecSql
+ * purpose : send a sql string to the database
+ * parameter p_connection db connection
+ * p_string sql string
+ * return false if error otherwise true
+ */
function ExecSql($p_connection, $p_string) {
echo_debug("SQL = $p_string");
$ret=pg_exec($p_connection,$p_string);
@@ -351,4 +336,31 @@ function SyncRight($p_dossier,$p_user) {
"(select uj_jrn_id from user_sec_jrn where uj_login='".$p_user."')";
$Res=ExecSql($cn,$sql);
}
+/* function GetUserProperty
+ * Purpose : Get the properties of an user
+ * it means theme, profile, admin...
+ *
+ * parm :
+ * - $p_user user login
+ * - $p_cn connection resource
+ * -
+ * gen :
+ * -
+ * return: an array
+ */
+function GetUserProperty($p_cn,$p_user)
+{
+ $sql="select use_admin,use_usertype,use_theme
+ from ac_users where use_login='$p_user'";
+ $Ret=ExecSql($p_cn,$sql);
+ if ( pg_NumRows($Ret) == 0)
+ return array('use_admin'=>0,
+ 'use_usertype'=>'user',
+ 'use_theme'=>'classic');
+
+ $a=pg_fetch_array($Ret,0);
+
+ return $a;
+}
+
?>
diff --git a/include/top_menu_compta.php b/include/top_menu_compta.php
index 31f9f7c9f..15629b2d7 100644
--- a/include/top_menu_compta.php
+++ b/include/top_menu_compta.php
@@ -21,29 +21,29 @@
// Auteur Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
-/* function
- * Purpose :
+/* function ShowMenu
+ * Purpose : Show The login menu
*
* parm :
- * -
+ * - $p_admin 1 if admin
+ * - $p_item item to add
* gen :
- * -
+ * - none
* return:
- * -
+ * - nothing
*
*/
- function ShowMenu($p_check = 1,$p_item="")
+ function ShowMenu($p_admin,$p_check = 1,$p_item="")
{
/* $p_check == 1 si test sur Admin */
include_once("postgres.php");
echo '';
echo "
";
- if ( $p_check == 1 ) {
- if ( CheckAdmin() != 0 ) {
+ if ( $p_admin !=0 ) {
/* Administrator Menu */
echo '| Administrator Menu | ';
}
- }
+
if (strlen ( $p_item ) != 0 ) {
echo ''.$p_item.' | ';
}
@@ -178,15 +178,16 @@ function ShowMenuComptaLeft($p_dossier,$p_item)
}
}
-/* function
- * Purpose :
- *
+/* function ShowMenuComptaRight
+ * Purpose : Display menu on the Right
+ * (preference, logout and admin)
* parm :
- * -
+ * - $p_dossier the current dossier
+ * - $p_more code
* gen :
- * -
+ * - none
* return:
- * -
+ * - none
*
*/
function ShowMenuComptaRight($p_dossier=0,$p_more="")
@@ -208,15 +209,15 @@ function ShowMenuComptaRight($p_dossier=0,$p_more="")
echo "
";
echo '
';
}
-/* function
+/* function ShowMenuAdminGlobalRight($p_dossier=0)
* Purpose :
- *
+ * Same as previous : show the right menu
* parm :
- * -
+ * - p_dossier
* gen :
- * -
+ * - none
* return:
- * -
+ * - none
*
*/
function ShowMenuAdminGlobalRight($p_dossier=0)
@@ -237,15 +238,15 @@ printf( '| Reto
echo "";
echo '';
}
-/* function
- * Purpose :
+/* function ShowMenuPcmn($p_start=1)
+ * Purpose : Show the menu from the pcmn page
*
* parm :
- * -
+ * - $p_start class start
* gen :
- * -
+ * - none
* return:
- * -
+ * - none
*
*/
@@ -264,15 +265,15 @@ function ShowMenuPcmn($p_start=1)
echo '';
}
-/* function
- * Purpose :
+/* function ShowMenuJrn($p_dossier)
+ * Purpose : Show the menu in the jrn page
*
* parm :
- * -
+ * - $p_dossier
* gen :
- * -
+ * - none
* return:
- * -
+ * - none
*
*/
@@ -284,7 +285,8 @@ function ShowMenuJrn($p_dossier)
include_once("postgres.php");
$l_jrn=sprintf("dossier%d",$p_dossier);
$Cn=DbConnect($l_jrn);
- $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc
+ $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_name,
+ jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc
from jrn_def join jrn_type on jrn_def_type=jrn_type_id");
$Max=pg_NumRows($Ret);
for ($i=0;$i<$Max;$i++) {
@@ -297,15 +299,17 @@ function ShowMenuJrn($p_dossier)
echo '';
}
-/* function
- * Purpose :
+/* function ShowMenuJrnUser($p_dossier,$p_user)
+ * Purpose : Show the Menu from the jrn encode
+ * page
*
* parm :
- * -
+ * - $p_dossier
+ * - $p_user
* gen :
- * -
+ * - none
* return:
- * -
+ * - none
*
*/
@@ -362,15 +366,17 @@ function ShowMenuJrnUser($p_dossier,$p_user)
echo '';
}
-/* function
+/* function ShowMenuRecherche
* Purpose :
*
* parm :
- * -
+ * - $p_dossier,
+ * - $p_jrn jrn id
+ * - $p_array=null previous search
* gen :
- * -
+ * - none
* return:
- * -
+ * - none
*
*/
@@ -456,15 +462,19 @@ function ShowMenuComptaForm($p_dossier) {
echo "";
echo '';
}
-/* function
- * Purpose :
+/* function ShowMenuJrnUserImp(
+ *
+ *
+ * Purpose : Show the menu of jrn to print
*
* parm :
- * -
+ * - $p_cn, connection
+ * $p_user, user
+ * $p_dossier dossier
* gen :
- * -
+ * - none
* return:
- * -
+ * - none
*
*/
@@ -590,7 +600,7 @@ function ShowMenuAdminGlobal()
echo $menu;
echo '';
}
-/* Function ShowItem($p_array) */
+/* function ShowItem($p_array) */
/* purpose : store the string which print */
/* the content of p_array in a table */
/* used to display the menu */
|