function save_settings ($post) { if (isset($post['match_categories'])) : foreach ($post['match_categories'] as $what => $set) : // Defaulting is controlled by a separate radio button if ($this->for_feed_settings() and isset($post['match_default']) and isset($post['match_default'][$what]) and $post['match_default'][$what]=='yes') : $set = NULL; // Defaulted! endif; $this->update_setting("match/$what", $set, NULL); endforeach; endif; $optionMap = $this->term_option_map(); $settingMap = $this->term_setting_map(); $saveTerms = array(); $separateSaveTerms = array('category' => array(), 'post_tag' => array()); if (!isset($post['tax_input'])) : $post['tax_input'] = array(); endif; // Merge in data from older-notation category check boxes if (isset($post['post_category'])) : // Just merging in for processing below. $post['tax_input']['category'] = array_merge( (isset($post['tax_input']['category']) ? $post['tax_input']['category'] : array()), $post['post_category'] ); endif; // Process data from term tag boxes and check boxes foreach ($post['tax_input'] as $tax => $terms) : $saveTerms[$tax] = array(); if (is_array($terms)) : // Numeric IDs from checklist foreach ($terms as $term) : if ($term) : $saveTerms[$tax][] = '{'.$tax.'#'.$term.'}'; endif; endforeach; else : // String from tag input $saveTerms[$tax] = explode(",", $terms); endif; $saveTerms[$tax] = array_map('trim', $saveTerms[$tax]); if (isset($optionMap[$tax])) : $separateSaveTerms[$tax] = $saveTerms[$tax]; unset($saveTerms[$tax]); endif; endforeach; if (isset($post['post_category'])) : foreach ($post['post_category'] as $cat) : $separateSaveTerms['category'][] = '{category#'.$cat.'}'; endforeach; endif; // Unmatched categories and tags foreach (array('category', 'post_tag') as $what) : if (isset($post["unfamiliar_{$what}"])) : $this->update_setting( "unfamiliar {$what}", $post["unfamiliar_{$what}"], 'site-default' ); endif; endforeach; // Categories and Tags foreach ($separateSaveTerms as $tax => $terms) : if ($this->for_feed_settings()) : $this->link->update_setting($settingMap[$tax], $terms, array()); else : if (!empty($terms)) : update_option($optionMap[$tax], implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms)); else : delete_option($optionMap[$tax]); endif; endif; endforeach; // Other terms $this->update_setting(array('feed'=>'terms', 'global'=>'syndication_terms'), $saveTerms, array()); if ($this->for_feed_settings()) : // Category splitting regex if (isset($post['cat_split'])) : $this->link->update_setting('cat_split', trim($post['cat_split']), ''); endif; // Treat global terms (cats, tags, etc.) as additional, // or as defaults to be overridden and replaced? if (isset($post['add_global'])) : foreach ($post['add_global'] as $what => $value) : $this->link->update_setting("add/$what", $value); endforeach; endif; endif; parent::save_settings($post); } /* FeedWordPressCategoriesPage::save_settings() */
function save_settings($post) { // custom post settings $custom_settings = $this->custom_post_settings(); foreach ($post['notes'] as $mn) { if (isset($mn['key0'])) { $mn['key0'] = trim($mn['key0']); if (strlen($mn['key0']) > 0) { unset($custom_settings[$mn['key0']]); // out with the old } } if (isset($mn['key1'])) { $mn['key1'] = trim($mn['key1']); if ($mn['action'] == 'update' and strlen($mn['key1']) > 0) { $custom_settings[$mn['key1']] = $mn['value']; // in with the new } } } $this->updatedPosts->accept_POST($post); if ($this->for_feed_settings()) { $alter = array(); $this->link->settings['postmeta'] = serialize($custom_settings); if (isset($post['resolve_relative'])) { $this->link->settings['resolve relative'] = $post['resolve_relative']; } if (isset($post['munge_permalink'])) { $this->link->settings['munge permalink'] = $post['munge_permalink']; } if (isset($post['munge_comments_feed_links'])) { $this->link->settings['munge comments feed links'] = $post['munge_comments_feed_links']; } // Post status, comment status, ping status foreach (array('post', 'comment', 'ping') as $what) { $sfield = "feed_{$what}_status"; if (isset($post[$sfield])) { if ($post[$sfield] == 'site-default') { unset($this->link->settings["{$what} status"]); } else { $this->link->settings["{$what} status"] = $post[$sfield]; } } } if (isset($post['syndicated_post_type'])) { if ($post['syndicated_post_type'] == 'default') { unset($this->link->settings['syndicated post type']); } else { $this->link->settings['syndicated post type'] = $post['syndicated_post_type']; } } } else { // update_option ... if (isset($post['feed_post_status'])) { update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']); } update_option('feedwordpress_custom_settings', serialize($custom_settings)); update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']); update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']); update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']); if (isset($post['resolve_relative'])) { update_option('feedwordpress_resolve_relative', $post['resolve_relative']); } if (isset($post['munge_comments_feed_links'])) { update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']); } if (isset($_REQUEST['feed_comment_status']) and $_REQUEST['feed_comment_status'] == 'open') { update_option('feedwordpress_syndicated_comment_status', 'open'); } else { update_option('feedwordpress_syndicated_comment_status', 'closed'); } if (isset($_REQUEST['feed_ping_status']) and $_REQUEST['feed_ping_status'] == 'open') { update_option('feedwordpress_syndicated_ping_status', 'open'); } else { update_option('feedwordpress_syndicated_ping_status', 'closed'); } if (isset($post['syndicated_post_type'])) { update_option('feedwordpress_syndicated_post_type', $post['syndicated_post_type']); } } parent::save_settings($post); }
function save_settings($post) { if ($this->for_feed_settings()) { if (isset($post['link_rss_params_key'])) { $qp = array(); foreach ($post['link_rss_params_key'] as $index => $key) { if (strlen($key) > 0) { if (isset($post['link_rss_params_value'][$index]) and strlen($post['link_rss_params_value'][$index])) { $value = $post['link_rss_params_value'][$index]; $qp[] = array($key, $value); } } } $this->update_setting('query parameters', serialize($qp)); } // custom feed settings first foreach ($post['notes'] as $mn) { $mn['key0'] = isset($mn['key0']) ? trim($mn['key0']) : NULL; $mn['key1'] = trim($mn['key1']); if (preg_match("^((" . implode(')|(', $this->special_settings) . "))\$i", $mn['key1'])) { $mn['key1'] = 'user/' . $mn['key1']; } if (strlen($mn['key0']) > 0) { unset($this->link->settings[$mn['key0']]); // out with the old } if ($mn['action'] == 'update' and strlen($mn['key1']) > 0) { $this->link->settings[$mn['key1']] = $mn['value']; // in with the new } } // now stuff through the web form // hardcoded feed info foreach (array('name', 'description', 'url') as $what) { // We have a checkbox for "No," so if it's unchecked, mark as "Yes." $this->link->settings["hardcode {$what}"] = isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes'; if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) { $this->link->link->{'link_' . $what} = $post['link' . $what]; } } // Update scheduling if (isset($post['update_schedule'])) { $this->link->settings['update/hold'] = $post['update_schedule']; } if (isset($post['use_default_update_window']) and strtolower($post['use_default_update_window']) == 'yes') { unset($this->link->settings['update/window']); } elseif (isset($post['update_window'])) { if ((int) $post['update_window'] > 0) { $this->link->settings['update/window'] = (int) $post['update_window']; } } } else { // Global update_option('feedwordpress_cat_id', $post['syndication_category']); if (!isset($post['automatic_updates']) or !in_array($post['automatic_updates'], array('init', 'shutdown'))) { $automatic_updates = NULL; } else { $automatic_updates = $post['automatic_updates']; } update_option('feedwordpress_automatic_updates', $automatic_updates); if (isset($post['update_window'])) { if ((int) $post['update_window'] > 0) { update_option('feedwordpress_update_window', (int) $post['update_window']); } } update_option('feedwordpress_update_time_limit', $post['update_time_limit'] == 'yes' ? (int) $post['time_limit_seconds'] : 0); foreach (array('name', 'description', 'url') as $what) { // We have a checkbox for "No," so if it's unchecked, mark as "Yes." $hardcode = isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes'; update_option("feedwordpress_hardcode_{$what}", $hardcode); } } if (isset($post['fetch_timeout'])) { if (isset($post['fetch_timeout_default']) and $post['fetch_timeout_default'] == 'yes') { $timeout = NULL; } else { $timeout = $post['fetch_timeout']; } if (is_int($timeout)) { $timeout = intval($timeout); } $this->update_setting('fetch timeout', $timeout); } if (isset($post['update_minimum'])) { $this->update_setting('update/minimum', $post['update_minimum']); } if (isset($post['link_rss_auth_method']) and $post['link_rss_auth_method'] and '-' != $post['link_rss_auth_method']) { $this->update_setting('http auth method', $post['link_rss_auth_method']); } else { $this->update_setting('http auth method', NULL); } if (isset($post['link_rss_username']) and strlen($post['link_rss_username']) > 0 and '-' != $post['link_rss_auth_method']) { $this->update_setting('http username', $post['link_rss_username']); } else { $this->update_setting('http username', NULL); } if (isset($post['link_rss_password']) and strlen($post['link_rss_password']) > 0 and '-' != $post['link_rss_auth_method']) { $this->update_setting('http password', $post['link_rss_password']); } else { $this->update_setting('http password', NULL); } $this->updatedPosts->accept_POST($post); parent::save_settings($post); }
function save_settings($post) { if ($this->for_feed_settings()) { $alter = array(); // Unfamiliar author rule if (isset($post["unfamiliar_author"])) { if ('newuser' == $post['unfamiliar_author']) { $new_name = trim($post["unfamiliar_author_newuser"]); $this->link->map_name_to_new_user(NULL, $new_name); } else { $this->link->update_setting("unfamiliar author", $post['unfamiliar_author'], 'site-default'); } } // Handle author mapping rules if (isset($post['author_rules_name']) and isset($post['author_rules_action'])) { if (isset($post['author_rules_name']['all'])) { if (strlen($post['author_rules_name']['all']) > 0) { $post['author_rules_name'] = array('all' => $post['author_rules_name']['all']); // Erase all the rest. } } unset($this->link->settings['map authors']); foreach ($post['author_rules_name'] as $key => $name) { // Normalize for case and whitespace $name = strtolower(trim($name)); $author_action = strtolower(trim($post['author_rules_action'][$key])); if (strlen($name) > 0) { if ('newuser' == $author_action) { $new_name = trim($post['author_rules_newuser'][$key]); $this->link->map_name_to_new_user($name, $new_name); } else { $this->link->settings['map authors']['name'][$name] = $author_action; } } } } if (isset($post['add_author_rule_name']) and isset($post['add_author_rule_action'])) { $name = strtolower(trim($post['add_author_rule_name'])); $author_action = strtolower(trim($post['add_author_rule_action'])); if (strlen($name) > 0) { if ('newuser' == $author_action) { $new_name = trim($post['add_author_rule_newuser']); $this->link->map_name_to_new_user($name, $new_name); } else { $this->link->settings['map authors']['name'][$name] = $author_action; } } } } else { if ('newuser' == $post['unfamiliar_author']) { $new_name = trim($post['unfamiliar_author_newuser']); $new_id = fwp_insert_new_user($new_name); if (is_numeric($new_id)) { update_option('feedwordpress_unfamiliar_author', $new_id); } else { // TODO: Add some error detection and reporting // Put WP_Error stuff into $this->mesg ? } } else { update_option('feedwordpress_unfamiliar_author', $post['unfamiliar_author']); } update_option('feedwordpress_do_not_match_author_by_email', (isset($post['match_author_by_email']) and 'yes' == $post['match_author_by_email']) ? 'no' : 'yes'); if (isset($post['null_emails'])) { update_option('feedwordpress_null_email_set', $post['null_emails']); } } parent::save_settings($post); $this->refresh_author_list(); }