Code cleaning : preference are now in a separate table
This commit is contained in:
parent
29c9a40ded
commit
8165e96780
22 changed files with 71 additions and 44 deletions
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
begin;
|
||||
create table user_global_pref (
|
||||
user_id text,
|
||||
parameter_type text,
|
||||
|
|
@ -12,6 +12,9 @@ comment on column user_global_pref.parameter_value is 'the value of parameter ';
|
|||
alter table user_global_pref add constraint pk_user_global_pref primary key (user_id,parameter_type);
|
||||
|
||||
insert into user_global_pref select use_login,'PAGESIZE','50' from ac_users;
|
||||
insert into user_global_pref select use_login,'THEME',use_theme from ac_users;
|
||||
alter table ac_users drop use_usertype;
|
||||
alter table ac_users drop use_theme;
|
||||
update version set val=7;
|
||||
commit;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
/* $Revision$ */
|
||||
include_once ("ac_common.php");
|
||||
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/* $Revision$ */
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
include ("ac_common.php");
|
||||
include ("check_priv.php");
|
||||
/* $Revision$ */
|
||||
html_page_start($g_UserProperty['use_theme']);
|
||||
html_page_start($g_UserProperty['g_theme']);
|
||||
if ( ! isset ( $g_dossier ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
include_once ("ac_common.php");
|
||||
//phpinfo();
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
include_once ("ac_common.php");
|
||||
include_once ("user_menu.php");
|
||||
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
/* $Revision$ */
|
||||
include_once ("ac_common.php");
|
||||
include_once("jrn.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/* $Revision$ */
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
include_once ("ac_common.php");
|
||||
include_once ("poste.php");
|
||||
include_once ("user_common.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
// phpinfo();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/* $Revision$ */
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/* $Revision$ */
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
require_once("constant.php");
|
||||
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
/* $Revision$ */
|
||||
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['use_theme'],"onLoad='window.focus();'");
|
||||
html_page_start($_SESSION['g_theme'],"onLoad='window.focus();'");
|
||||
include_once ("postgres.php");
|
||||
include_once("jrn.php");
|
||||
/* Admin. Dossier */
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ include_once("ac_common.php");
|
|||
include_once("postgres.php");
|
||||
include_once("debug.php");
|
||||
include_once("user_menu.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
echo_debug(__FILE__,__LINE__,"entering priv_users");
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ include_once("user_common.php");
|
|||
include_once("class_widget.php");
|
||||
|
||||
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ include_once("postgres.php");
|
|||
include_once("stock_inc.php");
|
||||
include_once("check_priv.php");
|
||||
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
include_once ("ac_common.php");
|
||||
/* $Revision$ */
|
||||
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
phpinfo();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/* $Revision$ */
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ include_once ("class_user.php");
|
|||
$User=new cl_user($rep);
|
||||
|
||||
$User->Check();
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
include_once("user_menu.php");
|
||||
|
||||
$priv=($User->admin==1)?"Administrator":"User";
|
||||
|
|
|
|||
|
|
@ -27,18 +27,17 @@ include_once ("class_user.php");
|
|||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
$User=new cl_user($cn);
|
||||
$User->Check();
|
||||
|
||||
// Met a jour le theme utilisateur (style)
|
||||
if ( isset ( $_POST['style_user']) ) {
|
||||
$Res=ExecSql($Rep,
|
||||
"update ac_users set use_theme='".$_POST['style_user'].
|
||||
"' where use_login='".$_SESSION['g_user']."'");
|
||||
$Res=ExecSql($Rep,
|
||||
"update user_global_pref set parameter_value='".$_POST['style_user'].
|
||||
"' where user_id='".$_SESSION['g_user']."' and parameter_type='THEME'");
|
||||
// echo '<H2 class="info"> Theme utilisateur changé </H1>';
|
||||
$_SESSION['use_theme']=$_POST['style_user'];
|
||||
$_SESSION['g_theme']=$_POST['style_user'];
|
||||
|
||||
}
|
||||
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
// show the top menu depending of the use_style
|
||||
// comta style
|
||||
|
|
@ -67,15 +66,6 @@ if ( isset ($_POST['spass']) ) {
|
|||
$g_pass=$pass_1;
|
||||
}
|
||||
}
|
||||
// Met a jour le theme utilisateur (style)
|
||||
if ( isset ( $_POST['style_user']) ) {
|
||||
$Res=ExecSql($Rep,
|
||||
"update ac_users set use_theme='".$_POST['style_user'].
|
||||
"' where use_login='".$_SESSION['g_user']."'");
|
||||
// echo '<H2 class="info"> Theme utilisateur changé </H1>';
|
||||
$_SESSION['use_theme']=$_POST['style_user'];
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<H2 CLASS="info"> Password</H2>
|
||||
|
|
@ -97,7 +87,7 @@ for ($i=0;$i < pg_NumRows($res);$i++){
|
|||
// Formatte le display
|
||||
$disp_style="<SELECT NAME=\"style_user\" >";
|
||||
foreach ($style as $st){
|
||||
if ( $st == $_SESSION['use_theme'] ) {
|
||||
if ( $st == $_SESSION['g_theme'] ) {
|
||||
$disp_style.='<OPTION VALUE="'.$st.'" SELECTED>'.$st;
|
||||
} else {
|
||||
$disp_style.='<OPTION VALUE="'.$st.'">'.$st;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
include_once ("ac_common.php");
|
||||
include_once("check_priv.php");
|
||||
html_page_start($_SESSION['use_theme']);
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ class cl_user {
|
|||
$this->pass=$_SESSION['g_pass'];
|
||||
$this->valid=(isset ($_SESSION['isValid']))?1:0;
|
||||
$this->db=$p_cn;
|
||||
if ( isset($_SESSION['use_theme']) )
|
||||
$this->theme=$_SESSION['use_theme'];
|
||||
if ( isset($_SESSION['g_theme']) )
|
||||
$this->theme=$_SESSION['g_theme'];
|
||||
|
||||
$this->admin=( isset($_SESSION['use_admin']) )?$_SESSION['use_admin']:0;
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ class cl_user {
|
|||
use_name,
|
||||
use_login,
|
||||
use_active,
|
||||
use_admin
|
||||
use_admin,
|
||||
from ac_users
|
||||
where use_id=$p_id";
|
||||
$cn=DbConnect();
|
||||
|
|
@ -91,7 +91,7 @@ class cl_user {
|
|||
$cn=DbConnect();
|
||||
if ( $cn != false ) {
|
||||
$sql="select ac_users.use_login,ac_users.use_active, ac_users.use_pass,
|
||||
use_theme,use_admin,use_first_name,use_name
|
||||
use_admin,use_first_name,use_name
|
||||
from ac_users
|
||||
where ac_users.use_login='$this->id'
|
||||
and ac_users.use_active=1
|
||||
|
|
@ -102,15 +102,16 @@ class cl_user {
|
|||
echo_debug(__FILE__,__LINE__,"Number of found rows : $res");
|
||||
if ( $res >0 ) {
|
||||
$r=pg_fetch_array($ret,0);
|
||||
$_SESSION['use_theme']=$r['use_theme'];
|
||||
$_SESSION['use_admin']=$r['use_admin'];
|
||||
$_SESSION['use_name']=$r['use_name'];
|
||||
$_SESSION['use_first_name']=$r['use_first_name'];
|
||||
|
||||
$this->theme=$_SESSION['use_theme'];
|
||||
$this->theme=$_SESSION['g_theme'];
|
||||
$this->admin=$_SESSION['use_admin'];
|
||||
$this->name=$_SESSION['use_name'];
|
||||
$this->first_name=$_SESSION['use_first_name'];
|
||||
$this->GetGlobalPref();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +266,40 @@ function GetPreferences ()
|
|||
if ( $Count == 1 ) return 1;
|
||||
echo "<H2 class=\"error\"> Invalid action !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id </H2>";
|
||||
}
|
||||
/* function GetGlobalPref
|
||||
**************************************************
|
||||
* Purpose : Get the global preferences from user_global_pref
|
||||
* in the account_repository db
|
||||
* parm :
|
||||
* - set g_variable
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* - none
|
||||
*/
|
||||
|
||||
|
||||
function GetGlobalPref()
|
||||
{
|
||||
$cn=Dbconnect();
|
||||
// Load everything in an array
|
||||
$Res=ExecSql ($cn,"select parameter_type,parameter_value from
|
||||
user_global_pref
|
||||
where user_id='".$this->id."'");
|
||||
$Max=pg_NumRows($Res);
|
||||
if ( $Max == 0 ) return null;
|
||||
// Load value into array
|
||||
$line=array();
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$row=pg_fetch_array($Res,$i);
|
||||
$type=$row['parameter_type'];
|
||||
$line[$type]=$row['parameter_value'];;
|
||||
}
|
||||
// save array into g_ variable
|
||||
$array_pref=array ('g_theme'=>'THEME','g_pagesize'=>'PAGESIZE');
|
||||
foreach ($array_pref as $name=>$parameter ) {
|
||||
$_SESSION[$name]=$line[$parameter];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -316,13 +316,13 @@ function SyncRight($p_dossier,$p_user) {
|
|||
* return: an array
|
||||
* containing use_admin
|
||||
* use_usertype
|
||||
* use_theme
|
||||
* g_theme
|
||||
* use_name
|
||||
* use_login
|
||||
*/
|
||||
function GetUserProperty($p_cn,$p_user)
|
||||
{
|
||||
$sql="select use_login,use_first_name,use_name,use_admin,use_usertype,use_theme
|
||||
$sql="select use_login,use_first_name,use_name,use_admin,use_usertype,g_theme
|
||||
from ac_users where use_login='$p_user'";
|
||||
$Ret=ExecSql($p_cn,$sql);
|
||||
if ( pg_NumRows($Ret) == 0)
|
||||
|
|
@ -330,7 +330,7 @@ function GetUserProperty($p_cn,$p_user)
|
|||
'use_name'=>'Unknown',
|
||||
'use_admin'=>0,
|
||||
'use_usertype'=>'user',
|
||||
'use_theme'=>'classic',
|
||||
'g_theme'=>'classic',
|
||||
'use_login'=>$p_user);
|
||||
|
||||
$a=pg_fetch_array($Ret,0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue