Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/EmirPolito/CRUD-HOTEL-GUEVARINI-Publico/llms.txt

Use this file to discover all available pages before exploring further.

Hotel Guevarini has two user roles defined in the roles database table. Each role controls which sections of the panel are visible and which actions a user can perform.
id_rolRole Name
1Administrator
2Client

Permissions Matrix

FeatureAdministratorClient
Dashboard
View Rooms
Manage Rooms
View Reservations
Create/Edit Reservations
View Clients
Manage Clients
Manage Users

How Roles Are Checked in PHP

After a user logs in, their role ID is stored in the session as $_SESSION['usuario_rol_id']. PHP views read this value to decide what to show. In views/panel.php, the role check looks like this:
$rol_id = $_SESSION['usuario_rol_id']; // 1 = Administrator, 2 = Client

// The "Usuarios" nav link is only rendered for administrators
if ($rol_id == 1): ?>
    <a href="usuarios/usuarios.php">Usuarios</a>
<?php endif; ?>

// Panel cards also adapt based on role
if ($rol_id == 1): ?>
    <a href="clientes/clientes.php" class="card card-admin">
        <h3>Clientes</h3>
        ...
    </a>
<?php endif; ?>
Any value other than 1 is treated as a Client. This pattern is applied consistently across views to hide administrative sections from Client users.
The Users navigation link in the top navbar only appears for Administrators ($rol_id == 1). Clients have no route to the user management section from the UI.

Role Assignment

Roles are assigned at the time a user account is created:
  • Public self-registration (php/auth/procesar_registro.php) always assigns role 2 (Client). This is hardcoded and cannot be changed by the registering user:
    $rol = 2; // Cliente de forma predeterminada para registros públicos
    
  • Admin-created users (php/usuarios/guardar_usuario.php) allow the administrator to select any role from a dropdown when filling out the creation form:
    $rol = intval($_POST['id_rol']);
    

How to Change a User’s Role

Only an Administrator can change a user’s role after the account has been created.
1

Navigate to User Management

From the panel, click the Usuarios link in the top navigation bar. This link is only visible to Administrators.
2

Find the user

Locate the user whose role you want to change in the users list.
3

Open the edit form

Click the edit action for that user to open the edit form.
4

Change the role

Use the role dropdown to select the new role — either Administrador or Cliente.
5

Save

Submit the form. The change takes effect immediately; the user will see the updated permissions on their next login.

Build docs developers (and LLMs) love