diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-07-13 16:52:09 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-07-13 16:52:09 +0000 |
| commit | 151e726b7bb00a3f46a64bb10c71011bd56dca34 (patch) | |
| tree | dfea07401f0142bf57ef6ce40ae15da645e1a502 /wp-inst/wp-admin/admin-functions.php | |
| parent | 28072f254cf1380fa6334e7adfc659d02eb9e436 (diff) | |
| download | wordpress-mu-151e726b7bb00a3f46a64bb10c71011bd56dca34.tar.gz wordpress-mu-151e726b7bb00a3f46a64bb10c71011bd56dca34.tar.xz wordpress-mu-151e726b7bb00a3f46a64bb10c71011bd56dca34.zip | |
Merge from WP Core, things are broken right now.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@20 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/admin-functions.php')
| -rw-r--r-- | wp-inst/wp-admin/admin-functions.php | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index cb3fcff..e6d0521 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -301,26 +301,33 @@ function wp_delete_category($cat_ID) { return 1; } -function wp_delete_user($id) { +function wp_delete_user($id, $reassign = 'novalue') { global $wpdb; $id = (int) $id; - - $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); - - if ($post_ids) { - $post_ids = implode(',', $post_ids); - - // Delete comments, *backs - $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)"); - // Clean cats - $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)"); - // Clean post_meta - $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)"); + + if($reassign == 'novalue') { + $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); + + if ($post_ids) { + $post_ids = implode(',', $post_ids); + + // Delete comments, *backs + $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)"); + // Clean cats + $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)"); + // Clean post_meta + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)"); + // Delete posts + $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id"); + } + // Clean links $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id"); - // Delete posts - $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id"); + } else { + $reassign = (int)$reassign; + $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}"); + $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}"); } // FINALLY, delete user @@ -996,14 +1003,13 @@ function user_can_access_admin_page() { global $pagenow; global $menu; global $submenu; - global $user_level; $parent = get_admin_page_parent(); foreach ($menu as $menu_array) { //echo "parent array: " . $menu_array[2]; if ($menu_array[2] == $parent) { - if ($user_level < $menu_array[1]) { + if ( !current_user_can($menu_array[1]) ) { return false; } else { break; @@ -1014,7 +1020,7 @@ function user_can_access_admin_page() { if (isset($submenu[$parent])) { foreach ($submenu[$parent] as $submenu_array) { if ($submenu_array[2] == $pagenow) { - if ($user_level < $submenu_array[1]) { + if ( !current_user_can($submenu_array[1]) ) { return false; } else { return true; @@ -1395,4 +1401,4 @@ function documentation_link( $for ) { return; } -?>
\ No newline at end of file +?> |
