- Change the user editor, read the fields and required fields from a config

variable, this will allow the committee to specify exactly what they
  wish to collect (and which fields are requried)
- Insert config variables for volunteers and committee
This commit is contained in:
dave 2007-11-26 02:28:45 +00:00
parent 9eca885410
commit 55983aca38
4 changed files with 82 additions and 49 deletions

View File

@ -1 +1 @@
67
68

35
db/db.update.68.sql Normal file
View File

@ -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');

View File

@ -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]);

View File

@ -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 '<td>'.i18n($text).'</td>';
echo '<td>'.i18n($text).': </td>';
echo "<td><input onchange=\"fieldChanged()\" type=\"text\" name=\"$fname\" value=\"{$user[$fname]}\" />";
if(in_array($fname, $required)) echo REQUIREDFIELD;
echo '</td>';
@ -181,6 +180,10 @@ item($u, "Last Name", 'lastname');
echo "</tr>\n";
echo "<tr>\n";
item($u, "Email Address", 'email');
echo '<td></td><td></td>';
echo "</tr>\n";
echo "<tr>\n";
item($u, "Username", 'username');
item($u, "Password", 'password');
echo "</tr>\n";
echo "<tr>\n";
@ -190,7 +193,7 @@ echo "</tr>\n";
echo "<tr>\n";
item($u, "City", 'city');
if(in_array('province', $fields)) {
echo '<td>'.i18n('Province').'</td>';
echo '<td>'.i18n('Province').': </td>';
echo '<td>';
emit_province_selector("province",$judgeinfo->province,"onchange=\"fieldChanged()\"");
if(in_array('province', $required)) echo REQUIREDFIELD;
@ -223,9 +226,7 @@ echo "</table>";
/* Committee specific fields */
if(in_array('committee', $u['types'])) {
echo "<table><tr>\n";
item($u, "Email (Private)", 'emailprivate');
echo "</tr>";
echo "<table>";
echo "<tr><td>".i18n("Email (Private)").":</td><td><input size=\"25\" type=\"text\" name=\"emailprivate\" value=\"{$u['emailprivate']}\" /></td></tr>\n";
echo "<tr><td>".i18n("Display Emails").":</td><td>";