public function ProcessPageLoad()
 {
     $this->presenter->PageLoad();
     $this->Set('priorities', range(1, 10));
     $this->Set('timezone', ServiceLocator::GetServer()->GetUserSession()->Timezone);
     $this->Display('Admin/manage_announcements.tpl');
 }
 public function PageLoad()
 {
     $this->Set('DefaultTitle', Resources::GetInstance()->GetString('NoTitleLabel'));
     $this->presenter->SetSearchCriteria(ServiceLocator::GetServer()->GetUserSession()->UserId, ReservationUserLevel::ALL);
     $this->presenter->PageLoad();
     $this->Display('upcoming_reservations.tpl');
 }
Exemple #3
0
 public function __construct($user = null)
 {
     $this->user = $user;
     if ($this->user == null) {
         $this->user = ServiceLocator::GetServer()->GetUserSession();
     }
 }
 public function __construct()
 {
     parent::__construct();
     $userRepository = new UserRepository();
     $this->presenter = new ManageReservationsPresenter($this, new ScheduleAdminManageReservationsService(new ReservationViewRepository(), $userRepository, new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization())), new ScheduleAdminScheduleRepository($userRepository, ServiceLocator::GetServer()->GetUserSession()), new ResourceAdminResourceRepository($userRepository, ServiceLocator::GetServer()->GetUserSession()), new AttributeService(new AttributeRepository()), new UserPreferenceRepository());
     $this->SetPageId('manage-reservations-schedule-admin');
 }
 public function __construct()
 {
     parent::__construct();
     $userRepository = new UserRepository();
     $user = ServiceLocator::GetServer()->GetUserSession();
     $this->_presenter = new ManageSchedulesPresenter($this, new ScheduleAdminManageScheduleService(new ScheduleAdminScheduleRepository($userRepository, $user), new ScheduleRepository(), new ResourceAdminResourceRepository($userRepository, $user)), new GroupRepository());
 }
 public function PageLoad()
 {
     ob_clean();
     $this->presenter->PageLoad();
     $config = Configuration::Instance();
     $feed = new FeedWriter(ATOM);
     $title = $config->GetKey(ConfigKeys::APP_TITLE);
     $feed->setTitle("{$title} Reservations");
     $url = $config->GetScriptUrl();
     $feed->setLink($url);
     $feed->setChannelElement('updated', date(DATE_ATOM, time()));
     $feed->setChannelElement('author', array('name' => $title));
     foreach ($this->reservations as $reservation) {
         /** @var FeedItem $item */
         $item = $feed->createNewItem();
         $item->setTitle($reservation->Summary);
         $item->setLink($reservation->ReservationUrl);
         $item->setDate($reservation->DateCreated->Timestamp());
         $item->setDescription($this->FormatReservationDescription($reservation, ServiceLocator::GetServer()->GetUserSession()));
         //			sprintf('<div><span>Start</span> %s</div>
         //										  <div><span>End</span> %s</div>
         //										  <div><span>Organizer</span> %s</div>
         //										  <div><span>Description</span> %s</div>',
         //										  $reservation->DateStart->ToString(),
         //										  $reservation->DateEnd->ToString(),
         //										  $reservation->Organizer,
         //										  $reservation->Description));
         $feed->addItem($item);
     }
     $feed->genarateFeed();
 }
