forked from science-ation/science-ation
Add registration field roles to testapi.php page
Fix char(2) field detection
This commit is contained in:
parent
19e146547f
commit
3971df267f
2
api.php
2
api.php
@ -647,6 +647,7 @@ switch($request[0]) {
|
||||
unset($reqroles[$x]);
|
||||
}
|
||||
$ret['status']="ok";
|
||||
$ret['roles']=$reqroles;
|
||||
$ret['fields']=user_get_fields($reqroles);
|
||||
} else {
|
||||
//load the currently logged in user
|
||||
@ -654,6 +655,7 @@ switch($request[0]) {
|
||||
$u = user_load($_SESSION['users_id']);
|
||||
if(is_array($u['roles']) && count($u['roles']>0)) {
|
||||
$ret['status']="ok";
|
||||
$ret['roles']=array_keys($u['roles']);
|
||||
$ret['fields']=user_get_fields(array_keys($u['roles']));
|
||||
} else {
|
||||
$ret['status']="error";
|
||||
|
@ -119,6 +119,15 @@ Remove a role from this account
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h1>Registration Fields</h1>
|
||||
(leave all blank to use currently logged in users fields)<br />
|
||||
<form method="post" action="api/registration/fields">
|
||||
<?
|
||||
foreach($roles AS $role=>$r) {
|
||||
echo "<label><input type=\"checkbox\" name=\"roles[]\" value=\"{$role}\">$role</label><br />\n";
|
||||
}?>
|
||||
<input type="submit" value="List Registration Fields for Selected Roles">
|
||||
</form>
|
||||
<h1>Session Variables</h1>
|
||||
<?
|
||||
echo json_encode($_SESSION);
|
||||
|
@ -453,6 +453,10 @@ function user_get_fields($userRoles = null){
|
||||
$parts = explode(')', $ftype);
|
||||
$parts = explode('(', $parts[0]);
|
||||
$fields[$fieldName]['type'] = $parts[0] . ':' . $parts[1];
|
||||
}elseif(!strncasecmp($ftype, "char", 4)){
|
||||
$parts = explode(')', $ftype);
|
||||
$parts = explode('(', $parts[0]);
|
||||
$fields[$fieldName]['type'] = $parts[0] . ':' . $parts[1];
|
||||
}else if(!strncasecmp($ftype, "enum", 4)){
|
||||
$fields[$fieldName]['type'] = 'singleselect';
|
||||
$fields[$fieldName]['options'] = array();
|
||||
|
Loading…
Reference in New Issue
Block a user