index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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(), 1);
  12. if( count($calendars) == 0){
  13. OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(),'Default calendar');
  14. $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1);
  15. }
  16. $eventSources = array();
  17. foreach($calendars as $calendar){
  18. $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
  19. }
  20. $eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true');
  21. $eventSources[] = array('url' => '?app=calendar&getfile=ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false');
  22. OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSources));
  23. $categories = OC_Calendar_App::getCategoryOptions();
  24. //Fix currentview for fullcalendar
  25. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
  26. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek");
  27. }
  28. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){
  29. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month");
  30. }
  31. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){
  32. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list");
  33. }
  34. OCP\Util::addscript('3rdparty/fullcalendar', 'fullcalendar');
  35. OCP\Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
  36. OCP\Util::addscript('3rdparty/timepicker', 'jquery.ui.timepicker');
  37. OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
  38. if(OCP\Config::getUserValue(OCP\USER::getUser(), "calendar", "timezone") == null || OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection') == 'true'){
  39. OCP\Util::addscript('calendar', 'geo');
  40. }
  41. OCP\Util::addscript('calendar', 'calendar');
  42. OCP\Util::addStyle('calendar', 'style');
  43. OCP\Util::addscript('', 'jquery.multiselect');
  44. OCP\Util::addStyle('', 'jquery.multiselect');
  45. OCP\Util::addscript('contacts','jquery.multi-autocomplete');
  46. OCP\Util::addscript('','oc-vcategories');
  47. OCP\App::setActiveNavigationEntry('calendar_index');
  48. $tmpl = new OCP\Template('calendar', 'calendar', 'user');
  49. $tmpl->assign('eventSources', $eventSources);
  50. $tmpl->assign('categories', $categories);
  51. if(array_key_exists('showevent', $_GET)){
  52. $tmpl->assign('showevent', $_GET['showevent']);
  53. }
  54. $tmpl->printPage();