/**
  * @param Bea_Sender_Campaign $campaign
  *
  * @return bool
  * @author Nicolas Juen
  */
 public function link_campaign(Bea_Sender_Campaign $campaign)
 {
     /* @var $wpdb wpdb */
     global $wpdb;
     if (!isset($this->id) || empty($this->id) || !isset($this->attachment_path) || empty($this->attachment_path)) {
         return false;
     }
     return $wpdb->update($wpdb->bea_s_attachments, array('campaign_id' => $campaign->getID()), array('id' => $this->id), array('%d'), array('%d'));
 }
Example #2
0
 /**
  * @return array
  * @author Nicolas Juen
  */
 private function sendCampaigns()
 {
     $results = array();
     do_action('bea_sender_before_send');
     foreach ($this->campaigns as $campaign_id) {
         $campaign = new Bea_Sender_Campaign($campaign_id);
         if ($campaign->isData() !== true) {
             continue;
         }
         $this->log->log_this(sprintf('Send %s campaign', $campaign_id));
         do_action('bea_sender_before_send_campaign', $campaign_id, $campaign);
         // Make the sending
         $results[] = $campaign->makeSend();
         do_action('bea_sender_after_send_campaign', $campaign_id, $campaign);
     }
     do_action('bea_sender_after_send');
     // Unlock the file
     self::unlock();
     $this->log->log_this('End campaigns ' . var_export($results, true));
     return $results;
 }
<?php

// Do the settings error
settings_errors('bea_sender');
// Setup the campaign
$campaign = new Bea_Sender_Campaign((int) $_GET['c_id']);
// Get all the receivers
$receivers = $campaign->get_receivers();
?>
<div class="wrap"> 
	<h2><?php 
echo get_admin_page_title();
?>
<a class="add-new-h2" href="<?php 
echo add_query_arg(array('page' => 'bea_sender'), admin_url('/tools.php'));
?>
"> <?php 
_e('Return to campaigns', 'bea_sender');
?>
</a></h2>
	<?php 
$this->ListTableSingle->prepare_items();
?>
	<form method="get" action="">
		<input type="hidden" name="page" value="bea_sender" />
		<?php 
$this->ListTableSingle->views();
$this->ListTableSingle->display();
?>
	</form>
</div>
Example #4
0
 /**
  * Add given data to the campaign
  * 
  * @param (array)$data_campaign : the campaign datas
  * @param (array)$data : the emails to do
  * @param (string)$content_html : the html content to use
  * @param (string)$content_text : (optional) the raw content to use on this emailing
  * 
  * @return boolean
  * 
  * @author Nicolas Juen
  * 
  */
 public static function registerCampaign($data_campaign, $data, $content_html, $content_text = '', $attachments = array())
 {
     $campaign = new Bea_Sender_Campaign();
     $insert = $campaign->add($data_campaign, $data, $content_html, $content_text, $attachments);
     return $insert;
 }
 /**
  * This method count total items in table
  *
  * @return integer Count(id)
  * @author Nicolas Juen
  */
 function totalItems()
 {
     /* @var $wpdb wpdb */
     global $wpdb;
     $filter = self::get_status_filter();
     // Setup the campaign
     $campaign = new Bea_Sender_Campaign((int) $_GET['c_id']);
     // Get the receivers
     return $campaign->get_total_receivers($filter);
 }
 /**
  * Check if user wants delete item on manage page
  *
  * @return string $status and $message
  * @author Amaury Balmer, Alexandre Sadowski
  */
 function checkDelete()
 {
     if (!isset($_GET['page']) || $_GET['page'] != 'bea_sender' || !isset($_GET['action'])) {
         return false;
     }
     $action = $this->current_action();
     if (empty($action) || !array_key_exists($action, $this->get_bulk_actions()) || !isset($_GET['id']) || empty($_GET['id'])) {
         add_settings_error('bea_sender', 'settings_updated', __('Oups! You probably forgot to tick campaigns to delete?', 'bea_sender'), 'error');
         return false;
     }
     check_admin_referer('bulk-campaigns');
     $_GET['id'] = array_map('absint', $_GET['id']);
     switch ($action) {
         case 'delete':
             $total = 0;
             foreach ($_GET['id'] as $c_id) {
                 $result = 0;
                 $c = new Bea_Sender_Campaign($c_id);
                 if ($c->isData() !== true) {
                     $message_code = 0;
                 } else {
                     $result = $c->deleteCampaign();
                     $total += $result;
                     if ($result == 0) {
                         $message_code = 1;
                     } else {
                         $message_code = 2;
                     }
                 }
             }
             wp_redirect(add_query_arg(array('page' => 'bea_sender', 'message-code' => 3, 'message-value' => $total), admin_url('tools.php')));
             exit;
             break;
         default:
             break;
     }
     return true;
 }
Example #7
0
$content_html = '<div>HTML Not multiple Okokokokokok</div>';
$content_text = '<div>TEXT Not multiple Okokokokokok</div>';
$campaign = new Bea_Sender_Campaign();
$insert = $campaign->add($data_campaign, $data, $content_html, $content_text);
if (!empty($insert)) {
    print_r($insert);
} else {
    echo $campaign->getID() . ' : ok Single content' . "\n";
}
$data_campaign = array('from' => '*****@*****.**', 'from_name' => 'Nicolas Juen', 'subject' => 'Tests mutltiple');
$content_html = '<div>HTML Multiple</div>';
$content_text = '<div>TEXT multiple</div>';
$data = array(array('email' => '*****@*****.**', 'html' => '1' . $content_html, 'text' => '1' . $content_text), array('email' => '*****@*****.**', 'html' => '2' . $content_html, 'text' => '2' . $content_text), array('email' => '*****@*****.**', 'html' => '3' . $content_html, 'text' => '3' . $content_text), array('email' => '*****@*****.**', 'html' => '4' . $content_html, 'text' => '4' . $content_text), array('email' => '*****@*****.**', 'html' => '5' . $content_html, 'text' => '5' . $content_text), array('email' => '*****@*****.**', 'html' => '6' . $content_html, 'text' => '6' . $content_text));
$campaign = new Bea_Sender_Campaign();
$insert = $campaign->add($data_campaign, $data);
if (!empty($insert)) {
    print_r($insert);
} else {
    echo $campaign->getID() . ' : ok Multiple content' . "\n";
}
$data_campaign = array('from' => '*****@*****.**', 'from_name' => 'Nicolas Juen', 'subject' => 'Tests mutltiple', 'scheduled_from' => date('Y-m-d H:m:i', strtotime('+15 minutes')));
$content_html = '<div>HTML Multiple</div>';
$content_text = '<div>TEXT multiple</div>';
$data = array(array('email' => '*****@*****.**', 'html' => '1' . $content_html, 'text' => '1' . $content_text), array('email' => '*****@*****.**', 'html' => '2' . $content_html, 'text' => '2' . $content_text), array('email' => '*****@*****.**', 'html' => '3' . $content_html, 'text' => '3' . $content_text), array('email' => '*****@*****.**', 'html' => '4' . $content_html, 'text' => '4' . $content_text), array('email' => '*****@*****.**', 'html' => '5' . $content_html, 'text' => '5' . $content_text), array('email' => '*****@*****.**', 'html' => '6' . $content_html, 'text' => '6' . $content_text));
$campaign = new Bea_Sender_Campaign();
$insert = $campaign->add($data_campaign, $data);
if (!empty($insert)) {
    print_r($insert);
} else {
    echo $campaign->getID() . ' : ok Multiple content' . "\n";
}