fix for bug #450: Advanced search does not work regarding categories

This commit is contained in:
Ralf Becker 2007-05-15 14:23:28 +00:00
parent f6b3216085
commit 61d0659715
2 changed files with 33 additions and 0 deletions

View File

@ -276,6 +276,11 @@ class socontacts_sql extends so_sql
$criteria[] = $this->db->expression($this->extra_table,'(',array('contact_name'=>substr($col,1),'contact_value'=>$val),')');
$search_customfields = true;
}
elseif($col == 'cat_id') // search in comma-sep. cat-column
{
$criteria = array_merge($criteria,$this->_cat_search($val));
unset($criteria[$col]);
}
}
}
if ($search_customfields) // search the custom-fields
@ -345,6 +350,23 @@ class socontacts_sql extends so_sql
return '('.implode(' OR ',$cat_filter).')';
}
/**
* fix cat_id criteria to search in comma-separated multiple cats
*
* @internal
* @param int/array $cats
* @return array of sql-strings to be OR'ed or AND'ed together
*/
function _cat_search($cats)
{
$cat_filter = array();
foreach(is_array($cats) ? $cats : array($cats) as $cat)
{
if (is_numeric($cat)) $cat_filter[] = $this->db->concat("','",cat_id,"','")." LIKE '%,$cat,%'";
}
return $cat_filter;
}
/**
* Change the ownership of contacts owned by a given account
*

View File

@ -1527,6 +1527,17 @@ $readonlys['button[vcard]'] = true;
'%' => lang('contains'),
false => lang('exact'),
);
if ($this->customfields)
{
foreach($this->customfields as $name => $data)
{
if ($data['type'] == 'select')
{
if (!isset($content['#'.$name])) $content['#'.$name] = '';
if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
}
}
}
// configure edit template as search dialog
$readonlys['change_photo'] = true;
$readonlys['fileas_type'] = true;