diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 3fdcd7c..38b10c1 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -67 +68 diff --git a/db/db.update.68.sql b/db/db.update.68.sql new file mode 100644 index 0000000..7045512 --- /dev/null +++ b/db/db.update.68.sql @@ -0,0 +1,35 @@ +ALTER TABLE `users` ADD `birthdate` DATE NOT NULL AFTER `organization` ; +ALTER TABLE `users` ADD `lang` VARCHAR( 2 ) NOT NULL AFTER `birthdate` ; +ALTER TABLE `users` ADD `sex` ENUM( 'male', 'female' ) NOT NULL AFTER `lastname` ; + +INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) +VALUES ( +'volunteer_personal_fields', 'phonehome,phonecell,org', +'Volunteer Registration', 'multisel', +'sex=Gender|phonehome=Home Phone|phonework=Work Phone|phonecell=Cell Phone|fax=Fax|org=Organization|birthdate=Birthdate|lang=Preferred Language|address=Address and PostalCode|city=City|province=Province', +'500', 'Personal Information to ask for on the Volunteer personal information page (in addition to Name and Email)', '-1'); + + +INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) +VALUES ( +'volunteer_personal_required', '', +'Volunteer Registration', 'multisel', +'sex=Gender|phonehome=Home Phone|phonework=Work Phone|phonecell=Cell Phone|fax=Fax|org=Organization|birthdate=Birthdate|lang=Preferred Language|address=Address and PostalCode|city=City|province=Province', +'600', 'Required Personal Information on the Volunteer personal information page (Name and Email is always required)', '-1'); + +INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) +VALUES ( +'committee_personal_fields', 'phonehome,phonecell,phonework,fax,org', +'Committee Members', 'multisel', +'sex=Gender|phonehome=Home Phone|phonework=Work Phone|phonecell=Cell Phone|fax=Fax|org=Organization|birthdate=Birthdate|lang=Preferred Language|address=Address and PostalCode|city=City|province=Province', +'500', 'Personal Information to ask for on the Committee Member profile page (in addition to Name and Email)', '-1'); + + +INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) +VALUES ( +'committee_personal_required', '', +'Committee Members', 'multisel', +'sex=Gender|phonehome=Home Phone|phonework=Work Phone|phonecell=Cell Phone|fax=Fax|org=Organization|birthdate=Birthdate|lang=Preferred Language|address=Address and PostalCode|city=City|province=Province', +'600', 'Required Personal Information on the Committee Member profile page (Name and Email is always required)', '-1'); + + diff --git a/user.inc.php b/user.inc.php index 1bdf38c..40ef7cc 100644 --- a/user.inc.php +++ b/user.inc.php @@ -408,51 +408,47 @@ function user_judge_registration_status() return "open"; } +$user_personal_fields_map = array( + 'name' => array('firstname','lastname'), + 'email' => array('email'), + 'sex' => array('sex'), + 'phonehome' => array('phonehome'), + 'phonework' => array('phonework'), + 'phonecell' => array('phonecell'), + 'fax' => array('fax'), + 'org' => array('organization'), + 'birthdate' => array('birthdate'), + 'lang' => array('lang'), + 'address' => array('address', 'address2', 'postalcode'), + 'city' => array('city'), + 'province' => array('province')); + function user_personal_fields($type) { - /* Figure out what fields we should show. */ - $all_fields = array('firstname','lastname','email','phonehome','phonecell','organization'); - switch($type) { - case 'volunteer': - $f = array(); - break; - case 'committee': - $f = array('phonework','fax'); - break; - case 'judge': - $f = array(); - break; - case 'student': - $f = array(); - break; - case 'region': - $f = array(); - break; + global $config, $user_personal_fields_map; + $ret = array('firstname','lastname','email'); + $fields = $config["{$type}_personal_fields"]; + if($fields != '') { + $fields = split(',', $fields); + foreach($fields as $f) { + $ret = array_merge($ret, $user_personal_fields_map[$f]); + } } - return array_merge($all_fields, $f); + return $ret; } function user_personal_required_fields($type) { - $all_fields = array('firstname','lastname','email'); - switch($type) { - case 'volunteer': - $f = array(); - break; - case 'committee': - $f = array(); - break; - case 'judge': - $f = array(); - break; - case 'student': - $f = array(); - break; - case 'region': - $f = array(); - break; + global $config, $user_personal_fields_map; + $ret = array('firstname','lastname','email'); + $required = $config["{$type}_personal_required"]; + if($required != '') { + $fields = split(',', $required); + foreach($fields as $f) { + $ret = array_merge($ret, $user_personal_fields_map[$f]); + } } - return array_merge($all_fields, $f); + return $ret; } function user_personal_info_status($u = false) @@ -462,7 +458,8 @@ function user_personal_info_status($u = false) } $required = array(); foreach($u['types'] as $t) { - $required = array_merge($required, user_personal_required_fields($t)); + $required = array_merge($required, + user_personal_required_fields($t)); } foreach($required as $r) { $val = trim($u[$r]); diff --git a/user_personal.php b/user_personal.php index 0242e77..39488ed 100644 --- a/user_personal.php +++ b/user_personal.php @@ -54,21 +54,20 @@ $fields = array(); $required = array(); foreach($u['types'] as $t) { - $fields = array_merge($fields, + $fields = array_merge($fields, user_personal_fields($t)); - $required = array_merge($required, + $required = array_merge($required, user_personal_required_fields($t)); } if(committee_auth_has_access('super')) { - /* If the editer is super, let them see/edit/save the password */ + /* If the editer is super, let them see/edit/save the user/pass */ + $fields[] = 'username'; $fields[] = 'password'; } if($_POST['action']=="save") { - - /* Set values */ foreach($fields as $f) { $u[$f] = mysql_escape_string(stripslashes($_POST[$f])); @@ -157,7 +156,7 @@ function item($user, $text, $fname) global $fields, $required; if(in_array($fname, $fields)) { - echo ''.i18n($text).''; + echo ''.i18n($text).': '; echo ""; if(in_array($fname, $required)) echo REQUIREDFIELD; echo ''; @@ -181,6 +180,10 @@ item($u, "Last Name", 'lastname'); echo "\n"; echo "\n"; item($u, "Email Address", 'email'); +echo ''; +echo "\n"; +echo "\n"; +item($u, "Username", 'username'); item($u, "Password", 'password'); echo "\n"; echo "\n"; @@ -190,7 +193,7 @@ echo "\n"; echo "\n"; item($u, "City", 'city'); if(in_array('province', $fields)) { - echo ''.i18n('Province').''; + echo ''.i18n('Province').': '; echo ''; emit_province_selector("province",$judgeinfo->province,"onchange=\"fieldChanged()\""); if(in_array('province', $required)) echo REQUIREDFIELD; @@ -223,9 +226,7 @@ echo ""; /* Committee specific fields */ if(in_array('committee', $u['types'])) { - echo "\n"; - item($u, "Email (Private)", 'emailprivate'); - echo ""; + echo "
"; echo "\n"; echo "
".i18n("Email (Private)").":
".i18n("Display Emails").":";