PluginProbe
FeedWordPress / 2008.1101
FeedWordPress v2008.1101
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
feedwordpress / syndication-options.php

syndication-options.php in FeedWordPress 2008.1101, at syndication-options.php

370 lines 16.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once(dirname(__FILE__) . '/admin-ui.php');
3
4 function fwp_syndication_options_page () {
5 global $wpdb, $wp_db_version;
6
7 if (FeedWordPress::needs_upgrade()) :
8 fwp_upgrade_page();
9 return;
10 endif;
11
12 if (isset($_POST['submit'])) :
13 check_admin_referer();
14
15 if (!current_user_can('manage_options')):
16 die (__("Cheatin' uh ?"));
17 else:
18 update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
19 update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
20 update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
21 update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
22
23 if ('newuser'==$_REQUEST['unfamiliar_author']) :
24 $newuser_name = trim($_REQUEST['unfamiliar_author_newuser']);
25 if (strlen($newuser_name) > 0) :
26 $userdata = array();
27 $userdata['ID'] = NULL;
28
29 $userdata['user_login'] = sanitize_user($newuser_name);
30 $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
31
32 $userdata['user_nicename'] = sanitize_title($newuser_name);
33 $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
34
35 $userdata['display_name'] = $wpdb->escape($newuser_name);
36
37 $newuser_id = wp_insert_user($userdata);
38 if (is_numeric($newuser_id)) :
39 update_option('feedwordpress_unfamiliar_author', $newuser_id);
40 else :
41 // TODO: Add some error detection and reporting
42 endif;
43 else :
44 // TODO: Add some error reporting
45 endif;
46 else :
47 update_option('feedwordpress_unfamiliar_author', $_REQUEST['unfamiliar_author']);
48 endif;
49
50 update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
51 update_option('feedwordpress_syndicated_post_status', $_REQUEST['post_status']);
52 update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
53 update_option('feedwordpress_freshness', ($_POST['freshness_interval']*60));
54
55 // Categories
56 $cats = array();
57 if (isset($_POST['post_category'])) :
58 $cats = array();
59 foreach ($_POST['post_category'] as $cat_id) :
60 $cats[] = '{#'.$cat_id.'}';
61 endforeach;
62 endif;
63
64 if (!empty($cats)) :
65 update_option('feedwordpress_syndication_cats', implode(FEEDWORDPRESS_CAT_SEPARATOR, $cats));
66 else :
67 delete_option('feedwordpress_syndication_cats');
68 endif;
69
70 // Tags
71 if (isset($_REQUEST['tags_input'])) :
72 $tags = explode(",", $_REQUEST['tags_input']);
73 else :
74 $tags = array();
75 endif;
76
77 if (!empty($tags)) :
78 update_option('feedwordpress_syndication_tags', implode(FEEDWORDPRESS_CAT_SEPARATOR, $tags));
79 else :
80 delete_option('feedwordpress_syndication_tags');
81 endif;
82
83 if (isset($_REQUEST['comment_status']) and ($_REQUEST['comment_status'] == 'open')) :
84 update_option('feedwordpress_syndicated_comment_status', 'open');
85 else :
86 update_option('feedwordpress_syndicated_comment_status', 'closed');
87 endif;
88
89 if (isset($_REQUEST['ping_status']) and ($_REQUEST['ping_status'] == 'open')) :
90 update_option('feedwordpress_syndicated_ping_status', 'open');
91 else :
92 update_option('feedwordpress_syndicated_ping_status', 'closed');
93 endif;
94
95 if (isset($_REQUEST['hardcode_name']) and ($_REQUEST['hardcode_name'] == 'no')) :
96 update_option('feedwordpress_hardcode_name', 'no');
97 else :
98 update_option('feedwordpress_hardcode_name', 'yes');
99 endif;
100
101 if (isset($_REQUEST['hardcode_description']) and ($_REQUEST['hardcode_description'] == 'no')) :
102 update_option('feedwordpress_hardcode_description', 'no');
103 else :
104 update_option('feedwordpress_hardcode_description', 'yes');
105 endif;
106
107 if (isset($_REQUEST['hardcode_url']) and ($_REQUEST['hardcode_url'] == 'no')) :
108 update_option('feedwordpress_hardcode_url', 'no');
109 else :
110 update_option('feedwordpress_hardcode_url', 'yes');
111 endif;
112 ?>
113 <div class="updated">
114 <p><?php _e('Options saved.')?></p>
115 </div>
116 <?php
117 endif;
118 endif;
119
120 $cat_id = FeedWordPress::link_category_id();
121 $munge_permalink = get_option('feedwordpress_munge_permalink');
122 $formatting_filters = get_option('feedwordpress_formatting_filters');
123 $update_logging = get_option('feedwordpress_update_logging');
124
125 $automatic_updates = get_option('feedwordpress_automatic_updates');
126
127 $freshness_interval = get_option('feedwordpress_freshness');
128 if (false === $freshness_interval) :
129 $freshness_interval = FEEDWORDPRESS_FRESHNESS_INTERVAL;
130 endif;
131 $freshness_interval = $freshness_interval / 60; // convert to minutes
132
133 $hardcode_name = get_option('feedwordpress_hardcode_name');
134 $hardcode_description = get_option('feedwordpress_hardcode_description');
135 $hardcode_url = get_option('feedwordpress_hardcode_url');
136
137 $post_status = get_option("feedwordpress_syndicated_post_status"); // default="publish"
138 $comment_status = get_option("feedwordpress_syndicated_comment_status"); // default="closed"
139 $ping_status = get_option("feedwordpress_syndicated_ping_status"); // default="closed"
140
141 $unfamiliar_author = array ('create' => '','default' => '','filter' => '');
142 $ua = FeedWordPress::on_unfamiliar('author');
143 if (is_string($ua) and array_key_exists($ua, $unfamiliar_author)) :
144 $unfamiliar_author[$ua] = ' checked="checked"';
145 endif;
146 $unfamiliar_category = array ('create'=>'','default'=>'','filter'=>'', 'tag'=>'');
147 $uc = FeedWordPress::on_unfamiliar('category');
148 if (is_string($uc) and array_key_exists($uc, $unfamiliar_category)) :
149 $unfamiliar_category[$uc] = ' checked="checked"';
150 endif;
151
152 if (isset($wp_db_version) and $wp_db_version >= 4772) :
153 $results = get_categories('type=link');
154
155 // Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty.
156 $found_link_category_id = false;
157 foreach ($results as $row) :
158 if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif;
159 endforeach;
160
161 if (!$found_link_category_id) : $results[] = get_category($cat_id); endif;
162 else :
163 $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
164 endif;
165
166 $cats = array_map('trim',
167 preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats'))
168 );
169 $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
170
171 $tags = array_map('trim',
172 preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags'))
173 );
174 ?>
175 <script type="text/javascript">
176 function flip_newuser (item) {
177 rollup=document.getElementById(item);
178 newuser=document.getElementById(item+'-newuser');
179 sitewide=document.getElementById(item+'-default');
180 if (rollup) {
181 if ('newuser'==rollup.value) {
182 if (newuser) newuser.style.display='block';
183 if (sitewide) sitewide.style.display='none';
184 } else {
185 if (newuser) newuser.style.display='none';
186 if (sitewide) sitewide.style.display='block';
187 }
188 }
189 }
190 </script>
191
192 <div class="wrap">
193 <h2>Syndication Options</h2>
194 <div id="poststuff">
195 <form action="" method="post">
196 <?php fwp_linkedit_single_submit(); ?>
197 <div id="post-body">
198 <?php fwp_option_box_opener('Syndicated Feeds', 'syndicatedfeedsdiv'); ?>
199 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
200 <tr>
201 <th width="33%" scope="row">Syndicated Link category:</th>
202 <td width="67%"><?php
203 echo "\n<select name=\"syndication_category\" size=\"1\">";
204 foreach ($results as $row) {
205 if (!isset($row->cat_id)) { $row->cat_id = $row->cat_ID; }
206
207 echo "\n\t<option value=\"$row->cat_id\"";
208 if ($row->cat_id == $cat_id)
209 echo " selected='selected'";
210 echo ">$row->cat_id: ".wp_specialchars($row->cat_name);
211 if ('Y' == $row->auto_toggle)
212 echo ' (auto toggle)';
213 echo "</option>\n";
214 }
215 echo "\n</select>\n";
216 ?></td>
217 </tr>
218
219 <tr>
220 <th width="33%" scope="row">Check for new posts:</th>
221 <td width="67%"><select name="automatic_updates" size="1" onchange="if (this.value=='yes') { disp = 'inline'; } else { disp = 'none'; }; el=document.getElementById('automatic-update-interval-span'); if (el) el.style.display=disp;">
222 <option value="yes"<?php echo ($automatic_updates)?' selected="selected"':''; ?>>automatically</option>
223 <option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>only when I request</option>
224 </select>
225 <span id="automatic-update-interval-span" style="display: <?php echo $automatic_updates?'inline':'none';?>"><label for="automatic-update-interval">every</label> <input id="automatic-update-interval" name="freshness_interval" value="<?php echo $freshness_interval; ?>" size="4" /> minutes.</span>
226 </td>
227 </tr>
228
229 <tr><th width="33%" scope="row" style="vertical-align:top">Feed information:</th>
230 <td width="67%"><ul style="margin:0;padding:0;list-style:none">
231 <li><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode_name=='yes')?'':' checked="checked"');?>/> Update the contributor title when the feed title changes</li>
232 <li><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode_description=='yes')?'':' checked="checked"');?>/> Update when contributor description if the feed tagline changes</li>
233 <li><input type="checkbox" name="hardcode_url" value="no"<?php echo (($hardcode_url=='yes')?'':' checked="checked"');?>/> Update the contributor homepage when the feed link changes</li>
234 </ul></td></tr>
235 </table>
236 <?php fwp_linkedit_periodic_submit(); ?>
237 <?php fwp_option_box_closer(); ?>
238
239 <?php
240 fwp_option_box_opener(__('Syndicated Posts'), 'syndicatedpostsdiv');
241 ?>
242 <table class="editform" width="75%" cellspacing="2" cellpadding="5">
243 <tr style="vertical-align: top"><th width="44%" scope="row">Publication:</th>
244 <td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
245 <li><label><input type="radio" name="post_status" value="publish"<?php echo (!$post_status or $post_status=='publish')?' checked="checked"':''; ?> /> Publish syndicated posts immediately</label></li>
246 <?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
247 <li><label><input type="radio" name="post_status" value="pending"<?php echo ($post_status=='pending')?' checked="checked"':''; ?> /> Hold syndicated posts for review; mark as Pending</label></li>
248 <?php endif; ?>
249 <li><label><input type="radio" name="post_status" value="draft"<?php echo ($post_status=='draft')?' checked="checked"':''; ?> /> Save syndicated posts as drafts</label></li>
250 <li><label><input type="radio" name="post_status" value="private"<?php echo ($post_status=='private')?' checked="checked"':''; ?> /> Save syndicated posts as private posts</label></li>
251 </ul></td></tr>
252 <tr style="vertical-align: top"><th width="44%" scope="row">Permalinks point to:</th>
253 <td width="56%"><select name="munge_permalink" size="1">
254 <option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>original website</option>
255 <option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>this website</option>
256 </select></td></tr>
257 <tr style="vertical-align:top"><th width="44%" scope="row">Formatting filters:</th>
258 <td width="56%">
259 <select name="formatting_filters" size="1">
260 <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
261 <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
262 </select>
263 <p>If you have trouble getting plugins to work that are supposed to insert
264 elements after posts (like relevant links or a social networking
265 <q>Share This</q> button), try changing this option to see if it fixes your
266 problem.</p>
267 </td></tr>
268 </table>
269 <?php
270 fwp_option_box_closer();
271 fwp_linkedit_periodic_submit();
272
273 fwp_option_box_opener(__('Categories for syndicated posts'), 'categorydiv', 'postbox');
274 fwp_category_box($dogs, '<em>all syndicated posts</em>');
275 ?>
276 <table class="editform" width="75%" cellspacing="2" cellpadding="5">
277 <tr style="vertical-align: top"><th width="27%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
278 <td><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
279 <ul style="margin: 0; padding:0; list-style:none">
280 <li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar_category['create']; ?>/> create a new category</label></li>
281 <li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar_category['tag']; ?>/> create a new tag</label></li>
282 <li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar_category['default']; ?>/> don't create new categories or tags</li>
283 <li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar_category['filter']; ?>/> don't create new categories or tags and don't syndicate posts unless they match at least one familiar category</label></li>
284 </ul></td></tr>
285 </table>
286 <?php
287 fwp_option_box_closer();
288 fwp_linkedit_periodic_submit();
289
290 if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
291 fwp_tags_box($tags);
292 fwp_linkedit_periodic_submit();
293 endif;
294
295 fwp_option_box_opener(__('Comments & Pings'), 'commentstatus', 'postbox');
296 ?>
297 <table class="editform" width="75%" cellspacing="2" cellpadding="5">
298 <tr style="vertical-align: top"><th width="44%" scope="row"><?php print __('Comments') ?>:</th>
299 <td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
300 <li><label><input type="radio" name="comment_status" value="open"<?php echo ($comment_status=='open')?' checked="checked"':''; ?> /> Allow comments on syndicated posts</label></li>
301 <li><label><input type="radio" name="comment_status" value="closed"<?php echo ($comment_status!='open')?' checked="checked"':''; ?> /> Don't allow comments on syndicated posts</label></li>
302 </ul></td></tr>
303
304 <tr style="vertical-align: top"><th width="44%" scope="row"><?php print __('Pings') ?>:</th>
305 <td width="56%"><ul style="margin:0; padding: 0; list-style:none">
306 <li><label><input type="radio" name="ping_status" value="open"<?php echo ($ping_status=='open')?' checked="checked"':''; ?> /> Accept pings on syndicated posts</label></li>
307 <li><label><input type="radio" name="ping_status" value="closed"<?php echo ($ping_status!='open')?' checked="checked"':''; ?> /> Don't accept pings on syndicated posts</label></li>
308 </ul></td></tr>
309 </table>
310 <?php
311 fwp_option_box_closer();
312 fwp_linkedit_periodic_submit();
313
314 fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox');
315
316 $unfamiliar_author = FeedWordPress::on_unfamiliar('author');
317 $authorlist = fwp_author_list();
318 ?>
319 <table>
320 <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>
321 <tr>
322 <th style="text-align: left">Posts by new authors</th>
323 <td>
324 <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
325 <option value="create"<?php if ('create'==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
326 <?php foreach ($authorlist as $author_id => $author_name) : ?>
327 <option value="<?php echo $author_id; ?>"<?php if ($author_id==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
328 <?php endforeach; ?>
329 <option value="newuser">will be assigned to a user named...</option>
330 <option value="filter"<?php if ('filter'==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
331 </select>
332 </td>
333 <td>
334 <div id="unfamiliar-author-default">This is a default setting. You can override it for one or more particular feeds using the Edit link in <a href="admin.php?page=feedwordpress/feedwordpress.php">Syndicated Sites</a></div>
335 <div id="unfamiliar-author-newuser"><input type="text" name="unfamiliar_author_newuser" value="" /></div>
336 </td>
337 </tr>
338 </table>
339
340 <script>
341 flip_newuser('unfamiliar-author');
342 </script>
343 <?php
344 fwp_option_box_closer();
345 fwp_linkedit_periodic_submit();
346
347 fwp_option_box_opener('Back End', 'backenddiv', 'postbox');
348 ?>
349 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
350 <th width="33%" scope="row">Write update notices to PHP logs:</th>
351 <td width="67%"><select name="update_logging" size="1">
352 <option value="yes"<?php echo (($update_logging=='yes')?' selected="selected"':''); ?>>yes</option>
353 <option value="no"<?php echo (($update_logging!='yes')?' selected="selected"':''); ?>>no</option>
354 </select></td>
355 </tr>
356 </table>
357 <?php
358 fwp_option_box_closer();
359 fwp_linkedit_periodic_submit();
360 ?>
361 </div>
362 </form>
363 </div>
364 </div>
365 <?php
366 }
367
368 fwp_syndication_options_page();
369
370