示例#1
0
function save_person_salsa($s)
{
    global $db;
    global $DIA;
    #parse types
    if ($s['type']) {
        foreach ($s['type'] as $item) {
            $s[$item] = 1;
        }
    }
    $tags = array();
    #parse tag types
    if ($s['activist_skills']) {
        foreach ($s['activist_skills'] as $i) {
            $tags[] = $i;
        }
    }
    if ($s['activist_interests']) {
        foreach ($s['activist_interests'] as $i) {
            $tags[] = $i;
        }
    }
    if ($s['issues']) {
        foreach ($s['issues'] as $i) {
            $tags[] = $i;
        }
    }
    $s['tag'] = $tags;
    #parse group types
    if ($s['email_lists']) {
        $s['group_KEYS'] = $s['email_lists'];
    }
    #parse trigger types
    if ($s['email_triggers']) {
        $email_triggers = person_parse_triggers($s['email_triggers']);
        $s = array_merge($s, $email_triggers);
    }
    if ($s['supporter_KEY']) {
        $s['key'] = $s['supporter_KEY'];
        #if update remove the tags from the supporter
        delete_tags($s['supporter_KEY'], 'Skill');
        delete_tags($s['supporter_KEY'], 'Volunteer');
        delete_tags($s['supporter_KEY'], 'Issue');
        unset($s['supporter_KEY']);
    }
    # make sure that corps dont get on the email list
    if ($s['corporate'] == 1 or $s['celeberit'] == 1) {
        $s['Receive_Email'] = '-99';
    }
    if ($s['Email']) {
        $supporter = check_supporter($s['Email']);
        if ($supporter['supporter_KEY']) {
            if ($supporter['Receive_Email']) {
                unset($s['Receive_Email']);
            }
        }
    }
    #print_r($s); die();
    $supporter_KEY = $DIA->save('supporter', $s);
    return $supporter_KEY;
}
示例#2
0
function insert_uploaded_data($up, $groups_KEY = NULL)
{
    global $DIA;
    $num = count($up);
    for ($c = 0; $c < $num; $c++) {
        unset($data[$c]);
        $data[$c]['Prefix'] = clean_crap($up[$c][0]);
        $data[$c]['First_Name'] = clean_crap($up[$c][1]);
        $data[$c]['Last_Name'] = clean_crap($up[$c][2]);
        $data[$c]['Suffix'] = clean_crap($up[$c][3]);
        $data[$c]['Occupation'] = clean_crap($up[$c][4]);
        $data[$c]['Organization'] = clean_crap($up[$c][5]);
        $data[$c]['TYPE'] = clean_crap($up[$c][6]);
        $data[$c]['sector'] = clean_crap($up[$c][7]);
        $data[$c]['Point_Person'] = clean_crap($up[$c][8]);
        $data[$c]['Email'] = clean_crap($up[$c][9]);
        $data[$c]['Phone'] = clean_crap($up[$c][10]);
        $data[$c]['Cell_Phone'] = clean_crap($up[$c][11]);
        $data[$c]['Work_Phone'] = clean_crap($up[$c][12]);
        $data[$c]['Street'] = clean_crap($up[$c][13]);
        $data[$c]['Street_2'] = clean_crap($up[$c][14]);
        $data[$c]['City'] = clean_crap($up[$c][15]);
        $data[$c]['State'] = clean_crap($up[$c][16]);
        $data[$c]['Zip'] = clean_crap($up[$c][17]);
        $data[$c]['Country'] = clean_crap($up[$c][18]);
        $data[$c]['twitter'] = clean_crap($up[$c][19]);
        $data[$c]['Web_Page'] = clean_crap($up[$c][20]);
        $data[$c]['skype'] = clean_crap($up[$c][21]);
        $data[$c]['Notes'] = clean_crap($up[$c][22]);
        if ($c != 0) {
            $campaign_manager_KEY = get_campaign_manager($data[$c]['Point_Person']);
            if (!$campaign_manager_KEY) {
                echo 'All fields need point person Error on line ' . $c . ', Person: ' . $data[$c]['First_Name'] . ' ' . $data[$c]['Last_Name'];
                return FALSE;
            }
            if ($data[$c]['Country']) {
                $data[$c]['Country'] = check_country($data[$c]['Country']);
            }
            if ($data[$c]['State']) {
                #$data[$c]['State'] = check_state($data[$c]['State']);
            }
            $data[$c]['point_campaign_manager_KEY'] = $campaign_manager_KEY;
            $data[$c]['campaign_manager_KEY'] = $campaign_manager_KEY;
            $data[$c]['Tracking_Code'] = 'Jaguar';
            if ($data[$c]['TYPE']) {
                $data[$c][strtolower($data[$c]['TYPE'])] = 1;
            } else {
                echo 'All fields need a contact type that is valid Error on line ' . $c . ', Person: ' . $data[$c]['First_Name'] . ' ' . $data[$c]['Last_Name'];
                return FALSE;
            }
            if ($data[$c]['TYPE'] == 'corporate' or $data[$c]['TYPE'] == 'celebrity') {
                $data[$c]['Receive_Email'] = '-99';
            }
            unset($supporter);
            if ($data[$c]['Email']) {
                $supporter = check_supporter($data[$c]['Email']);
                if ($supporter['supporter_KEY']) {
                    $data[$c]['key'] = $supporter['supporter_KEY'];
                    if ($supporter['Receive_Email']) {
                        unset($data[$c]['Receive_Email']);
                    }
                }
            }
            $data[$c] = remove_empty_data_fields($data[$c], $supporter);
            #echo '<pre>';
            #print_r($data[$c]);
            #echo '</pre>';
        }
    }
    $dnum = count($data);
    for ($x = 0; $x < $dnum; $x++) {
        if ($x != 0) {
            #print_r($data[$x]);
            $supporter_KEY = $DIA->save('supporter', $data[$x]);
            #save to group
            if ($groups_KEY) {
                $g_data['groups_KEY'] = $groups_KEY;
                $g_data['supporter_KEY'] = $supporter_KEY;
                #print_r($g_data);
                $DIA->save('supporter_groups', $g_data);
            }
            sync_person_monsterpants($supporter_KEY);
        }
    }
    echo $c - 1 . ' lines inserted<br>';
    return TRUE;
}