Exemple #7
0
 protected function __construct($titleKey = '', $pageDepth = 0)
 {
     $this->SetSecurityHeaders();
     $this->path = str_repeat('../', $pageDepth);
     $this->server = ServiceLocator::GetServer();
     $resources = Resources::GetInstance();
     ExceptionHandler::SetExceptionHandler(new WebExceptionHandler(array($this, 'RedirectToError')));
     $this->smarty = new SmartyPage($resources, $this->path);
     $userSession = ServiceLocator::GetServer()->GetUserSession();
     $this->smarty->assign('Charset', $resources->Charset);
     $this->smarty->assign('CurrentLanguage', $resources->CurrentLanguage);
     $this->smarty->assign('HtmlLang', $resources->HtmlLang);
     $this->smarty->assign('HtmlTextDirection', $resources->TextDirection);
     $appTitle = Configuration::Instance()->GetKey(ConfigKeys::APP_TITLE);
     $pageTile = $resources->GetString($titleKey);
     $this->smarty->assign('Title', (empty($appTitle) ? 'Booked' : $appTitle) . (empty($pageTile) ? '' : ' - ' . $pageTile));
     $this->smarty->assign('CalendarJSFile', $resources->CalendarLanguageFile);
     $this->smarty->assign('LoggedIn', $userSession->IsLoggedIn());
     $this->smarty->assign('Version', Configuration::VERSION);
     $this->smarty->assign('Path', $this->path);
     $this->smarty->assign('ScriptUrl', Configuration::Instance()->GetScriptUrl());
     $this->smarty->assign('UserName', !is_null($userSession) ? $userSession->FirstName : '');
     $this->smarty->assign('DisplayWelcome', $this->DisplayWelcome());
     $this->smarty->assign('UserId', $userSession->UserId);
     $this->smarty->assign('CanViewAdmin', $userSession->IsAdmin);
     $this->smarty->assign('CanViewGroupAdmin', $userSession->IsGroupAdmin);
     $this->smarty->assign('CanViewResourceAdmin', $userSession->IsResourceAdmin);
     $this->smarty->assign('CanViewScheduleAdmin', $userSession->IsScheduleAdmin);
     $this->smarty->assign('CanViewResponsibilities', !$userSession->IsAdmin && ($userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin));
     $allowAllUsersToReports = Configuration::Instance()->GetSectionKey(ConfigSection::REPORTS, ConfigKeys::REPORTS_ALLOW_ALL, new BooleanConverter());
     $this->smarty->assign('CanViewReports', $allowAllUsersToReports || $userSession->IsAdmin || $userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin);
     $timeout = Configuration::Instance()->GetKey(ConfigKeys::INACTIVITY_TIMEOUT);
     if (!empty($timeout)) {
         $this->smarty->assign('SessionTimeoutSeconds', max($timeout, 1) * 60);
     }
     $this->smarty->assign('ShouldLogout', $this->GetShouldAutoLogout());
     $this->smarty->assign('CssExtensionFile', Configuration::Instance()->GetKey(ConfigKeys::CSS_EXTENSION_FILE));
     $this->smarty->assign('UseLocalJquery', Configuration::Instance()->GetKey(ConfigKeys::USE_LOCAL_JQUERY, new BooleanConverter()));
     $this->smarty->assign('EnableConfigurationPage', Configuration::Instance()->GetSectionKey(ConfigSection::PAGES, ConfigKeys::PAGES_ENABLE_CONFIGURATION, new BooleanConverter()));
     $this->smarty->assign('ShowParticipation', !Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_PREVENT_PARTICIPATION, new BooleanConverter()));
     $this->smarty->assign('LogoUrl', 'booked.png');
     if (file_exists($this->path . 'img/custom-logo.png')) {
         $this->smarty->assign('LogoUrl', 'custom-logo.png');
     }
     if (file_exists($this->path . 'img/custom-logo.gif')) {
         $this->smarty->assign('LogoUrl', 'custom-logo.gif');
     }
     if (file_exists($this->path . 'img/custom-logo.jpg')) {
         $this->smarty->assign('LogoUrl', 'custom-logo.jpg');
     }
     $this->smarty->assign('CssUrl', 'null-style.css');
     if (file_exists($this->path . 'css/custom-style.css')) {
         $this->smarty->assign('CssUrl', 'custom-style.css');
     }
     $logoUrl = Configuration::Instance()->GetKey(ConfigKeys::HOME_URL);
     if (empty($logoUrl)) {
         $logoUrl = $this->path . Pages::UrlFromId($userSession->HomepageId);
     }
     $this->smarty->assign('HomeUrl', $logoUrl);
 }
 /**
  * @param IReservationViewRepository $reservationViewRepository
  * @param IReservationAuthorization $authorization
  * @param IReservationHandler $reservationHandler
  * @param IUpdateReservationPersistenceService $persistenceService
  */
 public function __construct(IReservationViewRepository $reservationViewRepository, $authorization = null, $reservationHandler = null, $persistenceService = null)
 {
     $this->reservationViewRepository = $reservationViewRepository;
     $this->reservationAuthorization = $authorization == null ? new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization()) : $authorization;
     $this->persistenceService = $persistenceService == null ? new UpdateReservationPersistenceService(new ReservationRepository()) : $persistenceService;
     $this->reservationHandler = $reservationHandler == null ? ReservationHandler::Create(ReservationAction::Update, $this->persistenceService, ServiceLocator::GetServer()->GetUserSession()) : $reservationHandler;
 }
 public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array(), $groups = null)
 {
     $encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
     $attributes = new UserAttribute($additionalFields);
     if ($this->CreatePending()) {
         $user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     } else {
         $user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     }
     $user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
     $user->ChangeCustomAttributes($attributeValues);
     if ($groups != null) {
         $user->WithGroups($groups);
     }
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
         foreach (ReservationEvent::AllEvents() as $event) {
             $user->ChangeEmailPreference($event, true);
         }
     }
     $userId = $this->_userRepository->Add($user);
     $this->AutoAssignPermissions($userId);
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_NOTIFY, new BooleanConverter())) {
         ServiceLocator::GetEmailService()->Send(new AccountCreationEmail($user, ServiceLocator::GetServer()->GetUserSession()));
     }
     return $user;
 }
 /**
  * @param ReservationItemView $existingReservation
  * @return bool
  */
 public function Handle(ReservationItemView $existingReservation)
 {
     $reservation = $this->repository->LoadById($existingReservation->GetId());
     $reservation->ApplyChangesTo(SeriesUpdateScope::ThisInstance);
     $reservation->Delete(ServiceLocator::GetServer()->GetUserSession());
     $this->repository->Delete($reservation);
     return true;
 }
