Basic message implementation
This commit is contained in:
@@ -375,4 +375,31 @@ class UserModel
|
||||
// return one row (we only have one result or nothing)
|
||||
return $query->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user role type based on account type
|
||||
*
|
||||
* @param $user_id int user id
|
||||
*
|
||||
* @return string The user role (admin, moderator, user)
|
||||
*/
|
||||
public static function getUserRole($user_id)
|
||||
{
|
||||
$database = DatabaseFactory::getFactory()->getConnection();
|
||||
|
||||
$sql = "SELECT user_account_type FROM users WHERE user_id = :user_id LIMIT 1";
|
||||
$query = $database->prepare($sql);
|
||||
$query->execute(array(':user_id' => $user_id));
|
||||
$result = $query->fetch();
|
||||
|
||||
// Map account type to role
|
||||
switch ($result->user_account_type) {
|
||||
case 7: // admin
|
||||
return 'admin';
|
||||
case 2: // moderator (example value, adjust according to your system)
|
||||
return 'moderator';
|
||||
default:
|
||||
return 'user';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user