Added grouping to the list of user information fields

This commit is contained in:
jacob 2010-11-10 18:47:01 +00:00
parent 769d5ee969
commit a7a7735347

View File

@ -293,46 +293,46 @@ function user_get_role_fields($role){
return $fields;
}
function user_get_field_labels(){
function user_get_field_info(){
return array(
'salutation' => 'Salutation',
'firstname' => 'First Name',
'lastname' => 'Last Name',
'sex' => 'Sex',
'phonehome' => 'Home Phone',
'phonework' => 'Work Phone',
'phonecell' => 'Cell Phone',
'fax' => 'Fax Number',
'organization' => 'Organization',
'birthdate' => 'Date of Birth',
'lang' => 'Language',
'address' => 'Address',
'address2' => '',
'city' => 'City',
'province' => 'Province',
'postalcode' => 'Postal Code',
'firstaid' => 'First Aid',
'cpr' => 'CPR',
'displayemail' => 'Display Email',
'years_school' => 'Years experience judging at school level',
'years_regional' => 'Years experience judging at regional level',
'years_national' => 'Years experience judging at national level',
'willing_chair' => 'Willing to lead a judging team',
'special_award_only' => 'Judging only for a special award',
'cat_prefs' => 'Category Preferences',
'div_prefs' => 'Division Preferences',
'divsub_prefs' => 'Subdivision Preferences',
'languages' => 'Languages',
'highest_psd' => 'Highest post-secondary degree',
'expertise_other' => 'Other areas of expertise',
'sponsors_id' => 'Sponsor',
'primary' => 'Primary Contact',
'position' => 'Position',
'notes' => 'Notes',
'schools_id' => 'School',
'grade' => 'Grade',
'special_awards' => 'Special Awards',
'available_times' => 'Times Available'
'salutation' => array('label' => 'Salutation', 'group' => 'Personal Information'),
'firstname' => array('label' => 'First Name', 'group' => 'Personal Information'),
'lastname' => array('label' => 'Last Name', 'group' => 'Personal Information'),
'sex' => array('label' => 'Sex', 'group' => 'Personal Information'),
'phonehome' => array('label' => 'Home Phone', 'group' => 'Contact Information'),
'phonework' => array('label' => 'Work Phone', 'group' => 'Contact Information'),
'phonecell' => array('label' => 'Cell Phone', 'group' => 'Contact Information'),
'fax' => array('label' => 'Fax Number', 'group' => 'Contact Information'),
'organization' => array('label' => 'Organization', 'group' => 'Contact Information'),
'birthdate' => array('label' => 'Date of Birth', 'group' => 'Personal Information'),
'lang' => array('label' => 'Language', 'group' => 'Contact Information'),
'address' => array('label' => 'Address', 'group' => 'Contact Information'),
'address2' => array('label' => '', 'group' => 'Contact Information'),
'city' => array('label' => 'City', 'group' => 'Contact Information'),
'province' => array('label' => 'Province', 'group' => 'Contact Information'),
'postalcode' => array('label' => 'Postal Code', 'group' => 'Contact Information'),
'firstaid' => array('label' => 'First Aid', 'group' => 'Personal Information'),
'cpr' => array('label' => 'CPR', 'group' => 'Personal Information'),
'displayemail' => array('label' => 'Display Email', 'group' => 'Personal Information'),
'years_school' => array('label' => 'Years experience judging at school level', 'group' => 'Judges'),
'years_regional' => array('label' => 'Years experience judging at regional level', 'group' => 'Judges'),
'years_national' => array('label' => 'Years experience judging at national level', 'group' => 'Judges'),
'willing_chair' => array('label' => 'Willing to lead a judging team', 'group' => 'Judges'),
'special_award_only' => array('label' => 'Judging only for a special award', 'group' => 'Judges'),
'cat_prefs' => array('label' => 'Category Preferences', 'group' => 'Judges'),
'div_prefs' => array('label' => 'Division Preferences', 'group' => 'Judges'),
'divsub_prefs' => array('label' => 'Subdivision Preferences', 'group' => 'Judges'),
'languages' => array('label' => 'Languages', 'group' => 'Judges'),
'highest_psd' => array('label' => 'Highest post-secondary degree', 'group' => 'Judges'),
'expertise_other' => array('label' => 'Other areas of expertise', 'group' => 'Judges'),
'sponsors_id' => array('label' => 'Sponsor', 'group' => 'Sponsors'),
'primary' => array('label' => 'Primary Contact', 'group' => 'Sponsors'),
'position' => array('label' => 'Position', 'group' => 'Sponsors'),
'notes' => array('label' => 'Notes', 'group' => 'Sponsors'),
'schools_id' => array('label' => 'School', 'group' => 'Personal'),
'grade' => array('label' => 'Grade', 'group' => 'Personal Information'),
'special_awards' => array('label' => 'Special Awards', 'group' => 'Judges'),
'available_times' => array('label' => 'Times Available', 'group' => 'Judges,Volunteers')
);
}
@ -415,12 +415,13 @@ function user_get_fields($userRoles = null){
$fieldType[$row['Field']] = $row['Type'];
}
$fieldLabels = user_get_field_labels();
$fieldInfo = user_get_field_info();
foreach($fields as $fieldName => $field){
$ftype = $fieldType[$fieldName];
if(array_key_exists($fieldName, $fieldLabels)){
$fields[$fieldName]['display'] = $fieldLabels[$fieldName];
if(array_key_exists($fieldName, $fieldInfo)){
$fields[$fieldName]['display'] = i18n($fieldInfo[$fieldName]['label']);
$fields[$fieldName]['group'] = i18n($fieldInfo[$fieldName]['group']);
}
switch($fieldName){
case 'languages':
@ -513,7 +514,7 @@ function user_get_fields($userRoles = null){
if(count(array_intersect($specialFieldRoles['special_awards'], $userRoles)) > 0){
$fields['special_awards'] = array();
$fields['special_awards']['field'] = 'special_awards';
$fields['special_awards']['display'] = $fieldLabels['special_awards'];
$fields['special_awards']['display'] = $fieldInfo['special_awards']['label'];
$fields['special_awards']['type'] = 'multiselectlist';
$fields['special_awards']['options'] = array('yes' => 'Yes', 'no' => 'No');
$fields['special_awards']['entries'] = get_special_awards($conference['id']);
@ -523,7 +524,7 @@ function user_get_fields($userRoles = null){
if(count(array_intersect($specialFieldRoles['available_times'], $userRoles)) > 0){
$fields['available_times'] = array();
$fields['available_times']['field'] = 'available_times';
$fields['available_times']['display'] = $fieldLabels['available_times'];
$fields['available_times']['display'] = $fieldInfo['available_times'];
$fields['available_times']['type'] = 'multiselectlist';
$fields['available_times']['options'] = array('yes' => 'Yes', 'no' => 'No');
$fields['available_times']['entries'] = array();
@ -898,11 +899,11 @@ function user_set_school($u, $schoolId, $schoolCode){
// now just a skin on top of account_add_role
function user_add_role(&$u, $role, $password = null){
$row = mysql_fetch_assoc(mysql_query("SELECT conferences_id FROM users WHERE id = " . $u['id']));
if(!is_array($q)){
return 'no conference';
}
$conference_id = $q['conferences_id'];
$result = account_add_role($u['accounts_id'], $roles[$role]['id'], $password);
$conferences_id = $row['conferences_id'];
$row = mysql_fetch_assoc(mysql_query("SELECT id FROM roles WHERE `type` = '$role'"));
$roleId = $row['id'];
$result = account_add_role($u['accounts_id'], $roleId, $conferences_id, $password);
if($result == 'ok'){
// we need this "if" because account_add_role will return "ok" if they already have this role
if(!in_array($role, $_SESSION['roles'])){