PluginProbe
FeedWordPress / 2011.0211
FeedWordPress v2011.0211
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | authors-page.php +130 -216 trunk2011.0211 View file →
@@ -1,66 +1,45 @@
1 1 <?php
2 -require_once dirname(__FILE__) . '/admin-ui.php';
2 +require_once(dirname(__FILE__) . '/admin-ui.php');
3 3
4 4 class FeedWordPressAuthorsPage extends FeedWordPressAdminPage {
5 5 var $authorlist = NULL;
6 6 var $rule_count = 0;
7 -
8 - /**
9 - * Class constructor
10 - *
11 - * @param int $link ID of the feed in the Links.
12 - */
13 - public function __construct( $link = -1 ) {
14 - if ( is_numeric( $link ) and -1 == $link ) :
15 - $link = $this->submitted_link();
7 +
8 + function FeedWordPressAuthorsPage ($link = -1) {
9 + if (is_numeric($link) and -1 == $link) :
10 + $link = FeedWordPressAdminPage::submitted_link();
16 11 endif;
17 12
18 - parent::__construct( 'feedwordpressauthors', $link );
13 + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressauthors', $link);
19 14 $this->refresh_author_list();
20 15 $this->dispatch = 'feedwordpress_author_settings';
21 16 $this->filename = __FILE__;
22 17
23 18 $this->pagenames = array(
24 - 'default' => 'Authors',
19 + 'default' => 'Authors',
25 20 'settings-update' => 'Syndicated Authors',
26 - 'open-sheet' => 'Syndicated Author',
21 + 'open-sheet' => 'Syndicated Author',
27 22 );
28 - } /* construct() */
29 -
30 - /**
31 - * Refreshes the author list and optionally sort it with the natural
32 - * alphanumeric sort algorithm.
33 - */
34 - function refresh_author_list() {
23 + }
24 +
25 + function refresh_author_list () {
35 26 $this->authorlist = fwp_author_list();
27 + }
28 +
29 + /*static*/ function syndicated_authors_box ($page, $box = NULL) {
30 + $link = $page->link;
31 + $unfamiliar = array ('create' => '','default' => '','filter' => '');
36 32
37 - // Case-insensitive "natural" alphanumeric sort. Preserves key/value associations.
38 - if ( function_exists( 'natcasesort' ) ) :
39 - natcasesort( $this->authorlist );
40 - endif;
41 - } /* FeedWordPressAuthorsPage::refresh_author_list) */
42 -
43 - /**
44 - * Displays the page box for the syndicated authors.
45 - *
46 - * @param FeedWordPressAuthorsPage $page FWP dashboard page.
47 - * @param string|null $box Page box (unused).
48 - */
49 - /*static*/ function syndicated_authors_box( $page, $box = NULL ) {
50 - /** @var SyndicatedLink|null An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings. */
51 - $link = $page->link; // unused? (gwyneth 20230920)
52 - $unfamiliar = array( 'create' => '','default' => '','filter' => '' );
53 -
54 - if ( $page->for_feed_settings() ) :
55 - $key = $this->link->setting( 'unfamiliar author', NULL, 'site-default' );
33 + if ($page->for_feed_settings()) :
34 + $key = $this->link->setting('unfamiliar author', NULL, 'site-default');
56 35 $unfamiliar['site-default'] = '';
57 36 else :
58 37 $key = FeedWordPress::on_unfamiliar('author');
59 38 endif;
60 - $unfamiliar[$key] = true;
39 + $unfamiliar[$key] = ' selected="selected"';
61 40
62 - $match_author_by_email = ! ( 'yes' == get_option( "feedwordpress_do_not_match_author_by_email" ) );
41 + $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
63 42 $null_emails = FeedWordPress::null_email_set();
64 43
65 44 // Hey ho, let's go...
66 45 ?>
@@ -65,30 +44,8 @@
65 44 // Hey ho, let's go...
66 45 ?>
67 46 <table class="form-table">
68 47 <?php
69 -if ( $page->for_default_settings() ) :
70 -?>
71 -<tr><th>Unmatched authors</th>
72 -<td><span>Authors who haven&rsquo;t been syndicated before</span>
73 - <select style="max-width: 27.0em" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');">
74 - <option value="create"<?php fwp_selected_flag($unfamiliar, 'create'); ?>>will have a new author account created for them</option>
75 - <?php foreach ($page->authorlist as $author_id => $author_name) :
76 - if ( !isset($unfamiliar[$author_id])) : $unfamiliar[$author_id] = false; endif;
77 - ?>
78 - <option value="<?php echo esc_attr($author_id); ?>"<?php fwp_selected_flag($unfamiliar, $author_id); ?>>will have their posts attributed to <?php echo esc_html($author_name); ?></option>
79 - <?php endforeach; ?>
80 - <option value="newuser">will have their posts attributed to a new user...</option>
81 - <option value="filter"<?php fwp_selected_flag($unfamiliar, 'filter'); ?>>get filtered out</option>
82 - </select>
83 -
84 - <span id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></span></p>
85 - </td>
86 -</tr>
87 -
88 -<?php
89 -endif;
90 -
91 48 if ($page->for_feed_settings()) :
92 49 $map = $this->link->setting('map authors', NULL, array());
93 50 ?>
94 51 <tr><th>Matching authors</th>
@@ -97,25 +54,23 @@
97 54 <ul class="settings">
98 55 <li><p><input type="radio" name="author_rules_name[all]" value="*"
99 56 <?php if (isset($map['name']['*'])) : $author_action = $map['name']['*']; ?>
100 57 checked="checked"
101 -<?php
102 - else :
103 - $author_action = NULL;
104 - endif; ?>
58 +<?php else : $author_action = NULL; ?>
59 +<?php endif; ?>
105 60 /> All posts syndicated
106 61 from this feed <select class="author-rules" id="author-rules-all"
107 62 name="author_rules_action[all]" onchange="contextual_appearance('author-rules-all', 'author-rules-all-newuser', 'author-rules-all-default', 'newuser', 'inline');">
108 63 <?php foreach ($page->authorlist as $local_author_id => $local_author_name) : ?>
109 - <option value="<?php echo esc_attr($local_author_id); ?>"<?php fwp_selected_flag($local_author_id==$author_action); ?>>are assigned to <?php echo esc_html($local_author_name); ?></option>
64 + <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>
110 65 <?php endforeach; ?>
111 66 <option value="newuser">will be assigned to a new user...</option>
112 - <option value="filter"<?php fwp_selected_flag('filter'==$author_action); ?>>get filtered out</option>
67 + <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
113 68 </select>
114 69 <span class="author-rules-newuser" id="author-rules-all-newuser">named
115 70 <input type="text" name="author_rules_newuser[all]" value="" /></span></p></li>
116 71 <li><p><input type="radio" name="author_rules_name[all]" value=""
117 -<?php if ( !isset($map['name']['*'])) : ?>
72 +<?php if (!isset($map['name']['*'])) : ?>
118 73 checked="checked"
119 74 <?php endif; ?>
120 75 /> Attribute posts to authors based on automatic mapping rules. (Blank out a
121 76 name to delete the rule. Fill in a new name at the bottom to create a new rule.)</p>
@@ -128,23 +83,22 @@
128 83 $page->rule_count=0;
129 84 foreach ($this->link->settings['map authors'] as $author_rules) :
130 85 foreach ($author_rules as $author_name => $author_action) :
131 86 if ($author_name != '*') :
132 - $page->rule_count++;
133 - $authorRulesId = sanitize_html_class(sprintf("author-rules-%d", $page->rule_count));
87 + $page->rule_count++;
134 88 ?>
135 89 <tr>
136 -<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="author_rules_name[]" value="<?php echo esc_attr($author_name); ?>" size="11" /></th>
90 +<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" size="11" /></th>
137 91 <td>
138 - <select class="author-rules" id="<?php echo esc_attr($authorRulesId); ?>" name="author_rules_action[]" onchange="contextual_appearance('<?php echo esc_attr($authorRulesId); ?>', '<?php echo esc_attr($authorRulesId); ?>-newuser', '<?php echo esc_attr($authorRulesId); ?>-default', 'newuser', 'inline');">
92 + <select class="author-rules" id="author-rules-<?php echo $page->rule_count; ?>" name="author_rules_action[]" onchange="contextual_appearance('author-rules-<?php echo $page->rule_count; ?>', 'author-rules-<?php echo $page->rule_count; ?>-newuser', 'author-rules-<?php echo $page->rule_count; ?>-default', 'newuser', 'inline');">
139 93 <?php foreach ($page->authorlist as $local_author_id => $local_author_name) : ?>
140 - <option value="<?php echo esc_attr($local_author_id); ?>"<?php fwp_selected_flag($local_author_id==$author_action); ?>>are assigned to <?php echo esc_attr($local_author_name); ?></option>
94 + <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>
141 95 <?php endforeach; ?>
142 96 <option value="newuser">will be assigned to a new user...</option>
143 - <option value="filter"<?php fwp_selected_flag('filter'==$author_action); ?>>get filtered out</option>
97 + <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
144 98 </select>
145 -
146 - <span class="author-rules-newuser" id="<?php echo esc_attr($authorRulesId); ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></span>
99 +
100 + <span class="author-rules-newuser" id="author-rules-<?php echo $page->rule_count; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></span>
147 101 </td>
148 102 </tr>
149 103 <?php
150 104 endif;
@@ -157,14 +111,14 @@
157 111 <th style="text-align: left; width: 15.0em">Posts by <input type="text" name="add_author_rule_name" size="11" /></th>
158 112 <td>
159 113 <select id="add-author-rule" name="add_author_rule_action" onchange="contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');">
160 114 <?php foreach ($page->authorlist as $author_id => $author_name) : ?>
161 - <option value="<?php echo esc_attr($author_id); ?>">are assigned to <?php echo esc_html($author_name); ?></option>
115 + <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
162 116 <?php endforeach; ?>
163 117 <option value="newuser">will be assigned to a new user...</option>
164 118 <option value="filter">get filtered out</option>
165 119 </select>
166 -
120 +
167 121 <span id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></span>
168 122 </td>
169 123 </tr>
170 124
@@ -173,16 +127,16 @@
173 127 <td>
174 128 <span>Authors who haven't been syndicated before</span>
175 129 <select style="max-width: 27.0em" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');">
176 130 <?php if ($page->for_feed_settings()) : ?>
177 - <option value="site-default"<?php fwp_selected_flag($unfamiliar, 'site-default'); ?>>are handled according to the default for all feeds</option>
131 + <option value="site-default"<?php print $unfamiliar['site-default']; ?>>are handled according to the default for all feeds</option>
178 132 <?php endif; ?>
179 - <option value="create"<?php fwp_selected_flag($unfamiliar, 'create'); ?>>will have a new author account created for them</option>
180 - <?php foreach ( $page->authorlist as $author_id => $author_name ) : ?>
181 - <option value="<?php echo esc_attr($author_id); ?>"<?php fwp_selected_flag($unfamiliar, $author_id); ?>>will have their posts attributed to <?php echo esc_html($author_name); ?></option>
133 + <option value="create"<?php print $unfamiliar['create']; ?>>will have a new author account created for them</option>
134 + <?php foreach ($page->authorlist as $author_id => $author_name) : ?>
135 + <option value="<?php echo $author_id; ?>"<?php print (isset($unfamiliar[$author_id]) ? $unfamiliar[$author_id] : ''); ?>>will have their posts attributed to <?php echo $author_name; ?></option>
182 136 <?php endforeach; ?>
183 137 <option value="newuser">will have their posts attributed to a user named ...</option>
184 - <option value="filter"<?php fwp_selected_flag($unfamiliar, 'filter'); ?>>get filtered out</option>
138 + <option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option>
185 139 </select>
186 140
187 141 <span id="unfamiliar-author-newuser"><input type="text" name="unfamiliar_author_newuser" value="" /></span></p>
188 142 </td>
@@ -193,17 +147,17 @@
193 147 </td>
194 148 </tr>
195 149 <?php endif; ?>
196 150
197 -<?php if ( $page->for_default_settings() ) : ?>
151 +<?php if ($page->for_default_settings()) : ?>
198 152 <tr>
199 153 <th scope="row">Matching Authors</th>
200 154 <td><ul style="list-style: none; margin: 0; padding: 0;">
201 -<li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php fwp_selected_flag($match_author_by_email, null, "checked"); ?> onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div>
155 +<li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php if ($match_author_by_email) : ?>checked="checked" <?php endif; ?>onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div>
202 156 <div id="unless-null-email">
203 157 <p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p>
204 158 <textarea name="null_emails" rows="3" style="width: 100%">
205 -<?php print esc_html(implode("\n", $null_emails)); ?>
159 +<?php print implode("\n", $null_emails); ?>
206 160 </textarea>
207 161 </div></li>
208 162 </ul></td>
209 163 </tr>
@@ -210,18 +164,11 @@
210 164 <?php endif; ?>
211 165 </tbody>
212 166 </table>
213 167 <?php
214 - } /* FeedWordPressAuthorsPage::syndicated_authors_box() */
215 -
216 - /**
217 - * Displays a box for fixing mismatched authors.
218 - *
219 - * @param FeedWordPressAuthorsPage $page FWP dashboard page.
220 - * @param string|null $box Page box (unused).
221 - */
222 - /*static*/ function fix_authors_box( $page, $box = NULL )
223 - {
168 + } /* FeedWordPressAuthorsPage::syndicated_authors_box () */
169 +
170 + /*static*/ function fix_authors_box ($page, $box = NULL) {
224 171 ?>
225 172 <table class="form-table">
226 173 <tbody>
227 174 <tr>
@@ -227,16 +174,16 @@
227 174 <tr>
228 175 <th scope="row">Fixing mis-matched authors:</th>
229 176 <td><p style="margin: 0.5em 0px">Take all the posts from this feed attributed to
230 177 <select name="fix_mismatch_from">
231 - <?php foreach ( $page->authorlist as $author_id => $author_name ) : ?>
232 - <option value="<?php echo esc_attr( $author_id ); ?>"><?php echo esc_html( $author_name ); ?></option>
178 + <?php foreach ($page->authorlist as $author_id => $author_name) : ?>
179 + <option value="<?php echo $author_id; ?>"><?php echo $author_name; ?></option>
233 180 <?php endforeach; ?>
234 181 </select>
235 182 and instead
236 183 <select id="fix-mismatch-to" name="fix_mismatch_to" onchange="contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');">
237 184 <?php foreach ($page->authorlist as $author_id => $author_name) : ?>
238 - <option value="<?php echo esc_attr($author_id); ?>">re-assign them to <?php echo esc_html($author_name); ?></option>
185 + <option value="<?php echo $author_id; ?>">re-assign them to <?php echo $author_name; ?></option>
239 186 <?php endforeach; ?>
240 187 <option value="newuser">re-assign them to a new user...</option>
241 188 <option value="filter">delete them</option>
242 189 </select>
@@ -247,11 +194,11 @@
247 194 </tr>
248 195 </tbody>
249 196 </table>
250 197 <?php
251 - } /* FeedWordPressAuthorsPage::fix_authors_box() */
198 + } /* FeedWordPressAuthorsPage::fix_authors_box () */
252 199
253 - function display() {
200 + function display () {
254 201 $this->boxes_by_methods = array(
255 202 'syndicated_authors_box' => __('Syndicated Authors'),
256 203 'fix_authors_box' => __('Reassign Authors'),
257 204 );
@@ -280,47 +227,28 @@
280 227 </script>
281 228 <?php endif;
282 229 } /* FeedWordPressAuthorsPage::display () */
283 230
284 - /**
285 - * Checks if a mismatch fix was requested.
286 - *
287 - * @return bool True if a fix was requested and not empty.
288 - */
289 - public function fix_mismatch_requested() {
290 - /** @var string|null */
291 - $fix = FeedWordPress::post( 'fix_mismatch' );
292 - return ( ! is_null( $fix ) && strlen( $fix ) > 0 ); // possibly the same as `( ! empty( $fix ) )`.
293 - } /* FeedWordPressAuthorsPage::fix_mismatch_requested() */
294 -
295 - /**
296 - * If a mismatch fix was requested, handles it here;
297 - * else sends it to the parent class for processing.
298 - */
299 - public function accept_POST() {
300 - if ( self::fix_mismatch_requested() ) :
301 - $this->fix_mismatch();
231 + function accept_POST ($post) {
232 + if (isset($post['fix_mismatch']) and (strlen($post['fix_mismatch']) > 0)) :
233 + $this->fix_mismatch($post);
302 234 else :
303 - parent::accept_POST();
235 + parent::accept_POST($post);
304 236 endif;
305 - } /* FeedWordPressAuthorsPage::accept_POST() */
237 + }
306 238
307 - /**
308 - * Fixes an author mismatch.
309 - */
310 - function fix_mismatch() {
239 + function fix_mismatch ($post) {
311 240 global $wpdb;
312 241
313 - $to = FeedWordPress::post( 'fix_mismatch_to' );
314 -// if ( 'newuser' === $fix_to ) : // will _always_ be false, since $fix_to is not called from anywhere (gwyneth 20230915)
315 - if ( 'newuser' === $to ) : // probably this is what was intended! (gwyneth 20230920)
316 - $newuser_name = trim( FeedWordPress::post( 'fix_mismatch_to_newuser', '' ) );
317 - $to = fwp_insert_new_user( $newuser_name );
242 + if ('newuser'==$post['fix_mismatch_to']) :
243 + $newuser_name = trim($post['fix_mismatch_to_newuser']);
244 + $to = fwp_insert_new_user($newuser_name);
245 + else :
246 + $to = $post['fix_mismatch_to'];
318 247 endif;
319 248
320 - $from = (int) FeedWordPress::post( 'fix_mismatch_from' );
321 - if ( is_numeric( $from ) ) :
322 -
249 + $from = (int) $post['fix_mismatch_from'];
250 + if (is_numeric($from)) :
323 251 // Make a list of all the items by this author
324 252 // syndicated from this feed...
325 253 $post_ids = $wpdb->get_col("
326 254 SELECT {$wpdb->posts}.id
@@ -329,38 +257,35 @@
329 257 AND {$wpdb->postmeta}.meta_key = 'syndication_feed_id'
330 258 AND {$wpdb->postmeta}.meta_value = '{$this->link->id}'
331 259 AND {$wpdb->posts}.post_author = '{$from}'
332 260 ");
261 +
262 + if (count($post_ids) > 0) :
263 + $N = count($post_ids);
264 + $posts = 'post'.(($N==1) ? '' : 's');
333 265
334 - if ( count( $post_ids ) > 0 ) :
335 - $N = count( $post_ids );
336 -
337 - // $posts = 'post'.(($N==1) ? '' : 's'); // Wordpress has _n() for plurals... (gwyneth 20230920)
338 - $posts = sprintf( _n( '%s post', '%s posts', $N, 'text-domain' ), number_format_i18n( $N ) );
339 -
340 266 // Re-assign them all to the correct author
341 - if ( is_numeric( $to ) ) : // re-assign to a particular user
342 - $post_set = "(" . implode( ",", $post_ids ) . ")";
343 -
267 + if (is_numeric($to)) : // re-assign to a particular user
268 + $post_set = "(".implode(",", $post_ids).")";
269 +
344 270 // Getting the revisions too, if there are any
345 271 $parent_in_clause = "OR {$wpdb->posts}.post_parent IN $post_set";
346 -
272 +
347 273 $wpdb->query("
348 - UPDATE {$wpdb->posts}
349 - SET post_author='{$to}'
350 - WHERE ({$wpdb->posts}.id IN $post_set
351 - $parent_in_clause)
274 + UPDATE {$wpdb->posts}
275 + SET post_author='{$to}'
276 + WHERE ({$wpdb->posts}.id IN $post_set
277 + $parent_in_clause)
352 278 ");
353 - // $this->mesg = sprintf(__("Re-assigned %d {$posts}."), $N); // see comment abpve
354 - $this->mesg = __( "Re-assigned " ) . $posts;
279 + $this->mesg = sprintf(__("Re-assigned %d ${posts}."), $N);
355 280
356 281 // ... and kill them all
357 - elseif ( 'filter' == $to ) :
358 - foreach ( $post_ids as $post_id ) :
359 - wp_delete_post( $post_id );
282 + elseif ('filter'==$to) :
283 + foreach ($post_ids as $post_id) :
284 + wp_delete_post($post_id);
360 285 endforeach;
361 -
362 - $this->mesg = __( "Deleted " ) . $posts;
286 +
287 + $this->mesg = sprintf(__("Deleted %d ${posts}."), $N);
363 288 endif;
364 289 else :
365 290 $this->mesg = __("Couldn't find any posts that matched your criteria.");
366 291 endif;
@@ -365,58 +290,51 @@
365 290 $this->mesg = __("Couldn't find any posts that matched your criteria.");
366 291 endif;
367 292 endif;
368 293 $this->updated = false;
369 - } /* FeedWordPressAuthorsPage::fix_mismatch() */
294 + }
370 295
371 - /**
372 - * Presumably saves settings...
373 - *
374 - * @return void description
375 - */
376 - function save_settings () {
296 + function save_settings ($post) {
297 +
377 298 if ($this->for_feed_settings()) :
378 - // $alter = array(); // what is this array? It's never used. (gwyneth 20230920)
299 + $alter = array ();
379 300
380 301 // Unfamiliar author rule
381 - $unfamiliar_author = FeedWordPress::post( 'unfamiliar_author' );
382 - if ( ! is_null( $unfamiliar_author ) ) :
383 - if ( 'newuser' == $unfamiliar_author ) :
384 - $new_name = trim( FeedWordPress::post( "unfamiliar_author_newuser" ) );
385 - $this->link->map_name_to_new_user(/*name=*/ null, $new_name);
302 + if (isset($post["unfamiliar_author"])) :
303 + if ('newuser'==$post['unfamiliar_author']) :
304 + $new_name = trim($post["unfamiliar_author_newuser"]);
305 + $this->link->map_name_to_new_user(/*name=*/ NULL, $new_name);
386 306 else :
387 307 $this->link->update_setting(
388 308 "unfamiliar author",
389 - $unfamiliar_author,
309 + $post['unfamiliar_author'],
390 310 'site-default'
391 311 );
392 312 endif;
393 313 endif;
394 -
314 +
395 315 // Handle author mapping rules
396 - $author_rules_name = FeedWordPress::post( 'author_rules_name' );
397 - $author_rules_action = FeedWordPress::post('author_rules_action' );
398 - if ( ! ( is_null( $author_rules_name ) || is_null( $author_rules_action ) ) ) :
399 - if ( isset( $author_rules_name['all'] ) ) :
400 - if ( strlen( $author_rules_name['all']) > 0 ) :
401 - $author_rules_name = array(
402 - 'all' => $author_rules_name['all'],
316 + if (isset($post['author_rules_name'])
317 + and isset($post['author_rules_action'])) :
318 + if (isset($post['author_rules_name']['all'])) :
319 + if (strlen($post['author_rules_name']['all']) > 0) :
320 + $post['author_rules_name'] = array(
321 + 'all' => $post['author_rules_name']['all'],
403 322 );
404 -
323 +
405 324 // Erase all the rest.
406 325 endif;
407 326 endif;
408 -
327 +
409 328 unset($this->link->settings['map authors']);
410 - foreach ($author_rules_name as $key => $name) :
329 + foreach ($post['author_rules_name'] as $key => $name) :
411 330 // Normalize for case and whitespace
412 - $name = strtolower( trim( $name ) );
413 - $author_action = strtolower( trim( $author_rules_action[$key] ) );
414 -
415 - $author_rules_newuser = FeedWordPress::post('author_rules_newuser' );
416 - if ( strlen($name) > 0 ) :
417 - if ( 'newuser' == $author_action ) :
418 - $new_name = trim( $author_rules_newuser[ $key ] );
331 + $name = strtolower(trim($name));
332 + $author_action = strtolower(trim($post['author_rules_action'][$key]));
333 +
334 + if (strlen($name) > 0) :
335 + if ('newuser' == $author_action) :
336 + $new_name = trim($post['author_rules_newuser'][$key]);
419 337 $this->link->map_name_to_new_user($name, $new_name);
420 338 else :
421 339 $this->link->settings['map authors']['name'][$name] = $author_action;
422 340 endif;
@@ -423,17 +341,16 @@
423 341 endif;
424 342 endforeach;
425 343 endif;
426 344
427 - $name = FeedWordPress::post( 'add_author_rule_name');
428 - $author_action = FeedWordPress::post( 'add_author_rule_action' );
429 - if ( ! ( is_null( $name ) || is_null( $author_action ) ) ) :
430 - $name = strtolower( trim( $name ) );
431 - $author_action = strtolower( trim( $author_action ) );
432 -
345 + if (isset($post['add_author_rule_name'])
346 + and isset($post['add_author_rule_action'])) :
347 + $name = strtolower(trim($post['add_author_rule_name']));
348 + $author_action = strtolower(trim($post['add_author_rule_action']));
349 +
433 350 if (strlen($name) > 0) :
434 351 if ('newuser' == $author_action) :
435 - $new_name = trim( FeedWordPress::post( 'add_author_rule_newuser' ));
352 + $new_name = trim($post['add_author_rule_newuser']);
436 353 $this->link->map_name_to_new_user($name, $new_name);
437 354 else :
438 355 $this->link->settings['map authors']['name'][$name] = $author_action;
439 356 endif;
@@ -438,41 +355,38 @@
438 355 $this->link->settings['map authors']['name'][$name] = $author_action;
439 356 endif;
440 357 endif;
441 358 endif;
442 -
443 359 else :
444 -
445 - $unfamiliar_author = FeedWordPress::post( 'unfamiliar_author' );
446 - if ( 'newuser' === $unfamiliar_author ) :
447 - $new_name = FeedWordPress::post( 'unfamiliar_author_newuser' );
448 - $new_id = fwp_insert_new_user( trim( $new_name ) );
449 - if ( is_numeric( $new_id ) ) :
450 - update_option( 'feedwordpress_unfamiliar_author', $new_id );
360 + if ('newuser'==$post['unfamiliar_author']) :
361 + $new_name = trim($post['unfamiliar_author_newuser']);
362 + $new_id = fwp_insert_new_user($new_name);
363 + if (is_numeric($new_id)) :
364 + update_option('feedwordpress_unfamiliar_author', $new_id);
451 365 else :
452 366 // TODO: Add some error detection and reporting
453 367 // Put WP_Error stuff into $this->mesg ?
454 368 endif;
455 369 else :
456 - update_option( 'feedwordpress_unfamiliar_author', $unfamiliar_author );
370 + update_option('feedwordpress_unfamiliar_author', $post['unfamiliar_author']);
457 371 endif;
458 372
459 - $by_email = FeedWordPress::post( 'match_author_by_email' );
460 - update_option(
461 - 'feedwordpress_do_not_match_author_by_email',
462 - ( isset( $by_email ) && 'yes' == $by_email ) ? 'no' : 'yes'
373 + update_option('feedwordpress_do_not_match_author_by_email',
374 + (isset($post['match_author_by_email'])
375 + and 'yes'==$post['match_author_by_email'])
376 + ? 'no'
377 + : 'yes'
463 378 );
464 379
465 - $null_emails = FeedWordPress::post( 'null_emails', null, 'textarea' );
466 - if ( ! is_null( $null_emails ) ) :
467 - update_option( 'feedwordpress_null_email_set', $null_emails );
380 + if (isset($post['null_emails'])) :
381 + update_option('feedwordpress_null_email_set', $post['null_emails']);
468 382 endif;
469 383 endif;
470 384
471 - parent::save_settings();
385 + parent::save_settings($post);
472 386 $this->refresh_author_list();
473 - } /* FeedWordPressAuthorsPage::save_settings() */
387 + }
388 +} /* class FeedWordPressAuthorsPage */
474 389
475 -} /* class FeedWordPressAuthorsPage */
390 + $authorsPage = new FeedWordPressAuthorsPage;
391 + $authorsPage->display();
476 392
477 -$authorsPage = new FeedWordPressAuthorsPage;
478 -$authorsPage->display();