[sfiab-commits] [svn] commit: r2396 - in /trunk: api.php testapi.php user.inc.php
Brought to you by:
sfiab
From: <in...@sf...> - 2010-10-25 23:55:45
|
Author: james Date: Mon Oct 25 19:55:38 2010 New Revision: 2396 Log: Add registration field roles to testapi.php page Fix char(2) field detection Modified: trunk/api.php trunk/testapi.php trunk/user.inc.php Modified: trunk/api.php ============================================================================== --- trunk/api.php (original) +++ trunk/api.php Mon Oct 25 19:55:38 2010 @@ -647,6 +647,7 @@ 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 @@ $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"; Modified: trunk/testapi.php ============================================================================== --- trunk/testapi.php (original) +++ trunk/testapi.php Mon Oct 25 19:55:38 2010 @@ -119,6 +119,15 @@ </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); Modified: trunk/user.inc.php ============================================================================== --- trunk/user.inc.php (original) +++ trunk/user.inc.php Mon Oct 25 19:55:38 2010 @@ -453,6 +453,10 @@ $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(); |