Drafts clean up.

git-svn-id: https://develop.svn.wordpress.org/trunk@2701 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2005-07-08 22:59:15 +00:00
parent 537b91b582
commit 5bd6027fbd
8 changed files with 62 additions and 52 deletions

29
wp-admin/admin-db.php Normal file
View File

@ -0,0 +1,29 @@
<?php
function get_users_drafts( $user_id ) {
global $wpdb;
$user_id = (int) $user_id;
$query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
$query = apply_filters('get_users_drafts', $query);
return $wpdb->get_results( $query );
}
function get_others_drafts( $user_id ) {
global $wpdb;
$user = get_userdata( $user_id );
$level_key = $wpdb->prefix . 'user_level';
if ( 1 < $user->user_level ) {
$editable = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value <= '$user->user_level' AND user_id != $user_id");
if( is_array( $editable ) == false )
$other_drafts = '';
else {
$editable = join(',', $editable);
$other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) ");
}
} else {
$other_drafts = false;
}
return apply_filters('get_others_drafts', $other_drafts);
}
?>

View File

@ -1388,4 +1388,8 @@ function pimp_firefox() {
} }
add_action('admin_footer', 'pimp_firefox'); add_action('admin_footer', 'pimp_firefox');
function documentation_link( $for ) {
return;
}
?> ?>

View File

@ -5,6 +5,7 @@ else
require_once('../wp-config.php'); require_once('../wp-config.php');
require_once(ABSPATH . 'wp-admin/admin-functions.php'); require_once(ABSPATH . 'wp-admin/admin-functions.php');
require_once(ABSPATH . 'wp-admin/admin-db.php');
auth_redirect(); auth_redirect();
nocache_headers(); nocache_headers();

View File

@ -9,18 +9,8 @@ $_GET['m'] = (int) $_GET['m'];
get_currentuserinfo(); get_currentuserinfo();
$drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID"); $drafts = get_users_drafts( $user_ID );
if (1 < $user_level) { $other_drafts = get_others_drafts( $user_ID);
$editable = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_level <= '$user_level' AND ID != $user_ID");
if( is_array( $editable ) == false )
$other_drafts = '';
else {
$editable = join(',', $editable);
$other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) ");
}
} else {
$other_drafts = false;
}
if ($drafts || $other_drafts) { if ($drafts || $other_drafts) {
?> ?>

View File

@ -51,6 +51,16 @@ if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url,
?> ?>
<div> <div>
<h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">&raquo;</a></h3> <h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">&raquo;</a></h3>
<?php
if ( $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_approved = '0'") ) :
?>
<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
<?php endif; ?>
</div>
<?php endif; ?>
<ul> <ul>
<?php <?php
foreach ($comments as $comment) { foreach ($comments as $comment) {
@ -60,14 +70,6 @@ foreach ($comments as $comment) {
} }
?> ?>
</ul> </ul>
<?php
if ( $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_approved = '0'") ) :
?>
<p><strong><a href="moderation.php"><?php echo sprintf(__('There are comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
<?php endif; ?>
</div>
<?php endif; ?>
<div> <div>
<h3><?php _e('Blog Stats'); ?></h3> <h3><?php _e('Blog Stats'); ?></h3>
@ -146,28 +148,7 @@ foreach ($rss->items as $item ) {
<br clear="all" /> <br clear="all" />
</div> </div>
</div> </div>
<?php
$drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID");
if ($drafts) {
?>
<div class="wrap">
<p><strong><?php _e('Your Drafts:') ?></strong>
<?php
$i = 0;
foreach ($drafts as $draft) {
if (0 != $i)
echo ', ';
$draft->post_title = stripslashes($draft->post_title);
if ($draft->post_title == '')
$draft->post_title = sprintf(__('Post #%s'), $draft->ID);
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
++$i;
}
?>
.</p>
</div>
<?php } ?>
<?php <?php
require('./admin-footer.php'); require('./admin-footer.php');
?> ?>

View File

@ -322,26 +322,28 @@ default:
<div class="updated"><p><?php printf(__('Post saved. <a href="%s">View site &raquo;</a>'), get_bloginfo('home')); ?></p></div> <div class="updated"><p><?php printf(__('Post saved. <a href="%s">View site &raquo;</a>'), get_bloginfo('home')); ?></p></div>
<?php endif; ?> <?php endif; ?>
<?php <?php
if (user_can_create_draft($user_ID)) { if ( user_can_create_draft($user_ID) ) {
$action = 'post'; $action = 'post';
get_currentuserinfo(); get_currentuserinfo();
$drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID"); if ( $drafts = get_users_drafts( $user_ID ) ) {
if ($drafts) {
?> ?>
<div class="wrap"> <div class="wrap">
<p><strong><?php _e('Your Drafts:') ?></strong> <p><strong><?php _e('Your Drafts:') ?></strong>
<?php <?php
$i = 0; for ( $i = 0; $i < 15; $i++ ) {
foreach ($drafts as $draft) { $draft = $drafts[$i];
if (0 != $i) if ( 0 != $i )
echo ', '; echo ', ';
$draft->post_title = stripslashes($draft->post_title); $draft->post_title = stripslashes($draft->post_title);
if ($draft->post_title == '') if ( empty($draft->post_title) )
$draft->post_title = sprintf(__('Post # %s'), $draft->ID); $draft->post_title = sprintf(__('Post # %s'), $draft->ID);
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>"; echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
++$i; }
} ?>
?>.</p> <?php if ( 15 < count($drafts) ) { ?>
, <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> &raquo;</a>
<?php } ?>
.</p>
</div> </div>
<?php <?php
} }

View File

@ -7,6 +7,7 @@ $wp_queries="CREATE TABLE $wpdb->categories (
category_nicename varchar(200) NOT NULL default '', category_nicename varchar(200) NOT NULL default '',
category_description longtext NOT NULL, category_description longtext NOT NULL,
category_parent bigint(20) NOT NULL default '0', category_parent bigint(20) NOT NULL default '0',
category_count bigint(20) NOT NULL default '0',
PRIMARY KEY (cat_ID), PRIMARY KEY (cat_ID),
KEY category_nicename (category_nicename) KEY category_nicename (category_nicename)
); );

View File

@ -50,6 +50,8 @@ $wpdb->options = $table_prefix . 'options';
$wpdb->postmeta = $table_prefix . 'postmeta'; $wpdb->postmeta = $table_prefix . 'postmeta';
$wpdb->usermeta = $table_prefix . 'usermeta'; $wpdb->usermeta = $table_prefix . 'usermeta';
$wpdb->prefix = $table_prefix;
if ( defined('CUSTOM_USER_TABLE') ) if ( defined('CUSTOM_USER_TABLE') )
$wpdb->users = CUSTOM_USER_TABLE; $wpdb->users = CUSTOM_USER_TABLE;
if ( defined('CUSTOM_USER_META_TABLE') ) if ( defined('CUSTOM_USER_META_TABLE') )
@ -161,4 +163,4 @@ $wp = new WP();
// Everything is loaded and initialized. // Everything is loaded and initialized.
do_action('init'); do_action('init');
?> ?>