public function onSearch() { $periodString = $this->getTrimmedInput('period', $_GET); if (!empty($periodString) && in_array($periodString, array('lastweek', 'lastmonth', 'lastsixmonths', 'lastyear', 'all'))) { /* formats start and end date for searching */ switch ($periodString) { case 'lastweek': $period = 'DATE_SUB(CURDATE(), INTERVAL 1 WEEK)'; break; case 'lastmonth': $period = 'DATE_SUB(CURDATE(), INTERVAL 1 MONTH)'; break; case 'lastsixmonths': $period = 'DATE_SUB(CURDATE(), INTERVAL 6 MONTH)'; break; case 'lastyear': $period = 'DATE_SUB(CURDATE(), INTERVAL 1 YEAR)'; break; case 'all': default: $period = ''; break; } $startDate = ''; $endDate = ''; $startDateURLString = ''; $endDateURLString = ''; } else { /* Do we have a valid starting date? */ if (!$this->isRequiredIDValid('startDay', $_GET) || !$this->isRequiredIDValid('startMonth', $_GET) || !$this->isRequiredIDValid('startYear', $_GET)) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid starting date.'); } /* Do we have a valid ending date? */ if (!$this->isRequiredIDValid('endDay', $_GET) || !$this->isRequiredIDValid('endMonth', $_GET) || !$this->isRequiredIDValid('endYear', $_GET)) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid ending date.'); } if (!checkdate($_GET['startMonth'], $_GET['startDay'], $_GET['startYear'])) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid starting date.'); } if (!checkdate($_GET['endMonth'], $_GET['endDay'], $_GET['endYear'])) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid ending date.'); } /* formats start and end date for searching */ $startDate = DateUtility::formatSearchDate( $_GET['startMonth'], $_GET['startDay'], $_GET['startYear'] ); $endDate = DateUtility::formatSearchDate( $_GET['endMonth'], $_GET['endDay']+1, $_GET['endYear'] ); $startDateURLString = sprintf( '&startMonth=%s&startDay=%s&startYear=%s', $_GET['startMonth'], $_GET['startDay'], $_GET['startYear'] ); $endDateURLString = sprintf( '&endMonth=%s&endDay=%s&endYear=%s', $_GET['endMonth'], $_GET['endDay'], $_GET['endYear'] ); $period = ''; } $baseURL = sprintf( 'm=activity&a=viewByDate&getback=getback%s%s', $startDateURLString, $endDateURLString ); $dataGridProperties = DataGrid::getRecentParamaters("activity:ActivityDataGrid"); /* If this is the first time we visited the datagrid this session, the recent paramaters will * be empty. Fill in some default values. */ if ($dataGridProperties == array()) { $dataGridProperties = array( 'rangeStart' => 0, 'maxResults' => 15, 'filterVisible' => false ); } $dataGridProperties['startDate'] = $startDate; $dataGridProperties['endDate'] = $endDate; $dataGridProperties['period'] = $period; $dataGrid = DataGrid::get("activity:ActivityDataGrid", $dataGridProperties); $quickLinks = $this->getQuickLinks(); if (!eval(Hooks::get('ACTIVITY_LIST_BY_VIEW_DG'))) return; $this->_template->assign('quickLinks', $quickLinks); $this->_template->assign('active', $this); $this->_template->assign('dataGrid', $dataGrid); $this->_template->assign('userID', $_SESSION['CATS']->getUserID()); $activityEntries = new ActivityEntries($this->_siteID); $this->_template->assign('numActivities', $activityEntries->getCount()); $this->_template->display('./modules/activity/ActivityDataGrid.php'); }