Changeset 657422
- Timestamp:
- 01/23/2013 03:08:54 PM (13 years ago)
- Location:
- network-mass-email
- Files:
-
- 8 added
- 3 edited
-
assets/banner-772x250.png (modified) (previous)
-
tags/1.5 (added)
-
tags/1.5/icon.png (added)
-
tags/1.5/network-mass-email.php (added)
-
tags/1.5/readme.txt (added)
-
tags/1.5/screenshot-1.png (added)
-
tags/1.5/templates.php (added)
-
trunk/icon.png (added)
-
trunk/network-mass-email.php (modified) (12 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates.php (added)
Legend:
- Unmodified
- Added
- Removed
-
network-mass-email/trunk/network-mass-email.php
r654991 r657422 4 4 Plugin URI: http://wordpress.org/extend/plugins/network-mass-email/ 5 5 Description: Allows network admins to send a manually created notification email to all registered users based on user role. 6 Version: 1. 4.26 Version: 1.5 7 7 Author: Kenny Zaron 8 8 Author URI: http://www.kennyzaron.com/ … … 25 25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 26 */ 27 28 // Mail Icon(s) courtesy of: http://www.iconhot.com/icon/android-style-icons-r1/mail-64.html 27 29 28 30 //error variables … … 32 34 $nmenoemailserror = false; 33 35 $nmenoroleserror = false; 36 $nmeloadtemplateserr = false; 37 $message = ""; 38 $subject = ""; 34 39 35 40 // Determines on pageload whether to load the compose email function or the send email function … … 38 43 // Run some checks on the submitted form; if everything is OK, send our message 39 44 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); } 41 68 } 42 69 … … 54 81 if( ($_POST['emaillist'] == "") && (isset($_POST['submitsendemail'])) ) { $nmenoemailserror = true; } 55 82 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); } 57 84 } 58 85 } … … 60 87 //page header function 61 88 function nme_pageheader() { 62 screen_icon( );89 screen_icon('users'); 63 90 ?><h2>Network Mass Email</h2><?php 64 91 } … … 66 93 //sends the messages to the users selected after form is submitted 67 94 function nme_sendmail() { 68 $subject = $_POST['emailsubject'];95 $subject = stripslashes(html_entity_decode($_POST['emailsubject'], ENT_NOQUOTES, 'UTF-8')); 69 96 $body = stripslashes(html_entity_decode($_POST['emailmessage'], ENT_NOQUOTES, 'UTF-8')); 70 97 $from = $_POST['emailfrom']; … … 104 131 // Adds the submenu page under users in network admin 105 132 function 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 138 define( 'NETWORKMASSEMAIL_PATH', plugin_dir_path(__FILE__) ); 139 require NETWORKMASSEMAIL_PATH .'/templates.php'; 108 140 109 141 // Displays error messages … … 113 145 114 146 // Creates the part of the page where users compose their email 115 function nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror ) {147 function nme_menu_page($nmewassuberror, $nmewasmsgerror, $nmewasfromerror, $nmenoemailserror, $nmenoroleserror, $nmeloadtemplateserr, $subject, $message) { 116 148 nme_pageheader(); 149 nme_install(); 117 150 if($nmewasfromerror == true) { $nmeerrmessage = "ERROR: Your from email address cannot be blank."; nme_error_msg($nmeerrmessage); } 118 151 if($nmewassuberror == true) { $nmeerrmessage = "ERROR: Your subject cannot be blank."; nme_error_msg($nmeerrmessage); } 119 152 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); } 120 154 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); } 121 155 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 />"; } ?> 124 157 <h2>Audience</h2> 125 158 <p>Select the user levels you wish to send this message to:</p> 126 159 <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 130 <input type="checkbox" name="editors" id="editors" <?php if($_POST['editors']) echo 'checked="checked"'; else echo ""; ?> /> Editors 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 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> 163 <input type="checkbox" name="editors" id="editors" <?php if($_POST['editors']) echo 'checked="checked"'; else echo ""; ?> /> <label for="editors">Editors</label> 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> 166 <input type="checkbox" name="subscribers" id="subscribers" <?php if($_POST['subscribers']) echo 'checked="checked"'; else echo ""; ?> /> <label for="subscribers">Subscribers</label><br /><br /> 134 167 <input type="submit" name="listbuttonsubmit" style="width: 200px, height: 30px" value=" Load the List " /> 135 168 <script type="text/javascript" charset="utf-8"> … … 176 209 <?php $current_user = wp_get_current_user(); ?> 177 210 <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: </b> 212 <select name="selecttemplate"> 213 <?php nmef_loadalltemplates() ?> 214 <?php //read from wordpress table to get templates stored in database -- foreach( ?> 215 </select> <input type="submit" value="Load Template" name="loadtemplate" id="loadtemplate"> <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 } ?> 180 226 <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> 181 227 <?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 183 230 if($nmenoroleserror == false) { 184 231 global $wpdb; … … 245 292 } 246 293 } 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 } 250 299 } 251 300 ?> … … 261 310 foreach ($blogusers as $user) { 262 311 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'; }?>> <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 321 function 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 ) ); 265 343 } 266 344 } -
network-mass-email/trunk/readme.txt
r654950 r657422 2 2 Contributors: kzaron 3 3 Tags: multisite, network, email 4 Requires at least: 3. 45 Tested up to: 3. 4.16 Stable tag: 1. 4.24 Requires at least: 3.3 5 Tested up to: 3.5 6 Stable tag: 1.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 58 58 == Changelog == 59 59 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 60 69 = 1.4.2 = 61 70 * Applied a fix (again) for escaping slashes and special characters in email body contents. 62 71 63 72 = 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. 65 74 66 75 = 1.4 =
Note: See TracChangeset
for help on using the changeset viewer.