Esempio n. 1
0
     return;
 }
 $edits = tdomf_get_edits(array('post_id' => $post_id));
 $last_edit = tdomf_get_edits(array('post_id' => $post_id, 'limit' => 1));
 if (!empty($last_edit)) {
     $last_edit = $last_edit[0];
 } else {
     $last_edit = false;
 }
 $last_approved_edit = tdomf_get_edits(array('post_id' => $post_id, 'limit' => 1, 'state' => 'approved'));
 if (!empty($last_approved_edit)) {
     $last_approved_edit = $last_approved_edit[0];
 } else {
     $last_approved_edit = false;
 }
 $first_edit = tdomf_get_edits(array('post_id' => $post_id, 'limit' => 1, 'sort' => 'ASC'));
 if (!empty($first_edit)) {
     $first_edit = $first_edit[0];
 } else {
     $first_edit = false;
 }
 $doCompare = false;
 $left = $edit_id;
 if (isset($_REQUEST['left'])) {
     $left = $_REQUEST['left'];
     $doCompare = true;
 }
 $right = 'current';
 if (isset($_REQUEST['right'])) {
     $right = $_REQUEST['right'];
     $doCompare = true;
Esempio n. 2
0
function tdomf_moderation_handler()
{
    $message .= "";
    # this means a post was deleted
    #
    if (isset($_REQUEST['deleted'])) {
        $message .= __("Submissions deleted. ", "tdomf");
    }
    // bulk actions
    if (isset($_REQUEST['doaction']) && isset($_REQUEST['action']) && isset($_REQUEST['post'])) {
        $posts = $_REQUEST['post'];
        $action = $_REQUEST['action'];
        if ($action != -1 && is_array($posts) && !empty($posts)) {
            check_admin_referer('tdomf-moderate-bulk');
            switch ($action) {
                case 'spam_recheck':
                    $spam_list = array();
                    $ham_list = array();
                    foreach ($posts as $post) {
                        if (tdomf_check_submissions_spam($post)) {
                            $ham_list[] = $post;
                        } else {
                            $spam_list[] = $post;
                        }
                    }
                    tdomf_log_message('Akismet thinks these submissions are spam: ' . implode(", ", $spam_list));
                    $message .= sprintf(__("Marked these submissions as spam: %s.", "tdomf"), implode(", ", $spam_list));
                    tdomf_log_message('Akismet thinks these posts are not spam: ' . implode(", ", $ham_list));
                    $message .= " ";
                    $message .= sprintf(__("Marked these submissions as not spam: %s.", "tdomf"), implode(", ", $ham_list));
                    break;
                case 'delete':
                    foreach ($posts as $p) {
                        wp_delete_post($p);
                    }
                    tdomf_log_message('Deleted ' . implode(", ", $posts) . ' posts');
                    $message .= sprintf(__("Deleted submissions: %s", "tdomf"), implode(", ", $posts));
                    break;
                case 'publish_now':
                    $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, false);
                        $list .= "<a href=\"" . get_permalink($p) . "\">" . $p . "</a>, ";
                    }
                    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 .= "<a href=\"" . get_permalink($p) . "\">" . $p . "</a>, ";
                    }
                    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 <a href=\"%s\">%d</a>.", "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 <a href=\"%s\">%d</a>.", "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);
                                    }
                                } 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 <a href="%s">Post %d</a> 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 <a href="%s">Post %d</a> 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 <a href="%s">Post %d</a> 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 <a href="%s">Post %d</a> 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 <a href="%s">Post %d</a> 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)) {
        ?>
      <div id="message" class="updated fade"><p><?php 
        echo $message;
        ?>
</p></div>
   <?php 
    }
}
Esempio n. 3
0
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>';
}
Esempio n. 4
0
function tdomf_cleanup_spam()
{
    global $wpdb;
    if (!get_option(TDOMF_OPTION_SPAM_AUTO_DELETE)) {
        return;
    }
    // delete edit spam older than a month
    $edit_list = '';
    $time_diff = tdomf_timestamp_wp_sql(time() - 2592000);
    // 1 month in seconds
    $edits = tdomf_get_edits(array('state' => 'spam', 'older_than' => $time_diff));
    if (count($edits) > 0) {
        foreach ($edits as $edit) {
            $edit_list[] = $edit->edit_id;
            if ($edit->revision_id != 0) {
                wp_delete_post_revision($edit->revision_id);
            }
            if ($edit->current_revision_id != 0) {
                wp_delete_post_revision($last_edit[0]->current_revision_id);
            }
        }
        tdomf_delete_edits($edit_list);
        tdomf_log_message("Deleting spam edits older than a month: " . implode(",", $edit_list));
    }
    // delete spam more than a month old
    $query = "SELECT ID, post_modified_gmt\n             FROM {$wpdb->posts}\n             LEFT JOIN {$wpdb->postmeta} ON ({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)\n             WHERE meta_key = '" . TDOMF_KEY_SPAM . "'";
    $spam_posts = $wpdb->get_results($query);
    if (count($spam_posts) > 0) {
        $list = "";
        foreach ($spam_posts as $post) {
            // we use to use post_modified_gmt but since 2.6 or 2.7 this is
            // no longer set when the post is initially created in draft
            //
            $post_date_gmt = get_post_meta($post->ID, TDOMF_KEY_SUBMISSION_DATE, true);
            if ($post_date_gmt != false) {
                $post_date_ts = mysql2date('U', $post_date_gmt);
                $diff = time() - $post_date_ts;
                if ($diff >= 2952000) {
                    // 1 month (30 days)
                    $list .= $post->ID . ", ";
                    wp_delete_post($post->ID);
                }
                tdomf_log_message($post->ID . ' ' . $post_data_ts . ' ' . $diff);
            } else {
                // old way
                //
                $last_updated = strtotime($post->post_modified_gmt);
                $diff = time() - $last_updated;
                if ($diff >= 2952000) {
                    // 1 month (30 days)
                    $list .= $post->ID . ", ";
                    wp_delete_post($post->ID);
                }
            }
        }
        if ($list != "") {
            tdomf_log_message("Deleting spam posts older than a month: {$list}");
        }
    } else {
        #tdomf_log_message("No spam submissions to clean up!",TDOMF_LOG_GOOD);
    }
}
Esempio n. 5
0
function tdomf_add_menus()
{
    $unmod_count = tdomf_get_unmoderated_posts_count();
    $unmod_count += tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
    /*if(tdomf_wp25() && $unmod_count > 0) {
          add_menu_page(__('TDO Mini Forms', 'tdomf'), sprintf(__("TDO Mini Forms <span id='awaiting-mod' class='count-%d'><span class='comment-count'>%d</span></span>", 'tdomf'), $unmod_count, $unmod_count), 'edit_others_posts', TDOMF_FOLDER, 'tdomf_overview_menu');
      } else {*/
    add_menu_page(__('TDO Mini Forms', 'tdomf'), __('TDO Mini Forms', 'tdomf'), 'edit_others_posts', TDOMF_FOLDER, 'tdomf_overview_menu');
    /*}*/
    // Options
    add_submenu_page(TDOMF_FOLDER, __('Plugin Options', 'tdomf'), __('Plugin Options', 'tdomf'), 'manage_options', 'tdomf_show_options_menu', 'tdomf_show_options_menu');
    //
    // Form Options
    add_submenu_page(TDOMF_FOLDER, __('Form Options', 'tdomf'), __('Form Options', 'tdomf'), 'manage_options', 'tdomf_show_form_options_menu', 'tdomf_show_form_options_menu');
    //
    // Form Widgets
    add_submenu_page(TDOMF_FOLDER, __('Form Creator', 'tdomf'), __('Form Creator', 'tdomf'), 'manage_options', 'tdomf_show_form_menu', 'tdomf_show_form_menu');
    //
    // Form Hacker
    add_submenu_page(TDOMF_FOLDER, __('Form Hacker', 'tdomf'), __('Form Hacker', 'tdomf'), 'manage_options', 'tdomf_show_form_hacker', 'tdomf_show_form_hacker');
    //
    // Form Export
    add_submenu_page(TDOMF_FOLDER, __('Form Export', 'tdomf'), __('Form Export', 'tdomf'), 'manage_options', 'tdomf_show_form_export_menu', 'tdomf_show_form_export_menu');
    /*//
      // Form Options
      add_submenu_page( TDOMF_FOLDER , __('Form Options', 'tdomf'), __('Forms', 'tdomf'), 'manage_options', 'tdomf_show_form_options_menu', 'tdomf_show_form_options_menu');
      //
      // Form Widgets
      add_submenu_page( 'admin.php' , __('Form Creator', 'tdomf'), __('Form Creator', 'tdomf'), 'manage_options', 'tdomf_show_form_menu', 'tdomf_show_form_menu');
      //
      // Form Hacker
      add_submenu_page( 'admin.php' , __('Form Hacker', 'tdomf'), __('Form Hacker', 'tdomf'), 'manage_options', 'tdomf_show_form_hacker', 'tdomf_show_form_hacker');
      //
      // Form Export
      add_submenu_page( 'admin.php' , __('Form Export', 'tdomf'), __('Form Export', 'tdomf'), 'manage_options', 'tdomf_show_form_export_menu', 'tdomf_show_form_export_menu');*/
    //
    // Moderation Queue
    if (tdomf_is_moderation_in_use()) {
        add_submenu_page(TDOMF_FOLDER, __('Moderation', 'tdomf'), sprintf(__('Moderation (%d)', 'tdomf'), $unmod_count), 'edit_others_posts', 'tdomf_show_mod_posts_menu', 'tdomf_show_mod_posts_menu');
    } else {
        add_submenu_page(TDOMF_FOLDER, __('Moderation', 'tdomf'), __('Moderation', 'tdomf'), 'edit_others_posts', 'tdomf_show_mod_posts_menu', 'tdomf_show_mod_posts_menu');
    }
    //
    // Manage Submitters
    add_submenu_page(TDOMF_FOLDER, __('Users and IPs', 'tdomf'), __('Users and IPs', 'tdomf'), 'edit_others_posts', 'tdomf_show_manage_menu', 'tdomf_show_manage_menu');
    //
    // Log
    add_submenu_page(TDOMF_FOLDER, __('Log', 'tdomf'), __('Log', 'tdomf'), 'manage_options', 'tdomf_show_log_menu', 'tdomf_show_log_menu');
    //
    // Uninstall
    add_submenu_page(TDOMF_FOLDER, __('Uninstall', 'tdomf'), __('Uninstall', 'tdomf'), 'manage_options', 'tdomf_show_uninstall_menu', 'tdomf_show_uninstall_menu');
    //
    // Your submissions
    if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
        add_submenu_page('profile.php', 'Your Submissions', 'Your Submissions', 0, 'tdomf_your_submissions', 'tdomf_show_your_submissions_menu');
    }
    // Restoring old behaviour that Wordpress 2.8 took away for this page
    //
    add_submenu_page('admin.php', __('Revisions', 'tdomf'), __('Revisions', 'tdomf'), 'manage_options', TDOMF_FOLDER . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'tdomf-revision.php');
}
function tdomf_show_your_submissions_menu()
{
    global $current_user;
    // how many of the recently published/approved entries to see
    //
    $limit = 10;
    get_currentuserinfo();
    $tdomf_flag = get_usermeta($current_user->ID, TDOMF_KEY_FLAG);
    $sub_total = tdomf_get_users_submitted_posts_count($current_user->ID);
    $app_total = tdomf_get_users_published_posts_count($current_user->ID);
    $user_status = get_usermeta($current_user->ID, TDOMF_KEY_STATUS);
    $app_posts = tdomf_get_user_published_posts($current_user->ID, 0, $limit);
    $mod_posts = tdomf_get_user_draft_posts($current_user->ID);
    $mod_total = count($mod_posts);
    $fut_posts = tdomf_get_user_scheduled_posts($current_user->ID);
    $fut_total = count($fut_posts);
    $unapp_edits = tdomf_get_edits(array('state' => 'unapproved', 'unique_post_ids' => true, 'user_id' => $current_user->ID));
    $app_edits = tdomf_get_edits(array('state' => 'approved', 'unique_post_ids' => true, 'user_id' => $current_user->ID, 'limit' => $limit));
    ?>

  <div class="wrap">
    <h2><?php 
    _e('Your Submissions', 'tdomf');
    ?>
</h2>
    
    <?php 
    if (in_array($_REQUEST['REMOTE_ADDR'], tdomf_get_ips_banned())) {
        ?>
      <?php 
        printf(__("You are logged on from the banned IP %s. If this is in error please contact the <a href='mailto:%s'>admins</a>.", "tdomf"), $_SERVER['REMOTE_ADDR'], get_bloginfo('admin_email'));
        ?>
    <?php 
    } else {
        if ($user_status == TDOMF_USER_STATUS_BANNED) {
            ?>
      <?php 
            printf(__("You are banned from using this functionality on this site. If this is in error please contact the <a href='mailto:%s'>admins</a>.", "tdomf"), get_bloginfo('admin_email'));
            ?>
    <?php 
        } else {
            ?>

      <p>
      <?php 
            if ($user_status == TDOMF_USER_STATUS_TRUSTED) {
                ?>
        <?php 
                printf(__("Good to see you again <b>%s</b>! ", "tdomf"), $current_user->display_name);
                ?>
      <?php 
            } else {
                if ($tdomf_flag) {
                    ?>
        <?php 
                    printf(__("Welcome back <b>%s</b>!", "tdomf"), $current_user->display_name);
                    ?>
      <?php 
                } else {
                    ?>
        <?php 
                    printf(__("Welcome <b>%s</b>.", "tdomf"), $current_user->display_name);
                    ?>
      <?php 
                }
            }
            ?>
      </p>
      
      <p><?php 
            printf(__("From here you can submit posts to the %s using the form below and check on the status of your submissions.", "tdomf"), get_bloginfo());
            ?>
</p>
      
      <?php 
            if (current_user_can('edit_others_posts') || current_user_can('manage_options')) {
                ?>
      <ul>
      <?php 
                if (current_user_can('manage_options')) {
                    ?>
      <li><a href="admin.php?page=tdomf_show_options_menu"><?php 
                    _e("Configure Options", "tdomf");
                    ?>
</a></li>
      <li><a href="admin.php?page=tdomf_show_form_menu"><?php 
                    _e("Modify Form", "tdomf");
                    ?>
</a></li>
      <?php 
                }
                ?>
      <li><a href="admin.php?page=tdomf_show_mod_posts_menu"><?php 
                _e("Moderate Submissions", "tdomf");
                ?>
</a></li>
      </ul>
      <?php 
            }
            ?>

    <?php 
            if ($tdomf_flag && ($sub_total > 0 || $app_total > 0)) {
                ?>
        
        <?php 
                if ($fut_total > 0) {
                    ?>
            <h3><?php 
                    printf(__('Your Next %d Scheduled Submissions', 'tdomf'), $fut_total);
                    ?>
</h3>
            <ul>
         <?php 
                    foreach ($fut_posts as $p) {
                        ?>
          <li>
          <?php 
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $p->post_date;
                        $time = tdomf_get_post_time('G', true, $p);
                        if (abs(time() - $time) < 86400) {
                            $h_time = sprintf(__('%s from now'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                        ?>
                <?php 
                        printf(__("<a href='%s'>%s</a> will be published %s", "tdomf"), get_permalink($p->ID), $p->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                        ?>
          </li>
         <?php 
                    }
                    ?>
    	  </ul>
        <?php 
                }
                ?>
        
       <?php 
                if ($app_total > 0) {
                    ?>
         <h3><?php 
                    printf(__('Your Last %d Published Submissions', 'tdomf'), $app_total < 5 ? $app_total : 5);
                    ?>
</h3>
         <ul>
         <?php 
                    foreach ($app_posts as $p) {
                        ?>
          <li>
          <?php 
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $p->post_date;
                        $time = tdomf_get_post_time('G', true, $p);
                        if (abs(time() - $time) < 86400) {
                            $h_time = sprintf(__('%s ago'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                        ?>
                <?php 
                        printf(__("<a href='%s'>%s</a> approved %s", "tdomf"), get_permalink($p->ID), $p->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                        ?>
          </li>
         <?php 
                    }
                    ?>
    	  </ul>
       <?php 
                }
                ?>
       
       <?php 
                if ($mod_total > 0) {
                    ?>
         <h3><?php 
                    _e('Your Sumissions awaiting Moderation', 'tdomf');
                    ?>
</h3>
         <ul>
         <?php 
                    foreach ($mod_posts as $p) {
                        ?>
          <li>"<?php 
                        echo $p->post_title;
                        ?>
"</li>
         <?php 
                    }
                    ?>
    	  </ul>
       <?php 
                }
                ?>
    <?php 
            }
            ?>
      
      
    <?php 
            if (!empty($app_edits)) {
                $num = number_format_i18n(count($app_edits));
                $text = __ngettext('Your Last Approved Contribution', 'Your Last %d Approved Contributions', count($app_edits));
                ?>
        <h3><?php 
                printf($text, count($app_edits));
                ?>
</h3>
        <ul>
        <?php 
                foreach ($app_edits as $app_edit) {
                    ?>
            <li>
            <?php 
                    $edit = tdomf_get_edits(array('state' => 'approved', 'post_id' => $app_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
                    $edit = $edit[0];
                    $t_time = get_the_time(__('Y/m/d g:i:s A'));
                    $h_time = mysql2date(__('Y/m/d'), $edit->date);
                    $post = get_post($app_edit->post_id);
                    printf(__("<a href='%s'>%s</a> edited %s", "tdomf"), get_permalink($app_edit->post_id), $post->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                    ?>
            </li>
        <?php 
                }
                ?>
        </ul>
    <?php 
            }
            ?>
    
    <?php 
            if (!empty($unapp_edits)) {
                $num = number_format_i18n(count($unapp_edits));
                $text = __ngettext('Your Contribution awaiting Moderation', 'Your Contributions awaiting Moderation', count($unapp_edits));
                ?>
        <h3><?php 
                printf($text, count($unapp_edits));
                ?>
</h3>
        <ul>
        <?php 
                foreach ($unapp_edits as $unapp_edit) {
                    ?>
            <li>
            <?php 
                    $edit = tdomf_get_edits(array('state' => 'unapproved', 'post_id' => $unapp_edit->post_id, 'user_id' => $current_user->ID, 'limit' => 1));
                    $edit = $edit[0];
                    $t_time = get_the_time(__('Y/m/d g:i:s A'));
                    $h_time = mysql2date(__('Y/m/d'), $edit->date);
                    $post = get_post($unapp_edit->post_id);
                    printf(__("<a href='%s'>%s</a> edited %s", "tdomf"), get_permalink($unapp_edit->post_id), $post->post_title, "<abbr title='{$t_time}'>{$h_time}</abbr>");
                    ?>
            </li>
        <?php 
                }
                ?>
        </ul>
    <?php 
            }
            ?>
    
     </div>
      
     <!-- Form formatting -->     
     <style>
     .tdomf_form {
     }
     .tdomf_form fieldset legend {
       #border-bottom: 1px dotted black;
       font-weight: bold;
       padding: 0px;
       margin: 0px;
       padding-bottom: 10px;
     }
     .tdomf_form_preview {
       border: 1px dotted black;
       padding: 5px;
       margin: 5px;
       margin-bottom: 20px;
     }
     .tdomf_form_preview p {
       margin-left: 15px;
     }
     .tdomf_form .required {
       color: red;
     }
     .tdomf_form fieldset {
       margin-bottom: 10px;
       border: 0;
     }
     </style>
      
    <?php 
            $form_ids = tdomf_get_form_ids();
            if (!empty($form_ids)) {
                foreach ($form_ids as $form_id) {
                    if (tdomf_get_option_form(TDOMF_OPTION_INCLUDED_YOUR_SUBMISSIONS, $form_id->form_id)) {
                        $edit = tdomf_get_option_form(TDOMF_OPTION_FORM_EDIT, $form_id->form_id);
                        $post_id = false;
                        if (isset($_REQUEST['tdomf_post_id'])) {
                            $post_id = intval($_REQUEST['tdomf_post_id']);
                        }
                        $good = true;
                        if ($edit && tdomf_check_permissions_form($form_id->form_id, $post_id) != NULL) {
                            $good = false;
                        }
                        if ($good) {
                            ?>
     <div class="wrap">
        <h2><?php 
                            echo tdomf_get_option_form(TDOMF_OPTION_NAME, $form_id->form_id);
                            ?>
</h2>
        <p><?php 
                            echo tdomf_get_option_form(TDOMF_OPTION_DESCRIPTION, $form_id->form_id);
                            ?>
</p>
        <?php 
                            echo tdomf_generate_form($form_id->form_id);
                            ?>
        <br/><br/>
     </div>
          <?php 
                        }
                    }
                }
            }
            ?>
    <?php 
        }
    }
    ?>
    
  </div>

  <p><center><?php 
    _e('Powered by the <a href="http://thedeadone.net/software/tdo-mini-forms-wordpress-plugin/">TDO Mini Forms Plugin.', 'tdomf');
    ?>
</a></center></p>
  
<?php 
}
function tdomf_show_edit_post_revision_panel()
{
    global $post;
    // don't show on new post
    if ($post->ID > 0) {
        $edits = tdomf_get_edits(array('post_id' => $post->ID));
        if (count($edits) > 0) {
            echo "<ul class='post-revisions'>\n";
            foreach ($edits as $edit) {
                echo "<li>";
                // actual revision
                if ($edit->revision_id != 0) {
                    #echo '<a href="'.get_bloginfo('wpurl').'/wp-admin/revision.php?revision='.$edit->revision_id.'">';
                    echo '<a href="admin.php?page=' . TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR . 'tdomf-revision.php&edit=' . $edit->edit_id . '">';
                }
                echo mysql2date(__('d F, Y @ H:i'), $edit->date_gmt);
                if ($edit->revision_id != 0) {
                    echo '</a>';
                }
                // status
                if ($edit->state == 'unapproved') {
                    _e(' [Pending]', "tdomf");
                } else {
                    if ($edit->state == 'spam') {
                        _e(' [Spam]', "tdomf");
                    }
                }
                // user
                echo _e(' by ', 'tdomf');
                $name = __("N/A", "tdomf");
                if (isset($edit->data[TDOMF_KEY_NAME])) {
                    $name = $ledit->data[TDOMF_KEY_NAME];
                }
                $email = __("N/A", "tdomf");
                if (isset($edit->data[TDOMF_KEY_EMAIL])) {
                    $email = $edit->data[TDOMF_KEY_EMAIL];
                }
                if ($edit->user_id != 0) {
                    ?>
                 <a href="user-edit.php?user_id=<?php 
                    echo $edit->user_id;
                    ?>
" class="edit">
                 <?php 
                    $u = get_userdata($edit->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");
                            }
                        }
                    }
                }
                // form
                if (tdomf_form_exists($edit->form_id) != false) {
                    $form_edit_url = "admin.php?page=tdomf_show_form_options_menu&form={$edit->form_id}";
                    $form_name = tdomf_get_option_form(TDOMF_OPTION_NAME, $edit->form_id);
                    _e(' using ', 'tdomf');
                    echo '<a href="' . $form_edit_url . '">' . sprintf(__('Form #%d: %s', 'tdomf'), $edit->form_id, $form_name) . '</a>';
                }
                // ip
                echo ' (' . $edit->ip . ')';
                echo "</li>";
            }
            echo "</ul>\n";
        }
    }
}
Esempio n. 8
0
function tdomf_trust_user($user_id)
{
    #tdomf_log_message("Check if user $user_id's status needs to be updated");
    if ($user_id && $user_id != get_option(TDOMF_DEFAULT_AUTHOR)) {
        $trust_count = intval(get_option(TDOMF_OPTION_TRUST_COUNT));
        #tdomf_log_message("trust count = $trust_count");
        if ($trust_count >= 0) {
            $user_status = get_usermeta($user_id, TDOMF_KEY_STATUS);
            $user_role = new WP_User($user_id);
            if ($user_status != TDOMF_USER_STATUS_TRUSTED && !$user_role->has_cap("publish_posts")) {
                /** @todo bug: the counts here include posts that were automatically published, which isn't exactly correct, but it'll do. */
                $approved_submissions_count = tdomf_get_users_published_posts_count($user_id);
                #tdomf_log_message("User $user_id's approved submissions = $approved_submissions_count");
                $approved_edit_count = tdomf_get_edits(array('user_id' => $user_id, 'count' => true, 'state' => 'approved'));
                #tdomf_log_message("User $user_id's approved edits = $approved_edit_count");
                $approved_total = $approved_submissions_count + $approved_edit_count;
                // 0 is a valid trust count, means that at least one approved post makes the user truested
                if ($trust_count == 0 && $approved_total > 0 || $trust_count > 0 && $trust_count <= $approved_total) {
                    tdomf_log_message("User {$user_id} has {$approved_submissions_count} approved submissions and {$approved_edit_count} approved contributions. Automatically setting the user to trusted. Well done.", TDOMF_LOG_GOOD);
                    update_usermeta($user_id, TDOMF_KEY_FLAG, true);
                    update_usermeta($user_id, TDOMF_KEY_STATUS, TDOMF_USER_STATUS_TRUSTED);
                } else {
                    #tdomf_log_message("User $user_id's approved total $approved_total does hit trust count's threshold of $trust_count");
                }
            } else {
                #tdomf_log_message("User $user_id is already trusted (current status='$user_status') or can publish posts");
            }
        } else {
            #tdomf_log_message("trust count < 0, feature disabled");
        }
    } else {
        #tdomf_log_message("User $user_id is invalid or the default author", TDOMF_LOG_ERROR);
    }
}