Exemple #11
0
 public static function Create()
 {
     if (ServiceLocator::GetServer()->GetQuerystring(QueryStringKeys::RESPONSE_TYPE) == 'json') {
         return new ReservationDeleteJsonPage();
     } else {
         return new ReservationDeletePage();
     }
 }
 public function __construct()
 {
     parent::__construct();
     $this->_presenter->SetUserRepository(new GroupAdminUserRepository(new GroupRepository(), ServiceLocator::GetServer()->GetUserSession()));
     $groupRepository = new GroupAdminGroupRepository(new UserRepository(), ServiceLocator::GetServer()->GetUserSession());
     $this->_presenter->SetGroupRepository($groupRepository);
     $this->_presenter->SetGroupViewRepository($groupRepository);
 }
Exemple #13
0
 public function PageLoad()
 {
     $this->presenter->PageLoad(ServiceLocator::GetServer()->GetUserSession());
     header("Content-Type: text/Calendar");
     header("Content-Disposition: inline; filename=calendar.ics");
     $display = new CalendarExportDisplay();
     echo $display->Render($this->reservations);
 }
Exemple #14
0
 public function __construct($titleKey = '', $pageDepth = 1)
 {
     parent::__construct($titleKey, $pageDepth);
     $user = ServiceLocator::GetServer()->GetUserSession();
     if (!$user->IsAdmin) {
         $this->RedirectResume(sprintf("%s%s?%s=%s", $this->path, Pages::LOGIN, QueryStringKeys::REDIRECT, urlencode($this->server->GetUrl())));
         die;
     }
 }
