class OC_Calendar_App{
const CALENDAR = 'calendar';
const EVENT = 'event';
- /*
+ /**
* @brief language object for calendar app
*/
public static $l10n;
- /*
+ /**
* @brief categories of the user
*/
protected static $categories = null;
- /*
+ /**
* @brief timezone of the user
*/
public static $tz;
- /*
+ /**
* @brief returns informations about a calendar
* @param int $id - id of the calendar
* @param bool $security - check access rights or not
return $calendar;
}
- /*
+ /**
* @brief returns informations about an event
* @param int $id - id of the event
* @param bool $security - check access rights or not
return $event;
}
- /*
+ /**
* @brief returns the parsed calendar data
* @param int $id - id of the event
* @param bool $security - check access rights or not
return $vobject;
}
- /*
+ /**
* @brief checks if an event was edited and dies if it was
* @param (object) $vevent - vevent object of the event
* @param (int) $lastmodified - time of last modification as unix timestamp
return true;
}
- /*
+ /**
* @brief returns the default categories of ownCloud
* @return (array) $categories
*/
);
}
- /*
+ /**
* @brief returns the vcategories object of the user
* @return (object) $vcategories
*/
return self::$categories;
}
- /*
+ /**
* @brief returns the categories of the vcategories object
* @return (array) $categories
*/
self::getVCategories()->loadFromVObject($object, true);
}
}
-
+
+ /**
+ * @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(){
return OC_Calendar_Object::getRepeatOptions(self::$l10n);
}
- /*
+ /**
* @brief returns the options for the end of an repeating event
* @return array - valid inputs for the end of an repeating events
*/
return OC_Calendar_Object::getEndOptions(self::$l10n);
}
- /*
+ /**
* @brief returns the options for an monthly repeating event
* @return array - valid inputs for monthly repeating events
*/
return OC_Calendar_Object::getMonthOptions(self::$l10n);
}
- /*
+ /**
* @brief returns the options for an weekly repeating event
* @return array - valid inputs for weekly repeating events
*/
return OC_Calendar_Object::getWeeklyOptions(self::$l10n);
}
- /*
+ /**
* @brief returns the options for an yearly repeating event
* @return array - valid inputs for yearly repeating events
*/
return OC_Calendar_Object::getYearOptions(self::$l10n);
}
- /*
+ /**
* @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
*/
return OC_Calendar_Object::getByYearDayOptions();
}
- /*
+ /**
* @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
*/
return OC_Calendar_Object::getByMonthOptions(self::$l10n);
}
- /*
+ /**
* @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
*/
return OC_Calendar_Object::getByWeekNoOptions();
}
- /*
+ /**
* @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
*/
return OC_Calendar_Object::getByMonthDayOptions();
}
- /*
+ /**
* @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
*/
return OC_Calendar_Object::getWeekofMonth(self::$l10n);
}
- /*
+ /**
* @brief checks the access for a calendar / an event
* @param (int) $id - id of the calendar / event
* @param (string) $type - type of the id (calendar/event)
}
}
- /*
+ /**
* @brief analyses the parameter for calendar parameter and returns the objects
* @param (string) $calendarid - calendarid
* @param (int) $start - unixtimestamp of start
return $events;
}
- /*
+ /**
* @brief generates the output for an event which will be readable for our js
* @param (mixed) $event - event object / array
* @param (int) $start - DateTime object of start
* later.
* See the COPYING-README file.
*/
-/*
+/**
*
* The following SQL statement is just a help for developers and will not be
* executed!
return true;
}
- /*
+ /**
* @brief merges two calendars
* @param integer $id1
* @param integer $id2
return $userid;
}
- /*
+ /**
* @brief returns the possible color for calendars
* @return array
*/
);
}
- /*
+ /**
* @brief generates the Event Source Info for our JS
* @param array $calendar calendar data
* @return array
* later.
* See the COPYING-README file.
*/
-/*
+/**
* This class does export and converts all times to UTC
*/
class OC_Calendar_Export{
- /*
+ /**
* @brief Use one of these constants as second parameter if you call OC_Calendar_Export::export()
*/
const CALENDAR = 'calendar';
const EVENT = 'event';
- /*
+ /**
* @brief export a calendar or an event
* @param integer $id id of calendar / event
* @param string $type use OC_Calendar_Export constants
return self::fixLineBreaks($return);
}
- /*
+ /**
* @brief exports a calendar and convert all times to UTC
* @param integer $id id of the calendar
* @return string
return $return;
}
- /*
+ /**
* @brief exports an event and convert all times to UTC
* @param integer $id id of the event
* @return string
return $return;
}
- /*
+ /**
* @brief generates the VEVENT with UTC dates
* @param array $event
* @return string
return $object->VEVENT->serialize();
}
- /*
+ /**
* @brief fixes new line breaks
* (fixes problems with Apple iCal)
* @param string $string to fix
<?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!
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;
}
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'),
'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'),
'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'),
'-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){
}
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){
}
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'),
'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'),
'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'] == ''){
}
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');
$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"];
$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();
* later.
* See the COPYING-README file.
*/
-/*
+/**
* This class manages the caching of repeating events
* Events will be cached for the current year ± 5 years
*/
class OC_Calendar_Repeat{
- /*
+ /**
* @brief returns the cache of an event
* @param (int) $id - id of the event
* @return (array)
}
return $return;
}
- /*
+ /**
* @brief returns the cache of an event in a specific peroid
* @param (int) $id - id of the event
* @param (DateTime) $from - start for period in UTC
}
return $return;
}
- /*
+ /**
* @brief returns the cache of all repeating events of a calendar
* @param (int) $id - id of the calendar
* @return (array)
}
return $return;
}
- /*
+ /**
* @brief returns the cache of all repeating events of a calendar in a specific period
* @param (int) $id - id of the event
* @param (string) $from - start for period in UTC
}
return $return;
}
- /*
+ /**
* @brief generates the cache the first time
* @param (int) id - id of the event
* @return (bool)
}
return true;
}
- /*
+ /**
* @brief generates the cache the first time for all repeating event of an calendar
* @param (int) id - id of the calendar
* @return (bool)
}
return true;
}
- /*
+ /**
* @brief updates an event that is already cached
* @param (int) id - id of the event
* @return (bool)
self::generate($id);
return true;
}
- /*
+ /**
* @brief updates all repating events of a calendar that are already cached
* @param (int) id - id of the calendar
* @return (bool)
self::generateCalendar($id);
return true;
}
- /*
+ /**
* @brief checks if an event is already cached
* @param (int) id - id of the event
* @return (bool)
return false;
}
}
- /*
+ /**
* @brief checks if an event is already cached in a specific period
* @param (int) id - id of the event
* @param (DateTime) $from - start for period in UTC
}
}
- /*
+ /**
* @brief checks if a whole calendar is already cached
* @param (int) id - id of the calendar
* @return (bool)
return true;
}
}
- /*
+ /**
* @brief removes the cache of an event
* @param (int) id - id of the event
* @return (bool)
$stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_repeat WHERE eventid = ?');
$stmt->execute(array($id));
}
- /*
+ /**
* @brief removes the cache of all events of a calendar
* @param (int) id - id of the calendar
* @return (bool)
* later.
* See the COPYING-README file.
*/
-/*
+/**
* This class manages shared calendars
*/
class OC_Calendar_Share{
const CALENDAR = 'calendar';
const EVENT = 'event';
- /*
+ /**
* @brief: returns informations about all calendar or events which users are sharing with the user - userid
* @param: string $userid - id of the user
* @param: string $type - use const self::CALENDAR or self::EVENT
}
return $return;
}
- /*
+ /**
* @brief: returns all users a calendar / event is shared with
* @param: integer id - id of the calendar / event
* @param: string $type - use const self::CALENDAR or self::EVENT
}
return $users;
}
- /*
+ /**
* @brief: shares a calendar / event
* @param: string $owner - userid of the owner
* @param: string $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public)
return true;
}
}
- /*
+ /**
* @brief: stops sharing a calendar / event
* @param: string $owner - userid of the owner
* @param: string $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public)
}
return true;
}
- /*
+ /**
* @brief: changes the permission for a calendar / event
* @param: string $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public)
* @param: string $sharetype - type of sharing (can be: user/group/public)
$stmt->execute(array($permission, $share, $sharetype, $id));
return true;
}
- /*
+ /**
* @brief: generates a token for public calendars / events
* @return: string $token
*/
$token = md5($string);
return substr($token, rand(0,16), 15);
}
- /*
+ /**
* @brief: checks if it is already shared
* @param: string $owner - userid of the owner
* @param: string $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public)
}
return $active_where;
}
- /*
+ /**
* @brief: checks the permission for editing an event
* @param: string $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public)
* @param: string $id - id of the calendar / event
}
return false;
}
- /*
+ /**
* @brief: checks the access of
* @param: string $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public)
* @param: string $id - id of the calendar / event
return false;
}
}
- /*
+ /**
* @brief: returns the calendardata of an event or a calendar
* @param: string $token - token which should be searched
* @return: mixed - bool if false, array with type and id if true
return $return;
}
- /*
+ /**
* @brief sets the active status of the calendar
* @param string
*/
$stmt->execute(array($active, $share, $id));
}
- /*
+ /**
* @brief deletes all shared calendars / events after a user was deleted
* @param string $userid
* @return boolean
return true;
}
- /*
+ /**
* @brief deletes all shared events of a calendar
* @param integer $calid
* @return boolean
return true;
}
- /*
+ /**
* @brief deletes all shares of an event
* @param integer $eventid
* @return boolean