Privacy Preferences

getTemplate(); $userEmail = $_GET[“email”]; $firmwareContact = false; $mailingListContact = false; $optOutAll = false; $leadOptin = false; $contactOptin = false; $showFirmware = false; $showMailinglist = false; /* GET salesforce data */ function getSalesforceData($email) { $curl = curl_init(); $url = $_SERVER[‘SERVER_NAME’] . “/sf/get/contact_prefs.php”; $curl_post_data = array( ’email’ => $email ); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); $curl_response = curl_exec($curl); if ($curl_response === false) { $info = curl_getinfo($curl); curl_close($curl); die(‘error occured during curl exec. Additioanl info: ‘ . var_export($info)); } curl_close($curl); $salesforceUserData = json_decode($curl_response, true); return $salesforceUserData; } /* SET salesforce data */ function setSalesforceData($postData) { $curl = curl_init(); $url = $_SERVER[‘SERVER_NAME’] . “/sf/set/contact_prefs.php”; $contactData = json_encode($postData[0][‘Contact’]); $leadData = json_encode($postData[0][‘Lead’]); $regData = ‘[‘.json_encode($postData[0][‘reg__c’][0]).’]’; $curl_post_data = array( ‘Contact’ => $contactData, ‘Lead’ => $leadData, ‘reg__c’ => $regData ); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array(‘Content-Type:multipart/form-data’)); curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); $curl_response = curl_exec($curl); if ($curl_response === false) { $info = curl_getinfo($curl); curl_close($curl); die(‘error occured during curl exec. Additioanl info: ‘ . var_export($info)); } curl_close($curl); $salesforceResponse = json_decode($curl_response, true); return $salesforceResponse; } /* process form POST data */ if (!empty($_POST)) { $salesforceData = getSalesforceData($_POST[’email’]); $postData = array(); foreach($salesforceData as $key => $item) { if ($key == ‘payload’) { $postData[] = $item[0]; } } $regData = $postData[0][‘reg__c’]; $contactData = $postData[0][‘Contact’]; $leadData = $postData[0][‘Lead’]; if (isset($_POST[‘firmware-optin’])) { foreach ($regData as $regIndex => $regItem) { $postData[0][‘reg__c’][$regIndex][‘HasOptedOutOfEmail__c’] = false; } } else { foreach ($regData as $regIndex => $regItem) { $postData[0][‘reg__c’][$regIndex][‘HasOptedOutOfEmail__c’] = true; } } if (isset($_POST[‘mailinglist-optin’])) { // $postData[0][‘Contact’][0][‘HasOptedOutOfEmail’] = false; // $postData[0][‘Contact’][0][‘Mailing_List__c’] = true; foreach ($contactData as $contactIndex => $contactItem) { $postData[0][‘Contact’][$contactIndex][‘HasOptedOutOfEmail’] = false; $postData[0][‘Contact’][$contactIndex][‘Mailing_List__c’] = true; } foreach ($leadData as $leadIndex => $leadItem) { $postData[0][‘Lead’][$leadIndex][‘HasOptedOutOfEmail’] = false; $postData[0][‘Lead’][$leadIndex][‘Mailing_List__c’] = true; } } else { // $postData[0][‘Contact’][0][‘HasOptedOutOfEmail’] = true; // $postData[0][‘Contact’][0][‘Mailing_List__c’] = false; foreach ($contactData as $contactIndex => $contactItem) { $postData[0][‘Contact’][$contactIndex][‘HasOptedOutOfEmail’] = true; $postData[0][‘Contact’][$contactIndex][‘Mailing_List__c’] = false; } foreach ($leadData as $leadIndex => $leadItem) { $postData[0][‘Lead’][$leadIndex][‘HasOptedOutOfEmail’] = true; $postData[0][‘Lead’][$leadIndex][‘Mailing_List__c’] = false; } } if (isset($_POST[‘optout’])) { foreach ($regData as $regIndex => $regItem) { $postData[0][‘reg__c’][$regIndex][‘HasOptedOutOfEmail__c’] = true; } foreach ($contactData as $contactIndex => $contactItem) { $postData[0][‘Contact’][$contactIndex][‘HasOptedOutOfEmail’] = true; $postData[0][‘Contact’][$contactIndex][‘Mailing_List__c’] = false; } foreach ($leadData as $leadIndex => $leadItem) { $postData[0][‘Lead’][$leadIndex][‘HasOptedOutOfEmail’] = true; $postData[0][‘Lead’][$leadIndex][‘Mailing_List__c’] = false; } // $postData[0][‘reg__c’][0][‘HasOptedOutOfEmail__c’] = true; // $postData[0][‘Contact’][0][‘HasOptedOutOfEmail’] = true; // foreach($postData[0][‘Lead’] as $leads => $leadItem) { // $leadItem[‘HasOptedOutOfEmail’] = true; // } } $response = setSalesforceData($postData); echo ‘

Thank you. Your communication preferences have been updated.

You can return to this page at any time to change your preferences.

‘; } /* page load functions */ if (!empty($userEmail)) { $salesforceData = getSalesforceData($userEmail); $payloadData = array(); foreach($salesforceData as $key => $item) { if ($key == ‘payload’) { $payloadData[] = $item[0]; } } foreach($payloadData as $lists => $value) { foreach($value as $sublist => $subitems) { if ($sublist == ‘reg__c’ && count($subitems) > 0) { foreach($subitems as $firmware => $firmwareItem) { if (isset($firmwareItem[‘HasOptedOutOfEmail__c’]) && $firmwareItem[‘HasOptedOutOfEmail__c’] == false) { $firmwareContact = true; } } } else if($sublist == ‘Contact’ && count($subitems) > 0) { foreach($subitems as $contact => $contactItem) { if (isset($contactItem[‘HasOptedOutOfEmail’]) && $contactItem[‘HasOptedOutOfEmail’] == false && isset($contactItem[‘Mailing_List__c’]) && $contactItem[‘Mailing_List__c’] == true) { $contactOptin = true; } } } else if($sublist == ‘Lead’ && count($subitems) > 0) { foreach($subitems as $lead => $leadItems) { foreach($leadItems as $leadData => $leadDataItem) { if (isset($leadDataItem[‘HasOptedOutOfEmail’]) && $leadDataItem[‘HasOptedOutOfEmail’] == false && isset($leadDataItem[‘Mailing_List__c’]) && $leadDataItem[‘Mailing_List__c’] == true) { $leadOptin = true; } else if (isset($leadDataItem[‘HasOptedOutOfEmail’]) && $leadDataItem[‘HasOptedOutOfEmail’] == true) { $leadOptin = false; } } } } } } if ($contactOptin == true || $leadOptin == true) { $mailingListContact = true; } } ?>

Privacy Preferences

Use the form below to set your communication preferences with us. We will only contact you if you have opted in to one of our mailing lists.

<input type="email" name="email" id="email" class="form-control" value="”>