summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-admin
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-13 16:52:09 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-13 16:52:09 +0000
commit151e726b7bb00a3f46a64bb10c71011bd56dca34 (patch)
treedfea07401f0142bf57ef6ce40ae15da645e1a502 /wp-inst/wp-admin
parent28072f254cf1380fa6334e7adfc659d02eb9e436 (diff)
downloadwordpress-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')
-rw-r--r--wp-inst/wp-admin/admin-functions.php44
-rw-r--r--wp-inst/wp-admin/menu-header.php7
-rw-r--r--wp-inst/wp-admin/menu.php68
-rw-r--r--wp-inst/wp-admin/options-general.php13
-rw-r--r--wp-inst/wp-admin/options-writing.php10
-rw-r--r--wp-inst/wp-admin/profile.php99
-rw-r--r--wp-inst/wp-admin/upgrade-functions.php11
-rw-r--r--wp-inst/wp-admin/upgrade-schema.php6
-rw-r--r--wp-inst/wp-admin/user-edit.php128
-rw-r--r--wp-inst/wp-admin/wp-admin.css9
10 files changed, 234 insertions, 161 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
+?>
diff --git a/wp-inst/wp-admin/menu-header.php b/wp-inst/wp-admin/menu-header.php
index b661146..6807a9e 100644
--- a/wp-inst/wp-admin/menu-header.php
+++ b/wp-inst/wp-admin/menu-header.php
@@ -11,7 +11,7 @@ foreach ($menu as $item) {
// 0 = name, 1 = user_level, 2 = file
if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
- if ($user_level >= $item[1]) {
+ if ( current_user_can($item[1]) ) {
if ( file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") )
echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else
@@ -31,9 +31,8 @@ if ( isset($submenu["$parent_file"]) ) :
<ul id="adminmenu2">
<?php
foreach ($submenu["$parent_file"] as $item) :
- if ($user_level < $item[1]) {
+ if ( !current_user_can($item[1]) )
continue;
- }
if ( isset($submenu_file) ) {
if ( $submenu_file == $item[2] ) $class = ' class="current"';
@@ -55,4 +54,4 @@ endforeach;
?>
</ul>
-<?php endif; ?> \ No newline at end of file
+<?php endif; ?>
diff --git a/wp-inst/wp-admin/menu.php b/wp-inst/wp-admin/menu.php
index c087250..1f31a28 100644
--- a/wp-inst/wp-admin/menu.php
+++ b/wp-inst/wp-admin/menu.php
@@ -4,51 +4,49 @@
// Menu item name
// The minimum level the user needs to access the item: between 0 and 10
// The URL of the item's file
-$menu[0] = array(__('Dashboard'), 0, 'index.php');
-if( $wpblog == 'main' && $user_level == 10) {
- $menu[1] = array(__('Site Admin'), 10, 'wpmu-admin.php' );
-}
-$menu[5] = array(__('Write'), 1, 'post.php');
-$menu[10] = array(__('Manage'), 1, 'edit.php');
-$menu[20] = array(__('Links'), 5, 'link-manager.php');
-$menu[25] = array(__('Presentation'), 8, 'themes.php');
-$menu[30] = array(__('Plugins'), 8, 'plugins.php');
-$menu[35] = array(__('Users'), 0, 'profile.php');
-$menu[40] = array(__('Options'), 6, 'options-general.php');
+$menu[0] = array(__('Dashboard'), 'read', 'index.php');
+$menu[5] = array(__('Write'), 'edit_posts', 'post.php');
+$menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
+$menu[20] = array(__('Links'), 'manage_links', 'link-manager.php');
+$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
+$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
+$menu[35] = array(__('Users'), 'read', 'profile.php');
+$menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
if ( get_option('use_fileupload') )
- $menu[45] = array(__('Upload'), get_settings('fileupload_minlevel'), 'upload.php');
+ $menu[45] = array(__('Upload'), 'upload_files', 'upload.php');
-$submenu[ 'wpmu-admin.php' ][5] = array( 'Blogs', 10, 'wpmu-blogs.php' );
-$submenu[ 'wpmu-admin.php' ][10] = array( 'Users', 10, 'wpmu-users.php' );
-$submenu['post.php'][5] = array(__('Write Post'), 1, 'post.php');
-$submenu['post.php'][10] = array(__('Write Page'), 5, 'page-new.php');
+$submenu['post.php'][5] = array(__('Write Post'), 'edit_posts', 'post.php');
+$submenu['post.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php');
-$submenu['edit.php'][5] = array(__('Posts'), 1, 'edit.php');
-$submenu['edit.php'][10] = array(__('Pages'), 5, 'edit-pages.php');
-$submenu['edit.php'][15] = array(__('Categories'), 1, 'categories.php');
-$submenu['edit.php'][20] = array(__('Comments'), 1, 'edit-comments.php');
+$submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
+$submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
+$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php');
+$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
-$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 1, 'moderation.php');
-$submenu['edit.php'][30] = array(__('Files'), 8, 'templates.php');
+$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 'edit_posts', 'moderation.php');
+$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php');
-$submenu['link-manager.php'][5] = array(__('Manage Links'), 5, 'link-manager.php');
-$submenu['link-manager.php'][10] = array(__('Add Link'), 5, 'link-add.php');
-$submenu['link-manager.php'][15] = array(__('Link Categories'), 5, 'link-categories.php');
-$submenu['link-manager.php'][20] = array(__('Import Links'), 5, 'link-import.php');
+$submenu['link-manager.php'][5] = array(__('Manage Links'), 'manage_links', 'link-manager.php');
+$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php');
+$submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_links', 'link-categories.php');
+$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php');
-$submenu['profile.php'][5] = array(__('Your Profile'), 0, 'profile.php');
-$submenu['profile.php'][10] = array(__('Authors &amp; Users'), 5, 'users.php');
+$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
+$submenu['profile.php'][10] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
-$submenu['options-general.php'][5] = array(__('General'), 6, 'options-general.php');
-$submenu['options-general.php'][10] = array(__('Writing'), 6, 'options-writing.php');
-$submenu['options-general.php'][15] = array(__('Reading'), 6, 'options-reading.php');
-$submenu['options-general.php'][20] = array(__('Discussion'), 6, 'options-discussion.php');
-$submenu['options-general.php'][30] = array(__('Miscellaneous'), 6, 'options-misc.php');
+$submenu['options-general.php'][5] = array(__('General'), 'manage_options', 'options-general.php');
+$submenu['options-general.php'][10] = array(__('Writing'), 'manage_options', 'options-writing.php');
+$submenu['options-general.php'][15] = array(__('Reading'), 'manage_options', 'options-reading.php');
+$submenu['options-general.php'][20] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
+$submenu['options-general.php'][30] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
-$submenu['plugins.php'][5] = array(__('Plugins'), 8, 'plugins.php');
+$submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
-$submenu['themes.php'][5] = array(__('Themes'), 8, 'themes.php');
+$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
+
+$submenu[ 'wpmu-admin.php' ][5] = array( 'Blogs', 10, 'wpmu-blogs.php' );
+$submenu[ 'wpmu-admin.php' ][10] = array( 'Users', 10, 'wpmu-users.php' );
// Create list of page plugin hook names.
foreach ($menu as $menu_page) {
diff --git a/wp-inst/wp-admin/options-general.php b/wp-inst/wp-admin/options-general.php
index 2a09684..95d5aa1 100644
--- a/wp-inst/wp-admin/options-general.php
+++ b/wp-inst/wp-admin/options-general.php
@@ -11,7 +11,7 @@ include('admin-header.php');
<h2><?php _e('General Options') ?></h2>
<form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" />
- <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','admin_email','users_can_register','gmt_offset','date_format','time_format','start_of_week','comment_registration'" />
+ <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','admin_email','users_can_register','gmt_offset','date_format','time_format','start_of_week','comment_registration','default_role'" />
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row"><?php _e('Weblog title:') ?></th>
@@ -40,6 +40,17 @@ include('admin-header.php');
</label>
</td>
</tr>
+ <tr valign="top">
+ <th scope="row"><?php _e('New User Default Role:') ?></th>
+ <td><label for="default_role">
+ <select name="default_role" id="default_role"><?php
+ foreach($wp_roles->role_names as $role => $name) {
+ $selected = (get_settings('default_role') == $role) ? 'selected="selected"' : '';
+ echo "<option {$selected} value=\"{$role}\">{$name}</option>";
+ }
+ ?></select></label>
+ </td>
+ </tr>
</table>
<fieldset class="options">
<legend><?php _e('Date and Time') ?></legend>
diff --git a/wp-inst/wp-admin/options-writing.php b/wp-inst/wp-admin/options-writing.php
index 792e3be..e0f5e92 100644
--- a/wp-inst/wp-admin/options-writing.php
+++ b/wp-inst/wp-admin/options-writing.php
@@ -11,7 +11,7 @@ include('admin-header.php');
<h2><?php _e('Writing Options') ?></h2>
<form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" />
- <input type="hidden" name="page_options" value="'default_post_edit_rows','use_smilies','use_balanceTags','ping_sites','mailserver_url', 'mailserver_port','mailserver_login','mailserver_pass','default_category','default_email_category','new_users_can_blog'" />
+ <input type="hidden" name="page_options" value="'default_post_edit_rows','use_smilies','use_balanceTags','ping_sites','mailserver_url', 'mailserver_port','mailserver_login','mailserver_pass','default_category','default_email_category'," />
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
@@ -39,12 +39,6 @@ endforeach;
?>
</select></td>
</tr>
- <tr>
- <th scope="row"><?php _e('Newly registered members:') ?></th>
- <td> <label for="new_users_can_blog0"><input name="new_users_can_blog" id="new_users_can_blog0" type="radio" value="0" <?php checked('0', get_settings('new_users_can_blog')); ?> /> <?php _e('Cannot write articles') ?></label><br />
-<label for="new_users_can_blog1"><input name="new_users_can_blog" id="new_users_can_blog1" type="radio" value="1" <?php checked('1', get_settings('new_users_can_blog')); ?> /> <?php _e('May submit drafts for review') ?></label><br />
-<label for="new_users_can_blog2"><input name="new_users_can_blog" id="new_users_can_blog2" type="radio" value="2" <?php checked('2', get_settings('new_users_can_blog')); ?> /> <?php _e('May publish articles') ?></label><br /></td>
- </tr>
</table>
<fieldset class="options">
@@ -98,4 +92,4 @@ endforeach;
</form>
</div>
-<?php include('./admin-footer.php') ?> \ No newline at end of file
+<?php include('./admin-footer.php') ?>
diff --git a/wp-inst/wp-admin/profile.php b/wp-inst/wp-admin/profile.php
index 4fe4162..66ec010 100644
--- a/wp-inst/wp-admin/profile.php
+++ b/wp-inst/wp-admin/profile.php
@@ -24,6 +24,38 @@ require_once('../wp-config.php');
auth_redirect();
switch($action) {
+case 'IErightclick':
+
+ $bookmarklet_height= 550;
+
+ ?>
+
+ <div class="menutop">&nbsp;IE one-click bookmarklet</div>
+
+ <table width="100%" cellpadding="20">
+ <tr><td>
+
+ <p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
+ <?php
+ $regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
+ ?>
+ <pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
+ <p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
+ window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
+ That's it, you can now right-click in an IE window and select <br />
+ 'Post to WP' to make the bookmarklet appear. :)</p>
+
+ <p align="center">
+ <form>
+ <input class="search" type="button" value="1" name="Close this window" />
+ </form>
+ </p>
+ </td></tr>
+ </table>
+ <?php
+
+break;
+
case 'update':
get_currentuserinfo();
@@ -100,43 +132,12 @@ case 'update':
wp_redirect('profile.php?updated=true');
break;
-case 'IErightclick':
-
- $bookmarklet_height= 550;
-
- ?>
-
- <div class="menutop">&nbsp;IE one-click bookmarklet</div>
-
- <table width="100%" cellpadding="20">
- <tr><td>
-
- <p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
- <?php
- $regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
- ?>
- <pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
- <p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
- window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
- That's it, you can now right-click in an IE window and select <br />
- 'Post to WP' to make the bookmarklet appear. :)</p>
-
- <p align="center">
- <form>
- <input class="search" type="button" value="1" name="Close this window" />
- </form>
- </p>
- </td></tr>
- </table>
- <?php
-
-break;
-
default:
$parent_file = 'profile.php';
include_once('admin-header.php');
- $profiledata = get_userdata($user_ID);
+ $profileuser = new WP_User($user_ID);
+ $profiledata = &$profileuser->data;
$bookmarklet_height= 440;
@@ -159,8 +160,15 @@ if (isset($updated)) { ?>
<td width="67%"><?php echo $profiledata->user_login; ?></td>
</tr>
<tr>
- <th scope="row"><?php _e('Level:') ?></th>
- <td><?php echo $profiledata->user_level; ?></td>
+ <th scope="row"><?php _e('Role:') ?></th>
+ <td><?php
+ $output = '';
+ foreach($profileuser->roles as $role => $value) {
+ if($output != '') $output .= ', ';
+ $output .= $wp_roles->role_names[$role];
+ }
+ echo $output;
+ ?></td>
</tr>
<tr>
<th scope="row"><?php _e('Posts:') ?></th>
@@ -169,6 +177,25 @@ if (isset($updated)) { ?>
echo $posts;
?></td>
</tr>
+ <?php
+ if(count($profileuser->caps) > count($profileuser->roles)):
+ ?>
+ <tr>
+ <th scope="row"><?php _e('Additional Capabilities:') ?></th>
+ <td><?php
+ $output = '';
+ foreach($profileuser->caps as $cap => $value) {
+ if(!$wp_roles->is_role($cap)) {
+ if($output != '') $output .= ', ';
+ $output .= $value ? $cap : "Denied: {$cap}";
+ }
+ }
+ echo $output;
+ ?></td>
+ </tr>
+ <?php
+ endif;
+ ?>
<tr>
<th scope="row"><?php _e('First name:') ?></th>
<td><input type="text" name="newuser_firstname" id="newuser_firstname" value="<?php echo $profiledata->first_name ?>" /></td>
@@ -229,6 +256,8 @@ if (isset($updated)) { ?>
<td><textarea name="user_description" rows="5" id="textarea2" style="width: 99%; "><?php echo $profiledata->user_description ?></textarea></td>
</tr>
<?php
+do_action('show_user_profile');
+
$show_password_fields = apply_filters('show_password_fields', true);
if ( $show_password_fields ) :
?>
diff --git a/wp-inst/wp-admin/upgrade-functions.php b/wp-inst/wp-admin/upgrade-functions.php
index e6ee8c8..3c60393 100644
--- a/wp-inst/wp-admin/upgrade-functions.php
+++ b/wp-inst/wp-admin/upgrade-functions.php
@@ -759,20 +759,19 @@ function translate_level_to_role($level) {
case 10:
case 9:
case 8:
- return 'publisher';
+ return 'administrator';
case 7:
case 6:
case 5:
- return 'managing_editor';
+ return 'editor';
case 4:
case 3:
- return 'copy_editor';
case 2:
- return 'staff_writer';
+ return 'author';
case 1:
- return 'freelancer';
+ return 'contributor';
case 0:
- return 'visitor';
+ return 'subscriber';
}
}
diff --git a/wp-inst/wp-admin/upgrade-schema.php b/wp-inst/wp-admin/upgrade-schema.php
index 0388640..b5292ad 100644
--- a/wp-inst/wp-admin/upgrade-schema.php
+++ b/wp-inst/wp-admin/upgrade-schema.php
@@ -247,11 +247,13 @@ function populate_options() {
add_option('html_type', 'text/html');
// 1.5.1
add_option('use_trackback', 0);
+ // 1.6
+ add_option('default_role', 'Inactive');
populate_roles();
// Delete unused options
- $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url');
+ $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
foreach ($unusedoptions as $option) :
delete_option($option);
endforeach;
@@ -276,7 +278,7 @@ function populate_roles() {
'edit_pages' => true,
'manage_categories' => true,
'manage_links' => true,
- 'upload_images' => true,
+ 'upload_files' => true,
'manage_options' => true,
'switch_themes' => true,
'edit_themes' => true,
diff --git a/wp-inst/wp-admin/user-edit.php b/wp-inst/wp-admin/user-edit.php
index adac5a0..20737b2 100644
--- a/wp-inst/wp-admin/user-edit.php
+++ b/wp-inst/wp-admin/user-edit.php
@@ -22,16 +22,27 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
switch ($action) {
+case 'switchposts':
+
+check_admin_referer();
+
+/* TODO: Switch all posts from one user to another user */
+
+break;
+
case 'update':
-get_currentuserinfo();
-$edituser = get_userdata($user_id);
-if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
+$errors = array();
+if(empty($wp_user)) {
+ $wp_user = new WP_User($user_id);
+ $edituser = &$wp_user->data;
+}
+
+if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
/* checking the nickname has been typed */
if (empty($_POST["new_nickname"])) {
- die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
- return false;
+ $errors['nickname'] = __("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)");
}
$new_user_login = wp_specialchars($_POST['new_user_login']);
@@ -41,60 +52,61 @@ do_action('check_passwords', array($new_user_login, &$pass1, &$pass2));
if ( '' == $pass1 ) {
if ( '' != $pass2 )
- die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
+ $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
$updatepassword = '';
} else {
if ( '' == $pass2)
- die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
+ $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
if ( $pass1 != $pass2 )
- die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
+ $errors['pass'] = __("<strong>ERROR</strong>: you typed two different passwords.");
$new_pass = $pass1;
$updatepassword = "user_pass=MD5('$new_pass'), ";
}
-$new_firstname = wp_specialchars($_POST['new_firstname']);
-$new_lastname = wp_specialchars($_POST['new_lastname']);
-$new_nickname = $_POST['new_nickname'];
-$new_nicename = sanitize_title($new_nickname, $user_id);
-$new_icq = wp_specialchars($_POST['new_icq']);
-$new_aim = wp_specialchars($_POST['new_aim']);
-$new_msn = wp_specialchars($_POST['new_msn']);
-$new_yim = wp_specialchars($_POST['new_yim']);
-$new_email = wp_specialchars($_POST['new_email']);
-$new_url = wp_specialchars($_POST['new_url']);
-$new_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $new_url) ? $new_url : 'http://' . $new_url;
-$display_name = wp_specialchars($_POST['display_name']);
-$new_description = $_POST['new_description'];
-
-$result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$new_user_login', $updatepassword user_email='$new_email', user_url='$new_url', user_nicename = '$new_nicename', display_name = '$display_name' WHERE ID = '$user_id'");
-
-update_usermeta( $user_id, 'first_name', $new_firstname );
-update_usermeta( $user_id, 'last_name', $new_lastname );
-update_usermeta( $user_id, 'nickname', $new_nickname );
-update_usermeta( $user_id, 'description', $new_description );
-update_usermeta( $user_id, 'icq', $new_icq );
-update_usermeta( $user_id, 'aim', $new_aim );
-update_usermeta( $user_id, 'msn', $new_msn );
-update_usermeta( $user_id, 'yim', $new_yim );
-
-header("Location: user-edit.php?user_id=$user_id&updated=true");
-
-break;
-
-case 'switchposts':
-
-check_admin_referer();
-
-/* TODO: Switch all posts from one user to another user */
-
-break;
+$edituser->user_login = wp_specialchars($_POST['new_user_login']);
+$edituser->user_nicename = sanitize_title($new_nickname, $user_id);
+$edituser->user_email = wp_specialchars($_POST['new_email']);
+$edituser->user_url = wp_specialchars($_POST['new_url']);
+$edituser->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $edituser->user_url) ? $edituser->user_url : 'http://' . $edituser->user_url;
+$edituser->display_name = wp_specialchars($_POST['display_name']);
+
+$edituser->first_name = wp_specialchars($_POST['new_firstname']);
+$edituser->last_name = wp_specialchars($_POST['new_lastname']);
+$edituser->nickname = $_POST['new_nickname'];
+$edituser->icq = wp_specialchars($_POST['new_icq']);
+$edituser->aim = wp_specialchars($_POST['new_aim']);
+$edituser->msn = wp_specialchars($_POST['new_msn']);
+$edituser->yim = wp_specialchars($_POST['new_yim']);
+$edituser->description = $_POST['new_description'];
+
+if(count($errors) == 0) {
+ $result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$edituser->user_login', $updatepassword user_email='$edituser->user_email', user_url='$edituser->user_url', user_nicename = '$edituser->user_nicename', display_name = '$edituser->display_name' WHERE ID = '$user_id'");
+
+ update_usermeta( $user_id, 'first_name', $edituser->firstname );
+ update_usermeta( $user_id, 'last_name', $edituser->lastname );
+ update_usermeta( $user_id, 'nickname', $edituser->nickname );
+ update_usermeta( $user_id, 'description', $edituser->description );
+ update_usermeta( $user_id, 'icq', $edituser->icq );
+ update_usermeta( $user_id, 'aim', $edituser->aim );
+ update_usermeta( $user_id, 'msn', $edituser->msn );
+ update_usermeta( $user_id, 'yim', $edituser->yim );
+
+ $wp_user->set_role($_POST['new_role']);
+
+ header("Location: user-edit.php?user_id=$user_id&updated=true");
+} else {
+ $wp_user->roles = array($_POST['new_role'] => true);
+}
default:
include ('admin-header.php');
-$edituser = get_userdata($user_id);
+if(empty($wp_user)) {
+ $wp_user = new WP_User($user_id);
+ $edituser = &$wp_user->data;
+}
-if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
+if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
?>
<?php if ( isset($_GET['updated']) ) : ?>
@@ -102,6 +114,15 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
<p><strong><?php _e('User updated.') ?></strong></p>
</div>
<?php endif; ?>
+<?php if ( isset($errors) ) : ?>
+<div class="error">
+ <ul>
+ <?php
+ foreach($errors as $error) echo "<li>$error</li>";
+ ?>
+ </ul>
+</div>
+<?php endif; ?>
<div class="wrap">
<h2><?php _e('Edit User'); ?></h2>
@@ -112,14 +133,19 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
<td width="73%"><input type="text" name="new_user_login" id="new_user_login" value="<?php echo $edituser->user_login; ?>" /></td>
</tr>
<tr>
- <th scope="row"><?php _e('Level:') ?></th>
- <td><?php echo $edituser->user_level; ?></td>
+ <th scope="row"><?php _e('Role:') ?></th>
+ <td><select name="new_role" id="new_role"><?php
+ foreach($wp_roles->role_names as $role => $name) {
+ $selected = (empty($wp_user->roles[$role])) ? '' : 'selected="selected"';
+ echo "<option {$selected} value=\"{$role}\">{$name}</option>";
+ }
+ ?></select></td>
</tr>
<tr>
<th scope="row"><?php _e('Posts:') ?></th>
<td><?php echo get_usernumposts($edituser->ID); ?></td>
</tr>
-<?php if ( '0000-00-00 00:00:00' != $edituser->user_registered ) { ?>
+<?php if ( isset($edituser->user_registered) && ('0000-00-00 00:00:00' != $edituser->user_registered) ) { ?>
<tr>
<th scope="row"><?php _e('Registered on:') ?></th>
<td><?php echo substr($edituser->user_registered, 0, 11); ?></td>
@@ -135,7 +161,7 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
</tr>
<tr>
<th scope="row"><?php _e('Profile:') ?></th>
- <td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->user_description ?></textarea></td>
+ <td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->description ?></textarea></td>
</tr>
<tr>
<th scope="row"><?php _e('Nickname:') ?></th>
@@ -189,6 +215,8 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to
</td>
</tr>
<?php
+do_action('edit_user_profile');
+
$show_password_fields = apply_filters('show_password_fields', true);
if ( $show_password_fields ) :
?>
diff --git a/wp-inst/wp-admin/wp-admin.css b/wp-inst/wp-admin/wp-admin.css
index d2e47c1..59b776d 100644
--- a/wp-inst/wp-admin/wp-admin.css
+++ b/wp-inst/wp-admin/wp-admin.css
@@ -246,6 +246,13 @@ textarea, input, select {
padding: 0 1em 0 1em;
}
+.error {
+ background: #FFEFF7;
+ border: 1px solid #c69;
+ margin: 1em 5% 10px;
+ padding: 0 1em 0 1em;
+}
+
.wrap {
background: #fff;
border: 1px solid #ccc;
@@ -679,4 +686,4 @@ a.dbx-toggle-hilite-closed, a.dbx-toggle-hilite-closed:visited {
-moz-opacity: 0.8;
-khtml-opacity: 0.8;
filter: alpha(opacity=80);
-} \ No newline at end of file
+}