コード例 #1
0
 public static function indexationBuild()
 {
     set_time_limit(0);
     /*         * ****** PAGE ******* */
     $pageSelect = new PagesIndex();
     $select = $pageSelect->select()->where('PI_Status = 1');
     $pageData = $pageSelect->fetchAll($select)->toArray();
     $cpt = count($pageData);
     for ($i = 0; $i < $cpt; $i++) {
         $indexData['action'] = "add";
         $indexData['pageID'] = $pageData[$i]['PI_PageID'];
         $indexData['moduleID'] = 0;
         $indexData['contentID'] = $pageData[$i]['PI_PageID'];
         $indexData['languageID'] = $pageData[$i]['PI_LanguageID'];
         $indexData['title'] = $pageData[$i]['PI_PageTitle'];
         $indexData['text'] = '';
         $indexData['link'] = '';
         $indexData['contents'] = $pageData[$i]['PI_PageTitle'];
         Cible_FunctionsIndexation::indexation($indexData);
     }
     /*         * ****** TEXT ******* */
     if (class_exists('Text', false)) {
         $textSelect = new Text();
         $select = $textSelect->select()->setIntegrityCheck(false)->from('TextData', array('ID' => 'TD_ID', 'LanguageID' => 'TD_LanguageID', 'Text' => 'TD_OnlineText'))->join('Blocks', 'B_ID = TD_BlockID', array('BlockID' => 'B_ID', 'ModuleID' => 'B_ModuleID'))->where('B_Online = 1')->join('PagesIndex', 'PI_PageID = B_PageID', array('PageID' => 'PI_PageID', 'Title' => 'PI_PageTitle'))->where('PI_Status = 1')->where('PI_LanguageID = TD_LanguageID');
         $textData = $textSelect->fetchAll($select)->toArray();
         $cpt = count($textData);
         for ($i = 0; $i < $cpt; $i++) {
             $indexData['action'] = "add";
             $indexData['pageID'] = $textData[$i]['PageID'];
             $indexData['moduleID'] = $textData[$i]['ModuleID'];
             $indexData['contentID'] = $textData[$i]['ID'];
             $indexData['languageID'] = $textData[$i]['LanguageID'];
             $indexData['title'] = $textData[$i]['Title'];
             $indexData['text'] = '';
             $indexData['link'] = '';
             $indexData['contents'] = $textData[$i]['Title'] . " " . $textData[$i]['Text'];
             Cible_FunctionsIndexation::indexation($indexData);
         }
     }
     /*         * ********************* */
     /*         * ****** NEWS ******* */
     if (class_exists('NewsData', false)) {
         $newsSelect = new NewsData();
         $select = $newsSelect->select()->setIntegrityCheck(false)->from('NewsData', array('NewsID' => 'ND_ID', 'CategoryID' => 'ND_CategoryID'))->join('NewsIndex', 'NI_NewsDataID = ND_ID', array('LanguageID' => 'NI_LanguageID', 'NewsTitle' => 'NI_Title', 'NewsBrief' => 'NI_Brief', 'NewsText' => 'NI_Text', 'NewsImageAlt' => 'NI_ImageAlt'))->where('NI_Status = 1');
         $newsData = $newsSelect->fetchAll($select);
         $cpt = count($newsData);
         for ($i = 0; $i < $cpt; $i++) {
             $indexData['action'] = "add";
             $indexData['pageID'] = $newsData[$i]['CategoryID'];
             $indexData['moduleID'] = 2;
             $indexData['contentID'] = $newsData[$i]['NewsID'];
             $indexData['languageID'] = $newsData[$i]['LanguageID'];
             $indexData['title'] = $newsData[$i]['NewsTitle'];
             $indexData['text'] = '';
             $indexData['link'] = '';
             $indexData['contents'] = $newsData[$i]['NewsTitle'] . " " . $newsData[$i]['NewsBrief'] . " " . $newsData[$i]['NewsText'] . " " . $newsData[$i]['NewsImageAlt'];
             Cible_FunctionsIndexation::indexation($indexData);
         }
     }
     /*         * ********************* */
     /*         * ****** EVENTS ******* */
     if (class_exists('EventsIndex', false)) {
         $eventsSelect = new EventsIndex();
         $select = $eventsSelect->select()->setIntegrityCheck(false)->from('EventsIndex', array('ID' => 'EI_EventsDataID', 'LanguageID' => 'EI_LanguageID', 'Title' => 'EI_Title', 'Brief' => 'EI_Brief', 'Text' => 'EI_Text', 'ImageAlt' => 'EI_ImageAlt'))->join('EventsData', 'ED_ID = EI_EventsDataID', array('CategoryID' => 'ED_CategoryID'))->where('EI_Status = 1');
         $eventsData = $eventsSelect->fetchAll($select)->toArray();
         $cpt = count($eventsData);
         for ($i = 0; $i < $cpt; $i++) {
             $indexData['action'] = "add";
             $indexData['pageID'] = $eventsData[$i]['CategoryID'];
             $indexData['moduleID'] = 7;
             $indexData['contentID'] = $eventsData[$i]['ID'];
             $indexData['languageID'] = $eventsData[$i]['LanguageID'];
             $indexData['title'] = $eventsData[$i]['Title'];
             $indexData['text'] = '';
             $indexData['link'] = '';
             $indexData['contents'] = $eventsData[$i]['Title'] . " " . $eventsData[$i]['Brief'] . " " . $eventsData[$i]['Text'] . " " . $eventsData[$i]['ImageAlt'];
             Cible_FunctionsIndexation::indexation($indexData);
         }
     }
     /*         * ********************* */
     /*         * ****** GALLERY ******* */
     if (class_exists('Galleries', false)) {
         $gallerySelect = new Galleries();
         $select = $gallerySelect->select()->setIntegrityCheck(false)->from('Galleries', array('ID' => 'G_ID', 'CategoryID' => 'G_CategoryID'))->where('G_Online = 1')->join('GalleriesIndex', 'GI_GalleryID = G_ID', array('LanguageID' => 'GI_LanguageID', 'Title' => 'GI_Title', 'Description' => 'GI_Description'))->join('ImagesIndex', 'II_ImageID = G_ImageID', array('ImageTitle' => 'II_Title', 'ImageDescription' => 'II_Description'))->where('II_LanguageID = GI_LanguageID');
         $galleryData = $gallerySelect->fetchAll($select);
         $cpt = count($galleryData);
         for ($i = 0; $i < $cpt; $i++) {
             $indexData['action'] = "add";
             $indexData['pageID'] = $galleryData[$i]['CategoryID'];
             $indexData['moduleID'] = 9;
             $indexData['contentID'] = $galleryData[$i]['ID'];
             $indexData['languageID'] = $galleryData[$i]['LanguageID'];
             $indexData['title'] = $galleryData[$i]['Title'];
             $indexData['text'] = '';
             $indexData['link'] = 'gallery';
             $indexData['contents'] = $galleryData[$i]['Title'] . " " . $galleryData[$i]['Description'] . " " . $galleryData[$i]['ImageTitle'] . " " . $galleryData[$i]['ImageDescription'];
             Cible_FunctionsIndexation::indexation($indexData);
             $imagesSelect = new GalleriesImages();
             $select = $imagesSelect->select()->setIntegrityCheck(false)->from('Galleries_Images', array('ID' => 'GI_ImageID'))->where('GI_GalleryID = ?', $galleryData[$i]['ID'])->where('GI_Online = 1')->join('ImagesIndex', 'II_ImageID = GI_ImageID', array('LanguageID' => 'II_LanguageID', 'Title' => 'II_Title', 'Description' => 'II_Description'));
             $imagesData = $imagesSelect->fetchAll($select);
             $cptImage = count($imagesData);
             for ($y = 0; $y < $cptImage; $y++) {
                 $indexData['action'] = "add";
                 $indexData['pageID'] = $galleryData[$i]['CategoryID'];
                 $indexData['moduleID'] = 9;
                 $indexData['contentID'] = $galleryData[$i]['ID'];
                 $indexData['languageID'] = $imagesData[$y]['LanguageID'];
                 $indexData['title'] = $imagesData[$y]['Title'];
                 $indexData['text'] = '';
                 $indexData['link'] = 'image';
                 $indexData['contents'] = $imagesData[$y]['Title'] . " " . $imagesData[$y]['Description'];
                 Cible_FunctionsIndexation::indexation($indexData);
             }
         }
     }
     /*         * ********************* */
     /*         * ****** NEWSLETTERS ******* */
     if (class_exists('NewsletterRelease', false)) {
         $newsletterSelect = new NewsletterReleases();
         $select = $newsletterSelect->select()->from('Newsletter_Releases', array('ID' => 'NR_ID', 'LanguageID' => 'NR_LanguageID', 'Title' => 'NR_Title'))->where('NR_Online = 1');
         $newsletterData = $newsletterSelect->fetchAll($select)->toArray();
         $cpt = count($newsletterData);
         for ($i = 0; $i < $cpt; $i++) {
             $indexData['action'] = "add";
             $indexData['pageID'] = $newsletterData[$i]['ID'];
             $indexData['moduleID'] = 8;
             $indexData['contentID'] = $newsletterData[$i]['ID'];
             $indexData['languageID'] = $newsletterData[$i]['LanguageID'];
             $indexData['title'] = $newsletterData[$i]['Title'];
             $indexData['text'] = '';
             $indexData['link'] = 'release';
             $indexData['contents'] = $newsletterData[$i]['Title'];
             Cible_FunctionsIndexation::indexation($indexData);
             $articlesSelect = new NewsletterArticles();
             $select = $articlesSelect->select()->from('Newsletter_Articles', array('ID' => 'NA_ID', 'Title' => 'NA_Title', 'Resume' => 'NA_Resume', 'Text' => 'NA_Text'))->where('NA_ReleaseID = ?', $newsletterData[$i]['ID']);
             $articlesData = $articlesSelect->fetchAll($select);
             $cptArticle = count($articlesData);
             for ($y = 0; $y < $cptArticle; $y++) {
                 $indexData['action'] = "add";
                 $indexData['pageID'] = $newsletterData[$i]['ID'];
                 $indexData['moduleID'] = 8;
                 $indexData['contentID'] = $articlesData[$y]['ID'];
                 $indexData['languageID'] = $newsletterData[$i]['LanguageID'];
                 $indexData['title'] = $articlesData[$y]['Title'];
                 $indexData['text'] = '';
                 $indexData['link'] = 'article';
                 $indexData['contents'] = $articlesData[$y]['Title'] . " " . $articlesData[$y]['Resume'] . " " . $articlesData[$y]['Text'];
                 Cible_FunctionsIndexation::indexation($indexData);
             }
         }
     }
     /*         * ********************* */
 }
