Example #1
0
 /**
  * Performs the box view
  * 
  * @return null
  */
 function showThreeBoxes()
 {
     global $_ARRAYLANG;
     $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($this->startDate, $this->endDate, $this->categoryId, $this->searchTerm, true, $this->needAuth, true, 0, 'n', $this->sortDirection, true, $this->author);
     $objEventManager->getEventList();
     $this->_objTpl->setTemplate($this->pageContent);
     if ($_REQUEST['cmd'] == 'boxes') {
         $objEventManager->calendarBoxUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', 'boxes')->toString() . "?act=list";
         $objEventManager->calendarBoxMonthNavUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', 'boxes')->toString();
     } else {
         $objEventManager->calendarBoxUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', '')->toString() . "?act=list";
         $objEventManager->calendarBoxMonthNavUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', '')->toString();
     }
     if (empty($_GET['catid'])) {
         $catid = 0;
     } else {
         $catid = $_GET['catid'];
     }
     if (isset($_GET['yearID']) && isset($_GET['monthID']) && isset($_GET['dayID'])) {
         $day = $_GET['dayID'];
         $month = $_GET['monthID'];
         $year = $_GET['yearID'];
     } elseif (isset($_GET['yearID']) && isset($_GET['monthID']) && !isset($_GET['dayID'])) {
         $day = 0;
         $month = $_GET['monthID'];
         $year = $_GET['yearID'];
     } elseif (isset($_GET['yearID']) && !isset($_GET['monthID']) && !isset($_GET['dayID'])) {
         $day = 0;
         $month = 0;
         $year = $_GET['yearID'];
     } else {
         $day = date("d");
         $month = date("m");
         $year = date("Y");
     }
     $calendarbox = $objEventManager->getBoxes($this->boxCount, $year, $month, $day, $catid);
     $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true);
     $objCategoryManager->getCategoryList();
     $this->_objTpl->setVariable(array("TXT_{$this->moduleLangVar}_ALL_CAT" => $_ARRAYLANG['TXT_CALENDAR_ALL_CAT'], "{$this->moduleLangVar}_BOX" => $calendarbox, "{$this->moduleLangVar}_JAVA_SCRIPT" => $objEventManager->getCalendarBoxJS(), "{$this->moduleLangVar}_CATEGORIES" => $objCategoryManager->getCategoryDropdown($catid, 1)));
 }
 /**
  * Returns all series dates based on the given post data
  *       
  * @return array Array of dates
  */
 function getExeceptionDates()
 {
     global $_CORELANG;
     $exceptionDates = array();
     $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent();
     $objEvent->loadEventFromPost($_POST);
     $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($objEvent->startDate);
     $objEventManager->_setNextSeriesElement($objEvent);
     $dayArray = explode(',', $_CORELANG['TXT_CORE_DAY_ABBREV2_ARRAY']);
     foreach ($objEventManager->eventList as $event) {
         $startDate = $event->startDate;
         $endDate = $event->endDate;
         $exceptionDates[$this->format2userDate($startDate)] = $this->format2userDate($startDate) != $this->format2userDate($endDate) ? $dayArray[$this->formatDateTime2user($startDate, "w")] . ", " . $this->format2userDate($startDate) . ' - ' . $dayArray[$this->formatDateTime2user($endDate, "w")] . ", " . $this->format2userDate($endDate) : $dayArray[$this->formatDateTime2user($startDate, "w")] . ", " . $this->format2userDate($startDate);
     }
     return $exceptionDates;
 }
 /**
  * Perform the overview page functionalities
  *
  * @return null
  */
 function showOverview()
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG;
     $this->_objTpl->loadTemplateFile('module_calendar_overview.html');
     $this->_pageTitle = $_ARRAYLANG['TXT_CALENDAR_MENU_OVERVIEW'];
     $this->getSettings();
     if (isset($_GET['switch_status'])) {
         \Permission::checkAccess(180, 'static');
         $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(intval($_GET['switch_status']));
         if ($objEvent->switchStatus()) {
             $this->okMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_SUCCESSFULLY_EDITED'];
         } else {
             $this->errMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_CORRUPT_EDITED'];
         }
     }
     if (isset($_GET['delete'])) {
         \Permission::checkAccess(180, 'static');
         $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(intval($_GET['delete']));
         if ($objEvent->delete()) {
             $this->okMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_SUCCESSFULLY_DELETED'];
         } else {
             $this->errMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_CORRUPT_DELETED'];
         }
     }
     if (isset($_GET['confirm'])) {
         \Permission::checkAccess(180, 'static');
         $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(intval($_GET['confirm']));
         if ($objEvent->confirm()) {
             $this->okMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_SUCCESSFULLY_EDITED'];
         } else {
             $this->errMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_CORRUPT_EDITED'];
         }
     }
     if (isset($_GET['export'])) {
         $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(intval($_GET['export']));
         $objEvent->export();
     }
     if (isset($_GET['multi'])) {
         \Permission::checkAccess(180, 'static');
         $status = true;
         $messageVar = 'EDITED';
         foreach ($_POST['selectedEventId'] as $key => $eventId) {
             $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(intval($eventId));
             switch ($_GET['multi']) {
                 case 'delete':
                     $status = $objEvent->delete() ? true : false;
                     $messageVar = 'DELETED';
                     break;
                 case 'activate':
                     $objEvent->status = 0;
                     $status = $objEvent->switchStatus() ? true : false;
                     $messageVar = 'EDITED';
                     break;
                 case 'deactivate':
                     $objEvent->status = 1;
                     $status = $objEvent->switchStatus() ? true : false;
                     $messageVar = 'EDITED';
                     break;
                 case 'export':
                     $objEvent->export();
                     break;
             }
         }
         if ($status) {
             $this->okMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_SUCCESSFULLY_' . $messageVar];
         } else {
             $this->errMessage = $_ARRAYLANG['TXT_CALENDAR_EVENT_CORRUPT_' . $messageVar];
         }
     }
     $categoryId = intval($_REQUEST['categoryId']) != 0 ? $categoryId = intval($_REQUEST['categoryId']) : ($categoryId = null);
     $searchTerm = isset($_REQUEST['term']) ? $_REQUEST['term'] : ($searchTerm = $_ARRAYLANG['TXT_CALENDAR_KEYWORD']);
     $startPos = isset($_REQUEST['pos']) ? $_REQUEST['pos'] : 0;
     $listType = 'all';
     if ($_GET['list'] == 'actual' || !isset($_GET['list'])) {
         $styleListActual = 'underline';
         $styleListAll = '';
         $startDate = new \DateTime();
         $listType = 'upcoming';
     } else {
         $styleListActual = '';
         $styleListAll = 'underline';
         $startDate = null;
     }
     $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_OVERVIEW' => $this->_pageTitle, 'TXT_' . $this->moduleLangVar . '_UPCOMING_EVENTS' => $_ARRAYLANG['TXT_CALENDAR_UPCOMING_EVENTS'], 'TXT_' . $this->moduleLangVar . '_ALL_EVENTS' => $_ARRAYLANG['TXT_CALENDAR_ALL_EVENTS'], 'TXT_' . $this->moduleLangVar . '_FILTER' => $_ARRAYLANG['TXT_CALENDAR_FILTER'], 'TXT_' . $this->moduleLangVar . '_CONFIRMLIST' => $_ARRAYLANG['TXT_CALENDAR_CONFIRMLIST'], 'TXT_SEARCH' => $_CORELANG['TXT_USER_SEARCH'], 'TXT_' . $this->moduleLangVar . '_SEARCH' => $_CORELANG['TXT_USER_SEARCH'], 'TXT_' . $this->moduleLangVar . '_KEYWORD' => $searchTerm, 'TXT_' . $this->moduleLangVar . '_EVENTS' => $_ARRAYLANG['TXT_CALENDAR_EVENTS'], 'TXT_' . $this->moduleLangVar . '_STATUS' => $_ARRAYLANG['TXT_CALENDAR_STATUS'], 'TXT_' . $this->moduleLangVar . '_DATE' => $_ARRAYLANG['TXT_CALENDAR_DATE'], 'TXT_' . $this->moduleLangVar . '_TITLE' => $_ARRAYLANG['TXT_CALENDAR_TITLE'], 'TXT_' . $this->moduleLangVar . '_CATEGORY' => $_ARRAYLANG['TXT_CALENDAR_CATEGORY'], 'TXT_' . $this->moduleLangVar . '_SERIES' => $_ARRAYLANG['TXT_CALENDAR_SERIES'], 'TXT_' . $this->moduleLangVar . '_RE_DEREGISTRATIONS' => $_ARRAYLANG['TXT_CALENDAR_RE_DEGISTRATIONS'], 'TXT_' . $this->moduleLangVar . '_REGISTRATIONS' => $_ARRAYLANG['TXT_CALENDAR_REGISTRATIONS'], 'TXT_' . $this->moduleLangVar . '_WAITLIST' => $_ARRAYLANG['TXT_CALENDAR_WAITLIST'], 'TXT_' . $this->moduleLangVar . '_ACTION' => $_ARRAYLANG['TXT_CALENDAR_ACTION'], 'TXT_' . $this->moduleLangVar . '_EXPORT_ICAL_FORMAT' => $_ARRAYLANG['TXT_CALENDAR_EXPORT_ICAL_FORMAT'], 'TXT_' . $this->moduleLangVar . '_EDIT' => $_ARRAYLANG['TXT_CALENDAR_EDIT'], 'TXT_' . $this->moduleLangVar . '_COPY' => $_ARRAYLANG['TXT_CALENDAR_COPY'], 'TXT_' . $this->moduleLangVar . '_DELETE' => $_ARRAYLANG['TXT_CALENDAR_DELETE'], 'TXT_' . $this->moduleLangVar . '_LANGUAGES' => $_ARRAYLANG['TXT_CALENDAR_LANGUAGES'], 'TXT_SELECT_ALL' => $_ARRAYLANG['TXT_CALENDAR_MARK_ALL'], 'TXT_DESELECT_ALL' => $_ARRAYLANG['TXT_CALENDAR_REMOVE_CHOICE'], 'TXT_SUBMIT_SELECT' => $_ARRAYLANG['TXT_SUBMIT_SELECT'], 'TXT_SUBMIT_ACTIVATE' => $_ARRAYLANG['TXT_SUBMIT_ACTIVATE'], 'TXT_SUBMIT_DEACTIVATE' => $_ARRAYLANG['TXT_SUBMIT_DEACTIVATE'], 'TXT_SUBMIT_DELETE' => $_ARRAYLANG['TXT_SUBMIT_DELETE'], 'TXT_SUBMIT_EXPORT' => $_ARRAYLANG['TXT_SUBMIT_EXPORT'], 'TXT_' . $this->moduleLangVar . '_CONFIRM_DELETE_DATA' => $_ARRAYLANG['TXT_CALENDAR_CONFIRM_DELETE_DATA'], 'TXT_' . $this->moduleLangVar . '_ACTION_IS_IRREVERSIBLE' => $_ARRAYLANG['TXT_CALENDAR_ACTION_IS_IRREVERSIBLE'], 'TXT_' . $this->moduleLangVar . '_MAKE_SELECTION' => $_ARRAYLANG['TXT_CALENDAR_MAKE_SELECTION'], 'TXT_' . $this->moduleLangVar . '_LIST_ACTUAL' => $_ARRAYLANG['TXT_CALENDAR_LIST_ACTUAL'], 'TXT_' . $this->moduleLangVar . '_LIST_ALL' => $_ARRAYLANG['TXT_CALENDAR_LIST_ALL'], $this->moduleLangVar . '_LINKSTYLE_LIST_ACTUAL' => $styleListActual, $this->moduleLangVar . '_LINKSTYLE_LIST_ALL' => $styleListAll));
     $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true);
     $objCategoryManager->getCategoryList();
     $this->_objTpl->setVariable(array('CALENDAR_CATEGORIES' => $objCategoryManager->getCategoryDropdown($categoryId, 1)));
     $objConfirmEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager(null, null, null, null, null, null, true, null, null, false, null);
     $objConfirmEventManager->getEventList();
     if (count($objConfirmEventManager->eventList) > 0) {
         $objConfirmEventManager->showEventList($this->_objTpl, 'confirm');
     } else {
         $this->_objTpl->hideBlock('showConfirmList');
     }
     if ($this->arrSettings['rssFeedStatus'] == 1) {
         $objFeedEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager(time(), null, null, null, true);
         $objFeed = new \Cx\Modules\Calendar\Controller\CalendarFeed($objFeedEventManager);
         $objFeed->creatFeed();
     }
     $showSeries = $listType == 'upcoming';
     $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($startDate, null, $categoryId, $searchTerm, $showSeries, null, null, $startPos, $this->arrSettings['numPaging'], 'ASC', true, null, $listType);
     $objEventManager->getEventList();
     if ($objEventManager->countEvents > $this->arrSettings['numPaging']) {
         $pagingCategory = !empty($categoryId) ? '&categoryId=' . $categoryId : '';
         $pagingTerm = !empty($searchTerm) ? '&term=' . $searchTerm : '';
         $pagingList = !empty($_GET['list']) ? '&list=' . $_GET['list'] : '';
         $this->_objTpl->setVariable(array($this->moduleLangVar . '_PAGING' => getPaging($objEventManager->countEvents, $startPos, "&cmd=" . $this->moduleName . $pagingCategory . $pagingTerm . $pagingList, "<b>" . $_ARRAYLANG['TXT_CALENDAR_EVENTS'] . "</b>", true, $this->arrSettings['numPaging'])));
     }
     $objEventManager->showEventList($this->_objTpl);
 }
 /**
  * Returns all series dates based on the given post data
  *       
  * @return array Array of dates
  */
 function getExeceptionDates()
 {
     global $_CORELANG;
     $exceptionDates = array();
     $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent();
     $objEvent->loadEventFromPost($_POST);
     $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($objEvent->startDate);
     $objEventManager->_setNextSeriesElement($objEvent);
     $dayArray = explode(',', $_CORELANG['TXT_CORE_DAY_ABBREV2_ARRAY']);
     foreach ($objEventManager->eventList as $event) {
         $exceptionDates[date(self::getDateFormat(), $event->startDate)] = $event->startDate != $event->endDate ? $dayArray[date("w", $event->startDate)] . ", " . date(self::getDateFormat(), $event->startDate) . ' - ' . $dayArray[date("w", $event->endDate)] . ", " . date(self::getDateFormat(), $event->endDate) : $dayArray[date("w", $event->startDate)] . ", " . date(self::getDateFormat(), $event->startDate);
     }
     return $exceptionDates;
 }
 /**
  * Count the number of entries in the category
  *      
  * @return integer Entry count of the category
  */
 function countEntries($getAll = false, $onlyActive = false)
 {
     // get startdate
     if (!empty($_GET['from'])) {
         $startDate = $this->getDateTime($_GET['from']);
     } else {
         if ($_GET['cmd'] == 'archive') {
             $startDate = null;
         } else {
             $startDate = new \DateTime();
             $startDay = isset($_GET['day']) ? $_GET['day'] : $startDate->format('d');
             $startDay = $_GET['cmd'] == 'boxes' ? 1 : $startDay;
             $startMonth = isset($_GET['month']) ? $_GET['month'] : $startDate->format('m');
             $startYear = isset($_GET['year']) ? $_GET['year'] : $startDate->format('Y');
             $startDate->setDate($startYear, $startMonth, $startDay);
             $startDate->setTime(0, 0, 0);
         }
     }
     // get enddate
     if (!empty($_GET['till'])) {
         $endDate = $this->getDateTime($_GET['till']);
     } else {
         if ($_GET['cmd'] == 'archive') {
             $endDate = new \DateTime();
         } else {
             $endDate = new \DateTime();
             $endDay = isset($_GET['endDay']) ? $_GET['endDay'] : $endDate->format('d');
             $endMonth = isset($_GET['endMonth']) ? $_GET['endMonth'] : $endDate->format('m');
             $endYear = isset($_GET['endYear']) ? $_GET['endYear'] : $endDate->format('Y');
             $endYear = empty($_GET['endYear']) && empty($_GET['endMonth']) ? $endYear + 10 : $endYear;
             $endDate->setDate($endYear, $endMonth, $endDay);
             $endDate->setTime(23, 59, 59);
         }
     }
     $searchTerm = !empty($_GET['term']) ? contrexx_addslashes($_GET['term']) : null;
     // set the start date as null if $getAll is true
     if ($getAll) {
         $startDate = null;
     }
     $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($startDate, $endDate, $this->id, $searchTerm, true, false, $onlyActive);
     $objEventManager->getEventList();
     $count = count($objEventManager->eventList);
     return $count;
 }