Global hook for permissions

Wish to see a specific feature/change in future releases? Feel free to post it here, and if it gets enough "likes", we'd definitely include it in future releases!
Post Reply
jlarmarange
Posts: 4
Joined: 2019-02-21 19:03

Global hook for permissions

Post by jlarmarange » 2019-06-13 09:45

Would it be a way to have a hook allowing to define custom permissions functions without overwriting files generated by AppGini? With a global hook for example.

I have a project management system and all tables are sub-tables of the main Projects table. I want to define permission per project, using a link table between Projects and Users.

Therefore, I would like to be able to write my own functions defining what a user can see and modify.

Best regards

onoehring
Veteran Member
Posts: 194
Joined: 2019-05-21 22:42
Contact:

Re: Global hook for permissions

Post by onoehring » 2019-06-16 06:57

Hi,

I would add my voice to that as well.
Olaf

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

Re: Global hook for permissions

Post by a.gneady » 2019-06-22 15:24

Hmm .. to make sure I understand what you describe, would this be for example something like this:

Code: Select all

get_custom_permissions($table, $pk, $operation, $user_info)

that the application would call before displaying a record, editing or deleting it? The application would call this function passing the table name, the primary key value of the record, the operation ('view', 'edit', 'delete') and the user info array, and then if the return value is true, the operation is allowed, else it's denied. Did I understand this correctly?
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.

:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.

:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

onoehring
Veteran Member
Posts: 194
Joined: 2019-05-21 22:42
Contact:

Re: Global hook for permissions

Post by onoehring » 2019-06-23 06:07

Hi,

yes, I guess that sounds reasonable.
Even passing PK seemed first weird to me, it is a good idea for handling the response.

Olaf

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

Re: Global hook for permissions

Post by jsetzer » 2019-06-23 06:51

Hi,

for :arrow: table view, how about using the existing TABLENAME_init()-function in TABLENAME.php? We already have the $options-variable which contains most of the required properties like ...
  • AllowInsert
  • AllowUpdate
  • AllowDelete
  • AllowMassDelete
  • AllowDeleteOfParents
  • ...
AppGini could evaluate the values after the TABLENAME_init()-call and apply the settings accordingly.


For :arrow: detail view, personally I'd prefer a hook-function inside TABLENAME.php for having all table-related stuff together in one file.

I'm wondering if we need a new hook-function or if we could use the existing TABLENAME_dv()-function, extended by a new $options-variable similar to TABLENAME_init().

Concerning "global hook" for permissions:
Great idea, Ahmed! Having the record's primary key (PK) would be perfect! :)

Additionally I suggest some kind of hierarchy:
If exists, the more detailed permission-configuration (defined in TABLENAME.php) overrules the global permission-configuration which overrules the permissions defined in admin-area.

Best,
Jan

onoehring
Veteran Member
Posts: 194
Joined: 2019-05-21 22:42
Contact:

Re: Global hook for permissions

Post by onoehring » 2019-06-23 09:05

Hi,

as I am to new to AG to know so much details as Jan does, I suppose, his suggestion to use existing infrastructure is better than creating something here, and another there.

Olaf

Post Reply