ALO EasyMail Newsletter

lang) ) ? $sub->lang : "UNKNOWN"; // if subscriber has not specified lang if ( $to_langs && array_search($search_lang, $to_langs)=== false ) continue; $recipients[$sub->email]['email'] = $sub->email; $recipients[$sub->email]['name'] = $sub->name; $recipients[$sub->email]['firstname'] = $sub->name; $recipients[$sub->email]['unikey'] = $sub->unikey; $recipients[$sub->email]['lang'] = $sub->lang; } } else { // if not requested all subcribers, maybe requested only by selected lists? if ( isset($_POST['check_list']) && is_array ($_POST['check_list']) ) { $subs = ALO_em_get_recipients_subscribers( $_POST['check_list'] ); if ( $subs) { foreach ( $subs as $sub ) { // do not add the subscribers with not required langs $search_lang = ( !empty($sub->lang) ) ? $sub->lang : "UNKNOWN"; // if subscriber has not specified lang if ( $to_langs && array_search($search_lang, $to_langs)=== false ) continue; $recipients[$sub->email]['email'] = $sub->email; $recipients[$sub->email]['name'] = $sub->name; $recipients[$sub->email]['firstname'] = $sub->name; $recipients[$sub->email]['unikey'] = $sub->unikey; $recipients[$sub->email]['lang'] = $sub->lang; } } } } // If request add all REGISTERED users if ( isset($_POST['all_regusers']) && $_POST['all_regusers'] == 'checked') { $reg_users = ALO_em_get_recipients_registered (); if ($reg_users) { foreach ($reg_users as $reg_user) { // login name as default name if first/lastname are empty //$user_info = get_userdata( $reg_user->UID ); //$user_loginname = $user_info->user_login; if ( get_user_meta($reg_user->UID, 'first_name', true) != "" ) { $reg_firstname = ucfirst(get_user_meta($reg_user->UID, 'first_name', true)); } else { $reg_firstname = get_user_meta($reg_user->UID, 'nickname', true); } if ( get_user_meta($reg_user->UID, 'first_name', true) != "" || get_user_meta($reg_user->UID, 'last_name', true) != "" ) { $reg_name = ucfirst(get_user_meta($reg_user->UID, 'first_name',true))." " .ucfirst(get_user_meta($reg_user->UID,'last_name',true)); } else { $reg_name = get_user_meta($reg_user->UID, 'nickname', true); } $recipients[$reg_user->user_email]['email'] = $reg_user->user_email; $recipients[$reg_user->user_email]['name'] = $reg_name; $recipients[$reg_user->user_email]['firstname'] = $reg_firstname; $recipients[$reg_user->user_email]['lang'] = $reg_user->lang; } } } // Subject $subject = stripslashes($wpdb->escape($_POST['title'])); // Main content $main_content = stripslashes($_POST['content']); // Check errors $error_on_submit = false; if ($subject == "" || $main_content == "") { $fbk_msg = "error"; $error_on_submit = true; } if (count($recipients) < 1 ) { $fbk_msg = "norecipients"; $error_on_submit = true; } // If no errors let's go! if ( $error_on_submit == false ) { // Save emails'list for next sending, if request if ( isset($_POST['ck_save_list']) ) update_option( 'ALO_em_list_user_'.$user_ID, trim($_POST['emails_add']) ); // Tracking feature $tracking = ( isset($_POST['ck_tracking']) && $_POST['ck_tracking'] != "" ) ? $_POST['ck_tracking'] : ""; // need a numeric index array $num_rec = array(); $n =0; foreach($recipients as $rec) { $num_rec[$n]= $rec; $n ++; } // adjust content (post tags) $updated_content = $main_content; $updated_content = str_replace("\n", "
", $updated_content); // trim
added when rendering html tables (thanks to gunu) $updated_content = str_replace( array("
". get_the_title($obj_post->ID) ."", $updated_content); } else { $updated_content = str_replace("[POST-TITLE]", "", $updated_content); } // TAG: [POST-CONTENT] if ($pID) { $updated_content = str_replace("[POST-CONTENT]", $obj_post->post_content, $updated_content); } else { $updated_content = str_replace("[POST-CONTENT]", "", $updated_content); } // TAG: [POST-EXCERPT] - if any if ($pID && !empty($obj_post->post_excerpt)) { $updated_content = str_replace("[POST-EXCERPT]", $obj_post->post_excerpt, $updated_content); } else { $updated_content = str_replace("[POST-EXCERPT]", "", $updated_content); } // TAG: [SITE-LINK] $updated_content = str_replace("[SITE-LINK]", "".get_option('blogname')."", $updated_content); */ //echo "
";print_r($num_rec);echo "
";exit; /* //--------- // DEBUG //--------- echo "HEADERS: ".$headers."
"; echo "SUBJECT: ".$subject."
"; echo "CONTENT: ".$updated_content."
"; echo "PLAIN CONTENT:
" . ALO_em_html2plain($updated_content) ."

"; foreach ($recipients as $rec) { echo "
";print_r ($rec);echo "
"; } // echo $wpdb->last_query; //echo "
";print_r ($_REQUEST);echo "
"; */ // add the newsletter to db if ( ALO_em_add_new_batch ( $user_ID, $subject, $updated_content, serialize($num_rec), $tracking, $pID ) == true) { $fbk_msg = "success"; $_REQUEST['tab'] = "reports"; // show report } else { $fbk_msg = "nosending"; } } // end if $error_on_submit == false } /******************************************************************************* * Submit template ******************************************************************************/ if(isset($_REQUEST['submit_tpl'])) { if ( !current_user_can('send_easymail_newsletters') ) wp_die(__('Cheatin’ uh?')); check_admin_referer('alo-easymail_main'); // Subject $subject = stripslashes($wpdb->escape($_POST['title'])); // Main content $main_content = stripslashes($_POST['content']); // Check for errors $error_on_submit = false; if ($subject == "" || $main_content == "") { $fbk_msg = "tpl_error"; $error_on_submit = true; } // If no errors let's go! if ( $error_on_submit == false ) { // UPDATE the template to db if ( isset($_POST['task']) && $_POST['task'] == "update_tpl" && isset($_POST['tpl_id']) && is_numeric($_POST['tpl_id']) ) { if ( ALO_em_update_template ( $_POST['tpl_id'], $user_ID, $subject, $main_content ) == true) { $fbk_msg = "tpl_saved"; } else { $fbk_msg = "tpl_nosaved"; } } else { // ADD the template to db if ( ALO_em_add_new_template ( $user_ID, $subject, $main_content ) == true) { $fbk_msg = "tpl_saved"; } else { $fbk_msg = "tpl_nosaved"; } } unset($_POST); } // end if $error_on_submit == false } /** * Set Tabs */ if ( empty($active_tab) ) { if ( isset( $_REQUEST['tab']) ) { if ( $_REQUEST['tab'] == "reports") { $active_tab = "reports"; $reports_tab_active = $sel_active_class; } else if ( $_REQUEST['tab'] == "templates") { $active_tab = "templates"; $templates_tab_active = $sel_active_class; } else { $active_tab = "send"; $send_tab_active = $sel_active_class; } } else { $active_tab = "send"; $send_tab_active = $sel_active_class; } } // Reset base url (cut message vars...) $clean_url = remove_query_arg( array('tab', 'message', 'task', 'id') ); ?>

» » »

= 8)? /** * Other Requested actions */ if ( isset( $_REQUEST['task']) ) { // Cancel one of own newsletter in sending queue if ( $_REQUEST['task'] == "del_send" && isset( $_REQUEST['id'])) { $where_user = ( $can_edit_all )? "" : " AND user = %d "; $check_id = $wpdb->query( $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}easymail_sendings WHERE ID = %d {$where_user}", $_REQUEST['id'], $user_ID ) ); if ($check_id) { if ( ALO_em_delete_newsletter ( $_REQUEST['id'] ) ) { echo '

'.__("Newsletter successfully deleted", "alo-easymail").'

'; } else { echo '

'.__("Impossible to delete the selected newsletter", "alo-easymail").'

'; } } } // Delete a template if ( $_REQUEST['task'] == "del_tpl" && isset( $_REQUEST['id'])) { $where_user = ( $can_edit_all )? "" : " AND user = %d "; $check_id = $wpdb->query( $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}easymail_sendings WHERE ID = %d {$where_user} AND sent = 9", $_REQUEST['id'], $user_ID ) ); if ($check_id) { if ( ALO_em_delete_newsletter ( $_REQUEST['id'] ) ) { echo '

'.__("Template successfully deleted", "alo-easymail").'

'; } else { echo '

'.__("Impossible to delete the selected template", "alo-easymail").'

'; } } } // Send a newsletter from a template / Modify a template if ( ($_REQUEST['task'] == "send_tpl" || $_REQUEST['task'] == "mod_tpl") && isset( $_REQUEST['id'])) { $where_user = ( $can_edit_all )? "" : " AND user = %d "; $from_template = $wpdb->get_row( $wpdb->prepare( "SELECT ID, subject, content, sent FROM {$wpdb->prefix}easymail_sendings WHERE ID = %d {$where_user} AND sent = 9", $_REQUEST['id'], $user_ID ) ); } } /** * If feedback message */ if ( !empty( $fbk_msg )) : switch( $fbk_msg ) { case 'success': // ok, sending scheduled $fbk_msg = '
'; $fbk_msg .= '

'; $fbk_msg .= ''.__("New sending added with success!", "alo-easymail").'

'; if ( isset( $and_tpl ) ) $fbk_msg .= '

'.__("Template saved", "alo-easymail").'.

'; $fbk_msg .= "
"; break; case 'error': // error in inputs $fbk_msg = '
'; $fbk_msg .= '

'; $fbk_msg .= ''.__("Inputs are incompled or wrong. Please check and try again.", "alo-easymail").'

'; if ( isset( $and_tpl ) ) $fbk_msg .= '

'.__("Template saved", "alo-easymail").'.

'; $fbk_msg .= "
"; break; case 'norecipients': // no recipients selected $fbk_msg = '
'; $fbk_msg .= '

'; $fbk_msg .= ''.__("No recipients selected.", "alo-easymail").'

'; $fbk_msg .= "
"; break; case 'nosending': // error on sending $fbk_msg = '
'; $fbk_msg .= '

'; $fbk_msg .= ''.__("Impossible to send. Please try again.", "alo-easymail").'

'; $fbk_msg .= "
"; break; case 'tpl_saved': // template saved $fbk_msg = '
'; $fbk_msg .= '

'; $fbk_msg .= ''.__("Template saved", "alo-easymail").'

'; $fbk_msg .= "
"; break; case 'tpl_nosaved': // error on template saving $fbk_msg = '
'; $fbk_msg .= '

'; $fbk_msg .= ''.__("Impossible to save the template. Please try again.", "alo-easymail").'

'; $fbk_msg .= "
"; break; case 'tpl_error': // error in template inputs $fbk_msg = '
'; $fbk_msg .= '

'; $fbk_msg .= ''.__("Inputs are incompled or wrong. Please check and try again.", "alo-easymail").'

'; $fbk_msg .= "
"; break; default: $fbk_msg = ""; } echo $fbk_msg; endif; // end if ( isset( $_REQUEST['message'])) /*-------------------------------------- REPORTS Tab --------------------------------------*/ if ( $active_tab == "reports" ) : /*------------------------------------*/ $linkthick = wp_nonce_url( ALO_EM_PLUGIN_URL . '/alo-easymail_report.php?', 'alo-easymail_main'); ?> get_results("SELECT * FROM {$wpdb->prefix}easymail_sendings WHERE sent = 0 ORDER BY ID ASC"); //echo "
";print_r($news_on_queue);echo "
"; if (count($news_on_queue)) { ?> ID}' class='$class'>\n"; ?> "; $row_count++; } echo "
(»)
'; } else { echo $row_count; } ?> user == $user_ID) { echo "".__("you", "alo-easymail").""; } else { if ( $can_edit_all ) { echo get_user_meta($q->user, 'nickname', true); } else { echo"".__("another user", "alo-easymail").""; } } ?> start_at))." h.".date("H:i", strtotime($q->start_at)) ?> user == $user_ID || $can_edit_all ) { $qsubject = $q->subject; if ( $q->tag ) { $obj_post = get_post( $q->tag ); $qpost_title = stripslashes ( ALO_em___ ( $obj_post->post_title ) ); $qsubject = str_replace('[POST-TITLE]', $qpost_title, $qsubject); } echo stripslashes ( ALO_em___( $qsubject ) ); } ?> recipients ); $q_tot = count($q_recipients); $n_sent = 0; foreach ($q_recipients as $qr) { if ( isset($qr['result']) ) $n_sent ++; } echo round($n_sent*100/ $q_tot ) . " %" ; ?> user == $user_ID && $can_edit_own ) || $can_edit_all ) { echo ""; echo __("Cancel", "alo-easymail"). ""; } ?>
"; echo "

 

"; } ?> get_results("SELECT * FROM {$wpdb->prefix}easymail_sendings WHERE sent = 1 {$where_user} ORDER BY ID DESC"); //echo "
";print_r($news_on_queue);echo "
"; if (count($news_done)) { ?> '.__("Scheduled by", "alo-easymail").''; ?> ID}' class='$class'>\n"; ?> ". ( ($q->user == $user_ID)? "".__("you", "alo-easymail")."": get_user_meta($q->user, 'nickname', true) ). ""; } ?> "; $row_count++; } echo "
#
start_at))." h.".date("H:i", strtotime($q->start_at)) ?> last_at))." h.".date("H:i", strtotime($q->last_at)) ?> user == $user_ID || $can_edit_all ) { $qsubject = $q->subject; if ( $q->tag ) { $obj_post = get_post( $q->tag ); $qpost_title = stripslashes ( ALO_em___ ( $obj_post->post_title ) ); $qsubject = str_replace('[POST-TITLE]', $qpost_title, $qsubject); } echo stripslashes ( ALO_em___( $qsubject ) ); } ?> user == $user_ID && $can_edit_own ) || $can_edit_all ) { echo ""; echo __("Delete", "alo-easymail"). " - "; echo "ID})\">"; echo __("View", "alo-easymail"). ""; } ?>
"; echo "

 

