More user stuff to get things workinga gain

Add a API module for science olympics
This commit is contained in:
james 2010-08-31 20:12:41 +00:00
parent ec3be0f10f
commit de564f3c55
3 changed files with 44 additions and 8 deletions

45
api.php
View File

@ -88,6 +88,7 @@ switch($request[0]) {
$ret['status']="ok";
$ret['account']=$a;
//$ret['user']=user_load($_SESSION['users_id']);
$ret['roles']=$_SESSION['roles'];
}
}
@ -118,13 +119,47 @@ switch($request[0]) {
}
break;
case "so":
api_user_auth_required('teacher');
switch($request[1]) {
case "teams":
switch($request[2]) {
case "list":
$u=user_load($_SESSION['users_id']);
$q=mysql_query("SELECT id,name FROM so_teams WHERE schools_id='{$u['schools_id']}' AND conferences_id='{$conference['id']}'");
$ret['status']='ok';
$teams=array();
while($r=mysql_fetch_assoc($q)) {
$teams[]=$r;
}
$ret['teams']=$teams;
break;
case "add":
$ret['status']='error';
$ret['error']='not implemented yet';
break;
case "edit":
$ret['status']='error';
$ret['error']='not implemented yet';
break;
case "remove";
$ret['status']='error';
$ret['error']='not implemented yet';
break;
default:
$ret['status']="error";
$ret['error']="invalid so/teams command ({$request[2]})";
break;
case "soteams":
api_user_auth_required('teacher');
}
break;
default:
$ret['status']="error";
$ret['error']="invalid so command ({$request[1]})";
break;
}
break;
default:
$ret['status']="error";
$ret['error']="Invalid API command ({$request[0]})";

View File

@ -596,14 +596,14 @@ function api_user_auth_required($all_required = array(), $one_required = array()
if(!$ok) {
$ret['status']="error";
$ret['error']="You do not have permission to access that information";
exit;
return $ret;
}
/* Forward to password expired, remember the target URI */
if($_SESSION['password_expired'] == true) {
$ret['status']="error";
$ret['error']="Your password has expired";
exit;
return $ret;
}
$ret['status']="ok";
$ret['match']=$match[0];

View File

@ -84,6 +84,7 @@ case 'save':
if($save) {
// action_create_set_email($accounts_id, $email);
mysql_query("UPDATE accounts SET email='".mysql_real_escape_string($email)."' WHERE id={$accounts_id}");
happy_("An email has been sent to %1 to confirm the new email address", array($email));
}
}
@ -175,7 +176,7 @@ case 'save':
<td style="text-align: left" colspan="2"><b>Email</b><hr /></td>
</tr><tr>
<td><label for="email"><?=i18n('Email')?>:</label></td>
<td><input id="email" <?=$d?> name="email" type="text" size="20" value="<?=$email?>"></td>
<td><input id="email" <?=$d?> name="email" type="text" size="30" value="<?=$email?>"></td>
</tr><tr>
<td></td><td>
<div style="font-size: 0.75em;"><?=i18n('Changing the email address will cause a confirmation email to be sent to the new email address before the change will take effect.')?></div>