From af2363c7cdb45a4d95f4a9ac839118cb136cd6fc Mon Sep 17 00:00:00 2001 From: Phyks Date: Tue, 12 Nov 2013 20:11:24 +0100 Subject: [PATCH] Mask invoices when user is not concerned (except if admin user) Only the invoices that concern the current user (as buyer or user in) are displayed now. --- TODO | 1 - index.php | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index b297b9d..35e18d8 100755 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ * Notifications by e-mail for users -* Mask invoices when user is not concerned in "show all invoices" Improvements : ============== diff --git a/index.php b/index.php index 257660c..edf7513 100755 --- a/index.php +++ b/index.php @@ -1055,6 +1055,17 @@ $tpl->assign('all', 1); } + // Only keep the invoices which concern the user (as buyer or user in) (only if user != admin) + // TODO : Optimize ? + if(!$current_user->getAdmin()) { + foreach($invoices_list as $key=>$invoice) { + if($invoice->getBuyer() != $current_user->getId() && !$invoice->getUsersIn()->inUsersIn($current_user->getId())) { + unset($invoices_list[$key]); + } + } + } + + if($invoices_list === false) $invoices_list = array(); else { $sort_keys = array();