<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2325] 2013/codebykat/post-by-email/trunk: allow user to configure what to do when sender doesn't match any users (discard or pending)</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://gsoc.trac.wordpress.org/changeset/2325">2325</a></dd>
<dt>Author</dt> <dd>codebykat</dd>
<dt>Date</dt> <dd>2013-09-16 02:12:48 +0000 (Mon, 16 Sep 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>allow user to configure what to do when sender doesn't match any users (discard or pending)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#2013codebykatpostbyemailtrunkclasspostbyemailadminphp">2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php</a></li>
<li><a href="#2013codebykatpostbyemailtrunkclasspostbyemailphp">2013/codebykat/post-by-email/trunk/class-post-by-email.php</a></li>
<li><a href="#2013codebykatpostbyemailtrunkpostbyemailphp">2013/codebykat/post-by-email/trunk/post-by-email.php</a></li>
<li><a href="#2013codebykatpostbyemailtrunkreadmemd">2013/codebykat/post-by-email/trunk/readme.md</a></li>
<li><a href="#2013codebykatpostbyemailtrunkreadmetxt">2013/codebykat/post-by-email/trunk/readme.txt</a></li>
<li><a href="#2013codebykatpostbyemailtrunkviewsadminphp">2013/codebykat/post-by-email/trunk/views/admin.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013codebykatpostbyemailtrunkclasspostbyemailadminphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php (2324 => 2325)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php 2013-09-16 02:12:41 UTC (rev 2324)
+++ 2013/codebykat/post-by-email/trunk/class-post-by-email-admin.php    2013-09-16 02:12:48 UTC (rev 2325)
</span><span class="lines">@@ -111,6 +111,10 @@
</span><span class="cx">          $options['pin_required'] = isset( $input['pin_required'] ) && '' != $input['pin_required'];
</span><span class="cx">          $options['pin'] = trim( $input['pin'] );
</span><span class="cx"> 
</span><ins>+               if ( isset( $input['discard_pending'] ) ) {
+                       $options['discard_pending'] = ( 'discard' == $input['discard_pending'] );
+               }
+
</ins><span class="cx">           // this is ridiculous
</span><span class="cx">          if ( isset ( $input['status'] ) && in_array( $input['status'], array( 'unconfigured', 'error', '') ) ) {
</span><span class="cx">                  // maintain saved state
</span><span class="lines">@@ -133,6 +137,13 @@
</span><span class="cx">                  $options['status'] = '';
</span><span class="cx">          }
</span><span class="cx"> 
</span><ins>+               // make sure all default options are set
+               foreach ( $default_options as $key => $value ) {
+                       if ( ! isset( $options[ $key ] ) ) {
+                               $options[ $key ] = $value;
+                       }
+               }
+
</ins><span class="cx">           return $options;
</span><span class="cx">  }
</span><span class="cx"> 
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkclasspostbyemailphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/class-post-by-email.php (2324 => 2325)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/class-post-by-email.php       2013-09-16 02:12:41 UTC (rev 2324)
+++ 2013/codebykat/post-by-email/trunk/class-post-by-email.php  2013-09-16 02:12:48 UTC (rev 2325)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @var     string
</span><span class="cx">   */
</span><del>-       protected $version = '1.0.2';
</del><ins>+        protected $version = '1.0.3';
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Unique identifier for the plugin.
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx">          'status'                    => 'unconfigured',
</span><span class="cx">          'pin_required'              => false,
</span><span class="cx">          'pin'                       => '',
</span><ins>+               'discard_pending'           => false,
</ins><span class="cx">   );
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="lines">@@ -289,6 +290,11 @@
</span><span class="cx">                          $user = new WP_User( $post_author );
</span><span class="cx">                          $post_status = ( $user->has_cap( 'publish_posts' ) ) ? 'publish' : 'pending';
</span><span class="cx">                  } else {
</span><ins>+                               if ( $options['discard_pending'] ) {
+                                       $log_message .= '<br />' . sprintf( __( "No author match for %s (Subject: %s); skipping.", 'post-by-email' ),
+                                                                                                                       $from_email, $subject );
+                                       continue;
+                               }
</ins><span class="cx">                           // use admin if no author found
</span><span class="cx">                          $post_author = $this->get_admin_id();
</span><span class="cx">                          $post_status = 'pending';
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkpostbyemailphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/post-by-email.php (2324 => 2325)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/post-by-email.php     2013-09-16 02:12:41 UTC (rev 2324)
+++ 2013/codebykat/post-by-email/trunk/post-by-email.php        2013-09-16 02:12:48 UTC (rev 2325)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx">  * Plugin Name: Post By Email
</span><span class="cx">  * Plugin URI:  http://codebykat.wordpress.com
</span><span class="cx">  * Description: Create new posts on your WordPress blog by sending email to a specific email address.
</span><del>- * Version:     1.0.2
</del><ins>+ * Version:     1.0.3
</ins><span class="cx">  * Author:      Kat Hagan
</span><span class="cx">  * Author URI:  http://profiles.wordpress.org/codebykat
</span><span class="cx">  * Text Domain: post-by-email
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkreadmemd"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/readme.md (2324 => 2325)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/readme.md     2013-09-16 02:12:41 UTC (rev 2324)
+++ 2013/codebykat/post-by-email/trunk/readme.md        2013-09-16 02:12:48 UTC (rev 2325)
</span><span class="lines">@@ -18,16 +18,17 @@
</span><span class="cx"> 
</span><span class="cx"> Once an email has been successfully posted to the blog, it will either be marked as read (IMAP servers only) or deleted from the mailbox.
</span><span class="cx"> 
</span><del>-You can set categories and tags on your posts by including shortcodes in your email.  These should be space-separated.  Use slugs for tags and either slugs or IDs for categories.  Terms that do not yet exist will be created.  Examples:
</del><ins>+You can set categories, tags and custom taxonomy terms on your posts by including shortcodes in your email.  These should be space-separated.  Use slugs for tags (and non-hierarchical taxonomies) and either slugs or IDs for categories (/ hierarchical taxonomies).  Terms that do not yet exist will be created.  Examples:
</ins><span class="cx"> `[category posted-by-email another-category]`
</span><span class="cx"> `[tag cool-stuff]`
</span><span class="cx"> `[category 14]`
</span><ins>+`[custom-taxonomy-name thing1 thing2]`
+`[another-custom-taxonomy 2 3 5]`
</ins><span class="cx"> 
</span><span class="cx"> Updates on the project can be found on the [Make WordPress Core blog](http://make.wordpress.org/core/tag/post-by-email/).
</span><span class="cx"> 
</span><span class="cx"> ## Installation ##
</span><span class="cx"> 
</span><del>-1. Apply the patch found in the plugin directory to WordPress Core.  See [Applying .patch or .diff files](https://codex.wordpress.org/Using_Subversion#Applying_.patch_or_.diff_files).
</del><span class="cx"> 1. See [Installing Plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
</span><span class="cx"> 1. Activate the plugin through the 'Plugins' menu.
</span><span class="cx"> 1. Configure mailbox information under plugin settings.
</span><span class="lines">@@ -44,6 +45,14 @@
</span><span class="cx"> 
</span><span class="cx"> ## Changelog ##
</span><span class="cx"> 
</span><ins>+### 1.0.3 ###
+* Added option to choose what to do when message senders don't match WP users (discard or set to pending).
+* Added shortcode support for custom taxonomy terms.
+* Added support for attachments.
+* Fixed some bugs in PHP 5.2.
+* Fixed bugs with the admin notices and default options.
+* Switched manual check to a trigger for do_action and disabled wp-mail.php entirely.
+
</ins><span class="cx"> ### 1.0.2 ###
</span><span class="cx"> * Support shortcodes to specify categories and tags.
</span><span class="cx"> * Added PIN-based authentication.
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkreadmetxt"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/readme.txt (2324 => 2325)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/readme.txt    2013-09-16 02:12:41 UTC (rev 2324)
+++ 2013/codebykat/post-by-email/trunk/readme.txt       2013-09-16 02:12:48 UTC (rev 2325)
</span><span class="lines">@@ -18,16 +18,17 @@
</span><span class="cx"> 
</span><span class="cx"> Once an email has been successfully posted to the blog, it will either be marked as read (IMAP servers only) or deleted from the mailbox.
</span><span class="cx"> 
</span><del>-You can set categories and tags on your posts by including shortcodes in your email.  These should be space-separated.  Use slugs for tags and either slugs or IDs for categories.  Terms that do not yet exist will be created.  Examples:
</del><ins>+You can set categories, tags and custom taxonomy terms on your posts by including shortcodes in your email.  These should be space-separated.  Use slugs for tags (and non-hierarchical taxonomies) and either slugs or IDs for categories (/ hierarchical taxonomies).  Terms that do not yet exist will be created.  Examples:
</ins><span class="cx"> `[category posted-by-email another-category]`
</span><span class="cx"> `[tag cool-stuff]`
</span><span class="cx"> `[category 14]`
</span><ins>+`[custom-taxonomy-name thing1 thing2]`
+`[another-custom-taxonomy 2 3 5]`
</ins><span class="cx"> 
</span><span class="cx"> Updates on the project can be found on the [Make WordPress Core blog](http://make.wordpress.org/core/tag/post-by-email/).
</span><span class="cx"> 
</span><span class="cx"> == Installation ==
</span><span class="cx"> 
</span><del>-1. Apply the patch found in the plugin directory to WordPress Core.  See [Applying .patch or .diff files](https://codex.wordpress.org/Using_Subversion#Applying_.patch_or_.diff_files).
</del><span class="cx"> 1. See [Installing Plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
</span><span class="cx"> 1. Activate the plugin through the 'Plugins' menu.
</span><span class="cx"> 1. Configure mailbox information under plugin settings.
</span><span class="lines">@@ -44,6 +45,14 @@
</span><span class="cx"> 
</span><span class="cx"> == Changelog ==
</span><span class="cx"> 
</span><ins>+= 1.0.3 =
+* Added option to choose what to do when message senders don't match WP users (discard or set to pending).
+* Added shortcode support for custom taxonomy terms.
+* Added support for attachments.
+* Fixed some bugs in PHP 5.2.
+* Fixed bugs with the admin notices and default options.
+* Switched manual check to a trigger for do_action and disabled wp-mail.php entirely.
+
</ins><span class="cx"> = 1.0.2 =
</span><span class="cx"> * Support shortcodes to specify categories and tags.
</span><span class="cx"> * Added PIN-based authentication.
</span></span></pre></div>
<a id="2013codebykatpostbyemailtrunkviewsadminphp"></a>
<div class="modfile"><h4>Modified: 2013/codebykat/post-by-email/trunk/views/admin.php (2324 => 2325)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/codebykat/post-by-email/trunk/views/admin.php       2013-09-16 02:12:41 UTC (rev 2324)
+++ 2013/codebykat/post-by-email/trunk/views/admin.php  2013-09-16 02:12:48 UTC (rev 2325)
</span><span class="lines">@@ -198,7 +198,7 @@
</span><span class="cx">                                          <input type="checkbox" name="post_by_email_options[pin_required]" id="post_by_email_options[pin_required]" <?php checked( $options['pin_required'] ); ?> />
</span><span class="cx">                                  </td>
</span><span class="cx">                          </tr>
</span><del>-                               <tr class="post-by-email-pin-settings" <?php if ( ! $options['pin_required'] ) { echo 'style="display:none;";'; } ?>>
</del><ins>+                                <tr valign="top" class="post-by-email-pin-settings" <?php if ( ! $options['pin_required'] ) { echo 'style="display:none;";'; } ?>>
</ins><span class="cx">                                   <th scope="row">
</span><span class="cx">                                          <label for="post_by_email_options[pin]">
</span><span class="cx">                                                  <?php _e( 'PIN', 'post-by-email' ); ?>
</span><span class="lines">@@ -209,6 +209,25 @@
</span><span class="cx">                                          <input type="button" class="button-secondary" href='' id="generatePIN" value="<?php _e( 'Generate' ); ?>" />
</span><span class="cx">                                  </td>
</span><span class="cx">                          </tr>
</span><ins>+                               <tr valign="top">
+                                       <th scope="row">
+                                               <label for="post_by_email_options[discard_pending]">
+                                                       <?php _e( 'What should be done with posts from unrecognized emails?', 'post-by-email' ); ?>
+                                               </label>
+                                       </th>
+                                       <td>
+                                               <select name="post_by_email_options[discard_pending]">
+                                                       <option value="pending" <?php selected( $options['discard_pending'], false ); ?>><?php _e( 'Save as drafts' ); ?></option>
+                                                       <option value="discard" <?php selected( $options['discard_pending'] ); ?>><?php _e( 'Discard them' ); ?></option>
+                                               </select>
+                                               <p class="description">
+                                                       <?php _e( "Any messages received from email addresses registered to WordPress users will be posted
+                                                               (set to pending if they don't have the publish posts capability).  For emails that don't match
+                                                               a user in the system, you can choose to skip the message or post it as a pending draft.",
+                                                               'post-by-email' ); ?>
+                                               </p>
+                                       </td>
+                               </tr>
</ins><span class="cx">                   </table>
</span><span class="cx"> 
</span><span class="cx">                  <?php submit_button(); ?>
</span></span></pre>
</div>
</div>

</body>
</html>