posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' "; $query .= "AND post_status = 'future' "; $query .= "ORDER BY ID DESC "; if($limit > 0) { $query .= "LIMIT $limit "; } if($offset > 0) { $query .= "OFFSET $offset "; } return $wpdb->get_results( $query );*/ return tdomf_get_posts(array('limit' => $limit, 'offset' => $offset, 'post_status' => array('future'))); } function tdomf_get_queued_posts_count() { /* global $wpdb; $query = "SELECT count(ID) "; $query .= "FROM $wpdb->posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' "; $query .= "AND post_status = 'future' "; $query .= "ORDER BY ID DESC "; $result = $wpdb->get_var( $query ); return intval($result);*/ return tdomf_get_posts(array('count' => true, 'post_status' => array('future'))); } function tdomf_get_spam_posts($offset = 0, $limit = 0) { /*global $wpdb; $query = "SELECT ID, post_title, meta_value, post_status "; $query .= "FROM $wpdb->posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_SPAM."' "; $query .= "ORDER BY ID DESC "; if($limit > 0) { $query .= "LIMIT $limit "; } if($offset > 0) { $query .= "OFFSET $offset "; } return $wpdb->get_results( $query );*/ return tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'spam' => true)); } function tdomf_get_spam_posts_count() { /*global $wpdb; $query = "SELECT count(ID) "; $query .= "FROM $wpdb->posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_SPAM."' "; return intval($wpdb->get_var( $query ));*/ return tdomf_get_posts(array('count' => true, 'spam' => true)); } // make a post draft // function tdomf_unpublish_post($post_id) { $postargs = array ( "ID" => $post_id, "post_status" => "draft", ); wp_update_post($postargs); } // publish a post // function tdomf_publish_post($post_ID,$use_queue=true) { $form_id = get_post_meta($post_ID,TDOMF_KEY_FORM_ID,true); $post = &get_post($post_ID); if($post->post_status == 'future') { // updating the post when the post is already queued wont' work // we need to use the publish post option wp_publish_post($post_ID); } else { $current_ts = current_time( 'mysql' ); $ts = tdomf_queue_date($form_id,$current_ts); if($current_ts == $ts || !$use_queue) { $post = array ( "ID" => $post_ID, "post_status" => 'publish', ); } else { tdomf_log_message("Future Post Date = $ts!"); $post = array ( "ID" => $post_ID, "post_status" => 'future', "post_date" => $ts, /* edit date required for wp 2.7 */ "edit_date" => $ts, ); } // use update_post as this was the most consistent function since // wp2.2 for publishign the post correctly wp_update_post($post); } } // grab a list of all submitted posts // function tdomf_get_submitted_posts($offset = 0, $limit = 0) { /*global $wpdb; $query = "SELECT ID, post_title, meta_value, post_status "; $query .= "FROM $wpdb->posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' "; $query .= "ORDER BY ID DESC "; if($limit > 0) { $query .= "LIMIT $limit "; } if($offset > 0) { $query .= "OFFSET $offset "; } return $wpdb->get_results( $query );*/ return tdomf_get_posts(array('limit' => $limit, 'offset' => $offset)); } // Return count of submitted posts // function tdomf_get_submitted_posts_count() { /*global $wpdb; $query = "SELECT count(ID) "; $query .= "FROM $wpdb->posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' "; return intval($wpdb->get_var( $query ));*/ return tdomf_get_posts(array('count' => true)); } // Grab a list of unmoderated posts // function tdomf_get_unmoderated_posts($offset = 0, $limit = 0) { global $wpdb; /* // Using subqueries... only works on newer SQL version, not the minmum // supported by WP. Use the second method below #$query = "SELECT ID, post_title, meta_value, post_status "; #$query .= "FROM $wpdb->posts "; #$query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; #$query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' "; #$query .= "AND post_status = 'draft' "; #$query .= "AND $wpdb->posts.ID NOT IN (SELECT post_id FROM $wpdb->postmeta "; #$query .= "WHERE meta_key = '".TDOMF_KEY_SPAM."' ) "; #$query .= "ORDER BY ID DESC "; $query = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->postmeta.meta_value, $wpdb->posts.post_status FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->postmeta tdopm ON $wpdb->posts.id = tdopm.post_id AND tdopm.meta_key ='".TDOMF_KEY_SPAM."' WHERE tdopm.post_id IS NULL AND post_status = 'draft' AND $wpdb->postmeta.meta_key='".TDOMF_KEY_FLAG."' ORDER BY $wpdb->posts.ID DESC "; if($limit > 0) { $query .= "LIMIT $limit "; } if($offset > 0) { $query .= "OFFSET $offset "; } return $wpdb->get_results( $query );*/ return tdomf_get_posts(array('limit' => $limit, 'offset' => $offset, 'post_status' => array('draft'), 'nospam' => true)); } // Return a count of unmoderated posts // function tdomf_get_unmoderated_posts_count() { /*global $wpdb; $query = "SELECT count($wpdb->posts.ID) FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->postmeta tdopm ON $wpdb->posts.id = tdopm.post_id AND tdopm.meta_key ='_tdomf_spam_flag' WHERE tdopm.post_id IS NULL AND post_status = 'draft' AND $wpdb->postmeta.meta_key='_tdomf_flag' "; return intval($wpdb->get_var( $query ));*/ return tdomf_get_posts(array('count' => true, 'post_status' => array('draft'), 'nospam' => true)); } // Grab a list of published submitted posts // function tdomf_get_published_posts($offset = 0, $limit = 0) { /*global $wpdb; $query = "SELECT ID, post_title, meta_value, post_status "; $query .= "FROM $wpdb->posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' "; $query .= "AND post_status = 'publish' "; $query .= "ORDER BY ID DESC "; if($limit > 0) { $query .= "LIMIT $limit "; } if($offset > 0) { $query .= "OFFSET $offset "; } return $wpdb->get_results( $query );*/ return tdomf_get_posts(array('limit' => $limit, 'offset' => $offset, 'post_status' => array('publish'))); } // Return a count of pubilshed posts // function tdomf_get_published_posts_count() { /*global $wpdb; $query = "SELECT count(ID) "; $query .= "FROM $wpdb->posts "; $query .= "LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; $query .= "WHERE meta_key = '".TDOMF_KEY_FLAG."' "; $query .= "AND post_status = 'publish' "; return intval($wpdb->get_var( $query ));*/ return tdomf_get_posts(array('count' => true, 'post_status' => array('publish'))); } function tdomf_get_mod_posts_url($args) { $defaults = array('echo' => false, 'show' => 'all', 'action' => false, 'post_id' => false, 'mode' => 'list', 'nonce' => false, 'revision_id' => false, 'edit_id' => false, 'limit' => false, 'form_id' => false, 'user_id' => false, 'ip' => false); if(isset($_REQUEST['show'])) { $defaults['show'] = $_REQUEST['show']; } if(isset($_REQUEST['mode'])) { $defaults['mode'] = $_REQUEST['mode']; } if(isset($_REQUEST['form_id'])) { $defaults['form_id'] = intval($_REQUEST['form_id']); } if(isset($_REQUEST['user_id'])) { $defaults['user_id'] = intval($_REQUEST['user_id']); } if(isset($_REQUEST['ip'])) { $defaults['ip'] = $_REQUEST['ip']; } if(isset($_REQUEST['limit'])) { $defaults['limit'] = intval($_REQUEST['limit']); } $args = wp_parse_args($args, $defaults); extract($args); $url = get_bloginfo('wpurl').'/wp-admin/admin.php?page=tdomf_show_mod_posts_menu'; if($show != 'all') { $url .= '&show=' . $show; } $url .= '&mode=' . $mode; if($form_id && $form_id > 0) { $url .= '&form_id=' . $form_id; } if($user_id && $user_id > 0) { $url .= '&user_id=' . $user_id; } if($ip && $ip > 0) { $url .= '&ip=' . $ip; } if($action) { $url .= '&action=' . $action; } if($post_id) { $url .= '&post=' . $post_id; } if($revision_id) { $url .= '&revision=' . $revision_id; } if($edit_id) { $url .= '&edit=' . $edit_id; } if($limit) { $url .= '&limit=' . $limit; } if($nonce) { $url = wp_nonce_url($url,$nonce); } if($echo) { echo $url; } return $url; } /* @todo filters: form ids, posts with edits, with no edits, by user, by IP */ // Show the moderation menu // function tdomf_show_mod_posts_menu() { tdomf_moderation_handler(); $user_id = false; if(isset($_REQUEST['user_id'])) { $user_id = intval($_REQUEST['user_id']); } $ip = false; if(isset($_REQUEST['ip'])) { $ip = $_REQUEST['ip']; } $form_id = false; if(isset($_REQUEST['form_id'])) { $form_id = intval($_REQUEST['form_id']); if($form_id <= 0) { $form_id = false; } } $pending_count = tdomf_get_posts(array('count' => true, 'post_status' => array('draft'), 'nospam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $scheduled_count = tdomf_get_posts(array('count' => true, 'post_status' => array('future'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $published_count = tdomf_get_posts(array('count' => true, 'post_status' => array('publish'), 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $spam_count = tdomf_get_posts(array('count' => true, 'spam' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $all_count = tdomf_get_posts(array('count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip )); $form_ids = tdomf_get_form_ids(); $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)); $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)); $approved_edits_count = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $limit = 10; # fixed if(isset($_REQUEST['limit'])) { $limit = intval($_REQUEST['limit']); } $paged = 1; if(isset($_GET['paged'])) { $paged = intval($_GET['paged']); } $offset = $limit * ($paged - 1); $show = 'all'; if(isset($_REQUEST['show'])) { $show = $_REQUEST['show']; } $posts = false; $max_pages = 0; $max_items = 0; if($show == 'all') { $posts = tdomf_get_posts(array('offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($all_count / $limit); $max_items = $all_count; } else if($show == 'pending_submissions') { $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)); $max_pages = ceil($pending_count / $limit); $max_items = $pending_count; } else if($show == 'scheduled') { $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('future'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($scheduled_count / $limit); $max_items = $scheduled_count; } else if($show == 'published') { $posts = tdomf_get_posts(array('offset' => $offset, 'post_status' => array('publish'), 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($published_count / $limit); $max_items = $published_count; } else if($show == 'spam_submissions') { $posts = tdomf_get_posts(array('offset' => $offset, 'spam' => true, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($spam_count / $limit); $max_items = $spam_count; } else if($show == 'pending_edits') { $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)); $max_pages = ceil($pending_edits_count / $limit); $posts = array(); # a little hacky magic foreach($edits as $e) { $posts[] = (OBJECT) array( 'ID' => $e->post_id ); } $max_items = $pending_edits_count; } else if($show == 'spam_edits') { $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)); $max_pages = ceil($spam_edits_count / $limit); $posts = array(); # a little hacky magic foreach($edits as $e) { $posts[] = (OBJECT) array( 'ID' => $e->post_id ); } $max_items = $spam_edits_count; } else if($show == 'approved_edits') { $edits = tdomf_get_edits(array('state' => 'approved', 'offset' => $offset, 'limit' => $limit, 'form_id' => $form_id, 'user_id' => $user_id, 'ip' => $ip)); $max_pages = ceil($approved_edits_count / $limit); $posts = array(); # a little hacky magic foreach($edits as $e) { $posts[] = (OBJECT) array( 'ID' => $e->post_id, 'edit_id' => $e->edit_id ); } $max_items = $approved_edits_count; } # max is incorrect... doesn't account for form filter... $mode = 'list'; if(isset($_GET['mode'])) { $mode = $_GET['mode']; } $count = 0; # what bulk actions to support $bulk_sub_publish_now = false; $bulk_sub_publish = false; $bulk_sub_unpublish = false; $bulk_sub_spamit = false; $bulk_sub_hamit = false; $bulk_sub_lock = false; $bulk_sub_unlock = false; $bulk_edit_approve = false; $bulk_edit_revert = false; $bulk_edit_delete = false; $bulk_edit_spamit = false; $bulk_edit_hamit = false; ?>

