Hide field depending user group
Hide field depending user group
Hi,
I'm trying to hide a checked field if the user isn't in the "adminstrador" group
I tried with this code but the detail view shows me blank
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an administrador group?
if($mi['group'] != 'administrador'){
$html .= <<<eoc <script="">
\$j(function() { $j('#checado').hide();
})
</script>
EOC;
}
}
</eoc>
Regards
Esteban Ceniceros
Mexico City
I'm trying to hide a checked field if the user isn't in the "adminstrador" group
I tried with this code but the detail view shows me blank
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an administrador group?
if($mi['group'] != 'administrador'){
$html .= <<<eoc <script="">
\$j(function() { $j('#checado').hide();
})
</script>
EOC;
}
}
</eoc>
Regards
Esteban Ceniceros
Mexico City
Re: Hide field depending user group
Do eoc and EOC match in your code? In your forum post they don't.
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: Hide field depending user group
Thanks
I copied exacttly the sample code from the suport page from AppGini
Regards
I copied exacttly the sample code from the suport page from AppGini
Regards
Re: Hide field depending user group
Hi,
try this:
In the funtction you need to access the $memberInfo, not the $mi, also the EOC marks is case sensitiv, so the must be eqal and no space or any other information after the starting on and the ending one must be at the beginning of the line.
Make sure that you check against the correct group. In your case "administrador".
try this:
Code: Select all
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an administrador group?
if($memberInfo['group'] != 'administrador'){
$html.=<<<EOC
<script>
\$j(function() { \$j('#checado').hide(); })
</script>
EOC;
}
}
Make sure that you check against the correct group. In your case "administrador".
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.
Re: Hide field depending user group
Thanks pböttcher
Now the page is displaying but the function $j('#checado').hide(); is not working
Regardless of whether the user belongs to the 'administrador' group or not, the checkbox always appears
Regards
Now the page is displaying but the function $j('#checado').hide(); is not working
Regardless of whether the user belongs to the 'administrador' group or not, the checkbox always appears
Regards
Re: Hide field depending user group
I tried this from the console and always get the value "1", checked or not
j('#checado').val();
This is the code for the checkbox
<input type="checkbox" name="checado" id="checado" value="1">
Regards
j('#checado').val();
This is the code for the checkbox
<input type="checkbox" name="checado" id="checado" value="1">
Regards
Re: Hide field depending user group
If I run from the console this comand
$j('label[for="checado"]').hide();
The checkbox and the label these disappear
and with this command
$j('label[for="checado"]').sown();
both appear
But if I include the code at the Pagos.php this dont works
Regards
$j('label[for="checado"]').hide();
The checkbox and the label these disappear
and with this command
$j('label[for="checado"]').sown();
both appear
But if I include the code at the Pagos.php this dont works
Regards
Re: Hide field depending user group
Hi,
can you post what you have in your hook file
can you post what you have in your hook file
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.
Re: Hide field depending user group
Thanks,
This is the code
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an administrador group?
if($memberInfo['group'] != 'administrador'){
$html.=<<<EOC
<script>
\$j(function() { \$j('label[for="checado"]').hide(); })
</script>
EOC;
}
}
This is the code
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an administrador group?
if($memberInfo['group'] != 'administrador'){
$html.=<<<EOC
<script>
\$j(function() { \$j('label[for="checado"]').hide(); })
</script>
EOC;
}
}
Re: Hide field depending user group
Hi,
I tried it on my testsystem and it works.
Can you please post the code exaclty as you have it in your hook file (with all spaces, tabs, etc.).
And did you check of a user that is not in the administrador group (sorry to ask so stupid...).
Also you could test for the user that is in the administrador group by setting
if($memberInfo['group'] == 'administrador')
I tried it on my testsystem and it works.
Can you please post the code exaclty as you have it in your hook file (with all spaces, tabs, etc.).
And did you check of a user that is not in the administrador group (sorry to ask so stupid...).
Also you could test for the user that is in the administrador group by setting
if($memberInfo['group'] == 'administrador')
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.
Re: Hide field depending user group
Thanks,
I copied the code exactly from the file
I checked about the user group but in both cases with a user from the administrator group ornot the field it is not hiding
Today I will make another tests and but really I can understand what's happen
Thanks for your support and help
I copied the code exactly from the file
I checked about the user group but in both cases with a user from the administrator group ornot the field it is not hiding
Today I will make another tests and but really I can understand what's happen
Thanks for your support and help
Re: Hide field depending user group
Now I ran again the funcion
$j('label[for="Checado"]').hide();
An I got this message
n.fn.init [label, prevObject: n.fn.init(1), context: document, selector: "label[for="Checado"]"]
0: label
context: document
length: 1
prevObject: n.fn.init [document, context: document]
selector: "label[for="Checado"]"
__proto__: Object(0)
$j('label[for="Checado"]').hide();
An I got this message
n.fn.init [label, prevObject: n.fn.init(1), context: document, selector: "label[for="Checado"]"]
0: label
context: document
length: 1
prevObject: n.fn.init [document, context: document]
selector: "label[for="Checado"]"
__proto__: Object(0)
Re: Hide field depending user group
Sorry
it isn't a error is working the function from de console, but not from the php file
it isn't a error is working the function from de console, but not from the php file
- landinialejandro
- AppGini Super Hero
- Posts: 126
- Joined: 2016-03-06 00:59
- Location: Argentina
- Contact:
Re: Hide field depending user group
hi, try in the browser console to write your code:
and see in your page if it is hide, if dont work you have a problem in the selector.
Code: Select all
$j('label[for="Checado"]').hide();
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.
Some of my posts that may interest you:
Landini Admin Template: Template for Appgini like AdminLTE
Profile image plugin: add and changue image user profile
Field editor in table view: Configurable fast edit fields in TV
my personal page
AppGini 5.98 - Linux OpenSuse Tumblewweed.
Some of my posts that may interest you:
Landini Admin Template: Template for Appgini like AdminLTE
Profile image plugin: add and changue image user profile
Field editor in table view: Configurable fast edit fields in TV
my personal page
Re: Hide field depending user group
I thing the If isn't working!!!
- landinialejandro
- AppGini Super Hero
- Posts: 126
- Joined: 2016-03-06 00:59
- Location: Argentina
- Contact:
Re: Hide field depending user group
i need to see the code in html from the browser, you can post the screenshot please?
make right click over the checkbox and the click in inpsecto option.
make right click over the checkbox and the click in inpsecto option.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.
Some of my posts that may interest you:
Landini Admin Template: Template for Appgini like AdminLTE
Profile image plugin: add and changue image user profile
Field editor in table view: Configurable fast edit fields in TV
my personal page
AppGini 5.98 - Linux OpenSuse Tumblewweed.
Some of my posts that may interest you:
Landini Admin Template: Template for Appgini like AdminLTE
Profile image plugin: add and changue image user profile
Field editor in table view: Configurable fast edit fields in TV
my personal page
Re: Hide field depending user group
Hi,
this is the code: (I changed some names doing tests, and I tried disable the checkbox)
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an Adminis group?
$mi=$memberInfo['group'];
if($memberInfo['group'] != 'Admins'){
$html.=<<<EOC
<script>
\$j(function() { \Checado.disabled = true)
</script>
EOC;
}
}
And think the if is not working, I made some test directly from the console and hide o diabled working well
this is the code: (I changed some names doing tests, and I tried disable the checkbox)
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
/* current user is not an Adminis group?
$mi=$memberInfo['group'];
if($memberInfo['group'] != 'Admins'){
$html.=<<<EOC
<script>
\$j(function() { \Checado.disabled = true)
</script>
EOC;
}
}
And think the if is not working, I made some test directly from the console and hide o diabled working well
- Attachments
-
- checkbox.jpg (97.31 KiB) Viewed 15011 times
Re: Hide field depending user group
Thanks to Alejandro Landini
Now is working
The code is:
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
// current user is not an Adminis group?
$mi=$memberInfo['group'];
if ($memberInfo['group'] != 'Admins'){
$html.="<script>\$j('#Checado').attr('disabled', true);</script>";
}
}
Best regards
Now is working
The code is:
function Pagos_dv($selectedID, $memberInfo, &$html, &$args){
// current user is not an Adminis group?
$mi=$memberInfo['group'];
if ($memberInfo['group'] != 'Admins'){
$html.="<script>\$j('#Checado').attr('disabled', true);</script>";
}
}
Best regards
Re: Hide field depending user group
Hi cesteban,
I think the field will be hidden from view only. The "interested" user could still use some tool (chrome developer console) to activate the checkbox.
Maybe it's worth keeping in mind, that user input should not be trusted.
I would think it would be much better, if the field would actually not be generated at all and that there should be some serverside checking done be AppGini to make sure that something the user does not see, can not be changed by that user either.
Olaf
I think the field will be hidden from view only. The "interested" user could still use some tool (chrome developer console) to activate the checkbox.
Maybe it's worth keeping in mind, that user input should not be trusted.
I would think it would be much better, if the field would actually not be generated at all and that there should be some serverside checking done be AppGini to make sure that something the user does not see, can not be changed by that user either.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Hide field depending user group
how are you people;
been following the hide fields and I have manage to add some ideas for hiding date values for example you do not want users to input date.
function table_dv($selectedID, $memberInfo, &$html, &$args) {
$mi=$memberInfo['group'];
if ($memberInfo['group'] != 'Admins'){
$html.="<script>\$j('#status').attr('disabled', true);</script>";
$html.="<script>\$j('#date-dd').attr('disabled', true);</script>";
$html.="<script>\$j('#date-mm').attr('disabled', true);</script>";
$html.="<script>\$j('#date').attr('disabled', true);</script>";
}
been following the hide fields and I have manage to add some ideas for hiding date values for example you do not want users to input date.
function table_dv($selectedID, $memberInfo, &$html, &$args) {
$mi=$memberInfo['group'];
if ($memberInfo['group'] != 'Admins'){
$html.="<script>\$j('#status').attr('disabled', true);</script>";
$html.="<script>\$j('#date-dd').attr('disabled', true);</script>";
$html.="<script>\$j('#date-mm').attr('disabled', true);</script>";
$html.="<script>\$j('#date').attr('disabled', true);</script>";
}
Re: Hide field depending user group
Hi,
did you see my Field Permissions ( viewtopic.php?f=4&t=3308 )? I admit, implementing takes some minutes, but the result is quite good I think.
Olaf
did you see my Field Permissions ( viewtopic.php?f=4&t=3308 )? I admit, implementing takes some minutes, but the result is quite good I think.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view