PageRenderTime 52ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/plugins/tdo-mini-forms/admin/tdomf-moderation.php

https://github.com/archives-of-michigan/seekingmichigan.org-Wordpress
PHP | 1379 lines | 1050 code | 156 blank | 173 comment | 386 complexity | d85f173515e155900ea346b093487972 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('TDOMF: You are not allowed to call this page directly.'); }
  3. /////////////////////////
  4. // Moderate Posts page //
  5. /////////////////////////
  6. function tdomf_get_queued_posts($offset = 0, $limit = 0) {
  7. /* global $wpdb;
  8. $query = "SELECT ID, post_title, post_status ";
  9. $query .= "FROM $wpdb->posts ";
  10. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  11. $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
  12. $query .= "AND post_status = 'future' ";
  13. $query .= "ORDER BY ID DESC ";
  14. if($limit > 0) {
  15. $query .= "LIMIT $limit ";
  16. }
  17. if($offset > 0) {
  18. $query .= "OFFSET $offset ";
  19. }
  20. return $wpdb->get_results( $query );*/
  21. return tdomf_get_posts(array('limit' => $limit,
  22. 'offset' => $offset,
  23. 'post_status' => array('future')));
  24. }
  25. function tdomf_get_queued_posts_count() {
  26. /* global $wpdb;
  27. $query = "SELECT count(ID) ";
  28. $query .= "FROM $wpdb->posts ";
  29. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  30. $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
  31. $query .= "AND post_status = 'future' ";
  32. $query .= "ORDER BY ID DESC ";
  33. $result = $wpdb->get_var( $query );
  34. return intval($result);*/
  35. return tdomf_get_posts(array('count' => true,
  36. 'post_status' => array('future')));
  37. }
  38. function tdomf_get_spam_posts($offset = 0, $limit = 0) {
  39. /*global $wpdb;
  40. $query = "SELECT ID, post_title, meta_value, post_status ";
  41. $query .= "FROM $wpdb->posts ";
  42. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  43. $query .= "WHERE meta_key = '".TDOMF_KEY_SPAM."' ";
  44. $query .= "ORDER BY ID DESC ";
  45. if($limit > 0) {
  46. $query .= "LIMIT $limit ";
  47. }
  48. if($offset > 0) {
  49. $query .= "OFFSET $offset ";
  50. }
  51. return $wpdb->get_results( $query );*/
  52. return tdomf_get_posts(array('offset' => $offset,
  53. 'limit' => $limit,
  54. 'spam' => true));
  55. }
  56. function tdomf_get_spam_posts_count() {
  57. /*global $wpdb;
  58. $query = "SELECT count(ID) ";
  59. $query .= "FROM $wpdb->posts ";
  60. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  61. $query .= "WHERE meta_key = '".TDOMF_KEY_SPAM."' ";
  62. return intval($wpdb->get_var( $query ));*/
  63. return tdomf_get_posts(array('count' => true,
  64. 'spam' => true));
  65. }
  66. // make a post draft
  67. //
  68. function tdomf_unpublish_post($post_id) {
  69. $postargs = array (
  70. "ID" => $post_id,
  71. "post_status" => "draft",
  72. );
  73. wp_update_post($postargs);
  74. }
  75. // publish a post
  76. //
  77. function tdomf_publish_post($post_ID,$use_queue=true) {
  78. $form_id = get_post_meta($post_ID,TDOMF_KEY_FORM_ID,true);
  79. $post = &get_post($post_ID);
  80. if($post->post_status == 'future') {
  81. // updating the post when the post is already queued wont' work
  82. // we need to use the publish post option
  83. wp_publish_post($post_ID);
  84. } else {
  85. $current_ts = current_time( 'mysql' );
  86. $ts = tdomf_queue_date($form_id,$current_ts);
  87. if($current_ts == $ts || !$use_queue) {
  88. $post = array (
  89. "ID" => $post_ID,
  90. "post_status" => 'publish',
  91. );
  92. } else {
  93. tdomf_log_message("Future Post Date = $ts!");
  94. $post = array (
  95. "ID" => $post_ID,
  96. "post_status" => 'future',
  97. "post_date" => $ts,
  98. /* edit date required for wp 2.7 */
  99. "edit_date" => $ts,
  100. );
  101. }
  102. // use update_post as this was the most consistent function since
  103. // wp2.2 for publishign the post correctly
  104. wp_update_post($post);
  105. }
  106. }
  107. // grab a list of all submitted posts
  108. //
  109. function tdomf_get_submitted_posts($offset = 0, $limit = 0) {
  110. /*global $wpdb;
  111. $query = "SELECT ID, post_title, meta_value, post_status ";
  112. $query .= "FROM $wpdb->posts ";
  113. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  114. $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
  115. $query .= "ORDER BY ID DESC ";
  116. if($limit > 0) {
  117. $query .= "LIMIT $limit ";
  118. }
  119. if($offset > 0) {
  120. $query .= "OFFSET $offset ";
  121. }
  122. return $wpdb->get_results( $query );*/
  123. return tdomf_get_posts(array('limit' => $limit,
  124. 'offset' => $offset));
  125. }
  126. // Return count of submitted posts
  127. //
  128. function tdomf_get_submitted_posts_count() {
  129. /*global $wpdb;
  130. $query = "SELECT count(ID) ";
  131. $query .= "FROM $wpdb->posts ";
  132. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  133. $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
  134. return intval($wpdb->get_var( $query ));*/
  135. return tdomf_get_posts(array('count' => true));
  136. }
  137. // Grab a list of unmoderated posts
  138. //
  139. function tdomf_get_unmoderated_posts($offset = 0, $limit = 0) {
  140. global $wpdb;
  141. /*
  142. // Using subqueries... only works on newer SQL version, not the minmum
  143. // supported by WP. Use the second method below
  144. #$query = "SELECT ID, post_title, meta_value, post_status ";
  145. #$query .= "FROM $wpdb->posts ";
  146. #$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  147. #$query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
  148. #$query .= "AND post_status = 'draft' ";
  149. #$query .= "AND $wpdb->posts.ID NOT IN (SELECT post_id FROM $wpdb->postmeta ";
  150. #$query .= "WHERE meta_key = '".TDOMF_KEY_SPAM."' ) ";
  151. #$query .= "ORDER BY ID DESC ";
  152. $query = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->postmeta.meta_value, $wpdb->posts.post_status
  153. FROM $wpdb->posts
  154. LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
  155. LEFT JOIN $wpdb->postmeta tdopm ON $wpdb->posts.id =
  156. tdopm.post_id AND tdopm.meta_key ='".TDOMF_KEY_SPAM."'
  157. WHERE tdopm.post_id IS NULL AND post_status = 'draft' AND $wpdb->postmeta.meta_key='".TDOMF_KEY_FLAG."'
  158. ORDER BY $wpdb->posts.ID DESC ";
  159. if($limit > 0) {
  160. $query .= "LIMIT $limit ";
  161. }
  162. if($offset > 0) {
  163. $query .= "OFFSET $offset ";
  164. }
  165. return $wpdb->get_results( $query );*/
  166. return tdomf_get_posts(array('limit' => $limit,
  167. 'offset' => $offset,
  168. 'post_status' => array('draft'),
  169. 'nospam' => true));
  170. }
  171. // Return a count of unmoderated posts
  172. //
  173. function tdomf_get_unmoderated_posts_count() {
  174. /*global $wpdb;
  175. $query = "SELECT count($wpdb->posts.ID)
  176. FROM $wpdb->posts
  177. LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
  178. LEFT JOIN $wpdb->postmeta tdopm ON $wpdb->posts.id =
  179. tdopm.post_id AND tdopm.meta_key ='_tdomf_spam_flag'
  180. WHERE tdopm.post_id IS NULL AND post_status = 'draft' AND $wpdb->postmeta.meta_key='_tdomf_flag' ";
  181. return intval($wpdb->get_var( $query ));*/
  182. return tdomf_get_posts(array('count' => true,
  183. 'post_status' => array('draft'),
  184. 'nospam' => true));
  185. }
  186. // Grab a list of published submitted posts
  187. //
  188. function tdomf_get_published_posts($offset = 0, $limit = 0) {
  189. /*global $wpdb;
  190. $query = "SELECT ID, post_title, meta_value, post_status ";
  191. $query .= "FROM $wpdb->posts ";
  192. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  193. $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
  194. $query .= "AND post_status = 'publish' ";
  195. $query .= "ORDER BY ID DESC ";
  196. if($limit > 0) {
  197. $query .= "LIMIT $limit ";
  198. }
  199. if($offset > 0) {
  200. $query .= "OFFSET $offset ";
  201. }
  202. return $wpdb->get_results( $query );*/
  203. return tdomf_get_posts(array('limit' => $limit,
  204. 'offset' => $offset,
  205. 'post_status' => array('publish')));
  206. }
  207. // Return a count of pubilshed posts
  208. //
  209. function tdomf_get_published_posts_count() {
  210. /*global $wpdb;
  211. $query = "SELECT count(ID) ";
  212. $query .= "FROM $wpdb->posts ";
  213. $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
  214. $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' ";
  215. $query .= "AND post_status = 'publish' ";
  216. return intval($wpdb->get_var( $query ));*/
  217. return tdomf_get_posts(array('count' => true,
  218. 'post_status' => array('publish')));
  219. }
  220. function tdomf_get_mod_posts_url($args) {
  221. $defaults = array('echo' => false,
  222. 'show' => 'all',
  223. 'action' => false,
  224. 'post_id' => false,
  225. 'mode' => 'list',
  226. 'nonce' => false,
  227. 'revision_id' => false,
  228. 'edit_id' => false,
  229. 'limit' => false,
  230. 'form_id' => false,
  231. 'user_id' => false,
  232. 'ip' => false);
  233. if(isset($_REQUEST['show'])) { $defaults['show'] = $_REQUEST['show']; }
  234. if(isset($_REQUEST['mode'])) { $defaults['mode'] = $_REQUEST['mode']; }
  235. if(isset($_REQUEST['form_id'])) { $defaults['form_id'] = intval($_REQUEST['form_id']); }
  236. if(isset($_REQUEST['user_id'])) { $defaults['user_id'] = intval($_REQUEST['user_id']); }
  237. if(isset($_REQUEST['ip'])) { $defaults['ip'] = $_REQUEST['ip']; }
  238. if(isset($_REQUEST['limit'])) { $defaults['limit'] = intval($_REQUEST['limit']); }
  239. $args = wp_parse_args($args, $defaults);
  240. extract($args);
  241. $url = get_bloginfo('wpurl').'/wp-admin/admin.php?page=tdomf_show_mod_posts_menu';
  242. if($show != 'all') {
  243. $url .= '&show=' . $show;
  244. }
  245. $url .= '&mode=' . $mode;
  246. if($form_id && $form_id > 0) {
  247. $url .= '&form_id=' . $form_id;
  248. }
  249. if($user_id && $user_id > 0) {
  250. $url .= '&user_id=' . $user_id;
  251. }
  252. if($ip && $ip > 0) {
  253. $url .= '&ip=' . $ip;
  254. }
  255. if($action) {
  256. $url .= '&action=' . $action;
  257. }
  258. if($post_id) {
  259. $url .= '&post=' . $post_id;
  260. }
  261. if($revision_id) {
  262. $url .= '&revision=' . $revision_id;
  263. }
  264. if($edit_id) {
  265. $url .= '&edit=' . $edit_id;
  266. }
  267. if($limit) {
  268. $url .= '&limit=' . $limit;
  269. }
  270. if($nonce) {
  271. $url = wp_nonce_url($url,$nonce);
  272. }
  273. if($echo) {
  274. echo $url;
  275. }
  276. return $url;
  277. }
  278. /* @todo filters: form ids, posts with edits, with no edits, by user, by IP */
  279. // Show the moderation menu
  280. //
  281. function tdomf_show_mod_posts_menu() {
  282. tdomf_moderation_handler();
  283. $user_id = false;
  284. if(isset($_REQUEST['user_id'])) { $user_id = intval($_REQUEST['user_id']); }
  285. $ip = false;
  286. if(isset($_REQUEST['ip'])) { $ip = $_REQUEST['ip']; }
  287. $form_id = false;
  288. if(isset($_REQUEST['form_id'])) {
  289. $form_id = intval($_REQUEST['form_id']);
  290. if($form_id <= 0) { $form_id = false; }
  291. }
  292. $pending_count = tdomf_get_posts(array('count' => true, 'post_status' => array('draft'), 'nospam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  293. $scheduled_count = tdomf_get_posts(array('count' => true, 'post_status' => array('future'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  294. $published_count = tdomf_get_posts(array('count' => true, 'post_status' => array('publish'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  295. $spam_count = tdomf_get_posts(array('count' => true, 'spam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  296. $all_count = tdomf_get_posts(array('count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip ));
  297. $form_ids = tdomf_get_form_ids();
  298. $pending_edits_count = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  299. $spam_edits_count = tdomf_get_edits(array('state' => 'spam', 'count' => true, 'unique_post_ids' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  300. $approved_edits_count = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  301. $limit = 10; # fixed
  302. if(isset($_REQUEST['limit'])) { $limit = intval($_REQUEST['limit']); }
  303. $paged = 1;
  304. if(isset($_GET['paged'])) { $paged = intval($_GET['paged']); }
  305. $offset = $limit * ($paged - 1);
  306. $show = 'all';
  307. if(isset($_REQUEST['show'])) { $show = $_REQUEST['show']; }
  308. $posts = false;
  309. $max_pages = 0;
  310. $max_items = 0;
  311. if($show == 'all') {
  312. $posts = tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  313. $max_pages = ceil($all_count / $limit);
  314. $max_items = $all_count;
  315. } else if($show == 'pending_submissions') {
  316. $posts = tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'post_status' => array('draft'), 'nospam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  317. $max_pages = ceil($pending_count / $limit);
  318. $max_items = $pending_count;
  319. } else if($show == 'scheduled') {
  320. $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('future'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  321. $max_pages = ceil($scheduled_count / $limit);
  322. $max_items = $scheduled_count;
  323. } else if($show == 'published') {
  324. $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('publish'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  325. $max_pages = ceil($published_count / $limit);
  326. $max_items = $published_count;
  327. } else if($show == 'spam_submissions') {
  328. $posts = tdomf_get_posts(array('offset' => $offset, 'spam' => true, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  329. $max_pages = ceil($spam_count / $limit);
  330. $max_items = $spam_count;
  331. } else if($show == 'pending_edits') {
  332. $edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  333. $max_pages = ceil($pending_edits_count / $limit);
  334. $posts = array();
  335. # a little hacky magic
  336. foreach($edits as $e) {
  337. $posts[] = (OBJECT) array( 'ID' => $e->post_id );
  338. }
  339. $max_items = $pending_edits_count;
  340. } else if($show == 'spam_edits') {
  341. $edits = tdomf_get_edits(array('state' => 'spam', 'unique_post_ids' => true, 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  342. $max_pages = ceil($spam_edits_count / $limit);
  343. $posts = array();
  344. # a little hacky magic
  345. foreach($edits as $e) {
  346. $posts[] = (OBJECT) array( 'ID' => $e->post_id );
  347. }
  348. $max_items = $spam_edits_count;
  349. } else if($show == 'approved_edits') {
  350. $edits = tdomf_get_edits(array('state' => 'approved', 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip));
  351. $max_pages = ceil($approved_edits_count / $limit);
  352. $posts = array();
  353. # a little hacky magic
  354. foreach($edits as $e) {
  355. $posts[] = (OBJECT) array( 'ID' => $e->post_id, 'edit_id' => $e->edit_id );
  356. }
  357. $max_items = $approved_edits_count;
  358. }
  359. # max is incorrect... doesn't account for form filter...
  360. $mode = 'list';
  361. if(isset($_GET['mode'])) { $mode = $_GET['mode']; }
  362. $count = 0;
  363. # what bulk actions to support
  364. $bulk_sub_publish_now = false;
  365. $bulk_sub_publish = false;
  366. $bulk_sub_unpublish = false;
  367. $bulk_sub_spamit = false;
  368. $bulk_sub_hamit = false;
  369. $bulk_sub_lock = false;
  370. $bulk_sub_unlock = false;
  371. $bulk_edit_approve = false;
  372. $bulk_edit_revert = false;
  373. $bulk_edit_delete = false;
  374. $bulk_edit_spamit = false;
  375. $bulk_edit_hamit = false;
  376. ?>
  377. <div class="wrap">
  378. <?php /* screen_icon(); */ ?>
  379. <h2>
  380. <?php if($user_id || $ip) {
  381. if($user_id) {
  382. $u = get_userdata($user_id);
  383. printf(__('Posts submitted by user %s','tdomf'),$u->user_login);
  384. } else if($ip) {
  385. printf(__('Posts submitted from IP %s','tdomf'),$ip);
  386. }
  387. } else { ?>
  388. <?php _e('Moderation', 'tdomf'); ?>
  389. <?php } ?>
  390. </h2>
  391. <?php /*if(count($posts) <= 0) { ?>
  392. <div class="clear"></div>
  393. <p><?php _e('No submissions found','tdomf') ?></p>
  394. </div> <!-- wrap --><?php
  395. return; }*/ ?>
  396. <form id="posts-filter" action="<?php tdomf_get_mod_posts_url(true,$show,0); ?>" method="post">
  397. <!-- hidden vars -->
  398. <ul class="subsubsub">
  399. <?php if($all_count > 0) { ?>
  400. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'all')); ?>"<?php if($show == 'all') { ?> class="current"<?php } ?>><?php printf(__('All Submissions (%s)','tdomf'),$all_count); ?></a> | </li>
  401. <?php } ?>
  402. <?php if($pending_count > 0) { ?>
  403. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'pending_submissions')); ?>"<?php if($show == 'pending_submissions') { ?> class="current"<?php } ?>><?php printf(__('Pending Submissions (%s)','tdomf'),$pending_count); ?></a> | </li>
  404. <?php } ?>
  405. <?php if($scheduled_count > 0) { ?>
  406. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'scheduled')); ?>"<?php if($show == 'scheduled') { ?> class="current"<?php } ?>><?php printf(__('Scheduled Submissions (%s)','tdomf'),$scheduled_count); ?></a> | </li>
  407. <?php } ?>
  408. <?php if($published_count > 0) { ?>
  409. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'published')); ?>"<?php if($show == 'published') { ?> class="current"<?php } ?>><?php printf(__('Published (%s)','tdomf'),$published_count); ?></a> | </li>
  410. <?php } ?>
  411. <?php if($spam_count > 0) { ?>
  412. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'spam_submissions')); ?>"<?php if($show == 'spam_submissions') { ?> class="current"<?php } ?>><?php printf(__('Spam Submissions (%s)','tdomf'),$spam_count); ?></a> | </li>
  413. <?php } ?>
  414. <?php if($approved_edits_count > 0) { ?>
  415. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'approved_edits')); ?>"<?php if($show == 'approved_edits') { ?> class="current"<?php } ?>><?php printf(__('Approved Edits (%s)','tdomf'),$approved_edits_count); ?></a> | </li>
  416. <?php } ?>
  417. <?php if($pending_edits_count > 0) { ?>
  418. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'pending_edits')); ?>"<?php if($show == 'pending_edits') { ?> class="current"<?php } ?>><?php printf(__('Pending Edits (%s)','tdomf'),$pending_edits_count); ?></a> | </li>
  419. <?php } ?>
  420. <?php if($spam_edits_count > 0) { ?>
  421. <li><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'show' => 'spam_edits')); ?>"<?php if($show == 'spam_edits') { ?> class="current"<?php } ?>><?php printf(__('Spam Edits (%s)','tdomf'),$spam_edits_count); ?></a> | </li>
  422. <?php } ?>
  423. </ul>
  424. <div class="tablenav">
  425. <?php
  426. $page_links = paginate_links( array(
  427. 'base' => add_query_arg( 'paged', '%#%', tdomf_get_mod_posts_url(array()) ),
  428. 'format' => '',
  429. 'prev_text' => __('&laquo;'),
  430. 'next_text' => __('&raquo;'),
  431. 'total' => $max_pages,
  432. 'current' => $paged
  433. ));
  434. ?>
  435. <?php if ( $page_links ) { ?>
  436. <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
  437. number_format_i18n( $offset ),
  438. number_format_i18n( $offset + count($posts) ),
  439. number_format_i18n( $max_items ),
  440. $page_links
  441. ); echo $page_links_text; ?></div>
  442. <?php } ?>
  443. <div class="view-switch">
  444. <a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'mode' => 'list')); ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
  445. <a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'mode' => 'excerpt')); ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
  446. </div>
  447. <?php $form_ids_check = array();
  448. foreach($form_ids as $form) {
  449. if(TDOMF_Widget::isSubmitForm(false,$form->form_id)) {
  450. $count = tdomf_get_posts(array('count' => true, 'form_id' => $form->form_id));
  451. } else {
  452. $count = tdomf_get_edits(array('count' => true, 'form_id' => $form->form_id));
  453. }
  454. if($count > 0) {
  455. $form_ids_check[] = $form->form_id;
  456. }
  457. }
  458. if(!empty($form_ids_check)) { ?>
  459. <select name='form_id'>
  460. <option value="-1" selected="selected"><?php _e('Show All','tdomf'); ?></option>
  461. <?php foreach($form_ids_check as $form) { ?>
  462. <option value="<?php echo $form; ?>" <?php if($form_id == $form) { ?> selected="selected" <?php } ?>><?php printf(__('Form #%d','tdomf'),$form); ?></option>
  463. <?php } ?>
  464. </select>
  465. <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
  466. <?php } ?>
  467. <div class="clear"></div>
  468. </div> <!-- tablenav -->
  469. <div class="clear"></div>
  470. <table class="widefat post fixed" cellspacing="0">
  471. <thead>
  472. <tr>
  473. <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
  474. <th scope="col" id="title" class="manage-column column-title" style=""><?php _e('Post','tdomf'); ?></th>
  475. <th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php _e('Submitted','tdomf'); ?></th>
  476. <th scope="col" id="edited" class="manage-column column-edited" style="">
  477. <?php if($show == 'approved_edits') { _e('Edit','tdomf'); }
  478. else if($show == 'pending_edits') { _e('Pending Edit','tdomf'); }
  479. else if($show == 'spam_edits') { _e('Spam Edit','tdomf'); }
  480. else { _e('Most Recent Edit','tdomf'); } ?></th>
  481. <th scope="col" id="status" class="manage-column column-status" style=""><?php _e('Status','tdomf'); ?></th>
  482. </tr>
  483. </thead>
  484. <tfoot>
  485. <tr>
  486. <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
  487. <th scope="col" id="title" class="manage-column column-title" style=""><?php _e('Post','tdomf'); ?></th>
  488. <th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php _e('Submitted','tdomf'); ?></th>
  489. <th scope="col" id="edited" class="manage-column column-edited" style="">
  490. <?php if($show == 'approved_edits') { _e('Edit','tdomf'); }
  491. else if($show == 'pending_edits') { _e('Pending Edit','tdomf'); }
  492. else if($show == 'spam_edits') { _e('Spam Edit','tdomf'); }
  493. else { _e('Most Recent Edit','tdomf'); } ?></th>
  494. <th scope="col" id="status" class="manage-column column-status" style=""><?php _e('Status','tdomf'); ?></th>
  495. </tr>
  496. </tfoot>
  497. <tbody>
  498. <?php if(!empty($posts)) { foreach($posts as $p) { $count++; ?>
  499. <?php $post = &get_post( $p->ID ); /* seems I need this later */ ?>
  500. <?php if($show == 'approved_edits') {
  501. // not really the "last" edit but lest pretend
  502. $last_edit = array( tdomf_get_edit($p->edit_id) );
  503. } else {
  504. $last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 2)); /* and need this earlier too */
  505. } ?>
  506. <?php $form_id = get_post_meta($p->ID, TDOMF_KEY_FORM_ID, true); ?>
  507. <?php $queue = intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD,$form_id));
  508. if($queue > 0) { $queue = true; } else { $queue = false; } ?>
  509. <?php $is_spam = get_post_meta($p->ID, TDOMF_KEY_SPAM); ?>
  510. <?php $locked = get_post_meta($post->ID, TDOMF_KEY_LOCK, true); ?>
  511. <tr id='post-<?php echo $p->ID; ?>' class='<?php if(($count%2) != 0) { ?>alternate <?php } ?>status-<?php echo $post->post_status; ?> iedit' valign="top">
  512. <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php echo $p->ID; ?>" /></th>
  513. <td class="post-title column-title"><strong><a class="row-title" href="post.php?action=edit&amp;post=<?php echo $p->ID; ?>" title="Edit"><?php echo $post->post_title; ?></a></strong>
  514. <?php /*$fuoptions = TDOMF_WidgetUploadFiles::getOptions($form_id);*/
  515. $index = 0;
  516. $filelinks = "";
  517. while(true) {
  518. $filename = get_post_meta($p->ID, TDOMF_KEY_DOWNLOAD_NAME.$index,true);
  519. if($filename == false) { break; }
  520. /*if($fuoptions['nohandler'] && trim($fuoptions['url']) != "") {
  521. $uri = trailingslashit($fuoptions['url'])."$p->ID/".$filename;
  522. } else {*/
  523. $uri = trailingslashit(get_bloginfo('wpurl')).'?tdomf_download='.$p->ID.'&id='.$i;
  524. /*}*/
  525. $filelinks .= "<a href='$uri' title='".htmlentities($filename)."'>$index</a>, ";
  526. $index++;
  527. }
  528. if(!empty($filelinks)) { ?>
  529. <?php _e('Uploaded Files: ','tdomf'); ?><?php echo $filelinks; ?><br/>
  530. <?php } ?>
  531. <?php if ( 'excerpt' == $mode ){
  532. # Have to create our own excerpt, the_excerpt() doesn't cut it
  533. # here :(
  534. if ( empty($post->post_excerpt) ) {
  535. $excerpt = apply_filters('the_content', $post->post_content);
  536. } else {
  537. $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
  538. }
  539. $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
  540. $excerpt = wp_html_excerpt($excerpt, 252);
  541. if(strlen($excerpt) == 252){ $excerpt .= '...'; };
  542. echo '<blockquote>'.$excerpt.'</blockquote>';
  543. } ?>
  544. <?php if(get_option(TDOMF_OPTION_MOD_SHOW_LINKS)) { ?>
  545. <div>
  546. <?php } else { ?>
  547. <div class="row-actions">
  548. <?php } ?>
  549. <?php if($post->post_status == 'future') {
  550. $bulk_sub_publish_now = true; ?>
  551. <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)) ?>" title="<?php echo htmlentities(__('Publish this submission now','tdomf')); ?>"><?php _e('Publish Now','tdomf'); ?></a> |</span>
  552. <?php } else if($post->post_status != 'publish') { ?>
  553. <?php if($queue) {
  554. $bulk_sub_publish_now = true;
  555. $bulk_sub_publish = true; ?>
  556. <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'publish', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)) ?>" title="<?php echo htmlentities(__('Add submission to publish queue','tdomf')); ?>"><?php _e('Queue','tdomf'); ?></a> |</span>
  557. <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)) ?>" title="<?php echo htmlentities(__('Publish submission now','tdomf')); ?>"><?php _e('Publish Now','tdomf'); ?></a> |</span>
  558. <?php } else {
  559. $bulk_sub_publish = true; ?>
  560. <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'publish_now', 'post_id' => $p->ID, 'nonce' => 'tdomf-publish_' . $p->ID)) ?>" title="<?php echo htmlentities(__('Publish submission','tdomf')); ?>"><?php _e('Publish','tdomf'); ?></a> |</span>
  561. <?php } ?>
  562. <?php } else if($post->post_status == 'publish') {
  563. $bulk_sub_unpublish = true; ?>
  564. <span class="publish"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'unpublish', 'post_id' => $p->ID, 'nonce' => 'tdomf-unpublish_' . $p->ID)) ?>" title="<?php echo htmlentities(__('Set submission to draft/unmoderated status.','tdomf')); ?>"><?php _e('Un-publish','tdomf'); ?></a> |</span>
  565. <?php } ?>
  566. <span class='delete'><a class='submitdelete' title='Delete this submission' href='<?php echo wp_nonce_url("post.php?action=delete&amp;post=$p->ID", 'delete-post_' . $p->ID); ?>' onclick="if ( confirm('<?php echo js_escape(sprintf(__("You are about to delete this post \'%s\'\n \'Cancel\' to stop, \'OK\' to delete.",'tdomf'),$post->post_title)); ?>') ) { return true;}return false;"><?php _e('Delete','tdomf'); ?></a> | </span>
  567. <?php if($locked) { $bulk_sub_unlock = true; ?>
  568. <span class="lock"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'unlock', 'post_id' => $p->ID, 'nonce' => 'tdomf-unlock_' . $p->ID)) ?>" title="<?php echo htmlentities(__('Unlock submission so it can be edited.','tdomf')); ?>"><?php _e('Unlock','tdomf'); ?></a> |</span>
  569. <?php } else { $bulk_sub_lock = true; ?>
  570. <span class="lock"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'lock', 'post_id' => $p->ID, 'nonce' => 'tdomf-lock_' . $p->ID)) ?>" title="<?php echo htmlentities(__('Lock submission from being edited.','tdomf')); ?>"><?php _e('Lock','tdomf'); ?></a> |</span>
  571. <?php } ?>
  572. <?php if($post->post_status == 'publish') { ?>
  573. <span class='view'><a href="<?php echo get_permalink($p->ID); ?>" title="<?php echo htmlentities(sprintf(__('View \'%s\'','tdomf'),$post->post_title)); ?>" rel="permalink"><?php _e('View','tdomf'); ?></a> | </span>
  574. <?php } else { ?>
  575. <span class='view'><a href="<?php echo get_permalink($p->ID); ?>" title="<?php echo htmlentities(sprintf(__('Preview \'%s\'','tdomf'),$post->post_title)); ?>" rel="permalink"><?php _e('Preview','tdomf'); ?></a> | </span>
  576. <?php } ?>
  577. <span class='edit'><a href="post.php?action=edit&amp;post=<?php echo $p->ID; ?>" title="<?php echo htmlentities(__('Edit this submission','tdomf')); ?>"><?php _e('Edit','tdomf'); ?></a>
  578. <?php if(get_option(TDOMF_OPTION_SPAM)) { ?> |</span><?php } ?>
  579. <?php if(get_option(TDOMF_OPTION_SPAM)) {
  580. if(!$is_spam) {
  581. $bulk_sub_spamit = true; ?>
  582. <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'spamit', 'post_id' => $p->ID, 'nonce' => 'tdomf-spamit_' . $p->ID)) ?>" onclick="if ( confirm('<?php echo js_escape(sprintf(__("You are about to flag this submission \'%s\' as spam\n \'Cancel\' to stop, \'OK\' to delete.",'tdomf'),$post->post_title)); ?>') ) { return true;}return false;"><?php _e('Spam','tdomf'); ?></a></span>
  583. <?php } else {
  584. $bulk_sub_hamit = true; ?>
  585. <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'hamit', 'post_id' => $p->ID, 'nonce' => 'tdomf-hamit_' . $p->ID)) ?>" ><?php _e('Not Spam','tdomf'); ?></span>
  586. <?php } } ?>
  587. </div>
  588. </td>
  589. <td class="column-submitted">
  590. <ul style="font-size: 11px;">
  591. <li>
  592. <?php $name = get_post_meta($p->ID, TDOMF_KEY_NAME, true);
  593. $email = get_post_meta($p->ID, TDOMF_KEY_EMAIL, true);
  594. $user_id = get_post_meta($p->ID, TDOMF_KEY_USER_ID, true);
  595. if($user_id != false) { ?>
  596. <!-- <a href="user-edit.php?user_id=<?php echo $user_id;?>" class="edit"> -->
  597. <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'user_id' => $user_id, 'ip' => false, 'form_id' => false)); ?>">
  598. <?php $u = get_userdata($user_id);
  599. echo $u->user_login; ?></a>
  600. <?php } else if(!empty($name) && !empty($email)) {
  601. echo $name." (".$email.")";
  602. } else if(!empty($name)) {
  603. echo $name;
  604. } else if(!empty($email)) {
  605. echo $email;
  606. } else {
  607. _e("N/A","tdomf");
  608. } ?>
  609. / <?php $ip = get_post_meta($p->ID, TDOMF_KEY_IP, true); if(!empty($ip)) { ?>
  610. <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'ip' => $ip, 'user_id' => false, 'form_id' => false)); ?>">
  611. <?php } ?> <?php echo $ip; ?> <?php if(!empty($ip)) { ?> </a> <?php } ?>
  612. </li>
  613. <li>
  614. <?php if($form_id == false || tdomf_form_exists($form_id) == false) { ?>
  615. <?php _e("Unknown or deleted form","tdomf"); ?>
  616. <?php } else {
  617. $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form=$form_id";
  618. $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id);
  619. echo '<a href="'.$form_edit_url.'">'.sprintf(__('Form #%d: %s</a>','tdomf'),$form_id,$form_name).'</a>';
  620. } ?>
  621. </li>
  622. <li>
  623. <?php if($post->post_status != 'publish' && $post->post_status != 'future') {
  624. $post_date_gmt = get_post_meta($p->ID, TDOMF_KEY_SUBMISSION_DATE, true);
  625. if($post_date_gmt) {
  626. echo mysql2date(__('Y/m/d'), $post_date_gmt);
  627. } else {
  628. #echo mysql2date(__('Y/m/d'), $post->post_modified_gmt);
  629. }
  630. } else {
  631. echo mysql2date(__('Y/m/d'), $post->post_date_gmt);
  632. } ?>
  633. </li>
  634. </ul>
  635. </td>
  636. <td class="column-edited">
  637. <?php /*$last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 1));*/
  638. if($last_edit == false || empty($last_edit) || $last_edit == NULL) { ?>
  639. <!-- no edits -->
  640. <?php } else {
  641. $previous_edit = false;
  642. if(count($last_edit) == 2){
  643. $previous_edit = $last_edit[1];
  644. };
  645. $last_edit = $last_edit[0]; # only care about the first entry
  646. $last_edit_data = maybe_unserialize($last_edit->data); ?>
  647. <ul style="font-size: 11px;">
  648. <li><?php $user_id = $last_edit->user_id;
  649. $name = __("N/A","tdomf");
  650. if(isset($last_edit_data[TDOMF_KEY_NAME])) {
  651. $name = $last_edit_data[TDOMF_KEY_NAME];
  652. }
  653. $email = __("N/A","tdomf");
  654. if(isset($last_edit_data[TDOMF_KEY_EMAIL])) {
  655. $email = $last_edit_data[TDOMF_KEY_EMAIL];
  656. }
  657. if($user_id != 0) { ?>
  658. <a href="user-edit.php?user_id=<?php echo $user_id;?>" class="edit">
  659. <?php $u = get_userdata($user_id);
  660. echo $u->user_login; ?></a>
  661. <?php } else if(!empty($name) && !empty($email)) {
  662. echo $name." (".$email.")";
  663. } else if(!empty($name)) {
  664. echo $name;
  665. } else if(!empty($email)) {
  666. echo $email;
  667. } else {
  668. _e("N/A","tdomf");
  669. } ?>
  670. / <?php echo $last_edit->ip; ?>
  671. </li>
  672. <li>
  673. <?php $form_id = $last_edit->form_id;
  674. if($form_id == false || tdomf_form_exists($form_id) == false) { ?>
  675. <?php _e("Unknown or deleted form","tdomf"); ?>
  676. <?php } else {
  677. $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form=$form_id";
  678. $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME,$form_id);
  679. echo '<a href="'.$form_edit_url.'">'.sprintf(__('Form #%d: %s','tdomf'),$form_id,$form_name).'</a>';
  680. } ?>
  681. </li>
  682. <li><?php echo mysql2date(__('Y/m/d'), $last_edit->date_gmt); ?></li>
  683. <li><?php switch($last_edit->state) {
  684. case 'unapproved':
  685. _e('Unapproved',"tdomf");
  686. break;
  687. case 'approved':
  688. _e('Approved',"tdomf");
  689. break;
  690. case 'spam':
  691. _e('Spam',"tdomf");
  692. break;
  693. default:
  694. echo _e($last_edit->state,"tdomf");
  695. break;
  696. } ?>
  697. </li>
  698. </ul>
  699. <div class="row-actions">
  700. <?php /* nothing to do if revisioning is disabled for the edits... */
  701. if($last_edit->revision_id != 0) { ?>
  702. <?php if($last_edit->state != 'approved') { ?>
  703. <span class='view'><a href="admin.php?page=<?php echo TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.'tdomf-revision.php&edit='.$last_edit->edit_id; ?>"><?php _e('View','tdomf'); ?></a> |<span>
  704. <!-- <span class='view'><a href="revision.php?revision=<?php echo $last_edit->revision_id; ?>"><?php _e('View','tdomf'); ?></a> |<span> -->
  705. <?php }?>
  706. <?php if($last_edit->state == 'approved') { $bulk_edit_revert = true; ?>
  707. <span class="edit"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'revert_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-revert_edit_' . $last_edit->edit_id)) ?>"><?php _e('Revert','tdomf'); ?></a> | </span>
  708. <?php } else if($last_edit->state == 'unapproved' || $last_edit->state == 'spam') { $bulk_edit_delete = true; $bulk_edit_approve = true; ?>
  709. <span class="delete"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'delete_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-delete_edit_' . $last_edit->edit_id)) ?>"><?php _e('Delete','tdomf'); ?></a> | </span>
  710. <span class="edit"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'approve_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-approve_edit_' . $last_edit->edit_id)) ?>"><?php _e('Approve','tdomf'); ?></a> | </span>
  711. <?php } ?>
  712. <?php if($previous_edit) { ?>
  713. <span class="edit"><a href="admin.php?page=<?php echo TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.'tdomf-revision.php&edit='.$last_edit->edit_id; ?>&right=<?php echo $last_edit->edit_id; ?>&left=<?php echo $previous_edit->edit_id; ?>"><?php _e('Compare','tdomf'); ?></a>
  714. <?php } else { ?>
  715. <!-- <span class="edit"><a href="revision.php?action=diff&right=<?php echo $last_edit->revision_id; ?>&left=<?php echo $last_edit->current_revision_id; ?>"><?php _e('Compare','tdomf'); ?></a> -->
  716. <span class="edit"><a href="admin.php?page=<?php echo TDOMF_FOLDER.DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR.'tdomf-revision.php&edit='.$last_edit->edit_id; ?>&right=<?php echo $last_edit->edit_id; ?>&left=previous"><?php _e('Compare','tdomf'); ?></a>
  717. <?php } ?>
  718. <?php if(get_option(TDOMF_OPTION_SPAM)) { ?> |<?php } ?></span>
  719. <?php if(get_option(TDOMF_OPTION_SPAM)) {
  720. if($last_edit->state == 'spam') { $bulk_edit_hamit = true; ?>
  721. <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'hamit_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-hamit_edit_' . $last_edit->edit_id)) ?>" title="<?php echo htmlentities(__('Flag contributation as not being spam','tdomf')); ?>" ><?php _e('Not Spam','tdomf'); ?></span>
  722. <?php } else { $bulk_edit_spamit = true; ?>
  723. <span class="spam"><a href="<?php tdomf_get_mod_posts_url(array('echo'=> true, 'action' => 'spamit_edit', 'edit_id' => $last_edit->edit_id, 'nonce' => 'tdomf-spamit_edit_' . $last_edit->edit_id)) ?>" title="<?php echo htmlentities(__('Flag contributation as being spam','tdomf')); ?>" onclick="if ( confirm('<?php echo js_escape(__("You are about to flag this contribution as spam\n \'Cancel\' to stop, \'OK\' to delete.",'tdomf')); ?>') ) { return true;}return false;"><?php _e('Spam','tdomf'); ?></a></span>
  724. <?php } }?>
  725. <?php } ?>
  726. </div>
  727. <?php } ?>
  728. </td>
  729. <td class="status column-status">
  730. <!-- todo take into account edited status -->
  731. <?php if($is_spam && $post->post_status == 'draft') { ?>
  732. <?php _e('Spam',"tdomf"); ?>
  733. <?php } else {
  734. switch($post->post_status) {
  735. case 'draft':
  736. _e('Draft',"tdomf");
  737. break;
  738. case 'publish':
  739. _e('Published',"tdomf");
  740. break;
  741. case 'future':
  742. _e('Scheduled',"tdomf");
  743. break;
  744. default:
  745. echo _e($post->post_status,"tdomf");
  746. break;
  747. }
  748. if($is_spam) { _e(' (Spam)',"tdomf"); }
  749. if($locked) { _e(' [Locked]','tdomf'); }
  750. } ?>
  751. </td>
  752. <?php } } ?>
  753. </tbody>
  754. </table>
  755. <div class="tablenav">
  756. <?php
  757. if ( $page_links )
  758. echo "<div class='tablenav-pages'>$page_links_text</div>";
  759. ?>
  760. <?php
  761. if(count($posts) > 0) {
  762. ?>
  763. <div class="alignleft actions">
  764. <select name="action">
  765. <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
  766. <?php if($bulk_sub_publish_now) { ?>
  767. <option value="publish_now"><?php _e('Publish Submissions (Now)','tdomf'); ?></option>
  768. <?php } ?>
  769. <?php if($bulk_sub_publish) { ?>
  770. <option value="publish"><?php _e('Publish/Queue Submissions','tdomf'); ?></option>
  771. <?php } ?>
  772. <?php if($bulk_sub_unpublish) { ?>
  773. <option value="unpublish"><?php _e('Un-publish Submissions','tdomf'); ?></option>
  774. <?php } ?>
  775. <option value="delete"><?php _e('Delete Submissions','tdomf'); ?></option>
  776. <?php if($bulk_sub_unlock) { ?>
  777. <option value="unlock"><?php _e('Unlock Submissions','tdomf'); ?></option>
  778. <?php } ?>
  779. <?php if($bulk_sub_lock) { ?>
  780. <option value="lock"><?php _e('Lock Submissions','tdomf'); ?></option>
  781. <?php } ?>
  782. <?php if($bulk_sub_spamit) { ?>
  783. <option value="spamit"><?php _e('Mark Submissions as Spam','tdomf'); ?></option>
  784. <?php } ?>
  785. <?php if($bulk_sub_hamit) { ?>
  786. <option value="hamit"><?php _e('Mark Submissions as Not Spam','tdomf'); ?></option>
  787. <?php } ?>
  788. <?php if($bulk_sub_hamit || $bulk_sub_spamit) { ?>
  789. <option value="spam_recheck"><?php _e('Recheck Submssions for Spam','tdomf'); ?></option>
  790. <?php } ?>
  791. <?php if($bulk_edit_approve) { ?>
  792. <option value="edit_approve"><?php _e('Approve Edits','tdomf'); ?></option>
  793. <?php } ?>
  794. <?php if($bulk_edit_revert) { ?>
  795. <option value="edit_revert"><?php _e('Revert Edits','tdomf'); ?></option>
  796. <?php } ?>
  797. <?php if($bulk_edit_delete) { ?>
  798. <option value="edit_delete"><?php _e('Delete Edits','tdomf'); ?></option>
  799. <?php } ?>
  800. <?php if($bulk_edit_spamit) { ?>
  801. <option value="edit_spamit"><?php _e('Mark Edits as Spam','tdomf'); ?></option>
  802. <?php } ?>
  803. <?php if($bulk_edit_hamit) { ?>
  804. <option value="edit_hamit"><?php _e('Mark Edits as not Spam','tdomf'); ?></option>
  805. <?php } ?>
  806. <?php if($bulk_edit_hamit || $bulk_edit_spamit) { ?>
  807. <option value="edit_spam_recheck"><?php _e('Recheck Edits for Spam','tdomf'); ?></option>
  808. <?php } ?>
  809. </select>
  810. <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
  811. <?php wp_nonce_field('tdomf-moderate-bulk'); ?>
  812. <?php
  813. }
  814. ?>
  815. <!-- hide filters
  816. <select name='form'>
  817. <option value="-1" selected="selected"><?php _e('Show All Forms','tdomf'); ?></option>
  818. <?php foreach($form_ids as $form) { ?>
  819. <option value="<?php echo $form->form_id; ?>"><?php printf(__('Form #%d','tdomf'),$form->form_id); ?></option>
  820. <?php } ?>
  821. </select>
  822. -->
  823. <br class="clear" />
  824. </div> <!-- tablenav -->
  825. <br class="clear" />
  826. </div> <!-- wrap -->
  827. </form>
  828. <?php
  829. }
  830. // Handle operations for this form
  831. //
  832. function tdomf_moderation_handler() {
  833. $message .= "";
  834. # this means a post was deleted
  835. #
  836. if(isset($_REQUEST['deleted'])) {
  837. $message .= __("Submissions deleted. ","tdomf");
  838. }
  839. // bulk actions
  840. if(isset($_REQUEST['doaction']) && isset($_REQUEST['action']) && isset($_REQUEST['post'])) {
  841. $posts = $_REQUEST['post'];
  842. $action = $_REQUEST['action'];
  843. if( $action != -1 && is_array($posts) && !empty($posts))
  844. {
  845. check_admin_referer('tdomf-moderate-bulk');
  846. switch($action) {
  847. case 'spam_recheck' :
  848. $spam_list = array();
  849. $ham_list = array();
  850. foreach($posts as $post) {
  851. if(tdomf_check_submissions_spam($post)) {
  852. $ham_list [] = $post;
  853. } else {
  854. $spam_list [] = $post;
  855. }
  856. }
  857. tdomf_log_message('Akismet thinks these submissions are spam: ' .implode(", ", $spam_list) );
  858. $message .= sprintf(__("Marked these submissions as spam: %s.","tdomf"),implode(", ", $spam_list));
  859. tdomf_log_message('Akismet thinks these posts are not spam: ' .implode(", ", $ham_list) );
  860. $message .= " ";
  861. $message .= sprintf(__("Marked these submissions as not spam: %s.","tdomf"),implode(", ", $ham_list));
  862. break;
  863. case 'delete' :
  864. foreach($posts as $p) {
  865. wp_delete_post($p);
  866. }
  867. tdomf_log_message('Deleted ' . implode(", ", $posts) . ' posts');
  868. $message .= sprintf(__("Deleted submissions: %s","tdomf"),implode(", ", $posts));
  869. break;
  870. case 'publish_now' :
  871. $list = "";
  872. foreach($posts as $p) {
  873. if(!get_post_meta($p, TDOMF_KEY_SPAM)) {
  874. // if we're going to publish the post, then it's not spam!
  875. tdomf_ham_post($p);
  876. }
  877. tdomf_publish_post($p,false);
  878. $list .= "<a href=\"".get_permalink($p)."\">".$p."</a>, ";
  879. }
  880. tdomf_log_message("Published $list posts");
  881. $message .= sprintf(__("Attempted to published these submissions immediately: %s","tdomf"),$list);
  882. break;
  883. case 'publish' :
  884. $list = "";
  885. foreach($posts as $p) {
  886. if(!get_post_meta($p, TDOMF_KEY_SPAM)) {
  887. // if we're going to publish the post, then it's not spam!
  888. tdomf_ham_post($p);
  889. }
  890. tdomf_publish_post($p);
  891. $list .= "<a href=\"".get_permalink($p)."\">".$p."</a>, ";
  892. }
  893. tdomf_log_message("Published or queued $list posts");
  894. $message .= sprintf(__("Attempted to publish or queue these submissions: %s","tdomf"),$list);
  895. break;
  896. case 'unpublish' :
  897. foreach($posts as $p) {
  898. tdomf_unpublish_post($p);
  899. }
  900. tdomf_log_message("Un-published " . implode(", ", $posts) . " posts");
  901. $message .= sprintf(__("Attempted to un-publish theses submissions: %s","tdomf"),implode(", ", $posts));
  902. break;
  903. case 'spamit' :
  904. $spams = array();
  905. foreach($posts as $p) {
  906. if(!get_post_meta($p, TDOMF_KEY_SPAM)) {
  907. tdomf_spam_post($p);
  908. $spams [] = $p;
  909. }
  910. }
  911. tdomf_log_message("Marked as spam " . implode(", ", $spams) . " posts");
  912. $message .= sprintf(__("Marked these submissions as spam: %s","tdomf"),implode(", ", $spams));
  913. break;
  914. case 'hamit' :
  915. $hams = array();
  916. foreach($posts as $p) {
  917. if(get_post_meta($p, TDOMF_KEY_SPAM)) {
  918. tdomf_spam_post($p);
  919. $hams [] = $p;
  920. }
  921. }
  922. if(!empty($hams)) {

Large files files are truncated, but you can click here to view the full file