index.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. OCP\User::checkLoggedIn();
  9. OCP\App::checkAppEnabled('calendar');
  10. // Create default calendar ...
  11. $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), false);
  12. if( count($calendars) == 0){
  13. OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(),'Default calendar');
  14. $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
  15. }
  16. $eventSources = array();
  17. foreach($calendars as $calendar){
  18. if($calendar['active'] == 1) {
  19. $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
  20. }
  21. }
  22. $eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true');
  23. $eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false');
  24. OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSources));
  25. $categories = OC_Calendar_App::getCategoryOptions();
  26. //Fix currentview for fullcalendar
  27. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
  28. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek");
  29. }
  30. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){
  31. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month");
  32. }
  33. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){
  34. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list");
  35. }
  36. OCP\Util::addscript('3rdparty/fullcalendar', 'fullcalendar');
  37. OCP\Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
  38. OCP\Util::addscript('3rdparty/timepicker', 'jquery.ui.timepicker');
  39. OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
  40. if(OCP\Config::getUserValue(OCP\USER::getUser(), "calendar", "timezone") == null || OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection') == 'true'){
  41. OCP\Util::addscript('calendar', 'geo');
  42. }
  43. OCP\Util::addscript('calendar', 'calendar');
  44. OCP\Util::addStyle('calendar', 'style');
  45. OCP\Util::addscript('', 'jquery.multiselect');
  46. OCP\Util::addStyle('', 'jquery.multiselect');
  47. OCP\Util::addscript('contacts','jquery.multi-autocomplete');
  48. OCP\Util::addscript('','oc-vcategories');
  49. OCP\App::setActiveNavigationEntry('calendar_index');
  50. $tmpl = new OCP\Template('calendar', 'calendar', 'user');
  51. $tmpl->assign('eventSources', $eventSources,false);
  52. $tmpl->assign('categories', $categories);
  53. if(array_key_exists('showevent', $_GET)){
  54. $tmpl->assign('showevent', $_GET['showevent'], false);
  55. }
  56. $tmpl->printPage();