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); }
public function PageLoad() { $this->Set('DefaultTitle', Resources::GetInstance()->GetString('NoTitleLabel')); $this->presenter->SetSearchCriteria(ReservationViewRepository::ALL_USERS, ReservationUserLevel::ALL); $this->presenter->PageLoad(); $this->Display('admin_upcoming_reservations.tpl'); }
/** * @param $invitationAction * @return string|null */ private function HandleInvitationAction($invitationAction) { $referenceNumber = $this->page->GetInvitationReferenceNumber(); $userId = $this->page->GetUserId(); Log::Debug('Invitation action %s for user %s and reference number %s', $invitationAction, $userId, $referenceNumber); $series = $this->reservationRepository->LoadByReferenceNumber($referenceNumber); if ($invitationAction == InvitationAction::Accept) { $series->AcceptInvitation($userId); foreach ($series->AllResources() as $resource) { if (!$resource->HasMaxParticipants()) { continue; } /** @var $instance Reservation */ foreach ($series->Instances() as $instance) { $numberOfParticipants = count($instance->Participants()); if ($numberOfParticipants > $resource->GetMaxParticipants()) { return Resources::GetInstance()->GetString('MaxParticipantsError', array($resource->GetName(), $resource->GetMaxParticipants())); } } } } if ($invitationAction == InvitationAction::Decline) { $series->DeclineInvitation($userId); } if ($invitationAction == InvitationAction::CancelInstance) { $series->CancelInstanceParticipation($userId); } if ($invitationAction == InvitationAction::CancelAll) { $series->CancelAllParticipation($userId); } $this->reservationRepository->Update($series); return null; }
public function Validate($category, $attributeValues, $entityId = null, $ignoreEmpty = false) { $isValid = true; $errors = array(); $resources = Resources::GetInstance(); $values = array(); foreach ($attributeValues as $av) { $values[$av->AttributeId] = $av->Value; } $attributes = $this->attributeRepository->GetByCategory($category); foreach ($attributes as $attribute) { if ($attribute->UniquePerEntity() && $entityId != $attribute->EntityId()) { continue; } $value = trim($values[$attribute->Id()]); $label = $attribute->Label(); if (empty($value) && $ignoreEmpty) { continue; } if (!$attribute->SatisfiesRequired($value)) { $isValid = false; $errors[] = $resources->GetString('CustomAttributeRequired', $label); } if (!$attribute->SatisfiesConstraint($value)) { $isValid = false; $errors[] = $resources->GetString('CustomAttributeInvalid', $label); } } return new AttributeServiceValidationResult($isValid, $errors); }
/** * @param ReservationItemView|ReservationView $res * @return null|string */ private function CreateRecurRule($res) { if (is_a($res, 'ReservationItemView')) { // don't populate the recurrance rule when a list of reservation is being exported return null; } ### !!! THIS DOES NOT WORK BECAUSE EXCEPTIONS TO RECURRENCE RULES ARE NOT PROPERLY HANDLED !!! ### see bug report http://php.brickhost.com/forums/index.php?topic=11450.0 if (empty($res->RepeatType) || $res->RepeatType == RepeatType::None) { return null; } $freqMapping = array(RepeatType::Daily => 'DAILY', RepeatType::Weekly => 'WEEKLY', RepeatType::Monthly => 'MONTHLY', RepeatType::Yearly => 'YEARLY'); $freq = $freqMapping[$res->RepeatType]; $interval = $res->RepeatInterval; $format = Resources::GetInstance()->GetDateFormat('ical'); $end = $res->RepeatTerminationDate->SetTime($res->EndDate->GetTime())->Format($format); $rrule = sprintf('FREQ=%s;INTERVAL=%s;UNTIL=%s', $freq, $interval, $end); if ($res->RepeatType == RepeatType::Monthly) { if ($res->RepeatMonthlyType == RepeatMonthlyType::DayOfMonth) { $rrule .= ';BYMONTHDAY=' . $res->StartDate->Day(); } } if (!empty($res->RepeatWeekdays)) { $dayMapping = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); $days = ''; foreach ($res->RepeatWeekdays as $weekDay) { $days .= $dayMapping[$weekDay] . ','; } $days = substr($days, 0, -1); $rrule .= ';BYDAY=' . $days; } return $rrule; }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $userId = $reservationSeries->UserId(); $resourceId = $reservationSeries->ResourceId(); $isOk = !empty($userId) && !empty($resourceId); return new ReservationRuleResult($isOk, Resources::GetInstance()->GetString('InvalidReservationData')); }
public function Execute(ISqlCommand $sqlCommand) { mysqli_set_charset($this->_db, Resources::GetInstance()->Charset); $mysqlCommand = new MySqlCommandAdapter($sqlCommand, $this->_db); Log::Sql('MySql Execute: ' . str_replace('%', '%%', $mysqlCommand->GetQuery())); $result = mysqli_query($this->_db, $mysqlCommand->GetQuery()); $this->_handleError($result); }
public function testLanguageIsLoadedCorrectlyWhenSet() { $langFile = 'en_us.php'; $lang = 'en_us'; $this->Resources = Resources::GetInstance(); $this->Resources->SetLanguage($lang); $this->assertEquals($lang, $this->Resources->CurrentLanguage); $this->assertEquals($langFile, $this->Resources->LanguageFile); }
protected function GetFullName(ReservationItemView $reservation) { $shouldHide = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter()); if ($shouldHide && (is_null($this->user) || $this->user->UserId != $reservation->UserId)) { return Resources::GetInstance()->GetString('Private'); } $name = new FullName($reservation->FirstName, $reservation->LastName); return $name->__toString(); }
private function showSecurimage() { Log::Debug('CaptchaControl using Securimage'); $url = CaptchaService::Create()->GetImageUrl(); $label = Resources::GetInstance()->GetString('SecurityCode'); $formName = FormKeys::CAPTCHA; echo "<img src='{$url}' alt='captcha' id='captchaImg'/>"; echo "<br/><label class=\"reg\">{$label}<br/><input type=\"text\" class=\"input\" name=\"{$formName}\" size=\"20\" id=\"captchaValue\"/>"; }
/** * @return void */ public function ProcessPageLoad() { $this->Set('untitled', Resources::GetInstance()->GetString('NoTitleLabel')); $this->Set('RepeatEveryOptions', range(1, 20)); $this->Set('RepeatOptions', array('none' => array('key' => 'Never', 'everyKey' => ''), 'daily' => array('key' => 'Daily', 'everyKey' => 'days'), 'weekly' => array('key' => 'Weekly', 'everyKey' => 'weeks'), 'monthly' => array('key' => 'Monthly', 'everyKey' => 'months'), 'yearly' => array('key' => 'Yearly', 'everyKey' => 'years'))); $this->Set('DayNames', array(0 => 'DaySundayAbbr', 1 => 'DayMondayAbbr', 2 => 'DayTuesdayAbbr', 3 => 'DayWednesdayAbbr', 4 => 'DayThursdayAbbr', 5 => 'DayFridayAbbr', 6 => 'DaySaturdayAbbr')); $this->presenter->PageLoad(); $this->Display('Reports/saved-reports.tpl'); }
public function Validate() { if ($this->file == null) { return; } $this->isValid = in_array($this->file->Extension(), $this->allowedTypes); if (!$this->IsValid()) { $this->AddMessage(Resources::GetInstance()->GetString('InvalidAttachmentExtension', array(implode(',', $this->allowedTypes)))); } }
public function __construct(IReport $report, $timezone) { $dateFormat = Resources::GetInstance()->GeneralDateTimeFormat(); $orderedColumns = array(ColumnNames::ACCESSORY_NAME => new ReportStringColumn('Accessory', ChartColumnDefinition::Label(ColumnNames::ACCESSORY_ID, ChartGroup::Accessory)), ColumnNames::RESOURCE_NAME_ALIAS => new ReportStringColumn('Resource', ChartColumnDefinition::Label(ColumnNames::RESOURCE_ID, ChartGroup::Resource)), ColumnNames::QUANTITY => new ReportStringColumn('QuantityReserved', ChartColumnDefinition::Total()), ColumnNames::RESERVATION_START => new ReportDateColumn('BeginDate', $timezone, $dateFormat, ChartColumnDefinition::Date()), ColumnNames::RESERVATION_END => new ReportDateColumn('EndDate', $timezone, $dateFormat, ChartColumnDefinition::Null()), ColumnNames::RESERVATION_TITLE => new ReportStringColumn('Title', ChartColumnDefinition::Null()), ColumnNames::RESERVATION_DESCRIPTION => new ReportStringColumn('Description', ChartColumnDefinition::Null()), ColumnNames::REFERENCE_NUMBER => new ReportStringColumn('ReferenceNumber', ChartColumnDefinition::Null()), ColumnNames::OWNER_FULL_NAME_ALIAS => new ReportStringColumn('User', ChartColumnDefinition::Label(ColumnNames::OWNER_USER_ID)), ColumnNames::GROUP_NAME_ALIAS => new ReportStringColumn('Group', ChartColumnDefinition::Label(ColumnNames::GROUP_ID)), ColumnNames::SCHEDULE_NAME_ALIAS => new ReportStringColumn('Schedule', ChartColumnDefinition::Label(ColumnNames::SCHEDULE_ID)), ColumnNames::RESERVATION_CREATED => new ReportDateColumn('Created', $timezone, $dateFormat, ChartColumnDefinition::Null()), ColumnNames::RESERVATION_MODIFIED => new ReportDateColumn('LastModified', $timezone, $dateFormat, ChartColumnDefinition::Null()), ColumnNames::TOTAL => new ReportStringColumn('Total', ChartColumnDefinition::Total()), ColumnNames::TOTAL_TIME => new ReportTimeColumn('Total', ChartColumnDefinition::Total())); $reportColumns = $report->GetColumns(); foreach ($orderedColumns as $key => $column) { if ($reportColumns->Exists($key)) { $this->columns[$key] = $column; } } }
/** * @param ReservationSeries $reservation * @return ReservationRuleResult */ public function Validate($reservation) { $reservation->UserId(); $permissionService = $this->permissionServiceFactory->GetPermissionService(); $resourceIds = $reservation->AllResourceIds(); foreach ($resourceIds as $resourceId) { if (!$permissionService->CanAccessResource(new ReservationResource($resourceId), $reservation->BookedBy())) { return new ReservationRuleResult(false, Resources::GetInstance()->GetString('NoResourcePermission')); } } return new ReservationRuleResult(true); }
public function Validate($reservationSeries) { foreach ($reservationSeries->AllResources() as $resource) { if (!$resource->GetAllowMultiday()) { $schedule = $this->scheduleRepository->LoadById($reservationSeries->ScheduleId()); $tz = $schedule->GetTimezone(); $isSameDay = $reservationSeries->CurrentInstance()->StartDate()->ToTimezone($tz)->DateEquals($reservationSeries->CurrentInstance()->EndDate()->ToTimezone($tz)); return new ReservationRuleResult($isSameDay, Resources::GetInstance()->GetString('MultiDayRule', $resource->GetName())); } } return new ReservationRuleResult(); }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $quotas = $this->quotaRepository->LoadAll(); $user = $this->userRepository->LoadById($reservationSeries->UserId()); $schedule = $this->scheduleRepository->LoadById($reservationSeries->ScheduleId()); foreach ($quotas as $quota) { if ($quota->ExceedsQuota($reservationSeries, $user, $schedule, $this->reservationViewRepository)) { Log::Debug('Quota exceeded. %s', $quota->ToString()); return new ReservationRuleResult(false, Resources::GetInstance()->GetString('QuotaExceeded')); } } return new ReservationRuleResult(); }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $resources = Resources::GetInstance(); $errorMessage = new StringBuilder(); $result = $this->attributeService->Validate(CustomAttributeCategory::RESERVATION, $reservationSeries->AttributeValues()); $isValid = $result->IsValid(); foreach ($result->Errors() as $error) { $errorMessage->AppendLine($error); } if (!$isValid) { $errorMessage->PrependLine($resources->GetString('CustomAttributeErrors')); } return new ReservationRuleResult($isValid, $errorMessage->ToString()); }
/** * @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(); }
/** * @see IReservationValidationRule::Validate() * * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $r = Resources::GetInstance(); $resources = $reservationSeries->AllResources(); foreach ($resources as $resource) { if ($resource->HasMinLength()) { $minDuration = $resource->GetMinLength()->Interval(); $start = $reservationSeries->CurrentInstance()->StartDate(); $end = $reservationSeries->CurrentInstance()->EndDate(); $minEnd = $start->ApplyDifference($minDuration); if ($end->LessThan($minEnd)) { return new ReservationRuleResult(false, $r->GetString("MinDurationError", $minDuration)); } } } return new ReservationRuleResult(); }
/** * @see IReservationValidationRule::Validate() * * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $r = Resources::GetInstance(); $resources = $reservationSeries->AllResources(); foreach ($resources as $resource) { if ($resource->HasMinNotice()) { $minStartDate = Date::Now()->ApplyDifference($resource->GetMinNotice()->Interval()); /* @var $instance Reservation */ foreach ($reservationSeries->Instances() as $instance) { if ($instance->StartDate()->LessThan($minStartDate)) { return new ReservationRuleResult(false, $r->GetString("MinNoticeError", $minStartDate->Format($r->GeneralDateTimeFormat()))); } } } } return new ReservationRuleResult(); }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $layout = $this->repository->GetLayout($reservationSeries->Resource()->GetScheduleId(), new ScheduleLayoutFactory($this->session->Timezone)); $startDate = $reservationSeries->CurrentInstance()->StartDate(); $startPeriod = $layout->GetPeriod($startDate); $endDate = $reservationSeries->CurrentInstance()->EndDate(); $endPeriod = $layout->GetPeriod($endDate); $errors = new StringBuilder(); if ($startPeriod == null || !$startPeriod->IsReservable() || !$startPeriod->BeginDate()->Equals($startDate)) { $errors->AppendLine(Resources::GetInstance()->GetString('InvalidStartSlot')); } if ($endPeriod == null || !$endPeriod->BeginDate()->Equals($endDate)) { $errors->AppendLine(Resources::GetInstance()->GetString('InvalidEndSlot')); } $errorMessage = $errors->ToString(); return new ReservationRuleResult(strlen($errorMessage) == 0, $errorMessage); }
/** * @param array|Schedule[] $schedules * @param array|ResourceDto[] $resources * @param int $selectedScheduleId * @param int $selectedResourceId */ public function __construct($schedules, $resources, $selectedScheduleId, $selectedResourceId) { if (!empty($resources)) { $this->filters[] = new CalendarFilter(self::FilterSchedule, null, Resources::GetInstance()->GetString("AllReservations"), empty($selectedResourceId) && empty($selectedScheduleId)); } foreach ($schedules as $schedule) { if ($this->ScheduleContainsNoResources($schedule, $resources)) { continue; } $filter = new CalendarFilter(self::FilterSchedule, $schedule->GetId(), $schedule->GetName(), empty($selectedResourceId) && $selectedScheduleId == $schedule->GetId()); foreach ($resources as $resource) { if ($resource->GetScheduleId() == $schedule->GetId()) { $filter->AddSubFilter(new CalendarFilter(self::FilterResource, $resource->GetResourceId(), $resource->GetName(), $selectedResourceId == $resource->GetResourceId())); } } $this->filters[] = $filter; } }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $attachments = $reservationSeries->AddedAttachments(); $allowedExtensionsConfig = Configuration::Instance()->GetSectionKey(ConfigSection::UPLOADS, ConfigKeys::UPLOAD_RESERVATION_EXTENSIONS); if (empty($allowedExtensionsConfig) || empty($attachments)) { return new ReservationRuleResult(); } $allowedExtensions = str_replace('.', '', $allowedExtensionsConfig); $allowedExtensions = str_replace(' ', '', $allowedExtensions); $allowedExtensionList = explode(',', $allowedExtensions); foreach ($attachments as $attachment) { $isValid = in_array($attachment->FileExtension(), $allowedExtensionList); if (!$isValid) { return new ReservationRuleResult($isValid, Resources::GetInstance()->GetString('InvalidAttachmentExtension', $allowedExtensionsConfig)); } } return new ReservationRuleResult(); }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $errorMessage = new StringBuilder(); if ($reservationSeries->GetStartReminder()->Enabled()) { if (!$this->minutesValid($reservationSeries->GetStartReminder())) { $errorMessage->AppendLine(Resources::GetInstance()->GetString('InvalidStartReminderTime')); } } if ($reservationSeries->GetEndReminder()->Enabled()) { if (!$this->minutesValid($reservationSeries->GetEndReminder())) { $errorMessage->AppendLine(Resources::GetInstance()->GetString('InvalidEndReminderTime')); } } $message = $errorMessage->ToString(); if (strlen($message) > 0) { return new ReservationRuleResult(false, $message); } return new ReservationRuleResult(); }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $constraint = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_START_TIME_CONSTRAINT); if (empty($constraint)) { $constraint = ReservationStartTimeConstraint::_DEFAULT; } if ($constraint == ReservationStartTimeConstraint::NONE) { return new ReservationRuleResult(); } $currentInstance = $reservationSeries->CurrentInstance(); $dateThatShouldBeLessThanNow = $currentInstance->StartDate(); if ($constraint == ReservationStartTimeConstraint::CURRENT) { $timezone = $dateThatShouldBeLessThanNow->Timezone(); /** @var $currentPeriod SchedulePeriod */ $currentPeriod = $this->scheduleRepository->GetLayout($reservationSeries->ScheduleId(), new ScheduleLayoutFactory($timezone))->GetPeriod($currentInstance->EndDate()); $dateThatShouldBeLessThanNow = $currentPeriod->BeginDate(); } Log::Debug("Start Time Rule: Comparing %s to %s", $dateThatShouldBeLessThanNow, Date::Now()); $startIsInFuture = $dateThatShouldBeLessThanNow->Compare(Date::Now()) >= 0; return new ReservationRuleResult($startIsInFuture, Resources::GetInstance()->GetString('StartIsInPast')); }
/** * @param ReservationSeries $reservationSeries * @return ReservationRuleResult */ public function Validate($reservationSeries) { $errorMessage = new StringBuilder(); foreach ($reservationSeries->AllResources() as $resource) { if (!$resource->HasMaxParticipants()) { continue; } foreach ($reservationSeries->Instances() as $instance) { $numberOfParticipants = count($instance->Participants()); Log::Debug('ResourceParticipationRule Resource=%s,InstanceId=%s,MaxParticipants=%s,CurrentParticipants=%s', $resource->GetName(), $instance->ReservationId(), $resource->GetMaxParticipants(), $numberOfParticipants); if ($numberOfParticipants > $resource->GetMaxParticipants()) { $errorMessage->AppendLine(Resources::GetInstance()->GetString('MaxParticipantsError', array($resource->GetName(), $resource->GetMaxParticipants()))); continue; } } } $message = $errorMessage->ToString(); if (strlen($message) > 0) { return new ReservationRuleResult(false, $message); } return new ReservationRuleResult(); }
/** * * @param Resources $resources * @param string $rootPath */ public function __construct(Resources &$resources = null, $rootPath = null) { parent::__construct(); $base = dirname(__FILE__) . '/../../'; $this->debugging = isset($_GET['debug']); $this->AddTemplateDirectory($base . 'tpl'); $this->compile_dir = $base . 'tpl_c'; $this->config_dir = $base . 'configs'; $this->cache_dir = $base . 'cache'; $this->plugins_dir = $base . 'lib/external/Smarty/plugins'; $this->error_reporting = E_ALL & ~E_NOTICE; $cacheTemplates = Configuration::Instance()->GetKey(ConfigKeys::CACHE_TEMPLATES, new BooleanConverter()); $this->caching = false; $this->compile_check = !$cacheTemplates; $this->force_compile = !$cacheTemplates; if (is_null($resources)) { $resources = Resources::GetInstance(); } $this->Resources =& $resources; $this->RootPath = $rootPath; $this->AddTemplateDirectory($base . 'lang/' . $this->Resources->CurrentLanguage); $this->RegisterFunctions(); }
public function Validate() { $caseRequirements = Configuration::Instance()->GetSectionKey(ConfigSection::PASSWORD, ConfigKeys::PASSWORD_UPPER_AND_LOWER, new BooleanConverter()); $letters = Configuration::Instance()->GetSectionKey(ConfigSection::PASSWORD, ConfigKeys::PASSWORD_LETTERS, new IntConverter()); $numbers = Configuration::Instance()->GetSectionKey(ConfigSection::PASSWORD, ConfigKeys::PASSWORD_NUMBERS, new IntConverter()); $passwordNumbers = preg_match_all("/[^a-zA-Z]/", $this->password, $m1); $passwordUpper = preg_match_all("/[A-Z]/", $this->password, $m2); $passwordLower = preg_match_all("/[a-z]/", $this->password, $m3); $passwordLetters = strlen($this->password); if (empty($letters)) { $letters = 6; } $this->isValid = $passwordNumbers >= $numbers && $passwordLetters >= $letters; if ($caseRequirements) { $this->isValid = $this->isValid && $passwordUpper > 0 && $passwordLower > 0; } if (!$this->IsValid()) { if (!$caseRequirements) { $this->AddMessage(Resources::GetInstance()->GetString('PasswordError', array($letters, $numbers))); } else { $this->AddMessage(Resources::GetInstance()->GetString('PasswordErrorRequirements', array($letters, $numbers))); } } }
public function ProcessPageLoad() { $this->_presenter->PageLoad(); $config = Configuration::Instance(); $resources = Resources::GetInstance(); $this->Set('statusDescriptions', array(AccountStatus::ALL => $resources->GetString('All'), AccountStatus::ACTIVE => $resources->GetString('Active'), AccountStatus::AWAITING_ACTIVATION => $resources->GetString('Pending'), AccountStatus::INACTIVE => $resources->GetString('Inactive'))); $this->Set('Timezone', $config->GetDefaultTimezone()); $this->Set('Timezones', $GLOBALS['APP_TIMEZONES']); $this->Set('Languages', $GLOBALS['APP_TIMEZONES']); $this->Set('ManageGroupsUrl', Pages::MANAGE_GROUPS); $this->Set('ManageReservationsUrl', Pages::MANAGE_RESERVATIONS); $this->Set('FilterStatusId', $this->GetFilterStatusId()); $this->Set('PerUserColors', $config->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_PER_USER_COLORS, new BooleanConverter())); $this->RenderTemplate(); }
/** * @param ExistingReservationSeries $series * @return mixed|null|string */ private function CheckCapacityAndReturnAnyError($series) { foreach ($series->AllResources() as $resource) { if (!$resource->HasMaxParticipants()) { continue; } /** @var $instance Reservation */ foreach ($series->Instances() as $instance) { $numberOfParticipants = count($instance->Participants()); if ($numberOfParticipants > $resource->GetMaxParticipants()) { return Resources::GetInstance()->GetString('MaxParticipantsError', array($resource->GetName(), $resource->GetMaxParticipants())); } } } return null; }