Hide Fields based on Groups

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
MikeB
Posts: 18
Joined: 2013-01-08 19:18

Hide Fields based on Groups

Post by MikeB » 2013-01-16 19:12

Is there a way to hide specific fields in a table based on the login group? I'd like to have some fields hidden from users depending on the group they are in. Perhaps this should be a request for a new feature.
Thanks,
Mike

User avatar
a.gneady
Site Admin
Posts: 1024
Joined: 2012-09-27 14:46
Contact:

Re: Hide Fields based on Groups

Post by a.gneady » 2013-01-19 17:45

It's possible but needs several hook customizations. I'll try writing an article or post on how to do this, or consider adding it as a new feature in the admin area.
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.

:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.

:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

KSan
AppGini Super Hero
AppGini Super Hero
Posts: 252
Joined: 2013-01-08 20:17

Re: Hide Fields based on Groups

Post by KSan » 2013-01-19 18:50

Great idea. I too would love to see this as a new feature in future but having a hooks approach in the meanwhile would be great! Thank you very much.

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: Hide Fields based on Groups

Post by shasta59 » 2013-01-20 02:22

This does not really give you a long term fix but I needed to do this in a hurry. Had only about an hour to get it working. I had asked Ahmad about this but did not have the time to write the javascript and test it to get this working. I would have also needed different help files to be displayed so opted for the easiest solution.

What I did was the following:

1. Duplicated the template file for the form where I wanted different fields to be displayed based upon group. Lets say my table was named clinic_reg. In there was a field to be checked if the person's registration was approved. I did not want the person registering to check this off or even see it. I duplicated the template file. In the one for one group (registrars) I left the field in the template. For the people registering I deleted the field so they could not fill it out. This way only the registrars could see the field.

2. Next I had to change which template was used based upon which group the person belonged to. Now remember I was under the gun to get this live. The following are the actual table names but you can use your own.

Table name: clinic_reg
Template name: clinic_reg_templateDV.html
Template name for registrars: clinic_reg_templateDVM.html (this is template the registrars would see)

Code changed in clinic_reg_dml.php file. This code already exists in the file but I expanded it to redirect to the template file I wanted the person to see.

The following code looks at the group the person who logs in belongs to, then based upon the group # directs the system to use a specific template file. I also customized the template file with specific instructions depending who logged in - person registering had one set of instructions, registrar had other instructions. (Had no time to train on how to use so this made it easy - read the instructions was what they were told)

if(($_POST['dvprint_x']!='' || $_GET['dvprint_x']!='') && $selected_id){
$templateCode=@implode('', @file('./templates/clinic_reg_templateDVP.html'));
$dvprint=true;
}elseif(getLoggedGroupID() == 6 || getLoggedGroupID() == 2){ //group selector, if either a member of group 2 or 6 logged
$templateCode=@implode('', @file('./templates/clinic_reg_templateDVM.html'));//opens registrar version of template
$dvprint=false;
}else{ //code to use if not member of group 6 or 2
$templateCode=@implode('', @file('./templates/clinic_reg_templateDV.html')); //opens registrant version of template
$dvprint=false;

}


While cheap and dirty I actually still use this code. Biggest benefit I found was the ability to have unique instructions at the top of each page based upon the group they are in. The detail view was not shown on the same page as the table view.

Hope this helps someone with a solution which works and is easy to implement but not all that pretty and does mean an extra file.

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Re: Hide Fields based on Groups

Post by benzoD » 2013-02-06 17:11

Thanks for your quick solution, shasta59. I was looking for this ability in AG and though I have yet to implement it to my needs, it looks like a nice simple solution.

You don't need to be sensitive about hacking something together, it's the way of the web!

MI000001
Posts: 6
Joined: 2015-08-16 13:13

Re: Hide Fields based on Groups

Post by MI000001 » 2015-08-23 18:34

Hello, I am not an expert but i can find my way around code modifications... I need to achieve this if someone can help me with a draft of its code (preferably hooks) to do the followings:

I have Groups: Admin, Guest, Group1, Group2, Group3, Group-etc...

I have table1 (with fields a, b, c, d, e, f and g)

For table view, i show to all groups, fields a, b, c, and d only (this is easily done with the app gini project before code generation)

However, For the detail view only, i want:

for Admins, i want the admins members to be able to see all feilds in detail view of table1

for Guest, i want the guest to see in detail views only fields a, b, c and d (but not see e, f, and g as if they do not exist) - this would be the same fields they say as the table1 table view...

for Group1, they will see fields a, b, c, d only - if the record is not in their group (and also see e, f and g - if the record is in thier group

same condition for Group2, and group2, and so on... (all other groups)

a wish list, (although not what i want now, but in the near future) to be able to get the above behavor not only by which groups the records belongs to, but by owner (member) of the subject record... (not necessary now, but if we can achieve both type of filters, that would be great, otherwise, filers by groups will suffice for now.

Thank you very much in advance!

dragon
Veteran Member
Posts: 44
Joined: 2015-09-29 00:06

Re: Hide Fields based on Groups

Post by dragon » 2015-12-21 03:47

Was this feature added in 5.50?
Appgini 5.50, Revision 835. Mac OSX 10.11 running Windows 10 on VMWare.

User avatar
a.gneady
Site Admin
Posts: 1024
Joined: 2012-09-27 14:46
Contact:

Re: Hide Fields based on Groups

Post by a.gneady » 2016-01-03 16:55

Was this feature added in 5.50?
Nope. We plan to add it in future releases.
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.

:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.

:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

Moh Youba
Veteran Member
Posts: 67
Joined: 2017-03-12 09:31

Re: Hide Fields based on Groups

Post by Moh Youba » 2019-09-11 00:26

Hello

Was this feature added in 5.76? if yes where to find ?

Thank you

Post Reply