Before any of the crud events happens, I want to check if the current user has access to do so.
Is there a way to do this?
I used general language to show what i’m thinking. is it possible to:
$e[“on_insert”] = array(“add_client”, null, true);
$e[“on_delete”] = array(“del_client”, null, true);
$g->set_events($e);
function add_client($data)
{
global $g;
// CHECK IF CURRENT USER HAS ACCESS
// IF NO, SHOW ERROR else CONTINUE DEFAULT INSERT
}
function del_client($data)
{
global $g;
// CHECK IF CURRENT USER HAS ACCESS
// IF NO, SHOW ERROR else CONTINUE DEFAULT DELETE
}
thanks.
1 Answers
Yes, that’s the correct way to do it.
Also refer demos/editing/server-validation.php for help.
Your Answer