diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-14 00:40:10 +0400 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-14 00:40:10 +0400 |
commit | afcb0aee40230c68dd99f5ea2501b7ba7e444560 (patch) | |
tree | 5ccd10e78128c70e71a36ca9080a652a7bd833d5 /apps/calendar | |
parent | 02dc34320978bfbcb30dea34b87808837586bb65 (diff) | |
parent | b9f9228a22944184803a8835282862e468812c1d (diff) |
fix merge conflicts
Diffstat (limited to 'apps/calendar')
-rw-r--r-- | apps/calendar/ajax/categories/rescan.php | 42 | ||||
-rw-r--r-- | apps/calendar/ajax/event/edit.form.php | 21 | ||||
-rw-r--r-- | apps/calendar/ajax/event/new.form.php | 3 | ||||
-rw-r--r-- | apps/calendar/index.php | 4 | ||||
-rw-r--r-- | apps/calendar/js/calendar.js | 15 | ||||
-rw-r--r-- | apps/calendar/lib/app.php | 79 | ||||
-rw-r--r-- | apps/calendar/lib/calendar.php | 4 | ||||
-rw-r--r-- | apps/calendar/lib/object.php | 31 | ||||
-rwxr-xr-x | apps/calendar/templates/calendar.php | 1 | ||||
-rw-r--r-- | apps/calendar/templates/part.eventform.php | 10 |
10 files changed, 142 insertions, 68 deletions
diff --git a/apps/calendar/ajax/categories/rescan.php b/apps/calendar/ajax/categories/rescan.php new file mode 100644 index 00000000000..0fd878ed8f9 --- /dev/null +++ b/apps/calendar/ajax/categories/rescan.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); + +foreach ($_POST as $key=>$element) { + debug('_POST: '.$key.'=>'.print_r($element, true)); +} + +function bailOut($msg) { + OC_JSON::error(array('data' => array('message' => $msg))); + OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); +} + +$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +if(count($calendars) == 0) { + bailOut(OC_Calendar_App::$l10n->t('No calendars found.')); +} +$events = array(); +foreach($calendars as $calendar) { + $calendar_events = OC_Calendar_Object::all($calendar['id']); + $events = $events + $calendar_events; +} +if(count($events) == 0) { + bailOut(OC_Calendar_App::$l10n->t('No events found.')); +} + +OC_Calendar_App::scanCategories($events); +$categories = OC_Calendar_App::getCategoryOptions(); + +OC_JSON::success(array('data' => array('categories'=>$categories))); diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index 986ab65ed03..6582496577b 100644 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -47,13 +47,8 @@ switch($dtstart->getDateType()) { $summary = $vevent->getAsString('SUMMARY'); $location = $vevent->getAsString('LOCATION'); -$categories = $vevent->getAsArray('CATEGORIES'); +$categories = $vevent->getAsString('CATEGORIES'); $description = $vevent->getAsString('DESCRIPTION'); -foreach($categories as $category){ - if (!in_array($category, $category_options)){ - array_unshift($category_options, $category); - } -} $last_modified = $vevent->__get('LAST-MODIFIED'); if ($last_modified){ $lastmodified = $last_modified->getDateTime()->format('U'); @@ -220,7 +215,6 @@ $tmpl->assign('eventid', $id); $tmpl->assign('access', $access); $tmpl->assign('lastmodified', $lastmodified); $tmpl->assign('calendar_options', $calendar_options); -$tmpl->assign('category_options', $category_options); $tmpl->assign('repeat_options', $repeat_options); $tmpl->assign('repeat_month_options', $repeat_month_options); $tmpl->assign('repeat_weekly_options', $repeat_weekly_options); @@ -257,7 +251,14 @@ if($repeat['repeat'] != 'doesnotrepeat'){ $tmpl->assign('repeat_bymonthday', $repeat['bymonthday']); $tmpl->assign('repeat_bymonth', $repeat['bymonth']); $tmpl->assign('repeat_byweekno', $repeat['byweekno']); +} else { + $tmpl->assign('repeat_month', 'monthday'); + $tmpl->assign('repeat_weekdays', array()); + $tmpl->assign('repeat_interval', 1); + $tmpl->assign('repeat_end', 'never'); + $tmpl->assign('repeat_count', '10'); + $tmpl->assign('repeat_weekofmonth', 'auto'); + $tmpl->assign('repeat_date', ''); + $tmpl->assign('repeat_year', 'bydate'); } -$tmpl->printpage(); - -?>
\ No newline at end of file +$tmpl->printpage();
\ No newline at end of file diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php index 69d1dc3f08b..91b95546569 100644 --- a/apps/calendar/ajax/event/new.form.php +++ b/apps/calendar/ajax/event/new.form.php @@ -32,7 +32,6 @@ $start->setTimezone(new DateTimeZone($timezone)); $end->setTimezone(new DateTimeZone($timezone)); $calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -$category_options = OC_Calendar_App::getCategoryOptions(); $repeat_options = OC_Calendar_App::getRepeatOptions(); $repeat_end_options = OC_Calendar_App::getEndOptions(); $repeat_month_options = OC_Calendar_App::getMonthOptions(); @@ -47,7 +46,6 @@ $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); $tmpl = new OC_Template('calendar', 'part.newevent'); $tmpl->assign('access', 'owner'); $tmpl->assign('calendar_options', $calendar_options); -$tmpl->assign('category_options', $category_options); $tmpl->assign('repeat_options', $repeat_options); $tmpl->assign('repeat_month_options', $repeat_month_options); $tmpl->assign('repeat_weekly_options', $repeat_weekly_options); @@ -74,4 +72,3 @@ $tmpl->assign('repeat_weekofmonth', 'auto'); $tmpl->assign('repeat_date', ''); $tmpl->assign('repeat_year', 'bydate'); $tmpl->printpage(); -?> diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 280b0a18867..c44de7f07df 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -26,6 +26,7 @@ $eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_rw', 'backg $eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); OC_Hook::emit('OC_Calendar', 'getSources', array('sources' => &$eventSources)); +$categories = OC_Calendar_App::getCategoryOptions(); //Fix currentview for fullcalendar if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){ @@ -49,9 +50,12 @@ OC_Util::addScript('calendar', 'calendar'); OC_Util::addStyle('calendar', 'style'); OC_Util::addScript('', 'jquery.multiselect'); OC_Util::addStyle('', 'jquery.multiselect'); +OC_Util::addScript('contacts','jquery.multi-autocomplete'); +OC_Util::addScript('','oc-vcategories'); OC_App::setActiveNavigationEntry('calendar_index'); $tmpl = new OC_Template('calendar', 'calendar', 'user'); $tmpl->assign('eventSources', $eventSources); +$tmpl->assign('categories', $categories); if(array_key_exists('showevent', $_GET)){ $tmpl->assign('showevent', $_GET['showevent']); } diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 84829695eee..a267f15f781 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -32,13 +32,7 @@ Calendar={ $('#totime').timepicker({ showPeriodLabels: false }); - $('#category').multiselect({ - header: false, - noneSelectedText: $('#category').attr('title'), - selectedList: 2, - minWidth:'auto', - classes: 'category', - }); + $('#category').multiple_autocomplete({source: categories}); Calendar.UI.repeat('init'); $('#end').change(function(){ Calendar.UI.repeat('end'); @@ -371,6 +365,11 @@ Calendar={ } $('#'+id).addClass('active'); }, + categoriesChanged:function(newcategories){ + categories = $.map(newcategories, function(v) {return v;}); + console.log('Calendar categories changed to: ' + categories); + $('#category').multiple_autocomplete('option', 'source', categories); + }, Calendar:{ overview:function(){ if($('#choosecalendar_dialog').dialog('isOpen') == true){ @@ -833,6 +832,8 @@ $(document).ready(function(){ loading: Calendar.UI.loading, eventSources: eventSources }); + OCCategories.changed = Calendar.UI.categoriesChanged; + OCCategories.app = 'calendar'; $('#oneweekview_radio').click(function(){ $('#calendar_holder').fullCalendar('changeView', 'agendaWeek'); }); 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'); diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 7eeb004d181..321f4c73ba0 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -44,10 +44,8 @@ class OC_Calendar_Calendar{ /** * @brief Returns the list of calendars for a specific user. * @param string $uid User ID - * @param boolean $active + * @param boolean $active Only return calendars with this $active state, default(=null) is don't care * @return array - * - * TODO: what is active for? */ public static function allCalendars($uid, $active=null){ $values = array($uid); diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index ab005bd4a4a..825977c17c5 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -93,6 +93,7 @@ class OC_Calendar_Object{ */ public static function add($id,$data){ $object = OC_VObject::parse($data); + OC_Calendar_App::loadCategoriesFromVCalendar($object); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); if(is_null($uid)){ @@ -139,6 +140,7 @@ class OC_Calendar_Object{ $oldobject = self::find($id); $object = OC_VObject::parse($data); + OC_Calendar_App::loadCategoriesFromVCalendar($object); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); @@ -320,27 +322,6 @@ class OC_Calendar_Object{ return $dtend; } - public static function getCategoryOptions($l10n) - { - return array( - $l10n->t('Birthday'), - $l10n->t('Business'), - $l10n->t('Call'), - $l10n->t('Clients'), - $l10n->t('Deliverer'), - $l10n->t('Holidays'), - $l10n->t('Ideas'), - $l10n->t('Journey'), - $l10n->t('Jubilee'), - $l10n->t('Meeting'), - $l10n->t('Other'), - $l10n->t('Personal'), - $l10n->t('Projects'), - $l10n->t('Questions'), - $l10n->t('Work'), - ); - } - public static function getRepeatOptions($l10n) { return array( @@ -452,10 +433,6 @@ class OC_Calendar_Object{ $errnum++; } - if(isset($request['categories']) && !is_array($request['categories'])){ - $errarr['categories'] = $l10n->t('Not an array'); - } - $fromday = substr($request['from'], 0, 2); $frommonth = substr($request['from'], 3, 2); $fromyear = substr($request['from'], 6, 4); @@ -623,7 +600,7 @@ class OC_Calendar_Object{ { $title = $request["title"]; $location = $request["location"]; - $categories = isset($request["categories"]) ? $request["categories"] : array(); + $categories = $request["categories"]; $allday = isset($request["allday"]); $from = $request["from"]; $to = $request["to"]; @@ -795,7 +772,7 @@ class OC_Calendar_Object{ $vevent->setString('LOCATION', $location); $vevent->setString('DESCRIPTION', $description); - $vevent->setString('CATEGORIES', join(',', $categories)); + $vevent->setString('CATEGORIES', $categories); /*if($repeat == "true"){ $vevent->RRULE = $repeat; diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 63c3b500296..ba9423a66f1 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -1,6 +1,7 @@ <script type='text/javascript'> var defaultView = '<?php echo OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') ?>'; var eventSources = <?php echo json_encode($_['eventSources']) ?>; + var categories = <?php echo json_encode($_['categories']); ?>; var dayNames = <?php echo json_encode($l->tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>; var dayNamesShort = <?php echo json_encode($l->tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>; var monthNames = <?php echo json_encode($l->tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>; diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 3e12f2973e2..c63630a5a05 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -26,12 +26,8 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <tr> <th width="75px"><?php echo $l->t("Category");?>:</th> <td> - <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>"> - <?php - if (!isset($_['categories'])) {$_['categories'] = array();} - echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true)); - ?> - </select> + <input id="category" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? htmlspecialchars($_['categories']) : '' ?>"> + <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a> </td> <?php if(count($_['calendar_options']) > 1) { ?> <th width="75px"> <?php echo $l->t("Calendar");?>:</th> @@ -253,4 +249,4 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <div id="tabs-5"> <?php echo $this->inc('share.dropdown'); ?> </div> -<?php } ?>
\ No newline at end of file +<?php } ?> |