index.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. $events_baseURL = OCP\Util::linkTo('calendar', 'ajax/events.php');
  23. $eventSources[] = array('url' => $events_baseURL.'?calendar_id=shared_rw',
  24. 'backgroundColor' => '#1D2D44',
  25. 'borderColor' => '#888',
  26. 'textColor' => 'white',
  27. 'editable'=>'true');
  28. $eventSources[] = array('url' => $events_baseURL.'?calendar_id=shared_r',
  29. 'backgroundColor' => '#1D2D44',
  30. 'borderColor' => '#888',
  31. 'textColor' => 'white',
  32. 'editable' => 'false');
  33. OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSources));
  34. $categories = OC_Calendar_App::getCategoryOptions();
  35. //Fix currentview for fullcalendar
  36. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
  37. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek");
  38. }
  39. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){
  40. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month");
  41. }
  42. if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){
  43. OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list");
  44. }
  45. OCP\Util::addscript('3rdparty/fullcalendar', 'fullcalendar');
  46. OCP\Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
  47. OCP\Util::addscript('3rdparty/timepicker', 'jquery.ui.timepicker');
  48. OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
  49. if(OCP\Config::getUserValue(OCP\USER::getUser(), "calendar", "timezone") == null || OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection') == 'true'){
  50. OCP\Util::addscript('calendar', 'geo');
  51. }
  52. OCP\Util::addscript('calendar', 'calendar');
  53. OCP\Util::addStyle('calendar', 'style');
  54. OCP\Util::addscript('', 'jquery.multiselect');
  55. OCP\Util::addStyle('', 'jquery.multiselect');
  56. OCP\Util::addscript('contacts','jquery.multi-autocomplete');
  57. OCP\Util::addscript('','oc-vcategories');
  58. OCP\App::setActiveNavigationEntry('calendar_index');
  59. $tmpl = new OCP\Template('calendar', 'calendar', 'user');
  60. $tmpl->assign('eventSources', $eventSources,false);
  61. $tmpl->assign('categories', $categories);
  62. if(array_key_exists('showevent', $_GET)){
  63. $tmpl->assign('showevent', $_GET['showevent'], false);
  64. }
  65. $tmpl->printPage();