| @@ -2,13 +2,13 @@ | ||
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: FeedWordPress |
| 4 | 4 | Plugin URI: http://projects.radgeek.com/feedwordpress |
| 5 | 5 | Description: simple and flexible Atom/RSS syndication for WordPress |
| 6 | -Version: 0.992 | |
| 6 | +Version: 0.991 | |
| 7 | 7 | Author: Charles Johnson |
| 8 | 8 | Author URI: http://radgeek.com/ |
| 9 | 9 | License: GPL |
| 10 | -Last modified: 2008-01-04 18:03 PDT | |
| 10 | +Last modified: 2007-09-25 12:48 PDT | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | # This uses code derived from: |
| 14 | 14 | # - wp-rss-aggregate.php by Kellan Elliot-McCrea <kellan@protest.net> |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | # <http://www.zyx.com/blog/xmlrpc.php>), or see `update-feeds.php` |
| 27 | 27 | |
| 28 | 28 | # -- Don't change these unless you know what you're doing... |
| 29 | 29 | |
| 30 | -define ('FEEDWORDPRESS_VERSION', '0.992'); | |
| 30 | +define ('FEEDWORDPRESS_VERSION', '0.991'); | |
| 31 | 31 | define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact'); |
| 32 | 32 | define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors'); |
| 33 | 33 | |
| 34 | 34 | define ('FEEDWORDPRESS_DEBUG', false); |
| @@ -111,15 +111,8 @@ | ||
| 111 | 111 | add_filter('the_content', 'feedwordpress_restore_syndicated_content', 10000); |
| 112 | 112 | |
| 113 | 113 | # Filter in original permalinks if the user wants that |
| 114 | 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 & -- 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 | 115 | |
| 123 | 116 | # Admin menu |
| 124 | 117 | add_action('admin_menu', 'fwp_add_pages'); |
| 125 | 118 | |
| @@ -237,33 +230,9 @@ | ||
| 237 | 230 | function sanitize_user ($text, $strict) { |
| 238 | 231 | return $text; // Don't munge it if it wasn't munged going in... |
| 239 | 232 | } |
| 240 | 233 | } |
| 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 | 234 | |
| 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 | 235 | ################################################################################ |
| 267 | 236 | ## TEMPLATE API: functions to make your templates syndication-aware ############ |
| 268 | 237 | ################################################################################ |
| 269 | 238 | |
| @@ -581,9 +550,9 @@ | ||
| 581 | 550 | .(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); |
| 582 | 551 | if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; |
| 583 | 552 | ?> |
| 584 | 553 | <td> |
| 585 | - <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td> | |
| 554 | + <strong><a href="<?php echo $link->link_rss; ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td> | |
| 586 | 555 | <?php |
| 587 | 556 | else: |
| 588 | 557 | $caption='Find Feed'; |
| 589 | 558 | ?> |
| @@ -695,9 +664,9 @@ | ||
| 695 | 664 | <div> |
| 696 | 665 | <h3>Feed Information</h3> |
| 697 | 666 | <ul> |
| 698 | 667 | <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 <<?php echo wp_specialchars($f, 'both'); ?>> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</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 <<?php echo wp_specialchars($f, 'both'); ?>> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>"><img src="../wp-images/smilies/icon_arrow.gif" alt="(→)" /></a></li> | |
| 700 | 669 | <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li> |
| 701 | 670 | <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li> |
| 702 | 671 | </ul> |
| 703 | 672 | <div class="submit"><input type="submit" name="Use" value="« Use this feed" /></div> |
| @@ -784,9 +753,8 @@ | ||
| 784 | 753 | 'comment status', |
| 785 | 754 | 'ping status', |
| 786 | 755 | 'unfamiliar author', |
| 787 | 756 | 'unfamliar categories', |
| 788 | - 'map authors', | |
| 789 | 757 | 'update/.*', |
| 790 | 758 | 'feed/.*', |
| 791 | 759 | 'link/.*', |
| 792 | 760 | ); |
| @@ -803,11 +771,11 @@ | ||
| 803 | 771 | if (isset($GLOBALS['fwp_post']['save'])) : |
| 804 | 772 | $alter = array (); |
| 805 | 773 | |
| 806 | 774 | $meta = $link->settings; |
| 807 | - //if (isset($meta['cats'])): | |
| 808 | - // $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']); | |
| 809 | - //endif; | |
| 775 | + if (isset($meta['cats'])): | |
| 776 | + $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']); | |
| 777 | + endif; | |
| 810 | 778 | |
| 811 | 779 | // custom feed settings first |
| 812 | 780 | foreach ($GLOBALS['fwp_post']['notes'] as $mn) : |
| 813 | 781 | $mn['key0'] = trim($mn['key0']); |
| @@ -879,33 +847,10 @@ | ||
| 879 | 847 | // Unfamiliar author, unfamiliar categories |
| 880 | 848 | foreach (array("author", "category") as $what) : |
| 881 | 849 | $sfield = "unfamiliar_{$what}"; |
| 882 | 850 | if (isset($GLOBALS['fwp_post'][$sfield])) : |
| 883 | - if ('site-default'==$GLOBALS['fwp_post'][$sfield]) : | |
| 851 | + if ($GLOBALS['fwp_post'][$sfield]=='site-default') : | |
| 884 | 852 | 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 | 853 | else : |
| 909 | 854 | $meta["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield]; |
| 910 | 855 | endif; |
| 911 | 856 | endif; |
| @@ -910,80 +855,8 @@ | ||
| 910 | 855 | endif; |
| 911 | 856 | endif; |
| 912 | 857 | endforeach; |
| 913 | 858 | |
| 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 | 859 | if (isset($GLOBALS['fwp_post']['cat_split'])) : |
| 987 | 860 | if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) : |
| 988 | 861 | $meta['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']); |
| 989 | 862 | else : |
| @@ -993,20 +866,9 @@ | ||
| 993 | 866 | |
| 994 | 867 | if (is_array($meta['cats'])) : |
| 995 | 868 | $meta['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['cats']); |
| 996 | 869 | 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 | - | |
| 870 | + | |
| 1009 | 871 | $notes = ''; |
| 1010 | 872 | foreach ($meta as $key => $value) : |
| 1011 | 873 | $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n"; |
| 1012 | 874 | endforeach; |
| @@ -1098,25 +960,8 @@ | ||
| 1098 | 960 | o = document.getElementById('basics-hardcode-'+item); |
| 1099 | 961 | if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; } |
| 1100 | 962 | else { ed.style.display='none'; view.style.display='inline'; } |
| 1101 | 963 | } |
| 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 | 964 | </script> |
| 1120 | 965 | |
| 1121 | 966 | <?php if ($updated_link) : ?> |
| 1122 | 967 | <div class="updated"><p>Syndicated feed settings updated.</p></div> |
| @@ -1128,15 +973,15 @@ | ||
| 1128 | 973 | <input type="hidden" name="action" value="linkedit" /> |
| 1129 | 974 | <input type="hidden" name="save" value="link" /> |
| 1130 | 975 | |
| 1131 | 976 | <h2>Edit a syndicated feed:</h2> |
| 1132 | -<fieldset class="options"><legend>Basics</legend> | |
| 977 | +<fieldset><legend>Basics</legend> | |
| 1133 | 978 | <table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 1134 | 979 | <tr> |
| 1135 | 980 | <th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 1136 | 981 | <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 <<?php echo wp_specialchars($link_rss_uri, 'both'); ?>> for validity">validate</a>) | |
| 982 | +<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>" | |
| 983 | +title="Check feed <<?php echo wp_specialchars($link_rss_uri, 'both'); ?>> for validity"><img src="../wp-images/smilies/icon_arrow.gif" alt="→" /></a> | |
| 1139 | 984 | </td> |
| 1140 | 985 | <td width="20%"><input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /></td> |
| 1141 | 986 | </tr> |
| 1142 | 987 | <tr> |
| @@ -1223,9 +1068,9 @@ | ||
| 1223 | 1068 | <p class="submit"> |
| 1224 | 1069 | <input type="submit" name="submit" value="<?php _e('Save Changes »') ?>" /> |
| 1225 | 1070 | </p> |
| 1226 | 1071 | |
| 1227 | -<fieldset class="options"> | |
| 1072 | +<fieldset> | |
| 1228 | 1073 | <legend>Syndicated Posts</legend> |
| 1229 | 1074 | |
| 1230 | 1075 | <?php fwp_category_box($dogs, 'all syndicated posts from this feed'); ?> |
| 1231 | 1076 | |
| @@ -1273,91 +1118,27 @@ | ||
| 1273 | 1118 | <p class="submit"> |
| 1274 | 1119 | <input type="submit" name="submit" value="<?php _e('Save Changes »') ?>" /> |
| 1275 | 1120 | </p> |
| 1276 | 1121 | |
| 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 »') ?>" /> | |
| 1349 | -</p> | |
| 1350 | - | |
| 1351 | 1122 | <fieldset> |
| 1352 | 1123 | <legend>Advanced Feed Options</legend> |
| 1353 | 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> | |
| 1354 | 1135 | |
| 1355 | 1136 | <tr> |
| 1356 | 1137 | <th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th> |
| 1357 | 1138 | <td width="80%"><ul style="margin: 0; list-style:none"> |
| 1358 | 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> |
| 1359 | -(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li> | |
| 1140 | +(currently <strong><?php echo FeedWordPress::on_unfamiliar('category');; ?></strong>)</label></li> | |
| 1360 | 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> |
| 1361 | 1142 | <li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories</label></li> |
| 1362 | 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> |
| 1363 | 1144 | </ul></td> |
| @@ -1427,21 +1208,8 @@ | ||
| 1427 | 1208 | endif; |
| 1428 | 1209 | return false; // Don't continue |
| 1429 | 1210 | } |
| 1430 | 1211 | |
| 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 | 1212 | function fwp_multidelete_page () { |
| 1445 | 1213 | global $wpdb; |
| 1446 | 1214 | |
| 1447 | 1215 | check_admin_referer(); // Make sure the referers are kosher |
| @@ -1854,15 +1622,12 @@ | ||
| 1854 | 1622 | |
| 1855 | 1623 | function on_unfamiliar ($what = 'author', $override = NULL) { |
| 1856 | 1624 | $set = array('create', 'default', 'filter'); |
| 1857 | 1625 | |
| 1858 | - if (is_string($override)) : | |
| 1859 | - $ret = strtolower($override); | |
| 1860 | - endif; | |
| 1861 | - | |
| 1862 | - if (!is_numeric($override) and !in_array($ret, $set)) : | |
| 1626 | + $ret = strtolower($override); | |
| 1627 | + if (!in_array($ret, $set)) : | |
| 1863 | 1628 | $ret = get_option('feedwordpress_unfamiliar_'.$what); |
| 1864 | - if (!is_numeric($ret) and !in_array($ret, $set)) : | |
| 1629 | + if (!in_array($ret, $set)) : | |
| 1865 | 1630 | $ret = 'create'; |
| 1866 | 1631 | endif; |
| 1867 | 1632 | endif; |
| 1868 | 1633 | |
| @@ -2583,89 +2348,86 @@ | ||
| 2583 | 2348 | $author = $wpdb->escape($author); |
| 2584 | 2349 | $email = $wpdb->escape($email); |
| 2585 | 2350 | $url = $wpdb->escape($url); |
| 2586 | 2351 | |
| 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 | - | |
| 2352 | + // Look for an existing author record that fits... | |
| 2353 | + if (!isset($wp_db_version)) : | |
| 2605 | 2354 | #-- 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 | - ) | |
| 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|\$)' | |
| 2626 | 2373 | ) |
| 2627 | - "); | |
| 2628 | - | |
| 2374 | + ) | |
| 2375 | + "); | |
| 2376 | + elseif ($wp_db_version >= 2966) : | |
| 2629 | 2377 | #-- WordPress 2.0+ |
| 2630 | - elseif ($wp_db_version >= 2966) : | |
| 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 | + "); | |
| 2631 | 2390 | |
| 2632 | - // First try the user core data table. | |
| 2391 | + if (is_null($id)) : # Then look for aliases in the user meta data table | |
| 2633 | 2392 | $id = $wpdb->get_var( |
| 2634 | - "SELECT ID FROM $wpdb->users | |
| 2393 | + "SELECT user_id FROM $wpdb->usermeta | |
| 2635 | 2394 | WHERE |
| 2636 | - TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) | |
| 2395 | + (meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('$author'))) | |
| 2637 | 2396 | OR ( |
| 2638 | - LENGTH(TRIM(LCASE(user_email))) > 0 | |
| 2639 | - AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email')) | |
| 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 | + ) | |
| 2640 | 2404 | ) |
| 2641 | - OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) | |
| 2642 | 2405 | "); |
| 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 | 2406 | endif; |
| 2407 | + endif; | |
| 2662 | 2408 | |
| 2663 | - // ... if you don't find one, then do what you need to do | |
| 2664 | - if (is_null($id)) : | |
| 2665 | - if ($unfamiliar_author === 'create') : | |
| 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+ | |
| 2666 | 2428 | $userdata = array(); |
| 2667 | - | |
| 2429 | + | |
| 2668 | 2430 | #-- user table data |
| 2669 | 2431 | $userdata['ID'] = NULL; // new user |
| 2670 | 2432 | $userdata['user_login'] = $login; |
| 2671 | 2433 | $userdata['user_nicename'] = $nice_author; |
| @@ -2672,21 +2434,15 @@ | ||
| 2672 | 2434 | $userdata['user_pass'] = substr(md5(uniqid(microtime())), 0, 6); // just something random to lock it up |
| 2673 | 2435 | $userdata['user_email'] = $email; |
| 2674 | 2436 | $userdata['user_url'] = $url; |
| 2675 | 2437 | $userdata['display_name'] = $author; |
| 2676 | - | |
| 2438 | + | |
| 2677 | 2439 | $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 | 2440 | endif; |
| 2441 | + elseif ($unfamiliar_author === 'default') : | |
| 2442 | + $id = 1; | |
| 2683 | 2443 | endif; |
| 2684 | 2444 | endif; |
| 2685 | - | |
| 2686 | - if ($id) : | |
| 2687 | - $this->link->settings['map authors']['name'][strtolower(trim($author))] = $id; | |
| 2688 | - endif; | |
| 2689 | 2445 | return $id; |
| 2690 | 2446 | } // function SyndicatedPost::author_id () |
| 2691 | 2447 | |
| 2692 | 2448 | // look up (and create) category ids from a list of categories |
| @@ -3037,24 +2793,8 @@ | ||
| 3037 | 2793 | |
| 3038 | 2794 | if (isset($this->settings['cats'])): |
| 3039 | 2795 | $this->settings['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $this->settings['cats']); |
| 3040 | 2796 | 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 | 2797 | endif; |
| 3058 | 2798 | } // SyndicatedLink::SyndicatedLink () |
| 3059 | 2799 | |
| 3060 | 2800 | function found () { |
| @@ -3130,19 +2870,8 @@ | ||
| 3130 | 2870 | |
| 3131 | 2871 | if (is_array($to_notes['cats'])) : |
| 3132 | 2872 | $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']); |
| 3133 | 2873 | 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 | 2874 | unset($to_notes['link/id']); unset($to_notes['link/uri']); |
| 3146 | 2875 | unset($to_notes['link/name']); |
| 3147 | 2876 | unset($to_notes['hardcode categories']); // Deprecated |
| 3148 | 2877 | |
| @@ -3170,43 +2899,8 @@ | ||
| 3170 | 2899 | if ( $new !== false ) $new_count[$new]++; |
| 3171 | 2900 | endif; |
| 3172 | 2901 | endforeach; |
| 3173 | 2902 | 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 | 2903 | endif; |
| 3210 | 2904 | return $new_count; |
| 3211 | 2905 | } /* SyndicatedLink::poll() */ |
| 3212 | 2906 | |
| @@ -3262,9 +2956,9 @@ | ||
| 3262 | 2956 | endif; |
| 3263 | 2957 | return $ret; |
| 3264 | 2958 | } /* SyndicatedLink::ttl() */ |
| 3265 | 2959 | |
| 3266 | - // SyndicatedLink::flatten_array (): flatten an array. Useful for | |
| 2960 | + // SyndicatedLink:flatten_array (): flatten an array. Useful for | |
| 3267 | 2961 | // hierarchical and namespaced elements. |
| 3268 | 2962 | // |
| 3269 | 2963 | // Given an array which may contain array or object elements in it, |
| 3270 | 2964 | // return a "flattened" array: a one-dimensional array of scalars |