"; } ?>

:
:
  • />
  • />
:
    $val) { if ( $val['available'] == "deleted" || $val['available'] == "hidden" ) continue; $checked = ( isset($_POST['check_list']) && in_array($list, $_POST['check_list']) ) ? ' checked="checked" ' : ''; ?>
  • />
:
    $lang) { $checked = ( (isset($_POST['check_lang']) && in_array($lang, $_POST['check_lang'])) || !isset($_POST['submit']) ) ? ' checked="checked" ' : ''; $tot_sub_x_lang = ALO_em_count_subscribers_by_lang( $lang, true ); ?>
  • />
  • />
. .
:

subject ) ); } else { $subj = ( isset($_POST['title'])? htmlspecialchars ( stripslashes ( $_POST['title'] ) ) : ""); } ?>
$n_last_posts, 'order' => 'DESC', 'orderby' => 'date' ); $get_posts = get_posts($args); $tot_posts = count($get_posts); echo ''; ?>
.
:

()
:
content; } else { $main_content = ( isset($_POST['content'])? $_POST['content'] : ""); } the_editor ($main_content); ?>

. ID . '">'; } ?>

';"/> .
get_results("SELECT ID, start_at, last_at, user, subject, content, sent FROM {$wpdb->prefix}easymail_sendings WHERE sent = 9 AND user={$user_ID} ORDER BY last_at DESC"); //echo "
";print_r($templates);echo "
"; if (count($templates)) { ?> ID}' class='$class'>\n"; ?> "; $row_count++; } echo "
last_at))." h.".date("H:i", strtotime($t->last_at)) ?> start_at))." h.".date("H:i", strtotime($t->start_at)) ?> user == $user_ID )? stripslashes ( ALO_em___( $t->subject ) ) /*stripslashes ( $t->subject )*/ : "" ?> user == $user_ID && $can_edit_own ) { echo ""; echo __("Delete", "alo-easymail"). " - "; echo "". __("Edit", "alo-easymail"). " - "; echo "". __("Send", "alo-easymail"). ""; } ?>
"; echo "

 

"; } else { echo "

". __("There are no templates yet", "alo-easymail") .".

"; } ?>

subject ) ); } else if ( isset($_POST['title'])) { $subj = htmlspecialchars ( stripslashes ( $_POST['title'] ) ); } ?>
:

()
:
content; } else if ( isset($_POST['content'])) { $main_content = $_POST['content']; } the_editor ($main_content); ?>

';"/>
'; echo ''; } ?>