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_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); } }