WordPress.org

Plugin Directory

Changeset 657422


Ignore:
Timestamp:
01/23/13 15:08:54 (5 years ago)
Author:
kzaron
Message:

Update to version 1.5!

Location:
network-mass-email
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • network-mass-email/trunk/network-mass-email.php

    r654991 r657422  
    44 Plugin URI: http://wordpress.org/extend/plugins/network-mass-email/ 
    55 Description: Allows network admins to send a manually created notification email to all registered users based on user role. 
    6  Version: 1.4.2 
     6 Version: 1.5 
    77 Author: Kenny Zaron 
    88 Author URI: http://www.kennyzaron.com/ 
     
    2525    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    2626*/ 
     27 
     28// Mail Icon(s) courtesy of: http://www.iconhot.com/icon/android-style-icons-r1/mail-64.html 
    2729 
    2830//error variables 
     
    3234$nmenoemailserror = false; 
    3335$nmenoroleserror = false; 
     36$nmeloadtemplateserr = false; 
     37$message = ""; 
     38$subject = ""; 
    3439 
    3540// Determines on pageload whether to load the compose email function or the send email function 
     
    3843    // Run some checks on the submitted form; if everything is OK, send our message 
    3944    elseif (isset($_POST['submitsendemail'])) { nme_error_checker(); } 
    40     else { nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror); } 
     45    elseif (isset($_POST['loadtemplate'])) {         
     46        global $wpdb; 
     47        $table_name = $wpdb->prefix . "networkmassemail";    
     48        //see if template name exists in wpdb    
     49        if ( $_POST['selecttemplate'] == "" ) { 
     50            // it was blank, just load the page 
     51            nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror, $nmeloadtemplateserr, $subject, $message); 
     52        } 
     53        else if ($wpdb->get_var("SELECT name FROM {$table_name} WHERE name='{$_POST['selecttemplate']}'") == $_POST['selecttemplate']) {         
     54            //select template row from db            
     55            $templateresult = $wpdb->get_row("SELECT * FROM $table_name WHERE name='" . $_POST['selecttemplate'] . "'");             
     56            $subject = $templateresult->subject; 
     57            $message = $templateresult->message;                             
     58        } 
     59        else { 
     60            $nmeloadtemplateserr = true;             
     61        } 
     62        // check if the list was already loaded 
     63         
     64         
     65        nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror, $nmeloadtemplateserr, $subject, $message); 
     66    } 
     67    else { nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror, $nmeloadtemplateserr, $subject, $message); } 
    4168} 
    4269 
     
    5481    if( ($_POST['emaillist'] == "") && (isset($_POST['submitsendemail'])) ) { $nmenoemailserror = true; } 
    5582    if (isset($_POST['submitsendemail']) && $nmewassuberror == false && $nmewasmsgerror == false && $nmewasfromerror == false && $nmenoemailserror == false) { nme_sendmail(); } 
    56     else { nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror); } 
     83    else { nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror, $nmeloadtemplateserr, $subject, $message); } 
    5784    } 
    5885} 
     
    6087//page header function 
    6188function nme_pageheader() { 
    62         screen_icon(); 
     89        screen_icon('users'); 
    6390        ?><h2>Network Mass Email</h2><?php 
    6491} 
     
    6693//sends the messages to the users selected after form is submitted 
    6794function nme_sendmail() { 
    68         $subject = $_POST['emailsubject']; 
     95        $subject = stripslashes(html_entity_decode($_POST['emailsubject'], ENT_NOQUOTES, 'UTF-8')); 
    6996        $body = stripslashes(html_entity_decode($_POST['emailmessage'], ENT_NOQUOTES, 'UTF-8')); 
    7097        $from = $_POST['emailfrom'];  
     
    104131// Adds the submenu page under users in network admin 
    105132function nme_add_menu() { 
    106     add_submenu_page( 'users.php', 'Network Mass Email', 'Mass Email', 'manage_network', 'nme_menupage', 'nme_decider' ); 
    107 } 
     133    // reference: add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); http://codex.wordpress.org/Function_Reference/add_menu_page 
     134    add_menu_page( 'Network Mass Email', 'Mass Email', 'manage_network', 'nme_menupage', 'nme_decider', plugins_url('network-mass-email/icon.png'), 99 ); 
     135    add_submenu_page( 'nme_menupage', 'Network Mass Email', 'Send Email', 'manage_network', 'nme_menupage', 'nme_decider' ); 
     136} 
     137 
     138define( 'NETWORKMASSEMAIL_PATH', plugin_dir_path(__FILE__) ); 
     139require NETWORKMASSEMAIL_PATH .'/templates.php'; 
    108140 
    109141// Displays error messages 
     
    113145 
    114146// Creates the part of the page where users compose their email 
    115 function nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror) { 
     147function nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror, $nmeloadtemplateserr, $subject, $message) { 
    116148    nme_pageheader();  
     149    nme_install(); 
    117150    if($nmewasfromerror == true) { $nmeerrmessage = "ERROR: Your from email address cannot be blank."; nme_error_msg($nmeerrmessage); } 
    118151    if($nmewassuberror == true) { $nmeerrmessage = "ERROR: Your subject cannot be blank."; nme_error_msg($nmeerrmessage); } 
    119152    if($nmewasmsgerror == true) { $nmeerrmessage = "ERROR: Your message body cannot be blank."; nme_error_msg($nmeerrmessage); } 
     153    if($nmeloadtemplateserr == true) { $nmeerrmessage = "ERROR: Could not load template."; nme_error_msg($nmeerrmessage); } 
    120154    if($nmenoroleserror == true && isset($_POST['listbuttonsubmit'])) { $nmeerrmessage = "ERROR: You need to select at least one group of users in order to load the list."; nme_error_msg($nmeerrmessage); } 
    121155    if($nmenoemailserror == true && isset($_POST['submitsendemail'])) { $nmeerrmessage = "ERROR: You need to load users before sending an email."; nme_error_msg($nmeerrmessage); } 
    122     if ($nmewassuberror == false && $nmewasmsgerror == false && $nmewasfromerror == false && $nmenoemailserror == false && $nmenoroleserror == false) { echo "<br />"; } 
    123     ?> 
     156    if ($nmewassuberror == false && $nmewasmsgerror == false && $nmewasfromerror == false && $nmenoemailserror == false && $nmenoroleserror == false) { echo "<br />"; }    ?> 
    124157    <h2>Audience</h2> 
    125158    <p>Select the user levels you wish to send this message to:</p> 
    126159    <form name="massemailform" action="" method="post"> 
    127     <input type="checkbox" name="allincsubs" <?php if($_POST['allincsubs']) echo 'checked="checked"'; else echo ""; ?> onclick="selectAllIncSubs(this);"/> All Users<br /> 
    128     <input type="checkbox" name="allbutsubs" <?php if($_POST['allbutsubs']) echo 'checked="checked"'; else echo ""; ?> onclick="selectAllButSubs(this);"/> All Users EXCEPT Subscribers<br /> 
    129     <input type="checkbox" name="admins" id="admins" <?php if($_POST['admins']) echo 'checked="checked"'; else echo ""; ?> /> Administrators  &nbsp; 
    130     <input type="checkbox" name="editors" id="editors" <?php if($_POST['editors']) echo 'checked="checked"'; else echo ""; ?> /> Editors &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    131     <input type="checkbox" name="authors" id="authors" <?php if($_POST['authors']) echo 'checked="checked"'; else echo ""; ?> /> Authors<br /> 
    132     <input type="checkbox" name="contributors" id="contributors" <?php if($_POST['contributors']) echo 'checked="checked"'; else echo ""; ?> /> Contributors &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    133     <input type="checkbox" name="subscribers" id="subscribers" <?php if($_POST['subscribers']) echo 'checked="checked"'; else echo ""; ?> /> Subscribers<br /><br /> 
     160    <input type="checkbox" name="allincsubs" id="allincsubs" <?php if($_POST['allincsubs']) echo 'checked="checked"'; else echo ""; ?> onclick="selectAllIncSubs(this);"/> <label for="allincsubs">All Users</label><br /> 
     161    <input type="checkbox" name="allbutsubs" id="allbutsubs" <?php if($_POST['allbutsubs']) echo 'checked="checked"'; else echo ""; ?> onclick="selectAllButSubs(this);"/> <label for="allbutsubs">All Users EXCEPT Subscribers</label><br /> 
     162    <input type="checkbox" name="admins" id="admins" <?php if($_POST['admins']) echo 'checked="checked"'; else echo ""; ?> /> <label for="admins">Administrators</label>  &nbsp; 
     163    <input type="checkbox" name="editors" id="editors" <?php if($_POST['editors']) echo 'checked="checked"'; else echo ""; ?> /> <label for="editors">Editors</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     164    <input type="checkbox" name="authors" id="authors" <?php if($_POST['authors']) echo 'checked="checked"'; else echo ""; ?> /> <label for="authors">Authors</label><br /> 
     165    <input type="checkbox" name="contributors" id="contributors" <?php if($_POST['contributors']) echo 'checked="checked"'; else echo ""; ?> /> <label for="contributors">Contributors</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     166    <input type="checkbox" name="subscribers" id="subscribers" <?php if($_POST['subscribers']) echo 'checked="checked"'; else echo ""; ?> /> <label for="subscribers">Subscribers</label><br /><br /> 
    134167    <input type="submit" name="listbuttonsubmit" style="width: 200px, height: 30px" value="&nbsp;&nbsp;&nbsp;Load the List&nbsp;&nbsp;&nbsp;" />     
    135168    <script type="text/javascript" charset="utf-8"> 
     
    176209    <?php $current_user = wp_get_current_user(); ?> 
    177210    <p><b>From:</b><br /><input type="text" id="emailfrom" name="emailfrom" size="128" value="<?php if(isset($_POST['emailfrom'])) { echo $_POST['emailfrom']; } else { echo $current_user->user_email; } ?>"/></p> 
    178     <p><b>Subject:</b><br /><input type="text" id="emailsubject" name="emailsubject" size="128" value="<?php if(isset($_POST['emailsubject'])) { echo $_POST['emailsubject']; } else { echo "WordPress Network Email"; } ?>"/></p> 
    179     <p><b>Message:</b><br /><textarea cols="125" rows="15" id="emailmessage" name="emailmessage"><?php if(isset($_POST['emailmessage'])) { echo stripslashes(htmlentities($_POST['emailmessage'], ENT_NOQUOTES, 'UTF-8')); } else { echo "Enter message text"; } ?></textarea></p> 
     211    <p><b>Load a Template:&nbsp;&nbsp;</b> 
     212    <select name="selecttemplate"> 
     213    <?php nmef_loadalltemplates() ?> 
     214    <?php //read from wordpress table to get templates stored in database -- foreach( ?> 
     215    </select>&nbsp;&nbsp;<input type="submit" value="Load Template" name="loadtemplate" id="loadtemplate"> &nbsp;&nbsp;<INPUT Type="BUTTON" VALUE="Add/Edit Templates" ONCLICK="window.location.href='<?php echo network_admin_url( 'admin.php?page=nme_templatespage' ); ?>'"> 
     216    </p> 
     217    <?php if (isset($_POST['loadtemplate'])) { ?> 
     218    <p><b>Subject:</b><br /><input type="text" id="emailsubject" name="emailsubject" size="128" value="<?php echo $subject; ?>"/></p> 
     219    <p><b>Message:</b><br /><textarea cols="125" rows="15" id="emailmessage" name="emailmessage"><?php echo $message; ?></textarea></p>  
     220    <?php } 
     221    else { ?> 
     222    <p><b>Subject:</b><br /><input type="text" id="emailsubject" name="emailsubject" size="128" value="<?php if(isset($_POST['emailsubject'])) { echo stripslashes(html_entity_decode($_POST['emailsubject'], ENT_NOQUOTES, 'UTF-8')); } else { echo "WordPress Network Email"; } ?>"/></p> 
     223    <p><b>Message:</b><br /><textarea cols="125" rows="15" id="emailmessage" name="emailmessage"><?php if(isset($_POST['emailmessage'])) { echo stripslashes(html_entity_decode($_POST['emailmessage'], ENT_NOQUOTES, 'UTF-8')); } else { echo "Enter message text"; } ?></textarea></p>     
     224    <?php 
     225    } ?> 
    180226    <p><input type="submit" name="submitsendemail" style="width: 199px, height: 31px" text="Send Email" value="Send This Email" onClick="return selectAllEmails();" /> (This may take some time, please do not click twice!)</p> 
    181227    <?php 
    182     if(isset($_POST['listbuttonsubmit']) || isset($_POST['submitsendemail'])) { 
     228    if( isset($_POST['listbuttonsubmit']) || isset($_POST['submitsendemail']) || isset($_POST['listsubmitted']) ) { 
     229        ?> <input type="hidden" id="listsubmitted" name="listsubmitted" value="listsubmitted"><?php 
    183230        if($nmenoroleserror == false) { 
    184231            global $wpdb; 
     
    245292        } 
    246293    } 
    247     if ( ($nmenoroleserror == true) || ( (isset($_POST['listbuttonsubmit']) == false) && (isset($_POST['submitsendemail']) ==false) ) ) {  
    248         echo "<h2>Recipients</h2>";  
    249         echo "Select your user role types from Audience above to build a recipient list.";  
     294    if ( ($nmenoroleserror == true) || ((isset($_POST['listbuttonsubmit']) == false) && ( isset($_POST['submitsendemail']) ==false)) ) {  
     295        if (!isset($_POST['listsubmitted'])) { 
     296            echo "<h2>Recipients</h2>";  
     297            echo "Select your user role types from Audience above to build a recipient list.";  
     298        } 
    250299    } 
    251300    ?> 
     
    261310    foreach ($blogusers as $user) { 
    262311        if($user->user_email != "") { 
    263             ?><li><?php echo $user->user_email; ?><input type="hidden" name="emaillist[]" value ="<?php echo $user->user_email ?>"></li><?php 
    264         } 
     312            ?><li><input type="checkbox" name="emaillist[]" id="<?php echo $user->user_email; ?>" value="<?php echo $user->user_email ?>" <?php if( isset($_POST['emaillist']) ) { if(in_array($user->user_email, $_POST['emaillist'])) { echo 'checked'; } } else { echo 'checked'; }?>>&nbsp;&nbsp;<label for="<?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></li><?php        
     313        } 
     314    } 
     315    return; 
     316} 
     317 
     318// stuff for message templates in wpdb 
     319 
     320// create the table of stored message templates for the nme plugin for the first time 
     321function nme_install() { 
     322    global $wpdb;    
     323    $table_name = $wpdb->prefix . "networkmassemail";    
     324    if ($wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'") != $table_name) {        
     325        $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, name text NOT NULL, subject text NOT NULL, message text NOT NULL, UNIQUE KEY id (id) );"; 
     326        require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
     327        dbDelta($sql); 
     328         
     329        add_option("nme_db_version", "1.5"); 
     330         
     331        $firsttemplatename = "Example"; 
     332        $firsttemplatesubject = "Example Subject"; 
     333        $firsttemplatemessage = "This is an example message.\nYou can store message templates that you would like quick access to by typing up a message and clicking \'Save Template\'."; 
     334        $rows_affected = $wpdb->insert( $table_name, array( 'name' => $firsttemplatename, 'subject' => $firsttemplatesubject, 'message' => $firsttemplatemessage ) );    
     335    } 
     336    if ($wpdb->get_var( "SELECT name FROM " . $table_name . " WHERE name='Example'") != "Example" ) {        
     337        $firsttemplatename = "Example"; 
     338        $firsttemplatesubject = "Example Subject"; 
     339        $firsttemplatemessage = "This is an example message. 
     340         
     341        You can store message templates that you would like quick access to by typing up a message and clicking 'Save Template'."; 
     342        $rows_affected = $wpdb->insert( $table_name, array( 'name' => $firsttemplatename, 'subject' => $firsttemplatesubject, 'message' => $firsttemplatemessage ) );    
    265343    } 
    266344} 
  • network-mass-email/trunk/readme.txt

    r654950 r657422  
    22Contributors: kzaron 
    33Tags: multisite, network, email 
    4 Requires at least: 3.4 
    5 Tested up to: 3.4.1 
    6 Stable tag: 1.4.2 
     4Requires at least: 3.3 
     5Tested up to: 3.5 
     6Stable tag: 1.5 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    5858== Changelog == 
    5959 
     60= 1.5 = 
     61* Big Update - Lots of stuff! 
     62* Added message templates! You can now save message templates to re-use at a later date! 
     63* Added checkboxes to all users when they are loaded with 'load the list'. This means you can now manually uncheck users that you would like not to receive an email you are sending and vice-versa. 
     64* Moved the menu for the plguin to the main Network Admin menu. It now has it's own icon and submenus instead of being listed under 'Users'. 
     65* Updated the plugin compatibility for 'compatible up to' and 'requires'. 
     66* Added checkbox labels to all checkboxes that appear. I don't know why they weren't there in the first place... 
     67* Added more tweaks to variable formatting so that messages are stored and are sent as intended when you compose them. 
     68 
    6069= 1.4.2 = 
    6170* Applied a fix (again) for escaping slashes and special characters in email body contents. 
    6271 
    6372= 1.4.1 = 
    64 * Applied a fix for escaping slashes in email body contents. UPDATE: This didn't work =( 
     73* Applied a fix for escaping slashes in email body contents. UPDATE: This fix did not work, was patched in 1.4.2. 
    6574 
    6675= 1.4 = 
Note: See TracChangeset for help on using the changeset viewer.