public static function login($user_id = null) { if ($user_id === null) { $user_id = template_session::get_user_id(); } if (!$user_id) { return false; } $user = users::get($user_id); if (!$user) { return false; } template_session::set_user_id($user->id); template_session::set_user_name($user->name); $setting_popup = settings::get_popup($user->id); template_session::set_use_popup($setting_popup->value); switch ($user->role_id) { case RUDE_ROLE_ADMIN: template_session::set_authorized(); template_session::set_admin(); template_session::set_editor(); template_session::set_user(); break; case RUDE_ROLE_EDITOR: template_session::set_authorized(); template_session::set_editor(); template_session::set_user(); break; case RUDE_ROLE_USER: template_session::set_authorized(); template_session::set_user(); break; } return true; }