コード例 #2
0
ファイル: ArticleController.php プロジェクト: anunay/stentors
 function updatezoneAction()
 {
     $articleID = $this->_getParam('articleID');
     $newpositionID = $this->_getParam('newpositionID');
     $newzoneID = $this->_getParam('newzoneID');
     $newpositionID = $this->_getParam('newpositionID');
     $newsletterArticleSelect = new NewsletterArticles();
     $select = $newsletterArticleSelect->select();
     $select->where('NA_ID = ?', $articleID);
     $newsletterArticleData = $newsletterArticleSelect->fetchRow($select);
     $releaseID = $newsletterArticleData['NA_ReleaseID'];
     $oldzoneID = $newsletterArticleData['NA_ZoneID'];
     $oldpositionID = $newsletterArticleData['NA_PositionID'];
     //update zone
     $newsletterArticleData['NA_ZoneID'] = $newzoneID;
     $newsletterArticleData->save();
     // update position (old zone)
     $newsletterArticlePosition = new NewsletterArticles();
     $where = 'NA_PositionID > ' . $oldpositionID;
     $where .= ' AND NA_ReleaseID = ' . $releaseID;
     $where .= ' AND NA_ZoneID = ' . $oldzoneID;
     $newsletterArticlePosition->update(array('NA_PositionID' => new Zend_Db_Expr('NA_PositionID - 1 ')), $where);
     // update position (new zone)
     $where = 'NA_PositionID >= ' . $newpositionID;
     $where .= ' AND NA_ReleaseID = ' . $releaseID;
     $where .= ' AND NA_ZoneID = ' . $newzoneID;
     $newsletterArticlePosition->update(array('NA_PositionID' => new Zend_Db_Expr('NA_PositionID + 1 ')), $where);
     // update position article
     $newsletterArticleData['NA_PositionID'] = $newpositionID;
     $newsletterArticleData->save();
     $this->getHelper('viewRenderer')->setNoRender();
 }
