Custom Hook

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
utony
Veteran Member
Posts: 144
Joined: 2020-04-03 18:37

Custom Hook

Post by utony » 2020-11-10 02:28

Anyone know how to write a custom hook to turn off add, edit and delete rights for a group at a certain time? I want to allow a group to add, edit, and delete a record up to certain time and then I want the table to go to a read only mode for the users in a group.

Any help would be great!

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

Re: Custom Hook

Post by onoehring » 2020-11-13 07:23

Hi,

you should be able to use the options->.... in the ..._init function of /hooks/tablename
Let's say your groups (that have the permissions to add, update, delete) are GROUP_1_THAT_HAS_PERMISSIONS and GROUP_2_THAT_HAS_PERMISSIONS (code not tested):

Code: Select all

	if (in_array($memberInfo['group'], array('GROUP_1_THAT_HAS_PERMISSIONS','GROUP_2_THAT_HAS_PERMISSIONS'))) {
		$options->AllowDelete= 1;
		$options->AllowInsert= 1;
		$options->AllowUpdate= 1;
	} else {
		$options->AllowDelete= 0;
		$options->AllowInsert= 0;
		$options->AllowUpdate= 0;
        }
also see https://bigprof.com/appgini/help/workin ... s/DataList

Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Custom Hook

Post by pbottcher » 2020-11-13 15:41

To add to this,

As you did not specify how you define
up to certain time ...


Code: Select all

if (YOUR_TIME_CHECK == true ) {
	if (in_array($memberInfo['group'], array('GROUP_1_THAT_HAS_PERMISSIONS','GROUP_2_THAT_HAS_PERMISSIONS'))) {
		$options->AllowDelete= 1;
		$options->AllowInsert= 1;
		$options->AllowUpdate= 1;
	} else {
		$options->AllowDelete= 0;
		$options->AllowInsert= 0;
		$options->AllowUpdate= 0;
        }
}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply