Single entry a registered user

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
pasbonte
Veteran Member
Posts: 53
Joined: 2013-02-06 09:49

Single entry a registered user

Post by pasbonte » 2019-02-06 10:57

Hello
How to limit to a single entry a registered user?
Thank you

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

Re: Single entry a registered user

Post by jsetzer » 2019-02-06 11:15

I'm not sure if I got your question. If you want to give a user permission to insert/edit exactly one record of a certain table only, you may consider the following alternatives:
  • Give the user's group permission to INSERT
  • Give the user's group permission to UPDATE OWN records on that table
  • After Insert: Remove the USER's (!) permission to insert into that table by modifying the membership_userpermissions table
Another idea is:
  • Deny INSERT for the user's group
  • Allow UPDATE OWN records on that table
  • after login: Check if there is a record for the logged in user already in your table (see function login_ok in hooks/_global.php).
  • If not, create a record for him (using SQL) and set the ownership in table membership_userrecords (using SQL)
  • Now the user will only see his one record and will be able to edit it due to the group's permission (UPDATE OWN).
  • He will not be able to insert a new one due to missing group-permissions.
Hope this helps.
Regards,
Jan

sjohn
Veteran Member
Posts: 84
Joined: 2018-05-23 09:32

Re: Single entry a registered user

Post by sjohn » 2019-02-06 18:50

Maybe the easiest would be, to have a field where you store the user.
This could be done by using the : Default >> Auto - username
If you then set this field a unique, then a user will only be allowed to create one entry, and if he tries to create one more, then he will see that this is not possible.

pasbonte
Veteran Member
Posts: 53
Joined: 2013-02-06 09:49

Re: Single entry a registered user

Post by pasbonte » 2019-02-07 09:20

Hello
I tried method 2 because it seemed simple but it does not work. Or I'm bad!
Attachments
07022019 appgini.JPG
07022019 appgini.JPG (66.43 KiB) Viewed 454 times

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 525
Joined: 2018-04-01 10:12

Re: Single entry a registered user

Post by pböttcher » 2019-02-07 09:42

Don't set it to read only, hide it in detailview and tableview.

pasbonte
Veteran Member
Posts: 53
Joined: 2013-02-06 09:49

Re: Single entry a registered user

Post by pasbonte » 2019-02-07 10:55

No it does not work ...
Attachments
07022019 appgini.JPG
07022019 appgini.JPG (40.46 KiB) Viewed 448 times

sjohn
Veteran Member
Posts: 84
Joined: 2018-05-23 09:32

Re: Single entry a registered user

Post by sjohn » 2019-02-07 12:39

Do you have existing data?
There could be a conflict then, with more records that has the same "empty" value - and then the unique setting.
Check in the table if the field is set as unique. Maybe it is needed you manually set a value in existing records before the field can be set as unique.

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

Re: Single entry a registered user

Post by jsetzer » 2019-02-07 14:20

@pasbonte: What is inside the ELEVE NOM field?

It looks like ...

Code: Select all

<!-- creatorUsename -->
...but sjohn has written...

Code: Select all

<%%creatorUsername%%>
You should try with <%%creatorUsername%%> as default value as sjohn has suggested. This should work.

Regards,
Jan

Post Reply