PluginProbe
FeedWordPress / 2014.0805
FeedWordPress v2014.0805
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 +135 -196 trunk2014.0805 View file →
@@ -1,66 +1,48 @@
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();
36 27
37 28 // 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) */
29 + if (function_exists('natcasesort')) : natcasesort($this->authorlist); endif;
30 + }
31 +
32 + /*static*/ function syndicated_authors_box ($page, $box = NULL) {
33 + $link = $page->link;
34 + $unfamiliar = array ('create' => '','default' => '','filter' => '');
42 35
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' );
36 + if ($page->for_feed_settings()) :
37 + $key = $this->link->setting('unfamiliar author', NULL, 'site-default');
56 38 $unfamiliar['site-default'] = '';
57 39 else :
58 40 $key = FeedWordPress::on_unfamiliar('author');
59 41 endif;
60 - $unfamiliar[$key] = true;
42 + $unfamiliar[$key] = ' selected="selected"';
61 43
62 - $match_author_by_email = ! ( 'yes' == get_option( "feedwordpress_do_not_match_author_by_email" ) );
44 + $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
63 45 $null_emails = FeedWordPress::null_email_set();
64 46
65 47 // Hey ho, let's go...
66 48 ?>
@@ -65,21 +47,19 @@
65 47 // Hey ho, let's go...
66 48 ?>
67 49 <table class="form-table">
68 50 <?php
69 -if ( $page->for_default_settings() ) :
51 +if ($page->for_default_settings()) :
70 52 ?>
71 53 <tr><th>Unmatched authors</th>
72 -<td><span>Authors who haven&rsquo;t been syndicated before</span>
54 +<td><span>Authors who haven&#8217;t been syndicated before</span>
73 55 <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>
56 + <option value="create"<?php print $unfamiliar['create']; ?>>will have a new author account created for them</option>
57 + <?php foreach ($page->authorlist as $author_id => $author_name) : ?>
58 + <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>
79 59 <?php endforeach; ?>
80 60 <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>
61 + <option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option>
82 62 </select>
83 63
84 64 <span id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></span></p>
85 65 </td>
@@ -105,17 +85,17 @@
105 85 /> All posts syndicated
106 86 from this feed <select class="author-rules" id="author-rules-all"
107 87 name="author_rules_action[all]" onchange="contextual_appearance('author-rules-all', 'author-rules-all-newuser', 'author-rules-all-default', 'newuser', 'inline');">
108 88 <?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>
89 + <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 90 <?php endforeach; ?>
111 91 <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>
92 + <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
113 93 </select>
114 94 <span class="author-rules-newuser" id="author-rules-all-newuser">named
115 95 <input type="text" name="author_rules_newuser[all]" value="" /></span></p></li>
116 96 <li><p><input type="radio" name="author_rules_name[all]" value=""
117 -<?php if ( !isset($map['name']['*'])) : ?>
97 +<?php if (!isset($map['name']['*'])) : ?>
118 98 checked="checked"
119 99 <?php endif; ?>
120 100 /> Attribute posts to authors based on automatic mapping rules. (Blank out a
121 101 name to delete the rule. Fill in a new name at the bottom to create a new rule.)</p>
@@ -128,23 +108,22 @@
128 108 $page->rule_count=0;
129 109 foreach ($this->link->settings['map authors'] as $author_rules) :
130 110 foreach ($author_rules as $author_name => $author_action) :
131 111 if ($author_name != '*') :
132 - $page->rule_count++;
133 - $authorRulesId = sanitize_html_class(sprintf("author-rules-%d", $page->rule_count));
112 + $page->rule_count++;
134 113 ?>
135 114 <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>
115 +<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 116 <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');">
117 + <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 118 <?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>
119 + <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 120 <?php endforeach; ?>
142 121 <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>
122 + <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
144 123 </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>
124 +
125 + <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 126 </td>
148 127 </tr>
149 128 <?php
150 129 endif;
@@ -157,14 +136,14 @@
157 136 <th style="text-align: left; width: 15.0em">Posts by <input type="text" name="add_author_rule_name" size="11" /></th>
158 137 <td>
159 138 <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 139 <?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>
140 + <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
162 141 <?php endforeach; ?>
163 142 <option value="newuser">will be assigned to a new user...</option>
164 143 <option value="filter">get filtered out</option>
165 144 </select>
166 -
145 +
167 146 <span id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></span>
168 147 </td>
169 148 </tr>
170 149
@@ -173,16 +152,16 @@
173 152 <td>
174 153 <span>Authors who haven't been syndicated before</span>
175 154 <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 155 <?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>
156 + <option value="site-default"<?php print $unfamiliar['site-default']; ?>>are handled according to the default for all feeds</option>
178 157 <?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>
158 + <option value="create"<?php print $unfamiliar['create']; ?>>will have a new author account created for them</option>
159 + <?php foreach ($page->authorlist as $author_id => $author_name) : ?>
160 + <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 161 <?php endforeach; ?>
183 162 <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>
163 + <option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option>
185 164 </select>
186 165
187 166 <span id="unfamiliar-author-newuser"><input type="text" name="unfamiliar_author_newuser" value="" /></span></p>
188 167 </td>
@@ -193,17 +172,17 @@
193 172 </td>
194 173 </tr>
195 174 <?php endif; ?>
196 175
197 -<?php if ( $page->for_default_settings() ) : ?>
176 +<?php if ($page->for_default_settings()) : ?>
198 177 <tr>
199 178 <th scope="row">Matching Authors</th>
200 179 <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>
180 +<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 181 <div id="unless-null-email">
203 182 <p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p>
204 183 <textarea name="null_emails" rows="3" style="width: 100%">
205 -<?php print esc_html(implode("\n", $null_emails)); ?>
184 +<?php print implode("\n", $null_emails); ?>
206 185 </textarea>
207 186 </div></li>
208 187 </ul></td>
209 188 </tr>
@@ -210,18 +189,11 @@
210 189 <?php endif; ?>
211 190 </tbody>
212 191 </table>
213 192 <?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 - {
193 + } /* FeedWordPressAuthorsPage::syndicated_authors_box () */
194 +
195 + /*static*/ function fix_authors_box ($page, $box = NULL) {
224 196 ?>
225 197 <table class="form-table">
226 198 <tbody>
227 199 <tr>
@@ -227,16 +199,16 @@
227 199 <tr>
228 200 <th scope="row">Fixing mis-matched authors:</th>
229 201 <td><p style="margin: 0.5em 0px">Take all the posts from this feed attributed to
230 202 <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>
203 + <?php foreach ($page->authorlist as $author_id => $author_name) : ?>
204 + <option value="<?php echo $author_id; ?>"><?php echo $author_name; ?></option>
233 205 <?php endforeach; ?>
234 206 </select>
235 207 and instead
236 208 <select id="fix-mismatch-to" name="fix_mismatch_to" onchange="contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');">
237 209 <?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>
210 + <option value="<?php echo $author_id; ?>">re-assign them to <?php echo $author_name; ?></option>
239 211 <?php endforeach; ?>
240 212 <option value="newuser">re-assign them to a new user...</option>
241 213 <option value="filter">delete them</option>
242 214 </select>
@@ -247,11 +219,11 @@
247 219 </tr>
248 220 </tbody>
249 221 </table>
250 222 <?php
251 - } /* FeedWordPressAuthorsPage::fix_authors_box() */
223 + } /* FeedWordPressAuthorsPage::fix_authors_box () */
252 224
253 - function display() {
225 + function display () {
254 226 $this->boxes_by_methods = array(
255 227 'syndicated_authors_box' => __('Syndicated Authors'),
256 228 'fix_authors_box' => __('Reassign Authors'),
257 229 );
@@ -280,47 +252,28 @@
280 252 </script>
281 253 <?php endif;
282 254 } /* FeedWordPressAuthorsPage::display () */
283 255
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();
256 + function accept_POST ($post) {
257 + if (isset($post['fix_mismatch']) and (strlen($post['fix_mismatch']) > 0)) :
258 + $this->fix_mismatch($post);
302 259 else :
303 - parent::accept_POST();
260 + parent::accept_POST($post);
304 261 endif;
305 - } /* FeedWordPressAuthorsPage::accept_POST() */
262 + }
306 263
307 - /**
308 - * Fixes an author mismatch.
309 - */
310 - function fix_mismatch() {
264 + function fix_mismatch ($post) {
311 265 global $wpdb;
312 266
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 );
267 + if ('newuser'==$post['fix_mismatch_to']) :
268 + $newuser_name = trim($post['fix_mismatch_to_newuser']);
269 + $to = fwp_insert_new_user($newuser_name);
270 + else :
271 + $to = $post['fix_mismatch_to'];
318 272 endif;
319 273
320 - $from = (int) FeedWordPress::post( 'fix_mismatch_from' );
321 - if ( is_numeric( $from ) ) :
322 -
274 + $from = (int) $post['fix_mismatch_from'];
275 + if (is_numeric($from)) :
323 276 // Make a list of all the items by this author
324 277 // syndicated from this feed...
325 278 $post_ids = $wpdb->get_col("
326 279 SELECT {$wpdb->posts}.id
@@ -329,38 +282,35 @@
329 282 AND {$wpdb->postmeta}.meta_key = 'syndication_feed_id'
330 283 AND {$wpdb->postmeta}.meta_value = '{$this->link->id}'
331 284 AND {$wpdb->posts}.post_author = '{$from}'
332 285 ");
286 +
287 + if (count($post_ids) > 0) :
288 + $N = count($post_ids);
289 + $posts = 'post'.(($N==1) ? '' : 's');
333 290
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 291 // 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 -
292 + if (is_numeric($to)) : // re-assign to a particular user
293 + $post_set = "(".implode(",", $post_ids).")";
294 +
344 295 // Getting the revisions too, if there are any
345 296 $parent_in_clause = "OR {$wpdb->posts}.post_parent IN $post_set";
346 -
297 +
347 298 $wpdb->query("
348 - UPDATE {$wpdb->posts}
349 - SET post_author='{$to}'
350 - WHERE ({$wpdb->posts}.id IN $post_set
351 - $parent_in_clause)
299 + UPDATE {$wpdb->posts}
300 + SET post_author='{$to}'
301 + WHERE ({$wpdb->posts}.id IN $post_set
302 + $parent_in_clause)
352 303 ");
353 - // $this->mesg = sprintf(__("Re-assigned %d {$posts}."), $N); // see comment abpve
354 - $this->mesg = __( "Re-assigned " ) . $posts;
304 + $this->mesg = sprintf(__("Re-assigned %d ${posts}."), $N);
355 305
356 306 // ... and kill them all
357 - elseif ( 'filter' == $to ) :
358 - foreach ( $post_ids as $post_id ) :
359 - wp_delete_post( $post_id );
307 + elseif ('filter'==$to) :
308 + foreach ($post_ids as $post_id) :
309 + wp_delete_post($post_id);
360 310 endforeach;
361 -
362 - $this->mesg = __( "Deleted " ) . $posts;
311 +
312 + $this->mesg = sprintf(__("Deleted %d ${posts}."), $N);
363 313 endif;
364 314 else :
365 315 $this->mesg = __("Couldn't find any posts that matched your criteria.");
366 316 endif;
@@ -365,58 +315,51 @@
365 315 $this->mesg = __("Couldn't find any posts that matched your criteria.");
366 316 endif;
367 317 endif;
368 318 $this->updated = false;
369 - } /* FeedWordPressAuthorsPage::fix_mismatch() */
319 + }
370 320
371 - /**
372 - * Presumably saves settings...
373 - *
374 - * @return void description
375 - */
376 - function save_settings () {
321 + function save_settings ($post) {
322 +
377 323 if ($this->for_feed_settings()) :
378 - // $alter = array(); // what is this array? It's never used. (gwyneth 20230920)
324 + $alter = array ();
379 325
380 326 // 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);
327 + if (isset($post["unfamiliar_author"])) :
328 + if ('newuser'==$post['unfamiliar_author']) :
329 + $new_name = trim($post["unfamiliar_author_newuser"]);
330 + $this->link->map_name_to_new_user(/*name=*/ NULL, $new_name);
386 331 else :
387 332 $this->link->update_setting(
388 333 "unfamiliar author",
389 - $unfamiliar_author,
334 + $post['unfamiliar_author'],
390 335 'site-default'
391 336 );
392 337 endif;
393 338 endif;
394 -
339 +
395 340 // 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'],
341 + if (isset($post['author_rules_name'])
342 + and isset($post['author_rules_action'])) :
343 + if (isset($post['author_rules_name']['all'])) :
344 + if (strlen($post['author_rules_name']['all']) > 0) :
345 + $post['author_rules_name'] = array(
346 + 'all' => $post['author_rules_name']['all'],
403 347 );
404 -
348 +
405 349 // Erase all the rest.
406 350 endif;
407 351 endif;
408 -
352 +
409 353 unset($this->link->settings['map authors']);
410 - foreach ($author_rules_name as $key => $name) :
354 + foreach ($post['author_rules_name'] as $key => $name) :
411 355 // 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 ] );
356 + $name = strtolower(trim($name));
357 + $author_action = strtolower(trim($post['author_rules_action'][$key]));
358 +
359 + if (strlen($name) > 0) :
360 + if ('newuser' == $author_action) :
361 + $new_name = trim($post['author_rules_newuser'][$key]);
419 362 $this->link->map_name_to_new_user($name, $new_name);
420 363 else :
421 364 $this->link->settings['map authors']['name'][$name] = $author_action;
422 365 endif;
@@ -423,17 +366,16 @@
423 366 endif;
424 367 endforeach;
425 368 endif;
426 369
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 -
370 + if (isset($post['add_author_rule_name'])
371 + and isset($post['add_author_rule_action'])) :
372 + $name = strtolower(trim($post['add_author_rule_name']));
373 + $author_action = strtolower(trim($post['add_author_rule_action']));
374 +
433 375 if (strlen($name) > 0) :
434 376 if ('newuser' == $author_action) :
435 - $new_name = trim( FeedWordPress::post( 'add_author_rule_newuser' ));
377 + $new_name = trim($post['add_author_rule_newuser']);
436 378 $this->link->map_name_to_new_user($name, $new_name);
437 379 else :
438 380 $this->link->settings['map authors']['name'][$name] = $author_action;
439 381 endif;
@@ -438,41 +380,38 @@
438 380 $this->link->settings['map authors']['name'][$name] = $author_action;
439 381 endif;
440 382 endif;
441 383 endif;
442 -
443 384 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 );
385 + if ('newuser'==$post['unfamiliar_author']) :
386 + $new_name = trim($post['unfamiliar_author_newuser']);
387 + $new_id = fwp_insert_new_user($new_name);
388 + if (is_numeric($new_id)) :
389 + update_option('feedwordpress_unfamiliar_author', $new_id);
451 390 else :
452 391 // TODO: Add some error detection and reporting
453 392 // Put WP_Error stuff into $this->mesg ?
454 393 endif;
455 394 else :
456 - update_option( 'feedwordpress_unfamiliar_author', $unfamiliar_author );
395 + update_option('feedwordpress_unfamiliar_author', $post['unfamiliar_author']);
457 396 endif;
458 397
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'
398 + update_option('feedwordpress_do_not_match_author_by_email',
399 + (isset($post['match_author_by_email'])
400 + and 'yes'==$post['match_author_by_email'])
401 + ? 'no'
402 + : 'yes'
463 403 );
464 404
465 - $null_emails = FeedWordPress::post( 'null_emails', null, 'textarea' );
466 - if ( ! is_null( $null_emails ) ) :
467 - update_option( 'feedwordpress_null_email_set', $null_emails );
405 + if (isset($post['null_emails'])) :
406 + update_option('feedwordpress_null_email_set', $post['null_emails']);
468 407 endif;
469 408 endif;
470 409
471 - parent::save_settings();
410 + parent::save_settings($post);
472 411 $this->refresh_author_list();
473 - } /* FeedWordPressAuthorsPage::save_settings() */
412 + }
413 +} /* class FeedWordPressAuthorsPage */
474 414
475 -} /* class FeedWordPressAuthorsPage */
415 + $authorsPage = new FeedWordPressAuthorsPage;
416 + $authorsPage->display();
476 417
477 -$authorsPage = new FeedWordPressAuthorsPage;
478 -$authorsPage->display();