if ($e->state == 'spam') { ?> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'hamit_edit', 'edit_id' => $e->edit_id, 'nonce' => 'tdomf-hamit_edit_' . $e->edit_id)); ?> " title="<?php echo htmlentities(__('Flag contributation as not being spam', 'tdomf')); ?> " ><?php _e('Not Spam', 'tdomf'); ?> <?php } else { ?> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'action' => 'spamit_edit', 'edit_id' => $e->edit_id, 'nonce' => 'tdomf-spamit_edit_' . $e->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> <?php } } }
function tdomf_dashboard_status() { $published_sub_count = tdomf_get_published_posts_count(); $approved_edits_count = tdomf_get_edits(array('state' => 'approved', 'count' => true)); $scheduled_sub_count = tdomf_get_queued_posts_count(); $spam_edits_count = tdomf_get_edits(array('state' => 'spam', 'count' => true, 'unique_post_ids' => true)); $pending_edits_count = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true)); $pending_sub_count = tdomf_get_unmoderated_posts_count(); $spam_sub_count = tdomf_get_spam_posts_count(); echo '<tr>'; $num = number_format_i18n($published_sub_count); $text = __ngettext('Approved Submission', 'Approved Submissions', $published_sub_count); $url = tdomf_get_mod_posts_url(array('show' => 'all')); echo '<td class="b b_approved"><a href="' . $url . '">' . $num . '</a></td>'; echo '<td class="first t posts"><a class="approved" href="' . $url . '">' . $text . '</a></td>'; $num = number_format_i18n($approved_edits_count); $text = __ngettext('Approved Contribution', 'Approved Contributions', $approved_edits_count); $url = tdomf_get_mod_posts_url(array('show' => 'approved_edits')); echo '<td class="b b_approved"><a href="' . $url . '">' . $num . '</a></td>'; echo '<td class="first t posts"><a class="approved" href="' . $url . '">' . $text . '</a></td>'; echo '</tr><tr>'; if ($scheduled_sub_count > 0) { $num = number_format_i18n($scheduled_sub_count); $text = __ngettext('Scheduled Submission', 'Scheduled Submissions', $scheduled_sub_count); $url = tdomf_get_mod_posts_url(array('show' => 'scheduled')); echo '<td class="b posts"><a href="' . $url . '">' . $num . '</a></td>'; echo '<td class="first t posts"><a href="' . $url . '">' . $text . '</a></td>'; echo '</tr><tr>'; } if (get_option(TDOMF_OPTION_SPAM) && ($spam_edits_count > 0 || $spam_sub_count > 0)) { $num = number_format_i18n($pending_sub_count); $text = __ngettext('Pending Submission', 'Pending Submissions', $pending_sub_count); $url = tdomf_get_mod_posts_url(array('show' => 'pending_submissions')); echo '<td class="b b-waiting"><a class="waiting" href="' . $url . '"><span class=\'pending-count\'>' . $num . '</span></a></td>'; echo '<td class="first t"><a class="waiting" href="' . $url . '">' . $text . '</a></td>'; $num = number_format_i18n($spam_sub_count); $text = __ngettext('Spam Submission', 'Spam Submissions', $spam_sub_count); $url = tdomf_get_mod_posts_url(array('show' => 'spam_submissions')); echo '<td class="b b-spam"><a class="waiting" href="' . $url . '"><span class=\'spam-count\'>' . $num . '</span></a></td>'; echo '<td class="last t"><a class="spam" href="' . $url . '">' . $text . '</a></td>'; echo '</tr><tr>'; $num = number_format_i18n($pending_edits_count); $text = __ngettext('Pending Contribution', 'Pending Contributions', $pending_edits_count); echo '<td class="b b-waiting"><a class="waiting" href="' . $url . '"><span class=\'pending-count\'>' . $num . '</span></a></td>'; echo '<td class="first t"><a class="waiting" href="' . $url . '">' . $text . '</a></td>'; $num = number_format_i18n($spam_edits_count); $text = __ngettext('Spam Contribution', 'Spam Contributions', $spam_edits_count); $url = tdomf_get_mod_posts_url(array('show' => 'spam_edits')); echo '<td class="b b-waiting"><a class="waiting" href="' . $url . '"><span class=\'pending-count\'>' . $num . '</span></a></td>'; echo '<td class="first t"><a class="waiting" href="' . $url . '">' . $text . '</a></td>'; } else { $num = number_format_i18n($pending_sub_count); $url = tdomf_get_mod_posts_url(array('show' => 'pending_submissions')); $text = __ngettext('Pending Submission', 'Pending Submissions', $pending_sub_count); echo '<td class="b b-waiting"><a class="waiting" href="' . $url . '"><span class=\'pending-count\'>' . $num . '</span></a></td>'; echo '<td class="first t"><a class="waiting" href="' . $url . '">' . $text . '</a></td>'; $num = number_format_i18n($pending_edits_count); $url = tdomf_get_mod_posts_url(array('show' => 'pending_edits')); $text = __ngettext('Pending Contribution', 'Pending Contributions', $pending_edits_count); echo '<td class="b b-waiting"><a class="waiting" href="' . $url . '"><span class=\'pending-count\'>' . $num . '</span></a></td>'; echo '<td class="last t"><a class="waiting" href="' . $url . '">' . $text . '</a></td>'; } echo '</tr>'; }
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; ?> <div class="wrap"> <?php /* screen_icon(); */ ?> <h2> <?php if ($user_id || $ip) { if ($user_id) { $u = get_userdata($user_id); printf(__('Posts submitted by user %s', 'tdomf'), $u->user_login); } else { if ($ip) { printf(__('Posts submitted from IP %s', 'tdomf'), $ip); } } } else { ?> <?php _e('Moderation', 'tdomf'); ?> <?php } ?> </h2> <?php /*if(count($posts) <= 0) { ?> <div class="clear"></div> <p><?php _e('No submissions found','tdomf') ?></p> </div> <!-- wrap --><?php return; }*/ ?> <form id="posts-filter" action="<?php tdomf_get_mod_posts_url(true, $show, 0); ?> " method="post"> <!-- hidden vars --> <ul class="subsubsub"> <?php if ($all_count > 0) { ?> <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> <?php } ?> <?php if ($pending_count > 0) { ?> <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> <?php } ?> <?php if ($scheduled_count > 0) { ?> <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> <?php } ?> <?php if ($published_count > 0) { ?> <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> <?php } ?> <?php if ($spam_count > 0) { ?> <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> <?php } ?> <?php if ($approved_edits_count > 0) { ?> <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> <?php } ?> <?php if ($pending_edits_count > 0) { ?> <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> <?php } ?> <?php if ($spam_edits_count > 0) { ?> <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> <?php } ?> </ul> <div class="tablenav"> <?php $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%', tdomf_get_mod_posts_url(array())), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $max_pages, 'current' => $paged)); ?> <?php if ($page_links) { ?> <div class="tablenav-pages"><?php $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s', number_format_i18n($offset), number_format_i18n($offset + count($posts)), number_format_i18n($max_items), $page_links); echo $page_links_text; ?> </div> <?php } ?> <div class="view-switch"> <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> <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> </div> <?php $form_ids_check = array(); foreach ($form_ids as $form) { if (TDOMF_Widget::isSubmitForm(false, $form->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)) { ?> <select name='form_id'> <option value="-1" selected="selected"><?php _e('Show All', 'tdomf'); ?> </option> <?php foreach ($form_ids_check as $form) { ?> <option value="<?php echo $form; ?> " <?php if ($form_id == $form) { ?> selected="selected" <?php } ?> ><?php printf(__('Form #%d', 'tdomf'), $form); ?> </option> <?php } ?> </select> <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?> " class="button-secondary" /> <?php } ?> <div class="clear"></div> </div> <!-- tablenav --> <div class="clear"></div> <table class="widefat post fixed" cellspacing="0"> <thead> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" id="title" class="manage-column column-title" style=""><?php _e('Post', 'tdomf'); ?> </th> <th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php _e('Submitted', 'tdomf'); ?> </th> <th scope="col" id="edited" class="manage-column column-edited" style=""> <?php if ($show == 'approved_edits') { _e('Edit', 'tdomf'); } else { if ($show == 'pending_edits') { _e('Pending Edit', 'tdomf'); } else { if ($show == 'spam_edits') { _e('Spam Edit', 'tdomf'); } else { _e('Most Recent Edit', 'tdomf'); } } } ?> </th> <th scope="col" id="status" class="manage-column column-status" style=""><?php _e('Status', 'tdomf'); ?> </th> </tr> </thead> <tfoot> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th> <th scope="col" id="title" class="manage-column column-title" style=""><?php _e('Post', 'tdomf'); ?> </th> <th scope="col" id="submitted" class="manage-column column-submitted" style=""><?php _e('Submitted', 'tdomf'); ?> </th> <th scope="col" id="edited" class="manage-column column-edited" style=""> <?php if ($show == 'approved_edits') { _e('Edit', 'tdomf'); } else { if ($show == 'pending_edits') { _e('Pending Edit', 'tdomf'); } else { if ($show == 'spam_edits') { _e('Spam Edit', 'tdomf'); } else { _e('Most Recent Edit', 'tdomf'); } } } ?> </th> <th scope="col" id="status" class="manage-column column-status" style=""><?php _e('Status', 'tdomf'); ?> </th> </tr> </tfoot> <tbody> <?php if (!empty($posts)) { foreach ($posts as $p) { $count++; ?> <?php $post =& get_post($p->ID); /* seems I need this later */ ?> <?php if ($show == 'approved_edits') { // not really the "last" edit but lest pretend $last_edit = array(tdomf_get_edit($p->edit_id)); } else { $last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 2)); /* and need this earlier too */ } ?> <?php $form_id = get_post_meta($p->ID, TDOMF_KEY_FORM_ID, true); ?> <?php $queue = intval(tdomf_get_option_form(TDOMF_OPTION_QUEUE_PERIOD, $form_id)); if ($queue > 0) { $queue = true; } else { $queue = false; } ?> <?php $is_spam = get_post_meta($p->ID, TDOMF_KEY_SPAM); ?> <?php $locked = get_post_meta($post->ID, TDOMF_KEY_LOCK, true); ?> <tr id='post-<?php echo $p->ID; ?> ' class='<?php if ($count % 2 != 0) { ?> alternate <?php } ?> status-<?php echo $post->post_status; ?> iedit' valign="top"> <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php echo $p->ID; ?> " /></th> <td class="post-title column-title"><strong><a class="row-title" href="post.php?action=edit&post=<?php echo $p->ID; ?> " title="Edit"><?php echo $post->post_title; ?> </a></strong> <?php /*$fuoptions = TDOMF_WidgetUploadFiles::getOptions($form_id);*/ $index = 0; $filelinks = ""; while (true) { $filename = get_post_meta($p->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 .= "<a href='{$uri}' title='" . htmlentities($filename) . "'>{$index}</a>, "; $index++; } if (!empty($filelinks)) { ?> <?php _e('Uploaded Files: ', 'tdomf'); echo $filelinks; ?> <br/> <?php } ?> <?php if ('excerpt' == $mode) { # Have to create our own excerpt, the_excerpt() doesn't cut it # here :( if (empty($post->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 '<blockquote>' . $excerpt . '</blockquote>'; } ?> <?php if (get_option(TDOMF_OPTION_MOD_SHOW_LINKS)) { ?> <div> <?php } else { ?> <div class="row-actions"> <?php } ?> <?php if ($post->post_status == 'future') { $bulk_sub_publish_now = true; ?> <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> <?php } else { if ($post->post_status != 'publish') { ?> <?php if ($queue) { $bulk_sub_publish_now = true; $bulk_sub_publish = true; ?> <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> <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> <?php } else { $bulk_sub_publish = true; ?> <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> <?php } ?> <?php } else { if ($post->post_status == 'publish') { $bulk_sub_unpublish = true; ?> <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> <?php } } } ?> <span class='delete'><a class='submitdelete' title='Delete this submission' href='<?php echo wp_nonce_url("post.php?action=delete&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> <?php if ($locked) { $bulk_sub_unlock = true; ?> <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> <?php } else { $bulk_sub_lock = true; ?> <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> <?php } ?> <?php if ($post->post_status == 'publish') { ?> <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> <?php } else { ?> <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> <?php } ?> <span class='edit'><a href="post.php?action=edit&post=<?php echo $p->ID; ?> " title="<?php echo htmlentities(__('Edit this submission', 'tdomf')); ?> "><?php _e('Edit', 'tdomf'); ?> </a> <?php if (get_option(TDOMF_OPTION_SPAM)) { ?> |</span><?php } ?> <?php if (get_option(TDOMF_OPTION_SPAM)) { if (!$is_spam) { $bulk_sub_spamit = true; ?> <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> <?php } else { $bulk_sub_hamit = true; ?> <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> <?php } } ?> </div> </td> <td class="column-submitted"> <ul style="font-size: 11px;"> <li> <?php $name = get_post_meta($p->ID, TDOMF_KEY_NAME, true); $email = get_post_meta($p->ID, TDOMF_KEY_EMAIL, true); $user_id = get_post_meta($p->ID, TDOMF_KEY_USER_ID, true); if ($user_id != false) { ?> <!-- <a href="user-edit.php?user_id=<?php echo $user_id; ?> " class="edit"> --> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'user_id' => $user_id, 'ip' => false, 'form_id' => false)); ?> "> <?php $u = get_userdata($user_id); echo $u->user_login; ?> </a> <?php } else { if (!empty($name) && !empty($email)) { echo $name . " (" . $email . ")"; } else { if (!empty($name)) { echo $name; } else { if (!empty($email)) { echo $email; } else { _e("N/A", "tdomf"); } } } } ?> / <?php $ip = get_post_meta($p->ID, TDOMF_KEY_IP, true); if (!empty($ip)) { ?> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'ip' => $ip, 'user_id' => false, 'form_id' => false)); ?> "> <?php } ?> <?php echo $ip; ?> <?php if (!empty($ip)) { ?> </a> <?php } ?> </li> <li> <?php if ($form_id == false || tdomf_form_exists($form_id) == false) { ?> <?php _e("Unknown or deleted form", "tdomf"); ?> <?php } else { $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$form_id}"; $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id); echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s</a>', 'tdomf'), $form_id, $form_name) . '</a>'; } ?> </li> <li> <?php if ($post->post_status != 'publish' && $post->post_status != 'future') { $post_date_gmt = get_post_meta($p->ID, TDOMF_KEY_SUBMISSION_DATE, true); if ($post_date_gmt) { echo mysql2date(__('Y/m/d'), $post_date_gmt); } else { #echo mysql2date(__('Y/m/d'), $post->post_modified_gmt); } } else { echo mysql2date(__('Y/m/d'), $post->post_date_gmt); } ?> </li> </ul> </td> <td class="column-edited"> <?php /*$last_edit = tdomf_get_edits(array('post_id' => $p->ID, 'limit' => 1));*/ if ($last_edit == false || empty($last_edit) || $last_edit == NULL) { ?> <!-- no edits --> <?php } else { $previous_edit = false; if (count($last_edit) == 2) { $previous_edit = $last_edit[1]; } $last_edit = $last_edit[0]; # only care about the first entry $last_edit_data = maybe_unserialize($last_edit->data); ?> <ul style="font-size: 11px;"> <li><?php $user_id = $last_edit->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) { ?> <a href="user-edit.php?user_id=<?php echo $user_id; ?> " class="edit"> <?php $u = get_userdata($user_id); echo $u->user_login; ?> </a> <?php } else { if (!empty($name) && !empty($email)) { echo $name . " (" . $email . ")"; } else { if (!empty($name)) { echo $name; } else { if (!empty($email)) { echo $email; } else { _e("N/A", "tdomf"); } } } } ?> / <?php echo $last_edit->ip; ?> </li> <li> <?php $form_id = $last_edit->form_id; if ($form_id == false || tdomf_form_exists($form_id) == false) { ?> <?php _e("Unknown or deleted form", "tdomf"); ?> <?php } else { $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$form_id}"; $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id); echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s', 'tdomf'), $form_id, $form_name) . '</a>'; } ?> </li> <li><?php echo mysql2date(__('Y/m/d'), $last_edit->date_gmt); ?> </li> <li><?php switch ($last_edit->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; } ?> </li> </ul> <div class="row-actions"> <?php /* nothing to do if revisioning is disabled for the edits... */ if ($last_edit->revision_id != 0) { ?> <?php if ($last_edit->state != 'approved') { ?> <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> <!-- <span class='view'><a href="revision.php?revision=<?php echo $last_edit->revision_id; ?> "><?php _e('View', 'tdomf'); ?> </a> |<span> --> <?php } ?> <?php if ($last_edit->state == 'approved') { $bulk_edit_revert = true; ?> <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> <?php } else { if ($last_edit->state == 'unapproved' || $last_edit->state == 'spam') { $bulk_edit_delete = true; $bulk_edit_approve = true; ?> <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> <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> <?php } } ?> <?php if ($previous_edit) { ?> <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> <?php } else { ?> <!-- <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> --> <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> <?php } ?> <?php if (get_option(TDOMF_OPTION_SPAM)) { ?> |<?php } ?> </span> <?php if (get_option(TDOMF_OPTION_SPAM)) { if ($last_edit->state == 'spam') { $bulk_edit_hamit = true; ?> <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> <?php } else { $bulk_edit_spamit = true; ?> <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> <?php } } ?> <?php } ?> </div> <?php } ?> </td> <td class="status column-status"> <!-- todo take into account edited status --> <?php if ($is_spam && $post->post_status == 'draft') { ?> <?php _e('Spam', "tdomf"); ?> <?php } else { switch ($post->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'); } } ?> </td> <?php } } ?> </tbody> </table> <div class="tablenav"> <?php if ($page_links) { echo "<div class='tablenav-pages'>{$page_links_text}</div>"; } ?> <?php if (count($posts) > 0) { ?> <div class="alignleft actions"> <select name="action"> <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?> </option> <?php if ($bulk_sub_publish_now) { ?> <option value="publish_now"><?php _e('Publish Submissions (Now)', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_publish) { ?> <option value="publish"><?php _e('Publish/Queue Submissions', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_unpublish) { ?> <option value="unpublish"><?php _e('Un-publish Submissions', 'tdomf'); ?> </option> <?php } ?> <option value="delete"><?php _e('Delete Submissions', 'tdomf'); ?> </option> <?php if ($bulk_sub_unlock) { ?> <option value="unlock"><?php _e('Unlock Submissions', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_lock) { ?> <option value="lock"><?php _e('Lock Submissions', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_spamit) { ?> <option value="spamit"><?php _e('Mark Submissions as Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_hamit) { ?> <option value="hamit"><?php _e('Mark Submissions as Not Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_sub_hamit || $bulk_sub_spamit) { ?> <option value="spam_recheck"><?php _e('Recheck Submssions for Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_approve) { ?> <option value="edit_approve"><?php _e('Approve Edits', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_revert) { ?> <option value="edit_revert"><?php _e('Revert Edits', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_delete) { ?> <option value="edit_delete"><?php _e('Delete Edits', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_spamit) { ?> <option value="edit_spamit"><?php _e('Mark Edits as Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_hamit) { ?> <option value="edit_hamit"><?php _e('Mark Edits as not Spam', 'tdomf'); ?> </option> <?php } ?> <?php if ($bulk_edit_hamit || $bulk_edit_spamit) { ?> <option value="edit_spam_recheck"><?php _e('Recheck Edits for Spam', 'tdomf'); ?> </option> <?php } ?> </select> <input type="submit" value="<?php _e('Apply'); ?> " name="doaction" id="doaction" class="button-secondary action" /> <?php wp_nonce_field('tdomf-moderate-bulk'); } ?> <!-- hide filters <select name='form'> <option value="-1" selected="selected"><?php _e('Show All Forms', 'tdomf'); ?> </option> <?php foreach ($form_ids as $form) { ?> <option value="<?php echo $form->form_id; ?> "><?php printf(__('Form #%d', 'tdomf'), $form->form_id); ?> </option> <?php } ?> </select> --> <br class="clear" /> </div> <!-- tablenav --> <br class="clear" /> </div> <!-- wrap --> </form> <?php }
function tdomf_notify_admins_edit($edit_id, $form_id) { global $wpdb, $tdomf_form_widgets_adminemail; // grab email addresses $email_list = tdomf_get_admin_emails($form_id); if ($email_list == "") { tdomf_log_message("Could not get any email addresses to notify. No moderation notification email sent.", TDOMF_LOG_BAD); return false; } $edit = tdomf_get_edit($edit_id); // Submitter Info // $can_ban_user = false; $submitter_string = "N/A"; if ($edit->user_id != 0) { $submitter_string = $edit->data["user_login"]; $can_ban_user = true; } else { if (isset($edit->data[TDOMF_KEY_NAME])) { $submitter_string = $edit->data[TDOMF_KEY_NAME]; if (isset($edit->data[TDOMF_KEY_EMAIL])) { $submitter_string .= " (" . $edit->data[TDOMF_KEY_EMAIL] . ")"; } } } // Title and content of post // if ($edit->revision_id != 0) { $post = get_post($edit->revision_id); } else { $post = get_post($edit->post_id); } $content = $post->post_content; $title = $post->post_title; $status = $post->post_status; // Links // $moderate_edit_link = tdomf_get_mod_posts_url(array()); $approve_edit_link = tdomf_get_mod_posts_url(array('action' => 'approve_edit', 'edit_id' => $edit_id, 'nonce' => 'tdomf-approve_edit_' . $edit_id)); $delete_edit_link = tdomf_get_mod_posts_url(array('action' => 'delete_edit', 'edit_id' => $edit_id, 'nonce' => 'tdomf-approve_edit_' . $edit_id)); $compare_edit_link = get_bloginfo('wpurl') . "/wp-admin/revision.php?action=diff&right=" . $edit->revision_id . "&left=" . $edit->current_revision_id; $spamit_edit_link = tdomf_get_mod_posts_url(array('action' => 'hamit_edit', 'edit_id' => $edit_id, 'nonce' => 'tdomf-hamit_edit_' . $edit_id)); $hamit_edit_link = tdomf_get_mod_posts_url(array('action' => 'spamit_edit', 'edit_id' => $edit_id, 'nonce' => 'tdomf-hamit_edit_' . $edit_id)); $view_edit_link = get_bloginfo('wpurl') . "/wp-admin/revision.php?revision=" . $edit->revision_id; $view_post_link = get_permalink($edit->post_id); $is_spam = $edit->state == 'spam' && get_option(TDOMF_OPTION_SPAM); if ($can_ban_user) { $ban_user_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_manage_menu&action=ban&user={$edit->user_id}"; } $ban_ip_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=tdomf_show_manage_menu&mode=ip&action=ban&ip={$edit->ip}"; // Subject line // if ($is_spam) { $subject = sprintf(__("[SPAM] [%s] Please moderate this spam edit (%d)", "tdomf"), get_bloginfo('title'), $edit_id); } else { if ($edit->state == 'approved') { $subject = sprintf(__("[%s] Edit (%d) on Post '%s' has been approved", "tdomf"), get_bloginfo('title'), $edit_id, $title); } else { $subject = sprintf(__("[%s] Please moderate this new edit (%d) from '%s'", "tdomf"), get_bloginfo('title'), $edit_id, $submitter_name); } } // Email Body // if ($edit->state == 'approved') { $email_msg = sprintf(__("Edit (%d) on Post \"%s\" from %s has been published.\n\n", "tdomf"), $edit_id, $title, $submitter_string); } else { $email_msg = sprintf(__("A new edit (%d) on post with title \"%s\" from %s is awaiting your approval.\n\n", "tdomf"), $edit_id, $title, $submitter_string); } if ($is_spam) { $email_msg = __("This edit is considered SPAM\n\n", "tdomf"); } $email_msg .= sprintf(__("Form ID: %d (\"%s\")\n", "tdomf"), $edit->form_id, tdomf_get_option_form(TDOMF_OPTION_NAME, $edit->form_id)); $email_msg .= sprintf(__("Submitter IP: %s.\n\n", "tdomf"), $edit->ip); $email_msg .= sprintf(__("View Post: %s\n", "tdomf"), $view_post_link); $email_msg .= sprintf(__("View Edit: %s\n", "tdomf"), $view_edit_link); if ($edit->revision_id != 0 && $edit->current_revision_id != 0) { $email_msg .= sprintf(__("Compare with previous: %s.\n", "tdomf"), $compare_edit_link); } if ($edit->state != 'approved') { $email_msg .= sprintf(__("Approve edit (will also flag edit as not SPAM): %s\n", "tdomf"), $approve_edit_link); if (!$is_spam && get_option(TDOMF_OPTION_SPAM)) { $email_msg .= sprintf(__("Flag Edit as SPAM: %s\n", "tdomf"), $spamit_edit_link); } else { if ($is_spam) { $email_msg .= sprintf(__("Flag Edit as not SPAM: %s\n", "tdomf"), $hamit_edit_link); } } $email_msg .= sprintf(__("Ban IP: %s\n", "tdomf"), $ban_ip_link); if ($can_ban_user) { $email_msg .= sprintf(__("Ban User: %s\n", "tdomf"), $ban_user_link); } $email_msg .= sprintf(__("Delete Edit: %s\n", "tdomf"), $delete_edit_link); } $email_msg .= sprintf(__("You can moderate all edits from %s\n", "tdomf"), $moderate_edit_link); if ($is_spam) { $email_msg .= sprintf(__("\nTitle of the post: %s", "tdomf"), $title); } $email_msg .= sprintf(__("\nContent of the post: \n\n %s \n\n", "tdomf"), $content); // Widgets:adminemail // $widget_args = array("before_widget" => "", "after_widget" => "\n\n", "before_title" => "", "after_title" => "\n\n", "tdomf_form_id" => $form_id, "edit_id" => $edit_id); if ($edit->revision_id != 0) { $widget_args["post_ID"] = $edit->revision_id; $widget_args["tdomf_post_id"] = $edit->revision_id; } else { $widget_args["post_ID"] = $edit->post_id; $widget_args["tdomf_post_id"] = $edit->post_id; } $widget_order = tdomf_get_widget_order($form_id); foreach ($widget_order as $w) { if (isset($tdomf_form_widgets_adminemail[$w])) { $temp_message = call_user_func($tdomf_form_widgets_adminemail[$w]['cb'], $widget_args, $tdomf_form_widgets_adminemail[$w]['params']); if ($temp_message != NULL && trim($temp_message) != "") { $email_msg .= $temp_message; } } } $email_msg .= sprintf(__("Best Regards\nTDOMF @ %s", "tdomf"), get_bloginfo("title")); // prepare body // $email_msg = str_replace("\n", "\r\n", $email_msg); // Use custom from field // if (tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id)) { // We can modify the "from" field by using the "header" option at the end! // $headers = "MIME-Version: 1.0\n" . "From: " . tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id) . "\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; return @wp_mail($email_list, $subject, $email_msg, $headers); } else { return @wp_mail($email_list, $subject, $email_msg); } }
function tdomf_show_manage_ip_menu() { $limit = 15; if (isset($_REQUEST['limit'])) { $limit = intval($_REQUEST['limit']); } $offset = 0; if (isset($_REQUEST['offset'])) { $offset = intval($_REQUEST['offset']); } if (isset($_REQUEST['f']) && $_REQUEST['f'] == "1") { $ips = tdomf_get_ips_banned($offset, $limit); $max = tdomf_get_ips_banned_count(); } else { $ips = tdomf_get_ips($offset, $limit); $max = tdomf_get_ips_count(); } // for checking if an ip is banned! $banned_ips = tdomf_get_ips_banned(); ?> <div class="wrap"> <?php if (isset($_REQUEST['f']) && $_REQUEST['f'] == "1") { ?> <h2><?php if ($offset > 0) { _e("Previous Banned IPs", "tdomf"); } else { printf(__('Last %d Banned IPs', 'tdomf'), $limit); } ?> </h2> <?php } else { ?> <h2><?php if ($offset > 0) { _e("Previous IPs", "tdomf"); } else { printf(__('Last %d IPs', 'tdomf'), $limit); } ?> </h2> <?php } ?> <p><?php _e("You can ban an IP address. This means no-one with this IP address can use the form. It has no impact on anything else. i.e. they can still read, comment and post.", "tdomf"); ?> </p> <p><a href="admin.php?page=tdomf_show_manage_menu"><?php _e("« Manage Users", "tdomf"); ?> </a></p> <form method="post" action="admin.php?page=tdomf_show_manage_menu&mode=ip" id="filterips" name="filterips" > <fieldset> <b><?php _e("Filter Users", "tdomf"); ?> </b> <select name="f"> <option value="0" <?php if (!isset($_REQUEST['f']) || isset($_REQUEST['f']) && $_REQUEST['f'] == "0") { ?> selected <?php } ?> ><?php _e("All IPs of submitters", "tdomf"); ?> <option value="1" <?php if (isset($_REQUEST['f']) && $_REQUEST['f'] == "1") { ?> selected <?php } ?> ><?php _e("Banned IPs", "tdomf"); ?> </select> <input type="submit" name="submit" value="Show" /> </fieldset> </form> <br/> <?php if (count($ips) <= 0) { _e("There are no ips to moderate with this filter.", "tdomf"); } else { ?> <script type="text/javascript"> <!-- function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].checked == true) num++; } } return num; } //--> </script> <form method="post" action="admin.php?page=tdomf_show_manage_menu&mode=ip" id="moderateips" name="moderateips" > <table class="widefat"> <tr> <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('moderateips'));" /></th> <th scope="col"><?php _e("IP", "tdomf"); ?> </th> <th scope="col"><?php _e("Status", "tdomf"); ?> </th> <th scope="col" colspan="1" style="text-align: center">Actions</th> </tr> <?php $i = 0; foreach ($ips as $ip) { if (!is_string($ip)) { $ip = $ip->ip; } if (!empty($ip)) { $i++; if ($i % 2 == 0) { ?> <tr id='x' class=''> <?php } else { ?> <tr id='x' class='alternate'> <?php } ?> <td><input type="checkbox" name="moderateips[]" value="<?php echo $ip; ?> " /></td> <th scope="row"> <a href="<?php tdomf_get_mod_posts_url(array('echo' => true, 'ip' => $ip)); ?> "> <?php echo $ip; ?> </a> </th> <td><?php if (in_array($ip, $banned_ips)) { _e("Banned", "tdomf"); } else { _e("Normal", "tdomf"); } ?> </td> <?php if (isset($_REQUEST['f'])) { $farg = "&f=" . $_REQUEST['f']; } ?> <td> <?php if (in_array($ip, $banned_ips)) { ?> <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_manage_menu&mode=ip&action=reset&ip={$ip}{$farg}&offset={$offset}&limit={$limit}", 'tdomf-reset-ip_' . $ip); ?> "><?php _e("Un-ban", "tdomf"); ?> </a> <?php } else { ?> <a href="<?php echo wp_nonce_url("admin.php?page=tdomf_show_manage_menu&mode=ip&action=ban&ip={$ip}{$farg}&offset={$offset}&limit={$limit}", 'tdomf-ban-ip_' . $ip); ?> "><?php _e("Ban", "tdomf"); ?> </a> <?php } ?> </td> </tr> <?php } ?> <?php } ?> </table> <?php $farg = "0"; if (isset($_REQUEST['f'])) { $farg = $_REQUEST['f']; } ?> <input type="hidden" name="limit" id="limit" value="<?php echo $limit; ?> " /> <input type="hidden" name="offset" id="offset" value="<?php echo $offset; ?> " /> <input type="hidden" name="f" id="f" value="<?php echo $farg; ?> " /> <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('tdomf-manage-bulk_ips'); } ?> <p class="submit"> <?php if (!isset($_REQUEST['f']) || $_REQUEST['f'] == "0") { ?> <input type="submit" name="ban_button" class="delete" value="<?php _e("Ban"); ?> " onclick="var numchecked = getNumChecked(document.getElementById('moderateips')); if(numchecked < 1) { alert('Please select some ips to ban'); return false } return confirm('You are about to ban ' + numchecked + ' ips \n \'Cancel\' to stop, \'OK\' to ban.')" /> <?php } ?> <input type="submit" name="clear_button" value="<?php _e("Reset"); ?> " onclick="var numchecked = getNumChecked(document.getElementById('moderateips')); if(numchecked < 1) { alert('Please select some ips to reset'); return false } return confirm('You are about to reset the status of ' + numchecked + ' ips \n \'Cancel\' to stop, \'OK\' to reset')" /> </p> </form> <br/><br/> <div class="navigation"> <?php if ($max - ($offset + $limit) > 0) { ?> <div class="alignleft"><a href="admin.php?page=tdomf_show_manage_menu&mode=ip&offset=<?php echo $offset + $limit; if (isset($_REQUEST['f'])) { echo "&f=" . $_REQUEST['f']; } ?> ">« <?php _e("Previous Entries", "tdomf"); ?> </a></div> <?php } ?> <?php if ($offset > 0) { ?> <div class="alignright"><a href="admin.php?page=tdomf_show_manage_menu&mode=ip&offset=<?php echo $offset - $limit; if (isset($_REQUEST['f'])) { echo "&f=" . $_REQUEST['f']; } ?> "><?php _e("Next Entries", "tdomf"); ?> »</a></div> <?php } ?> </div> <br/><br/> <?php } ?> </div> <!-- wrap --> <?php }