New extension: subcategories-0.2.3.zip
[vanilla-miry.git] / ajax / getusers.php
blob57bfc5484aef2797a33bf3e4395478899083c7eb
1 <?php
2 /*
3 * Copyright 2003 Mark O'Sullivan
4 * This file is part of Vanilla.
5 * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
6 * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
7 * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8 * The latest source code for Vanilla is available at www.lussumo.com
9 * Contact Mark O'Sullivan at mark [at] lussumo [dot] com
11 * Description: File used by Dynamic Data Management object to fill autocomplete data on user input field
14 include('../appg/settings.php');
15 include('../appg/init_ajax.php');
17 $Search = ForceIncomingString('Search', '');
18 $Search = urldecode($Search);
19 $Search = FormatStringForDatabaseInput($Search);
20 if ($Search != '') {
21 $s = $Context->ObjectFactory->NewContextObject($Context, 'SqlBuilder');
22 $s->SetMainTable('User', 'u');
23 $s->AddSelect('Name', 'u');
24 $s->AddWhere('u', 'Name', '', $Search.'%', 'like');
25 $s->AddOrderBy('Name', 'u', 'asc');
26 $s->AddLimit(0,10);
27 $ResultSet = $Context->Database->Select($s, 'Ajax', 'AutoComplete', 'An error occurred while retrieving autocomplete items.', 0);
28 $Name = '';
29 $Loop = 1;
30 if ($ResultSet) {
31 while ($row = $Context->Database->GetRow($ResultSet)) {
32 if ($Loop > 1) echo ',';
33 $Name = FormatStringForDisplay($row['Name'], 1);
34 echo $Name;
35 $Loop++;
39 $Context->Unload();