Beispiel #1
0
 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();
             }
         }
     }
 }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
0
 public function manageRecipientsAction()
 {
     // web page title
     $this->view->title = "Gestion des destinataires";
     if ($this->view->aclIsAllowed('newsletter', 'manage', true)) {
         $blockID = (int) $this->_getParam('blockID');
         $pageID = (int) $this->_getParam('pageID');
         $newsletterID = (int) $this->_getParam('newsletterID');
         $orderField = $this->_getParam('orderField');
         $orderParam = $this->_getParam('orderParam');
         $tablePage = $this->_getParam('tablePage');
         $search = $this->_getParam('search');
         $nbByPage = 5;
         if ($orderField == "") {
             $orderField = 'lastName';
             $orderParam = 'asc';
         } elseif ($orderParam == "") {
             $orderParam = 'asc';
         }
         if ($tablePage == "") {
             $tablePage = 1;
         }
         $this->view->addRecipientLink = $this->view->baseUrl() . "/newsletter/recipient/add/blockID/{$blockID}/pageID/{$pageID}/newsletterID/{$newsletterID}";
         $newsletterSelect = new NewsletterReleases();
         $select = $newsletterSelect->select();
         $select->where('NR_ID = ?', $newsletterID);
         $newsletterData = $newsletterSelect->fetchRow($select);
         $profile = new NewsletterProfile();
         //$profile->updateMember(9,array('newsletter_categories'=>'1'));
         //$profileProperties = $profile->getProfileProperties();
         $sort[0]['field'] = $orderField;
         $sort[0]['param'] = $orderParam;
         if ($search != "") {
             $members = $profile->findMembers(array('newsletter_categories' => $newsletterData['NR_CategoryID'], 'lastName' => $search));
         } else {
             $members = $profile->findMembers(array('newsletter_categories' => $newsletterData['NR_CategoryID']));
         }
         $nbMembers = count($members);
         //$nbMembers = 0;
         $this->view->memberCount = $nbMembers;
         if ($nbMembers > 0) {
             $i = 0;
             foreach ($members as $member) {
                 //$membersDetails[$i] = $profile->getMemberDetails($member['MemberID']);
                 $membersDetails[$i] = $profile->getMemberDetails($member);
                 $i++;
             }
             $membersDetails = $this->subval_sort($membersDetails, $sort);
         }
         $tableTitle = "Liste des destinataires";
         $tableTH[0]["Title"] = "Nom";
         $tableTH[0]["OrderField"] = "lastName";
         $tableTH[1]["Title"] = "Envoi";
         $tableTH[2]["Title"] = "Actions";
         if ($nbMembers > 0) {
             $i = 0;
             foreach ($tableTH as $TH) {
                 if (array_key_exists("OrderField", $TH)) {
                     if ($orderField == $TH["OrderField"]) {
                         $tableTH[$i]["Order"] = strtolower($orderParam);
                     } else {
                         $tableTH[$i]["Order"] = "asc";
                     }
                     if ($tableTH[$i]["Order"] == "asc") {
                         $orderParamTH = "desc";
                     } else {
                         $orderParamTH = "asc";
                     }
                     $tableTH[$i]["OrderLink"] = $this->view->baseUrl() . "/newsletter/index/manage-recipients/blockID/{$blockID}/pageID/{$pageID}/newsletterID/{$newsletterID}/orderField/" . $tableTH[$i]['OrderField'] . "/orderParam/" . $orderParamTH;
                 }
                 $i++;
             }
             $nbTablePage = ceil(count($members) / $nbByPage);
             if ($tablePage > $nbTablePage || $tablePage < 1) {
                 $tablePage = 1;
             }
             $startMember = ($tablePage - 1) * $nbByPage;
             $endMember = $tablePage * $nbByPage - 1;
             if ($endMember >= count($membersDetails)) {
                 $endMember = count($membersDetails) - 1;
             }
             for ($i = $startMember; $i <= $endMember; $i++) {
                 $tableRows[$i][0] = $membersDetails[$i]['lastName'] . " " . $membersDetails[$i]['firstName'] . "<br>" . $membersDetails[$i]['email'];
                 $tableRows[$i][1] = "---";
                 $tableRows[$i][2] = '<a href="' . $this->view->baseUrl() . '/newsletter/recipient/edit/blockID/' . $blockID . '/pageID/' . $pageID . '/newsletterID/' . $newsletterID . '/recipientID/' . $membersDetails[$i]['memberID'] . '"><img class="action_icon" alt="Editer" src="' . $this->view->baseUrl() . '/icons/edit_icon_16x16.png"/></a>&nbsp;&nbsp';
                 $tableRows[$i][2] .= '<a href="' . $this->view->baseUrl() . '/newsletter/recipient/delete/blockID/' . $blockID . '/pageID/' . $pageID . '/newsletterID/' . $newsletterID . '/recipientID/' . $membersDetails[$i]['memberID'] . '"><img class="action_icon" alt="Supprimer" src="' . $this->view->baseUrl() . '/icons/del_icon_16x16.png"/></a>';
             }
             $listLink = $this->view->baseUrl() . "/newsletter/index/manage-recipients/blockID/{$blockID}/pageID/{$pageID}/newsletterID/{$newsletterID}";
             $search = array('searchLink' => $listLink, 'searchText' => $search, 'searchCount' => $nbMembers);
             $list = array('caption' => $tableTitle, 'thArray' => $tableTH, 'rowsArray' => $tableRows);
             $navigation = array('tablePage' => $tablePage, 'navigationLink' => $listLink, 'nbTablePage' => $nbTablePage);
             $this->view->htmltable = Cible_FunctionsGeneral::generateHtmlTableV2($search, $list, $navigation);
         } else {
             $listLink = $this->view->baseUrl() . "/newsletter/index/manage-recipients/blockID/{$blockID}/pageID/{$pageID}/newsletterID/{$newsletterID}";
             $search = array('searchLink' => $listLink, 'searchText' => $search, 'searchCount' => $nbMembers);
             $this->view->htmltable = Cible_FunctionsGeneral::generateHtmlTableV2($search, '', '');
         }
     }
 }