Changeset View
Changeset View
Standalone View
Standalone View
lib/Kolab/FreeBusy/Utils.php
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | class Utils | ||||
* Getter for the free/busy period start time | * Getter for the free/busy period start time | ||||
* | * | ||||
* @return int Unix timestamp | * @return int Unix timestamp | ||||
*/ | */ | ||||
public static function periodStart() | public static function periodStart() | ||||
{ | { | ||||
// use date from HTTP query | // use date from HTTP query | ||||
if (!empty($_GET['dtstart'])) { | if (!empty($_GET['dtstart'])) { | ||||
return self::periodStartDT()->format('u'); | return self::periodStartDT()->format('U'); | ||||
} | } | ||||
// Should probably be a setting. For now, do 8 weeks in the past | // Should probably be a setting. For now, do 8 weeks in the past | ||||
return time() - (60 * 60 * 24 * 7 * 8); | return time() - (60 * 60 * 24 * 7 * 8); | ||||
} | } | ||||
/** | /** | ||||
* Getter for the free/busy period start time | * Getter for the free/busy period start time | ||||
* | * | ||||
* @return object DateTime instance | * @return object DateTime instance | ||||
*/ | */ | ||||
public static function periodStartDT() | public static function periodStartDT() | ||||
{ | { | ||||
// use date from HTTP query | // use date from HTTP query | ||||
if (!empty($_GET['dtstart']) && | if (!empty($_GET['dtstart']) && | ||||
($dtstart = \rcube_utils::anytodatetime(filter_input(INPUT_GET, 'dtstart', FILTER_SANITIZE_STRING)))) { | ($dtstart = filter_input(INPUT_GET, 'dtstart', FILTER_SANITIZE_STRING)) | ||||
return $dtstart; | ) { | ||||
try { | |||||
return new \DateTime($dtstart, new \DateTimezone('UTC')); | |||||
} | |||||
catch (Exception $e) { | |||||
// ignore | |||||
} | |||||
} | } | ||||
// Should probably be a setting. For now, do 8 weeks in the past | // Should probably be a setting. For now, do 8 weeks in the past | ||||
return new \DateTime('now - 8 weeks 00:00:00', new \DateTimezone('UTC')); | return new \DateTime('now - 8 weeks 00:00:00', new \DateTimezone('UTC')); | ||||
} | } | ||||
/** | /** | ||||
* Getter for the free/busy period end time | * Getter for the free/busy period end time | ||||
* | * | ||||
* @return int Unix timestamp | * @return int Unix timestamp | ||||
*/ | */ | ||||
public static function periodEnd() | public static function periodEnd() | ||||
{ | { | ||||
// use date from HTTP query | // use date from HTTP query | ||||
if (!empty($_GET['dtend'])) { | if (!empty($_GET['dtend'])) { | ||||
return self::periodEndDT()->format('u'); | return self::periodEndDT()->format('U'); | ||||
} | } | ||||
// Should probably be a setting. For now, do 16 weeks into the future | // Should probably be a setting. For now, do 16 weeks into the future | ||||
return time() + (60 * 60 * 24 * 7 * 16); | return time() + (60 * 60 * 24 * 7 * 16); | ||||
} | } | ||||
/** | /** | ||||
* Getter for the free/busy period end time | * Getter for the free/busy period end time | ||||
* | * | ||||
* @return object DateTime instance | * @return object DateTime instance | ||||
*/ | */ | ||||
public static function periodEndDT() | public static function periodEndDT() | ||||
{ | { | ||||
// use date from HTTP query | // use date from HTTP query | ||||
if (!empty($_GET['dtend']) && | if (!empty($_GET['dtend']) && | ||||
($dtend = \rcube_utils::anytodatetime(filter_input(INPUT_GET, 'dtend', FILTER_SANITIZE_STRING)))) { | ($dtend = filter_input(INPUT_GET, 'dtend', FILTER_SANITIZE_STRING)) | ||||
return $dtend; | ) { | ||||
try { | |||||
return new \DateTime($dtend, new \DateTimezone('UTC')); | |||||
} | |||||
catch (Exception $e) { | |||||
// ignore | |||||
} | |||||
} | } | ||||
// Should probably be a setting. For now, do 8 weeks in the past | // Should probably be a setting. For now, do 8 weeks in the past | ||||
return new \DateTime('now + 16 weeks 00:00:00', new \DateTimezone('UTC')); | return new \DateTime('now + 16 weeks 00:00:00', new \DateTimezone('UTC')); | ||||
} | } | ||||
/** | /** | ||||
* Returns an apparent empty Free/Busy list for the given user | * Returns an apparent empty Free/Busy list for the given user | ||||
Show All 14 Lines | public static function dummyVFreebusy($user) | ||||
$dummy .= "DTEND:" . gmdate($dtformat, self::periodEnd()) . "\n"; | $dummy .= "DTEND:" . gmdate($dtformat, self::periodEnd()) . "\n"; | ||||
$dummy .= "COMMENT:This is a dummy vfreebusy that indicates an empty calendar\n"; | $dummy .= "COMMENT:This is a dummy vfreebusy that indicates an empty calendar\n"; | ||||
$dummy .= "FREEBUSY:19700101T000000Z/19700101T000000Z\n"; | $dummy .= "FREEBUSY:19700101T000000Z/19700101T000000Z\n"; | ||||
$dummy .= "END:VFREEBUSY\n"; | $dummy .= "END:VFREEBUSY\n"; | ||||
$dummy .= "END:VCALENDAR\n"; | $dummy .= "END:VCALENDAR\n"; | ||||
return $dummy; | return $dummy; | ||||
} | } | ||||
} | } | ||||
No newline at end of file |