FeedWordPress - Version 0.992

Version Description

Download this release

Release Info

Developer radgeek
Plugin Icon wp plugin FeedWordPress
Version 0.992
Comparing to
See all releases

Code changes from version 0.991 to 0.992

Files changed (4) hide show
  1. ChangeLog.text +30 -0
  2. feedwordpress.php +405 -99
  3. readme.txt +9 -10
  4. syndication-options.php +80 -8
ChangeLog.text CHANGED
@@ -1,6 +1,36 @@
1
  FeedWordPress Change Log
2
  ========================
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  Changes from 0.99 to 0.991
5
  --------------------------
6
  * WORDPRESS MU COMPATABILITY: FeedWordPress should now be compatible with
1
  FeedWordPress Change Log
2
  ========================
3
 
4
+ Changes from 0.991 to 0.992
5
+ ---------------------------
6
+ * AUTHOR RE-MAPPING: FeedWordPress now offers considerable control over
7
+ how author names on a feed are translated into usernames within the
8
+ WordPress database. When a post by an unrecognized author comes in,
9
+ Administrators can now specify any username as the default username to
10
+ assign the post to by setting the option in Syndication --> Options
11
+ (formerly FeedWordPress only allowed you to assign such posts to user
12
+ #1, the site administrator). Administrators can also create re-mapping
13
+ rules for particular feeds (under Syndication --> Syndicated Sites -->
14
+ Edit), so that (for example) any posts attributed to "Administrator"
15
+ on the feed <http://praxeology.net/blog/feed/> will be assigned to
16
+ a user named "Roderick T. Long," rather than a user named
17
+ "Administrator." These settings also allow administrators to filter out
18
+ posts by particular users, and to control what will happen when
19
+ FeedWordPress encounters a post by an unrecognized user on that
20
+ particular feed.
21
+
22
+ * BUG RELATED TO URIS CONTAINING AMPERSAND CHARACTERS FIXED: A bug in
23
+ WordPress 2.x's handling of URIs in Blogroll links created problems for
24
+ updating any feeds whose URIs included an ampersand character, such as
25
+ Google News RSS feeds and other feeds that have multiple parameters
26
+ passed through HTTP GET. If you experienced this bug, the most likely
27
+ effect was that FeedWordPress simply would not import new posts from a
28
+ feed when instructred to do so, returning a "0 new posts" response. In
29
+ other cases, it might lead to unpredictable results from feed updates,
30
+ such as importing posts which were not contained in the feed being
31
+ syndicated, but which did appear elsewhere on the same website. This bug
32
+ has, hopefully, been resolved, by correcting for the bug in WordPress.
33
+
34
  Changes from 0.99 to 0.991
35
  --------------------------
36
  * WORDPRESS MU COMPATABILITY: FeedWordPress should now be compatible with
feedwordpress.php CHANGED
@@ -3,11 +3,11 @@
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://projects.radgeek.com/feedwordpress
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
- Version: 0.991
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
10
- Last modified: 2007-09-25 12:48 PDT
11
  */
12
 
13
  # This uses code derived from:
@@ -27,7 +27,7 @@ Last modified: 2007-09-25 12:48 PDT
27
 
28
  # -- Don't change these unless you know what you're doing...
29
 
30
- define ('FEEDWORDPRESS_VERSION', '0.991');
31
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
32
  define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
33
 
@@ -112,6 +112,13 @@ if (!FeedWordPress::needs_upgrade()) : // only work if the conditions are safe!
112
 
113
  # Filter in original permalinks if the user wants that
114
  add_filter('post_link', 'syndication_permalink', 1);
 
 
 
 
 
 
 
115
 
116
  # Admin menu
117
  add_action('admin_menu', 'fwp_add_pages');
@@ -231,7 +238,31 @@ if (!function_exists('sanitize_user')) {
231
  return $text; // Don't munge it if it wasn't munged going in...
232
  }
233
  }
234
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  ################################################################################
236
  ## TEMPLATE API: functions to make your templates syndication-aware ############
237
  ################################################################################
@@ -551,7 +582,7 @@ if ($cont):
551
  if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
552
  ?>
553
  <td>
554
- <strong><a href="<?php echo $link->link_rss; ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
555
  <?php
556
  else:
557
  $caption='Find Feed';
