[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 37/65: Use the profile instead of the login n
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 37/65: Use the profile instead of the login name in the view |
Date: |
Wed, 09 Sep 2015 08:27:21 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 08e9239052fb1fb50569b2fb98af16e0fe03145e
Author: Dany De Bontridder <address@hidden>
Date: Fri Sep 4 13:25:00 2015 +0200
Use the profile instead of the login name in the view
---
include/ac_common.php | 6 ++--
include/class_user.php | 5 ++-
sql/upgrade.sql | 83 +++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 88 insertions(+), 6 deletions(-)
diff --git a/include/ac_common.php b/include/ac_common.php
index c45eb8e..1f820c4 100644
--- a/include/ac_common.php
+++ b/include/ac_common.php
@@ -843,9 +843,9 @@ function show_module($selected)
me_code,me_menu,me_url,me_javascript,p_order,me_type,me_description
from v_all_menu
where
- user_name=$1
+ p_id=$1
and p_type_display='M'
- order by p_order", array($g_user->login));
+ order by p_order", array($g_user->get_profile()));
if ($selected != -1)
{
@@ -853,7 +853,7 @@ function show_module($selected)
. ' pm_id = $1 ', array($selected));
require_once NOALYSS_INCLUDE.'/template/module.php';
$file = $cn->get_array("select
me_file,me_parameter,me_javascript,me_type,me_description from v_all_menu
- where pm_id=$1 and user_name=$2", array($selected,$g_user->login));
+ where pm_id=$1 and p_id=$2",
array($selected,$g_user->get_profile()));
if ( count($file ) == 0 )
{
echo '</div>';
diff --git a/include/class_user.php b/include/class_user.php
index 29a37d9..c166303 100644
--- a/include/class_user.php
+++ b/include/class_user.php
@@ -545,12 +545,13 @@ class User
/**
* Check if an user can access a module, return 1 if yes, otherwise 0
* record in audit log
+ * This function works only if user is connected to a Folder
* @param string $p_module menu_ref.me_code
*/
function check_module($p_module)
{
- $acc = $this->db->get_value("select count(*) from v_all_menu
where user_name = $1
- and me_code=$2", array($this->login, $p_module));
+ $acc = $this->db->get_value("select count(*) from v_all_menu
where p_id = $1
+ and me_code=$2", array($this->get_profile(), $p_module));
if ($acc == 0)
{
$this->audit("FAIL", $p_module);
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index f1718e1..d89c850 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -182,4 +182,85 @@ language plpgsql;
select insert_menu();
-drop function insert_menu();
\ No newline at end of file
+drop function insert_menu();
+
+CREATE OR REPLACE VIEW v_all_menu AS
+ SELECT pm.me_code,
+ pm.pm_id,
+ pm.me_code_dep,
+ pm.p_order,
+ pm.p_type_display,
+ p.p_name,
+ p.p_desc,
+ mr.me_menu,
+ mr.me_file,
+ mr.me_url,
+ mr.me_parameter,
+ mr.me_javascript,
+ mr.me_type,
+ pm.p_id,
+ mr.me_description
+ FROM profile_menu pm
+ JOIN profile p ON p.p_id = pm.p_id
+ JOIN menu_ref mr USING (me_code)
+ ORDER BY pm.p_order;
+
+DROP FUNCTION comptaproc.get_profile_menu(text);
+
+CREATE OR REPLACE FUNCTION comptaproc.get_profile_menu(p_profile integer)
+ RETURNS SETOF menu_tree AS
+$BODY$
+declare
+ a menu_tree;
+ e menu_tree;
+begin
+for a in select me_code,me_description from v_all_menu where p_id=p_profile
+ and me_code_dep is null and me_type <> 'PR' and me_type <>'SP'
+loop
+ return next a;
+
+ for e in select * from get_menu_tree(a.code,p_profile)
+ loop
+ return next e;
+ end loop;
+
+ end loop;
+return;
+end;
+$BODY$
+ LANGUAGE plpgsql ;
+
+DROP FUNCTION comptaproc.get_menu_tree(text, text);
+
+CREATE OR REPLACE FUNCTION comptaproc.get_menu_tree(p_code text, p_profile
integer)
+ RETURNS SETOF menu_tree AS
+$BODY$
+declare
+ i menu_tree;
+ e menu_tree;
+ a text;
+ x v_all_menu%ROWTYPE;
+begin
+ for x in select * from v_all_menu where me_code_dep=p_code::text and
p_id=p_profile
+ loop
+ if x.me_code_dep is not null then
+ i.code := x.me_code_dep||'/'||x.me_code;
+ else
+ i.code := x.me_code;
+ end if;
+
+ i.description := x.me_description;
+
+ return next i;
+
+ for e in select * from get_menu_tree(x.me_code,p_profile)
+ loop
+ e.code:=x.me_code_dep||'/'||e.code;
+ return next e;
+ end loop;
+
+ end loop;
+ return;
+end;
+$BODY$
+ LANGUAGE plpgsql;
\ No newline at end of file
- [Noalyss-commit] [noalyss] 24/65: Update documentation, (continued)
- [Noalyss-commit] [noalyss] 24/65: Update documentation, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 22/65: Script SQL à ajouter, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 27/65: Better debugging : add a button to show the request $_POST and $_GET, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 25/65: insert contact, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 29/65: Bug#1158 : sign and side of Analytic accountancy, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 30/65: comment, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 31/65: Fix issue : cannot zoom an operation after saving it., Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 35/65: Esthetic : message is nothing found in menu, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 33/65: Task#1173 : create a empty database to restaure in command line, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 36/65: Missing file, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 37/65: Use the profile instead of the login name in the view,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 39/65: Add the side D/C to aged balance, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 38/65: translation, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 34/65: increase size of font in box, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 40/65: Remove ENABLE_CACHE + DB Upgrade, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 42/65: Remove ENABLE_CACHE, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 43/65: set version, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 41/65: database upgrade, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 47/65: avoid duplicate, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 45/65: database upgrade : if empty, skipped, Dany De Bontridder, 2015/09/09
- [Noalyss-commit] [noalyss] 46/65: drop view before recreating it, Dany De Bontridder, 2015/09/09