From 3de118dae7fdc17e117330078846f538254411d0 Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 20 Nov 2008 18:31:26 +0000 Subject: Refs #452: Calendar interface on entities git-svn-id: https://code.elgg.org/elgg/trunk@2480 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/calendar.php | 2 +- engine/lib/entities.php | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'engine') diff --git a/engine/lib/calendar.php b/engine/lib/calendar.php index 15f7fff2e..70952cf7f 100644 --- a/engine/lib/calendar.php +++ b/engine/lib/calendar.php @@ -15,7 +15,7 @@ * Calendar interface for events. * */ - interface Noteable { + interface Notable { /** * Calendar functionality. diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 4da55d6b2..99c8bdca6 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -26,6 +26,7 @@ * @subpackage Core */ abstract class ElggEntity implements + Notable, // Calendar interface Exportable, // Allow export of data Importable, // Allow import of data Loggable, // Can events related to this object class be logged @@ -710,6 +711,42 @@ return $res; } + // NOTABLE INTERFACE /////////////////////////////////////////////////////////////// + + /** + * Calendar functionality. + * This function sets the time of an object on a calendar listing. + * + * @param int $hour If ommitted, now is assumed. + * @param int $minute If ommitted, now is assumed. + * @param int $second If ommitted, now is assumed. + * @param int $day If ommitted, now is assumed. + * @param int $month If ommitted, now is assumed. + * @param int $year If ommitted, now is assumed. + * @param int $duration Duration of event, remainder of the day is assumed. + */ + public function setCalendarTimeAndDuration($hour = NULL, $minute = NULL, $second = NULL, $day = NULL, $month = NULL, $year = NULL, $duration = NULL) + { + $start = mktime($hour, $minute, $second, $month, $day, $year); + $end = $start + abs($duration); + if (!$duration) + $end = get_day_end($day,$month,$year); + + $this->calendar_start = $start; + + return true; + } + + /** + * Return the start timestamp. + */ + public function getCalendarStartTime() { return (int)$this->calendar_start; } + + /** + * Return the end timestamp. + */ + public function getCalendarEndTime() { return (int)$this->calendar_end; } + // EXPORTABLE INTERFACE //////////////////////////////////////////////////////////// /** -- cgit v1.2.3