Show fields only for certain groups

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Show fields only for certain groups

Post by benzoD » 2013-02-06 16:28

Hi. I just purchased AppGini a few days ago and it's great! I've been using it and have a question about groups and permissions...

I am creating a service request system - the Office Staff group can add requests for maintenance or IT service, the Maintenance Admin group can assign the requests to Maintenance/IT staff as well as update request status and add notes, images, etc. For some fields I would like to have it viewable and editable by Maintenance Staff but not Office Staff. I've set them to hidden in table/detail view but it's also hidden for the Maintenance Staff.

How can I hide fields from one group but not another?

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

Re: Show fields only for certain groups

Post by a.gneady » 2013-02-07 10:55

Hi benzoD, I'm glad you like AppGini. I plan to implement field-level permissions in a future release. But for now, you'll need to do this through hooks .. I'll try to post a tutorial on that, but the idea is that you can add code into the tablename_before_edit() and tablename_before_insert() hooks to check the the current group (using getLoggedGroupID()), and if it's not the "maintenance staff" group, don't allow changing the values of the status and notes fields.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

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

Re: Show fields only for certain groups

Post by benzoD » 2013-02-07 14:32

Thanks. I found shasta59's solution after I posted this: viewtopic.php?f=8&t=291 . I haven't tried it yet but looks easy enough. I haven't gotten into the hooks yet but will study them when I have the time.

PcDok
Posts: 2
Joined: 2013-11-30 15:40

Re: Show fields only for certain groups

Post by PcDok » 2013-12-18 01:41

Allow me intro myself, Hi I'm Dave Strickland (just Dave please). I 1st used AppGini almost 7/8 years ago.
Let me say everyone at BigProf especially the Dev Teams have Not taken a break Cheers to you folks :ugeek: .

In my wish list for AppGini would be 2 upgrades to the scripting engine.

(1) an easier way to hide table fields. I have seen the code that the user (gmusgrave) showed us. Though it hides a button based on classes or groups. They go on to say that it could be used to hide fields also based on classes or groups. When creating or editing a tables fields it would be sweet. If I could just check say a radio button list that shows the groups allowed or not allowed to see the field or button either in table_view and or detail _view hide it from all except the groups you choose at compile time.

