view->headTitle()->append("Signup for our Newsletter"); $ccConfigOBJ = new CC_Config(); $ccContactOBJ = new CC_Contact(); $ccListOBJ = new CC_List(); if ($this->getRequest()->isPost()) { $postFields = array(); // ## PROCESS BASIC FIELDS ## // @$postFields["email_address"] = $_POST["EmailAddress"]; @$postFields["first_name"] = $_POST["FirstName"]; @$postFields["last_name"] = $_POST["LastName"]; @$postFields["middle_name"] = $_POST["MiddleName"]; @$postFields["company_name"] = $_POST["CompanyName"]; @$postFields["job_title"] = $_POST["JobTitle"]; @$postFields["home_number"] = $_POST["HomePhone"]; @$postFields["work_number"] = $_POST["WorkPhone"]; @$postFields["address_line_1"] = $_POST["Addr1"]; @$postFields["address_line_2"] = $_POST["Addr2"]; @$postFields["address_line_3"] = $_POST["Addr3"]; @$postFields["city_name"] = $_POST["City"]; @$postFields["state_code"] = $_POST["StateCode"]; @$postFields["state_name"] = $_POST["StateName"]; @$postFields["country_code"] = $_POST["CountryCode"]; @$postFields["zip_code"] = $_POST["PostalCode"]; @$postFields["sub_zip_code"] = $_POST["SubPostalCode"]; @$postFields["notes"] = $_POST["Note"]; @$postFields["mail_type"] = $_POST["EmailType"]; // ## PROCESS CUSTOM FIELDS ## // $postFields["custom_fields"] = array(); foreach ($_POST as $key => $val) { if (strncmp($key, 'CustomField', strlen('CustomField')) === 0) { $postFields["custom_fields"][substr($key, strlen('CustomField'), strlen($key) - 1)] = $val; } } // ## PROCESS LISTS ## // $allLists = $ccListOBJ->getLists('', true); foreach ($allLists as $k => $item) { if ($_POST['Lists'] && ! empty($_POST['Lists'])) { if (in_array($item['title'], $_POST['Lists'])) { $postFields["lists"][] = $item['id']; } } else { if (in_array($item['title'], $ccConfigOBJ->contact_lists)) { $postFields["lists"][] = $item['id']; } } } $contactXML = $ccContactOBJ->createContactXML(null, $postFields); if ($ccContactOBJ->addSubscriber($contactXML)) { $this->_forward('success'); } else { $this->_forward('error'); } } } public function errorAction() { } public function successAction() { } }