1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Fixes #4009 . Enhanced admin-ui to support custom filter handlers on string searches (not just drop-drop filters as was already the case)

This commit is contained in:
Cameron
2019-11-05 08:54:16 -08:00
parent e041e57587
commit 762844037f
2 changed files with 31 additions and 2 deletions

View File

@@ -141,6 +141,17 @@ class banlist_ui extends e_admin_ui
$this->fields['banlist_ip']['title']= BANLAN_5; $this->fields['banlist_ip']['title']= BANLAN_5;
} }
//
/**
* Custom filter for banlist_ip filter search.
* @param string $srch
*/
function handleListBanlistIpFilter($srch)
{
return "banlist_ip = '".e107::getIPHandler()->ipEncode($srch)."' OR banlist_ip = '".$srch."'";
}
// optional // optional
public function init() public function init()

View File

@@ -4198,6 +4198,7 @@ class e_admin_controller_ui extends e_admin_controller
e107::getMessage()->addDebug(print_a($searchQry,true)); e107::getMessage()->addDebug(print_a($searchQry,true));
} }
$className = get_class($this);
// main table should select everything // main table should select everything
$tableSFieldsArr[] = $tablePath.'*'; $tableSFieldsArr[] = $tablePath.'*';
@@ -4225,6 +4226,20 @@ class e_admin_controller_ui extends e_admin_controller
if(trim($searchQuery) !== '' && in_array($var['type'], $searchable_types) && $var['__tableField']) if(trim($searchQuery) !== '' && in_array($var['type'], $searchable_types) && $var['__tableField'])
{ {
// Search for customer filter handler.
$cutomerFilterMethod = 'handle'.$this->getRequest()->getActionName().$this->getRequest()->camelize($key).'Filter';
$args = array($searchQuery);
e107::getMessage()->addDebug("Searching for custom filter method: ".$className.'::'.$cutomerFilterMethod."(".implode(', ', $args).")");
if(method_exists($this, $cutomerFilterMethod)) // callback handling
{
e107::getMessage()->addDebug('Executing filter callback <strong>'.$className.'::'.$cutomerFilterMethod.'('.implode(', ', $args).')</strong>');
$filter[] = call_user_func_array(array($this, $cutomerFilterMethod), $args);
continue;
}
if($var['data'] === 'int' || $var['data'] === 'integer' || $var['type'] === 'int' || $var['type'] === 'integer') if($var['data'] === 'int' || $var['data'] === 'integer' || $var['type'] === 'int' || $var['type'] === 'integer')
{ {
if(is_numeric($searchQuery)) if(is_numeric($searchQuery))
@@ -4279,6 +4294,7 @@ class e_admin_controller_ui extends e_admin_controller
} }
} }
if(strpos($filterOptions,'searchfield__') === 0) // search in specific field, so remove the above filters. if(strpos($filterOptions,'searchfield__') === 0) // search in specific field, so remove the above filters.
{ {
$filter = array(); // reset filter. $filter = array(); // reset filter.
@@ -5478,6 +5494,8 @@ class e_admin_ui extends e_admin_controller_ui
{ {
$string = $this->getQuery('searchquery'); $string = $this->getQuery('searchquery');
if(empty($string)) if(empty($string))
{ {
return null; return null;