Freeze the record so no one can modify that record

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
azharhussain
Posts: 6
Joined: 2013-01-22 06:40

Freeze the record so no one can modify that record

Post by azharhussain » 2013-01-22 06:46

How i can freeze the record so no one can modify that record after changing some status in the record, for example customer created a record (using new button), the default status (of a field) is "Open". Now he worked on it and change the status (of a field) to "Applied" and save it. Now I want make this record to be freeze (after change the status from Open to Applied), so no one can edit it anymore. Any idea how to do it?

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

Re: Freeze the record so no one can modify that record

Post by a.gneady » 2013-01-23 10:02

You could use the before_update hook to perform this ... the idea is to use the record ID provided in the $data['selectedID'] variable to retrieve the stored status value (don't use $data['status'] since the user can change this ... use the actual status value stored in the record) ... you can then return false if the status is "Applied" (returning false from the before_update hook prevents the update from taking place).
: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.

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Re: Freeze the record so no one can modify that record

Post by shasta59 » 2013-01-24 01:58

I already use a variation of Ahmad's method but I also return a line that advises the user it cannot be updated.

I am currently working on a hook to display a message, based upon a value, telling everyone when they select the record it cannot be modified anymore. This way they will not try to modify it and waste their time.

I do put in code so only those who are in one of the allowed groups can modify it.

Actually I am just working on changing it from group based permission in this case to using another table to pull a value from checking to see if that individual member can modify it. This is a table similar to what I talk about here.

http://forums.appgini.com/phpbb/viewtopic.php?f=7&t=58

The advantage, IMHO, is with another table present it is used as a lookup and an admin does not need to be involved. Anyone who has permission to see this table can add members who can modify it. The biggest advantage is modify access is controlled by who is in the table not by who is in a group.

It is actually less work this way as the admin/designer/programmer does not get involved at all. It allows the easy creation of turnkey systems so to speak. Consider the additional tables to be behind the scene administrator controls.

If you have any questions just ask.
Calgary, Alberta, Canada - Using Appgini 5.50 -

bambinou
Veteran Member
Posts: 163
Joined: 2013-02-01 15:09

Re: Freeze the record so no one can modify that record

Post by bambinou » 2013-02-02 21:26

Thanks for the explanation, so if I wanted to create a table where the staff had some sort of points given by the management on a monthly basis, could the above method be applied? I do not want the staff to change their points value but only their personal details, phone number, address....

Thank you,

Ben

bambinou
Veteran Member
Posts: 163
Joined: 2013-02-01 15:09

Re: Freeze the record so no one can modify that record

Post by bambinou » 2013-02-03 22:45

Hi Ahmad,

Do you have an example in your website about the before_update hook please?
I am having the same problem, I need to freeze certain details so the user cannot change them, only the admin.

Thank you,

Ben

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

Re: Freeze the record so no one can modify that record

Post by a.gneady » 2013-02-07 11:12

bambinou wrote:Hi Ahmad,

Do you have an example in your website about the before_update hook please?
I am having the same problem, I need to freeze certain details so the user cannot change them, only the admin.
Unfortunately there is no example code published currently for this, but I plan to prepare a post on this 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.

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Freeze the record so no one can modify that record

Post by AhmedBR » 2013-10-17 22:40

I know you are busy with the new release, but would also appreciate it, if you can post this example.
Take your time no rush.

Take care,
Ahmed
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Freeze the record so no one can modify that record

Post by AhmedBR » 2013-10-18 23:52

For the time being I did it like this:
I have a master details, I ask the user to choose a YES when he finishes the last detail, this would trigger a change of ownership on the master table.
That is it, table is now locked and the save button disappears for him.
The user HAS to choose yes in order to process the item, this way there is no escape.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Freeze the record so no one can modify that record

Post by espo » 2014-01-29 08:28

Hi AhmedBR,

I need to better understand the procedure you used to lock the fields.
Is a long time I'm looking for a solution to this, and this could be a very good way.

Thank you very much for your help.

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Freeze the record so no one can modify that record

Post by AhmedBR » 2014-02-07 20:41

All you need to do is to update membership_userrecords and change the usarname from the user to another user.
And make sure the user can only edit his own records.
That is it.
This user can no longer edit the record because it is not his anymore = the records is LOCKED for him.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Freeze the record so no one can modify that record

Post by espo » 2014-05-16 13:31

Hi Ahmed,

can you insert an example with code... i'm a novice and i don't understand where i must change the information for change the owner.

Thank you very much for your patience.

Post Reply