* IP Address: 67.79.165.254
 */
$module->page_title = _l('Statistics');
$newsletter_id = isset($_REQUEST['newsletter_id']) ? (int) $_REQUEST['newsletter_id'] : false;
if (!$newsletter_id) {
    set_error('Sorry no newsletter id specified');
    redirect_browser(module_newsletter::link_list(0));
}
$newsletter = module_newsletter::get_newsletter($newsletter_id);
// great a new blank send table ready to go (only if user clicks confirm)
$send_id = isset($_REQUEST['send_id']) ? (int) $_REQUEST['send_id'] : false;
if (!$send_id) {
    set_error('Sorry no newsletter send id specified');
    redirect_browser(module_newsletter::link_open($newsletter_id));
}
$send = module_newsletter::get_send($send_id);
if ($send['status'] != _NEWSLETTER_STATUS_SENT) {
    // hasnt sent yet, redirect to the pending watch page.
    redirect_browser(module_newsletter::link_queue_watch($newsletter_id, $send_id));
}
$start_time = $send['start_time'];
if (isset($_REQUEST['show'])) {
    // render the newsletter and display it on screen with nothing else.
    $content = module_newsletter::render($newsletter_id, $send_id, false, 'preview');
    // do the link click overview here:
    ob_end_clean();
    // grab all the links for this send
    $send_links = get_multiple('newsletter_link', array('send_id' => $send_id));
    $links_to_process = array();
    $old_links_by_url = array();
    foreach ($send_links as $send_link) {
예제 #2
0
 if (class_exists('module_newsletter', false)) {
     $columns['member_newsletter'] = array('title' => 'Newsletter', 'callback' => function ($member) {
         // find the groups for this member.
         $g = array();
         $groups = module_group::get_groups_search(array('owner_table' => 'newsletter_subscription', 'owner_id' => $member['member_id']));
         foreach ($groups as $group) {
             $g[] = $group['name'];
         }
         echo implode(', ', $g);
         echo ' ';
         $newsletter_member_id = module_newsletter::member_from_email($member, false);
         if ($newsletter_member_id) {
             if ($res = module_newsletter::is_member_unsubscribed($newsletter_member_id, $member)) {
                 if (isset($res['unsubscribe_send_id']) && $res['unsubscribe_send_id']) {
                     // they unsubscribed from a send.
                     $send_data = module_newsletter::get_send($res['unsubscribe_send_id']);
                     _e('(unsubscribed %s)', print_date($res['time']));
                 } else {
                     if (isset($res['reason']) && $res['reason'] == 'no_email') {
                         _e('(do not send)');
                     } else {
                         if (isset($res['reason']) && $res['reason'] == 'doubleoptin') {
                             _e('(double opt-in incomplete)', print_date($res['time']));
                         } else {
                             _e('(unsubscribed %s)', print_date($res['time']));
                         }
                     }
                 }
             }
         }
     });
예제 #3
0
                echo module_newsletter::link_open($newsletter['newsletter_id']);
                ?>
"><?php 
                _e('Edit');
                ?>
</a>
                        <?php 
                break;
        }
    }
});
$table_manager->set_columns($columns);
$table_manager->row_callback = function ($newsletter) {
    $newsletter['send_data'] = false;
    if ($newsletter['send_id']) {
        $newsletter['send_data'] = module_newsletter::get_send($newsletter['send_id']);
        // special cache for old newsletter subject.
        if (isset($newsletter['send_data']['cache']) && strlen($newsletter['send_data']['cache']) > 1) {
            $cache = unserialize($newsletter['send_data']['cache']);
            if ($cache) {
                $newsletter = array_merge($newsletter, $cache);
            }
        }
    }
    return $newsletter;
};
$table_manager->set_rows($newsletters);
$table_manager->pagination = true;
$table_manager->print_table();
?>
예제 #4
0
 public static function run_cron($debug = false)
 {
     // send any scheduled newsletters via cron job
     $pending = self::get_newsletters(array('pending' => 1));
     if (mysql_num_rows($pending) > 0) {
         while ($send = mysql_fetch_assoc($pending)) {
             if ($debug) {
                 echo "Attempting to send: ";
             }
             if ($debug) {
                 print_r($send['send_id']);
             }
             if ($send['send_id']) {
                 $send = module_newsletter::get_send($send['send_id']);
                 $start_time = $send['start_time'];
                 if ($start_time > time()) {
                     if ($debug) {
                         echo 'not sending this one yet due to start time';
                     }
                 } else {
                     if ($send['status'] == _NEWSLETTER_STATUS_PENDING) {
                         $newsletter_send_burst_count = module_config::c('newsletter_send_burst_count', 40);
                         $newsletter_send_burst_break = module_config::c('newsletter_send_burst_break', 2);
                         for ($x = 0; $x < 10; $x++) {
                             // todo: find a better way to run the cron job, eg: a timeout in configuration, or a max sends per cron run.
                             $send_result = module_newsletter::process_send($send['newsletter_id'], $send['send_id'], $newsletter_send_burst_count, false, false);
                             if (!isset($send_result['send_members']) || !count($send_result['send_members'])) {
                                 //$output_messages[] = _l('All done');
                             } else {
                                 foreach ($send_result['send_members'] as $send_member_result) {
                                     $update_members[$send_member_result['newsletter_member_id']] = array();
                                     switch ($send_member_result['status']) {
                                         case _MAIL_STATUS_SENT:
                                             $update_members[$send_member_result['newsletter_member_id']]['.sent_time'] = print_date(time(), true);
                                             $update_members[$send_member_result['newsletter_member_id']]['.status'] = _l('sent');
                                             $output_messages[] = _l('Sent successfully: %s', $send_member_result['email']);
                                             break;
                                         case _MAIL_STATUS_OVER_QUOTA:
                                             $output_messages[] = _l('Over quota, please wait: %s', $send_member_result['email']);
                                             $update_members[$send_member_result['newsletter_member_id']]['.status'] = _l('pending');
                                             // todo - update the main newsletter status to over quota? nah..
                                             break 2;
                                         case _MAIL_STATUS_FAILED:
                                         default:
                                             $output_messages[] = _l('FAILED: %s Reason: %s', $send_member_result['email'], $send_member_result['error']);
                                             $update_members[$send_member_result['newsletter_member_id']]['.status'] = _l('failed');
                                             break;
                                     }
                                 }
                             }
                             // get an update:
                             $send = module_newsletter::get_send($send['send_id']);
                             $remain = (int) $send['total_member_count'] - (int) $send['total_sent_count'];
                             if ($remain > 0) {
                                 if ($debug) {
                                     echo " Finished sending, {$remain} people remain\n";
                                 }
                             } else {
                                 if ($debug) {
                                     echo " Everyone sent!\n";
                                 }
                                 if (!$send['finish_time']) {
                                     // just to make sure we set the finish time.
                                     module_newsletter::process_send($send['newsletter_id'], $send['send_id']);
                                 }
                                 break;
                                 //exit for loop.
                             }
                         }
                     } else {
                         if ($debug) {
                             echo 'not sending due to status of ' . $send['status'];
                         }
                     }
                 }
             }
         }
     }
     if (!function_exists('imap_open')) {
         set_error('Please contact hosting provider and enable IMAP for PHP');
         echo 'Imap extension not available for php';
         return false;
     }
     self::check_bounces();
 }