private function newSubmissions() { /* Grab an instance of Statistics. */ $statistics = new Statistics($this->_siteID); $RS = $statistics->getSubmissionsByPeriod(TIME_PERIOD_LASTTWOWEEKS); // FIXME: Factor out these calculations? Common to most of these graphs. $firstDay = mktime(0, 0, 0, DateUtility::getAdjustedDate('m'), DateUtility::getAdjustedDate('d') - DateUtility::getAdjustedDate('w') - 7, DateUtility::getAdjustedDate('Y')); $y = array(); for ($i = 0; $i < 14; $i++) { $thisDay = mktime(0, 0, 0, date('m', $firstDay), date('d', $firstDay) + $i, date('Y', $firstDay)); $y[] = date('d', $thisDay); } /* Get values. */ $x = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); foreach ($RS as $lineRS) { $thisDay = mktime(0, 0, 0, $lineRS['month'], $lineRS['day'], $lineRS['year']); $dayOfWeek = (int) date('w', $thisDay); if (DateUtility::getWeekNumber($thisDay) != DateUtility::getWeekNumber()) { $x[$dayOfWeek]++; } else { $x[$dayOfWeek + 7]++; } } $graph = new GraphSimple($y, $x, 'Orange', 'New Submissions', $this->width, $this->height); if (!eval(Hooks::get('GRAPH_NEW_SUBMISSIONS'))) { return; } $graph->draw(); die; }
public function showCalendar() { $currentHour = DateUtility::getAdjustedDate('H'); $currentDay = DateUtility::getAdjustedDate('j'); $currentMonth = DateUtility::getAdjustedDate('n'); $currentYear = DateUtility::getAdjustedDate('Y'); $currentUnixTime = DateUtility::getAdjustedDate(); $currentDateMDY = DateUtility::getAdjustedDate('m-d-y'); $currentWeek = DateUtility::getWeekNumber($currentUnixTime) - DateUtility::getWeekNumber( mktime(0, 0, 0, $currentMonth, 1, $currentYear) ); /* Do we have a valid date argument? If a month was specified and * isn't valid, fatal() out. If none was specified, use the current * month. */ if ($this->isRequiredIDValid('month', $_GET) && $this->isRequiredIDValid('year', $_GET)) { $month = $_GET['month']; $year = $_GET['year']; if (!checkdate($month, 1, $year)) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid date.'); } if ($month == $currentMonth && $year == $currentYear) { $isCurrentMonth = true; } else { $isCurrentMonth = false; } } else { $month = $currentMonth; $year = $currentYear; $isCurrentMonth = true; } if (isset($_GET['view'])) { $view = $_GET['view']; } else { $view = 'DEFAULT_VIEW'; } if (isset($_GET['week'])) { $week = $_GET['week']; } else { $week = $currentWeek+1; } if (isset($_GET['day'])) { $day = $_GET['day']; } else { $day = $currentDay; } if (isset($_GET['showEvent'])) { $showEvent = $_GET['showEvent']; } else { $showEvent = null; } $userIsSuperUser = ($this->_accessLevel < ACCESS_LEVEL_SA ? 0 : 1); if ($userIsSuperUser && isset($_GET['superuser']) && $_GET['superuser'] == 1) { $superUserActive = true; } else { $superUserActive = false; } $startingWeekday = DateUtility::getStartingWeekday($month, $year); $daysInMonth = DateUtility::getDaysInMonth($month, $year); $calendar = new Calendar($this->_siteID); $monthBefore = $month - 1; $monthAfter = $month + 1; $yearBefore = $year; $yearAfter = $year; if ($monthAfter > 12) { $monthAfter = 1; $yearAfter = $year + 1; } if ($monthBefore < 1) { $monthBefore = 12; $yearBefore = $year - 1; } $eventsStringNow = $calendar->makeEventString( $calendar->getEventArray($month, $year), $month, $year ); $eventsStringBefore = $calendar->makeEventString( $calendar->getEventArray($monthBefore, $yearBefore), $monthBefore, $yearBefore ); $eventsStringAfter = $calendar->makeEventString( $calendar->getEventArray($monthAfter, $yearAfter), $monthAfter, $yearAfter ); $eventsString = implode( '@', array($eventsStringNow, $eventsStringBefore, $eventsStringAfter, $userIsSuperUser) ); /* Textual representation of the month and year. */ $dateString = date( 'F Y', mktime($_SESSION['CATS']->getTimeZoneOffset(), 0, 0, $month, 1, $year) ); /* The offset is the number of days after the first Sunday on a given * calendar page on which the 1st of the month falls. We subtract 1 * because Sunday has a value of 1. */ $startingOffset = $startingWeekday - 1; $userEmail = $_SESSION['CATS']->getEmail(); $calendarEventTypes = $calendar->getAllEventTypes(); $calendarSettings = new CalendarSettings($this->_siteID); $calendarSettingsRS = $calendarSettings->getAll(); if ($view == 'DEFAULT_VIEW') { $view = $calendarSettingsRS['calendarView']; } $summaryHTML = $calendar->getUpcomingEventsHTML(12, UPCOMING_FOR_CALENDAR); if (!eval(Hooks::get('CALENDAR_SHOW'))) return; if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo()) { $allowEventReminders = true; } else { $allowEventReminders = false; } /* FIXME: Configurable */ $this->_template->assign('dayHourStart', $calendarSettingsRS['dayStart']); $this->_template->assign('dayHourEnd', $calendarSettingsRS['dayStop']); $this->_template->assign('firstDayMonday', $calendarSettingsRS['firstDayMonday']); $this->_template->assign('allowAjax', ($calendarSettingsRS['noAjax'] == 0 ? true : false)); $this->_template->assign('defaultPublic', ($calendarSettingsRS['defaultPublic'] == 0 ? 'false' : 'true')); $this->_template->assign('militaryTime', false); $this->_template->assign('active', $this); $this->_template->assign('currentDateMDY', $currentDateMDY); $this->_template->assign('startingWeekday', $startingWeekday); $this->_template->assign('daysInMonth', $daysInMonth); $this->_template->assign('currentHour', $currentHour); $this->_template->assign('currentDay', $currentDay); $this->_template->assign('currentMonth', $currentMonth); $this->_template->assign('currentYear', $currentYear); $this->_template->assign('startingOffset', $startingOffset); $this->_template->assign('userEmail', $userEmail); $this->_template->assign('userID', $this->_userID); $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail()); $this->_template->assign('summaryHTML', $summaryHTML); $this->_template->assign('userIsSuperUser', $userIsSuperUser); $this->_template->assign('superUserActive', $superUserActive); $this->_template->assign('calendarEventTypes', $calendarEventTypes); $this->_template->assign('view', $view); $this->_template->assign('day', $day); $this->_template->assign('week', $week); $this->_template->assign('month', $month); $this->_template->assign('year', $year); $this->_template->assign('showEvent', $showEvent); $this->_template->assign('dateString', $dateString); $this->_template->assign('isCurrentMonth', $isCurrentMonth); $this->_template->assign('eventsString', $eventsString); $this->_template->assign('allowEventReminders', $allowEventReminders); $this->_template->display('./modules/calendar/Calendar.php'); }