forked from science-ation/science-ation
6b37f4b721
Start fixing the school editor (not done yet) Update jqueryui (1.8.9) and jquery (1.4.4 - NOT 1.5 - 1.5 causes conflicts with autocomplete and validaotor plugins)
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?
|
|
/*
|
|
This file is part of the 'Science Fair In A Box' project
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
|
Copyright (C) 2005 James Grant <james@lightbox.org>
|
|
|
|
This program 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, version 2.
|
|
|
|
This program 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.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; see the file COPYING. If not, write to
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA.
|
|
*/
|
|
?>
|
|
<?
|
|
require("../common.inc.php");
|
|
require_once("../user.inc.php");
|
|
user_auth_required('admin');
|
|
$t=mysql_real_escape_string($_GET['term']);
|
|
$q=mysql_query("SELECT * FROM accounts WHERE username='$t'");
|
|
$out=array();
|
|
|
|
if(mysql_num_rows($q)) {
|
|
$r=mysql_fetch_object($q);
|
|
$u=user_load_by_accounts_id($r->id);
|
|
if(!$u) {
|
|
$u=user_create($r->id);
|
|
}
|
|
$out[]=array("accounts_id"=>"$r->id", "users_id"=>$u['id'], "label"=>$r->username);
|
|
}
|
|
else {
|
|
$q=mysql_query("SELECT * FROM accounts WHERE username LIKE '%$t%' OR email LIKE '%$t%'");
|
|
if(mysql_num_rows($q)) {
|
|
while($r=mysql_fetch_object($q)) {
|
|
$u=user_load_by_accounts_id($r->id);
|
|
if(!$u) {
|
|
$u=user_create($r->id);
|
|
}
|
|
$out[]=array("accounts_id"=>"$r->id", "users_id"=>$u['id'], "label"=>$r->username);
|
|
}
|
|
}
|
|
$out[]=array("accounts_id"=>0,"label"=>"Create new account with username: ".$t);
|
|
}
|
|
echo json_encode($out);
|