WYSIJA_model_campaign_list

The MailPoet Newsletters WYSIJA model campaign list class.

Defined (1)

The class is defined in the following location(s).

/models/campaign_list.php  
  1. class WYSIJA_model_campaign_list extends WYSIJA_model{ 
  2.  
  3. var $pk=array("list_id", "campaign_id"); 
  4. var $table_name="campaign_list"; 
  5. var $columns=array( 
  6. 'list_id'=>array("req"=>true, "type"=>"integer"),  
  7. 'campaign_id'=>array("req"=>true, "type"=>"integer"),  
  8. 'filter' => array("req"=>true),  
  9. ); 
  10.  
  11. function __construct() { 
  12. parent::__construct(); 
  13.  
  14. function getReceivers($mailid, $total = true, $onlypublished = true) { 
  15. $query = 'SELECT a.name, a.description, a.published, a.color, b.listid, b.mailid FROM [wysija]campaign_list as b LEFT JOIN [wysija]list as a on a.list_id = b.list_id WHERE b.campaign_id = '.intval($mailid); 
  16. if($onlypublished) $query .= ' AND a.published = 1'; 
  17. $lists=$this->query("get_res", $query, OBJECT_K); 
  18. //$lists = $this->database->loadObjectList('listid'); 
  19. if(empty($lists) OR !$total) return $lists; 
  20. $config = WYSIJA::get('config', 'model'); 
  21. $confirmed = $config->getValue('confirm_dbleoptin') ? 'b.status = 1 AND' : ''; 
  22. $countQuery = 'SELECT a.listid, count(b.subid) as nbsub FROM `[wysija]user_list` as a LEFT JOIN `[wysija]user` as b ON a.user_id = b.user_id WHERE '.$confirmed.' a.`list_id` IN ('.implode(', ', array_keys($lists)).') GROUP BY a.`list_id`'; 
  23. //$this->database->setQuery($countQuery); 
  24. //$countResult = $this->database->loadObjectList('listid'); 
  25. $countResult=$this->query('get_res', $countQuery, OBJECT_K); 
  26. foreach($lists as $listid => $count) { 
  27. $lists[$listid]->nbsub = empty($countResult[$listid]->nbsub) ? 0 : $countResult[$listid]->nbsub; 
  28. return $lists; 
  29.  
  30.