/** * This function applies the filter settings and builds an according WHERE clause for the SELECT statement * * @return string WHERE clause for the SELECT statement * @author Reinhard Führicht <*****@*****.**> */ protected function buildWhereClause() { //init gp params $params = t3lib_div::_GP('formhandler'); $where = array(); // Get tsconfig from current page if ($this->id) { $tsconfig = t3lib_BEfunc::getModTSconfig($this->id, 'tx_formhandler_mod1'); } $pidFilter = ''; if (strlen(trim($params['pidFilter'])) > 0) { $pidFilter = $params['pidFilter']; } if (strlen(trim($params['pidFilter'])) > 0 && trim($params['pidFilter']) != "*") { $pids = t3lib_div::trimExplode(',', $params['pidFilter'], 1); $pid_search = array(); // check is page shall be accessed by current BE user foreach ($pids as $pid) { if (t3lib_BEfunc::readPageAccess(intval($pid))) { $pid_search[] = intval($pid); } } // check if there's a valid pid left $this->pidFilter = empty($pid_search) ? 0 : implode(",", $pid_search); $where[] = 'pid IN (' . $this->pidFilter . ')'; // show all entries (admin only) } else { if (trim($params['pidFilter']) == "*" && $GLOBALS['BE_USER']->user['admin']) { $this->pidFilter = "*"; // show clicked page (is always accessable) } else { $where[] = 'pid = ' . $this->id; $this->pidFilter = $this->id; } } if (trim($params['ipFilter']) > 0) { $ips = t3lib_div::trimExplode(',', $params['ipFilter'], 1); $ip_search = array(); foreach ($ips as $value) { $ip_search[] = "'" . htmlspecialchars($value) . "'"; } $where[] = 'ip IN (' . implode(",", $ip_search) . ')'; } //only records submitted after given timestamp if (strlen(trim($params['startdateFilter'])) > 0) { $tstamp = Tx_Formhandler_StaticFuncs::dateToTimestamp($params['startdateFilter']); $where[] = 'crdate >= ' . $tstamp; } //only records submitted before given timestamp if (strlen(trim($params['enddateFilter'])) > 0) { $tstamp = Tx_Formhandler_StaticFuncs::dateToTimestamp($params['enddateFilter'], TRUE); $where[] = 'crdate <= ' . $tstamp; } //if filter was applied, return the WHERE clause if (count($where) > 0) { return implode(' AND ', $where); } }