コード例 #3
0
ファイル: IndexController.php プロジェクト: anunay/stentors
 public function detailsarticleAction()
 {
     //$this->view->jQuery()->addJavascriptFile($this->view->locateFile('jquery.prettyPhoto.js', 'jquery'));
     //$this->view->headLink()->appendStylesheet($this->view->locateFile('prettyPhoto.css'), 'screen');
     // Article ID and Newsletter ID
     $newsletterArticlesSelect = new NewsletterArticles();
     $id = 0;
     $newsletterID = 0;
     $url = $this->_request->getPathInfo();
     $fromEmail = (bool) preg_match('/-uid-[0-9]+/', $url);
     $user = Zend_Registry::get('user');
     $memberId = 0;
     $titleUrl = Cible_FunctionsGeneral::getTitleFromPath($url);
     if ($titleUrl != "") {
         $id = $newsletterArticlesSelect->getArticleIdByName($titleUrl);
         $newsletterID = $newsletterArticlesSelect->getNewsletterIdByName($titleUrl);
     }
     if ($fromEmail) {
         $pos = strpos($url, '-uid-');
         $uid = explode('-', substr($url, $pos));
         $memberId = end($uid);
         $url = substr_replace($url, '', $pos);
         $path = Zend_Registry::get('web_root') . '/';
         setcookie('uid_newsletter', (string) $memberId, 0, $path);
     } else {
         if (isset($_COOKIE['uid_newsletter'])) {
             $memberId = $_COOKIE['uid_newsletter'];
         }
     }
     if ($memberId == 0 && $user) {
         $oMember = new MemberProfile();
         $member = $oMember->findMember(array('email' => $user['email']));
         $memberId = $member['member_id'];
     }
     $back_to_newsletter = !empty($newsletterID) ? "/ID/{$newsletterID}" : '';
     $blockID = $this->_getParam('BlockID');
     $blockParams = Cible_FunctionsBlocks::getBlockParameters($blockID)->toArray();
     $newsletterCategoryID = $blockParams[0]['P_Value'];
     if (!empty($id)) {
         $this->_params = array('moduleId' => $this->_moduleID, 'releaseId' => $newsletterID, 'memberId' => $memberId, 'articleId' => $id);
         $this->logDetailsread();
         $newsletterSelect = new NewsletterReleases();
         $select = $newsletterSelect->select();
         $select->from('Newsletter_Releases')->where('NR_LanguageID = ?', Zend_Registry::get("languageID"))->where('NR_ID = ?', $newsletterID);
         $newsletterData = $newsletterSelect->fetchRow($select);
         $titleParution = $newsletterData['NR_Title'];
         $titleURLParution = $newsletterData['NR_ValUrl'];
         //var_dump($newsletterData);
         if ($newsletterData['NR_Online'] == 1) {
             // article info
             $select = $newsletterArticlesSelect->select();
             $select->where('NA_ID = ?', $id);
             //$select->where('NA_ReleaseID = ?', $newsletterID);
             $newsletterArticlesData = $newsletterArticlesSelect->fetchAll($select);
             if (count($newsletterArticlesData) < 0) {
                 $this->_redirect(Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8));
             }
             $this->view->articles = $newsletterArticlesData->toArray();
             $blockID = $this->_getParam('BlockID');
             $blockParams = Cible_FunctionsBlocks::getBlockParameters($blockID)->toArray();
             $newsletterCategoryID = $blockParams[0]['P_Value'];
             $this->view->assign('parution_title', $titleParution);
             $this->view->assign('parution_date', $newsletterData['NR_Date']);
             $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('parutionURL', $titleURLParution);
             $this->view->assign('back_to_release', Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 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);
         } else {
             $this->view->articles = array();
             $this->view->assign('parutionURL', $titleURLParution);
             $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);
         }
     } else {
         $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('parutionURL', $titleURLParution);
         $this->view->assign('archivesLink', $this->view->baseUrl() . "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8) . '/categoryID/' . $newsletterCategoryID);
         $this->view->articles = array();
     }
 }
