예제 #1
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;
 }
 /**
  * Define the columns that are going to be used in the table
  *
  * @return array() $query
  * @author Nicolas Juen
  */
 function prepareQuery()
 {
     /* @var $wpdb wpdb */
     global $wpdb;
     // Setup the campaign
     $campaign = new Bea_Sender_Campaign((int) $_GET['c_id']);
     // Make the order
     $limit = $wpdb->prepare(' LIMIT %d,%d', ($this->get_pagenum() == 1 ? 0 : $this->get_pagenum() - 1) * $this->get_items_per_page('bea_s_per_page', BEA_SENDER_PPP), $this->get_items_per_page('bea_s_per_page', BEA_SENDER_PPP));
     // fitlering by status
     $filter = self::get_status_filter();
     // Get all the receivers
     $receivers = $campaign->get_receivers($filter, '', $limit);
     // check there is data before
     if (!$campaign->isData()) {
         return array();
     }
     return $receivers;
 }
예제 #3
0
 /**
  * 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;
 }