Mass select for users from cpoteet and mdawaffe. fixes #5592

git-svn-id: http://svn.automattic.com/wordpress/trunk@6570 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-01-07 20:38:49 +00:00
parent f4e84d8abe
commit 62d4757979
7 changed files with 43 additions and 52 deletions

View File

@ -387,7 +387,7 @@ case 'add-user' :
$x = new WP_Ajax_Response( array(
'what' => 'user',
'id' => $user_id,
'data' => user_row( $user_object ),
'data' => user_row( $user_object, '', $user_object->roles[0] ),
'supplemental' => array(
'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login),
'role' => $user_object->roles[0]

View File

@ -4,39 +4,12 @@ require_once('admin.php');
$title = __('Edit Comments');
$parent_file = 'edit-comments.php';
wp_enqueue_script( 'admin-comments' );
wp_enqueue_script('admin-forms');
require_once('admin-header.php');
if (empty($_GET['mode'])) $mode = 'view';
else $mode = attribute_escape($_GET['mode']);
?>
<script type="text/javascript">
<!--
function checkAll(form)
{
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].checked == true)
form.elements[i].checked = false;
else
form.elements[i].checked = true;
}
}
}
function getNumChecked(form)
{
var num = 0;
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].checked == true)
num++;
}
}
return num;
}
//-->
</script>
<div class="wrap">
<h2><?php _e('Comments'); ?></h2>
<form name="searchform" action="" method="get" id="editcomments">

View File

@ -313,7 +313,7 @@ function page_rows( $pages ) {
}
}
function user_row( $user_object, $style = '' ) {
function user_row( $user_object, $style = '', $role = '' ) {
if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
$user_object = new WP_User( (int) $user_object );
$email = $user_object->user_email;
@ -326,7 +326,7 @@ function user_row( $user_object, $style = '' ) {
$short_url = substr( $short_url, 0, 32 ).'...';
$numposts = get_usernumposts( $user_object->ID );
$r = "<tr id='user-$user_object->ID'$style>
<td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
<td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
<td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
<td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
<td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>

31
wp-admin/js/forms.js Normal file
View File

@ -0,0 +1,31 @@
function checkAll(form) {
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox" && !(form.elements[i].hasAttribute('onclick'))) {
if(form.elements[i].checked == true)
form.elements[i].checked = false;
else
form.elements[i].checked = true;
}
}
}
function getNumChecked(form) {
var num = 0;
for (i = 0, n = form.elements.length; i < n; i++) {
if (form.elements[i].type == "checkbox") {
if (form.elements[i].checked == true)
num++;
}
}
return num;
}
function checkAllUsers(role) {
var checkboxs = document.getElementsByTagName('input');
for(var i = 0, inp; inp = checkboxs[i]; i++)
if(inp.type.toLowerCase() == 'checkbox' && inp.className == role)
if(inp.checked == false)
inp.checked = true;
else
inp.checked = false;
}

View File

@ -7,6 +7,7 @@
require_once ('admin.php');
wp_enqueue_script( 'wp-lists' );
wp_enqueue_script('admin-forms');
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
@ -45,25 +46,7 @@ switch ($order_by) {
break;
}
?>
<script type="text/javascript">
/* <![CDATA[ */
function checkAll(form)
{
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].checked == true)
form.elements[i].checked = false;
else
form.elements[i].checked = true;
}
}
}
jQuery(function($){$('#the-list').wpList();});
/* ]]> */
</script>
<script type="text/javascript" src="js/edit-comments.js"></script>
<?php
if ( isset($_GET['deleted']) ) {
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';

View File

@ -209,6 +209,7 @@ case 'delete':
<form action="" method="post" name="updateusers" id="updateusers">
<?php wp_nonce_field('delete-users') ?>
<?php echo $referer; ?>
<div class="wrap">
<h2><?php _e('Delete Users'); ?></h2>
<p><?php _e('You have specified these users for deletion:'); ?></p>
@ -270,7 +271,8 @@ case 'adduser':
default:
wp_enqueue_script('admin-users');
wp_enqueue_script('admin-forms');
include('admin-header.php');
// Query the users
@ -385,6 +387,7 @@ foreach($roleclasses as $role => $roleclass) {
<?php endif; ?>
</tr>
<tr class="thead">
<th><input type="checkbox" onclick="checkAllUsers('<?php echo $role; ?>')"/></th>
<th><?php _e('ID') ?></th>
<th><?php _e('Username') ?></th>
<th><?php _e('Name') ?></th>
@ -397,7 +400,7 @@ foreach($roleclasses as $role => $roleclass) {
$style = '';
foreach ( (array) $roleclass as $user_object ) {
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
echo "\n\t" . user_row($user_object, $style);
echo "\n\t" . user_row($user_object, $style, $role);
}
?>

View File

@ -119,6 +119,7 @@ class WP_Scripts {
$this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20071104' );
$this->add( 'admin-posts', '/wp-admin/js/edit-posts.js', array('wp-lists'), '20071023' );
$this->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' );
$this->add( 'admin-forms', '/wp-admin/js/forms.js', array('wp-lists'), '20080108' );
$this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
$this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
$this->add( 'post', '/wp-admin/js/post.js', array('suggest'), '20080102' );