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

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