/** * @return void */ public function ProcessPageLoad() { $this->Set('IsConfigFileWritable', true); $this->presenter->PageLoad(); $this->Set('Settings', $this->settings); $this->Set('SectionSettings', $this->sectionSettings); $this->PopulateTimezones(); $this->Set('Languages', Resources::GetInstance()->AvailableLanguages); $this->Set('SettingNames', $this->settingNames->ToString()); $this->Display('Admin/Configuration/manage_configuration.tpl'); }
/** * @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()); }
/** * @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 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(); }
public function Send(IEmailMessage $emailMessage) { $this->phpMailer->ClearAllRecipients(); $this->phpMailer->ClearReplyTos(); $this->phpMailer->CharSet = $emailMessage->Charset(); $this->phpMailer->Subject = $emailMessage->Subject(); $this->phpMailer->Body = $emailMessage->Body(); $from = $emailMessage->From(); $defaultFrom = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_ADDRESS); $defaultName = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_NAME); $address = empty($defaultFrom) ? $from->Address() : $defaultFrom; $name = empty($defaultName) ? $from->Name() : $defaultName; $this->phpMailer->SetFrom($address, $name); $replyTo = $emailMessage->ReplyTo(); $this->phpMailer->AddReplyTo($replyTo->Address(), $replyTo->Name()); $to = $this->ensureArray($emailMessage->To()); $toAddresses = new StringBuilder(); foreach ($to as $address) { $toAddresses->Append($address->Address()); $this->phpMailer->AddAddress($address->Address(), $address->Name()); } $cc = $this->ensureArray($emailMessage->CC()); foreach ($cc as $address) { $this->phpMailer->AddCC($address->Address(), $address->Name()); } $bcc = $this->ensureArray($emailMessage->BCC()); foreach ($bcc as $address) { $this->phpMailer->AddBCC($address->Address(), $address->Name()); } if ($emailMessage->HasStringAttachment()) { Log::Debug('Adding email attachment %s', $emailMessage->AttachmentFileName()); $this->phpMailer->AddStringAttachment($emailMessage->AttachmentContents(), $emailMessage->AttachmentFileName()); } Log::Debug('Sending %s email to: %s from: %s', get_class($emailMessage), $toAddresses->ToString(), $from->Address()); $success = false; try { $success = $this->phpMailer->Send(); } catch (Exception $ex) { Log::Error('Failed sending email. Exception: %s', $ex); } Log::Debug('Email send success: %d. %s', $success, $this->phpMailer->ErrorInfo); }
/** * @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 ReservationItemView $reservation * @param string $format * @return string */ public function Format(ReservationItemView $reservation, $format = null) { $shouldHideUser = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter()); $shouldHideDetails = ReservationDetailsFilter::HideReservationDetails($reservation->StartDate, $reservation->EndDate); if (($shouldHideUser || $shouldHideDetails) && (is_null($this->user) || $this->user->UserId != $reservation->UserId && !$this->user->IsAdminForGroup($reservation->OwnerGroupIds()))) { return ''; } if (empty($format)) { $format = Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_RESERVATION_LABEL); } if ($format == 'none' || empty($format)) { return ''; } $name = $this->GetFullName($reservation); $timezone = 'UTC'; $dateFormat = Resources::GetInstance()->GetDateFormat('res_popup'); if (!is_null($this->user)) { $timezone = $this->user->Timezone; } $label = $format; $label = str_replace('{name}', $name, $label); $label = str_replace('{title}', $reservation->Title, $label); $label = str_replace('{description}', $reservation->Description, $label); $label = str_replace('{email}', $reservation->OwnerEmailAddress, $label); $label = str_replace('{organization}', $reservation->OwnerOrganization, $label); $label = str_replace('{phone}', $reservation->OwnerPhone, $label); $label = str_replace('{position}', $reservation->OwnerPosition, $label); $label = str_replace('{startdate}', $reservation->StartDate->ToTimezone($timezone)->Format($dateFormat), $label); $label = str_replace('{enddate}', $reservation->EndDate->ToTimezone($timezone)->Format($dateFormat), $label); $label = str_replace('{resourcename}', $reservation->ResourceName, $label); $label = str_replace('{participants}', trim(implode(', ', $reservation->ParticipantNames)), $label); $label = str_replace('{invitees}', trim(implode(', ', $reservation->InviteeNames)), $label); $matches = array(); preg_match_all('/\\{(att\\d+?)\\}/', $format, $matches); $matches = $matches[0]; if (count($matches) > 0) { for ($m = 0; $m < count($matches); $m++) { $id = filter_var($matches[$m], FILTER_SANITIZE_NUMBER_INT); $value = $reservation->GetAttributeValue($id); $label = str_replace($matches[$m], $value, $label); } } if (BookedStringHelper::Contains($label, '{reservationAttributes}')) { $attributesLabel = new StringBuilder(); $attributes = $this->attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION); foreach ($attributes as $attribute) { $attributesLabel->Append($attribute->Label() . ': ' . $reservation->GetAttributeValue($attribute->Id()) . ', '); } $label = str_replace('{reservationAttributes}', rtrim($attributesLabel->ToString(), ', '), $label); } return $label; }
/** * @param array|IReservedItemView[] $conflicts * @return string */ protected function GetErrorString($conflicts) { $errorString = new StringBuilder(); $errorString->Append(Resources::GetInstance()->GetString('ConflictingReservationDates')); $errorString->Append("\n"); $format = Resources::GetInstance()->GetDateFormat(ResourceKeys::DATE_GENERAL); $dates = array(); /** @var IReservedItemView $conflict */ foreach ($conflicts as $conflict) { $dates[] = sprintf('%s - %s', $conflict->GetStartDate()->ToTimezone($this->timezone)->Format($format), $conflict->GetResourceName()); } $uniqueDates = array_unique($dates); sort($uniqueDates); foreach ($uniqueDates as $date) { $errorString->Append($date); $errorString->Append("\n"); } return $errorString->ToString(); }
/** * @param array $conflicts * @return string */ protected function GetErrorString($conflicts) { $errorString = new StringBuilder(); $errorString->Append(Resources::GetInstance()->GetString('ConflictingAccessoryDates')); $errorString->AppendLine(); $format = Resources::GetInstance()->GetDateFormat(ResourceKeys::DATE_GENERAL); foreach ($conflicts as $conflict) { $errorString->Append(sprintf('(%s) %s', $conflict['date']->ToTimezone($this->timezone)->Format($format), $conflict['name'])); $errorString->AppendLine(); } return $errorString->ToString(); }
public function CreatePagination($params, &$smarty) { /** @var PageInfo $pageInfo */ $pageInfo = $params['pageInfo']; if (empty($pageInfo->Total)) { return ''; } $sb = new StringBuilder(); $viewAllText = $this->Resources->GetString('ViewAll'); $sb->Append('<p><br/>'); $sb->Append($this->Resources->GetString('Rows')); $sb->Append(": {$pageInfo->ResultsStart} - {$pageInfo->ResultsEnd} ({$pageInfo->Total})"); $sb->Append('<span> </span>'); if ($pageInfo->TotalPages != 1) { $sb->Append($this->CreatePageLink(array('page' => 1, 'size' => '-1', 'text' => $viewAllText), $smarty)); } $sb->Append('</p><p>'); $sb->Append($this->Resources->GetString('Page')); $sb->Append(': '); $size = $pageInfo->PageSize; $currentPage = $pageInfo->CurrentPage; for ($i = 1; $i <= $pageInfo->TotalPages; $i++) { $isCurrent = $i == $currentPage; $sb->Append($this->CreatePageLink(array('page' => $i, 'size' => $size, 'iscurrent' => $isCurrent), $smarty)); $sb->Append(" "); } $sb->Append('</p>'); return $sb->ToString(); }