forked from science-ation/science-ation
Fix api registration fields when roles ar epassed in
roles can be passed in as array of ids or array of types
This commit is contained in:
parent
bb40bf4da1
commit
19e146547f
7
api.php
7
api.php
@ -640,8 +640,13 @@ switch($request[0]) {
|
|||||||
case 'fields':
|
case 'fields':
|
||||||
$reqroles=$_POST['roles'];
|
$reqroles=$_POST['roles'];
|
||||||
if(is_array($reqroles)) {
|
if(is_array($reqroles)) {
|
||||||
|
for($x=0;$x<count($reqroles);$x++) {
|
||||||
|
if(is_numeric($reqroles[$x]))
|
||||||
|
$reqroles[$x]=$roles_by_id[$reqroles[$x]];
|
||||||
|
if(!array_key_exists($reqroles[$x],$roles))
|
||||||
|
unset($reqroles[$x]);
|
||||||
|
}
|
||||||
$ret['status']="ok";
|
$ret['status']="ok";
|
||||||
echo "reqroles=";
|
|
||||||
$ret['fields']=user_get_fields($reqroles);
|
$ret['fields']=user_get_fields($reqroles);
|
||||||
} else {
|
} else {
|
||||||
//load the currently logged in user
|
//load the currently logged in user
|
||||||
|
@ -252,6 +252,7 @@ $roles=array();
|
|||||||
$q = mysql_query("SELECT * FROM roles");
|
$q = mysql_query("SELECT * FROM roles");
|
||||||
while(($r = mysql_fetch_assoc($q))) {
|
while(($r = mysql_fetch_assoc($q))) {
|
||||||
$roles[$r['type']] = $r;
|
$roles[$r['type']] = $r;
|
||||||
|
$roles_by_id[$r['id']]=$r;
|
||||||
}
|
}
|
||||||
|
|
||||||
//and now pull the theme
|
//and now pull the theme
|
||||||
|
Loading…
Reference in New Issue
Block a user