BxEventsModule.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Events Events
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Groups profiles module.
  13. */
  14. class BxEventsModule extends BxBaseModGroupsModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. public function actionCalendarData()
  21. {
  22. // TODO: check permissions
  23. $aEntries = $this->_oDb->getEntriesByDate(bx_get('start'), bx_get('end'));
  24. header('Content-Type: application/json; charset=utf-8');
  25. echo json_encode($aEntries);
  26. }
  27. public function serviceCalendar()
  28. {
  29. $o = new BxTemplCalendar(array('events' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'calendar_data'), $this->_oTemplate);
  30. return $o->display();
  31. }
  32. public function actionIntervals()
  33. {
  34. $sAction = bx_get('a');
  35. $sMethodName = 'subaction' . ucfirst($sAction);
  36. if (!method_exists($this, $sMethodName)) {
  37. $this->_oTemplate->pageNotFound();
  38. return;
  39. }
  40. $this->$sMethodName();
  41. }
  42. public function subactionRestore()
  43. {
  44. // TODO: check permissions
  45. $iContentId = (int)bx_get('c');
  46. $a = $this->_oDb->getIntervals($iContentId);
  47. foreach ($a as $iIntervalId => $r) {
  48. $a[$iIntervalId]['file_id'] = $r['interval_id'];
  49. $a[$iIntervalId]['repeat_stop'] = bx_process_output ($r['repeat_stop'], BX_DATA_DATE_TS);
  50. }
  51. if ('json' == bx_get('f')) {
  52. header('Content-type: text/html; charset=utf-8');
  53. echo json_encode($a);
  54. }
  55. }
  56. public function subactionDelete()
  57. {
  58. // TODO: check permissions
  59. }
  60. }
  61. /** @} */