Postie - Version 1.4.33

Version Description

(2013.02.05) = * Fixed bug where non-category taxonomy was being selected as the post category. * Added option to force categories to match exactly. * Added logic to skip text attachments named "ATT00001.txt" where the numbers can be any sequence. This improves the previous fix by detecting all attachments added, not just the first one.

Download this release

Release Info

Developer WayneAllen
Plugin Icon 128x128 Postie
Version 1.4.33
Comparing to
See all releases

Code changes from version 1.4.32 to 1.4.33

Revision CHANGED
@@ -1,2 +0,0 @@
1
- Revision: 660784
2
- Last Changed Date: 2013-01-27 22:37:48 -0800 (Sun, 27 Jan 2013)
 
 
config_form.php CHANGED
@@ -64,6 +64,9 @@
64
  DebugEcho("New setting: maxemails");
65
  $maxemails = 0;
66
  }
 
 
 
67
 
68
  if ($interval == 'manual') {
69
  wp_clear_scheduled_hook('check_postie_hook');
@@ -229,7 +232,7 @@
229
  <div id="simpleTabs-content-2" class="simpleTabs-content">
230
  <table class='form-table'>
231
 
232
- <?php echo BuildBooleanSelect(__("Allow Anyone To Post Via Email"), "postie-settings[turn_authorization_off]", $turn_authorization_off, "Changing this to yes is NOT RECOMMEDED - anything that gets sent in will automatically be posted. This could make it easier to compromise your server - YOU HAVE BEEN WARNED."); ?>
233
  <tr>
234
  <th scope="row">
235
  <?php _e('Roles That Can Post:', 'postie') ?><br />
@@ -307,14 +310,16 @@
307
  <div id = "simpleTabs-content-3" class = "simpleTabs-content">
308
  <table class = 'form-table'>
309
  <tr valign = "top">
310
- <th scope = "row"><?php _e('Default post by mail category:', 'postie')
311
- ?></th>
312
  <td>
313
  <?php
314
  $defaultCat = $default_post_category;
315
- wp_dropdown_categories("name=postie-settings[default_post_category]&hierarchical=1&selected=$defaultCat&hide_empty=0");
 
316
  ?>
317
  </tr>
 
 
318
  <tr valign="top">
319
  <th scope="row">
320
  <?php _e('Default post by mail tag(s)', 'postie') ?><br />
64
  DebugEcho("New setting: maxemails");
65
  $maxemails = 0;
66
  }
67
+ if (!isset($category_match)) {
68
+ $category_match = true;
69
+ }
70
 
