'.__("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 {
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;
}
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 "import":
?>
· :
· :
email_address1@domain.ltd;name1 surname1email_address2@domain.ltd;name2 surname2
email_address3@domain.ltd;name3email_address4@domain.ltd
.
'.__("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'] ) {
// 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;
// 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") ) {
$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").' '.__("Error", "alo-easymail").' ';
$html .= '';
}
while ( ($data = fgetcsv($handle, 1000, ";")) !== FALSE ) {
$row++;
// check data
$email = stripslashes ( $wpdb->escape ( $data[0] ) );
$email = ( is_email( $email )) ? $email : false;
$name = ( isset($data[1]) ) ? stripslashes ( $wpdb->escape ( $data[1] ) ) : "";
// 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." ";
$html .= "". ( ( isset($not_imported[$data[0]]) ) ? $not_imported[$data[0]] : "") ." ";
} else { // insert records into db
if ( $email && ALO_em_add_subscriber( $email , $name , 1 ) ) {
$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
$name = ucfirst(get_user_meta($reg_user->UID, 'first_name', true))." " .ucfirst(get_user_meta($reg_user->UID,'last_name', true));
if (ALO_em_add_subscriber( $email , $name , 1 ) ) $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;
} // end switch action
} else {
echo ''. __("No action selected", "alo-easymail") .'.
';
}
}
?>
';
echo ''. __('Maybe you would like to import subscribers from your blog registered members or an external archive (using CSV). Click the 'Add/import subscribers' button', 'alo-easymail') .'.
';
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 )?$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
));
/*
$page_links = paginate_links( array(
'base' => $link_base ."&num=".$items_per_page. (($_GET['s'])? "&s=".$s : "") ,
'format' => '&paged=%#%',
'total' => $total_pages,
'show_all' => true,
'current' => $page
));*/
if ( $page_links ) echo "
$page_links
";
?>
Add new subscribers
// DEBUG ------------------------------------------
//print "".$query." ";
//print " Totali = ".$total_items." ";
//print_r($_GET)
// end DEBUG --------------------------------------
/**
* --- end MAIN ----------------------------------------------------------------
*/
?>