OK, I'm just trying to improve the work with more free classes, etc. in PHP to improve your skills. I have a local test database on my computer, and for the user table, I have a column called "role". I am trying to create a function that is a general function for obtaining permissions for a user, so it does not depend on the specific task they are trying to do.
When a user tries to do something like creating a new forum section, etc., I want to query the database, and if the "role" is a certain value, save the permissions in a multidimensional array, for example:
$permissions = array(
'forums' => array("create", "delete", "edit", "lock"),
'users' => array("edit", "lock")
);
Then I want to be able to search this array for a specific permission without typing the following at the beginning of each PHP file after the user submits the form by checking isset ($ var). Therefore, if the user is trying to change the user, I want, if possible, to do something like the following using the class method
if (Class::get_permissions($userID),array($permissionType=>$permission))) {
// do query
} else {
// return error message
}
, - ? , , , . "admin", "user" .. , . , php script.
if (Class::get_permissions($userID) == "admin") {
// allow query
} else {
// return error
}
, , .