Ejemplo n.º 1
0
function SearchContactsByEmail($username, $session, $emailaddress)
{
    if (!validateSession($username, $session)) {
        return null;
    }
    require_once 'modules/Contacts/Contacts.php';
    require_once 'modules/Leads/Leads.php';
    require_once 'modules/Accounts/Accounts.php';
    $seed_contact = new Contacts();
    $output_list = array();
    //To avoid Blind SQL injection we are validating the Email address.
    if (filter_var($emailaddress, FILTER_VALIDATE_EMAIL) == false) {
        return null;
    }
    $response = $seed_contact->get_searchbyemailid($username, $emailaddress);
    $contactList = $response['list'];
    // create a return array of names and email addresses.
    foreach ($contactList as $contact) {
        $output_list[] = array("id" => $contact[contactid], "firstname" => decode_html($contact[firstname]), "lastname" => decode_html($contact[lastname]), "accountname" => decode_html($contact[accountname]), "emailaddress" => decode_html($contact[email]), "category" => "Contact");
    }
    // crm-now added Lead functionality
    $seed_lead = new Leads();
    $response2 = $seed_lead->get_searchbyemailid($username, $emailaddress);
    $leadList = $response2['list'];
    foreach ($leadList as $lead) {
        $output_list[] = array("id" => $lead[leadid], "firstname" => decode_html($lead[firstname]), "lastname" => decode_html($lead[lastname]), "accountname" => decode_html($lead[company]), "emailaddress" => decode_html($lead[email]), "category" => "Lead");
    }
    // crm-now added Accounts functionality
    $acc_lead = new Accounts();
    $response3 = $acc_lead->get_searchbyemailid($username, $emailaddress);
    $accList = $response3['list'];
    foreach ($accList as $acc) {
        $output_list[] = array("id" => $acc['accountid'], "firstname" => decode_html($acc['account_no']), "lastname" => decode_html($acc['accountname']), "accountname" => '', "emailaddress" => decode_html($acc['email1']), "category" => "Account");
    }
    // end crm-now
    //to remove an erroneous compiler warning
    $seed_contact = $seed_contact;
    $seed_lead = $seed_lead;
    $acc_lead = $acc_lead;
    return $output_list;
}