forked from science-ation/science-ation
Change sex field in 116 so judges also default to NULL
Add start of sponsor contacts conversion to user system for fundraising module
This commit is contained in:
parent
35d3211391
commit
f981858df9
@ -1,5 +1,6 @@
|
||||
|
||||
ALTER TABLE `users` ADD `uid` INT NOT NULL AFTER `id` ;
|
||||
ALTER TABLE `users` CHANGE `sex` `sex` ENUM( 'male', 'female' ) NULL DEFAULT NULL ;
|
||||
|
||||
ALTER TABLE `users_committee` CHANGE `active` `committee_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
|
||||
ALTER TABLE `users_committee` ADD `committee_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `committee_active` ;
|
||||
|
75
db/db.update.118.php
Normal file
75
db/db.update.118.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?
|
||||
function db_update_118_post()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$userfields=array("salutation","firstname","lastname","email","phonehome","phonework","phonecell","fax");
|
||||
|
||||
//grab all the contacts from awards_contacts
|
||||
$q=mysql_query("SELECT * FROM award_contacts");
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
|
||||
//if its older than the current year, then set them to complete/active because if they were in the
|
||||
//system then, then they must have beenc omplete and active
|
||||
//set anyone for the current fair year to complete=no, active = yes, because its not too late to get them
|
||||
//to login and make sure that all the info is complete
|
||||
if($r->year<$config['FAIRYEAR']) {
|
||||
$complete="yes";
|
||||
$active="yes";
|
||||
}
|
||||
else {
|
||||
$complete="no";
|
||||
$active="yes";
|
||||
}
|
||||
//see if a user exists with this email
|
||||
$uq=mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($r->email)."' AND year='$r->year'");
|
||||
if($r->email && $ur=mysql_fetch_object($uq)) {
|
||||
$user_id=$ur->id;
|
||||
echo "Using existing users.id=$user_id for award_contacts.id=$r->id because email address/year ($r->email/$r->year) matches\n";
|
||||
|
||||
//update any info we have thats missing
|
||||
$sqlset="";
|
||||
foreach($userfields AS $f) {
|
||||
//if its NOT in their USER record, but it IS in their AWARD_CONTACTS record, then bring it over, else, assume the users record has priority
|
||||
if(!$ur->$f && $r->$f) {
|
||||
$sqlset.="`$f`='".mysql_real_escape_string($r->$f)."', ";
|
||||
}
|
||||
}
|
||||
$sql="UPDATE users SET $sqlset `types`='{$ur->types},sponsor' WHERE id='$user_id'";
|
||||
mysql_query($sql);
|
||||
echo mysql_error();
|
||||
echo " Updated user record\n";
|
||||
|
||||
}
|
||||
else {
|
||||
$sql="INSERT INTO users (`types`,`username`,`".implode("`,`",$userfields)."`,`year`) VALUES (";
|
||||
$sql.="'sponsor','".mysql_real_escape_string($r->email)."'";
|
||||
foreach($userfields AS $f) {
|
||||
$sql.=",'".mysql_real_escape_string($r->$f)."'";
|
||||
}
|
||||
$sql.=",'".mysql_real_escape_string($r->year)."')";
|
||||
mysql_query($sql);
|
||||
echo mysql_error();
|
||||
|
||||
$user_id=mysql_insert_id();
|
||||
//and link it to themselves as a starting record
|
||||
mysql_query("UPDATE users SET uid='$user_id' WHERE id='$user_id'");
|
||||
echo "Creating new users.id=$user_id for award_contacts.id=$r->id\n";
|
||||
|
||||
}
|
||||
|
||||
echo " Linking $user_id to users_sponsor record\n";
|
||||
mysql_query("INSERT INTO users_sponsor (`users_id`,`sponsors_id`,`sponsor_complete`,`sponsor_active`,`primary`,`position`,`notes`) VALUES (
|
||||
'".$user_id."',
|
||||
'".$r->award_sponsors_id."',
|
||||
'$complete',
|
||||
'$active',
|
||||
'".mysql_real_escape_string($r->primary)."',
|
||||
'".mysql_real_escape_string($r->position)."',
|
||||
'".mysql_real_escape_string($r->notes)."')");
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
29
db/db.update.118.sql
Normal file
29
db/db.update.118.sql
Normal file
@ -0,0 +1,29 @@
|
||||
CREATE TABLE `users_sponsor` (
|
||||
`users_id` int(11) NOT NULL default '0',
|
||||
`sponsors_id` int(11) NOT NULL default '0',
|
||||
`sponsor_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
|
||||
`sponsor_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
|
||||
`primary` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
|
||||
`position` VARCHAR(64) NOT NULL default '',
|
||||
`notes` text NOT NULL,
|
||||
PRIMARY KEY (`users_id`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
ALTER TABLE `users` CHANGE `types` `types` SET( 'student', 'judge', 'committee', 'volunteer', 'fair', 'sponsor' ) NOT NULL ;
|
||||
ALTER TABLE `users` ADD `salutation` VARCHAR( 8 ) NOT NULL AFTER `types` ;
|
||||
|
||||
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` )
|
||||
VALUES (
|
||||
'sponsor_personal_fields', 'phonecell,phonework,fax,org',
|
||||
'Sponsors', 'multisel',
|
||||
'salutation=Salutation|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 Sponsor Contact profile page (in addition to Name and Email)', '-1');
|
||||
|
||||
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` )
|
||||
VALUES (
|
||||
'sponsor_personal_required', '',
|
||||
'Sponsors', 'multisel',
|
||||
'salutation=Salutation|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 Sponsor Contact profile page (Name and Email is always required)', '-1');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user