Exemple #15
0
 public function Initialize()
 {
     $announcement = new AnnouncementsControl(new SmartyPage());
     $upcomingReservations = new UpcomingReservations(new SmartyPage());
     $this->_page->AddItem($announcement);
     $this->_page->AddItem($upcomingReservations);
     if (ServiceLocator::GetServer()->GetUserSession()->IsAdmin) {
         $allUpcomingReservations = new AllUpcomingReservations(new SmartyPage());
         $this->_page->AddItem($allUpcomingReservations);
     }
 }
 public function PageLoad()
 {
     $this->page->SetEmailEnabled(Configuration::Instance()->GetKey(ConfigKeys::ENABLE_EMAIL, new BooleanConverter()));
     $userSession = ServiceLocator::GetServer()->GetUserSession();
     $user = $this->userRepository->LoadById($userSession->UserId);
     if ($this->page->IsPostBack()) {
         $this->UpdateProfile($user);
         $this->page->SetPreferencesSaved(true);
     }
     $this->page->SetApproved($user->WantsEventEmail(new ReservationApprovedEvent()));
     $this->page->SetCreated($user->WantsEventEmail(new ReservationCreatedEvent()));
     $this->page->SetUpdated($user->WantsEventEmail(new ReservationUpdatedEvent()));
     $this->page->SetDeleted($user->WantsEventEmail(new ReservationDeletedEvent()));
 }
 public function PageLoad()
 {
     try {
         $reservationAction = ReservationAction::Approve;
         $factory = new ReservationPersistenceFactory();
         $persistenceService = $factory->Create($reservationAction);
         $handler = ReservationHandler::Create($reservationAction, $persistenceService, ServiceLocator::GetServer()->GetUserSession());
         $auth = new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization());
         $presenter = new ReservationApprovalPresenter($this, $persistenceService, $handler, $auth, ServiceLocator::GetServer()->GetUserSession());
         $presenter->PageLoad();
     } catch (Exception $ex) {
         Log::Error('ReservationApprovalPage - Critical error saving reservation: %s', $ex);
         $this->Display('Ajax/reservation/reservation_error.tpl');
     }
 }
Exemple #18
0
 public function __construct($user = null, $privacyFilter = null, $attributeRepository = null)
 {
     $this->user = $user;
     if ($this->user == null) {
         $this->user = ServiceLocator::GetServer()->GetUserSession();
     }
     $this->privacyFilter = $privacyFilter;
     if ($this->privacyFilter == null) {
         $this->privacyFilter = new PrivacyFilter(new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization()));
     }
     $this->attributeRepository = $attributeRepository;
     if ($this->attributeRepository == null) {
         $this->attributeRepository = new AttributeRepository();
     }
 }
 public function ChangeAnnouncement()
 {
     $user = ServiceLocator::GetServer()->GetUserSession();
     $id = $this->page->GetAnnouncementId();
     $text = $this->page->GetText();
     $start = Date::Parse($this->page->GetStart(), $user->Timezone);
     $end = Date::Parse($this->page->GetEnd(), $user->Timezone);
     $priority = $this->page->GetPriority();
     Log::Debug('Changing Announcement with id %s', $id);
     $announcement = $this->announcementRepository->LoadById($id);
     $announcement->SetText($text);
     $announcement->SetDates($start, $end);
     $announcement->SetPriority($priority);
     $this->announcementRepository->Update($announcement);
 }
 public function PageLoad()
 {
     $user = ServiceLocator::GetServer()->GetUserSession();
     $timezone = $user->Timezone;
     $now = Date::Now();
     $today = $now->ToTimezone($timezone)->GetDate();
     $dayOfWeek = $today->Weekday();
     $lastDate = $now->AddDays(13 - $dayOfWeek - 1);
     $reservations = $this->repository->GetReservationList($now, $lastDate, $this->searchUserId, $this->searchUserLevel);
     $tomorrow = $today->AddDays(1);
     $startOfNextWeek = $today->AddDays(7 - $dayOfWeek);
     $todays = array();
     $tomorrows = array();
     $thisWeeks = array();
     $nextWeeks = array();
     /* @var $reservation ReservationItemView */
     /*foreach ($reservations as $reservation)
     		{
     			$start = $reservation->StartDate->ToTimezone($timezone);
     
     			if ($start->DateEquals($today))
     			{
     				$todays[] = $reservation;
     			}
     			else if ($start->DateEquals($tomorrow))
     			{
     				$tomorrows[] = $reservation;
     			}
     			else if ($start->LessThan($startOfNextWeek))
     			{
     				$thisWeeks[] = $reservation;
     			}
     			else
     			{
     				$nextWeeks[] = $reservation;
     			}
     		}*/
     $this->control->SetTotal(count($reservations));
     $this->control->SetTimezone($timezone);
     $this->control->SetUserId($user->UserId);
     $this->control->BindReservations($reservations);
     $this->control->BindExperiment($reservations->experiment);
     $this->control->BindTodayDate();
     /*$this->control->BindToday($todays);
     		$this->control->BindTomorrow($tomorrows);
     		$this->control->BindThisWeek($thisWeeks);
     		$this->control->BindNextWeek($nextWeeks);*/
 }
 public function ShowUserAttributes()
 {
     // User attributes on Dashboard, Added by Burak C.
     $userId = ServiceLocator::GetServer()->GetUserSession()->UserId;
     $userRepository = new UserRepository();
     $this->user = $userRepository->LoadById($userId);
     $attributeService = new AttributeService(new AttributeRepository());
     $attributes = $attributeService->GetByCategory(CustomAttributeCategory::USER);
     $reservationViewRepository = new ReservationViewRepository();
     $startDate = Date::Now();
     $endDate = $startDate->AddDays(30);
     $reservations = $reservationViewRepository->GetReservationList($startDate, $endDate, $userId, ReservationUserLevel::INVITEE);
     $this->_page->Set("invitations", $reservations);
     $this->_page->Set("user", $this->user);
     $this->_page->Set("attributes", $attributes);
 }
