forked from science-ation/science-ation
Couple of quick fixes:
- the "languages" field needed to be regrouped when applied to a Science Olympics account - Modified account/create api to test all errors and return them as a group, rather than exiting on the first error
This commit is contained in:
parent
a5bd01f621
commit
552ce74d96
@ -133,24 +133,27 @@ function account_load_by_username($username)
|
|||||||
function account_create($username,$password=NULL)
|
function account_create($username,$password=NULL)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
$errMsg = '';
|
||||||
|
|
||||||
/* Sanity check username */
|
/* Sanity check username */
|
||||||
if(!account_valid_user($username)) {
|
if(!account_valid_user($username)) {
|
||||||
return i18n("Invalid user name \"%1\"", array($username));
|
$errMsg .= i18n('Invalid user name "%1"', array($username)) . " ";
|
||||||
}
|
}else{
|
||||||
|
/* Make sure the user doesn't exist */
|
||||||
/* Make sure the user doesn't exist */
|
$us = mysql_real_escape_string($username);
|
||||||
$us = mysql_real_escape_string($username);
|
$q = mysql_query("SELECT * FROM accounts WHERE username='$us'");
|
||||||
$q = mysql_query("SELECT * FROM accounts WHERE username='$us'");
|
if(mysql_num_rows($q)) {
|
||||||
if(mysql_num_rows($q)) {
|
$errMsg .= i18n("The username %1 is already in use", array($username)) . " ";
|
||||||
return i18n("The username %1 is already in use", array($username));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the password is set, make sure its valid, if its null, thats OK, it'll get generated and set by account_set_password
|
//if the password is set, make sure its valid, if its null, thats OK, it'll get generated and set by account_set_password
|
||||||
if($password && !account_valid_password($password)) {
|
if($password && !account_valid_password($password)) {
|
||||||
return i18n("Invalid password");
|
$errMsg .= i18n("Invalid password") . " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($errMsg != '') return $errMsg;
|
||||||
|
|
||||||
/* Create the account */
|
/* Create the account */
|
||||||
mysql_query("INSERT INTO accounts (`username`,`created`,`deleted`,`superuser`)
|
mysql_query("INSERT INTO accounts (`username`,`created`,`deleted`,`superuser`)
|
||||||
VALUES ('$us', NOW(),'no','no')");
|
VALUES ('$us', NOW(),'no','no')");
|
||||||
|
10
testapi.php
10
testapi.php
@ -98,6 +98,14 @@ email: <input type="text" id="email"></input><br/>
|
|||||||
Link username to email? <input type="radio" name="link_username_to_email" value="yes"></input>Yes <input type="radio" name="link_username_to_email" value="no"></input>No<br/>
|
Link username to email? <input type="radio" name="link_username_to_email" value="yes"></input>Yes <input type="radio" name="link_username_to_email" value="no"></input>No<br/>
|
||||||
<button onclick = "submitAccountUpdate(); return false;">Update account information</button>
|
<button onclick = "submitAccountUpdate(); return false;">Update account information</button>
|
||||||
|
|
||||||
|
<br/><br/><strong>Create an account:</strong><br/>
|
||||||
|
<form method="post" action="api/account/create">
|
||||||
|
username: <input type="text" name="username"></input><br/>
|
||||||
|
password: <input type="text" name="password"></input><br/>
|
||||||
|
email address: <input type="text" name="email"></input><br/>
|
||||||
|
<input type="submit" value="Create Account"></input>
|
||||||
|
</form>
|
||||||
|
|
||||||
<h2>Teacher Specific Commands</h2>
|
<h2>Teacher Specific Commands</h2>
|
||||||
<a href="api/scienceolympics/teams/list">Science Olympic Teams List</a><br />
|
<a href="api/scienceolympics/teams/list">Science Olympic Teams List</a><br />
|
||||||
|
|
||||||
@ -142,6 +150,8 @@ role id: <input type="text" name="roles_id"></input><br/>
|
|||||||
<input type="submit" value="Uninvite User"></input>
|
<input type="submit" value="Uninvite User"></input>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Event Schedule</h2>
|
<h2>Event Schedule</h2>
|
||||||
<a href="api/schedule/list">Schedule Listing</a><br/>
|
<a href="api/schedule/list">Schedule Listing</a><br/>
|
||||||
|
|
||||||
|
@ -342,7 +342,6 @@ function user_get_field_info($noConference = false){
|
|||||||
'firstaid' => array('label' => 'First Aid', 'group' => 'Personal Information'),
|
'firstaid' => array('label' => 'First Aid', 'group' => 'Personal Information'),
|
||||||
'cpr' => array('label' => 'CPR', 'group' => 'Personal Information'),
|
'cpr' => array('label' => 'CPR', 'group' => 'Personal Information'),
|
||||||
'displayemail' => array('label' => 'Display Email', 'group' => 'Personal Information'),
|
'displayemail' => array('label' => 'Display Email', 'group' => 'Personal Information'),
|
||||||
'languages' => array('label' => 'Spoken Languages', 'group' => 'Judges'),
|
|
||||||
'sponsors_id' => array('label' => 'Sponsor', 'group' => 'Sponsors'),
|
'sponsors_id' => array('label' => 'Sponsor', 'group' => 'Sponsors'),
|
||||||
'primary' => array('label' => 'Primary Contact', 'group' => 'Sponsors'),
|
'primary' => array('label' => 'Primary Contact', 'group' => 'Sponsors'),
|
||||||
'position' => array('label' => 'Position', 'group' => 'Sponsors'),
|
'position' => array('label' => 'Position', 'group' => 'Sponsors'),
|
||||||
@ -380,9 +379,11 @@ function user_get_field_info($noConference = false){
|
|||||||
$returnval['expertise_other'] = array('label' => 'Other areas of expertise', 'group' => 'Judges');
|
$returnval['expertise_other'] = array('label' => 'Other areas of expertise', 'group' => 'Judges');
|
||||||
$returnval['available_times'] = array('label' => 'Times Available', 'group' => 'Judges');
|
$returnval['available_times'] = array('label' => 'Times Available', 'group' => 'Judges');
|
||||||
$returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Volunteers');
|
$returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Volunteers');
|
||||||
|
$returnval['languages'] = array('label' => 'Spoken Languages', 'group' => 'Judges');
|
||||||
break;
|
break;
|
||||||
case 'scienceolympics':
|
case 'scienceolympics':
|
||||||
$returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Judges,Volunteers');
|
$returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Judges,Volunteers');
|
||||||
|
$returnval['languages'] = array('label' => 'Spoken Languages', 'group' => 'Judges,Volunteers');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user