Basic message implementation

This commit is contained in:
2025-12-15 11:08:23 +01:00
parent 2b6d4c49f5
commit aa9b3359b1
10 changed files with 783 additions and 1 deletions

View File

@@ -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';
}
}
}