Task #0001519: Assouplissement de la sécurité : journaux et actions
This commit is contained in:
parent
aad3efbd5e
commit
2e4bbf1eb0
11 changed files with 222 additions and 28 deletions
|
|
@ -531,13 +531,10 @@ class Acc_Ledger_Search
|
|||
$fil_paid=$and.SQL_LIST_UNPAID_INVOICE;
|
||||
$and=" and ";
|
||||
}
|
||||
$repo=new Database();
|
||||
$g_user=new User($repo);
|
||||
$g_user->Check();
|
||||
$g_user->check_dossier(dossier::id());
|
||||
|
||||
if ($g_user->admin==0&&$g_user->is_local_admin()==0)
|
||||
global $g_user;
|
||||
if ($g_user->admin==0&&$g_user->is_local_admin()==0 && $g_user->get_status_security_ledger()==1 )
|
||||
{
|
||||
|
||||
$fil_sec=$and." jr_def_id in ( select uj_jrn_id ".
|
||||
" from user_sec_jrn where ".
|
||||
" uj_login='".sql_string($_SESSION['g_user'])."'".
|
||||
|
|
|
|||
|
|
@ -478,7 +478,7 @@ class Document
|
|||
$doc->d_number=$res[$i]['d_number'];
|
||||
$doc->d_filename=$res[$i]['d_filename'];
|
||||
$doc->d_mimetype=$res[$i]['d_mimetype'];
|
||||
$doc->d_description=$row['d_description'];
|
||||
$doc->d_description=$res[$i]['d_description'];
|
||||
$a[$i]=clone $doc;
|
||||
}
|
||||
return $a;
|
||||
|
|
|
|||
|
|
@ -280,7 +280,8 @@ class User
|
|||
function get_ledger_access($p_ledger)
|
||||
{
|
||||
if ($this->admin == 1 ||
|
||||
$this->is_local_admin(dossier::id()) == 1)
|
||||
$this->is_local_admin(dossier::id()) == 1
|
||||
|| $this->get_status_security_ledger()==0)
|
||||
return 'W';
|
||||
|
||||
$sql = "select uj_priv from user_sec_jrn where uj_login=$1 and uj_jrn_id=$2";
|
||||
|
|
@ -310,7 +311,7 @@ class User
|
|||
|
||||
function get_ledger($p_type = 'ALL', $p_access = 3)
|
||||
{
|
||||
if ($this->admin != 1 && $this->is_local_admin() != 1)
|
||||
if ($this->admin != 1 && $this->is_local_admin() != 1 && $this->get_status_security_ledger() == 1)
|
||||
{
|
||||
$sql_type = ($p_type == 'ALL') ? '' : "and jrn_def_type=upper('" . sql_string($p_type) . "')";
|
||||
switch ($p_access)
|
||||
|
|
@ -578,7 +579,8 @@ class User
|
|||
return 1;
|
||||
if ($this->is_local_admin(dossier::id()) == 1)
|
||||
return 1;
|
||||
|
||||
if ( $this->get_status_security_action() == 0)
|
||||
return 1;
|
||||
$Res = $this->db->exec_sql(
|
||||
"select * from user_sec_act where ua_login=$1 and ua_act_id=$2", array($this->login, $p_action_id));
|
||||
$Count = Database::num_row($Res);
|
||||
|
|
@ -1164,12 +1166,13 @@ class User
|
|||
*/
|
||||
function can_write_action($dtoc)
|
||||
{
|
||||
if ( $this->Admin() == 1 ) return true;
|
||||
$profile = $this->get_profile();
|
||||
if ( $this->Admin() == 1 ) return TRUE;
|
||||
if ( $this->get_status_security_action()==0) return TRUE;
|
||||
$profile = $this->get_profile();
|
||||
$r = $this->db->get_value(" select count(*) from action_gestion where ag_id=$1 and ag_dest in
|
||||
(select p_granted from user_sec_action_profile where ua_right='W' and p_id=$2) ", array($dtoc, $profile));
|
||||
if ($r == 0)
|
||||
return false;
|
||||
return FALSE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1328,9 +1331,68 @@ class User
|
|||
$cnx_dossier->exec_sql("delete from profile_user where user_name=$1",array($a_user[$i]['user_name']));
|
||||
$cnx_dossier->exec_sql("delete from user_sec_act where ua_login=$1",array($a_user[$i]['user_name']));
|
||||
$cnx_dossier->exec_sql("delete from user_sec_jrn where uj_login=$1",array($a_user[$i]['user_name']));
|
||||
$cnx_dossier->exec_sql("delete from user_active_security where us_login=$1",array($a_user[$i]['user_name']));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the security on ledger for the user , it returns 1 if the security
|
||||
* on ledgers is enabled, otherwise 0
|
||||
*/
|
||||
function get_status_security_ledger()
|
||||
{
|
||||
$security=$this->db->get_value("select us_ledger from user_active_security
|
||||
where
|
||||
us_login=$1",[$this->login]);
|
||||
$n_security =($security=="Y")?1:0;
|
||||
return $n_security;
|
||||
}
|
||||
/**
|
||||
* Set the flag in the table user_active_security
|
||||
* @param int $p_value 1==enable , 0 = disable
|
||||
* @exceptions invalid value
|
||||
*/
|
||||
function set_status_security_ledger($p_value)
|
||||
{
|
||||
if ($p_value != 0 && $p_value != 1) throw new Exception (_("Valeur invalide"));
|
||||
$exist=$this->db->get_value("select count(*) from user_active_security where us_login=$1",
|
||||
[$this->login]);
|
||||
$flag=($p_value==1)?"Y":"N";
|
||||
if ( $exist == 0) {
|
||||
$this->db->exec_sql("insert into user_active_security (us_login,us_ledger,us_action) values ($1,$2,$3",[$this->login,$flag,'Y']);
|
||||
} else {
|
||||
$this->db->exec_sql("update user_active_security set us_ledger=$1 where us_login = $2",[$flag,$this->login]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the security on ledger for the user , it returns 1 if the security
|
||||
* on ledgers is enabled, otherwise 0
|
||||
*/
|
||||
function get_status_security_action()
|
||||
{
|
||||
$security=$this->db->get_value("select us_action from user_active_security
|
||||
where
|
||||
us_login=$1",[$this->login]);
|
||||
$n_security =($security=="Y")?1:0;
|
||||
return $n_security;
|
||||
}
|
||||
/**
|
||||
* Set the flag in the table user_active_security
|
||||
* @param int $p_value 1==enable , 0 = disable
|
||||
* @exceptions invalid value
|
||||
*/
|
||||
function set_status_security_action($p_value)
|
||||
{
|
||||
if ($p_value != 0 && $p_value != 1) throw new Exception (_("Valeur invalide"));
|
||||
$exist=$this->db->get_value("select count(*) from user_active_security where us_login=$1",
|
||||
[$this->login]);
|
||||
$flag=($p_value==1)?"Y":"N";
|
||||
if ( $exist == 0) {
|
||||
$this->db->exec_sql("insert into user_active_security (us_login,us_action,us_ledger) values ($1,$2,$3",[$this->login,$flag,'Y']);
|
||||
} else {
|
||||
$this->db->exec_sql("update user_active_security set us_action=$1 where us_login = $2",[$flag,$this->login]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue