public function unsubscribeAction() { $blockID = $this->_getParam('BlockID'); $this->view->assign('messageConfidentialite', $this->view->getCibleText('joindre_fo_form_label_confident_joindre')); $newsletterID = $this->_getParam('newsletterID'); $back_to_newsletter = !empty($newsletterID) ? "/ID/{$newsletterID}" : ''; $blockParams = Cible_FunctionsBlocks::getBlockParameters($blockID)->toArray(); $newsletterCategoryID = $blockParams[0]['P_Value']; $newsletterCategoryDetails = Cible_FunctionsCategories::getCategoryDetails($newsletterCategoryID); $this->view->assign('newsletterTitle', $newsletterCategoryDetails['CI_Title']); $this->view->assign('subscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8)); $this->view->assign('unsubscribeLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8)); $this->view->assign('back_to_release', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8) . $back_to_newsletter); $this->view->assign('archivesLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8) . '/categoryID/' . $newsletterCategoryID); $form = new FormNewsletterUnsubscription(array()); $this->view->assign('form', $form); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $message = str_replace('###newsletter_title_release###', " <b>{$newsletterCategoryDetails['CI_Title']}</b>", $this->view->getCibleText('newsletter_unsubscribe_confirmation_message')); $this->view->assign('message', $message); $this->view->assign('unsubscribeValidate', true); $genericProfil = new GenericProfile(); $members = $genericProfil->findMembers(array('email' => $formData['email'])); if (count($members) != 0) { $memberID = $members[0]['member_id']; $newsletterProfile = new NewsletterProfile(); $memberDetails = $newsletterProfile->getMemberDetails($memberID); $memberNewsletterCategories = explode(',', $memberDetails['newsletter_categories']); $i = 0; foreach ($memberNewsletterCategories as $newsletterCategory) { if ($newsletterCategory == $newsletterCategoryID) { array_splice($memberNewsletterCategories, $i, 1); } else { $i++; } } if (count($memberNewsletterCategories) == 0) { $newsletterProfile->deleteMember($memberID); } else { $newMemberNewsletterCategories = implode(',', $memberNewsletterCategories); $newsletterProfile->updateMember($memberID, array('newsletter_categories' => $newMemberNewsletterCategories)); } if (empty($newsletterID)) { $newsletterID = 0; } $this->_params = array('memberId' => $memberID, 'releaseId' => $newsletterID, 'category' => $newsletterCategoryID, 'reason' => $formData); $this->logUnsubscribe(); } } } }
public function editAction() { /* * ********************************* */ // variable $webAddr = array(); $addressFields = array(); $memberID = $this->_request->getParam('ID'); $baseDir = $this->view->baseUrl(); $billAddr = array(); $shipAddr = array(); $current_state = ''; $currentCity = ''; $returnModule = $this->_request->getParam('returnModule'); $returnAction = $this->_request->getParam('returnAction'); if ($returnModule != '' && $returnAction != '') { $cancelUrl = $this->view->url(array('module' => $returnModule, 'action' => $returnAction, 'ID' => null, 'returnModule' => null, 'returnAction' => null)); } else { $cancelUrl = $this->view->url(array('action' => 'list', 'ID' => null)); } $this->view->assign('memberID', $memberID); /* * ********************************* */ // newsletter categories $newsletterProfil = new NewsletterProfile(); $newsletterMemberDetails = $newsletterProfil->getMemberDetails($memberID); //$this->view->assign('newsletterMemberDetails',$newsletterMemberDetails); $newsletterCategories = $this->view->GetAllNewsletterCategories(); $newsletterCategories = $newsletterCategories->toArray(); if (is_array($newsletterMemberDetails) && array_key_exists('newsletter_categories', $newsletterMemberDetails) && $newsletterMemberDetails['newsletter_categories'] != "") { $memberNewsletterCategories = $newsletterMemberDetails['newsletter_categories']; $memberNewsletterCategories = explode(',', $memberNewsletterCategories); $memberCat = array(); foreach ($memberNewsletterCategories as $memberCategory) { $memberCat["chkNewsletter{$memberCategory}"] = 1; } } else { $memberCat = array(); } $this->view->assign('memberNewsletterCategories', $memberCat); $this->view->assign('newsletterCategories', $newsletterCategories); // Form $form = new FormProfile(array('baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'langId' => $this->_defaultInterfaceLanguage, 'mode' => 'edit')); $this->view->assign('form', $form); $genericProfil = new GenericProfile(); $genericMemberDetails = $genericProfil->getMemberDetails($memberID); $this->view->assign('genericMemberDetails', $genericMemberDetails); $membersProfil = new MemberProfile(); $lang = $this->_defaultInterfaceLanguage; $membersDetails = $membersProfil->getMemberDetails($memberID); //Retailers data if ($form->getSubForm('membersForm')) { // $oRetailers = new RetailersObject(); $oAddress = new AddressObject(); // $retailerData = $oRetailers->getAll(null, true, $memberID); // if (count($retailerData)) // $retailerAddr = $oAddress->getAll(null, true, $retailerData[0]['R_AddressId']); if (!empty($membersDetails['addrBill'])) { $billAddr = $oAddress->populate($membersDetails['addrBill'], $lang); } if (!empty($membersDetails['addrShip'])) { $shipAddr = $oAddress->populate($membersDetails['addrShip'], $lang); } // $oRetailer = new RetailersObject(); // $onWeb = $oRetailer->getRetailerInfos($membersDetails['member_id'], $lang); // if ($onWeb && !empty($onWeb['R_AddressId'])) // { // $webAddrFr = $oAddress->populate($onWeb['R_AddressId'], 1); // $webAddrEn = $oAddress->populate($onWeb['R_AddressId'], 2); // $webAddr['isDistributeur-1'] = $onWeb['R_Status']; // $form->getSubForm('retailerForm')->getElement('isDistributeur')->setValue($onWeb['R_Status']); // } if (!empty($billAddr)) { $membersDetails['addressFact'] = $billAddr; // $membersDetails['AI_FirstTel'] = $billAddr['AI_FirstTel']; // $membersDetails['AI_SecondTel'] = $billAddr['AI_SecondTel']; // $membersDetails['A_Fax'] = $billAddr['A_Fax']; } if (isset($shipAddr['A_Duplicate']) && !$shipAddr['A_Duplicate']) { $shipAddr['duplicate'] = 0; } if (!empty($shipAddr)) { $membersDetails['addressShipping'] = $shipAddr; } // $membersDetails['retailerForm'] = $webAddrFr; // $membersDetails['retailerFormEn'] = $webAddrEn; $memberForm = $form->getSubForm('membersForm'); $stateBill = $memberForm->getSubForm('addressFact')->getElement('A_StateId'); $stateShip = $memberForm->getSubForm('addressShipping')->getElement('A_StateId'); $countries = Cible_FunctionsGeneral::getCountries(); if (count($webAddr) > 0) { $membersDetails['AI_WebSite'] = $billAddr['AI_WebSite']; $current_state = $billAddr['A_StateId'] . $this->_separ . $shipAddr['A_StateId'] . $this->_separ . $webAddrFr['A_StateId'] . $this->_separ; $currentCity = $billAddr['A_CityId'] . $this->_separ . $shipAddr['A_CityId'] . $this->_separ . $webAddrFr['A_CityId'] . $this->_separ; } elseif (!empty($billAddr) && !empty($shipAddr)) { $current_state = $billAddr['A_StateId'] . $this->_separ . $shipAddr['A_StateId'] . $this->_separ; $currentCity = $billAddr['A_CityId'] . $this->_separ . $shipAddr['A_CityId'] . $this->_separ; } } if ($this->_request->isPost()) { $data = $this->_request->getPost(); $currentCity = $data['retailerForm']['A_CityId']; $current_state = $data['membersForm']['addressFact']['A_StateId'] . $this->_separ; $current_state .= $data['membersForm']['addressShipping']['A_StateId'] . $this->_separ; $current_state .= $data['retailerForm']['A_StateId']; // ksort($data); // $tmpPostAddr = $this->_statesCitiesList($data, $form); // $currentCity = substr($tmpPostAddr['currentCity'], 0, strlen($tmpPostAddr['currentCity'])-1); // $current_state = substr($tmpPostAddr['currentState'], 0, strlen($tmpPostAddr['currentState'])-1); } $this->view->assign('selectedCity', $currentCity); $this->view->assign('selectedState', $current_state); $addressFields = array_unique($addressFields); // if( $memberForm->getElement("isRetailer")->isChecked() ) { // $this->view->headStyle()->appendStyle('dd.validatedBy { display: none }'); // } if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->getSubForm('membersForm')) { $oAddress = new AddressObject(); // Get the addresses data to insert $addressFact = $formData['membersForm']['addressFact']; $addressShipping = $formData['membersForm']['addressShipping']; // $addressRetailer = $formData['retailerForm']; // $addressRetailerEn = $formData['retailerFormEn']; //Remove data form form if the shipping address is the same as bill if ($addressShipping['duplicate'] == 1) { $subFormShip = $form->getSubForm('addressShipping'); foreach ($subFormShip as $key => $value) { $value->clearValidators()->setRequired(false); } unset($formData['addressShipping']); } //If customer doesn't want to add data on website, set to false the field name // if ($addressRetailer['isDistributeur'] == 1) // { // $form->getSubForm('retailerForm')->getElement('AI_Name')->clearValidators()->setRequired(false); // $form->getSubForm('retailerFormEn')->getElement('AI_Name')->clearValidators()->setRequired(false); // } // $form->removeSubForm('addressShipping'); } if ($form->isValid($formData)) { if (array_key_exists('genericForm', $formData)) { $genericForm = $formData['genericForm']; $genericProfil = new GenericProfile(); $langId = $genericForm['language']; $members = $genericProfil->findMembers(array('email' => $genericForm['email'])); if (count($members) == 1 and $members[0]['member_id'] == $memberID or count($members) == 0) { $genericProfil->updateMember($memberID, $genericForm); } else { $form->getSubForm('genericForm')->getElement('email')->addError($this->view->getCibleText('validation_message_used_email')); $cancelUrl = ''; } } if (array_key_exists('newsletterForm', $formData)) { $newsletterForm = $formData['newsletterForm']; $newsletterProfile = new NewsletterProfile(); $cat = ""; foreach ($newsletterForm as $item => $val) { if ($val == 1) { if ($cat == "") { $cat = str_replace('chkNewsletter', '', $item); } else { $cat .= "," . str_replace('chkNewsletter', '', $item); } } } $newsletterProfile->updateMember($memberID, array('newsletter_categories' => $cat)); } if (array_key_exists('membersForm', $formData)) { $membersForm = $formData['membersForm']; $langId = $this->_defaultInterfaceLanguage; if (!empty($membersForm['password'])) { $membersForm['password'] = md5($membersForm['password']); } else { $membersForm['password'] = $membersDetails['password']; } $memberProfil = new MemberProfile(); //get the last data to merge in the billing address // $addressFact['A_Fax'] = $membersForm['A_Fax']; // $addressFact['AI_FirstTel'] = $membersForm['AI_FirstTel']; // $addressFact['AI_SecondTel'] = $membersForm['AI_SecondTel']; // $addressFact['AI_WebSite'] = $membersForm['AI_WebSite']; if (empty($billAddr['A_AddressId'])) { $billAddr['A_AddressId'] = $oAddress->insert($addressFact, $langId); $membersForm['addressFact']['addrBill'] = $billAddr['A_AddressId']; $membersForm['addrBill'] = $billAddr['A_AddressId']; } else { $oAddress->save($billAddr['A_AddressId'], $addressFact, $langId); } if ($addressShipping['duplicate'] == 1) { $addressFact['A_Duplicate'] = $billAddr['A_AddressId']; if (empty($shipAddr['A_AddressId'])) { $shipAddrId = $oAddress->insert($addressFact, $langId); $membersForm['addressShipping']['addrShip'] = $shipAddrId; $membersForm['addrShip'] = $shipAddrId; } else { $oAddress->save($shipAddr['A_AddressId'], $addressFact, $langId); } } else { $addressShipping['A_Duplicate'] = 0; if (empty($shipAddr['A_AddressId'])) { $shipAddrId = $oAddress->insert($addressShipping, $langId); $membersForm['addressShipping']['addrShip'] = $shipAddrId; $membersForm['addrShip'] = $shipAddrId; } else { $oAddress->save($shipAddr['A_AddressId'], $addressShipping, $langId); } } $memberProfil->updateMember($memberID, $membersForm); //If customer doesn't want to add data on website, set to false the field name // switch ($addressRetailer['isDistributeur']) // { // case 1: // if (!empty($onWeb)) // { // $retailerData = array( // 'R_Status' => $addressRetailer['isDistributeur']); // $oRetailer->save($onWeb['R_ID'], $retailerData, $langId); // } // break; // case 2: // if (!empty($webAddrFr)) // { // $retailerData = array( // 'R_Status' => $addressRetailer['isDistributeur']); // $oAddress->save($webAddrFr['A_AddressId'], $addressRetailer, 1); // $oAddress->save($webAddrFr['A_AddressId'], $addressRetailerEn, 2); // $oRetailer->save($onWeb['R_ID'], $retailerData, $langId); // } // else // { // $addressId = $oAddress->insert($addressRetailer, 1); // $oAddress->save($addressId, $addressRetailerEn, 2); // $retailerData = array( // 'R_GenericProfileId' => $memberID, // 'R_AddressId' => $addressId, // 'R_Status' => $addressRetailer['isDistributeur'] // ); // $oRetailer->insert($retailerData, $langId); // } // break; // default: // break; // } } if ($cancelUrl != '') { $this->_redirect(str_replace($baseDir, '', $cancelUrl)); } } } else { $this->view->assign('membersDetails', $membersDetails); if ($genericMemberDetails) { $form->populate($genericMemberDetails); } if ($newsletterMemberDetails) { $form->populate($newsletterMemberDetails); } if ($membersDetails) { $form->populate($membersDetails); } if ($memberCat) { $form->populate($memberCat); } // if( $form->getSubForm('membersForm')->getElement("isRetailer")->isChecked() ) { // $this->view->headStyle()->appendStyle('dd.validatedBy { display: none }'); // } $this->view->assign('form', $form); } }
public function userExistsAction() { $email = $this->_getParam('GP_Email'); $id = $this->_getParam('id'); $isValid = true; $oGenericProfile = new GenericProfile(); $profiles = $oGenericProfile->findMembers(array('email' => $email)); foreach ($profiles as $key => $profile) { if ($profile['member_id'] == $id) { unset($profiles[$key]); break; } } if (count($profiles) > 0) { $isValid = false; } if (!$id && !$isValid) { $editLink = $this->view->baseUrl() . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . "/" . "actionKey/edit/" . $this->_ID . "/" . $profiles[0]['member_id']; return $editLink; } if ($this->_isXmlHttpRequest) { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); echo json_encode($isValid); } }