Exemplo n.º 1
0
 public function deleteCollectionAction()
 {
     if ($this->view->aclIsAllowed('newsletter', 'edit', true)) {
         $returnUrl = "/newsletter/filter/list-collection/";
         $collectionID = $this->_getParam('collectionID');
         if ($this->_request->isPost()) {
             $del = $this->_request->getPost('delete');
             if ($del && $collectionID > 0) {
                 $collectionDelete = new NewsletterFilterCollectionsSet();
                 $where = "NFCS_ID = {$collectionID}";
                 $collectionDelete->delete($where);
                 $filterSetSelect = new NewsletterFilterCollectionsFiltersSet();
                 $select = $filterSetSelect->select();
                 $select->where('NFCFS_CollectionSetID = ?', $collectionID);
                 $filterSetData = $filterSetSelect->fetchAll($select)->toArray();
                 foreach ($filterSetData as $filterSet) {
                     $filterSetDelete = new NewsletterFilterFiltersSet();
                     $where = 'NFFS_ID = ' . $filterSet['NFCFS_FilterSetID'];
                     $filterSetDelete->delete($where);
                     $filterDelete = new NewsletterFilterFilters();
                     $where = 'NFF_FilterSetID = ' . $filterSet['NFCFS_FilterSetID'];
                     $filterDelete->delete($where);
                     $collectionFilterSetDelete = new NewsletterFilterCollectionsFiltersSet();
                     $where = 'NFCFS_FilterSetID = ' . $filterSet['NFCFS_FilterSetID'];
                     $collectionFilterSetDelete->delete($where);
                 }
             }
             $this->_redirect($returnUrl);
         } else {
             $collectionSelect = new NewsletterFilterCollectionsSet();
             $select = $collectionSelect->select();
             $select->where('NFCS_ID = ?', $collectionID);
             $collectionData = $collectionSelect->fetchRow($select)->toArray();
             $this->view->assign('collection', $collectionData);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Set the list of members for the newsletter according to filters data.
  *
  * @param int $collectionSetId
  *
  * @return array
  */
 private function _countFilterMembers($collectionSetId, $lang = 0)
 {
     $filterSetSelect = new NewsletterFilterCollectionsFiltersSet();
     $select = $filterSetSelect->select()->setIntegrityCheck(false);
     $select->from('NewsletterFilter_CollectionsFiltersSet')->where('NFCFS_CollectionSetID = ?', $collectionSetId)->join('NewsletterFilter_Filters', 'NFF_FilterSetID = NFCFS_FilterSetID')->join('NewsletterFilter_ProfilesFields', 'NFPF_Name = NFF_ProfileFieldName')->join('NewsletterFilter_ProfilesTables', 'NFPT_ID = NFPF_ProfileTableID')->order('NFF_FilterSetID')->order('NFF_ID');
     $filterSetData = $filterSetSelect->fetchAll($select)->toArray();
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('GenericProfiles');
     $filterSetID = 0;
     $profileTables = array('GenericProfiles');
     $whereOR = "";
     foreach ($filterSetData as $filterSet) {
         if ($filterSetID != $filterSet['NFF_FilterSetID']) {
             $filterSetID = $filterSet['NFF_FilterSetID'];
             if ($whereOR != '') {
                 $select->orWhere($whereOR);
                 $whereOR = '';
             }
         }
         if (!in_array($filterSet['NFPT_Name'], $profileTables)) {
             $profileTables[] = $filterSet['NFPT_Name'];
             $select->joinLeft($filterSet['NFPT_Name'], $filterSet['NFPT_JoinOn']);
         }
         if ($whereOR != '') {
             $whereOR .= ' AND ';
         }
         if ($filterSet['NFPF_Type'] == 'int') {
             $whereOR .= " {$filterSet['NFPF_Name']} = {$filterSet['NFF_Value']}";
         } elseif ($filterSet['NFPF_Type'] == 'list') {
             $whereOR .= " ({$filterSet['NFPF_Name']} = {$filterSet['NFF_Value']}";
             $whereOR .= " OR {$filterSet['NFPF_Name']} like '%,{$filterSet['NFF_Value']}'";
             $whereOR .= " OR {$filterSet['NFPF_Name']} like '{$filterSet['NFF_Value']},%'";
             $whereOR .= " OR {$filterSet['NFPF_Name']} like '%,{$filterSet['NFF_Value']},%')";
         } elseif ($filterSet['NFPF_Type'] == 'char') {
             $whereOR .= " {$filterSet['NFPF_Name']} = '{$filterSet['NFF_Value']}'";
         }
     }
     if ($whereOR != '') {
         $select->orWhere($whereOR);
     }
     if ($lang != 0) {
         $select->where('GP_Language = ?', $lang);
     }
     $members = $db->fetchAll($select);
     $data['members'] = $members;
     $data['selection'] = utf8_encode($select);
     return $data;
 }