mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Drafts clean up.
git-svn-id: http://svn.automattic.com/wordpress/trunk@2701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6cbb6fecb3
commit
233afca132
29
wp-admin/admin-db.php
Normal file
29
wp-admin/admin-db.php
Normal 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);
|
||||
}
|
||||
|
||||
?>
|
@ -1388,4 +1388,8 @@ function pimp_firefox() {
|
||||
}
|
||||
add_action('admin_footer', 'pimp_firefox');
|
||||
|
||||
function documentation_link( $for ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@ -5,6 +5,7 @@ else
|
||||
require_once('../wp-config.php');
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/admin-functions.php');
|
||||
require_once(ABSPATH . 'wp-admin/admin-db.php');
|
||||
auth_redirect();
|
||||
|
||||
nocache_headers();
|
||||
|
@ -9,18 +9,8 @@ $_GET['m'] = (int) $_GET['m'];
|
||||
|
||||
get_currentuserinfo();
|
||||
|
||||
$drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID");
|
||||
if (1 < $user_level) {
|
||||
$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;
|
||||
}
|
||||
$drafts = get_users_drafts( $user_ID );
|
||||
$other_drafts = get_others_drafts( $user_ID);
|
||||
|
||||
if ($drafts || $other_drafts) {
|
||||
?>
|
||||
|
@ -51,6 +51,16 @@ if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url,
|
||||
?>
|
||||
<div>
|
||||
<h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">»</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) ); ?> »</a></strong></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($comments as $comment) {
|
||||
@ -60,14 +70,6 @@ foreach ($comments as $comment) {
|
||||
}
|
||||
?>
|
||||
</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) ); ?> »</a></strong></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div>
|
||||
<h3><?php _e('Blog Stats'); ?></h3>
|
||||
@ -146,28 +148,7 @@ foreach ($rss->items as $item ) {
|
||||
<br clear="all" />
|
||||
</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&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
|
||||
++$i;
|
||||
}
|
||||
?>
|
||||
.</p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
require('./admin-footer.php');
|
||||
?>
|
@ -322,26 +322,28 @@ default:
|
||||
<div class="updated"><p><?php printf(__('Post saved. <a href="%s">View site »</a>'), get_bloginfo('home')); ?></p></div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if (user_can_create_draft($user_ID)) {
|
||||
if ( user_can_create_draft($user_ID) ) {
|
||||
$action = 'post';
|
||||
get_currentuserinfo();
|
||||
$drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID");
|
||||
if ($drafts) {
|
||||
if ( $drafts = get_users_drafts( $user_ID ) ) {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<p><strong><?php _e('Your Drafts:') ?></strong>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($drafts as $draft) {
|
||||
if (0 != $i)
|
||||
for ( $i = 0; $i < 15; $i++ ) {
|
||||
$draft = $drafts[$i];
|
||||
if ( 0 != $i )
|
||||
echo ', ';
|
||||
$draft->post_title = stripslashes($draft->post_title);
|
||||
if ($draft->post_title == '')
|
||||
if ( empty($draft->post_title) )
|
||||
$draft->post_title = sprintf(__('Post # %s'), $draft->ID);
|
||||
echo "<a href='post.php?action=edit&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) ); ?> »</a>
|
||||
<?php } ?>
|
||||
.</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ $wp_queries="CREATE TABLE $wpdb->categories (
|
||||
category_nicename varchar(200) NOT NULL default '',
|
||||
category_description longtext NOT NULL,
|
||||
category_parent bigint(20) NOT NULL default '0',
|
||||
category_count bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (cat_ID),
|
||||
KEY category_nicename (category_nicename)
|
||||
);
|
||||
|
@ -50,6 +50,8 @@ $wpdb->options = $table_prefix . 'options';
|
||||
$wpdb->postmeta = $table_prefix . 'postmeta';
|
||||
$wpdb->usermeta = $table_prefix . 'usermeta';
|
||||
|
||||
$wpdb->prefix = $table_prefix;
|
||||
|
||||
if ( defined('CUSTOM_USER_TABLE') )
|
||||
$wpdb->users = CUSTOM_USER_TABLE;
|
||||
if ( defined('CUSTOM_USER_META_TABLE') )
|
||||
@ -161,4 +163,4 @@ $wp = new WP();
|
||||
|
||||
// Everything is loaded and initialized.
|
||||
do_action('init');
|
||||
?>
|
||||
?>
|
Loading…
Reference in New Issue
Block a user