/** * @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); }
/** * @param $urlFragment string * @return Url */ public function Add($urlFragment) { if (!BookedStringHelper::EndsWith($this->url, '/')) { $this->url .= '/'; } $this->url .= urlencode($urlFragment); return $this; }
public function GetPath() { $path = $this->GetConfig('wp_includes.directory'); if (!BookedStringHelper::StartsWith($path, '/')) { $path = ROOT_DIR . "/{$path}"; } if (BookedStringHelper::EndsWith($path, '/')) { return $path; } return $path . '/'; }
private static function AddSuites(PHPUnit_Framework_TestSuite $suite) { $dir = ROOT_DIR . 'tests'; $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST); /** @var $path SplFileInfo */ foreach ($iterator as $path) { if (!$path->isDir()) { $file = $path->getFilename(); if (BookedStringHelper::EndsWith($file, 'Suite.php')) { $testName = str_replace('.php', '', $file); $fullPath = "{$path->getPath()}/{$file}"; require_once $fullPath; $suite->addTest(eval("return {$testName}::suite();")); } } } }
public function __construct($name, $value, $expiration = null, $path = null) { $domain = null; if (is_null($expiration)) { $expiration = Date::Now()->AddDays(30)->TimeStamp(); } if (is_null($path)) { $path = Configuration::Instance()->GetScriptUrl(); } if (BookedStringHelper::StartsWith($path, 'http')) { $parts = parse_url($path); $path = isset($parts['path']) ? $parts['path'] : ''; } $this->Name = $name; $this->Value = $value; $this->Expiration = $expiration; // date(DATE_COOKIE, $expiration); $this->Path = $path; }
/** * Filesystem directory for storing reservation attachments. Always contains trailing slash * * @static * @return string */ public static function ReservationAttachments() { $uploadDir = Configuration::Instance()->GetSectionKey(ConfigSection::UPLOADS, ConfigKeys::UPLOAD_RESERVATION_ATTACHMENTS); if (empty($uploadDir)) { $uploadDir = ROOT_DIR . 'uploads/reservation'; } if (!is_dir($uploadDir)) { $uploadDir = ROOT_DIR . $uploadDir; } if (!BookedStringHelper::EndsWith($uploadDir, '/')) { $uploadDir = $uploadDir . '/'; } if (!is_dir($uploadDir)) { Log::Debug('Could not find directory %s. Attempting to create it', $uploadDir); $created = mkdir($uploadDir); if ($created) { Log::Debug('Created %s', $uploadDir); } else { Log::Debug('Could not create %s', $uploadDir); } } return $uploadDir; }
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; }
public function RedirectResume($url) { if (!BookedStringHelper::StartsWith($url, $this->path)) { $url = $this->path . $url; } header("Location: {$url}"); die; }
/** * @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; }
public function SetRegistrationUrl($url) { $this->Set('RegisterUrl', empty($url) ? Pages::REGISTRATION : $url); if (BookedStringHelper::StartsWith($url, 'http')) { $this->Set('RegisterUrlNew', "target='_new'"); } }
/** * @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; }
/** * @param string|ISqlFilterColumn $columnName * @param string $columnValue */ public function __construct($columnName, $columnValue) { if (!BookedStringHelper::Contains($columnValue, '%')) { $columnValue = '%' . $columnValue . '%'; } parent::__construct($columnName, $columnValue); }
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>"; }
public function GetRow($row) { $attributes = null; if (array_key_exists(ColumnNames::ATTRIBUTE_LIST, $row)) { $attributes = CustomAttributes::Parse($row[ColumnNames::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 ($attributes != null && BookedStringHelper::StartsWith($key, 'attribute')) { $id = intval(str_replace('attribute', '', $key)); $attribute = $attributes->Get($id); $formattedRow[] = new ReportAttributeCell($column->GetData($attribute)); } else { $formattedRow[] = new ReportCell($column->GetData($row[$key]), $column->GetChartData($row, $key), $column->GetChartColumnType(), $column->GetChartGroup()); } } return $formattedRow; }
/** * @param $regex */ private function SetRegex($regex) { $this->regex = $regex; if (empty($this->regex)) { return; } if (!BookedStringHelper::StartsWith($this->regex, '/')) { $this->regex = '/' . $this->regex; } if (!BookedStringHelper::EndsWith($this->regex, '/')) { $this->regex = $this->regex . '/'; } }
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, '/'); }
private function AddCustomAttributes($category, CustomAttributes $attributes, &$formattedRow, $key, ReportColumn $column) { $prefix = $category . 'attribute'; if ($attributes != null && BookedStringHelper::StartsWith($key, $prefix)) { $id = intval(str_replace($prefix, '', $key)); $attribute = $attributes->Get($id); $formattedRow[] = new ReportAttributeCell($column->GetData($attribute)); } }