From 233afca13245f7c5bb281a3dbccaab7259685755 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 8 Jul 2005 22:59:15 +0000 Subject: [PATCH] Drafts clean up. git-svn-id: http://svn.automattic.com/wordpress/trunk@2701 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-db.php | 29 +++++++++++++++++++++++++++ wp-admin/admin-functions.php | 4 ++++ wp-admin/admin.php | 1 + wp-admin/edit.php | 14 ++----------- wp-admin/index.php | 39 +++++++++--------------------------- wp-admin/post.php | 22 +++++++++++--------- wp-admin/upgrade-schema.php | 1 + wp-settings.php | 4 +++- 8 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 wp-admin/admin-db.php diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php new file mode 100644 index 0000000000..78e803c864 --- /dev/null +++ b/wp-admin/admin-db.php @@ -0,0 +1,29 @@ +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); +} + +?> \ No newline at end of file diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 7ac6ef6d3a..47c49b2fb1 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1388,4 +1388,8 @@ function pimp_firefox() { } add_action('admin_footer', 'pimp_firefox'); +function documentation_link( $for ) { + return; +} + ?> \ No newline at end of file diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 291564b44c..64e602afe4 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -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(); diff --git a/wp-admin/edit.php b/wp-admin/edit.php index cb821a6cb7..7f41629f16 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -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) { ?> diff --git a/wp-admin/index.php b/wp-admin/index.php index 52de37c79f..37dbef65b5 100644 --- a/wp-admin/index.php +++ b/wp-admin/index.php @@ -51,6 +51,16 @@ if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, ?>

»

+ +get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_approved = '0'") ) : +?> +

»

+ +
+ + + -get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_approved = '0'") ) : -?> -

»

- - - -

@@ -146,28 +148,7 @@ foreach ($rss->items as $item ) {
-get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID"); -if ($drafts) { -?> -
-

- post_title = stripslashes($draft->post_title); - if ($draft->post_title == '') - $draft->post_title = sprintf(__('Post #%s'), $draft->ID); - echo "$draft->post_title"; - ++$i; - } - ?> - .

-
- \ No newline at end of file diff --git a/wp-admin/post.php b/wp-admin/post.php index 6ec76cdbd5..4f0f5703fb 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -322,26 +322,28 @@ default:

View site »'), get_bloginfo('home')); ?>

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 ) ) { ?>

post_title = stripslashes($draft->post_title); - if ($draft->post_title == '') + if ( empty($draft->post_title) ) $draft->post_title = sprintf(__('Post # %s'), $draft->ID); echo "$draft->post_title"; - ++$i; - } - ?>.

+ } + ?> + + , » + + .

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) ); diff --git a/wp-settings.php b/wp-settings.php index 7439c63b16..890401d977 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -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'); -?> +?> \ No newline at end of file