(2) Now this may just show my PHP ignorance! Mathematics functions between any field cell and another, ex. employee_hrs = Job Table to sort and compile all the hours that an employee was on any given job. Take the values (( table_jobs)) (employee_num x any job_ref_num employee is on during date_time_start and date_time_finish (auto formatted for the week) then outputted to a row per employee that are being appended as long as the employee_hrs are between the values ((date_time_start & date_time_finish (finish_date is extended until the completion field is completed )). Now pushing Appgini, create an employee row that employee_hrs x job_ref_num are shown. Other cells on this sheet would be job_type, pay_rate, bill_rate. Then this sheet can be exported to a.csv file, then the 7 day loop starts again by flushing out of the employee_hrs_table. So I guess what I am looking for is an easier way to implement easy to use mathematics

If you can code the appgini scripts with a bit more power and granularity as mentioned above and Appgini should become the standard that other Web Apps are created.

Once Again great work folks!! pcdok will be giving great reviews if ever asked (along with upgrading my membership). Thank You for your time, patience and quick tech support.

mjt1234567890
Posts: 5
Joined: 2015-05-01 20:03

Re: Show fields only for certain groups

Post by mjt1234567890 » 2015-05-01 20:05

Hi,

Did anything ever happen with this? I need to only allow certain fields to be viewed by certain groups.

Thanks

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

Re: Show fields only for certain groups

Post by a.gneady » 2015-05-03 19:22

Hmm .. I'm afraid not yet :/ It's on our to-do list though. I hope we'll be able to implement it soon.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

danielefeola
Veteran Member
Posts: 31
Joined: 2013-04-19 13:36

Re: Show fields only for certain groups

Post by danielefeola » 2015-05-05 10:37

Hi,
to hide fields for certain groups, or other if condition - with Prototype, you can enter this code inside (for example) the footer.php

<?
$memberInfo = getMemberInfo();
if($memberInfo['group']=='Admins'){
?>
<script type='text/javascript'>
document.observe("dom:loaded", function() {
$$('label[for="AAA"]').invoke('hide'); // example for hide label
$$('#AAA').invoke('hide'); // example for hide input
//
$$('label[for="BBB"]').invoke('hide'); // example for hide label
$$('#BBB-dd').invoke('hide'); // example for hide day date
$$('#BBB-mm').invoke('hide'); // example for hide month date
$$('select[name="BBBYear"]').invoke('hide'); // example for hide select year date
$$('#fd-but-BBB').invoke('hide'); // example for hide button date
//
});
</script>
<?
}
?>

uchhavi
Veteran Member
Posts: 80
Joined: 2018-05-15 14:07

Re: Show fields only for certain groups

Post by uchhavi » 2019-09-19 11:53

Hello,

I followed the below code to hide Labels and its input.

"notes" files id a RichHTML Field

Code: Select all

<?
$memberInfo = getMemberInfo();
if($memberInfo['group']=='Admins'){
?>
<script type='text/javascript'>
document.observe("dom:loaded", function() {
$$('label[for="notes"]').invoke('hide'); // hide label for notes
$$('#notes').invoke('hide'); // hide input for notes
});
</script>
<?
}
?>
I am able to hide the label, but i am not able to hide the notes field input. Please advise.
Best regards,

Chhavi Jain

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Show fields only for certain groups

Post by pbottcher » 2019-09-19 14:06

Hi,

try

Code: Select all

<?
$memberInfo = getMemberInfo();
if($memberInfo['group']=='Admins'){
?>
<script type='text/javascript'>
document.observe("dom:loaded", function() {
$j('label[for="notes"]').parent().hide();
</script>
<?
}
?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

uchhavi
Veteran Member
Posts: 80
Joined: 2018-05-15 14:07

Re: Show fields only for certain groups

Post by uchhavi » 2019-09-19 14:21

Hi.. the basic program is working... but the intention is not getting met.

Basically I want to show this field to the Admin but not to other users.
But if I am putting this code in the footer.php file, the field is not showing fro Admin too.

Please can you help
Best regards,

Chhavi Jain

uchhavi
Veteran Member
Posts: 80
Joined: 2018-05-15 14:07

Re: Show fields only for certain groups

Post by uchhavi » 2019-09-19 14:34

oh i just realised that i was writing the code in footer.php.
If I write this code in footer-extras-php then nothing is working.

Please help
Best regards,

Chhavi Jain

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Show fields only for certain groups

Post by pbottcher » 2019-09-19 15:23

Hi,

the check is

Code: Select all

if($memberInfo['group'] == 'Admins')
so if the user is in the Admins group, it will hide that.

Code: Select all

if($memberInfo['group'] !='Admins')
would hide it to all apart the users of the admin group.

And it should work in the hooks/footer-extras.php
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

uchhavi
Veteran Member
Posts: 80
Joined: 2018-05-15 14:07

Re: Show fields only for certain groups

Post by uchhavi » 2019-09-19 19:06

Hi

So i wrote the code below in the footer-extras.php file, but nothing is happening :(
<?
$memberInfo = getMemberInfo();
if($memberInfo['group'] =='Admins'){
?>
<script type='text/javascript'>
document.observe("dom:loaded", function() {
$j('label[for="notes"]').parent().hide();
</script>
<?
}
?>
I have a field html text field "notes" in the table "stock".
I need to hide it for non-Admin Users.

Please can u tell me where I am going wrong above... is there any place else i can add a code.
I only need to hide one field per table
Best regards,

Chhavi Jain

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Show fields only for certain groups

Post by pbottcher » 2019-09-19 19:15

try

Code: Select all

<?
$memberInfo = getMemberInfo();
if($memberInfo['group'] !='Admins'){
?>
<script type='text/javascript'>
document.observe("dom:loaded", function() {
$j('label[for="notes"]').parent().hide();
});
</script>
<?
}
?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

uchhavi
Veteran Member
Posts: 80
Joined: 2018-05-15 14:07

Re: Show fields only for certain groups

Post by uchhavi » 2019-09-19 20:12

Hi
The fields are hiding for Admin as well as other users too.

I need the fields to show for the Admins group.
Best regards,

Chhavi Jain

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Show fields only for certain groups

Post by pbottcher » 2019-09-20 07:32

Hi,

sorry, that happens if I just copy paste the code that was already in the post.

Use:

Code: Select all

<?php
$memberInfo = getMemberInfo();
echo $memberInfo['group'];
if($memberInfo['group'] !='Admins'){
?>
<script type='text/javascript'>
document.observe("dom:loaded", function() {
$j('label[for="notes"]').parent().hide();
});
</script>
<?php
}
?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

uchhavi
Veteran Member
Posts: 80
Joined: 2018-05-15 14:07

Re: Show fields only for certain groups

Post by uchhavi » 2019-09-20 20:09

it worked .. thank u soooo much once again.
Best regards,

Chhavi Jain

zkarwinkar
Veteran Member
Posts: 32
Joined: 2021-06-12 21:01

Re: Show fields only for certain groups

Post by zkarwinkar » 2021-06-22 19:01

in my condition i need to disable certain fields for users group in detail view , can you help me please ??

ltlow
Posts: 15
Joined: 2021-07-29 09:37

Re: Show fields only for certain groups

Post by ltlow » 2021-09-09 04:16

How can I hide the attachment field?

$j("label[for='quote_attachment']").parent().hide();

This not working for me
Attachments
Capture.PNG
Capture.PNG (12.14 KiB) Viewed 3713 times

pfrumkin
Veteran Member
Posts: 157
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Show fields only for certain groups

Post by pfrumkin » 2021-09-09 15:20

Hi,

I would try something like
$j('#Quote_attachment').parent('.form-group').hide();

Make sure the case on the field name is correct.

~Paul

Post Reply