Field Permissions (hide / lock fields by usergroup)

Got something cool to share with AppGini users? Feel free to post it here!
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-08-11 13:05

Hi,

well, I have not heard of ckebell yet.
Do you, Ionut, have the same problem? If so, please provide details (description and screenshots - if the might help), I will try to help.

Make sure you
  • using the latest version of my AG
  • using the latest version of my extension
  • did all changes as documented
  • uploaded all files correctly
  • no other errors are shown in the browser console
  • no other errors are thrown by php
  • please also make sure, it's not working on your target site (the problem(s) might occur on localhost only)
Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-08-12 08:59

Hi,

I had a question like this:
i want to build a system that, would require some fields to be locked only for existing records.
When it is required to add a new record i would want to be unlocked the fields.
Actually it should work as permissions (if you followed the docs) are checked in the _before_update functions (Step 2.3a and 2.3b) only, but not in the _before_insert function.

Olaf

hubert
Veteran Member
Posts: 33
Joined: 2018-12-06 22:32

Re: Field Permissions (hide / lock fields by usergroup)

Post by hubert » 2021-02-21 19:52

Hi all, hi Olaf,

Havve verion 1.21 and AppGini Helper at 2020/10/26

After a few tries and misses (seems I did not understand or didn't strictly follow the last version PdF) I finally had the lists in both lookup

But ... another issue appeared after I was able to define locked/hidden fields.
When showing the concerned table (combattants) ... had this mistake ..

Fatal error: Uncaught Error: Call to undefined function check_field_permission() in /homepages/46/d459227834/htdocs/combattants2022/hooks/field_permission_table_init.php:42 Stack trace: #0 /homepages/46/d459227834/htdocs/combattants2022/hooks/combattants.php(6): include() #1 /homepages/46/d459227834/htdocs/combattants2022/combattants_view.php(347): combattants_init(Object(DataList), Array, Array) #2 {main} thrown in /homepages/46/d459227834/htdocs/combattants2022/hooks/field_permission_table_init.php on line 42

After some tests & checks, I finally found that I had to add a check in field_permission_base.php
I added this just after session variables
//START Field-Permissions
if (!function_exists('check_field_permission')) {
include("hooks/field_permission_functions.php");
}

No more issue, seems to work on a good way and is quite easy to use !

Another detail, we can see on the screen cap in the doc that in the view_membership_group table, groupID is required.
This is not mentionned in the creation procedure of that table, any importance ?

Thx Olaf !

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2021-02-22 09:26

Hi Hubert,

it seems to work for you now. That's good to hear.

I am not sure what you mean by you needed to add in include. Maybe I have updated this in my local version already, but in field_permission_base.php there is an include, just like the one you mentioned ... or did you mean something else?
f_base.png
f_base.png (14.46 KiB) Viewed 968 times
In the docs it's point 3 (3.1 to 3.4) where the VIEW needs to be created. I would think in 3.4 it says, that groupIP for the table db_field_permission.

Anyways, you go it working and that's good :-)

Olaf

hubert
Veteran Member
Posts: 33
Joined: 2018-12-06 22:32

Re: Field Permissions (hide / lock fields by usergroup)

Post by hubert » 2021-02-22 11:06

Sorry Olaf, I made a mistake on the file name after having looked everywhere for a change to do.
And I copied the check which you have in file_permission_base.php ...

I had to add this check in the file field_permission_table_init.php otherwise I experienced a crash with the message I sent.

And in this file, this check is not natively written (have version 1.2 at 2020/03/16)
Everythings working with this add.

An other question as you're there ...
Can we make this hide also operative for printing or should I follow the print invoice AppGini course example on Udemy ?

Thx for answering
Take care !

Hubert

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2021-02-22 13:10

Hi Hubert,

thank you for explaining and pointing this ...field_permission_table_init.php... out. I added it to the file now and will post an update soon.
Can we make this hide also operative for printing or should I follow the print invoice AppGini course example on Udemy ?
Well, what happens, when you print something that is hidden or locked? I would think it should/expect print the block characters (if hidden). When it's only locked the print should work as expected (as no one can use a paper output to change data ;-) )

Olaf

hubert
Veteran Member
Posts: 33
Joined: 2018-12-06 22:32

Re: Field Permissions (hide / lock fields by usergroup)

Post by hubert » 2021-02-22 19:47

onoehring wrote:
2021-02-22 13:10
thank you for explaining and pointing this ...field_permission_table_init.php... out. I added it to the file now and will post an update soon.
Great, may be will help some ...
Well, what happens, when you print something that is hidden or locked? I would think it should/expect print the block characters (if hidden). When it's only locked the print should work as expected (as no one can use a paper output to change data ;-) )
Well, either for hidden or blocked fields ... nothing occurs, meaning I can see them with the printing button on DV and ..
print them without any block character ...
Hidding or blocking seem to have no effect on printing.
I'm not expert enough to check in your code if .. or what ...
But could be useful may be to have a printing or not option...
I know, always looking for details ... sorry !

Thx for help !

Huibert

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2021-02-23 06:41

Hi Hubert,

no, perfect, that you are looking for detail. I did not notice that yet ... and noone else reported it.
I will check into that.

Olaf

hubert
Veteran Member
Posts: 33
Joined: 2018-12-06 22:32

Re: Field Permissions (hide / lock fields by usergroup)

Post by hubert » 2021-02-23 07:03

:P :P

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2021-02-23 09:16

Hi Hubert,

did you see in the docs, that I did mention there, that the "hidden" text is available in from the detailview?
I have to investigate if hiding text in detail (and print) is possible (viewtopic.php?f=2&t=4208).

Olaf

hubert
Veteran Member
Posts: 33
Joined: 2018-12-06 22:32

Re: Field Permissions (hide / lock fields by usergroup)

Post by hubert » 2021-02-23 20:42

onoehring wrote:
2021-02-23 09:16
did you see in the docs, that I did mention there, that the "hidden" text is available in from the detailview?
I have to investigate if hiding text in detail (and print) is possible (viewtopic.php?f=2&t=4208).
Sorry Olaf, I must admit I carefully read your doc for installing and possible issues but I had a very quick view after ... as I look for a result and only after - according to it - I'll go for further research or readings ...
As I discover either ApGini Helper and your tweaks, I'm too young there to have any idea on this new post ..

On TV, not all hidden fields have the same behaviour ...
Ones which are marked "hide in TV" in AppGini project don't show, ok.
For the ones which don't have this "hide in TV" checked but are hidden by yous code, they show on TV but with soecial characters noon can read ...
>Seems ok.
I could not check CSV export for nom

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2021-02-24 09:29

Hi,

I agree totally, that it would be much better, if data is completely inaccessible in DV if it's set to HIDDEN.
So your hint is valid and valuable.

I tried TV: In print the HIDDEN field was displayed with blocks, so it was in CSV output.

Olaf

hubert
Veteran Member
Posts: 33
Joined: 2018-12-06 22:32

Re: Field Permissions (hide / lock fields by usergroup)

Post by hubert » 2021-03-01 11:35

Last news !

I only realized after a while that, after installing modifying the hooks/tablename.php field permissions, I had a trouble for updating records.
In fact, I could read but no more write on the table, which is quite annoying.

Made so much mods everywhere that I spent some hours to locate the issue.
I just know it's in that file, didn't have time to look in the code why/what/where as I just fired all mods linked to ...

Other thing ..

I made a condition to color the background of a line in TV in different colors according to condition..
(using viewtopic.php?f=7&t=1322 )

When I set your script, colours disappear in the table view ... no idea for now ..

Don't know if these issues is just mine or if anyone encountered them ...

Hubert

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2021-03-01 11:59

Hi Hubert,

without looking at the code you linked to, it the Field Permissions script should not be the reason - except some JS problems occur? (Check the F12 -> Console for errors).

I am using something similar to color rows in TV depending on a value in some column. Please check the links I give in this forum post: viewtopic.php?f=8&t=577#p11441

Olaf

hubert
Veteran Member
Posts: 33
Joined: 2018-12-06 22:32

Re: Field Permissions (hide / lock fields by usergroup)

Post by hubert » 2021-03-11 16:24

Sorry Olaf, really not time to investigate.
HAve more dev' waiting and some issues on the cook.
For now, it's working, when finished my rush may be I'll come back on it.

G Scott
Posts: 11
Joined: 2018-02-25 00:02

Re: Field Permissions (hide / lock fields by usergroup)

Post by G Scott » 2021-04-09 19:57

Hi Olaf,

I'm having the same problem that Hubert describes.
I've also included this at the beginning of the field_permission_table_init.php:

Code: Select all

//START Field-Permissions
if (!function_exists('check_field_permission')) {
include("hooks/field_permission_functions.php");
}
That got rid of the 500 error as the script can now see the check_field_permission() function. However, I can no longer make changes to the records.
I get the message "Couldn't save changes to the record".

I'm using AppGini v5.95 and AppGini Helper JavaScript Library Version 2020.10.26.1

Do you have any idea what could be causing this?

Thanks,

G Scott

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 949
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2021-04-10 08:05

Hi,

searching the FieldPermissions code, I can not find the error message you provided. This makes me think, it's not an error from FieldPermission.
From your description I find it impossible to trace back the possible error source.

Olaf

Post Reply