Modified the filtering behavior; A filter specified as 'Table.field' results in the obvious split (Table, field); 'Table' results in (Table, id); 'field' results in (ModelTable, field). Fixed a bug in the app controller which was allowing 'fields' to leak into the top level of 'link'
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@430 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -309,20 +309,26 @@ class AppController extends Controller {
|
||||
foreach ($params['post']['filter'] AS $filter => $value) {
|
||||
$split = $this->gridDataFilterSplit($params, $model, $filter);
|
||||
|
||||
/* pr(array('AppController::gridDataFilterTable' => */
|
||||
/* array('checkpoint' => "Filter split") */
|
||||
/* + compact('split'))); */
|
||||
|
||||
$table = $this->gridDataFilterTablesTable($params, $model, $split['table']);
|
||||
if (!$table)
|
||||
continue;
|
||||
|
||||
$config = $this->gridDataFilterTablesConfig($params, $model, $split['table']);
|
||||
|
||||
/* pr(array('pre-filter-table-config' => */
|
||||
/* array('query[link]' => $query[$link], */
|
||||
/* 'config' => $config))); */
|
||||
/* pr(array('AppController::gridDataFilterTable' => */
|
||||
/* array('checkpoint' => "Add filter config to query") */
|
||||
/* + array('query[link]' => $query[$link]) */
|
||||
/* + compact('config'))); */
|
||||
|
||||
// If the table is already part of the query, append to it
|
||||
if ($table == $model->alias) {
|
||||
$query[$link] =
|
||||
array_merge_recursive($config, $query[$link]);
|
||||
array_merge_recursive(array_diff_key($config, array('fields'=>1)),
|
||||
$query[$link]);
|
||||
}
|
||||
elseif (isset($query[$link][$table])) {
|
||||
$query[$link][$table] =
|
||||
@@ -413,13 +419,14 @@ class AppController extends Controller {
|
||||
if (preg_match("/\./", $filter)) {
|
||||
list($table, $field) = explode(".", $filter);
|
||||
}
|
||||
elseif (preg_match('/^(.*)_(id)$/', $filter, $matches)) {
|
||||
list($table, $field) = array_slice($matches, 1);
|
||||
}
|
||||
else {
|
||||
elseif (preg_match('/^[A-Z]/', $filter)) {
|
||||
$table = $filter;
|
||||
$field = null;
|
||||
}
|
||||
else {
|
||||
$table = $model->alias;
|
||||
$field = $filter;
|
||||
}
|
||||
|
||||
return array('table' => $table, 'field' => $field);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user