Post and page management filter additions from mdawaffe. see #3945

git-svn-id: http://svn.automattic.com/wordpress/trunk@5587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-05-29 04:28:10 +00:00
parent c09ea05543
commit 4efb612c1a
5 changed files with 101 additions and 58 deletions

View File

@ -116,22 +116,13 @@ addLoadEvent(focusit);
<?php endif; ?>
<?php
$authors = get_editable_authors( $current_user->id ); // TODO: ROLE SYSTEM
$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
if ( $authors && count( $authors ) > 1 ) :
?>
<fieldset id="authordiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Post Author'); ?></h3>
<div class="dbx-content">
<select name="post_author_override" id="post_author_override">
<?php
foreach ($authors as $o) :
$o = get_userdata( $o->ID );
if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
else $selected = '';
echo "<option value='" . (int) $o->ID . "' $selected>" . wp_specialchars( $o->display_name ) . "</option>";
endforeach;
?>
</select>
<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
</div>
</fieldset>
<?php endif; ?>

View File

@ -13,14 +13,10 @@ $post_stati = array( // array( adj, noun )
$post_status_label = _c('Pages|manage pages header');
$post_listing_pageable = true;
$post_status_q = '';
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
$post_status_label = $post_stati[$_GET['post_status']][1];
$post_listing_pageable = false;
$post_status_q = '&post_status=' . $_GET['post_status'];
if ( 'publish' == $_GET['post_status'] );
$post_listing_pageable = true;
}
?>
@ -30,7 +26,12 @@ if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($
<h2><?php
// Use $_GET instead of is_ since they can override each other
$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
printf( _c( '%1$s%2$s|manage pages header' ), $post_status_label, $h2_search );
$h2_author = '';
if ( isset($_GET['author']) && $_GET['author'] ) {
$author_user = get_userdata( (int) $_GET['author'] );
$h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
}
printf( _c( '%1$s%2$s%3$s|manage pages header' ), $post_status_label, $h2_author, $h2_search );
?></h2>
<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p>
@ -50,6 +51,14 @@ printf( _c( '%1$s%2$s|manage pages header' ), $post_status_label, $h2_search );
</select>
</fieldset>
<?php $editable_ids = get_editable_user_ids( $user_ID ); if ( $editable_ids && count( $editable_ids ) > 1 ) : ?>
<fieldset><legend><?php _e('Author&hellip;'); ?></legend>
<?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?>
</fieldset>
<?php endif; ?>
<input type="submit" id="post-query-submit" value="<?php _e('Filter &#187;'); ?>" class="button" />
</form>

View File

@ -16,17 +16,10 @@ $post_stati = array( // array( adj, noun )
);
$post_status_q = '';
$author_q = '';
$post_status_label = _c('Posts|manage posts header');
$post_listing_pageable = true;
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
$post_status_label = $post_stati[$_GET['post_status']][1];
$post_listing_pageable = false;
$post_status_q = '&post_status=' . $_GET['post_status'];
if ( in_array( $_GET['post_status'], array('draft', 'private') ) )
$author_q = "&author=$user_ID";
elseif ( 'publish' == $_GET['post_status'] );
$post_listing_pageable = true;
}
?>
@ -34,7 +27,7 @@ if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($
<?php
wp("what_to_show=posts$author_q$post_status_q&posts_per_page=15&posts_per_archive_page=-1");
wp("what_to_show=posts$post_status_q&posts_per_page=15");
do_action('restrict_manage_posts');
@ -65,10 +58,15 @@ if ( is_single() ) {
else
$h2_noun = $post_status_label;
// Use $_GET instead of is_ since they can override each other
$h2_author = '';
if ( isset($_GET['author']) && $_GET['author'] ) {
$author_user = get_userdata( get_query_var( 'author' ) );
$h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
}
$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( get_search_query() ) ) : '';
$h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in &#8220;%s&#8221;'), single_cat_title('', false) ) : '';
$h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : '';
printf( _c( '%1$s%2$s%3$s%4$s|manage posts header' ), $h2_noun, $h2_search, $h2_cat, $h2_month );
printf( _c( '%1$s%2$s%3$s%4$s%5$s|manage posts header' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_month );
}
?></h2>
@ -86,8 +84,16 @@ if ( is_single() ) {
</select>
</fieldset>
<?php
<?php
$editable_ids = get_editable_user_ids( $user_ID );
if ( $editable_ids && count( $editable_ids ) > 1 ) :
?>
<fieldset><legend><?php _e('Author&hellip;'); ?></legend>
<?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?>
</fieldset>
<?php
endif;
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
@ -129,31 +135,7 @@ if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?
<br style="clear:both;" />
<?php
if ( $post_status_q && ( false !== strpos($post_status_q, 'draft') || false !== strpos($post_status_q, 'private') ) ) {
echo '<h3>' . __('Your Posts') . "</h3>\n";
include( 'edit-post-rows.php' );
$editable_ids = get_editable_user_ids( $user_ID );
if ( $editable_ids && count($editable_ids) > 1 ) {
$_editable_ids = join(',', array_diff($editable_ids, array($user_ID)));
$post_status_q = "&post_status=" . $_GET['post_status'];
unset($GLOBALS['day']); // setup_postdata does this
wp("what_to_show=posts&author=$_editable_ids$post_status_q&posts_per_page=-1&posts_per_archive_page=-1");
if ( have_posts() ) {
echo '<h3>' . __("Others' Posts") . "</h3>\n";
include( 'edit-post-rows.php' );
}
}
} else {
include( 'edit-post-rows.php' );
}
?>
<?php include( 'edit-post-rows.php' ); ?>
<div id="ajax-response"></div>

View File

@ -284,7 +284,7 @@ function wp_upload_posts_where( $where ) {
}
function wp_upload_tab_browse() {
global $wpdb, $action, $paged;
global $action, $paged;
$old_vars = compact( 'paged' );
switch ( $action ) :
@ -301,11 +301,7 @@ function wp_upload_tab_browse() {
add_action( 'pre_get_posts', 'wp_upload_grab_attachments' );
if ( 'browse' == $tab && $post_id )
add_filter( 'posts_where', 'wp_upload_posts_where' );
$attachments = query_posts("what_to_show=posts&posts_per_page=10&paged=$paged");
$count_query = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'";
if ( $post_id )
$count_query .= " AND post_parent = '$post_id'";
$total = $wpdb->get_var($count_query);
$attachments = query_posts("what_to_show=posts&post_status=any&posts_per_page=10&paged=$paged");
echo "<ul id='upload-files'>\n";
if ( have_posts() ) : while ( have_posts() ) : the_post();
@ -357,4 +353,4 @@ function wp_upload_admin_head() {
}
}
?>
?>

View File

@ -179,4 +179,69 @@ function setup_userdata($user_id = '') {
$user_identity = $user->display_name;
}
function wp_dropdown_users( $args = '' ) {
global $wpdb;
$defaults = array(
'show_option_all' => '', 'show_option_none' => '',
'orderby' => 'display_name', 'order' => 'ASC',
'include' => '', 'exclude' => '',
'show' => 'display_name', 'echo' => 1,
'selected' => 0, 'name' => 'user', 'class' => ''
);
$defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
$r = wp_parse_args( $args, $defaults );
extract( $r );
$query = "SELECT * FROM $wpdb->users";
$query_where = array();
if ( is_array($include) )
$include = join(',', $include);
$include = preg_replace('/[^0-9,]/', '', $include); // (int)
if ( $include )
$query_where[] = "ID IN ($include)";
if ( is_array($exclude) )
$exclude = join(',', $exclude);
$exclude = preg_replace('/[^0-9,]/', '', $exclude); // (int)
if ( $exclude )
$query_where[] = "ID NOT IN ($exclude)";
if ( $query_where )
$query .= " WHERE " . join(' AND', $query_where);
$query .= " ORDER BY $orderby $order";
$users = $wpdb->get_results( $query );
$output = '';
if ( !empty($users) ) {
$output = "<select name='$name' id='$name' class='$class'>\n";
if ( $show_option_all )
$output .= "\t<option value='0'>$show_option_all</option>\n";
if ( $show_option_none )
$output .= "\t<option value='-1'>$show_option_none</option>\n";
foreach ( $users as $user ) {
$user->ID = (int) $user->ID;
$_selected = $user->ID == $selected ? " selected='selected'" : '';
$output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($user->$show) . "</option>\n";
}
$output .= "</select>";
}
$output = apply_filters('wp_dropdown_users', $output);
if ( $echo )
echo $output;
return $output;
}
?>