Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit c7209c5

Browse files
committed
BUG: refs #0426. Fix user search model method on pgsql (was broken)
1 parent 0c1a849 commit c7209c5

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

core/controllers/SearchController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public function liveAction()
298298
}
299299
$label = $userDao->getFirstname().' '.$userDao->getLastname();
300300
$value = $label;
301-
if($userDao->count > 1)
301+
if(isset($userDao->count) && $userDao->count > 1)
302302
{
303303
$label .= ' ('.$userDao->count.')';
304304
}
@@ -307,7 +307,7 @@ public function liveAction()
307307
'value' => $value,
308308
'category' => $this->t('Users'));
309309

310-
if($userDao->count == 1)
310+
if(!isset($userDao->count) || $userDao->count == 1)
311311
{
312312
$result['userid'] = $userDao->getKey();
313313
}

core/models/pdo/UserModel.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,38 +212,38 @@ function getUsersFromSearch($search, $userDao, $limit = 14, $group = true, $orde
212212
if($isAdmin)
213213
{
214214
$sql ->where(' ('.
215-
$this->database->getDB()->quoteInto('firstname LIKE ?', '%'.$search.'%').' OR '.
216-
$this->database->getDB()->quoteInto('lastname LIKE ?', '%'.$search.'%').')')
215+
$this->database->getDB()->quoteInto('u.firstname LIKE ?', '%'.$search.'%').' OR '.
216+
$this->database->getDB()->quoteInto('u.lastname LIKE ?', '%'.$search.'%').')')
217217
->limit($limit)
218218
->setIntegrityCheck(false);
219219
}
220220
else
221221
{
222-
$sql ->where('(privacy = '.MIDAS_USER_PUBLIC.' OR ('.
222+
$sql ->where('(u.privacy = '.MIDAS_USER_PUBLIC.' OR ('.
223223
$subqueryUser.')>0'.') AND ('.
224-
$this->database->getDB()->quoteInto('firstname LIKE ?', '%'.$search.'%').' OR '.
225-
$this->database->getDB()->quoteInto('lastname LIKE ?', '%'.$search.'%').')')
224+
$this->database->getDB()->quoteInto('u.firstname LIKE ?', '%'.$search.'%').' OR '.
225+
$this->database->getDB()->quoteInto('u.lastname LIKE ?', '%'.$search.'%').')')
226226
->limit($limit)
227227
->setIntegrityCheck(false);
228228
}
229229

230230

231231
if($group)
232232
{
233-
$sql->group(array('firstname', 'lastname'));
233+
$sql->group(array('u.firstname', 'u.lastname'));
234234
}
235235

236236
switch($order)
237237
{
238238
case 'name':
239-
$sql->order(array('lastname ASC', 'firstname ASC'));
239+
$sql->order(array('u.lastname ASC', 'u.firstname ASC'));
240240
break;
241241
case 'date':
242-
$sql->order(array('creation ASC'));
242+
$sql->order(array('u.creation ASC'));
243243
break;
244244
case 'view':
245245
default:
246-
$sql->order(array('view DESC'));
246+
$sql->order(array('u.view DESC'));
247247
break;
248248
}
249249
$rowset = $this->database->fetchAll($sql);

0 commit comments

Comments
 (0)