Exemple #22
0
 public function PageLoad()
 {
     $this->presenter->PageLoad(ServiceLocator::GetServer()->GetUserSession());
     header("Content-Type: text/Calendar");
     header("Content-Disposition: inline; filename=calendar.ics");
     $config = Configuration::Instance();
     $this->Set('bookedVersion', $config->GetKey(ConfigKeys::VERSION));
     $this->Set('DateStamp', Date::Now());
     /**
      * ScriptUrl is used to generate iCal UID's. As a workaround to this bug
      * https://bugzilla.mozilla.org/show_bug.cgi?id=465853
      * we need to avoid using any slashes "/"
      */
     $url = $config->GetScriptUrl();
     $this->Set('ScriptUrl', parse_url($url, PHP_URL_HOST));
     $this->Display('Export/ical.tpl');
 }
 /**
  * @see IReservationValidationRule::Validate()
  *
  * @param ReservationSeries $reservationSeries
  * @return ReservationRuleResult
  */
 public function Validate($reservationSeries)
 {
     $r = Resources::GetInstance();
     $resources = $reservationSeries->AllResources();
     foreach ($resources as $resource) {
         if ($resource->HasMaxNotice()) {
             $maxStartDate = Date::Now()->ApplyDifference($resource->GetMaxNotice()->Interval());
             /* @var $instance Reservation */
             foreach ($this->GetInstances($reservationSeries) as $instance) {
                 if ($instance->StartDate()->GreaterThan($maxStartDate)) {
                     return new ReservationRuleResult(false, $r->GetString("MaxNoticeError", $maxStartDate->ToTimezone(ServiceLocator::GetServer()->GetUserSession()->Timezone)->Format($r->GeneralDateTimeFormat())));
                 }
             }
         }
     }
     return new ReservationRuleResult();
 }
 public function PageLoad()
 {
     try {
         $reservation = $this->_presenter->BuildReservation();
         $this->_presenter->HandleReservation($reservation);
         if ($this->_reservationSavedSuccessfully) {
             $this->Set('Resources', $reservation->AllResources());
             $this->Set('Instances', $reservation->Instances());
             $this->Set('Timezone', ServiceLocator::GetServer()->GetUserSession()->Timezone);
             $this->Display('Ajax/reservation/update_successful.tpl');
         } else {
             $this->Display('Ajax/reservation/save_failed.tpl');
         }
     } catch (Exception $ex) {
         Log::Error('ReservationUpdatePage - Critical error saving reservation: %s', $ex);
         $this->Display('Ajax/reservation/reservation_error.tpl');
     }
 }