71
  if ($interval == 'manual') {
72
  wp_clear_scheduled_hook('check_postie_hook');
232
  <div id="simpleTabs-content-2" class="simpleTabs-content">
233
  <table class='form-table'>
234
 
235
+ <?php echo BuildBooleanSelect(__("Allow Anyone To Post Via Email"), "postie-settings[turn_authorization_off]", $turn_authorization_off, "Changing this to yes is NOT RECOMMENEDED - anything that gets sent in will automatically be posted. This could make it easier to compromise your server - YOU HAVE BEEN WARNED."); ?>
236
  <tr>
237
  <th scope="row">
238
  <?php _e('Roles That Can Post:', 'postie') ?><br />
310
  <div id = "simpleTabs-content-3" class = "simpleTabs-content">
311
  <table class = 'form-table'>
312
  <tr valign = "top">
313
+ <th scope = "row"><?php _e('Default post by mail category:', 'postie') ?></th>
 
314
  <td>
315
  <?php
316
  $defaultCat = $default_post_category;
317
+ $args = array('name' => 'postie-settings[default_post_category]', 'hierarchical' => 1, 'selected' => $defaultCat, 'hide_empty' => 0);
318
+ wp_dropdown_categories($args);
319
  ?>
320
  </tr>
321
+ <?php echo BuildBooleanSelect("Match short category", "postie-settings[category_match]", $category_match,"Try to match categories using 'starts with logic' otherwise only do exact matches"); ?>
322
+
323
  <tr valign="top">
324
  <th scope="row">
325
  <?php _e('Default post by mail tag(s)', 'postie') ?><br />
docs/Changes.txt CHANGED
@@ -10,6 +10,12 @@ All script, style and body tags are stripped from html emails.
10
  Attachments are now processed in the order they were attached.
11
 
12
  == CHANGELOG ==
 
 
 
 
 
 
13
  = 1.4.32 (2013.01.29) =
14
  * Fixed bug in detecting need for imap extension.
15
  * Added additional selections for "Maximum number of emails to process"
10
  Attachments are now processed in the order they were attached.
11
 
12
  == CHANGELOG ==
13
+ = 1.4.33 (2013.02.05) =
14
+ * Fixed bug where non-category taxonomy was being selected as the post category.
15
+ * Added option to force categories to match exactly.
16
+ * Added logic to skip text attachments named "ATT00001.txt" where the numbers can be any sequence. This
17
+ improves the previous fix by detecting all attachments added, not just the first one.
18
+
19
  = 1.4.32 (2013.01.29) =
20
  * Fixed bug in detecting need for imap extension.
21
  * Added additional selections for "Maximum number of emails to process"
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
- Stable tag: 1.4.32
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
+ Stable tag: 1.4.33
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
docs/TODO.txt CHANGED
@@ -3,10 +3,12 @@ reply logic not adding to comments
3
  hide/disable config options that don't apply
4
  code to set featured image. Global setting (first picture is featured). Featured tag to enable per email. Enhance #img#
5
  handle condition where only one of text/plain & text/html is supplied, but Preferred Text Type is set to the opposite.
6
-
7
  replace native imap with flourish
8
  replace MIME parser
9
  debug assistance
 
 
 
10
  standardize tags
11
  fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
12
 
@@ -20,15 +22,6 @@ fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutor
20
  * Problem with some mail server
21
  * Multiple emails should tie to a single account
22
  * Each user should be able to have a default category
23
- * WP Switcher not compatible
24
- * Setup poll
25
- - web server
26
- - mail clients
27
- - plain/html
28
- - phone/computer
29
- - os of server
30
- - os of client
31
- - number of users posting
32
  * Test for calling from the command line
33
  * Support userid/domain as a valid username
34
  * WP-switcher not compatiable http://www.alexking.org/index.php?content=software/wordpress/content.php#wp_120
@@ -36,7 +29,6 @@ fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutor
36
  * Add support for http://unknowngenius.com/wp-plugins/faq.html#one-click
37
  * www.cdavies.org/code/3gp-thumb.php.txt
38
  * www.cdavies.org/permalink/watchingbrowserembeddedgpvideosinlinux.php
39
- * Support private posts
40
  * Make it possible to post without a script at all
41
  * TODO - fix corruption of rtf attachments
42
  * TODO - add port checking in tests
3
  hide/disable config options that don't apply
4
  code to set featured image. Global setting (first picture is featured). Featured tag to enable per email. Enhance #img#
5
  handle condition where only one of text/plain & text/html is supplied, but Preferred Text Type is set to the opposite.
 
6
  replace native imap with flourish
7
  replace MIME parser
8
  debug assistance
9
+ setting for default post type
10
+ automatically create category if it doesn't exist. new option to allow this feature?
11
+
12
  standardize tags
13
  fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
14
 
22
  * Problem with some mail server
23
  * Multiple emails should tie to a single account
24
  * Each user should be able to have a default category
 
 
 
 
 
 
 
 
 
25
  * Test for calling from the command line
26
  * Support userid/domain as a valid username
27
  * WP-switcher not compatiable http://www.alexking.org/index.php?content=software/wordpress/content.php#wp_120
29
  * Add support for http://unknowngenius.com/wp-plugins/faq.html#one-click
30
  * www.cdavies.org/code/3gp-thumb.php.txt
31
  * www.cdavies.org/permalink/watchingbrowserembeddedgpvideosinlinux.php
 
32
  * Make it possible to post without a script at all
33
  * TODO - fix corruption of rtf attachments
34
  * TODO - add port checking in tests
docs/Usage.txt CHANGED
@@ -46,7 +46,8 @@
46
 
47
  Gen: New News
48
 
49
- The system will post that in General.
 
50
 
51
  * All of the above also applies if you put the category in brackets []
52
  * Using [] or you can post to multiple categories at once
46
 
47
  Gen: New News
48
 
49
+ The system will post that in General. Note you must turn on the "Match short category"
50
+ setting for this to work.
51
 
52
  * All of the above also applies if you put the category in brackets []
53
  * Using [] or you can post to multiple categories at once
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 660792 2013-01-29 18:44:14Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
@@ -177,7 +177,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
177
  }
178
  $message_date = tag_Date($content, $message_date);
179
 
180
- list($post_date, $post_date_gmt, $delay) = DeterminePostDate($content, $message_date, $time_offset);
181
  if ($fulldebug)
182
  DebugEcho("post date: $content");
183
 
@@ -185,7 +185,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
185
  if ($fulldebug)
186
  DebugEcho("post ubb: $content");
187
 
188
- $post_categories = tag_categories($subject, $default_post_category);
189
  if ($fulldebug)
190
  DebugEcho("post category: $content");
191
 
@@ -854,7 +854,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
854
  //DebugDump($part);