user_login); } else if($ip) { printf(__('Posts submitted from IP %s','tdomf'),$ip); } } else { ?>

add_query_arg( 'paged', '%#%', tdomf_get_mod_posts_url(array()) ), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $max_pages, 'current' => $paged )); ?>
' . __( 'Displaying %s–%s of %s' ) . '%s', number_format_i18n( $offset ), number_format_i18n( $offset + count($posts) ), number_format_i18n( $max_items ), $page_links ); echo $page_links_text; ?>
form_id)) { $count = tdomf_get_posts(array('count' => true, 'form_id' => $form->form_id)); } else { $count = tdomf_get_edits(array('count' => true, 'form_id' => $form->form_id)); } if($count > 0) { $form_ids_check[] = $form->form_id; } } if(!empty($form_ids_check)) { ?>
ID ); /* seems I need this later */ ?> edit_id) ); } else { $last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 2)); /* and need this earlier too */ } ?> ID, TDOMF_KEY_FORM_ID, true); ?> 0) { $queue = true; } else { $queue = false; } ?> ID, TDOMF_KEY_SPAM); ?> ID, TDOMF_KEY_LOCK, true); ?>
post_title; ?> ID, TDOMF_KEY_DOWNLOAD_NAME.$index,true); if($filename == false) { break; } if($fuoptions['nohandler'] && trim($fuoptions['url']) != "") { $uri = trailingslashit($fuoptions['url'])."$p->ID/".$filename; } else { $uri = trailingslashit(get_bloginfo('wpurl')).'?tdomf_download='.$p->ID.'&id='.$i; } $filelinks .= "$index, "; $index++; } if(!empty($filelinks)) { ?>
post_excerpt) ) { $excerpt = apply_filters('the_content', $post->post_content); } else { $excerpt = apply_filters('the_excerpt', $post->post_excerpt); } $excerpt = str_replace(']]>', ']]>', $excerpt); $excerpt = wp_html_excerpt($excerpt, 252); if(strlen($excerpt) == 252){ $excerpt .= '...'; }; echo '
'.$excerpt.'
'; } ?>
post_status == 'future') { $bulk_sub_publish_now = true; ?> | post_status != 'publish') { ?> | | | post_status == 'publish') { $bulk_sub_unpublish = true; ?> | ID); ?>' onclick="if ( confirm('post_title)); ?>') ) { return true;}return false;"> | | | post_status == 'publish') { ?> | | | post_title)); ?>') ) { return true;}return false;">
$p->ID, 'limit' => 1));*/ if($last_edit == false || empty($last_edit) || $last_edit == NULL) { ?> data); ?>
  • user_id; $name = __("N/A","tdomf"); if(isset($last_edit_data[TDOMF_KEY_NAME])) { $name = $last_edit_data[TDOMF_KEY_NAME]; } $email = __("N/A","tdomf"); if(isset($last_edit_data[TDOMF_KEY_EMAIL])) { $email = $last_edit_data[TDOMF_KEY_EMAIL]; } if($user_id != 0) { ?> user_login; ?> / ip; ?>
  • form_id; if($form_id == false || tdomf_form_exists($form_id) == false) { ?> '.sprintf(__('Form #%d: %s','tdomf'),$form_id,$form_name).''; } ?>
  • date_gmt); ?>
  • state) { case 'unapproved': _e('Unapproved',"tdomf"); break; case 'approved': _e('Approved',"tdomf"); break; case 'spam': _e('Spam',"tdomf"); break; default: echo _e($last_edit->state,"tdomf"); break; } ?>