Exemple #25
0
 private function Configure()
 {
     if (!$this->securityGuard->IsAuthenticated()) {
         return;
     }
     $user = ServiceLocator::GetServer()->GetUserSession();
     Log::Debug('Editing configuration file. Email=%s, UserId=%s', $user->Email, $user->UserId);
     $configFile = ROOT_DIR . 'config/config.php';
     $configDistFile = ROOT_DIR . 'config/config.dist.php';
     $configurator = new Configurator();
     if ($configurator->CanOverwriteFile($configFile)) {
         $configurator->Merge($configFile, $configDistFile);
         $this->page->ShowConfigUpdateSuccess();
     } else {
         $manualConfig = $configurator->GetMergedString($configFile, $configDistFile);
         $this->page->ShowManualConfig($manualConfig);
     }
 }
 public function PageLoad()
 {
     $invitationAction = $this->page->GetInvitationAction();
     if (!empty($invitationAction)) {
         $resultString = $this->HandleInvitationAction($invitationAction);
         if ($this->page->GetResponseType() == 'json') {
             $this->page->DisplayResult($resultString);
             return;
         }
         $this->page->SetResult($resultString);
     }
     $startDate = Date::Now();
     $endDate = $startDate->AddDays(30);
     $user = ServiceLocator::GetServer()->GetUserSession();
     $userId = $user->UserId;
     $reservations = $this->reservationViewRepository->GetReservationList($startDate, $endDate, $userId, ReservationUserLevel::INVITEE);
     $this->page->SetTimezone($user->Timezone);
     $this->page->BindReservations($reservations);
     $this->page->DisplayParticipation();
 }
 public function UpdateAttribute()
 {
     $userSession = ServiceLocator::GetServer()->GetUserSession();
     $referenceNumber = $this->page->GetReferenceNumber();
     $attributeId = $this->page->GetAttributeId();
     $attributeValue = $this->page->GetAttributeValue();
     Log::Debug('Updating reservation attribute. UserId=%s, AttributeId=%s, AttributeValue=%s, ReferenceNumber=%s', $userSession->UserId, $attributeId, $attributeValue, $referenceNumber);
     $errors = $this->manageReservationsService->UpdateAttribute($referenceNumber, $attributeId, $attributeValue, $userSession);
     if (!empty($errors)) {
         $this->page->BindAttributeUpdateErrors($errors);
     }
 }
Exemple #28
0
 public function GetScriptUrl()
 {
     $url = $this->GetKey(ConfigKeys::SCRIPT_URL);
     if (BookedStringHelper::StartsWith($url, '//')) {
         $isHttps = ServiceLocator::GetServer()->GetIsHttps();
         if ($isHttps) {
             $url = "https:{$url}";
         } else {
             $url = "http:{$url}";
         }
     }
     return rtrim($url, '/');
 }
 public function DisableSubscription()
 {
     $userId = ServiceLocator::GetServer()->GetUserSession()->UserId;
     Log::Debug('Disabling calendar subscription for userId: %s', $userId);
     $user = $this->userRepository->LoadById($userId);
     $user->DisableSubscription();
     $this->userRepository->Update($user);
 }
Exemple #30
0
 public function __construct()
 {
     parent::__construct('CommonReports', 1);
     $this->presenter = new CommonReportsPresenter($this, ServiceLocator::GetServer()->GetUserSession(), new ReportingService(new ReportingRepository()));
 }