Check if they are alreayd a parent and dont re-add if they are

Also fix levengshtein distances for mere and pere with UTF8
This commit is contained in:
james 2009-10-22 20:31:52 +00:00
parent f165f39870
commit 101c3c7723
2 changed files with 11 additions and 8 deletions

View File

@ -1 +1 @@
148
149

View File

@ -1,8 +1,8 @@
<?
//146 user inc works fine here
include "db.update.146.inc.php";
include "db.update.146.user.inc.php";
function db_update_142_post() {
function db_update_149_post() {
$q=mysql_query("SELECT * FROM emergencycontact");
while($r=mysql_fetch_object($q)) {
$relation=strtolower(trim($r->relation));
@ -10,9 +10,9 @@ function db_update_142_post() {
|| levenshtein('mother',$relation)<3
|| levenshtein('father',$relation)<3
|| levenshtein('mom',$relation)<2
|| levenshtein('mere',$relation)<2
|| levenshtein('mere',$relation)<3
|| levenshtein('dad',$relation)<2
|| levenshtein('pere',$relation)<2
|| levenshtein('pere',$relation)<3
|| strstr($relation,'dad')
|| strstr($relation,'mom')
|| (strstr($relation,"mother") && !strstr($relation,"grand"))
@ -23,8 +23,11 @@ function db_update_142_post() {
if($r->email) {
echo " Have email, creating record - $r->email\n";
if($u=db146_user_load_by_email($r->email)) {
echo "This user already exists, linking parent record to their account!";
db146_user_create("parent",$r->email,$u);
echo " This user already exists, linking parent record to their account!\n";
if(!in_array("parent",$u['types']))
db146_user_create("parent",$r->email,$u);
else
echo " - Already a parent, no need to re-add!\n";
}
else {
echo "Creating new parent record\n";
@ -37,7 +40,7 @@ function db_update_142_post() {
}
}
else {
echo "No email address, skipping";
echo " No email address, skipping\n";
}
}
else {