Skip to content
Permalink
Browse files

Custom fields from/to filter

  • Loading branch information...
bloatware committed Jun 10, 2019
1 parent e747d0a commit 4f4cda8df4a6e6f887f68e89eb8cec4f47999611
Showing with 10 additions and 2 deletions.
  1. +10 −2 textpattern/lib/txplib_misc.php
@@ -5308,8 +5308,16 @@ function buildCustomSql($custom, $pairs, $exclude = array())
$no = array_search($k, $custom);
if ($no !== false) {
$not = ($exclude === true || in_array($k, $exclude)) ? ' not' : '';
$out[] = "and custom_".$no.$not." like '$v'";
$not = ($exclude === true || in_array($k, $exclude)) ? 'NOT' : '';
list($from, $to) = explode('%%', $v) + array(null, null);
if (!isset($to)) {
$out[] = "AND $not custom_".$no." LIKE '$v'";
} elseif ($from !== '') {
$out[] = $to === '' ? "AND $not custom_".$no.">='$from'" : "AND $not custom_".$no." BETWEEN '$from' and '$to'";
} elseif ($to !== '') {
$out[] = "AND $not custom_".$no."<='$to'";
}
}
}
}

0 comments on commit 4f4cda8

Please sign in to comment.
You can’t perform that action at this time.