855
 
856
  $charset = "";
857
- if (array_key_exists('charset', $part->ctype_parameters) && !empty($part->ctype_parameters['charset'])) {
858
  $charset = $part->ctype_parameters['charset'];
859
  DebugEcho("charset: $charset");
860
  }
@@ -875,7 +875,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
875
  }
876
  if (array_key_exists('disposition', $part) && $part->disposition == 'attachment') {
877
  DebugEcho("text Attachement: $filename");
878
- if (strtolower($filename) != strtolower('ATT00001.txt')) {
879
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
880
  if (!is_wp_error($file_id)) {
881
  $file = wp_get_attachment_url($file_id);
@@ -1425,10 +1425,11 @@ function tag_AllowCommentsOnPost(&$content) {
1425
  *
1426
  * todo split delay tag from date logic
1427
  */
1428
- function DeterminePostDate(&$content, $message_date = NULL, $offset = 0) {
1429
  $delay = 0;
1430
 
1431
  if (preg_match("/delay:(-?[0-9dhm]+)/i", $content, $matches) && trim($matches[1])) {
 
1432
  $days = 0;
1433
  $hours = 0;
1434
  $minutes = 0;
@@ -1442,6 +1443,7 @@ function DeterminePostDate(&$content, $message_date = NULL, $offset = 0) {
1442
  $minutes = $minuteMatches[1];
1443
  }
1444
  $delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
 
1445
  $content = preg_replace("/delay:$matches[1]/i", "", $content);
1446
  }
1447
  if (empty($message_date)) {
@@ -1453,13 +1455,8 @@ function DeterminePostDate(&$content, $message_date = NULL, $offset = 0) {
1453
 
1454
  $post_date = gmdate('Y-m-d H:i:s', $dateInSeconds + ($offset * 3600));
1455
  $post_date_gmt = gmdate('Y-m-d H:i:s', $dateInSeconds);
 
1456
 
1457
- /*
1458
- echo "--------------------DELAY------------\n";
1459
- echo "delay=$delay, dateInSeconds = $dateInSeconds\n";
1460
- echo "post_date=$post_date\n";
1461
- echo "--------------------DELAY------------\n";
1462
- */
1463
  return array($post_date, $post_date_gmt, $delay);
1464
  }
1465
 
@@ -2240,13 +2237,11 @@ function tag_Excerpt(&$content, $filterNewLines, $convertNewLines) {
2240
  * This function determines the categories ids for the post
2241
  * @return array
2242
  */
2243
- function tag_categories(&$subject, $defaultCategory) {
2244
- global $wpdb;
2245
  $original_subject = $subject;
2246
  $post_categories = array();
2247
  $matchtypes = array();
2248
  $matches = array();
2249
- //try and determine category
2250
 
2251
  if (preg_match_all('/\[(.[^\[]*)\]/', $subject, $matches)) { // [<category1>] [<category2>] <Subject>
2252
  preg_match("/]([^\[]*)$/", $subject, $subject_matches);
@@ -2260,8 +2255,9 @@ function tag_categories(&$subject, $defaultCategory) {
2260
  $matchtypes[] = $matches;
2261
  }
2262
  if (preg_match('/(.+): (.*)/', $subject, $matches)) { // <category>:<Subject>
2263
- $category = lookup_category($matches[1]);
2264
  if (!empty($category)) {
 
2265
  $subject = trim($matches[2]);
2266
  $post_categories[] = $category;
2267
  }
@@ -2270,7 +2266,7 @@ function tag_categories(&$subject, $defaultCategory) {
2270
  foreach ($matchtypes as $matches) {
2271
  if (count($matches)) {
2272
  foreach ($matches[1] as $match) {
2273
- $category = lookup_category($match);
2274
  if (!empty($category)) {
2275
  $post_categories[] = $category;
2276
  }
@@ -2284,23 +2280,29 @@ function tag_categories(&$subject, $defaultCategory) {
2284
  return $post_categories;
2285
  }
2286
 
2287
- function lookup_category($trial_category) {
2288
  global $wpdb;
2289
  $trial_category = trim($trial_category);
2290
  $found_category = NULL;
2291
- EchoInfo("Categories - Working on $trial_category");
2292
-
2293
- $sql_name = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE name=\'' . addslashes($trial_category) . '\'';
2294
- $sql_id = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE term_id=\'' . addslashes($trial_category) . '\'';
2295
- $sql_sub_name = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE name LIKE \'' . addslashes($trial_category) . '%\' limit 1';
2296
 
2297
- if ($found_category = $wpdb->get_var($sql_name)) {
 
2298
  //then category is a named and found
2299
- } elseif ($found_category = $wpdb->get_var($sql_id)) {
 
 
 
2300
  //then cateogry was an ID and found
2301
- } elseif ($found_category = $wpdb->get_var($sql_sub_name)) {
2302
- //then cateogry is a start of a name and found
2303
  }
 
 
 
 
 
 
 
2304
  return intval($found_category); //force to integer
2305
  }
2306
 
@@ -2424,6 +2426,7 @@ function config_GetDefaults() {
2424
  'converturls' => true,
2425
  'custom_image_field' => false,
2426
  'default_post_category' => NULL,
 
2427
  'default_post_tags' => array(),
2428
  'default_title' => "Live From The Field",
2429
  'delete_mail_after_processing' => true,
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 664075 2013-02-06 05:18:09Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
177
  }
178
  $message_date = tag_Date($content, $message_date);
179
 
180
+ list($post_date, $post_date_gmt, $delay) = filter_Delay($content, $message_date, $time_offset);
181
  if ($fulldebug)
182
  DebugEcho("post date: $content");
183
 
185
  if ($fulldebug)
186
  DebugEcho("post ubb: $content");
187
 
188
+ $post_categories = tag_categories($subject, $default_post_category, $category_match);
189
  if ($fulldebug)
190
  DebugEcho("post category: $content");
191
 
854
  //DebugDump($part);
855
 
856
  $charset = "";
857
+ if (property_exists($part, 'ctype_parameters') && array_key_exists('charset', $part->ctype_parameters) && !empty($part->ctype_parameters['charset'])) {
858
  $charset = $part->ctype_parameters['charset'];
859
  DebugEcho("charset: $charset");
860
  }
875
  }
876
  if (array_key_exists('disposition', $part) && $part->disposition == 'attachment') {
877
  DebugEcho("text Attachement: $filename");
878
+ if (!preg_match('/ATT\d\d\d\d\d.txt/i', $filename)) {
879
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
880
  if (!is_wp_error($file_id)) {
881
  $file = wp_get_attachment_url($file_id);
1425
  *
1426
  * todo split delay tag from date logic
1427
  */
1428
+ function filter_Delay(&$content, $message_date = NULL, $offset = 0) {
1429
  $delay = 0;
1430
 
1431
  if (preg_match("/delay:(-?[0-9dhm]+)/i", $content, $matches) && trim($matches[1])) {
1432
+ DebugEcho("found delay: " . $matches[1]);
1433
  $days = 0;
1434
  $hours = 0;
1435
  $minutes = 0;
1443
  $minutes = $minuteMatches[1];
1444
  }
1445
  $delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
1446
+ DebugEcho("calculated delay: $delay");
1447
  $content = preg_replace("/delay:$matches[1]/i", "", $content);
1448
  }
1449
  if (empty($message_date)) {
1455
 
1456
  $post_date = gmdate('Y-m-d H:i:s', $dateInSeconds + ($offset * 3600));
1457
  $post_date_gmt = gmdate('Y-m-d H:i:s', $dateInSeconds);
1458
+ DebugEcho("post date: $post_date / $post_date_gmt");
1459
 
 
 
 
 
 
 
1460
  return array($post_date, $post_date_gmt, $delay);
1461
  }
1462
 
2237
  * This function determines the categories ids for the post
2238
  * @return array
2239
  */
2240
+ function tag_categories(&$subject, $defaultCategory, $category_match) {
 
2241
  $original_subject = $subject;
2242
  $post_categories = array();
2243
  $matchtypes = array();
2244
  $matches = array();
 
2245
 
2246
  if (preg_match_all('/\[(.[^\[]*)\]/', $subject, $matches)) { // [<category1>] [<category2>] <Subject>
2247
  preg_match("/]([^\[]*)$/", $subject, $subject_matches);
2255
  $matchtypes[] = $matches;
2256
  }
2257
  if (preg_match('/(.+): (.*)/', $subject, $matches)) { // <category>:<Subject>
2258
+ $category = lookup_category($matches[1], $category_match);
2259
  if (!empty($category)) {
2260
+ DebugEcho("colon category: $category");
2261
  $subject = trim($matches[2]);
2262
  $post_categories[] = $category;
2263
  }
2266
  foreach ($matchtypes as $matches) {
2267
  if (count($matches)) {
2268
  foreach ($matches[1] as $match) {
2269
+ $category = lookup_category($match, $category_match);
2270
  if (!empty($category)) {
2271
  $post_categories[] = $category;
2272
  }
2280
  return $post_categories;
2281
  }
2282
 
2283
+ function lookup_category($trial_category, $category_match) {
2284
  global $wpdb;
2285
  $trial_category = trim($trial_category);
2286
  $found_category = NULL;
2287
+ EchoInfo("lookup_category: $trial_category");
 
 
 
 
2288
 
2289
+ $term = get_term_by('name', $trial_category, 'category');
2290
+ if ($term !== false) {
2291
  //then category is a named and found
2292
+ return $term['term_id'];
2293
+ }
2294
+ $term = get_term_by('id', $trial_category, 'category');
2295
+ if ($term !== false) {
2296
  //then cateogry was an ID and found
2297
+ return $term['term_id'];
 
2298
  }
2299
+ if (empty($found_category) && $category_match) {
2300
+ DebugEcho("category wildcard lookup: $trial_category");
2301
+ $sql_sub_name = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE name LIKE \'' . addslashes($trial_category) . '%\' limit 1';
2302
+ $found_category = $wpdb->get_var($sql_sub_name);
2303
+ DebugEcho("category wildcard found: $found_category");
2304
+ }
2305
+
2306
  return intval($found_category); //force to integer
2307
  }
2308
 
2426
  'converturls' => true,
2427
  'custom_image_field' => false,
2428
  'default_post_category' => NULL,
2429
+ 'category_match' => true,
2430
  'default_post_tags' => array(),
2431
  'default_title' => "Live From The Field",
2432
  'delete_mail_after_processing' => true,
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
- Version: 1.4.32
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
@@ -27,7 +27,7 @@
27
  */
28
 
29
  /*
30
- $Id: postie.php 660909 2013-01-29 21:22:26Z WayneAllen $
31
  */
32
 
33
  define("POSTIE_ROOT", dirname(__FILE__));
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
+ Version: 1.4.33
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 664075 2013-02-06 05:18:09Z WayneAllen $
31
  */
32
 
33
  define("POSTIE_ROOT", dirname(__FILE__));
postie_test.php CHANGED
@@ -62,7 +62,7 @@ $images = array("Test.png", "Test.jpg", "Test.gif");
62
  <p>This shows what time it would be if you posted right now</p>
63
  <?php
64
  $content = "";
65
- $data = DeterminePostDate($content);
66
  EchoInfo("GMT: $data[1]");
67
  EchoInfo("Current: $data[0]");
68
  ?>
62
  <p>This shows what time it would be if you posted right now</p>
63
  <?php
64
  $content = "";
65
+ $data = filter_Delay($content);
66
  EchoInfo("GMT: $data[1]");
67
  EchoInfo("Current: $data[0]");
68
  ?>
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
- Stable tag: 1.4.32
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -127,7 +127,8 @@ Then use the Task Scheduler control panel to call wget or cron.
127
 
128
  Gen: New News
129
 
130
- The system will post that in General.
 
131
 
132
  * All of the above also applies if you put the category in brackets []
133
  * Using [] or you can post to multiple categories at once
@@ -426,6 +427,12 @@ All script, style and body tags are stripped from html emails.
426
  Attachments are now processed in the order they were attached.
427
 
428
  == CHANGELOG ==
 
 
 
 
 
 
429
  = 1.4.32 (2013.01.29) =
430
  * Fixed bug in detecting need for imap extension.
431
  * Added additional selections for "Maximum number of emails to process"
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
+ Stable tag: 1.4.33
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
127
 
128
  Gen: New News
129
 
130
+ The system will post that in General. Note you must turn on the "Match short category"
131
+ setting for this to work.
132
 
133
  * All of the above also applies if you put the category in brackets []
134
  * Using [] or you can post to multiple categories at once
427
  Attachments are now processed in the order they were attached.
428
 
429
  == CHANGELOG ==
430
+ = 1.4.33 (2013.02.05) =
431
+ * Fixed bug where non-category taxonomy was being selected as the post category.
432
+ * Added option to force categories to match exactly.
433
+ * Added logic to skip text attachments named "ATT00001.txt" where the numbers can be any sequence. This
434
+ improves the previous fix by detecting all attachments added, not just the first one.
435
+
436
  = 1.4.32 (2013.01.29) =
437
  * Fixed bug in detecting need for imap extension.
438
  * Added additional selections for "Maximum number of emails to process"
test/inlineimageTest.php CHANGED
@@ -65,7 +65,7 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
65
  $config = config_GetDefaults();
66
 
67
  $post = $this->process_file("data/japanese-attachment.var", $config);
68
- $this->assertEquals('=?ISO-2022-JP?B?UG9zdGllGyRCTVElRiU5JUglYSE8JWsbKEo=?=', $post['post_title']);
69
  //$this->assertEquals('', $post['post_content']);
70
  }
71
 
65
  $config = config_GetDefaults();
66
 
67
  $post = $this->process_file("data/japanese-attachment.var", $config);
68
+ $this->assertEquals('JP?B?UG9zdGllGyRCTVElRiU5JUglYSE8JWsbKEo=?=', $post['post_title']);
69
  //$this->assertEquals('', $post['post_content']);
70
  }
71
 
test/postie-functionsTest.php CHANGED
@@ -77,66 +77,66 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
77
  $this->assertEquals("Код Обмена Информацией, 8 бит", ConvertToUTF_8('koi8-r', iconv("UTF-8", "koi8-r", "Код Обмена Информацией, 8 бит")));
78
  }
79
 
80
- public function testDeterminePostDate() {
81
  $content = "test";
82
- $r = DeterminePostDate($content);
83
  $this->assertTrue(is_array($r));
84
  $this->assertEquals(3, count($r));
85
  $this->assertEquals(0, $r[2]);
86
  $this->assertEquals("test", $content);
87
 
88
  $content = "test delay:";
89
- $r = DeterminePostDate($content);
90
  $this->assertEquals(0, $r[2]);
91
  $this->assertEquals("test delay:", $content);
92
 
93
  $content = "test delay:1h";
94
- $r = DeterminePostDate($content);
95
  $this->assertEquals(3600, $r[2]);
96
  $this->assertEquals("test ", $content);
97
 
98
  $content = "test delay:1d";
99
- $r = DeterminePostDate($content);
100
  $this->assertEquals(86400, $r[2]);
101
  $this->assertEquals("test ", $content);
102
 
103
  $content = "test delay:1m";
104
- $r = DeterminePostDate($content);
105
  $this->assertEquals(60, $r[2]);
106
  $this->assertEquals("test ", $content);
107
 
108
  $content = "test delay:m";
109
- $r = DeterminePostDate($content);
110
  $this->assertEquals(0, $r[2]);
111
  $this->assertEquals("test ", $content);
112
 
113
  $content = "test delay:dhm";
114
- $r = DeterminePostDate($content);
115
  $this->assertEquals(0, $r[2]);
116
  $this->assertEquals("test ", $content);
117
 
118
  $content = "test delay:x";
119
- $r = DeterminePostDate($content);
120
  $this->assertEquals(0, $r[2]);
121
  $this->assertEquals("test delay:x", $content);
122
 
123
  $content = "test delay:-1m";
124
- $r = DeterminePostDate($content);
125
  $this->assertEquals(-60, $r[2]);
126
  $this->assertEquals("test ", $content);
127
 
128
  $content = "test delay:1d1h1m";
129
- $r = DeterminePostDate($content);
130
  $this->assertEquals(90060, $r[2]);
131
  $this->assertEquals("test ", $content);
132
 
133
  $content = "test delay:d1hm";
134
- $r = DeterminePostDate($content);
135
  $this->assertEquals(3600, $r[2]);
136
  $this->assertEquals("test ", $content);
137
 
138
  $content = "test";
139
- $r = DeterminePostDate($content, '2012-11-20 08:00', 1);
140
  $this->assertEquals('2012-11-20 17:00:00', $r[0]);
141
  $this->assertEquals(0, $r[2]);
142
  $this->assertEquals("test", $content);
@@ -279,76 +279,70 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
279
 
280
  public function testGetPostCategories() {
281
  global $wpdb;
 
282
 
283
  $s = "test";
284
- $c = tag_categories($s, "default");
285
  $this->assertEquals("default", $c[0]);
286
  $this->assertEquals("test", $s);
287
 
288
  $s = ":test";
289
- $c = tag_categories($s, "default");
290
  $this->assertEquals("default", $c[0]);
291
  $this->assertEquals(":test", $s);
292
 
293
- $wpdb->t_get_var = "1";
294
  $s = "1: test";
295
- $c = tag_categories($s, "default");
296
  $this->assertEquals("1", $c[0]);
297
  $this->assertEquals("test", $s);
298
 
299
- $wpdb->t_get_var = null;
300
  $s = "not a category: test";
301
- $c = tag_categories($s, "default");
302
  $this->assertEquals("default", $c[0]);
303
  $this->assertEquals("not a category: test", $s);
304
 
305
  $s = "[not a category] test";
306
- $c = tag_categories($s, "default");
307
  $this->assertEquals("default", $c[0]);
308
  $this->assertEquals("[not a category] test", $s);
309
 
310
  $s = "-not a category- test";
311
- $c = tag_categories($s, "default");
312
  $this->assertEquals("default", $c[0]);
313
  $this->assertEquals("-not a category- test", $s);
314
 
315
- $wpdb->t_get_var = 1;
316
  $s = "general: test";
317
- $c = tag_categories($s, "default");
318
  $this->assertEquals(1, $c[0]);
319
  $this->assertEquals("test", $s);
320
 
321
- $wpdb->t_get_var = 1;
322
  $s = "[general] test";
323
- $c = tag_categories($s, "default");
324
  $this->assertEquals(1, $c[0]);
325
  $this->assertEquals("test", $s);
326
 
327
- $wpdb->t_get_var = 1;
328
  $s = "-general- test";
329
- $c = tag_categories($s, "default");
330
  $this->assertEquals(1, $c[0]);
331
  $this->assertEquals("test", $s);
332
 
333
- $wpdb->t_get_var = "";
334
  $s = "specific: test";
335
- $c = tag_categories($s, "default");
336
  $this->assertEquals("default", $c[0]);
337
  $this->assertEquals("specific: test", $s);
338
 
339
- $wpdb->t_get_var = array(1, 1);
340
  $s = "[1] [1] test";
341
- $c = tag_categories($s, "default");
342
  $this->assertEquals(2, count($c));
343
  $this->assertEquals("1", $c[0]);
344
  $this->assertEquals("1", $c[1]);
345
  $this->assertEquals("test", $s);
346
 
347
- $wpdb->t_get_var = array(null, null, null, 1);
348
- $s = "[general] test: with colon";
349
- $c = tag_categories($s, "default");
350
- $this->assertEquals(1, $c[0]);
351
- $this->assertEquals("test: with colon", $s);
352
  }
353
 
354
  public function testHTML2HTML() {
@@ -407,7 +401,7 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
407
  public function testmore_reccurences() {
408
  $sched = array();
409
  $newsched = postie_more_reccurences($sched);
410
- $this->assertEquals(3, count($newsched));
411
  }
412
 
413
  public function testpostie_get_tags() {
@@ -581,6 +575,7 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
581
  $this->assertEquals("", $c);
582
  $this->assertEquals("stuff ", $e);
583
  }
 
584
  }
585
 
586
  ?>
77
  $this->assertEquals("Код Обмена Информацией, 8 бит", ConvertToUTF_8('koi8-r', iconv("UTF-8", "koi8-r", "Код Обмена Информацией, 8 бит")));
78
  }
79
 
80
+ public function testfilter_Delay() {
81
  $content = "test";
82
+ $r = filter_Delay($content);
83
  $this->assertTrue(is_array($r));
84
  $this->assertEquals(3, count($r));
85
  $this->assertEquals(0, $r[2]);
86
  $this->assertEquals("test", $content);
87
 
88
  $content = "test delay:";
89
+ $r = filter_Delay($content);
90
  $this->assertEquals(0, $r[2]);
91
  $this->assertEquals("test delay:", $content);
92
 
93
  $content = "test delay:1h";
94
+ $r = filter_Delay($content);
95
  $this->assertEquals(3600, $r[2]);
96
  $this->assertEquals("test ", $content);
97
 
98
  $content = "test delay:1d";
99
+ $r = filter_Delay($content);
100
  $this->assertEquals(86400, $r[2]);
101
  $this->assertEquals("test ", $content);
102
 
103
  $content = "test delay:1m";
104
+ $r = filter_Delay($content);
105
  $this->assertEquals(60, $r[2]);
106
  $this->assertEquals("test ", $content);
107
 
108
  $content = "test delay:m";
109
+ $r = filter_Delay($content);
110
  $this->assertEquals(0, $r[2]);
111
  $this->assertEquals("test ", $content);
112
 
113
  $content = "test delay:dhm";
114
+ $r = filter_Delay($content);
115
  $this->assertEquals(0, $r[2]);
116
  $this->assertEquals("test ", $content);
117
 
118
  $content = "test delay:x";
119
+ $r = filter_Delay($content);
120
  $this->assertEquals(0, $r[2]);
121
  $this->assertEquals("test delay:x", $content);
122
 
123
  $content = "test delay:-1m";
124
+ $r = filter_Delay($content);
125
  $this->assertEquals(-60, $r[2]);
126
  $this->assertEquals("test ", $content);
127
 
128
  $content = "test delay:1d1h1m";
129
+ $r = filter_Delay($content);
130
  $this->assertEquals(90060, $r[2]);
131
  $this->assertEquals("test ", $content);
132
 
133
  $content = "test delay:d1hm";
134
+ $r = filter_Delay($content);
135
  $this->assertEquals(3600, $r[2]);
136
  $this->assertEquals("test ", $content);
137
 
138
  $content = "test";
139
+ $r = filter_Delay($content, '2012-11-20 08:00', 1);
140
  $this->assertEquals('2012-11-20 17:00:00', $r[0]);
141
  $this->assertEquals(0, $r[2]);
142
  $this->assertEquals("test", $content);
279
 
280
  public function testGetPostCategories() {
281
  global $wpdb;
282
+ global $g_get_term_by;
283
 
284
  $s = "test";
285
+ $c = tag_categories($s, "default", false);
286
  $this->assertEquals("default", $c[0]);
287
  $this->assertEquals("test", $s);
288
 
289
  $s = ":test";
290
+ $c = tag_categories($s, "default", false);
291
  $this->assertEquals("default", $c[0]);
292
  $this->assertEquals(":test", $s);
293
 
294
+ $g_get_term_by = array('term_id' => 1);
295
  $s = "1: test";
296
+ $c = tag_categories($s, "default", false);
297
  $this->assertEquals("1", $c[0]);
298
  $this->assertEquals("test", $s);
299
 
300
+ $g_get_term_by = false;
301
  $s = "not a category: test";
302
+ $c = tag_categories($s, "default", false);
303
  $this->assertEquals("default", $c[0]);
304
  $this->assertEquals("not a category: test", $s);
305
 
306
  $s = "[not a category] test";
307
+ $c = tag_categories($s, "default", false);
308
  $this->assertEquals("default", $c[0]);
309
  $this->assertEquals("[not a category] test", $s);
310
 
311
  $s = "-not a category- test";
312
+ $c = tag_categories($s, "default", false);
313
  $this->assertEquals("default", $c[0]);
314
  $this->assertEquals("-not a category- test", $s);
315
 
316
+ $g_get_term_by = array('term_id' => 1);
317
  $s = "general: test";
318
+ $c = tag_categories($s, "default", false);
319
  $this->assertEquals(1, $c[0]);
320
  $this->assertEquals("test", $s);
321
 
 
322
  $s = "[general] test";
323
+ $c = tag_categories($s, "default", false);
324
  $this->assertEquals(1, $c[0]);
325
  $this->assertEquals("test", $s);
326
 
 
327
  $s = "-general- test";
328
+ $c = tag_categories($s, "default", false);
329
  $this->assertEquals(1, $c[0]);
330
  $this->assertEquals("test", $s);
331
 
332
+ $g_get_term_by = false;
333
  $s = "specific: test";
334
+ $c = tag_categories($s, "default", false);
335
  $this->assertEquals("default", $c[0]);
336
  $this->assertEquals("specific: test", $s);
337
 
338
+ $g_get_term_by = array('term_id' => 1);
339
  $s = "[1] [1] test";
340
+ $c = tag_categories($s, "default", false);
341
  $this->assertEquals(2, count($c));
342
  $this->assertEquals("1", $c[0]);
343
  $this->assertEquals("1", $c[1]);
344
  $this->assertEquals("test", $s);
345
 
 
 
 
 
 
346
  }
347
 
348
  public function testHTML2HTML() {
401
  public function testmore_reccurences() {
402
  $sched = array();
403
  $newsched = postie_more_reccurences($sched);
404
+ $this->assertEquals(4, count($newsched));
405
  }
406
 
407
  public function testpostie_get_tags() {
575
  $this->assertEquals("", $c);
576
  $this->assertEquals("stuff ", $e);
577
  }
578
+
579
  }
580
 
581
  ?>
test/wpstub.php CHANGED
@@ -54,7 +54,7 @@ function get_post() {
54
  $r->post_parent = 0;
55
  $r->guid = '7b0d965d-b8b0-4654-ac9e-eeef1d8cf571';
56
  $r->post_title = '';
57
- $r->post_excerpt='';
58
  return $r;
59
  }
60
 
@@ -137,11 +137,23 @@ function is_wp_error() {
137
  return false;
138
  }
139
 
140
- function sanitize_title($title){
141
  return $title;
142
  }
143
 
144
- function get_temp_dir(){
145
  return sys_get_temp_dir();
146
  }
 
 
 
 
 
 
 
 
 
 
 
 
147
  ?>
54
  $r->post_parent = 0;
55
  $r->guid = '7b0d965d-b8b0-4654-ac9e-eeef1d8cf571';
56
  $r->post_title = '';
57
+ $r->post_excerpt = '';
58
  return $r;
59
  }
60
 
137
  return false;
138
  }
139
 
140
+ function sanitize_title($title) {
141
  return $title;
142
  }
143
 
144
+ function get_temp_dir() {
145
  return sys_get_temp_dir();
146
  }
147
+
148
+ function sanitize_term($s) {
149
+ return trim($s);
150
+ }
151
+
152
+ $g_get_term_by = array('term_id' => 1);
153
+
154
+ function get_term_by() {
155
+ global $g_get_term_by;
156
+ return $g_get_term_by;
157
+ }
158
+
159
  ?>