|
|
|
@ -1,11 +1,13 @@ |
|
|
|
<?php |
|
|
|
/** |
|
|
|
* Copyright (c) 2011 Jakob Sack <mail@jakobsack.de> |
|
|
|
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> |
|
|
|
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> |
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
|
|
* later. |
|
|
|
* See the COPYING-README file. |
|
|
|
*/ |
|
|
|
/* |
|
|
|
/** |
|
|
|
* |
|
|
|
* The following SQL statement is just a help for developers and will not be |
|
|
|
* executed! |
|
|
|
@ -330,7 +332,12 @@ class OC_Calendar_Object{ |
|
|
|
public static function getUTCforMDB($datetime){ |
|
|
|
return date('Y-m-d H:i', $datetime->format('U') - $datetime->getOffset()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the DTEND of an $vevent object |
|
|
|
* @param object $vevent vevent object |
|
|
|
* @return object |
|
|
|
*/ |
|
|
|
public static function getDTEndFromVEvent($vevent){ |
|
|
|
if ($vevent->DTEND) { |
|
|
|
$dtend = $vevent->DTEND; |
|
|
|
@ -355,9 +362,12 @@ class OC_Calendar_Object{ |
|
|
|
} |
|
|
|
return $dtend; |
|
|
|
} |
|
|
|
|
|
|
|
public static function getRepeatOptions($l10n) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for the repeat rule of an repeating event |
|
|
|
* @return array - valid inputs for the repeat rule of an repeating event |
|
|
|
*/ |
|
|
|
public static function getRepeatOptions($l10n){ |
|
|
|
return array( |
|
|
|
'doesnotrepeat' => $l10n->t('Does not repeat'), |
|
|
|
'daily' => $l10n->t('Daily'), |
|
|
|
@ -368,26 +378,35 @@ class OC_Calendar_Object{ |
|
|
|
'yearly' => $l10n->t('Yearly') |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
public static function getEndOptions($l10n) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for the end of an repeating event |
|
|
|
* @return array - valid inputs for the end of an repeating events |
|
|
|
*/ |
|
|
|
public static function getEndOptions($l10n){ |
|
|
|
return array( |
|
|
|
'never' => $l10n->t('never'), |
|
|
|
'count' => $l10n->t('by occurrences'), |
|
|
|
'date' => $l10n->t('by date') |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
public static function getMonthOptions($l10n) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an monthly repeating event |
|
|
|
* @return array - valid inputs for monthly repeating events |
|
|
|
*/ |
|
|
|
public static function getMonthOptions($l10n){ |
|
|
|
return array( |
|
|
|
'monthday' => $l10n->t('by monthday'), |
|
|
|
'weekday' => $l10n->t('by weekday') |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
public static function getWeeklyOptions($l10n) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an weekly repeating event |
|
|
|
* @return array - valid inputs for weekly repeating events |
|
|
|
*/ |
|
|
|
public static function getWeeklyOptions($l10n){ |
|
|
|
return array( |
|
|
|
'MO' => $l10n->t('Monday'), |
|
|
|
'TU' => $l10n->t('Tuesday'), |
|
|
|
@ -398,9 +417,12 @@ class OC_Calendar_Object{ |
|
|
|
'SU' => $l10n->t('Sunday') |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
public static function getWeekofMonth($l10n) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an monthly repeating event which occurs on specific weeks of the month |
|
|
|
* @return array - valid inputs for monthly repeating events |
|
|
|
*/ |
|
|
|
public static function getWeekofMonth($l10n){ |
|
|
|
return array( |
|
|
|
'auto' => $l10n->t('events week of month'), |
|
|
|
'1' => $l10n->t('first'), |
|
|
|
@ -411,7 +433,11 @@ class OC_Calendar_Object{ |
|
|
|
'-1' => $l10n->t('last') |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an yearly repeating event which occurs on specific days of the year |
|
|
|
* @return array - valid inputs for yearly repeating events |
|
|
|
*/ |
|
|
|
public static function getByYearDayOptions(){ |
|
|
|
$return = array(); |
|
|
|
foreach(range(1,366) as $num){ |
|
|
|
@ -419,7 +445,11 @@ class OC_Calendar_Object{ |
|
|
|
} |
|
|
|
return $return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an yearly or monthly repeating event which occurs on specific days of the month |
|
|
|
* @return array - valid inputs for yearly or monthly repeating events |
|
|
|
*/ |
|
|
|
public static function getByMonthDayOptions(){ |
|
|
|
$return = array(); |
|
|
|
foreach(range(1,31) as $num){ |
|
|
|
@ -427,7 +457,11 @@ class OC_Calendar_Object{ |
|
|
|
} |
|
|
|
return $return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an yearly repeating event which occurs on specific month of the year |
|
|
|
* @return array - valid inputs for yearly repeating events |
|
|
|
*/ |
|
|
|
public static function getByMonthOptions($l10n){ |
|
|
|
return array( |
|
|
|
'1' => $l10n->t('January'), |
|
|
|
@ -444,7 +478,11 @@ class OC_Calendar_Object{ |
|
|
|
'12' => $l10n->t('December') |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an yearly repeating event |
|
|
|
* @return array - valid inputs for yearly repeating events |
|
|
|
*/ |
|
|
|
public static function getYearOptions($l10n){ |
|
|
|
return array( |
|
|
|
'bydate' => $l10n->t('by events date'), |
|
|
|
@ -453,13 +491,21 @@ class OC_Calendar_Object{ |
|
|
|
'bydaymonth' => $l10n->t('by day and month') |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the options for an yearly repeating event which occurs on specific week numbers of the year |
|
|
|
* @return array - valid inputs for yearly repeating events |
|
|
|
*/ |
|
|
|
public static function getByWeekNoOptions(){ |
|
|
|
return range(1, 52); |
|
|
|
} |
|
|
|
|
|
|
|
public static function validateRequest($request) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief validates a request |
|
|
|
* @param array $request |
|
|
|
* @return mixed (array / boolean) |
|
|
|
*/ |
|
|
|
public static function validateRequest($request){ |
|
|
|
$errnum = 0; |
|
|
|
$errarr = array('title'=>'false', 'cal'=>'false', 'from'=>'false', 'fromtime'=>'false', 'to'=>'false', 'totime'=>'false', 'endbeforestart'=>'false'); |
|
|
|
if($request['title'] == ''){ |
|
|
|
@ -606,17 +652,24 @@ class OC_Calendar_Object{ |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
protected static function checkTime($time) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief validates time |
|
|
|
* @param string $time |
|
|
|
* @return boolean |
|
|
|
*/ |
|
|
|
protected static function checkTime($time){ |
|
|
|
list($hours, $minutes) = explode(':', $time); |
|
|
|
return empty($time) |
|
|
|
|| $hours < 0 || $hours > 24 |
|
|
|
|| $minutes < 0 || $minutes > 60; |
|
|
|
} |
|
|
|
|
|
|
|
public static function createVCalendarFromRequest($request) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief creates an VCalendar Object from the request data |
|
|
|
* @param array $request |
|
|
|
* @return object created $vcalendar |
|
|
|
*/ public static function createVCalendarFromRequest($request){ |
|
|
|
$vcalendar = new OC_VObject('VCALENDAR'); |
|
|
|
$vcalendar->add('PRODID', 'ownCloud Calendar'); |
|
|
|
$vcalendar->add('VERSION', '2.0'); |
|
|
|
@ -629,9 +682,14 @@ class OC_Calendar_Object{ |
|
|
|
$vevent->setUID(); |
|
|
|
return self::updateVCalendarFromRequest($request, $vcalendar); |
|
|
|
} |
|
|
|
|
|
|
|
public static function updateVCalendarFromRequest($request, $vcalendar) |
|
|
|
{ |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief updates an VCalendar Object from the request data |
|
|
|
* @param array $request |
|
|
|
* @param object $vcalendar |
|
|
|
* @return object updated $vcalendar |
|
|
|
*/ |
|
|
|
public static function updateVCalendarFromRequest($request, $vcalendar){ |
|
|
|
$title = $request["title"]; |
|
|
|
$location = $request["location"]; |
|
|
|
$categories = $request["categories"]; |
|
|
|
@ -811,29 +869,52 @@ class OC_Calendar_Object{ |
|
|
|
$vevent->setString('DESCRIPTION', $description); |
|
|
|
$vevent->setString('CATEGORIES', $categories); |
|
|
|
|
|
|
|
/*if($repeat == "true"){ |
|
|
|
/**if($repeat == "true"){ |
|
|
|
$vevent->RRULE = $repeat; |
|
|
|
}*/ |
|
|
|
|
|
|
|
return $vcalendar; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the owner of an object |
|
|
|
* @param integer $id |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
public static function getowner($id){ |
|
|
|
$event = self::find($id); |
|
|
|
$cal = OC_Calendar_Calendar::find($event['calendarid']); |
|
|
|
return $cal['userid']; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief returns the calendarid of an object |
|
|
|
* @param integer $id |
|
|
|
* @return integer |
|
|
|
*/ |
|
|
|
public static function getCalendarid($id){ |
|
|
|
$event = self::find($id); |
|
|
|
return $event['calendarid']; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief checks if an object is repeating |
|
|
|
* @param integer $id |
|
|
|
* @return boolean |
|
|
|
*/ |
|
|
|
public static function isrepeating($id){ |
|
|
|
$event = self::find($id); |
|
|
|
return ($event['repeating'] == 1)?true:false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @brief converts the start_dt and end_dt to a new timezone |
|
|
|
* @param object $dtstart |
|
|
|
* @param object $dtend |
|
|
|
* @param boolean $allday |
|
|
|
* @param string $tz |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public static function generateStartEndDate($dtstart, $dtend, $allday, $tz){ |
|
|
|
$start_dt = $dtstart->getDateTime(); |
|
|
|
$end_dt = $dtend->getDateTime(); |
|
|
|
|