示例#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);
 }
示例#2
0
文件: Url.php 项目: Trideon/gigolo
 /**
  * @param $urlFragment string
  * @return Url
  */
 public function Add($urlFragment)
 {
     if (!BookedStringHelper::EndsWith($this->url, '/')) {
         $this->url .= '/';
     }
     $this->url .= urlencode($urlFragment);
     return $this;
 }
示例#3
0
 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 . '/';
 }
示例#4
0
 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();"));
             }
         }
     }
 }
示例#5
0
文件: Cookie.php 项目: JoseTfg/Booked
 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;
 }
示例#6
0
文件: Paths.php 项目: hugutux/booked
 /**
  * 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;
 }
示例#7
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;
 }
示例#8
0
文件: Page.php 项目: Trideon/gigolo
 public function RedirectResume($url)
 {
     if (!BookedStringHelper::StartsWith($url, $this->path)) {
         $url = $this->path . $url;
     }
     header("Location: {$url}");
     die;
 }
示例#9
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;
 }
示例#10
0
 public function SetRegistrationUrl($url)
 {
     $this->Set('RegisterUrl', empty($url) ? Pages::REGISTRATION : $url);
     if (BookedStringHelper::StartsWith($url, 'http')) {
         $this->Set('RegisterUrlNew', "target='_new'");
     }
 }
示例#11
0
文件: Date.php 项目: JoseTfg/Booked
 /**
  * @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;
 }
示例#12
0
 /**
  * @param string|ISqlFilterColumn $columnName
  * @param string $columnValue
  */
 public function __construct($columnName, $columnValue)
 {
     if (!BookedStringHelper::Contains($columnValue, '%')) {
         $columnValue = '%' . $columnValue . '%';
     }
     parent::__construct($columnName, $columnValue);
 }
示例#13
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>";
 }
示例#14
0
 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;
 }
示例#15
0
 /**
  * @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 . '/';
     }
 }
示例#16
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, '/');
 }
示例#17
0
 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));
     }
 }