summaryrefslogtreecommitdiffstats
path: root/wp-admin
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-22 17:46:24 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-22 17:46:24 +0000
commite22b42332591c5c845c5dd513afe4ff9a9b7a565 (patch)
tree30b97d9a27c0a101254270a2d801c3b67ef100c9 /wp-admin
parent7aa77bc788c0ab60b9bb59de5f6b9dca3722c9cc (diff)
downloadwordpress-mu-e22b42332591c5c845c5dd513afe4ff9a9b7a565.tar.gz
wordpress-mu-e22b42332591c5c845c5dd513afe4ff9a9b7a565.tar.xz
wordpress-mu-e22b42332591c5c845c5dd513afe4ff9a9b7a565.zip
Cleanup user and blog add code. props ktlee, fixes #462
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1122 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin')
-rw-r--r--wp-admin/wpmu-blogs.php1
-rw-r--r--wp-admin/wpmu-edit.php107
-rw-r--r--wp-admin/wpmu-users.php1
3 files changed, 56 insertions, 53 deletions
diff --git a/wp-admin/wpmu-blogs.php b/wp-admin/wpmu-blogs.php
index 04b7511..cdad29a 100644
--- a/wp-admin/wpmu-blogs.php
+++ b/wp-admin/wpmu-blogs.php
@@ -631,6 +631,7 @@ switch( $_GET['action'] ) {
<tr><th style="text-align:center;" scope='row'><?php _e('Blog Title') ?></th><td><input name="blog[title]" type="text" size="20" title="<?php _e('Title') ?>"/></td></tr>
<tr><th style="text-align:center;" scope='row'><?php _e('Admin Email') ?></th><td><input name="blog[email]" type="text" size="20" title="<?php _e('Email') ?>"/></td></tr>
<tr><td colspan='2'><?php _e('A new user will be created if the above email address is not in the database.') ?></td></tr>
+ <tr><td colspan='2'><?php _e('The username and password will be mailed to this email address.') ?></td></tr>
</table>
<input class="button" type="submit" name="go" value="<?php _e('Add Blog') ?>" />
</form>
diff --git a/wp-admin/wpmu-edit.php b/wp-admin/wpmu-edit.php
index 903c4f1..777fd16 100644
--- a/wp-admin/wpmu-edit.php
+++ b/wp-admin/wpmu-edit.php
@@ -85,46 +85,47 @@ switch( $_GET['action'] ) {
case "addblog":
check_admin_referer('add-blog');
- if( is_array( $_POST['blog'] ) == true ) {
- $blog = $_POST['blog'];
- $domain = strtolower( wp_specialchars( $blog['domain'] ) );
- $email = wp_specialchars( $blog['email'] );
- if( !is_email( $email ) )
- wp_die( __("<p>Invalid email address</p>") );
-
- if( constant( "VHOST" ) == 'yes' ) {
- $newdomain = $domain.".".$current_site->domain;
- $path = $base;
- } else {
- $newdomain = $current_site->domain;
- $path = $base.$domain.'/';
- }
-
- $user_id = email_exists($email);
- if( !$user_id ) { // I'm not sure what this check should be.
- $password = generate_random_password();
- $user_id = wpmu_create_user( $domain, $password, $email );
- if(false == $user_id) {
- wp_die( __("<p>There was an error creating the user</p>") );
- } else {
- wp_new_user_notification($user_id, $password);
- }
- }
+ $blog = $_POST['blog'];
+ $domain = strtolower( wp_specialchars( $blog['domain'] ) );
+ $email = wp_specialchars( $blog['email'] );
+
+ if ( empty($domain) || empty($email))
+ wp_die( __("<p>Missing blog address or email address.</p>") );
+ if( !is_email( $email ) )
+ wp_die( __("<p>Invalid email address</p>") );
+
+ if( constant( "VHOST" ) == 'yes' ) {
+ $newdomain = $domain.".".$current_site->domain;
+ $path = $base;
+ } else {
+ $newdomain = $current_site->domain;
+ $path = $base.$domain.'/';
+ }
- $wpdb->hide_errors();
- $blog_id = wpmu_create_blog($newdomain, $path, wp_specialchars( $blog['title'] ), $user_id ,'', $current_site->id);
- $wpdb->show_errors();
- if( !is_wp_error($blog_id) ) {
- if( get_user_option( $user_id, 'primary_blog' ) == 1 )
- update_user_option( $user_id, 'primary_blog', $blog_id, true );
- $content_mail = sprintf(__("New blog created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, wp_specialchars($blog['title']) );
- wp_mail( get_site_option('admin_email'), sprintf(__('[%s] New Blog Created'), $current_site->site_name), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
- wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add-blog'), $_SERVER['HTTP_REFERER'] ) );
- exit();
+ $user_id = email_exists($email);
+ if( !$user_id ) {
+ $password = generate_random_password();
+ $user_id = wpmu_create_user( $domain, $password, $email );
+ if(false == $user_id) {
+ wp_die( __("<p>There was an error creating the user</p>") );
} else {
- die( $blog_id->get_error_message() );
+ wp_new_user_notification($user_id, $password);
}
}
+
+ $wpdb->hide_errors();
+ $blog_id = wpmu_create_blog($newdomain, $path, wp_specialchars( $blog['title'] ), $user_id ,'', $current_site->id);
+ $wpdb->show_errors();
+ if( !is_wp_error($blog_id) ) {
+ if( get_user_option( $user_id, 'primary_blog' ) == 1 )
+ update_user_option( $user_id, 'primary_blog', $blog_id, true );
+ $content_mail = sprintf(__("New blog created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, wp_specialchars($blog['title']) );
+ wp_mail( get_site_option('admin_email'), sprintf(__('[%s] New Blog Created'), $current_site->site_name), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
+ wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add-blog'), $_SERVER['HTTP_REFERER'] ) );
+ exit();
+ } else {
+ die( $blog_id->get_error_message() );
+ }
break;
case "updateblog":
@@ -402,24 +403,24 @@ switch( $_GET['action'] ) {
case "adduser":
check_admin_referer('add-user');
- if( is_array( $_POST['user'] ) == true ) {
- $user = $_POST['user'];
- if ( empty($user['username']) && empty($user['email']) ) {
- wp_die( __("<p>Missing username and email.</p>") );
- } elseif ( empty($user['username']) ) {
- wp_die( __("<p>Missing username.</p>") );
- } elseif ( empty($user['email']) ) {
- wp_die( __("<p>Missing email.</p>") );
- }
-
- $password = generate_random_password();
- $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) );
- if( false == $user_id ) {
- wp_die( __("<p>There was an error creating the user</p>") );
- } else {
- wp_new_user_notification($user_id, $password);
- }
+ $user = $_POST['user'];
+ if ( empty($user['username']) && empty($user['email']) ) {
+ wp_die( __("<p>Missing username and email.</p>") );
+ } elseif ( empty($user['username']) ) {
+ wp_die( __("<p>Missing username.</p>") );
+ } elseif ( empty($user['email']) ) {
+ wp_die( __("<p>Missing email.</p>") );
}
+
+ $password = generate_random_password();
+ $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) );
+
+ if( false == $user_id ) {
+ wp_die( __("<p>Duplicated username or email address.</p>") );
+ } else {
+ wp_new_user_notification($user_id, $password);
+ }
+
wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add'), $_SERVER['HTTP_REFERER'] ) );
exit();
break;
diff --git a/wp-admin/wpmu-users.php b/wp-admin/wpmu-users.php
index fa31940..96c016c 100644
--- a/wp-admin/wpmu-users.php
+++ b/wp-admin/wpmu-users.php
@@ -278,6 +278,7 @@ if ( $_GET['updated'] == 'true' ) {
<th style="text-align:center;" scope='row'><?php _e('Email') ?></th>
<td><input type="text" name="user[email]" /></td>
</tr>
+ <tr><td colspan='2'><?php _e('Username and password will be mailed to the above email address.') ?></td></tr>
</table>
<p>
<?php wp_nonce_field('add-user') ?>