From 62d475797933fec8a19424c4f83bbbbc8119975b Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 7 Jan 2008 20:38:49 +0000 Subject: [PATCH] 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 --- wp-admin/admin-ajax.php | 2 +- wp-admin/edit-comments.php | 29 +---------------------------- wp-admin/includes/template.php | 4 ++-- wp-admin/js/forms.js | 31 +++++++++++++++++++++++++++++++ wp-admin/link-manager.php | 21 ++------------------- wp-admin/users.php | 7 +++++-- wp-includes/script-loader.php | 1 + 7 files changed, 43 insertions(+), 52 deletions(-) create mode 100644 wp-admin/js/forms.js diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 817b70c515..25a8221215 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -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 %s added' ), "user-$user_id", $user_object->user_login), 'role' => $user_object->roles[0] diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index a46a8c28ff..13ada6f4f4 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -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']); ?> - -

diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 9f6f7dac5d..32b98f46bf 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -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 = " - + $email diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js new file mode 100644 index 0000000000..779f639bbd --- /dev/null +++ b/wp-admin/js/forms.js @@ -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; +} \ No newline at end of file diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index db8a383e45..ed90e71f01 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -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; } ?> - - +

'; diff --git a/wp-admin/users.php b/wp-admin/users.php index ba604a75b1..57c1d1e7b3 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -209,6 +209,7 @@ case 'delete': +

@@ -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) { + @@ -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); } ?> diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 1e3a621cd0..b3025b780d 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -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' );