Allow a non-admin group to change the owner of a record

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Allow a non-admin group to change the owner of a record

Post by fgazza » 2020-11-06 21:48

Hello everyone!
I would need to Allow a non-admin group to change the owner of a record

Can someone help me?

Thanks!

Fabiano

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1817
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Allow a non-admin group to change the owner of a record

Post by jsetzer » 2020-11-06 21:58

Php: set_record_owner function can be used or sql command on membership_userrecords table
Kind regards,
<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 readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
aarlauskas
Veteran Member
Posts: 127
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Allow a non-admin group to change the owner of a record

Post by aarlauskas » 2020-11-06 22:09

I have created another field in detail view (lookup) where I then added user names in there. Then you can add a code (set_record_owner) in hooks/before_update, then basically on that new field you select a name of whoever you want to assign the record to and save the record.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: Allow a non-admin group to change the owner of a record

Post by fgazza » 2020-11-07 06:33

Many thanks jsetzer and aarlauskas!
Can you help me with the code and more specific advice on how to deal with these conditions in my "booking" table
1) users belonging to the "clients" group cannot change the owner of a record so they should not see the lookup field with the list of owners but this restriction should not be managed with javascript because it could be sabotaged by an expert user
2) users belonging to the "managers" group should be able to see and modify the owner of the records.

I thought the problem could be solved by using multiple solutions at the same time:
a) create a "userlist" table with user names and authorize only the "managers" group to view the contents of that table
b) create, as suggested by aarlauskas, an "owner" lookup field in the booking table and set the "inherit access permissions" option in appgini.
c) set the privileges of the clients group to see only their own records and prevent them from updating their records (point "b" should prevent clients from seeing the list of other users and point "c" should prevent clients to try to change the user owner of the record).
d) even if it is not sure, but above all for "aesthetic" reasons, create a script that makes the "owner" field "hidden" and "readonly" to those who do not belong to the "admins" and "managers" groups.

So I ask you who are more experienced: do you think this hypothesis works?

Can you help me with the code?

The first hurdle for me is: how can I list the users in a lookup field of a new table?

Thank you very much for helping!

Fabiano

Post Reply