- $where = $this->_makeWhere($year, $month, $day, $loguid);
- $select = "SELECT s.id, s.start, s.uid,
- a.hruid as username
- FROM log_sessions AS s
- INNER JOIN accounts AS a ON (a.uid = s.uid)
- $where
- ORDER BY start DESC";
+ $where = $this->_makeWhere($year, $month, $day, $action, $loguid);
+ if ($action != 0) {
+ $join = 'INNER JOIN log_events AS le ON (ls.id = le.session)
+ INNER JOIN log_actions AS la ON (le.action = la.id)';
+ } else {
+ $join = '';
+ }
+ $select = 'SELECT ls.id, ls.start, ls.uid, a.hruid as username
+ FROM log_sessions AS ls
+ INNER JOIN accounts AS a ON (a.uid = ls.uid)
+ ' . $join . '
+ ' . $where . '
+ GROUP BY ls.id
+ ORDER BY ls.start DESC';