From e9214c2e47f2eaecafc81bfc5fe1291321467394 Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Wed, 22 Aug 2018 10:01:06 -0500 Subject: [PATCH] issue: CDATA Phone Contains This addresses an issue where people who do not have a phone field on the contact information form go to search for a User in the User Directory and the system crashes. This is due to the search query that always contains the phone field variable. This only adds the phone variable to the search query if the field actually exists. --- include/staff/users.inc.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/staff/users.inc.php b/include/staff/users.inc.php index 04c292a0b..6e61c002b 100644 --- a/include/staff/users.inc.php +++ b/include/staff/users.inc.php @@ -10,13 +10,15 @@ $users = User::objects() if ($_REQUEST['query']) { $search = $_REQUEST['query']; - $users->filter(Q::any(array( + $filter = Q::any(array( 'emails__address__contains' => $search, 'name__contains' => $search, 'org__name__contains' => $search, - 'cdata__phone__contains' => $search, - // TODO: Add search for cdata - ))); + )); + if (UserForm::getInstance()->getField('phone')) + $filter->add(array('cdata__phone__contains' => $search)); + + $users->filter($filter); $qs += array('query' => $_REQUEST['query']); } -- GitLab