function admin_index()
 {
     $this->NewsletterSendlist->recursive = -1;
     $this->paginate['order'] = array('NewsletterSendlist.order' => 'asc');
     $lists = $this->paginate();
     $this->NewsletterSendlist->NewsletterEmail->recursive = -1;
     App::import('Lib', 'Newsletter.TabledSendlist');
     $restrictedSendlists = (array) TabledSendlist::allIds();
     App::import('Lib', 'Newsletter.Sendlist');
     foreach ($lists as &$list) {
         $sendlist = Sendlist::getSendlist($list[$this->NewsletterSendlist->alias]['id']);
         $list[$this->NewsletterSendlist->alias]['nb_email'] = $sendlist->nbEmails();
     }
     $this->set('newsletterSendlists', $lists);
     $this->set('restrictedSendlists', $restrictedSendlists);
 }
示例#2
0
 function enable_email($email)
 {
     $emails = (array) $email;
     $NewsletterEmail = ClassRegistry::init('Newsletter.NewsletterEmail');
     $format = $NewsletterEmail->getDataSource()->columns['datetime']['format'];
     $email_data = array();
     $email_data['active'] = '1';
     $email_data['user_action'] = $NewsletterEmail->getDataSource()->value(date($format));
     $count = $NewsletterEmail->updateAll($email_data, array('email' => $emails));
     $normalCount = $NewsletterEmail->getAffectedRows();
     App::import('Lib', 'Newsletter.TabledSendlist');
     $tableSendlists = TabledSendlist::all();
     foreach ($tableSendlists as $tableSendlist) {
         if ($tableSendlist->allowUnsubscribe()) {
             $count += $tableSendlist->EmailModel->updateAll(array($tableSendlist->realField('active') => 1), array($tableSendlist->realField('email') => $emails));
         }
     }
     return $count;
 }
 function __construct($id)
 {
     $this->id = $id;
     $this->options = TabledSendlist::getOptions($id);
     $this->EmailModel = ClassRegistry::init($this->options['model']);
 }