_closeSessions(); if (empty($this->_removeHistoryDays) || in_array(idate('d'), $this->_removeHistoryDays)) { $this->_removeHistory(); } return $this; } protected function _closeSessions() { $stmt = $this->_getDataObj()->getUnclosedSessionsStatement(); $countClosed = 0; while ($sessionId = $stmt->fetchColumn()) { if (!$this->_getDataObj()->sessionExists($sessionId)) { $this->_getDataObj()->markSessionClosed($sessionId); $countClosed++; } } $report = 'Closed ' . $countClosed . ' ' . Qs_Translate::getPlural('session', $countClosed); SanityCheckView::writeCronLog($this, $report); return $this; } protected function _removeHistory() { $months = (int) SettingsObj::get('viewControllerLogLiveTime'); if (empty($months)) { SanityCheckView::writeCronLog($this, 'viewControllerLogLiveTime is empty'); return $this; } $affectedRows = $this->_getDataObj()->removeHistory($months); $report = 'Removed ' . $affectedRows . ' ' . Qs_Translate::getPlural('session', $affectedRows) . ' older ' . $months . ' ' . Qs_Translate::getPlural('month', $months); SanityCheckView::writeCronLog($this, $report); return $this; } public function setRemoveHistoryDays($removeHistoryDays) { $this->_removeHistoryDays = (array) $removeHistoryDays; return $this; } public function getRemoveHistoryDays() { return $this->_removeHistoryDays; } }