diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index f3b4dd086..beea21874 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -110,11 +110,15 @@ $path = array(
"card"=>"ajax_card",
"ledger"=>"ajax_ledger",
// Manage ledger access
- "ledger_access"=>"ajax_ledger_security",
+ "ledger_access"=>"ajax_user_security",
// Manage user profile
- "profile"=>"ajax_ledger_security",
+ "profile"=>"ajax_user_security",
// Update in once all the ledgers
- "ledger_access_all"=>"ajax_ledger_security",
+ "ledger_access_all"=>"ajax_user_security",
+ // From the page CFGSEC,set the actions
+ "action_access"=>"ajax_user_security",
+ // From the page CFGSEC,set all the actions
+ "action_access_all"=>"ajax_user_security",
"todo_list"=>"ajax_todo_list",
"history"=>"ajax_history",
"pcmn_update"=>"ajax_pcmn_update",
diff --git a/html/image/icon-off.png b/html/image/icon-off.png
new file mode 100644
index 000000000..8f8c56a8b
Binary files /dev/null and b/html/image/icon-off.png differ
diff --git a/html/image/icon-on.png b/html/image/icon-on.png
new file mode 100644
index 000000000..cc3344ab9
Binary files /dev/null and b/html/image/icon-on.png differ
diff --git a/include/ajax/ajax_ledger_security.php b/include/ajax/ajax_user_security.php
similarity index 73%
rename from include/ajax/ajax_ledger_security.php
rename to include/ajax/ajax_user_security.php
index 142396214..2c515b12c 100644
--- a/include/ajax/ajax_ledger_security.php
+++ b/include/ajax/ajax_user_security.php
@@ -27,13 +27,13 @@ require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
require_once NOALYSS_INCLUDE.'/lib/inum.class.php';
require_once NOALYSS_INCLUDE.'/lib/inplace_edit.class.php';
+require_once NOALYSS_INCLUDE.'/lib/inplace_switch.class.php';
/**
* @file
* @brief Manage the security of a ledger , from CFGSEC module
*
*/
-
$n_dossier_id=Dossier::id();
//-----------------------------------------------------------------------------
// Manage the user's access to ledgers
@@ -97,12 +97,12 @@ if ($op=="ledger_access")
//-----------------------------------------------------------------------------
// Set the user's profile
//-----------------------------------------------------------------------------
-if ( $op == "profile")
+if ($op=="profile")
{
$input=$http->request("input");
$action=$http->request("ieaction", "string", "display");
$user_id=$http->post("user_id", "numeric");
- $profile_id=$http->post("profile_id","numeric");
+ $profile_id=$http->post("profile_id", "numeric");
if ($action=="display")
{
$ie_input=Inplace_Edit::build($input);
@@ -117,16 +117,16 @@ if ( $op == "profile")
if ($action=="ok")
{
$value=$http->post("value");
- // save profile
- $sec_User=new User($cn,$user_id);
- $sec_User->save_profile($value);
+ // save profile
+ $sec_User=new User($cn, $user_id);
+ $sec_User->save_profile($value);
$ie_input=Inplace_Edit::build($input);
$ie_input->set_callback("ajax_misc.php");
$ie_input->add_json_param("op", "profile");
$ie_input->add_json_param("gDossier", $n_dossier_id);
$ie_input->add_json_param("user_id", $user_id);
$ie_input->set_value($value);
-
+
echo $ie_input->value();
return;
}
@@ -145,11 +145,13 @@ if ( $op == "profile")
//------------------------------------------------------------------------------
// Update in once all the ledger access for an user
//------------------------------------------------------------------------------
-if ( $op == 'ledger_access_all') {
+if ($op=='ledger_access_all')
+{
// Find the login
- $user_id=$http->post("user_id","numeric");
+ $user_id=$http->post("user_id", "numeric");
$access=$http->post("access");
- if ( $access != "W" && $access != "X" && $access !="R") die("Invalid access");
+ if ($access!="W"&&$access!="X"&&$access!="R")
+ die("Invalid access");
$sec_User=new User($cn, $user_id);
// Insert all the existing ledgers to user_sec_jrn
$sql="insert into user_sec_jrn(
@@ -167,7 +169,52 @@ if ( $op == 'ledger_access_all') {
uj_jrn_id = jrn_def_id
and uj_login = $1
)";
- $cn->exec_sql($sql,array($sec_User->login));
- $cn->exec_sql('update user_sec_jrn set uj_priv=$1 where uj_login=$2',array($access,$sec_User->login));
+ $cn->exec_sql($sql, array($sec_User->login));
+ $cn->exec_sql('update user_sec_jrn set uj_priv=$1 where uj_login=$2',
+ array($access, $sec_User->login));
return;
+}
+//------------------------------------------------------------------------------
+// Set on or off the action
+//------------------------------------------------------------------------------
+if ($op=="action_access")
+{
+ $action_id=$http->get("ac_id", "numeric");
+ $user_id=$http->get("user_id","numeric");
+ $sec_User=new User($cn, $user_id);
+
+ $right=$sec_User->check_action($action_id);
+ $is_switch=new Inplace_Switch("action".$action_id,0);
+ if ($right==1)
+ {
+ $cn->exec_sql("delete from user_sec_act where ua_act_id=$1 and ua_login=$2",
+ array($action_id, $sec_User->login));
+ echo $is_switch->get_iconoff();
+ } else {
+ $cn->exec_sql('insert into user_sec_act (ua_login,ua_act_id)'.
+ ' values ($1,$2)',
+ array($sec_User->login,$action_id));
+ echo $is_switch->get_iconon();
+ }
+
+
+
+}
+//----------------------------------------------------------------------------
+// Set all the actions
+//----------------------------------------------------------------------------
+if ($op=="action_access_all")
+{
+ $user_id=$http->get("user_id","numeric");
+ $access=$http->get("access","numeric");
+ $sec_User=new User($cn, $user_id);
+ if ( $access==0) {
+ $cn->exec_sql("delete from user_sec_act where ua_login=$1",array($sec_User->login));
+ }
+ if ( $access==1) {
+ $cn->exec_sql("
+ insert into user_sec_act(ua_login,ua_act_id) select $1,ac_id from action where not exists(select 1 from user_sec_act where ua_login=$1 and ua_act_id=ac_id)",
+ array($sec_User->login));
+ }
+
}
\ No newline at end of file
diff --git a/include/lib/inplace_edit.class.php b/include/lib/inplace_edit.class.php
index 522a59922..bbe9999e0 100644
--- a/include/lib/inplace_edit.class.php
+++ b/include/lib/inplace_edit.class.php
@@ -111,6 +111,7 @@ EOF;
$v=$this->input->get_value();
$v=(trim($v)=="")?$this->message:$v;
echo $v,
+ "
",
"
+EOF;
+ }
+
+ public function get_json()
+ {
+ return $this->json;
+ }
+
+ public function get_callback()
+ {
+ return $this->callback;
+ }
+
+ public function set_json($json)
+ {
+ $this->json=$json;
+ }
+
+ public function set_callback($callback)
+ {
+ $this->callback=$callback;
+ }
+
+ public function get_iconon()
+ {
+ return $this->iconon;
+ }
+
+ public function get_iconoff()
+ {
+ return $this->iconoff;
+ }
+
+ public function get_name()
+ {
+ return $this->name;
+ }
+
+ public function get_value()
+ {
+ return $this->value;
+ }
+
+ public function set_iconon($iconon)
+ {
+ $this->iconon=$iconon;
+ }
+
+ public function set_iconoff($iconoff)
+ {
+ $this->iconoff=$iconoff;
+ }
+
+ public function set_name($name)
+ {
+ $this->name=$name;
+ }
+
+ public function set_value($value)
+ {
+ $this->value=$value;
+ }
+ /**
+ * Add json parameter to the current one, if there attribute already exists
+ * it will be overwritten
+ */
+ function add_json_param($p_attribute,$p_value) {
+ $x=json_decode($this->json,TRUE);
+ $x[$p_attribute]=$p_value;
+ $this->json=json_encode($x, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
+ }
+}
diff --git a/include/param_sec.inc.php b/include/param_sec.inc.php
index 08b81c9e4..00ddcd78d 100644
--- a/include/param_sec.inc.php
+++ b/include/param_sec.inc.php
@@ -30,6 +30,7 @@ require_once NOALYSS_INCLUDE.'/class/user.class.php';
require_once NOALYSS_INCLUDE.'/lib/database.class.php';
require_once NOALYSS_INCLUDE.'/lib/sort_table.class.php';
require_once NOALYSS_INCLUDE.'/lib/inplace_edit.class.php';
+require_once NOALYSS_INCLUDE.'/lib/inplace_switch.class.php';
$http=new HttpInput();
@@ -119,57 +120,7 @@ if ( isset ($_GET["action"] ))
$action=$http->get("action");
}
-//----------------------------------------------------------------------
-// Action = save
-//----------------------------------------------------------------------
-if ( isset($_POST['ok']))
-{
- try
- {
- $cn->start();
- $user_id=$http->post('user_id',"numeric");
- $sec_User=new User($cn,$user_id);
-
- /* now save all the actions */
- $a=$cn->get_array('select ac_id from action');
- /*
- * @todo must be replaced by ajax
- */
- foreach ($a as $key)
- {
- $id=$key['ac_id'];
- $priv=sprintf("action%d",$id);
- if ( ! isset ($_POST[$priv]))
- {
- $cn->exec_sql("delete from user_sec_act where ua_act_id=$1",array($id));
- continue;
- }
- $count=$cn->get_value('select count(*) from user_sec_act where ua_login=$1 '.
- ' and ua_act_id=$2',array($sec_User->login,$id));
- if ( $_POST[$priv] == 1 && $count == 0)
- {
- $cn->exec_sql('insert into user_sec_act (ua_login,ua_act_id)'.
- ' values ($1,$2)',
- array($sec_User->login,$id));
-
- }
- if ($_POST[$priv] == 0 )
- {
- $cn->exec_sql('delete from user_sec_act where ua_login=$1 and ua_act_id=$2',
- array($sec_User->login,$id));
- }
- }
- $cn->commit();
- } // end try
- catch (Exception $e)
- {
- echo_warning ($e->getMessage());
- record_log($e->getTraceAsString());
- $cn->rollback();
- }
-
-}
@@ -241,7 +192,6 @@ if ( $action == "view" )
$sec_User=new User($cn,$user_id);
$n_dossier_id=Dossier::id();
- echo '