PluginProbe
FeedWordPress / 0.993
FeedWordPress v0.993
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 0.993, at syndication-options.php

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