コード例 #4
0
ファイル: IndexController.php プロジェクト: anunay/stentors
 /**
  * Sends mass mailing.
  * Prepares data and tests the recipients list before sendig emails.
  *
  * @param int $releaseID The release of the the newsletter to send.
  *
  * @return array Contains data corresponding to the send result.
  */
 public function sendMassMailingAction($releaseID = null)
 {
     $this->disableView();
     if (!$releaseID) {
         $releaseID = $_REQUEST['releaseID'];
     }
     //            $releaseID  = $this->view->params['releaseID'];
     // 1- Get all newsletter to send
     $dateTimeNow = date('Y-m-d H:i:s');
     $newsletterSelect = new NewsletterReleases();
     $select = $newsletterSelect->select()->setIntegrityCheck(false);
     $select->from('Newsletter_Releases')->join('Languages', 'L_ID = NR_LanguageID')->join('CategoriesIndex', 'CI_CategoryID = NR_CategoryID')->join('Newsletter_Models_Index', 'NMI_NewsletterModelID = NR_ModelID')->join('Newsletter_Models', 'NM_ID = NMI_NewsletterModelID')->where('CI_LanguageID = NR_LanguageID')->where('NMI_LanguageID = NR_LanguageID')->where('NR_Status <> 1')->where('NR_ID = ?', $releaseID);
     $newsletterData = $newsletterSelect->fetchAll($select);
     foreach ($newsletterData as $release) {
         $listSent = array();
         $listDest = array();
         $listIds = array();
         $mailLog = array();
         $date = new Zend_Date($release['NR_Date'], null, Zend_Registry::get('languageSuffix') == 'fr' ? 'fr_CA' : 'en_CA');
         $date_string = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_LONG_NO_DAY, '.');
         $date_string_url = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_SQL, '-');
         $releaseLanguage = $release['NR_LanguageID'];
         $this->view->assign('languageRelease', $releaseLanguage);
         $filteredData = $this->_countFilterMembers($release['NR_CollectionFiltersID'], $releaseLanguage);
         $members = $filteredData['members'];
         $selection = $filteredData['selection'];
         $dateTimeStart = date('Y-m-d H:i:s');
         $member_count = 0;
         $stats = array('action' => 'set', 'sentTo' => 0, 'targetedTotal' => 0);
         if ($release['NR_Status'] == 0 || $release['NR_Status'] == 3) {
             //Send to all recipient even if they have already received it
             $member_count = count($members);
         } elseif ($release['NR_Status'] == 2) {
             $member_count = count($members);
             $stats['action'] = 'increment';
             //Send to recipient who have not already received it
             $alreadyMembersRecievedSelect = new NewsletterReleasesMembers();
             $select = $alreadyMembersRecievedSelect->select()->where('NRM_ReleaseID = ?', $release['NR_ID']);
             $alreadyMembersRecievedData = $alreadyMembersRecievedSelect->fetchAll($select);
             $already_received_count = count($alreadyMembersRecievedData);
             $membersTmp = array();
             for ($i = 0; $i < $member_count; $i++) {
                 $received = "false";
                 for ($j = 0; $j < $already_received_count; $j++) {
                     if ($members[$i]['GP_MemberID'] == $alreadyMembersRecievedData[$j]['NRM_MemberID']) {
                         $received = "true";
                     }
                 }
                 if ($received == "false") {
                     array_push($membersTmp, $members[$i]);
                 }
             }
             $members = $membersTmp;
             $member_count = count($members);
         }
         $stats['targetedTotal'] = $member_count;
         if (!empty($members) && $member_count > 0) {
             $newsletterArticlesSelect = new NewsletterArticles();
             $select = $newsletterArticlesSelect->select();
             $select->where('NA_ReleaseID = ?', $release['NR_ID'])->order('NA_ZoneID')->order('NA_PositionID');
             $newsletterArticlesData = $newsletterArticlesSelect->fetchAll($select);
             $this->view->articles = $newsletterArticlesData->toArray();
             $registry = Zend_Registry::getInstance()->set('format', 'email');
             $config = Zend_Registry::get('config')->toArray();
             $nbMax = $config['massMailing']['packof'];
             $sleep = $config['massMailing']['sleep'];
             $server = $config['massMailing']['server'];
             $i = 0;
             set_time_limit(0);
             $emailValidator = new Zend_Validate_EmailAddress();
             $sentToCount = 0;
             $failedEmailAddress = array();
             for ($k = 0; $k < $member_count; $k++) {
                 try {
                     if ($i == $nbMax) {
                         $protocol->quit();
                         $protocol->disconnect();
                         sleep($sleep);
                         $i = 0;
                     }
                     if ($i == 0) {
                         $transport = new Zend_Mail_Transport_Smtp();
                         $protocol = new Zend_Mail_Protocol_Smtp($server);
                         $protocol->connect();
                         $protocol->helo($server);
                         $transport->setConnection($protocol);
                     }
                     $protocol->rset();
                     if ($emailValidator->isValid($members[$k]['GP_Email'])) {
                         $date = new Zend_Date($release['NR_Date'], null, Zend_Registry::get('languageSuffix') == 'fr' ? 'fr_CA' : 'en_CA');
                         $date_string = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_LONG_NO_DAY, '.');
                         $date_string_url = Cible_FunctionsGeneral::dateToString($date, Cible_FunctionsGeneral::DATE_SQL, '-');
                         $newsletterCategoryID = $release['NR_CategoryID'];
                         $this->view->assign('unsubscribeLink', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'unsubscribe', 8));
                         $this->view->assign('subscribeLink', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'subscribe', 8, $releaseLanguage));
                         $this->view->assign('archiveLink', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'list_archives', 8, $releaseLanguage));
                         //$this->view->assign('details_release', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8) . "/ID/" . $release['NR_ID']);
                         $this->view->assign('details_release', "/" . Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_release', 8, $releaseLanguage) . "/" . $date_string_url . "/" . $release['NR_Title']);
                         $this->view->assign('details_page', Cible_FunctionsCategories::getPagePerCategoryView($newsletterCategoryID, 'details_article', 8));
                         $this->view->assign('isOnline', $release['NR_Online']);
                         $this->view->assign('newsletterID', $release['NR_ID']);
                         $this->view->assign('memberId', $members[$k]['GP_MemberID']);
                         $this->view->assign('moduleId', $this->_moduleID);
                         $this->view->assign('dateString', $date_string);
                         $this->view->assign('parutionDate', $date_string_url);
                         $bodyText = $this->view->render($release['NM_DirectoryEmail']);
                         $salutationsSelect = new Salutations();
                         $select = $salutationsSelect->select()->setIntegrityCheck(false);
                         $salutationId = $members[$k]['GP_Salutation'];
                         if (is_null($salutationId)) {
                             $salutationId = 0;
                         }
                         $select->from('Salutations')->join('Static_Texts', 'ST_Identifier = S_StaticTitle')->where('ST_LangID = ?', Zend_Registry::get("languageID"))->where('S_ID = ?', $salutationId);
                         $salutationsData = $salutationsSelect->fetchRow($select);
                         $bodyText = str_replace('#prenom#', $members[$k]['GP_FirstName'], $bodyText);
                         $bodyText = str_replace('#nom#', $members[$k]['GP_LastName'], $bodyText);
                         $bodyText = str_replace('#courtoisie#', $salutationsData['ST_Value'], $bodyText);
                         //$newsletterData['NR_AfficherTitre'] = $form->getValue('NR_AfficherTitre');
                         $newsletterAfficherTitre = $release['NR_AfficherTitre'];
                         $newsletterTextIntro = $release['NR_TextIntro'];
                         $newsletterTextIntro = str_replace('##prenom##', $members[$k]['GP_FirstName'], $newsletterTextIntro);
                         $newsletterTextIntro = str_replace('##nom##', $members[$k]['GP_LastName'], $newsletterTextIntro);
                         $newsletterTextIntro = str_replace('##salutation##', $salutationsData['ST_Value'], $newsletterTextIntro);
                         $this->view->intro = $newsletterTextIntro;
                         $this->view->newsletterAfficherTitre = $newsletterAfficherTitre;
                         $mail = new Zend_Mail();
                         $mail->setBodyHtml($bodyText);
                         $mail->setFrom($release['NM_FromEmail'], $release['NMI_FromName']);
                         $mail->addTo($members[$k]['GP_Email']);
                         $mail->setSubject($release['NR_Title']);
                         if (!$mail->send()) {
                             array_push($failedEmailAddress, array('fname' => $members[$k]['GP_FirstName'], 'lname' => $members[$k]['GP_LastName'], 'email' => $members[$k]['GP_Email']));
                         }
                         $sentToCount++;
                         $releaseMember = new NewsletterReleasesMembers();
                         $releaseMemberData = $releaseMember->createRow();
                         $releaseMemberData['NRM_ReleaseID'] = $release['NR_ID'];
                         $releaseMemberData['NRM_MemberID'] = $members[$k]['GP_MemberID'];
                         $releaseMemberData['NRM_DateTimeReceived'] = date('Y-m-d H:i:s');
                         $insert = $releaseMemberData->save();
                         $i++;
                     } else {
                         array_push($failedEmailAddress, array('fname' => $members[$k]['GP_FirstName'], 'lname' => $members[$k]['GP_LastName'], 'email' => $members[$k]['GP_Email']));
                     }
                 } catch (Exception $exc) {
                     $index = $releaseID . '-';
                     $index .= $k + 1 . '-';
                     $index .= $members[$k]['GP_MemberID'];
                     $mailLog[$index]['message'] = $exc->getCode() . '-' . $exc->getFile() . '-' . $exc->getLine();
                     $mailLog[$index]['log'] = $protocol->getResponse();
                     $columnsMap = array('NEL_IdIndex' => 'NEL_IdIndex', 'NEL_CodeFileLine' => 'NEL_CodeFileLine', 'NEL_Response' => 'NEL_Response', 'NEL_Timestamp' => 'timestamp');
                     $writer = new Zend_Log_Writer_Db($this->_db, 'Newsletter_ErrorsLog', $columnsMap);
                     $oZLog = new Zend_Log($writer);
                     $oZLog->setEventItem('NEL_IdIndex', $index);
                     $oZLog->setEventItem('NEL_CodeFileLine', $mailLog[$index]['message']);
                     $oZLog->setEventItem('NEL_Response', $mailLog[$index]['log'][0]);
                     $oZLog->log('errors', 4);
                 }
             }
             $protocol->quit();
             $protocol->disconnect();
         } else {
             echo Zend_Json::encode(array('sentTo' => '0', 'targetedTotal' => '0', 'failedEmail' => array(), 'select' => $selection));
             break;
         }
         $stats['sentTo'] = $sentToCount;
         $dateTimeEnd = date('Y-m-d H:i:s');
         $release['NR_MailingDateTimeStart'] = $dateTimeStart;
         $release['NR_MailingDateTimeEnd'] = $dateTimeEnd;
         $release['NR_SendTo'] = $stats['action'] == 'set' ? $stats['sentTo'] : $release['NR_SendTo'] + $stats['sentTo'];
         $release['NR_TargetedTotal'] = $stats['action'] == 'set' ? $stats['targetedTotal'] : $release['NR_TargetedTotal'] + $stats['targetedTotal'];
         $release['NR_Status'] = 1;
         $release->save();
         if (count($failedEmailAddress) > 0) {
             $this->_recordEmails($failedEmailAddress, $releaseID);
         }
         $this->_stats = array('invalidEmails' => count($failedEmailAddress), 'errors' => count($mailLog), 'totalToSend' => $stats['targetedTotal'], 'totalSent' => $stats['sentTo']);
         if ($this->_isXmlHttpRequest) {
             array_push($listSent, $release['NR_Title']);
             array_push($listIds, $release['NR_ID']);
             array_push($listDest, $release['NR_AdminEmail']);
             $data = array('list' => $listSent, 'dest' => $listDest, 'ids' => $listIds);
             $this->_adminNotification($data);
             $this->_logSending($data);
         }
         echo Zend_Json::encode(array('sentTo' => $stats['sentTo'], 'targetedTotal' => $stats['targetedTotal'], 'failedEmail' => $failedEmailAddress, 'select' => $selection));
         exit;
     }
     // If all the newsletter have a status = 1, we don't pass through the foreach
     // So redirect the action to the newsletter
     //        echo(Zend_Json::encode(array('sentTo' => '0', 'targetedTotal' => '0', 'failedEmail' => array(), 'select' => '')));
     //        exit;
 }