From 49a9a35ac86113ffe1f7efccc039b470297774cf Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 14 Jan 2013 22:04:41 +0000 Subject: [PATCH] Understand date with wildcard (19??.02.??) as a date in user's format. Convert to match bday. --- addressbook/inc/class.addressbook_sql.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index bd7df846da..33ebaeabb1 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -386,6 +386,23 @@ class addressbook_sql extends so_sql_cf } //_debug_array($order_by); _debug_array($extra_cols); } + + // Understand search by date with wildcard (????.10.??) according to user date preference + if(is_string($criteria)) + { + $date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; + // First, check for a 'date', with wildcards, in the user's format + $date_regex = str_replace(array('Y','m','d','.','-'), array('(?P(?:\?|\Q){4})','(?P(?:\?|\Q){2})','(?P(?:\?|\Q){2})','\.','\-'),$date_format); + $date_regex = str_replace('Q','d',$date_regex); + if(preg_match_all('$'.$date_regex.'$', $criteria, $matches)) + { + foreach($matches[0] as $m_id => $match) + { + // Birthday is Y-m-d + $criteria = '*'.str_replace($match, "{$matches['Y'][$m_id]}-{$matches['m'][$m_id]}-{$matches['d'][$m_id]}",$criteria) . '*'; + } + } + } } $rows =& parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);