03-09-2017, 09:50 PM
Ok. What about a different approach. What about a table called redirect_groups 2 columns.
Id, int(11), auto increment
and redirect,varchar(255)
Every time you insert a row into the db you put the path of the page you want that "group" to redirect to.
Then in your users table, you can either create a new column or use the unused account_id column.
Store the place you want that person to redirect in that column.
Then just make a function like
if that's not it for the function, it's close.
The other idea would be to make your user account levels a hierarchy. So, let's assume level 1 (user) is only for unvalidated users. 2 is admin. Then put your highest level user groups with the lowest level numbers. Then you can do a search of all the users and their permissions to find out what the highest (in this case lowest) permission level they have. So, your query would look like this.
//That just gave you the highest permission level that user has.
So now you make that same table.
Basically this deals with users having multiple permission levels.
Id, int(11), auto increment
and redirect,varchar(255)
Every time you insert a row into the db you put the path of the page you want that "group" to redirect to.
Then in your users table, you can either create a new column or use the unused account_id column.
Store the place you want that person to redirect in that column.
Then just make a function like
Code:
function redir($id){
Code:
$db = DB::getInstance();
Code:
$userQ = $db->query("SELECT account_id FROM user WHERE id = ?",array($id));
Code:
$found = $userQ->first();
Code:
$redirQ = $db->query("SELECT * FROM redirect_groups WHERE id = ?",array($found->account_id));
Code:
$redir = $redirQ->first();
Code:
Redirect::to($redir->redirect);
Code:
}
if that's not it for the function, it's close.
The other idea would be to make your user account levels a hierarchy. So, let's assume level 1 (user) is only for unvalidated users. 2 is admin. Then put your highest level user groups with the lowest level numbers. Then you can do a search of all the users and their permissions to find out what the highest (in this case lowest) permission level they have. So, your query would look like this.
Code:
$highestQ = $db->query("SELECT * FROM user_permission_matches WHERE permission_id !=1 AND user_id = ?",array($user->data()->id);
Code:
$highest = $highestQ->first();
So now you make that same table.
Code:
if($highest==2){ //admin
Code:
Redirect::to('blah');
Code:
}
Basically this deals with users having multiple permission levels.