Ticket #10396: 10396_c.diff

File 10396_c.diff, 12.5 KB (added by dancole, 3 years ago)

Pick user name and password

Line 
1Index: wp-admin/includes/upgrade.php
2===================================================================
3--- wp-admin/includes/upgrade.php       (revision 12799)
4+++ wp-admin/includes/upgrade.php       (working copy)
5@@ -33,7 +33,7 @@
6  * @param null $deprecated Optional. Not used.
7  * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
8  */
9-function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '' ) {
10+function wp_install( $blog_title, $user_name, $user_password, $user_email, $public, $deprecated = '' ) {
11        global $wp_rewrite;
12 
13        if ( !empty( $deprecated ) )
14@@ -60,13 +60,15 @@
15        // Create default user.  If the user already exists, the user tables are
16        // being shared among blogs.  Just set the role in that case.
17        $user_id = username_exists($user_name);
18-       if ( !$user_id ) {
19-               $random_password = wp_generate_password();
20+       if ( !$user_id && $user_password == '' ) {
21+               $user_password = wp_generate_password();
22                $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
23-               $user_id = wp_create_user($user_name, $random_password, $user_email);
24+               $user_id = wp_create_user($user_name, $user_password, $user_email);
25                update_usermeta($user_id, 'default_password_nag', true);
26+       } else if ( !$user_id ) {
27+               $message = __('<strong><em>Note that password</em></strong> carefully!');
28+               $user_id = wp_create_user($user_name, $user_password, $user_email);
29        } else {
30-               $random_password = '';
31                $message =  __('User already exists.  Password inherited.');
32        }
33 
34@@ -77,11 +79,11 @@
35 
36        $wp_rewrite->flush_rules();
37 
38-       wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
39+       wp_new_blog_notification($blog_title, $guessurl, $user_id, $user_password);
40 
41        wp_cache_flush();
42 
43-       return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message);
44+       return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
45 }
46 endif;
47 
48Index: wp-admin/css/install.css
49===================================================================
50--- wp-admin/css/install.css    (revision 12799)
51+++ wp-admin/css/install.css    (working copy)
52@@ -1 +1 @@
53-html{background:#f7f7f7;}body{background:#fff;color:#333;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;margin:2em auto 0 auto;width:700px;padding:1em 2em;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;border:1px solid #dfdfdf;}a{color:#2583ad;text-decoration:none;}a:hover{color:#d54e21;}h1{border-bottom:1px solid #dadada;clear:both;color:#666;font:24px Georgia,"Times New Roman",Times,serif;margin:5px 0 0 -4px;padding:0;padding-bottom:7px;}h2{font-size:16px;}p,li{padding-bottom:2px;font-size:12px;line-height:18px;}code{font-size:13px;}ul,ol{padding:5px 5px 5px 22px;}#logo{margin:6px 0 14px 0;border-bottom:none;}.step{margin:20px 0 15px;}.step,th{text-align:left;padding:0;}.submit input,.button,.button-secondary{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;text-decoration:none;font-size:14px!important;line-height:16px;padding:6px 12px;cursor:pointer;border:1px solid #bbb;color:#464646;-moz-border-radius:15px;-khtml-border-radius:15px;-webkit-border-radius:15px;border-radius:15px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;-khtml-box-sizing:content-box;box-sizing:content-box;}.button:hover,.button-secondary:hover,.submit input:hover{color:#000;border-color:#666;}.button,.submit input,.button-secondary{background:#f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;}.button:active,.submit input:active,.button-secondary:active{background:#eee url(../images/white-grad-active.png) repeat-x scroll left top;}.form-table{border-collapse:collapse;margin-top:1em;width:100%;}.form-table td{margin-bottom:9px;padding:10px;border-bottom:8px solid #fff;font-size:12px;}.form-table th{font-size:13px;text-align:left;padding:16px 10px 10px 10px;border-bottom:8px solid #fff;width:110px;vertical-align:top;}.form-table tr{background:#f3f3f3;}.form-table code{line-height:18px;font-size:18px;}.form-table p{margin:4px 0 0 0;font-size:11px;}.form-table input{line-height:20px;font-size:15px;padding:2px;}#error-page{margin-top:50px;}#error-page p{font-size:12px;line-height:18px;margin:25px 0 20px;}#error-page code{font-family:Consolas,Monaco,Courier,monospace;}
54\ No newline at end of file
55+html{background:#f7f7f7;}body{background:#fff;color:#333;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;margin:2em auto 0 auto;width:700px;padding:1em 2em;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;border:1px solid #dfdfdf;}a{color:#2583ad;text-decoration:none;}a:hover{color:#d54e21;}h1{border-bottom:1px solid #dadada;clear:both;color:#666;font:24px Georgia,"Times New Roman",Times,serif;margin:5px 0 0 -4px;padding:0;padding-bottom:7px;}h2{font-size:16px;}p,li{padding-bottom:2px;font-size:12px;line-height:18px;}code{font-size:13px;}ul,ol{padding:5px 5px 5px 22px;}#logo{margin:6px 0 14px 0;border-bottom:none;}.step{margin:20px 0 15px;}.step,th{text-align:left;padding:0;}.submit input,.button,.button-secondary{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;text-decoration:none;font-size:14px!important;line-height:16px;padding:6px 12px;cursor:pointer;border:1px solid #bbb;color:#464646;-moz-border-radius:15px;-khtml-border-radius:15px;-webkit-border-radius:15px;border-radius:15px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;-khtml-box-sizing:content-box;box-sizing:content-box;}.button:hover,.button-secondary:hover,.submit input:hover{color:#000;border-color:#666;}.button,.submit input,.button-secondary{background:#f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;}.button:active,.submit input:active,.button-secondary:active{background:#eee url(../images/white-grad-active.png) repeat-x scroll left top;}.form-table{border-collapse:collapse;margin-top:1em;width:100%;}.form-table td{margin-bottom:9px;padding:10px;border-bottom:8px solid #fff;font-size:12px;}.form-table th{font-size:13px;text-align:left;padding:16px 10px 10px 10px;border-bottom:8px solid #fff;width:110px;vertical-align:top;}.form-table tr{background:#f3f3f3;}.form-table code{line-height:18px;font-size:18px;}.form-table p{margin:4px 0 0 0;font-size:11px;}.form-table input{line-height:20px;font-size:15px;padding:2px;}#error-page{margin-top:50px;}#error-page p{font-size:12px;line-height:18px;margin:25px 0 20px;}#error-page code{font-family:Consolas,Monaco,Courier,monospace;}#pass-strength-result {background-color: #EEEEEE;border-color: #DDDDDD !important;border-style: solid;border-width: 1px;float: left;margin: 12px 5px 5px 1px;padding: 5px;text-align: center;width: 200px;}#pass-strength-result.bad {background-color: #FFB78C;border-color: #FF853C !important;}#pass-strength-result.good {background-color: #FFEC8B;border-color: #FFCC00 !important;}#pass-strength-result.short {background-color: #FFA0A0;border-color: #F04040 !important;}#pass-strength-result.strong {background-color: #C3FF88;border-color: #8DFF1C !important;}
56Index: wp-admin/css/install.dev.css
57===================================================================
58--- wp-admin/css/install.dev.css        (revision 12799)
59+++ wp-admin/css/install.dev.css        (working copy)
60@@ -131,3 +131,35 @@
61 }
62 
63 #error-page code { font-family: Consolas, Monaco, Courier, monospace; }
64+
65+#pass-strength-result {
66+       background-color: #EEEEEE;
67+       border-color: #DDDDDD !important;
68+       border-style: solid;
69+       border-width: 1px;
70+       float: left;
71+       margin: 12px 5px 5px 1px;
72+       padding: 5px;
73+       text-align: center;
74+       width: 200px;
75+}
76+
77+#pass-strength-result.bad {
78+       background-color: #FFB78C;
79+       border-color: #FF853C !important;
80+}
81+
82+#pass-strength-result.good {
83+       background-color: #FFEC8B;
84+       border-color: #FFCC00 !important;
85+}
86+
87+#pass-strength-result.short {
88+       background-color: #FFA0A0;
89+       border-color: #F04040 !important;
90+}
91+
92+#pass-strength-result.strong {
93+       background-color: #C3FF88;
94+       border-color: #8DFF1C !important;
95+}
96Index: wp-admin/install.php
97===================================================================
98--- wp-admin/install.php        (revision 12799)
99+++ wp-admin/install.php        (working copy)
100@@ -66,6 +66,26 @@
101                        <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo ( isset($_POST['weblog_title']) ? esc_attr($_POST['weblog_title']) : '' ); ?>" /></td>
102                </tr>
103                <tr>
104+                       <th scope="row"><label for="user_name"><?php _e('User Name'); ?></label></th>
105+                       <td>
106+                       <?php if ( count( get_users_of_blog() ) > 0 ) { echo 'An user already exists. <input type="hidden" id="user_name" value="admin" />'; } else { ?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo ( isset($_POST['user_name']) ? esc_attr($_POST['user_name']) : 'admin' ); ?>" /><?php } ?>
107+                       </td>
108+               </tr>
109+               <tr>
110+                       <th scope="row"><label for="admin_password"><?php _e('Password'); ?></label></th>
111+                       <td>
112+                               <?php if ( count( get_users_of_blog() ) > 0 ) {
113+                                       echo 'If you forget your password you can recover it. <input type="hidden" id="user_name" value="admin" />';
114+                               }
115+                               else {
116+                                       ?><input name="admin_password" type="password" id="pass1" size="25" value="<?php echo ( isset($_POST['admin_password']) ? esc_attr($_POST['admin_password']) : '' ); ?>" />
117+                                       <br /><?php _e('A password will be automatically generated for you if this field is blank.'); ?>
118+                                       <br /><div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
119+                                       <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p><?php
120+                               } ?>
121+                       </td>
122+               </tr>
123+               <tr>
124                        <th scope="row"><label for="admin_email"><?php _e('Your E-mail'); ?></label></th>
125                        <td><input name="admin_email" type="text" id="admin_email" size="25" value="<?php echo ( isset($_POST['admin_email']) ? esc_attr($_POST['admin_email']) : '' ); ?>" /><br />
126                        <?php _e('Double-check your email address before continuing.'); ?></td>
127@@ -123,15 +143,21 @@
128                display_header();
129                // Fill in the data we gathered
130                $weblog_title = isset($_POST['weblog_title']) ? stripslashes($_POST['weblog_title']) : '';
131+               $user_name = isset($_POST['user_name']) ? stripslashes($_POST['user_name']) : '';
132+               $admin_password = isset($_POST['admin_password']) ? stripslashes($_POST['admin_password']) : '';
133                $admin_email = isset($_POST['admin_email']) ? stripslashes($_POST['admin_email']) : '';
134                $public = isset($_POST['blog_public']) ? (int) $_POST['blog_public'] : 0;
135                // check e-mail address
136                $error = false;
137-               if (empty($admin_email)) {
138+               if ( empty( $user_name ) ) {
139                        // TODO: poka-yoke
140+                       display_setup_form( __('you must provide a valid user name.') );
141+                       $error = true;
142+               } else if ( empty( $admin_email ) ) {
143+                       // TODO: poka-yoke
144                        display_setup_form( __('you must provide an e-mail address.') );
145                        $error = true;
146-               } else if (!is_email($admin_email)) {
147+               } else if ( !is_email( $admin_email ) ) {
148                        // TODO: poka-yoke
149                        display_setup_form( __('that isn&#8217;t a valid e-mail address.  E-mail addresses look like: <code>username@example.com</code>') );
150                        $error = true;
151@@ -139,7 +165,7 @@
152 
153                if ( $error === false ) {
154                        $wpdb->show_errors();
155-                       $result = wp_install($weblog_title, 'admin', $admin_email, $public);
156+                       $result = wp_install($weblog_title, $user_name, $admin_password, $admin_email, $public);
157                        extract($result, EXTR_SKIP);
158 ?>
159 
160@@ -150,7 +176,7 @@
161 <table class="form-table">
162        <tr>
163                <th><?php _e('Username'); ?></th>
164-               <td><code>admin</code></td>
165+               <td><code><?php echo $user_name; ?></code></td>
166        </tr>
167        <tr>
168                <th><?php _e('Password'); ?></th>
169@@ -168,6 +194,25 @@
170                break;
171 }
172 ?>
173+<script type="text/javascript" src="../wp-includes/js/jquery/jquery.js"></script>
174 <script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
175+<script type='text/javascript'>
176+/* <![CDATA[ */
177+var commonL10n = {
178+ warnDelete: "You are about to permanently delete the selected items.\n \'Cancel\' to stop, \'OK\' to delete."
179+};
180+try{convertEntities(commonL10n);}catch(e){};
181+var pwsL10n = {
182+ empty: "Strength indicator",
183+ short: "Very weak",
184+ bad: "Weak",
185+ good: "Medium",
186+ strong: "Strong"
187+};
188+try{convertEntities(pwsL10n);}catch(e){};
189+/* ]]> */
190+</script>
191+<script type="text/javascript" src="js/password-strength-meter.js"></script>
192+<script type="text/javascript" src="js/user-profile.js"></script>
193 </body>
194 </html>