Hello.
I have a situation and i need some help, please.
So i have 2 locations. A and B. And i have invoices table for locations A and B. Also i have table for locations A and B.
Invoice table:
1. Client (text insert)
2. Location (select from table Locations)
3. Price on invoice (text insert)
So i need that the manager from location A to have acces ONLY to rows selected the location A. And manager from location B to see and have ONLY the fileds that are selected location B.
Is that possible? To have 2 usernames on AppGini and each user to have acces to data only on their locations selection?
Thank you!
Row view based by a filed
Re: Row view based by a filed
You can modify the
Example
List customers starting with 'a' AND email-address like *@gmail.*
This can be a first step. You can filter out records which current user (
But the app users will still be able to open the detail view of "forbidden" records if they only knew the record-ID. To avoid this you will have to check in
WHERE
-clause of the SQL-statement in TABLENAME_init()
-function of hooks-file like this:Example
List customers starting with 'a' AND email-address like *@gmail.*
Code: Select all
// file: hooks/customers.php
function customers_init(&$options, $memberInfo, &$args)
{
// array of conditions. Will be AND-joined
$conditions = [
"customers.name LIKE 'a%'"
, "customers.email LIKE '%@gmail.%'"
// you can add more conditions here
];
if (sizeof($conditions)) $options->QueryWhere .= ($options->QueryWhere ? " AND " : " WHERE ") . implode(" AND ", $conditions);
return TRUE;
}
getLoggedMemberID()
) must not see. In many use cases this level of security is high enough.But the app users will still be able to open the detail view of "forbidden" records if they only knew the record-ID. To avoid this you will have to check in
TABLENAME_dv()
-hook and deny access to Detail View.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Row view based by a filed
If you need to check special permissions before opening Detail View, you can modify
Example
Deny access if customer's name starts with 'a'
Result
_dv
hook in file hooks/TABLENAME-dv.js
.Example
Deny access if customer's name starts with 'a'
Code: Select all
function customers_dv($selectedID, $memberInfo, &$html, &$args)
{
$tn = "customers";
$allow_access = $selectedID && strtolower(substr(getRecord($tn, $selectedID)['name'], 0, 1)) == 'a';
if (!$allow_access) die("<h1>Access denied</h1><a href=\"{$tn}_view.php\">Back</a>");
}
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Row view based by a filed
Sorry, there was a small but important mistake in my previous post due to copy & paste:
Wrong filename
Wrong filename
Correct filename
[...] you can modify_dv
hook in file hooks/TABLENAME.php [...]
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Row view based by a filed
Thank you for your time.
I understand. But maybe i was not to good in explination, sorry.
So i have a table Invoices. On that table i have Location, Name , etc. On Location i can select "Location A" and "Location B".
I need to filtrer when user A is logged to see rows that is selected "Location A" and when user B is logged to see rows that is selected "Location B".
I need to do this depending of what user is logged in (when acceses table Invoices)
Thank you verry much for your support. This forum helped me a lot!!!!
Thank you again!!!!!
I understand. But maybe i was not to good in explination, sorry.
So i have a table Invoices. On that table i have Location, Name , etc. On Location i can select "Location A" and "Location B".
I need to filtrer when user A is logged to see rows that is selected "Location A" and when user B is logged to see rows that is selected "Location B".
I need to do this depending of what user is logged in (when acceses table Invoices)
Thank you verry much for your support. This forum helped me a lot!!!!
Thank you again!!!!!
Re: Row view based by a filed
You can use the code a starting point and write any SQL query you need.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools