'.__("Activation state updated", "alo-easymail").'.
';
} else {
print ''.__("Error during operation.", "alo-easymail") ." ". __("Not updated", "alo-easymail").'.
';
}
}
// delete partecipation
if( isset($_REQUEST['task']) && $_REQUEST['task'] == 'delete' && is_numeric($_REQUEST['subscriber_id'])) {
if ( alo_em_delete_subscriber_by_id ($_REQUEST['subscriber_id']) ) {
print ''.__("Subscriber deleted", "alo-easymail").'.
';
} else {
if ( alo_em_is_subscriber_by_id($_REQUEST['subscriber_id']) ) { // error only if this subscriber exists yet, to prevent error on refresh page
print ''.__("Error during operation.", "alo-easymail") ." ". __("Not deleted", "alo-easymail").'.
';
}
}
}
// delete welcome import alert
if ( isset($_REQUEST['import_alert']) && $_REQUEST['import_alert'] == "stop" ) {
update_option( 'alo_em_import_alert', "hide" );
}
?>
Alo EasyMail Newsletter:
';
break;
}
if ($mailinglists) { ?>
:
:
'. __('There are no available lists', 'alo-easymail') .'.
';
break;
}
case "language":
if ( !isset($_REQUEST['subscribers'] ) || $_REQUEST['subscribers'] == "" ) {
echo ''.__("Error during operation.", "alo-easymail");
if ( !isset($_REQUEST['subscribers']) || $_REQUEST['subscribers'] == "" ) echo " ". __("No subscriber selected", "alo-easymail") .".";
if ( !isset($_REQUEST['check_lang']) || count ($_REQUEST['check_lang']) == 0 ) echo " ". __("No language option selected", "alo-easymail") .".";
echo '
';
break;
}
if ( $languages ) { ?>
:
:
'. __('No language available', 'alo-easymail') .'.
';
break;
}
case "delete":
if ( !isset($_REQUEST['subscribers'] ) || $_REQUEST['subscribers'] == "" ) {
echo ''.__("Error during operation.", "alo-easymail");
echo " ". __("No subscriber selected", "alo-easymail") .".";
echo '
';
break;
}
foreach ($_REQUEST['subscribers'] as $subsc => $val) {
alo_em_delete_subscriber_by_id ( $val );
}
print ''.__("Subscribers deleted", "alo-easymail").'.
';
break;
case "activate":
if ( !isset($_REQUEST['subscribers'] ) || $_REQUEST['subscribers'] == "" ) {
echo ''.__("Error during operation.", "alo-easymail");
echo " ". __("No subscriber selected", "alo-easymail") .".";
echo '
';
break;
}
foreach ($_REQUEST['subscribers'] as $subsc => $val) {
alo_em_edit_subscriber_state_by_id( $val , "1" );
}
print ''.__("Subscribers activated", "alo-easymail").'.
';
break;
case "deactivate":
if ( !isset($_REQUEST['subscribers'] ) || $_REQUEST['subscribers'] == "" ) {
echo ''.__("Error during operation.", "alo-easymail");
echo " ". __("No subscriber selected", "alo-easymail") .".";
echo '
';
break;
}
foreach ($_REQUEST['subscribers'] as $subsc => $val) {
alo_em_edit_subscriber_state_by_id( $val , "0" );
}
print ''.__("Subscribers deactivated", "alo-easymail").'.
';
break;
case "import":
?>
· :
· :
". __('You can list only languages available in the blog', 'alo-easymail') .": ". __('you can set them up in Settings > Newsletter', 'alo-easymail'). ". (". __('Language codes', 'alo-easymail') .": ". sprintf( '%s ', __('iso 639-1 codes', 'alo-easymail') ). ") " ?>
email_address1@domain.ltd;name1 surname1;en
email_address2@domain.ltd;name2 surname2;it
email_address3@domain.ltd;name3
email_address4@domain.ltd;;en
.
'.__("Error during operation.", "alo-easymail");
if ( !isset($_REQUEST['action']) || $_REQUEST['action'] == "" ) echo " ". __("No action selected", "alo-easymail") .".";
if ( !isset($_REQUEST['subscribers'] )) echo " ". __("No subscriber selected", "alo-easymail") .".";
echo '
';
}
}
/**
* Bulk action: Step #2/2
*/
if ( isset($_REQUEST['doaction_step2']) ) {
//if($wp_version >= '2.6.5') check_admin_referer('alo-easymail_subscribers');
if ( isset($_REQUEST['action']) && $_REQUEST['action'] != "" ) {
switch ( $_REQUEST['action'] ) {
// Add a subscriber with simple form
case "addsingle_step2":
if ( !isset($_REQUEST['addsingle_email']) || !is_email( $_REQUEST['addsingle_email']) ) {
echo ''.__("Error during operation.", "alo-easymail");
if ( !isset($_REQUEST['addsingle_email']) || !is_email( $_REQUEST['addsingle_email'] ) ) echo " ". __("The e-email address is not correct", "alo-easymail") .".";
echo '
';
echo ''. __("Back", "alo-easymail"). '
';
exit;
}
$email = stripslashes ( $wpdb->escape ( trim( $_REQUEST['addsingle_email'] ) ) );
$name = ( isset( $_REQUEST['addsingle_name'] ) ) ? stripslashes ( $wpdb->escape ( trim( $_REQUEST['addsingle_name'] ) ) ) : "";
$lang = ( isset( $_REQUEST['addsingle_name'] ) ) ? stripslashes ( $wpdb->escape ( trim( $_REQUEST['addsingle_lang'] ) ) ) : "";
if ( $email && alo_em_add_subscriber( $email , $name , 1, $lang ) == "OK" ) {
if ( isset($_REQUEST['check_list']) ) {
$subscriber_id = alo_em_is_subscriber( $email );
foreach ( $_REQUEST['check_list'] as $list ) {
alo_em_add_subscriber_to_list ( $subscriber_id, $list );
}
}
print ''.__("New subscriber added", "alo-easymail").'.
';
}
break;
// Save requested subscriptions to lists
case "lists_step2":
if ( !isset($_REQUEST['subscribers']) || $_REQUEST['subscribers'] == "" || !isset($_REQUEST['check_list']) || count ($_REQUEST['check_list']) == 0 ) {
echo ''.__("Error during operation.", "alo-easymail");
if ( !isset($_REQUEST['subscribers']) || $_REQUEST['subscribers'] == "" ) echo " ". __("No subscriber selected", "alo-easymail") .".";
if ( !isset($_REQUEST['check_list']) || count ($_REQUEST['check_list']) == 0 ) echo " ". __("No list selected", "alo-easymail") .".";
echo '
';
break;
}
$selected_subscribers = explode ( "," , $_REQUEST['subscribers'] );
switch ( $_REQUEST['mode'] ) { // The requested mode
case "add_remove": // Add to selected lists and remove from not selected lists
// TODO !
break;
case "add": // Add to selected lists
foreach ($selected_subscribers as $subscriber ) {
foreach ( $_REQUEST['check_list'] as $list ) {
alo_em_add_subscriber_to_list ( $subscriber, $list );
}
}
break;
case "remove": // Remove from selected lists
foreach ($selected_subscribers as $subscriber ) {
foreach ( $_REQUEST['check_list'] as $list ) {
alo_em_delete_subscriber_from_list ( $subscriber, $list );
}
}
break;
} // end switch mode
print ''.__("Updated", "alo-easymail").'.
';
break;
// Save requested language attribute
case "langs_step2":
if ( !isset($_REQUEST['subscribers']) || $_REQUEST['subscribers'] == "" || !isset($_REQUEST['check_lang']) || count ($_REQUEST['check_lang']) == 0 ) {
echo ''.__("Error during operation.", "alo-easymail");
if ( !isset($_REQUEST['subscribers']) || $_REQUEST['subscribers'] == "" ) echo " ". __("No subscriber selected", "alo-easymail") .".";
if ( !isset($_REQUEST['check_lang']) ) echo " ". __("No language option selected", "alo-easymail") .".";
echo '
';
break;
}
$selected_subscribers = explode ( "," , $_REQUEST['subscribers'] );
foreach ($selected_subscribers as $subscriber ) {
$lang = ( $_REQUEST['check_lang'] == "blank" ) ? "" : $_REQUEST['check_lang'] ;
alo_em_assign_subscriber_to_lang ( $subscriber, $lang );
}
print ''.__("Updated", "alo-easymail").'.
';
break;
// Upload csv and insert new subscribers into db
case "import_step2":
if ( ($handle = fopen($_FILES['uploaded_csv']['tmp_name'], "r")) !== FALSE /* && ($_FILES['uploaded_csv']['type'] == "text/csv" || $_FILES['uploaded_csv']['type'] == "text/plain" || $_FILES['uploaded_csv']['type'] == "text/tsv") */ ) {
$row = 0;
$success = 0; // success
$not_imported = array(); // list not imported and why
if ( isset($_REQUEST['test_only']) && $_REQUEST['test_only'] == "yes") {
$html = "";
$html .= ''. __("Back", "alo-easymail"). '
';
$html .= '';
$html .= ' '.__("E-mail", "alo-easymail").' '.__("Name", "alo-easymail").' '.__("Language", "alo-easymail").' '.__("Error", "alo-easymail").' ';
$html .= '';
}
while ( ($data = fgetcsv($handle, 1000, ";")) !== FALSE ) {
$row++;
// check data
$email = stripslashes ( $wpdb->escape ( trim( $data[0] ) ) );
$email = ( is_email( $email )) ? $email : false;
$name = ( isset($data[1]) ) ? stripslashes ( $wpdb->escape ( trim($data[1]) ) ) : "";
$lang = ( isset($data[2]) ) ? stripslashes ( $wpdb->escape ( trim($data[2]) ) ) : "";
if ( !empty( $lang ) ) {
$lang = alo_em_short_langcode ( $lang );
if ( !in_array ( $lang, alo_em_get_all_languages( false )) ) $lang = "";
}
// error
if ( $email == false ) { // error: email incorrect
$not_imported[$data[0]] = __("The e-email address is not correct", "alo-easymail") ;
} else { // error: already existing
if ( alo_em_is_subscriber($email) ) $not_imported[$data[0]] = __("There is already a subscriber with this e-email address", "alo-easymail") ;
}
if ( isset($_REQUEST['test_only']) && $_REQUEST['test_only'] == "yes") { // test, print records
//if ( $row > 10 ) continue; // print only the 1st 10
$span_email = ( isset($not_imported[$data[0]])) ? "".$data[0]." " : $data[0] ;
$html .= "$row: ";
$html .= "". $span_email ." ".$name." ".alo_em_get_lang_flag($lang, 'name')." ";
$html .= "". ( ( isset($not_imported[$data[0]]) ) ? $not_imported[$data[0]] : "") ." ";
} else { // insert records into db
if ( $email && $result = alo_em_add_subscriber( $email , $name , 1, $lang ) /*== "OK"*/ ) {
if ( isset($_REQUEST['check_list']) ) {
$subscriber_id = alo_em_is_subscriber( $email );
foreach ( $_REQUEST['check_list'] as $list ) {
alo_em_add_subscriber_to_list ( $subscriber_id, $list );
unset( $not_imported[$data[0]] );
if ( $result != "OK" ) { // if not just added
$not_imported[$data[0]] = __("There is already a subscriber with this e-email address", "alo-easymail").". ". __("Subscriber has been added to selected mailing lists", "alo-easymail") ;
}
}
}
if ( $result == "OK" ) $success ++;
}
}
}
fclose($handle);
if ( isset($_REQUEST['test_only']) && $_REQUEST['test_only'] == "yes") { // test report
$html .= '
';
echo ''. sprintf(__("Found %d records", "alo-easymail"), $row ) .'.
';
if ( count($not_imported) ) echo ''. __("Check the Error column to modify records that otherwise will not be imported", "alo-easymail"). '.
';
echo $html; // print table
echo ''. __("Back", "alo-easymail"). '
';
exit();
} else { // import report
echo ''. sprintf(__("Successfully import: %d records out of %d total", "alo-easymail"), $success, $row ) .'.';
if ( count($not_imported) ) {
echo '
'.__("Some records have not been imported", "alo-easymail").':
';
echo '';
echo '
';
foreach ($not_imported as $email => $error ) {
echo ''.$email.' ';
echo ''.$error.' ';
}
echo '
';
}
echo '
';
break;
}
} else {
echo ''.__("Not valid CSV file uploaded", "alo-easymail") . '.
';
}
break;
// Import from WP registrered users
case "wpusers_step2":
$reg_users = alo_em_get_recipients_registered ();
if ( $reg_users ) {
$add = 0;
foreach ( $reg_users as $reg_user ) {
$email = $reg_user->user_email;
if ( alo_em_is_subscriber($email) == false ){ // if not already subscriber, add
if ( get_user_meta($reg_user->UID, 'first_name', true) != "" ) {
$name = ucfirst(get_user_meta($reg_user->UID, 'first_name', true))." " .ucfirst(get_user_meta($reg_user->UID,'last_name', true));
} else {
$name = get_user_meta($reg_user->UID, 'nickname', true);
}
if ( alo_em_add_subscriber( $email , $name , 1, "" ) == "OK" ) $add ++;
}
}
}
if ( $add > 0 ) {
echo ''. sprintf(__("%d new subscribers successfully added from blog members", "alo-easymail"), $add ) .'.
';
} else {
echo ''. __("No subscribers added from blog members", "alo-easymail") .'.
';
}
break;
// Export: show subscribers on screen
case "export_step2":
$all_subs = $wpdb->get_results( "SELECT email, name, lang FROM {$wpdb->prefix}easymail_subscribers" );
if ( $all_subs ) {
echo ''. __("Back", "alo-easymail"). '
';
echo "\r\n";
foreach ( $all_subs as $sub ) {
echo $sub->email . ";" . $sub->name . ";" . $sub->lang. "\r\n";
}
echo "\r\n ";
} else {
echo ''. __("No subscribers", "alo-easymail") . '.
';
}
echo ''. __("Back", "alo-easymail"). '
';
exit();
break;
} // end switch action
} else {
echo ''. __("No action selected", "alo-easymail") .'.
';
}
}
?>
';
echo ''. sprintf( __('Maybe you would like to import subscribers from your blog registered members or an external archive (using CSV). Click the '%s' button', 'alo-easymail'), $impexp_butt) .'.
';
echo "( ". __('Do not show it again', 'alo-easymail') .")
";
echo '';
}
?>
";
foreach($array_num as $n) {
//$selected_test = ($id_test == $test->ID ? ' selected="selected" ': '');
echo "$n ";
}
echo "";
?>
get_var("SELECT COUNT(*) FROM {$wpdb->prefix}easymail_subscribers" . (!empty( $s ) || !empty($filter_list) || !empty($filter_lang) ? $where_search : ""));
$total_pages = ceil($total_items / $items_per_page);
$arr_params = array ('paged' => '%#%',
'subscriber_id' => '' /* unset to avoid updated msg in next page */
);
$page_links = paginate_links( array(
'base' => add_query_arg( $arr_params/*'paged', '%#%' */),
'format' => '',
'total' => $total_pages,
'show_all' => true,
'current' => $page
));
if ( $page_links ) echo "
$page_links
";
?>
".$query."";
//print " Totali = ".$total_items." ";
//print_r($_GET)
// end DEBUG --------------------------------------
/**
* --- end MAIN ----------------------------------------------------------------
*/
?>