-
Notifications
You must be signed in to change notification settings - Fork 26
3.1) Hooks: Implementation
For write hooks you can use hooks/custom
folder or edit manually the examples on hooks/actions.hooks.php
or hooks/filters.hooks.php
Remember to name file like this pattern: [FILENAME].hooks.php
or it will not be included automatically (else you can include it manually)
You can use this code for have a database instance and the current user authenticated row:
$user = Auth::getUser(); // User row
$db = API::getDatabase('dataset'); // You can specify dataset. Return PDO Object
-
sql_restriction
Description: Return a string to append in where condition
Parameters: $table, $permission
Options of $permission:
case 'READ': case 'EDIT': case 'DELETE':
Return
// All denied $sql = "'1' = '0'"; // All allowed $sql = "'1' = '1'";
Examples:
// Only Created $sql = 'created_by = '.$user['id']; // Only Team $sql = 'created_by IN ('.implode(',',$teams_ids).')';
-
can_read
Description: Return if can GET/SELECT
Parameters: $restriction, $permission, $table
Return: Boolean
-
can_write
Description: Return if can POST/INSERT
Parameters: $permission, $table
Return: Boolean
-
can_edit
Description: Return if can PUT/UPDATE
Parameters: $permission, $table
Return: Boolean
-
can_delete
Description: Return if can DELETE
Parameters: $permission, $table
Return: Boolean