forked from science-ation/science-ation
Add account/view api
This commit is contained in:
parent
a92544bbea
commit
f0b362eff7
@ -91,7 +91,18 @@ function account_set_password($accounts_id, $password = NULL)
|
||||
function account_load($id)
|
||||
{
|
||||
$id = intval($id);
|
||||
$q = mysql_query("SELECT * FROM accounts WHERE id='$id'");
|
||||
//we dont want password or the pending email code in here
|
||||
$q = mysql_query("SELECT id,
|
||||
username,
|
||||
link_username_to_email,
|
||||
passwordset,
|
||||
email,
|
||||
pendingemail,
|
||||
superuser,
|
||||
deleted,
|
||||
deleted_datetime,
|
||||
created
|
||||
FROM accounts WHERE id='$id'");
|
||||
if(mysql_num_rows($q) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
27
api.php
27
api.php
@ -209,12 +209,13 @@ switch($request[0]) {
|
||||
break;
|
||||
|
||||
case "account":
|
||||
switch($request[1]) {
|
||||
/* APIDOC: account/create
|
||||
description(creates an account)
|
||||
post(username varchar(64), password varchar(64), email varchar(64) optional)
|
||||
return(account array)
|
||||
*/
|
||||
if($request[1]=="create") {
|
||||
case 'create':
|
||||
$user = trim($_POST['username']);
|
||||
$pass = trim($_POST['password']);
|
||||
$email = trim($_POST['email']);
|
||||
@ -240,8 +241,24 @@ switch($request[0]) {
|
||||
$ret['status']="error";
|
||||
$ret['error']="username (varchar 64) and password (varchar 64) are required ";
|
||||
}
|
||||
break;
|
||||
|
||||
/* APIDOC: account/view
|
||||
description(view account information for currently logged in account)
|
||||
return(account array)
|
||||
*/
|
||||
case 'view':
|
||||
if(isset($_SESSION['accounts_id'])) {
|
||||
$a = account_load($_SESSION['accounts_id']);
|
||||
$ret['status']='ok';
|
||||
$ret['account']=$a;
|
||||
}
|
||||
else {
|
||||
$ret['status']="error";
|
||||
$ret['error']="You are not logged in";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$ret['status']="error";
|
||||
$ret['error']="invalid account command";
|
||||
}
|
||||
@ -429,7 +446,6 @@ switch($request[0]) {
|
||||
break;
|
||||
}
|
||||
|
||||
require_once("so_teams.inc.php");
|
||||
switch($request[1]) {
|
||||
/* APIDOC: user/view
|
||||
description(view user information for current conference)
|
||||
@ -499,13 +515,6 @@ echo json_encode($ret);
|
||||
return(schools array)
|
||||
*/
|
||||
|
||||
/* APIDOC: account/edit
|
||||
notimplemented
|
||||
description(edit account information)
|
||||
post(account array)
|
||||
return(account array)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* APIDOC: user/connect_teacher_to_school
|
||||
|
Loading…
Reference in New Issue
Block a user