@@ -665,7 +696,7 @@ function fwp_feedfinder_page () {
665
  <h3>Feed Information</h3>
666
  <ul>
667
  <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
668
- <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> <a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>"><img src="../wp-images/smilies/icon_arrow.gif" alt="(&rarr;)" /></a></li>
669
  <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
670
  <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
671
  </ul>
@@ -754,6 +785,7 @@ function fwp_linkedit_page () {
754
  'ping status',
755
  'unfamiliar author',
756
  'unfamliar categories',
 
757
  'update/.*',
758
  'feed/.*',
759
  'link/.*',
@@ -772,9 +804,9 @@ function fwp_linkedit_page () {
772
  $alter = array ();
773
 
774
  $meta = $link->settings;
775
- if (isset($meta['cats'])):
776
- $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']);
777
- endif;
778
 
779
  // custom feed settings first
780
  foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
@@ -848,14 +880,109 @@ function fwp_linkedit_page () {
848
  foreach (array("author", "category") as $what) :
849
  $sfield = "unfamiliar_{$what}";
850
  if (isset($GLOBALS['fwp_post'][$sfield])) :
851
- if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
852
  unset($meta["unfamiliar {$what}"]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
853
  else :
854
  $meta["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
855
  endif;
856
  endif;
857
  endforeach;
858
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
859
  if (isset($GLOBALS['fwp_post']['cat_split'])) :
860
  if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
861
  $meta['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
@@ -867,7 +994,18 @@ function fwp_linkedit_page () {
867
  if (is_array($meta['cats'])) :
868
  $meta['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['cats']);
869
  endif;
870
-
 
 
 
 
 
 
 
 
 
 
 
871
  $notes = '';
872
  foreach ($meta as $key => $value) :
873
  $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
@@ -961,6 +1099,23 @@ function fwp_linkedit_page () {
961
  if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
962
  else { ed.style.display='none'; view.style.display='inline'; }
963
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964
  </script>
965
 
966
  <?php if ($updated_link) : ?>
@@ -974,13 +1129,13 @@ function fwp_linkedit_page () {
974
  <input type="hidden" name="save" value="link" />
975
 
976
  <h2>Edit a syndicated feed:</h2>
977
- <fieldset><legend>Basics</legend>
978
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
979
  <tr>
980
  <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
981
  <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
982
- <a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
983
- title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity"><img src="../wp-images/smilies/icon_arrow.gif" alt="&rarr;" /></a>
984
  </td>
985
  <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
986
  </tr>
@@ -1069,7 +1224,7 @@ flip_hardcode('url');
1069
  <input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1070
  </p>
1071
 
1072
- <fieldset>
1073
  <legend>Syndicated Posts</legend>
1074
 
1075
  <?php fwp_category_box($dogs, 'all syndicated posts from this feed'); ?>
@@ -1119,25 +1274,89 @@ flip_hardcode('url');
1119
  <input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1120
  </p>
1121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1122
  <fieldset>
1123
  <legend>Advanced Feed Options</legend>
1124
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
1125
- <tr>
1126
- <th width="20%" scope="row" style="vertical-align:top">Unfamiliar authors:</th>
1127
- <td width="80%"><ul style="margin: 0; list-style:none">
1128
- <li><label><input type="radio" name="unfamiliar_author" value="site-default"<?php echo $unfamiliar['author']['site-default']; ?> /> use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1129
- (currently <strong><?php echo FeedWordPress::on_unfamiliar('author');; ?></strong>)</label></li>
1130
- <li><label><input type="radio" name="unfamiliar_author" value="create"<?php echo $unfamiliar['author']['create']; ?>/> create a new author account</label></li>
1131
- <li><label><input type="radio" name="unfamiliar_author" value="default"<?php echo $unfamiliar['author']['default']; ?> /> attribute the post to the default author</label></li>
1132
- <li><label><input type="radio" name="unfamiliar_author" value="filter"<?php echo $unfamiliar['author']['filter']; ?> /> don't syndicate the post</label></li>
1133
- </ul></td>
1134
- </tr>
1135
 
1136
  <tr>
1137
  <th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
1138
  <td width="80%"><ul style="margin: 0; list-style:none">
1139
  <li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1140
- (currently <strong><?php echo FeedWordPress::on_unfamiliar('category');; ?></strong>)</label></li>
1141
  <li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create any categories the post is in</label></li>
1142
  <li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories</label></li>
1143
  <li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories and don't syndicate posts unless they match at least one familiar category</label></li>
@@ -1209,6 +1428,19 @@ blank.</td>
1209
  return false; // Don't continue
1210
  }
1211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1212
  function fwp_multidelete_page () {
1213
  global $wpdb;
1214
 
@@ -1623,10 +1855,13 @@ class FeedWordPress {
1623
  function on_unfamiliar ($what = 'author', $override = NULL) {
1624
  $set = array('create', 'default', 'filter');
1625
 
1626
- $ret = strtolower($override);
1627
- if (!in_array($ret, $set)) :
 
 
 
1628
  $ret = get_option('feedwordpress_unfamiliar_'.$what);
1629
- if (!in_array($ret, $set)) :
1630
  $ret = 'create';
1631
  endif;
1632
  endif;
@@ -2349,84 +2584,87 @@ class SyndicatedPost {
2349
  $email = $wpdb->escape($email);
2350
  $url = $wpdb->escape($url);
2351
 
2352
- // Look for an existing author record that fits...
2353
- if (!isset($wp_db_version)) :
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2354
  #-- WordPress 1.5.x
2355
- $id = $wpdb->get_var(
2356
- "SELECT ID from $wpdb->users
2357
- WHERE
2358
- TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR
2359
- (
2360
- LENGTH(TRIM(LCASE(user_email))) > 0
2361
- AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
2362
- ) OR
2363
- TRIM(LCASE(user_firstname)) = TRIM(LCASE('$author')) OR
2364
- TRIM(LCASE(user_nickname)) = TRIM(LCASE('$author')) OR
2365
- TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) OR
2366
- TRIM(LCASE(user_description)) = TRIM(LCASE('$author')) OR
2367
- (
2368
- LOWER(user_description)
2369
- RLIKE CONCAT(
2370
- '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2371
- LCASE('$reg_author'),
2372
- '( |\\t|\\r)*(\\n|\$)'
 
 
2373
  )
2374
- )
2375
- ");
2376
- elseif ($wp_db_version >= 2966) :
2377
  #-- WordPress 2.0+
2378
-
2379
- # First try the user core data table.
2380
- $id = $wpdb->get_var(
2381
- "SELECT ID FROM $wpdb->users
2382
- WHERE
2383
- TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
2384
- OR (
2385
- LENGTH(TRIM(LCASE(user_email))) > 0
2386
- AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
2387
- )
2388
- OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author'))
2389
- ");
2390
 
2391
- if (is_null($id)) : # Then look for aliases in the user meta data table
2392
  $id = $wpdb->get_var(
2393
- "SELECT user_id FROM $wpdb->usermeta
2394
  WHERE
2395
- (meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('$author')))
2396
  OR (
2397
- meta_key = 'description'
2398
- AND TRIM(LCASE(meta_value))
2399
- RLIKE CONCAT(
2400
- '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2401
- TRIM(LCASE('$reg_author')),
2402
- '( |\\t|\\r)*(\\n|\$)'
2403
- )
2404
  )
 
2405
  ");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2406
  endif;
2407
- endif;
2408
 
2409
- // ... if you don't find one, then do what you need to do
2410
- if (is_null($id)) :
2411
- if ($unfamiliar_author === 'create') :
2412
- if (!isset($wp_db_version)) :
2413
- #-- WordPress 1.5.x
2414
- $wpdb->query (
2415
- "INSERT INTO $wpdb->users
2416
- SET
2417
- ID='0',
2418
- user_login='$login',
2419
- user_firstname='$author',
2420
- user_nickname='$author',
2421
- user_nicename='$nice_author',
2422
- user_description='$author',
2423
- user_email='$email',
2424
- user_url='$url'");
2425
- $id = $wpdb->insert_id;
2426
- elseif ($wp_db_version >= 2966) :
2427
- #-- WordPress 2.0+
2428
  $userdata = array();
2429
-
2430
  #-- user table data
2431
  $userdata['ID'] = NULL; // new user
2432
  $userdata['user_login'] = $login;
@@ -2435,13 +2673,19 @@ class SyndicatedPost {
2435
  $userdata['user_email'] = $email;
2436
  $userdata['user_url'] = $url;
2437
  $userdata['display_name'] = $author;
2438
-
2439
  $id = wp_insert_user($userdata);
 
 
 
 
2440
  endif;
2441
- elseif ($unfamiliar_author === 'default') :
2442
- $id = 1;
2443
  endif;
2444
  endif;
 
 
 
 
2445
  return $id;
2446
  } // function SyndicatedPost::author_id ()
2447
 
@@ -2794,6 +3038,22 @@ class SyndicatedLink {
2794
  if (isset($this->settings['cats'])):
2795
  $this->settings['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $this->settings['cats']);
2796
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2797
  endif;
2798
  } // SyndicatedLink::SyndicatedLink ()
2799
 
@@ -2871,6 +3131,17 @@ class SyndicatedLink {
2871
  if (is_array($to_notes['cats'])) :
2872
  $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
2873
  endif;
 
 
 
 
 
 
 
 
 
 
 
2874
  unset($to_notes['link/id']); unset($to_notes['link/uri']);
2875
  unset($to_notes['link/name']);
2876
  unset($to_notes['hardcode categories']); // Deprecated
@@ -2900,6 +3171,41 @@ class SyndicatedLink {
2900
  endif;
2901
  endforeach;
2902
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2903
  endif;
2904
  return $new_count;
2905
  } /* SyndicatedLink::poll() */
@@ -2957,7 +3263,7 @@ class SyndicatedLink {
2957
  return $ret;
2958
  } /* SyndicatedLink::ttl() */
2959
 
2960
- // SyndicatedLink:flatten_array (): flatten an array. Useful for
2961
  // hierarchical and namespaced elements.
2962
  //
2963
  // Given an array which may contain array or object elements in it,
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://projects.radgeek.com/feedwordpress
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
+ Version: 0.992
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
10
+ Last modified: 2008-01-04 18:03 PDT
11
  */
12
 
13
  # This uses code derived from:
27
 
28
  # -- Don't change these unless you know what you're doing...
29
 
30
+ define ('FEEDWORDPRESS_VERSION', '0.992');
31
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
32
  define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
33
 
112
 
113
  # Filter in original permalinks if the user wants that
114
  add_filter('post_link', 'syndication_permalink', 1);
115
+
116
+ # WTF? By default, wp_insert_link runs incoming link_url and link_rss
117
+ # URIs through default filters that include `wp_kses()`. But `wp_kses()`
118
+ # just happens to escape any occurrence of & to &amp; -- which just
119
+ # happens to fuck up any URI with a & to separate GET parameters.
120
+ remove_filter('pre_link_rss', 'wp_filter_kses');
121
+ remove_filter('pre_link_url', 'wp_filter_kses');
122
 
123
  # Admin menu
124
  add_action('admin_menu', 'fwp_add_pages');
238
  return $text; // Don't munge it if it wasn't munged going in...
239
  }
240
  }
241
+ if (!function_exists('wp_insert_user')) {
242
+ function wp_insert_user ($userdata) {
243
+ #-- Help WordPress 1.5.x quack like a duck
244
+ $login = $userdata['user_login'];
245
+ $author = $userdata['display_name'];
246
+ $nice_author = $userdata['user_nicename'];
247
+ $email = $userdata['user_email'];
248
+ $url = $userdata['user_url'];
249
+
250
+ $wpdb->query (
251
+ "INSERT INTO $wpdb->users
252
+ SET
253
+ ID='0',
254
+ user_login='$login',
255
+ user_firstname='$author',
256
+ user_nickname='$author',
257
+ user_nicename='$nice_author',
258
+ user_description='$author',
259
+ user_email='$email',
260
+ user_url='$url'");
261
+ $id = $wpdb->insert_id;
262
+
263
+ return $id;
264
+ }
265
+ }
266
  ################################################################################
267
  ## TEMPLATE API: functions to make your templates syndication-aware ############
268
  ################################################################################
582
  if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
583
  ?>
584
  <td>
585
+ <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
586
  <?php
587
  else:
588
  $caption='Find Feed';
696
  <h3>Feed Information</h3>
697
  <ul>
698
  <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
699
+ <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
700
  <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
701
  <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
702
  </ul>
785
  'ping status',
786
  'unfamiliar author',
787
  'unfamliar categories',
788
+ 'map authors',
789
  'update/.*',
790
  'feed/.*',
791
  'link/.*',
804
  $alter = array ();
805
 
806
  $meta = $link->settings;
807
+ //if (isset($meta['cats'])):
808
+ // $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']);
809
+ //endif;
810
 
811
  // custom feed settings first
812
  foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
880
  foreach (array("author", "category") as $what) :
881
  $sfield = "unfamiliar_{$what}";
882
  if (isset($GLOBALS['fwp_post'][$sfield])) :
883
+ if ('site-default'==$GLOBALS['fwp_post'][$sfield]) :
884
  unset($meta["unfamiliar {$what}"]);
885
+ elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) :
886
+ $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]);
887
+ if (strlen($newuser_name) > 0) :
888
+ $userdata = array();
889
+ $userdata['ID'] = NULL;
890
+
891
+ $userdata['user_login'] = sanitize_user($newuser_name);
892
+ $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
893
+
894
+ $userdata['user_nicename'] = sanitize_title($newuser_name);
895
+ $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
896
+
897
+ $userdata['display_name'] = $wpdb->escape($newuser_name);
898
+
899
+ $newuser_id = wp_insert_user($userdata);
900
+ if (is_numeric($newuser_id)) :
901
+ $meta["unfamiliar {$what}"] = $newuser_id;
902
+ else :
903
+ // TODO: Add some error detection and reporting
904
+ endif;
905
+ else :
906
+ // TODO: Add some error reporting
907
+ endif;
908
  else :
909
  $meta["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
910
  endif;
911
  endif;
912
  endforeach;
913
 
914
+ // Handle author mapping rules
915
+ if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
916
+ unset($meta['map authors']);
917
+ foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
918
+ // Normalize for case and whitespace
919
+ $name = strtolower(trim($name));
920
+ $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
921
+
922
+ if (strlen($name) > 0) :
923
+ if ('newuser' == $author_action) :
924
+ $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
925
+ if (strlen($newuser_name) > 0) :
926
+ $userdata = array();
927
+ $userdata['ID'] = NULL;
928
+
929
+ $userdata['user_login'] = sanitize_user($newuser_name);
930
+ $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
931
+
932
+ $userdata['user_nicename'] = sanitize_title($newuser_name);
933
+ $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
934
+
935
+ $userdata['display_name'] = $wpdb->escape($newuser_name);
936
+
937
+ $newuser_id = wp_insert_user($userdata);
938
+ if (is_numeric($newuser_id)) :
939
+ $meta['map authors']['name'][$name] = $newuser_id;
940
+ else :
941
+ // TODO: Add some error detection and reporting
942
+ endif;
943
+ else :
944
+ // TODO: Add some error reporting
945
+ endif;
946
+ else :
947
+ $meta['map authors']['name'][$name] = $author_action;
948
+ endif;
949
+ endif;
950
+ endforeach;
951
+ endif;
952
+
953
+ if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
954
+ $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
955
+ $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
956
+ if (strlen($name) > 0) :
957
+ if ('newuser' == $author_action) :
958
+ $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
959
+ if (strlen($newuser_name) > 0) :
960
+ $userdata = array();
961
+ $userdata['ID'] = NULL;
962
+
963
+ $userdata['user_login'] = sanitize_user($newuser_name);
964
+ $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
965
+
966
+ $userdata['user_nicename'] = sanitize_title($newuser_name);
967
+ $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
968
+
969
+ $userdata['display_name'] = $wpdb->escape($newuser_name);
970
+
971
+ $newuser_id = wp_insert_user($userdata);
972
+ if (is_numeric($newuser_id)) :
973
+ $meta['map authors']['name'][$name] = $newuser_id;
974
+ else :
975
+ // TODO: Add some error detection and reporting
976
+ endif;
977
+ else :
978
+ // TODO: Add some error reporting
979
+ endif;
980
+ else :
981
+ $meta['map authors']['name'][$name] = $author_action;
982
+ endif;
983
+ endif;
984
+ endif;
985
+
986
  if (isset($GLOBALS['fwp_post']['cat_split'])) :
987
  if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
988
  $meta['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
994
  if (is_array($meta['cats'])) :
995
  $meta['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['cats']);
996
  endif;
997
+
998
+ // Collapse the author mapping rule structure back into a flat string
999
+ if (isset($meta['map authors'])) :
1000
+ $ma = array();
1001
+ foreach ($meta['map authors'] as $rule_type => $author_rules) :
1002
+ foreach ($author_rules as $author_name => $author_action) :
1003
+ $ma[] = $rule_type."\n".$author_name."\n".$author_action;
1004
+ endforeach;
1005
+ endforeach;
1006
+ $meta['map authors'] = implode("\n\n", $ma);
1007
+ endif;
1008
+
1009
  $notes = '';
1010
  foreach ($meta as $key => $value) :
1011
  $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
1099
  if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
1100
  else { ed.style.display='none'; view.style.display='inline'; }
1101
  }
1102
+ function flip_newuser (item) {
1103
+ rollup=document.getElementById(item);
1104
+ newuser=document.getElementById(item+'-newuser');
1105
+ sitewide=document.getElementById(item+'-default');
1106
+ if (rollup) {
1107
+ if ('newuser'==rollup.value) {
1108
+ if (newuser) newuser.style.display='block';
1109
+ if (sitewide) sitewide.style.display='none';
1110
+ } else if ('site-default'==rollup.value) {
1111
+ if (newuser) newuser.style.display='none';
1112
+ if (sitewide) sitewide.style.display='block';
1113
+ } else {
1114
+ if (newuser) newuser.style.display='none';
1115
+ if (sitewide) sitewide.style.display='none';
1116
+ }
1117
+ }
1118
+ }
1119
  </script>
1120
 
1121
  <?php if ($updated_link) : ?>
1129
  <input type="hidden" name="save" value="link" />
1130
 
1131
  <h2>Edit a syndicated feed:</h2>
1132
+ <fieldset class="options"><legend>Basics</legend>
1133
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
1134
  <tr>
1135
  <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
1136
  <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
1137
+ (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
1138
+ title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity">validate</a>)
1139
  </td>
1140
  <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
1141
  </tr>
1224
  <input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1225
  </p>
1226
 
1227
+ <fieldset class="options">
1228
  <legend>Syndicated Posts</legend>
1229
 
1230
  <?php fwp_category_box($dogs, 'all syndicated posts from this feed'); ?>
1274
  <input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1275
  </p>
1276
 
1277
+ <fieldset class="options">
1278
+ <legend>Syndicated Authors</legend>
1279
+ <?php $authorlist = fwp_author_list(); ?>
1280
+
1281
+ <table>
1282
+ <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr>
1283
+
1284
+ <?php if (isset($meta['map authors'])) : $i=0; foreach ($meta['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?>
1285
+ <tr>
1286
+ <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th>
1287
+ <td>
1288
+ <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');">
1289
+ <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
1290
+ <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option>
1291
+ <?php endforeach; ?>
1292
+ <option value="newuser">will be assigned to a new user...</option>
1293
+ <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
1294
+ </select>
1295
+ </td>
1296
+ <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td>
1297
+ </tr>
1298
+ <?php endforeach; endforeach; endif; ?>
1299
+
1300
+ <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">Fill in to set up a new rule:</th></tr>
1301
+
1302
+ <tr>
1303
+ <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th>
1304
+ <td>
1305
+ <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');">
1306
+ <?php foreach ($authorlist as $author_id => $author_name) : ?>
1307
+ <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
1308
+ <?php endforeach; ?>
1309
+ <option value="newuser">will be assigned to a new user...</option>
1310
+ <option value="filter">get filtered out</option>
1311
+ </select>
1312
+ </td>
1313
+ <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td>
1314
+ </tr>
1315
+
1316
+ <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
1317
+ <tr>
1318
+ <th style="text-align: left">Posts by new authors</th>
1319
+ <td>
1320
+ <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
1321
+ <option value="site-default"<?php if (!isset($meta['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option>
1322
+ <option value="create"<?php if ('create'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
1323
+ <?php foreach ($authorlist as $author_id => $author_name) : ?>
1324
+ <option value="<?php echo $author_id; ?>"<?php if ($author_id==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
1325
+ <?php endforeach; ?>
1326
+ <option value="newuser">will be assigned to a new user...</option>
1327
+ <option value="filter"<?php if ('filter'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
1328
+ </select>
1329
+ </td>
1330
+ <td>
1331
+ <div id="unfamiliar-author-default">Site-wide settings can be set in <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a></div>
1332
+ <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div>
1333
+ </td>
1334
+ </tr>
1335
+
1336
+ </table>
1337
+ </fieldset>
1338
+
1339
+ <script>
1340
+ flip_newuser('unfamiliar-author');
1341
+ <?php for ($j=1; $j<=$i; $j++) : ?>
1342
+ flip_newuser('author-rules-<?php echo $j; ?>');
1343
+ <?php endfor; ?>
1344
+ flip_newuser('add-author-rule');
1345
+ </script>
1346
+
1347
+ <p class="submit">
1348
+ <input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
1349
+ </p>
1350
+
1351
  <fieldset>
1352
  <legend>Advanced Feed Options</legend>
1353
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
 
 
 
 
 
 
 
 
 
 
1354
 
1355
  <tr>
1356
  <th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
1357
  <td width="80%"><ul style="margin: 0; list-style:none">
1358
  <li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use site-wide setting from <a href="admin.php?page=feedwordpress/syndication-options.php">Syndication Options</a>
1359
+ (currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
1360
  <li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create any categories the post is in</label></li>
1361
  <li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories</label></li>
1362
  <li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories and don't syndicate posts unless they match at least one familiar category</label></li>
1428
  return false; // Don't continue
1429
  }
1430
 
1431
+ function fwp_author_list () {
1432
+ global $wpdb;
1433
+ $ret = array();
1434
+ $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY display_name");
1435
+ if (is_array($users)) :
1436
+ foreach ($users as $user) :
1437
+ $id = (int) $user->ID;
1438
+ $ret[$id] = $user->display_name;
1439
+ endforeach;
1440
+ endif;
1441
+ return $ret;
1442
+ }
1443
+
1444
  function fwp_multidelete_page () {
1445
  global $wpdb;
1446
 
1855
  function on_unfamiliar ($what = 'author', $override = NULL) {
1856
  $set = array('create', 'default', 'filter');
1857
 
1858
+ if (is_string($override)) :
1859
+ $ret = strtolower($override);
1860
+ endif;
1861
+
1862
+ if (!is_numeric($override) and !in_array($ret, $set)) :
1863
  $ret = get_option('feedwordpress_unfamiliar_'.$what);
1864
+ if (!is_numeric($ret) and !in_array($ret, $set)) :
1865
  $ret = 'create';
1866
  endif;
1867
  endif;
2584
  $email = $wpdb->escape($email);
2585
  $url = $wpdb->escape($url);
2586
 
2587
+ // Check for an existing author rule....
2588
+ if (isset($this->link->settings['map authors']['name'][strtolower(trim($author))])) :
2589
+ $author_rule = $this->link->settings['map authors']['name'][strtolower(trim($author))];
2590
+ else :
2591
+ $author_rule = NULL;
2592
+ endif;
2593
+
2594
+ // User name is mapped to a particular author. If that author ID exists, use it.
2595
+ if (is_numeric($author_rule) and get_userdata((int) $author_rule)) :
2596
+ $id = (int) $author_rule;
2597
+
2598
+ // User name is filtered out
2599
+ elseif ('filter' == $author_rule) :
2600
+ $id = NULL;
2601
+
2602
+ else :
2603
+ // Check the database for an existing author record that might fit
2604
+
2605
  #-- WordPress 1.5.x
2606
+ if (!isset($wp_db_version)) :
2607
+ $id = $wpdb->get_var(
2608
+ "SELECT ID from $wpdb->users
2609
+ WHERE
2610
+ TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR
2611
+ (
2612
+ LENGTH(TRIM(LCASE(user_email))) > 0
2613
+ AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
2614
+ ) OR
2615
+ TRIM(LCASE(user_firstname)) = TRIM(LCASE('$author')) OR
2616
+ TRIM(LCASE(user_nickname)) = TRIM(LCASE('$author')) OR
2617
+ TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) OR
2618
+ TRIM(LCASE(user_description)) = TRIM(LCASE('$author')) OR
2619
+ (
2620
+ LOWER(user_description)
2621
+ RLIKE CONCAT(
2622
+ '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2623
+ LCASE('$reg_author'),
2624
+ '( |\\t|\\r)*(\\n|\$)'
2625
+ )
2626
  )
2627
+ ");
2628
+
 
2629
  #-- WordPress 2.0+
2630
+ elseif ($wp_db_version >= 2966) :
 
 
 
 
 
 
 
 
 
 
 
2631
 
2632
+ // First try the user core data table.
2633
  $id = $wpdb->get_var(
2634
+ "SELECT ID FROM $wpdb->users
2635
  WHERE
2636
+ TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
2637
  OR (
2638
+ LENGTH(TRIM(LCASE(user_email))) > 0
2639
+ AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
 
 
 
 
 
2640
  )
2641
+ OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author'))
2642
  ");
2643
+
2644
+ // If that fails, look for aliases in the user meta data table
2645
+ if (is_null($id)) :
2646
+ $id = $wpdb->get_var(
2647
+ "SELECT user_id FROM $wpdb->usermeta
2648
+ WHERE
2649
+ (meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('$author')))
2650
+ OR (
2651
+ meta_key = 'description'
2652
+ AND TRIM(LCASE(meta_value))
2653
+ RLIKE CONCAT(
2654
+ '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
2655
+ TRIM(LCASE('$reg_author')),
2656
+ '( |\\t|\\r)*(\\n|\$)'
2657
+ )
2658
+ )
2659
+ ");
2660
+ endif;
2661
  endif;
 
2662
 
2663
+ // ... if you don't find one, then do what you need to do
2664
+ if (is_null($id)) :
2665
+ if ($unfamiliar_author === 'create') :
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2666
  $userdata = array();
2667
+
2668
  #-- user table data
2669
  $userdata['ID'] = NULL; // new user
2670
  $userdata['user_login'] = $login;
2673
  $userdata['user_email'] = $email;
2674
  $userdata['user_url'] = $url;
2675
  $userdata['display_name'] = $author;
2676
+
2677
  $id = wp_insert_user($userdata);
2678
+ elseif (is_numeric($unfamiliar_author) and get_userdata((int) $unfamiliar_author)) :
2679
+ $id = (int) $unfamiliar_author;
2680
+ elseif ($unfamiliar_author === 'default') :
2681
+ $id = 1;
2682
  endif;
 
 
2683
  endif;
2684
  endif;
2685
+
2686
+ if ($id) :
2687
+ $this->link->settings['map authors']['name'][strtolower(trim($author))] = $id;
2688
+ endif;
2689
  return $id;
2690
  } // function SyndicatedPost::author_id ()
2691
 
3038
  if (isset($this->settings['cats'])):
3039
  $this->settings['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $this->settings['cats']);
3040
  endif;
3041
+
3042
+ if (isset($this->settings['map authors'])) :
3043
+ $author_rules = explode("\n\n", $this->settings['map authors']);
3044
+ $ma = array();
3045
+ foreach ($author_rules as $rule) :
3046
+ list($rule_type, $author_name, $author_action) = explode("\n", $rule);
3047
+
3048
+ // Normalize for case and whitespace
3049
+ $rule_type = strtolower(trim($rule_type));
3050
+ $author_name = strtolower(trim($author_name));
3051
+ $author_action = strtolower(trim($author_action));
3052
+
3053
+ $ma[$rule_type][$author_name] = $author_action;
3054
+ endforeach;
3055
+ $this->settings['map authors'] = $ma;
3056
+ endif;
3057
  endif;
3058
  } // SyndicatedLink::SyndicatedLink ()
3059
 
3131
  if (is_array($to_notes['cats'])) :
3132
  $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
3133
  endif;
3134
+
3135
+ if (isset($to_notes['map authors'])) :
3136
+ $ma = array();
3137
+ foreach ($to_notes['map authors'] as $rule_type => $author_rules) :
3138
+ foreach ($author_rules as $author_name => $author_action) :
3139
+ $ma[] = $rule_type."\n".$author_name."\n".$author_action;
3140
+ endforeach;
3141
+ endforeach;
3142
+ $to_notes['map authors'] = implode("\n\n", $ma);
3143
+ endif;
3144
+
3145
  unset($to_notes['link/id']); unset($to_notes['link/uri']);
3146
  unset($to_notes['link/name']);
3147
  unset($to_notes['hardcode categories']); // Deprecated
3171
  endif;
3172
  endforeach;
3173
  endif;
3174
+
3175
+ // Copy back any changes to feed settings made in the course of updating (e.g. new author rules)
3176
+ $to_notes = $this->settings;
3177
+
3178
+ if (is_array($to_notes['cats'])) :
3179
+ $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
3180
+ endif;
3181
+
3182
+ if (isset($to_notes['map authors'])) :
3183
+ $ma = array();
3184
+ foreach ($to_notes['map authors'] as $rule_type => $author_rules) :
3185
+ foreach ($author_rules as $author_name => $author_action) :
3186
+ $ma[] = $rule_type."\n".$author_name."\n".$author_action;
3187
+ endforeach;
3188
+ endforeach;
3189
+ $to_notes['map authors'] = implode("\n\n", $ma);
3190
+ endif;
3191
+
3192
+ unset($to_notes['link/id']); unset($to_notes['link/uri']);
3193
+ unset($to_notes['link/name']);
3194
+ unset($to_notes['hardcode categories']); // Deprecated
3195
+
3196
+ $notes = '';
3197
+ foreach ($to_notes as $key => $value) :
3198
+ $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
3199
+ endforeach;
3200
+
3201
+ $update_set = "link_notes = '".$wpdb->escape($notes)."'";
3202
+
3203
+ // Update the properties of the link from the feed information
3204
+ $result = $wpdb->query("
3205
+ UPDATE $wpdb->links
3206
+ SET $update_set
3207
+ WHERE link_id='$this->id'
3208
+ ");
3209
  endif;
3210
  return $new_count;
3211
  } /* SyndicatedLink::poll() */
3263
  return $ret;
3264
  } /* SyndicatedLink::ttl() */
3265
 
3266
+ // SyndicatedLink::flatten_array (): flatten an array. Useful for
3267
  // hierarchical and namespaced elements.
3268
  //
3269
  // Given an array which may contain array or object elements in it,
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://projects.radgeek.com/feedwordpress/
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 1.5
6
  Tested up to: 2.3.1
7
- Stable tag: 0.991
8
 
9
  FeedWordPress is an Atom/RSS aggregator for WordPress. When activated, it syndicates content from feeds you choose into your WordPress weblog.
10
 
@@ -14,13 +14,12 @@ FeedWordPress is an Atom/RSS aggregator for WordPress. When activated, it syndic
14
  * Project URI: <http://projects.radgeek.com/feedwordpress>
15
  * License: GPL 2. See License below for copyright jots and tittles.
16
 
17
- FeedWordPress is an Atom/RSS aggregator for the WordPress weblog software. It
18
- syndicates content from newsfeeds that you choose into your WordPress webblog;
19
- if you syndicate several newsfeeds then you can use WordPress's posts database
20
- and templating engine as the back-end of an aggregation ("planet") website. It
21
- was developed, originally, because I needed a more flexible replacement for
22
- [Planet](http://www.planetplanet.org/) to use at
23
- [Feminist Blogs](http://feministblogs.org/).
24
 
25
  FeedWordPress is designed with flexibility, ease of use, and ease of
26
  configuration in mind. You'll need a working installation of WordPress or
@@ -39,7 +38,7 @@ offer shell access are *bad web hosts*.)
39
 
40
  == Installation ==
41
 
42
- To use version 0.991 of FeedWordPress, you will need:
43
 
44
  * an installed and configured copy of WordPress version 2.3.x, 2.2.x,
45
  2.1.x, 2.0.x, or 1.5.x. (FeedWordPress will also work with the
@@ -79,7 +78,7 @@ To use version 0.991 of FeedWordPress, you will need:
79
 
80
  = Upgrades =
81
 
82
- To *upgrade* an existing installation of FeedWordPress to version 0.991:
83
 
84
  1. Download the FeedWordPress archive in zip or gzipped tar format and
85
  extract the files on your computer.
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 1.5
6
  Tested up to: 2.3.1
7
+ Stable tag: 0.992
8
 
9
  FeedWordPress is an Atom/RSS aggregator for WordPress. When activated, it syndicates content from feeds you choose into your WordPress weblog.
10
 
14
  * Project URI: <http://projects.radgeek.com/feedwordpress>
15
  * License: GPL 2. See License below for copyright jots and tittles.
16
 
17
+ FeedWordPress is an Atom/RSS aggregator for WordPress. It syndicates content
18
+ from feeds that you choose into your WordPress weblog; if you syndicate several
19
+ feeds then you can use WordPress's posts database and templating engine as the
20
+ back-end of an aggregation ("planet") website. It was developed, originally,
21
+ because I needed a more flexible replacement for [Planet](http://www.planetplanet.org/)
22
+ to use at [Feminist Blogs](http://feministblogs.org/).
 
23
 
24
  FeedWordPress is designed with flexibility, ease of use, and ease of
25
  configuration in mind. You'll need a working installation of WordPress or
38
 
39
  == Installation ==
40
 
41
+ To use version 0.992 of FeedWordPress, you will need:
42
 
43
  * an installed and configured copy of WordPress version 2.3.x, 2.2.x,
44
  2.1.x, 2.0.x, or 1.5.x. (FeedWordPress will also work with the
78
 
79
  = Upgrades =
80
 
81
+ To *upgrade* an existing installation of FeedWordPress to version 0.992:
82
 
83
  1. Download the FeedWordPress archive in zip or gzipped tar format and
84
  extract the files on your computer.
syndication-options.php CHANGED
@@ -17,7 +17,34 @@ function fwp_syndication_options_page () {
17
  update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
18
  update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
19
  update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
20
- update_option('feedwordpress_unfamiliar_author', $_REQUEST['unfamiliar_author']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
22
  update_option('feedwordpress_syndicated_post_status', $_REQUEST['post_status']);
23
  update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
@@ -138,6 +165,23 @@ function fwp_syndication_options_page () {
138
  endforeach;
139
 
140
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  <div class="wrap">
142
  <h2>Syndication Options</h2>
143
  <form action="" method="post">
@@ -208,13 +252,6 @@ function fwp_syndication_options_page () {
208
  <li><label><input type="radio" name="ping_status" value="closed"<?php echo ($ping_status!='open')?' checked="checked"':''; ?> /> Don't accept pings on syndicated posts</label></li>
209
  </ul></td></tr>
210
 
211
- <tr style="vertical-align: top"><th width="44%" scope="row" style="vertical-align:top">Unfamiliar authors:</th>
212
- <td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
213
- <li><label><input type="radio" name="unfamiliar_author" value="create"<?php echo $unfamiliar_author['create']; ?>/> create a new author account</label></li>
214
- <li><label><input type="radio" name="unfamiliar_author" value="default"<?php echo $unfamiliar_author['default']; ?> /> attribute the post to the default author</label></li>
215
- <li><label><input type="radio" name="unfamiliar_author" value="filter"<?php echo $unfamiliar_author['filter']; ?> /> don't syndicate the post</label></li>
216
- </ul></td></tr>
217
-
218
  <tr style="vertical-align: top"><th width="44%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
219
  <td width="56%"><ul style="margin: 0; padding:0; list-style:none">
220
  <li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar_category['create']; ?>/> create any categories the post is in</label></li>
@@ -231,6 +268,41 @@ function fwp_syndication_options_page () {
231
  <div class="submit"><input type="submit" name="action" value="<?php echo $caption; ?>" /></div>
232
  </fieldset>
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  <fieldset class="options">
235
  <legend>Back-end Options</legend>
236
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
17
  update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
18
  update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
19
  update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
20
+
21
+ if ('newuser'==$_REQUEST['unfamiliar_author']) :
22
+ $newuser_name = trim($_REQUEST['unfamiliar_author_newuser']);
23
+ if (strlen($newuser_name) > 0) :
24
+ $userdata = array();
25
+ $userdata['ID'] = NULL;
26
+
27
+ $userdata['user_login'] = sanitize_user($newuser_name);
28
+ $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
29
+
30
+ $userdata['user_nicename'] = sanitize_title($newuser_name);
31
+ $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
32
+
33
+ $userdata['display_name'] = $wpdb->escape($newuser_name);
34
+
35
+ $newuser_id = wp_insert_user($userdata);
36
+ if (is_numeric($newuser_id)) :
37
+ update_option('feedwordpress_unfamiliar_author', $newuser_id);
38
+ else :
39
+ // TODO: Add some error detection and reporting
40
+ endif;
41
+ else :
42
+ // TODO: Add some error reporting
43
+ endif;
44
+ else :
45
+ update_option('feedwordpress_unfamiliar_author', $_REQUEST['unfamiliar_author']);
46
+ endif;
47
+
48
  update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
49
  update_option('feedwordpress_syndicated_post_status', $_REQUEST['post_status']);
50
  update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
165
  endforeach;
166
 
167
  ?>
168
+ <script type="text/javascript">
169
+ function flip_newuser (item) {
170
+ rollup=document.getElementById(item);
171
+ newuser=document.getElementById(item+'-newuser');
172
+ sitewide=document.getElementById(item+'-default');
173
+ if (rollup) {
174
+ if ('newuser'==rollup.value) {
175
+ if (newuser) newuser.style.display='block';
176
+ if (sitewide) sitewide.style.display='none';
177
+ } else {
178
+ if (newuser) newuser.style.display='none';
179
+ if (sitewide) sitewide.style.display='block';
180
+ }
181
+ }
182
+ }
183
+ </script>
184
+
185
  <div class="wrap">
186
  <h2>Syndication Options</h2>
187
  <form action="" method="post">
252
  <li><label><input type="radio" name="ping_status" value="closed"<?php echo ($ping_status!='open')?' checked="checked"':''; ?> /> Don't accept pings on syndicated posts</label></li>
253
  </ul></td></tr>
254
 
 
 
 
 
 
 
 
255
  <tr style="vertical-align: top"><th width="44%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
256
  <td width="56%"><ul style="margin: 0; padding:0; list-style:none">
257
  <li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar_category['create']; ?>/> create any categories the post is in</label></li>
268
  <div class="submit"><input type="submit" name="action" value="<?php echo $caption; ?>" /></div>
269
  </fieldset>
270
 
271
+ <fieldset class="options">
272
+ <legend>Syndicated Authors</legend>
273
+ <?php
274
+ $unfamiliar_author = FeedWordPress::on_unfamiliar('author');
275
+ $authorlist = fwp_author_list();
276
+ ?>
277
+
278
+ <table>
279
+ <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
280
+ <tr>
281
+ <th style="text-align: left">Posts by new authors</th>
282
+ <td>
283
+ <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
284
+ <option value="create"<?php if ('create'==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
285
+ <?php foreach ($authorlist as $author_id => $author_name) : ?>
286
+ <option value="<?php echo $author_id; ?>"<?php if ($author_id==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
287
+ <?php endforeach; ?>
288
+ <option value="newuser">will be assigned to a user named...</option>
289
+ <option value="filter"<?php if ('filter'==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
290
+ </select>
291
+ </td>
292
+ <td>
293
+ <div id="unfamiliar-author-default">This is a default setting. You can override it for one or more particular feeds using the Edit link in <a href="admin.php?page=feedwordpress/feedwordpress.php">Syndicated Sites</a></div>
294
+ <div id="unfamiliar-author-newuser"><input type="text" name="unfamiliar_author_newuser" value="" /></div>
295
+ </td>
296
+ </tr>
297
+ </table>
298
+
299
+ <script>
300
+ flip_newuser('unfamiliar-author');
301
+ </script>
302
+
303
+ <div class="submit"><input type="submit" name="action" value="<?php echo $caption; ?>" /></div>
304
+ </fieldset>
305
+
306
  <fieldset class="options">
307
  <legend>Back-end Options</legend>
308
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">