/** * Process the where for the field based on the UserStatistics display since this is a special type of field/limit * and return the where clause to use for the query. * @param string $field * @param array $limitStyles * @return string */ protected function processWhereByUserStatistics($field, $limitStyles) { if (!is_array($limitStyles) || count($limitStyles) == 0) { return ''; } $db_field = $field; if (array_key_exists('db_field', $this->fieldData[$field])) { if (is_array($this->fieldData[$field]['db_field'])) { return ''; } else { $db_field = $this->fieldData[$field]['db_field']; } } $config = $this->config->traverse("fields/{$field}/limits", false, false); if (!$config instanceof I2CE_MagicDataNode) { return ''; } $wheres = array(); foreach ($limitStyles as $limitStyle => $values) { if (!isset($config->{$limitStyle})) { continue; } if (!isset($config->{$limitStyle}->enabled) || !$config->{$limitStyle}->enabled) { continue; } if (!is_array($values) || count($values) == 0) { continue; } $formfield = "STRING_LINE"; if (array_key_exists('formfield', $this->fieldData[$field])) { $formfield = $this->fieldData[$field]['formfield']; } $fieldObj = $this->getFieldObj($field, $formfield); if (!$fieldObj instanceof I2CE_FormField) { I2CE::raiseError("Couldn't get formfield for limit {$field}"); continue; } $where = trim($fieldObj->generateLimit(array('style' => $limitStyle, 'data' => $values), "{$db_field}")); if (strlen($where) > 0) { $wheres[] = "( {$where} )"; } } $where = ''; if (count($wheres) > 0) { $where = '(' . implode(' AND ', $wheres) . ' )'; } if ($field == "username") { $where = str_replace("user|", "", $where); } if ($field == "change_type") { $where = str_replace("entry_change_type|", "", $where); } return $where; }