Exemplo n.º 1
0
 /**
  * @param string $dateString
  * @param UserSession $session
  * @return Date
  */
 public static function GetDate($dateString, UserSession $session)
 {
     if (BookedStringHelper::Contains($dateString, 'T')) {
         return Date::ParseExact($dateString);
     }
     return Date::Parse($dateString, $session->Timezone);
 }
Exemplo n.º 2
0
 /**
  * @param string $url
  */
 public function __construct($url)
 {
     $this->url = $url;
     $this->hasQuestionMark = BookedStringHelper::Contains($url, '?');
 }
Exemplo n.º 3
0
 private function CleanUsername($username)
 {
     if (BookedStringHelper::Contains($username, '@')) {
         Log::Debug('ActiveDirectory - Username %s appears to be an email address. Cleaning...', $username);
         $parts = explode('@', $username);
         $username = $parts[0];
     }
     if (BookedStringHelper::Contains($username, '\\')) {
         Log::Debug('ActiveDirectory - Username %s appears contain a domain. Cleaning...', $username);
         $parts = explode('\\', $username);
         $username = $parts[1];
     }
     return $username;
 }
Exemplo n.º 4
0
 /**
  * @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;
 }
Exemplo n.º 5
0
 /**
  * @param string $dateString
  * @return Date
  */
 public static function ParseExact($dateString)
 {
     if (empty($dateString)) {
         return NullDate::Instance();
     }
     $offset = '';
     $strLen = strlen($dateString);
     $hourAdjustment = 0;
     $minuteAdjustment = 0;
     if ($strLen > 5) {
         $offset = substr($dateString, -5);
         $hourAdjustment = substr($offset, 1, 2);
         $minuteAdjustment = substr($offset, 3, 2);
     }
     if (BookedStringHelper::Contains($offset, '+')) {
         $hourAdjustment *= -1;
         $minuteAdjustment *= -1;
     }
     $parsed = date_parse($dateString);
     $d = Date::Create($parsed['year'], $parsed['month'], $parsed['day'], $parsed['hour'] + $hourAdjustment, $parsed['minute'] + $minuteAdjustment, $parsed['second'], 'UTC');
     return $d;
 }
Exemplo n.º 6
0
 /**
  * @param string|ISqlFilterColumn $columnName
  * @param string $columnValue
  */
 public function __construct($columnName, $columnValue)
 {
     if (!BookedStringHelper::Contains($columnValue, '%')) {
         $columnValue = '%' . $columnValue . '%';
     }
     parent::__construct($columnName, $columnValue);
 }
Exemplo n.º 7
0
 public function IncludeCssFile($params, &$smarty)
 {
     $versionNumber = Configuration::VERSION;
     $src = $params['src'];
     if (!BookedStringHelper::Contains($src, '/')) {
         $src = "css/{$src}";
     }
     echo "<link rel='stylesheet' type='text/css' href='{$this->RootPath}{$src}?v={$versionNumber}'></link>";
 }
Exemplo n.º 8
0
 public function GetRow($row)
 {
     $reservationAttributes = null;
     $userAttributes = null;
     $resourceAttributes = null;
     $resourceTypeAttributes = null;
     if (array_key_exists(ColumnNames::ATTRIBUTE_LIST, $row)) {
         $reservationAttributes = CustomAttributes::Parse($row[ColumnNames::ATTRIBUTE_LIST]);
     }
     if (array_key_exists(ColumnNames::USER_ATTRIBUTE_LIST, $row)) {
         $userAttributes = CustomAttributes::Parse($row[ColumnNames::USER_ATTRIBUTE_LIST]);
     }
     if (array_key_exists(ColumnNames::RESOURCE_ATTRIBUTE_LIST, $row)) {
         $resourceAttributes = CustomAttributes::Parse($row[ColumnNames::RESOURCE_ATTRIBUTE_LIST]);
     }
     if (array_key_exists(ColumnNames::RESOURCE_TYPE_ATTRIBUTE_LIST, $row)) {
         $resourceTypeAttributes = CustomAttributes::Parse($row[ColumnNames::RESOURCE_TYPE_ATTRIBUTE_LIST]);
     }
     $formattedRow = array();
     foreach ($this->columns as $key => $column) {
         if ($key == ColumnNames::TOTAL || $key == ColumnNames::TOTAL_TIME) {
             $this->sum += $row[$key];
             $this->sumColumn = $column;
         }
         if (BookedStringHelper::Contains($key, 'attribute')) {
             $this->AddCustomAttributes(CustomAttributeCategory::RESERVATION, $reservationAttributes, $formattedRow, $key, $column);
             $this->AddCustomAttributes(CustomAttributeCategory::USER, $userAttributes, $formattedRow, $key, $column);
             $this->AddCustomAttributes(CustomAttributeCategory::RESOURCE, $resourceAttributes, $formattedRow, $key, $column);
             $this->AddCustomAttributes(CustomAttributeCategory::RESOURCE_TYPE, $resourceTypeAttributes, $formattedRow, $key, $column);
         } else {
             $formattedRow[] = new ReportCell($column->GetData($row[$key]), $column->GetChartData($row, $key), $column->GetChartColumnType(), $column->GetChartGroup());
         }
     }
     return $formattedRow;
 }