aboutsummaryrefslogtreecommitdiffstats
path: root/apps/calendar/lib/object.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/calendar/lib/object.php')
-rw-r--r--apps/calendar/lib/object.php37
1 files changed, 34 insertions, 3 deletions
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 33871cd3185..58d46ce6a7d 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -31,6 +31,34 @@ class OC_Calendar_Object{
}
/**
+ * @brief Returns all objects of a calendar between $start and $end
+ * @param integer $id
+ * @param DateTime $start
+ * @param DateTime $end
+ * @return array
+ *
+ * The objects are associative arrays. You'll find the original vObject
+ * in ['calendardata']
+ */
+ public static function allInPeriod($id, $start, $end){
+ $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?'
+ .' AND ((startdate >= ? AND startdate <= ? AND repeating = 0)'
+ .' OR (startdate <= ? AND repeating = 1))' );
+ $start = self::getUTCforMDB($start);
+ $end = self::getUTCforMDB($end);
+ $result = $stmt->execute(array($id,
+ $start, $end,
+ $end));
+
+ $calendarobjects = array();
+ while( $row = $result->fetchRow()){
+ $calendarobjects[] = $row;
+ }
+
+ return $calendarobjects;
+ }
+
+ /**
* @brief Returns an object
* @param integer $id
* @return associative array
@@ -279,6 +307,7 @@ class OC_Calendar_Object{
*/
public static function parse($data){
try {
+ Sabre_VObject_Reader::$elementMap['LAST-MODIFIED'] = 'Sabre_VObject_Element_DateTime';
$calendar = Sabre_VObject_Reader::read($data);
return $calendar;
} catch (Exception $e) {
@@ -398,7 +427,7 @@ class OC_Calendar_Object{
$errarr['endbeforestart'] = 'true';
$errnum++;
}
- if($fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
+ if(!$allday && $fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
list($tohours, $tominutes) = explode(':', $request['totime']);
list($fromhours, $fromminutes) = explode(':', $request['fromtime']);
if($tohours < $fromhours){
@@ -453,9 +482,11 @@ class OC_Calendar_Object{
$categories = isset($request["categories"]) ? $request["categories"] : null;
$allday = isset($request["allday"]);
$from = $request["from"];
- $fromtime = $request["fromtime"];
$to = $request["to"];
- $totime = $request["totime"];
+ if (!$allday){
+ $fromtime = $request['fromtime'];
+ $totime = $request['totime'];
+ }
$description = $request["description"];
//$repeat = $request["repeat"];
/*switch($request["repeatfreq"]){