summaryrefslogtreecommitdiffstats
path: root/apps/calendar/lib/app.php
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-04-13 16:40:10 -0400
committerGeorg Ehrke <dev@georgswebsite.de>2012-04-13 16:40:10 -0400
commitafcb0aee40230c68dd99f5ea2501b7ba7e444560 (patch)
tree5ccd10e78128c70e71a36ca9080a652a7bd833d5 /apps/calendar/lib/app.php
parent02dc34320978bfbcb30dea34b87808837586bb65 (diff)
parentb9f9228a22944184803a8835282862e468812c1d (diff)
downloadnextcloud-server-afcb0aee40230c68dd99f5ea2501b7ba7e444560.tar.gz
nextcloud-server-afcb0aee40230c68dd99f5ea2501b7ba7e444560.zip
fix merge conflicts
Diffstat (limited to 'apps/calendar/lib/app.php')
-rw-r--r--apps/calendar/lib/app.php79
1 files changed, 68 insertions, 11 deletions
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
index 58cc34658c6..ee1d39bc662 100644
--- a/apps/calendar/lib/app.php
+++ b/apps/calendar/lib/app.php
@@ -17,6 +17,7 @@ class OC_Calendar_App{
* @brief language object for calendar app
*/
public static $l10n;
+ protected static $categories = null;
/*
* @brief timezone of the user
@@ -106,19 +107,76 @@ class OC_Calendar_App{
}
return true;
}
- /*
- * THIS FUNCTION IS DEPRECATED AND WILL BE REMOVED SOON
- * @brief returns the valid categories
- * @return array - categories
+
+ protected static function getDefaultCategories()
+ {
+ return array(
+ self::$l10n->t('Birthday'),
+ self::$l10n->t('Business'),
+ self::$l10n->t('Call'),
+ self::$l10n->t('Clients'),
+ self::$l10n->t('Deliverer'),
+ self::$l10n->t('Holidays'),
+ self::$l10n->t('Ideas'),
+ self::$l10n->t('Journey'),
+ self::$l10n->t('Jubilee'),
+ self::$l10n->t('Meeting'),
+ self::$l10n->t('Other'),
+ self::$l10n->t('Personal'),
+ self::$l10n->t('Projects'),
+ self::$l10n->t('Questions'),
+ self::$l10n->t('Work'),
+ );
+ }
+
+ protected static function getVCategories() {
+ if (is_null(self::$categories)) {
+ self::$categories = new OC_VCategories('calendar', null, self::getDefaultCategories());
+ }
+ return self::$categories;
+ }
+
+ public static function getCategoryOptions()
+ {
+ $categories = self::getVCategories()->categories();
+ return $categories;
+ }
+
+ /**
+ * scan events for categories.
+ * @param $events VEVENTs to scan. null to check all events for the current user.
*/
- public static function getCategoryOptions(){
- return OC_Calendar_Object::getCategoryOptions(self::$l10n);
+ public static function scanCategories($events = null) {
+ if (is_null($events)) {
+ $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+ if(count($calendars) > 0) {
+ $events = array();
+ foreach($calendars as $calendar) {
+ $calendar_events = OC_Calendar_Object::all($calendar['id']);
+ $events = $events + $calendar_events;
+ }
+ }
+ }
+ if(is_array($events) && count($events) > 0) {
+ $vcategories = self::getVCategories();
+ $vcategories->delete($vcategories->categories());
+ foreach($events as $event) {
+ $vobject = OC_VObject::parse($event['calendardata']);
+ if(!is_null($vobject)) {
+ $vcategories->loadFromVObject($vobject->VEVENT, true);
+ }
+ }
+ }
}
-
- /*
- * @brief returns the options for an repeating event
- * @return array - valid inputs for repeating events
+
+ /**
+ * check VEvent for new categories.
+ * @see OC_VCategories::loadFromVObject
*/
+ public static function loadCategoriesFromVCalendar(OC_VObject $calendar) {
+ self::getVCategories()->loadFromVObject($calendar->VEVENT, true);
+ }
+
public static function getRepeatOptions(){
return OC_Calendar_Object::getRepeatOptions(self::$l10n);
}
@@ -244,7 +302,6 @@ class OC_Calendar_App{
* @return (array) $events
*/
public static function getrequestedEvents($calendarid, $start, $end){
-
$events = array();
if($calendarid == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){
$calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r');