Uname: Linux webm005.cluster107.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
User: 6036 (villadal)
Group: 100 (users)
Disabled functions: NONE
Safe mode: On[ PHPinfo ]
//home/villadal/www/old///////booked/Presenters/Calendar      ( Reset | Go to )
File Name: CalendarPresenter.php
Edit
<?php
/**
Copyright 2011-2014 Nick Korbel

This file is part of Booked Scheduler.

Booked Scheduler is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Booked Scheduler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Booked Scheduler.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once(ROOT_DIR 'lib/Config/namespace.php');
require_once(
ROOT_DIR 'lib/Common/namespace.php');
require_once(
ROOT_DIR 'Domain/Access/namespace.php');
require_once(
ROOT_DIR 'lib/Application/Schedule/namespace.php');
require_once(
ROOT_DIR 'lib/Application/Reservation/namespace.php');
require_once(
ROOT_DIR 'Presenters/Calendar/CalendarFilters.php');

class 
CalendarPresenter
{
    
/**
     * @var ICalendarPage
     */
    
private $page;

    
/**
     * @var ICalendarFactory
     */
    
private $calendarFactory;

    
/**
     * @var IReservationViewRepository
     */
    
private $reservationRepository;

    
/**
     * @var IScheduleRepository
     */
    
private $scheduleRepository;

    
/**
     * @var IResourceService
     */
    
private $resourceService;

    
/**
     * @var ICalendarSubscriptionService
     */
    
private $subscriptionService;

    
/**
     * @var IPrivacyFilter
     */
    
private $privacyFilter;

    public function 
__construct(ICalendarPage $page,
                                
ICalendarFactory $calendarFactory,
                                
IReservationViewRepository $reservationRepository,
                                
IScheduleRepository $scheduleRepository,
                                
IResourceService $resourceService,
                                
ICalendarSubscriptionService $subscriptionService,
                                
IPrivacyFilter $privacyFilter)
    {
        
$this->page $page;
        
$this->calendarFactory $calendarFactory;
        
$this->reservationRepository $reservationRepository;
        
$this->scheduleRepository $scheduleRepository;
        
$this->resourceService $resourceService;
        
$this->subscriptionService $subscriptionService;
        
$this->privacyFilter $privacyFilter;
    }

    public function 
PageLoad($userSession$timezone)
    {
        
$type $this->page->GetCalendarType();

        
$year $this->page->GetYear();
        
$month $this->page->GetMonth();
        
$day $this->page->GetDay();

        
$defaultDate Date::Now()->ToTimezone($timezone);

        if (empty(
$year))
        {
            
$year $defaultDate->Year();
        }
        if (empty(
$month))
        {
            
$month $defaultDate->Month();
        }
        if (empty(
$day))
        {
            
$day $defaultDate->Day();
        }

        
$schedules $this->scheduleRepository->GetAll();
        
$showInaccessible Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULEConfigKeys::SCHEDULE_SHOW_INACCESSIBLE_RESOURCES, new BooleanConverter());
        
$resources $this->resourceService->GetAllResources($showInaccessible$userSession);

        
$selectedScheduleId $this->page->GetScheduleId();
        
$selectedSchedule $this->GetDefaultSchedule($schedules);
        
$selectedResourceId $this->page->GetResourceId();

        if (!empty(
$selectedResourceId))
        {
            
$subscriptionDetails $this->subscriptionService->ForResource($selectedResourceId);
        }
        else
        {
            
$subscriptionDetails $this->subscriptionService->ForSchedule($selectedSchedule->GetId());
        }

        
$calendar $this->calendarFactory->Create($type$year$month$day$timezone$selectedSchedule->GetWeekdayStart());
        
$reservations $this->reservationRepository->GetReservationList($calendar->FirstDay(), $calendar->LastDay()->AddDays(1),
                                                                         
nullnull$selectedScheduleId,
                                                                         
$selectedResourceId);
        
$calendar->AddReservations(CalendarReservation::FromScheduleReservationList(
                                       
$reservations,
                                       
$resources,
                                       
$userSession,
                                       
$this->privacyFilter));
        
$this->page->BindCalendar($calendar);

        
$this->page->BindFilters(new CalendarFilters($schedules$resources$selectedScheduleId$selectedResourceId));

        
$this->page->SetDisplayDate($calendar->FirstDay());
        
$this->page->SetScheduleId($selectedScheduleId);
        
$this->page->SetResourceId($selectedResourceId);

        
$this->page->SetFirstDay($selectedSchedule->GetWeekdayStart());

        
$this->page->BindSubscription($subscriptionDetails);
    }

    
/**
     * @param array|Schedule[] $schedules
     * @return Schedule
     */
    
private function GetDefaultSchedule($schedules)
    {
        
$default null;
        
$scheduleId $this->page->GetScheduleId();

        
/** @var $schedule Schedule */
        
foreach ($schedules as $schedule)
        {
            if (!empty(
$scheduleId) && $schedule->GetId() == $scheduleId)
            {
                return 
$schedule;
            }

            if (
$schedule->GetIsDefault())
            {
                
$default $schedule;
            }
        }

        return 
$default;
    }
}

All system for education purposes only. For more tools: Telegram @jackleet

Mr.X Private Shell

Logo
-
New File | New Folder
Command
SQL