revision_id != 0) { ?> state != 'approved') { ?> | state == 'approved') { $bulk_edit_revert = true; ?> | state == 'unapproved' || $last_edit->state == 'spam') { $bulk_edit_delete = true; $bulk_edit_approve = true; ?> | | | state == 'spam') { $bulk_edit_hamit = true; ?> ') ) { return true;}return false;">
post_status == 'draft') { ?> post_status) { case 'draft': _e('Draft',"tdomf"); break; case 'publish': _e('Published',"tdomf"); break; case 'future': _e('Scheduled',"tdomf"); break; default: echo _e($post->post_status,"tdomf"); break; } if($is_spam) { _e(' (Spam)',"tdomf"); } if($locked) { _e(' [Locked]','tdomf'); } } ?>
$page_links_text
"; ?> 0) { ?>


".$p.", "; } tdomf_log_message("Published $list posts"); $message .= sprintf(__("Attempted to published these submissions immediately: %s","tdomf"),$list); break; case 'publish' : $list = ""; foreach($posts as $p) { if(!get_post_meta($p, TDOMF_KEY_SPAM)) { // if we're going to publish the post, then it's not spam! tdomf_ham_post($p); } tdomf_publish_post($p); $list .= "".$p.", "; } tdomf_log_message("Published or queued $list posts"); $message .= sprintf(__("Attempted to publish or queue these submissions: %s","tdomf"),$list); break; case 'unpublish' : foreach($posts as $p) { tdomf_unpublish_post($p); } tdomf_log_message("Un-published " . implode(", ", $posts) . " posts"); $message .= sprintf(__("Attempted to un-publish theses submissions: %s","tdomf"),implode(", ", $posts)); break; case 'spamit' : $spams = array(); foreach($posts as $p) { if(!get_post_meta($p, TDOMF_KEY_SPAM)) { tdomf_spam_post($p); $spams [] = $p; } } tdomf_log_message("Marked as spam " . implode(", ", $spams) . " posts"); $message .= sprintf(__("Marked these submissions as spam: %s","tdomf"),implode(", ", $spams)); break; case 'hamit' : $hams = array(); foreach($posts as $p) { if(get_post_meta($p, TDOMF_KEY_SPAM)) { tdomf_spam_post($p); $hams [] = $p; } } if(!empty($hams)) { tdomf_log_message("Marked as ham " . implode(", ", $hams) . " posts"); $message .= sprintf(__("Marked these submissions as not spam: %s","tdomf"),implode(", ", $hams)); } break; case 'lock' : $locks = array(); foreach($posts as $p) { if(!get_post_meta($p, TDOMF_KEY_LOCK)) { add_post_meta($p, TDOMF_KEY_LOCK, true, true); $locks [] = $p; } } if(!empty($locks)) { tdomf_log_message("Locked " . implode(", ", $locks) . " posts"); $message .= sprintf(__("Locked these posts/pages from editing: %s","tdomf"),implode(", ", $locks)); } break; case 'unlock' : $locks = array(); foreach($posts as $p) { if(get_post_meta($p, TDOMF_KEY_LOCK)) { delete_post_meta($p, TDOMF_KEY_LOCK); $locks [] = $p; } } if(!empty($locks)) { tdomf_log_message("Unlocked " . implode(", ", $locks) . " posts"); $message .= sprintf(__("Unlocked these posts/pages: %s","tdomf"),implode(", ", $locks)); } break; case 'edit_spam_recheck' : $spam_list = array(); $ham_list = array(); $edit_spam_list = array(); $edit_ham_list = array(); foreach($posts as $post) { $last_edit = tdomf_get_edits(array('post_id' => $post, 'limit' => 1)); if($last_edit != false && !empty($last_edit)) { if(tdomf_check_edit_spam($last_edit[0]->edit_id,false)) { $ham_list [] = $post; $edit_ham_list [] = $last_edit[0]->edit_id; } else { $spam_list [] = $post; $edit_spam_list [] = $last_edit[0]->edit_id; } } } tdomf_log_message('Akismet thinks these edits are spam: ' .implode(", ", $edit_spam_list) ); $message .= sprintf(__("Marked last contribution on these submissions as spam: %s.","tdomf"),implode(", ", $spam_list)); tdomf_log_message('Akismet thinks these edits are not spam: ' .implode(", ", $edit_ham_list) ); $message .= " "; $message .= sprintf(__("Marked last contribution on these submissions as not spam: %s.","tdomf"),implode(", ", $ham_list)); break; case 'edit_approve': $edit_list = array(); $post_list = array(); foreach($posts as $post) { $last_edit = tdomf_get_edits(array('post_id' => $post, 'limit' => 1)); if(!empty($last_edit) && $last_edit[0]->state != 'approved') { $edit_list [] = $last_edit[0]->edit_id; $post_list [] = $post; $user_id = $last_edit[0]->user_id; if($last_edit[0]->state == 'spam') { tdomf_hamit_edit($last_edit[0]); } wp_restore_post_revision($edit->revision_id); tdomf_set_state_edit('approved',$last_edit[0]->edit_id); if($user_id > 0) { tdomf_trust_user($user_id); } } } tdomf_log_message('These edits have been approved: ' .implode(", ", $edit_list) ); $message .= sprintf(__("Approved contributions on these submissions: %s.","tdomf"),implode(", ", $post_list)); break; case 'edit_revert': $edit_list = array(); $post_list = array(); foreach($posts as $post) { $last_edit = tdomf_get_edits(array('post_id' => $post, 'limit' => 1)); if(!empty($last_edit) && $last_edit[0]->state == 'approved' && $last_edit[0]->revision_id != 0 && $last_edit[0]->current_revision_id != 0) { $edit_list [] = $last_edit[0]->edit_id; $post_list [] = $post; wp_restore_post_revision($last_edit[0]->current_revision_id); tdomf_set_state_edit('unapproved',$last_edit[0]->edit_id); } } tdomf_log_message('These edits have been reverted: ' .implode(", ", $edit_list) ); $message .= sprintf(__("Latest contribution on these submissions have been reverted: %s.","tdomf"),implode(", ", $post_list)); break; case 'edit_delete': $edit_list = array(); $post_list = array(); foreach($posts as $post) { $last_edit = tdomf_get_edits(array('post_id' => $post, 'limit' => 1)); if(!empty($last_edit) && $last_edit[0]->state != 'approved') { $edit_list [] = $last_edit[0]->edit_id; $post_list [] = $post; if($last_edit[0]->revision_id != 0) { wp_delete_post_revision( $edit->revision_id ); tdomf_log_message("Deleting revision " . $last_edit[0]->revision_id ." on post " . $post); } if($last_edit[0]->current_revision_id != 0) { wp_delete_post_revision( $last_edit[0]->current_revision_id ); tdomf_log_message("Deleting revision " . $last_edit[0]->current_revision_id . " on post " . $post); } } tdomf_delete_edits($edit_list); } tdomf_log_message('These edits have been deleted: ' .implode(", ", $edit_list) ); $message .= sprintf(__("Latest contribution on these submissions have been deleted: %s.","tdomf"),implode(", ", $post_list)); break; case 'edit_spamit': $edit_list = array(); $post_list = array(); foreach($posts as $post) { $last_edit = tdomf_get_edits(array('post_id' => $post, 'limit' => 1)); if(!empty($last_edit) && $last_edit[0]->state != 'spam') { $edit_list [] = $last_edit[0]->edit_id; $post_list [] = $post; tdomf_spamit_edit($last_edit[0]); } } tdomf_log_message('These edits have been marked as spam: ' .implode(", ", $edit_list) ); $message .= sprintf(__("Latest contribution on these submissions have been marked as spam: %s.","tdomf"),implode(", ", $post_list)); break; case 'edit_hamit': $edit_list = array(); $post_list = array(); foreach($posts as $post) { $last_edit = tdomf_get_edits(array('post_id' => $post, 'limit' => 1)); if(!empty($last_edit) && $last_edit[0]->state == 'soam') { $edit_list [] = $last_edit[0]->edit_id; $post_list [] = $post; tdomf_hamit_edit($last_edit[0]); } } tdomf_log_message('These edits have been marked as not spam: ' .implode(", ", $edit_list) ); $message .= sprintf(__("Latest contribution on these submissions have been marked as not being spam: %s.","tdomf"),implode(", ", $post_list)); break; default : tdomf_log_message('Unexpected bulk action ' . $action . ' in moderation screen!',TDOMF_LOG_BAD); $message .= sprintf(__("Unrecognised bulk action %s,","tdomf"),$action); break; } } // else no posts selected or bulk actions // individual actions // operations on posts/pages (submissions) } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'publish_now') { $post_id = $_REQUEST['post']; check_admin_referer('tdomf-publish_'.$post_id); // if we're going to publish the post, then it's not spam! tdomf_ham_post($post_id); tdomf_publish_post($post_id,false); tdomf_log_message("Published post $post_id"); $message .= sprintf(__("Published post %d.","tdomf"),get_permalink($post_id),$post_id); } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'publish') { $post_id = $_REQUEST['post']; check_admin_referer('tdomf-publish_'.$post_id); // if we're going to publish the post, then it's not spam! tdomf_ham_post($post_id); tdomf_publish_post($post_id); tdomf_log_message("Published post $post_id"); $message .= sprintf(__("Published post %d.","tdomf"),get_permalink($post_id),$post_id); } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'unpublish') { $post_id = $_REQUEST['post']; check_admin_referer('tdomf-unpublish_'.$post_id); tdomf_unpublish_post($post_id); tdomf_log_message("Unpublished post $post_id"); $message .= sprintf(__("Unpublished post %d.","tdomf"),$post_id); } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'spamit') { $post_id = $_REQUEST['post']; check_admin_referer('tdomf-spamit_'.$post_id); if(!get_post_meta($post_id, TDOMF_KEY_SPAM)) { tdomf_spam_post($post_id); tdomf_log_message("Post $post_id submitted as spam"); $message .= sprintf(__("Post %d flagged as spam","tdomf"),$post_id); } else { $message .= sprintf(__("Did not flag post %d as being spam as it is already flagged appropriately.","tdomf"),$post_id); } } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'hamit') { $post_id = $_REQUEST['post']; check_admin_referer('tdomf-hamit_'.$post_id); if(get_post_meta($post_id, TDOMF_KEY_SPAM)) { tdomf_ham_post($post_id); tdomf_log_message("Post $post_id submitted as ham"); $message .= sprintf(__("Post %d flagged as not being spam","tdomf"),$post_id); } else { $message .= sprintf(__("Did not flag post %d as not being spam as it is already flagged appropriately.","tdomf"),$post_id); } } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'lock') { $post_id = $_REQUEST['post']; check_admin_referer('tdomf-lock_'.$post_id); if(!get_post_meta($post_id, TDOMF_KEY_LOCK)) { add_post_meta($post_id, TDOMF_KEY_LOCK, true, true); tdomf_log_message("Post $post_id locked"); $message .= sprintf(__("Post %d is now locked from editing","tdomf"),$post_id); } else { $message .= sprintf(__("Post %d is already locked from editing.","tdomf"),$post_id); } } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'unlock') { $post_id = $_REQUEST['post']; check_admin_referer('tdomf-unlock_'.$post_id); if(get_post_meta($post_id, TDOMF_KEY_LOCK)) { delete_post_meta($post_id, TDOMF_KEY_LOCK); tdomf_log_message("Post $post_id unlocked"); $message .= sprintf(__("Post %d is now unlocked.","tdomf"),$post_id); } else { $message .= sprintf(__("Post %d is already unlocked.","tdomf"),$post_id); } } // operations on edits (contributions) else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'approve_edit' ) { $edit_id = $_REQUEST['edit']; check_admin_referer('tdomf-approve_edit_'.$edit_id); $edit = tdomf_get_edit($edit_id); if($edit && ($edit->state == 'spam' || $edit->state == 'unapproved')) { if( $edit->state == 'spam') { tdomf_hamit_edit($edit); } wp_restore_post_revision($edit->revision_id); tdomf_set_state_edit('approved',$edit_id); if($edit->user_id > 0) { tdomf_trust_user($edit->user_id); } tdomf_log_message("Edit $edit_id has been approved on post " . $edit->post_id); $message .= sprintf(__('Contribution to Post %d has been approved and published',"tdomf"),get_permalink($edit->post_id),$edit->post_id); } else { tdomf_log_message("Invalid $action performed on edit $edit_id",TDOMF_LOG_BAD); $message .= sprintf(__('Invalid action %s or invalid edit identifier %d!','tdomf'),$_REQUEST['action'],$edit_id); } } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'revert_edit' ) { $edit_id = $_REQUEST['edit']; check_admin_referer('tdomf-revert_edit_'.$edit_id); $edit = tdomf_get_edit($edit_id); if($edit && $edit->state == 'approved' && $edit->revision_id != 0 && $edit->current_revision_id != 0) { wp_restore_post_revision($edit->current_revision_id); tdomf_set_state_edit('unapproved',$edit_id); tdomf_log_message("Edit $edit_id on post " . $edit->post_id . " has been reverted"); $message .= sprintf(__('Contribution to Post %d has reverted to previous revision',"tdomf"),get_permalink($edit->post_id),$edit->post_id); } else { tdomf_log_message("Invalid $action performed on edit $edit_id",TDOMF_LOG_BAD); $message .= sprintf(__('Invalid action %s or invalid edit identifier %d!','tdomf'),$_REQUEST['action'],$edit_id); } } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_edit' ) { $edit_id = $_REQUEST['edit']; check_admin_referer('tdomf-delete_edit_'.$edit_id); $edit = tdomf_get_edit($edit_id); if($edit && $edit->state != 'approved') { $post_id = $edit->post_id; if($edit->revision_id != 0) { wp_delete_post_revision( $edit->revision_id ); tdomf_log_message("Deleting revision $revision_id on post " . $post_id); } if($edit->current_revision_id != 0) { wp_delete_post_revision( $edit->current_revision_id ); tdomf_log_message("Deleting revision $current_revision_id on post " . $post_id); } tdomf_delete_edits(array($edit_id)); tdomf_log_message("Edit $edit_id on post " . $post_id . " has been deleted"); $message .= sprintf(__('Contribution to Post %d has deleted',"tdomf"),get_permalink($edit->post_id),$edit->post_id); } else { tdomf_log_message("Invalid $action performed on edit $edit_id",TDOMF_LOG_BAD); $message .= sprintf(__('Invalid action %s or invalid edit identifier %d!','tdomf'),$_REQUEST['action'],$edit_id); } } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'spamit_edit' ) { $edit_id = $_REQUEST['edit']; check_admin_referer('tdomf-spamit_edit_'.$edit_id); $edit = tdomf_get_edit($edit_id); if($edit && $edit->state != 'spam') { tdomf_spamit_edit($edit); tdomf_log_message("Marking edit $edit_id as spam!"); $message .= sprintf(__('Contribution to Post %d has been flagged as spam',"tdomf"),get_permalink($edit->post_id),$edit->post_id); } else { tdomf_log_message("Invalid $action performed on edit $edit_id",TDOMF_LOG_BAD); $message .= sprintf(__('Invalid action %s or invalid edit identifier %d!','tdomf'),$_REQUEST['action'],$edit_id); } } else if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'hamit_edit' ) { $edit_id = $_REQUEST['edit']; check_admin_referer('tdomf-hamit_edit_'.$edit_id); $edit = tdomf_get_edit($edit_id); if($edit && $edit->state == 'spam') { tdomf_spamit_edit($edit); tdomf_log_message("Marking edit $edit_id as not spam!"); $message .= sprintf(__('Contribution to Post %d has been flagged as not being spam',"tdomf"),get_permalink($edit->post_id),$edit->post_id); } else { tdomf_log_message("Invalid $action performed on edit $edit_id",TDOMF_LOG_BAD); $message .= sprintf(__('Invalid action %s or invalid edit identifier %d!','tdomf'),$_REQUEST['action'],$edit_id); } } if(!empty($message)) { ?>