Beispiel #1
0
 /**
  * @static
  * @param $reservationAction string|ReservationAction
  * @param $persistenceService null|IReservationPersistenceService
  * @param UserSession $session
  * @return IReservationHandler
  */
 public static function Create($reservationAction, $persistenceService, UserSession $session)
 {
     if (!isset($persistenceService)) {
         $persistenceFactory = new ReservationPersistenceFactory();
         $persistenceService = $persistenceFactory->Create($reservationAction);
     }
     $validationFactory = new ReservationValidationFactory();
     $validationService = $validationFactory->Create($reservationAction, $session);
     $notificationFactory = new ReservationNotificationFactory();
     $notificationService = $notificationFactory->Create($reservationAction, $session);
     return new ReservationHandler($persistenceService, $validationService, $notificationService);
 }
 public function testLoadsDeleteRulesFromPlugins()
 {
     $preResPlugin = $this->getMock('IPreReservationFactory');
     $pluginManager = new FakePluginManager();
     $pluginManager->preResPlugin = $preResPlugin;
     $validationService = $this->getMock('IReservationValidationService');
     PluginManager::SetInstance($pluginManager);
     $preResPlugin->expects($this->once())->method('CreatePreDeleteService')->with($this->fakeUser)->will($this->returnValue($validationService));
     $reservationValidationFactory = new ReservationValidationFactory();
     $actual = $reservationValidationFactory->Create(ReservationAction::Delete, $this->fakeUser);
     $this->assertEquals($validationService, $actual);
 }
Beispiel #3
0
    $series->UpdateDuration($timing);
}
if ($user->Id() == $series->UserId()) {
    $series->WithOwner($user->Id());
}
$title = $series->Title();
if ($params['summary']) {
    $title = $params['summary'];
}
$description = $series->Description();
if ($params['description']) {
    $description = $params['description'];
}
$series->Update($user->Id(), $resource, $title, $description, $user_session);
$vfactory = new ReservationValidationFactory();
$validationService = $vfactory->Create($updateAction, $user_session);
$nfactory = new ReservationNotificationFactory();
$notificationService = $nfactory->Create($updateAction, $user_session);
$validationResult = $validationService->Validate($series);
$result = $validationResult->CanBeSaved();
if ($result) {
    try {
        $persistenceService->Persist($series);
        header('HTTP/1.1 200 Ok', true, 200);
        $rn = $series->CurrentInstance()->ReferenceNumber();
        $response = array('series_id' => $series->SeriesId(), 'title' => $title, 'description' => $description, 'reference_number' => $rn);
        //print json_encode($response,JSON_UNESCAPED_SLASHES);  ## only in Php 5.4
        print json_encode($response);
        return;
    } catch (Exception $ex) {
        Log::Error('Error updating reservation: %s', $ex);
Beispiel #4
0
    print json_encode(array('message' => "contact_info or rid has to be set"));
    return;
}
/*************************************************
 	date
 *************************************************/
$timing = DateRange::Create($starts_at, $ends_at, $tz);
/*************************************************
 	Action
 *************************************************/
$series = ReservationSeries::Create($user->Id(), $resource, $title, $description, $timing, new RepeatNone(), $user_session);
$reservationAction = ReservationAction::Create;
$pfactory = new ReservationPersistenceFactory();
$persistenceService = $pfactory->Create($reservationAction);
$vfactory = new ReservationValidationFactory();
$validationService = $vfactory->Create($reservationAction, $user_session);
$nfactory = new ReservationNotificationFactory();
$notificationService = $nfactory->Create($reservationAction, $user_session);
#	$handler = new ReservationHandler($persistenceService, $validationService, $notificationService);
$validationResult = $validationService->Validate($series);
$result = $validationResult->CanBeSaved();
if ($result) {
    try {
        $persistenceResult = $persistenceService->Persist($series);
        header('HTTP/1.1 200 Ok', true, 200);
        $response = array('series_id' => $series->SeriesId(), 'reference_number' => $series->CurrentInstance()->ReferenceNumber(), 'requires_approval' => $resource->GetRequiresApproval());
        print json_encode($response);
        return;
    } catch (Exception $ex) {
        //Log::Error('Error saving reservation: %s', $ex);
        header('HTTP/1.1 403 Forbidden', true, 403);