Page 1 of 1

Approval of records

Posted: 2016-04-05 19:17
by miteshpc
I have made a standard crud application for club membership, no hooks.

I need that club members update their records on their own, but after the club administrator freezes the records, then the club members cannot update or delete those records. I can't figure out how to get that done. Any ideas will be appreciated.

Re: Approval of records

Posted: 2016-04-05 21:54
by AhmedBR
Check if user is admin and change record owner in HOOK after_update

Something like:

Code: Select all

$username=$memberInfo['username'];
if ($username = 'admin'){

sql("UPDATE membership_userrecords SET memberID='new_member' WHERE tableName='tablename' AND pkValue='{$data['selectedID']}'")

}
This way the user can edit the record as many times as he wants, but once ADMIN saves the record, owner will be changed and the user no longer can edit the record.

Also read this topic:
http://forums.appgini.com/phpbb/viewtopic.php?t=62#p115

Re: Approval of records

Posted: 2016-04-05 23:32
by AhmedBR
Bu the way in AppGini 5.5 Admin can simply change owner manually from the record itself.
This will do the trick without any programing.

Re: Approval of records

Posted: 2016-04-06 18:36
by miteshpc
This is very useful. Thank you very much. Is there a way we can filter records by owner id? If that's possible then we have a workflow almost ready in action.

Re: Approval of records

Posted: 2016-04-06 19:03
by AhmedBR
Sure, but will require some programing (a query on membership_userrecords would return current Owner)

These links will help you understand filters:
http://bigprof.com/appgini/tips-and-tut ... ult-filter
http://bigprof.com/appgini/tips-and-tut ... ers/part-1