WordPress.org

Plugin Directory

Changeset 590527


Ignore:
Timestamp:
08/26/12 17:21:08 (20 months ago)
Author:
jakemgold
Message:

Adds support for editing users, along with minor styling tweaks, and some simplification of code.

Location:
simple-user-password-generator/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • simple-user-password-generator/trunk/localization/simple-user-password-generator-es_ES.po

    r441580 r590527  
    66"Report-Msgid-Bugs-To: \n" 
    77"POT-Creation-Date: 2011-09-07 19:58-0500\n" 
    8 "PO-Revision-Date: 2011-09-07 20:03-0500\n" 
    9 "Last-Translator: Jake Goldman <jake@get10up.com>\n" 
    10 "Language-Team: 10up LLC <jake@get10up.com>\n" 
     8"PO-Revision-Date: 2012-08-26 11:17-0700\n" 
     9"Last-Translator: Jacob Goldman <jake@10up.com>\n" 
     10"Language-Team: 10up LLC <jake@10up.com>\n" 
    1111"MIME-Version: 1.0\n" 
    1212"Content-Type: text/plain; charset=UTF-8\n" 
    1313"Content-Transfer-Encoding: 8bit\n" 
    1414 
    15 #: simple-user-password-generator.php:52 
     15#: simple-user-password-generator.php:54 
    1616msgid "Generate Password" 
    1717msgstr "Generar Contraseña" 
    1818 
    19 #: simple-user-password-generator.php:53 
     19#: simple-user-password-generator.php:55 
    2020msgid "Encourage the user to change their password, once logged in." 
    2121msgstr "Anima a los usuarios cambiar su contraseña, una vez conectado pulg." 
    2222 
    23 #: simple-user-password-generator.php:74 
    24 msgid "You&rsquo;re using the auto-generated password for your account. Consider changing the password to something easier to remember." 
    25 msgstr "Usted está utilizando la contraseña generada automáticamente de su cuenta. Considere cambiar la contraseña a algo más fácil de recordar." 
    26  
    27 #: simple-user-password-generator.php:76 
    28 msgid "Edit my password" 
    29 msgstr "Editar mi contraseña" 
    30  
     23#: simple-user-password-generator.php:75 
     24msgid "Send this password to the user by email." 
     25msgstr "Enviar esta contraseña al usuario por correo electrónico." 
  • simple-user-password-generator/trunk/readme.txt

    r441580 r590527  
    11=== Simple User Password Generator === 
    2 Contributors: jakemgold 
    3 Donate link: http://www.get10up.com/plugins/simple-user-password-generator-wordpress/ 
     2Contributors: jakemgold, 10up 
     3Donate link: http://10up.com/plugins/simple-user-password-generator-wordpress/ 
    44Tags: users, password, security 
    55Requires at least: 3.2 
    6 Tested up to: 3.2.1 
    7 Stable tag: 1.0 
     6Tested up to: 3.4.1 
     7Stable tag: 2.0 
     8License: GPLv2 
    89 
    9 Allows administrators to generate a secure password when adding new users. 
     10Generate a secure password when adding or updating new users. 
    1011 
    1112== Description == 
    1213 
    13 Users with the ability to add new users (typically just administrators) have a new button on the add users screen that allows them to generate a secure password. 
     14Users with the ability to manage users (administrators) have a new button on the add and edit user screens to generate a secure password. 
    1415 
    15 Also adds a "Encourage the user to change their password, once logged in." checkbox (checked automatically when generating a password) that encourages the user to change their password to something more memorable. The password change suggestion appears on the top of admin pages, and can be easily dismissed. 
     16Also adds an option to encourage the user to change their password, when logged in to the dashboard, as well as an option to send 
     17existing users the new, generated password. 
    1618 
    17 Simple and light weight. No new settings pages or configuration screens, and nothing added to the database. Just install and go! 
     19No new settings pages or configuration screens, nothing added to the database. Just install and go! 
    1820 
    1921Localization ready; includes Spanish translation. Other translations welcome! 
     
    2123== Installation == 
    2224 
    23 1. Install easily with the WordPress plugin control panel or manually download the plugin and upload the extracted folder to the `/wp-content/plugins/` directory 
    24 1. Activate the plugin through the 'Plugins' menu in WordPress 
    25 1. Start adding new users with automatically generated passwords from the Add New users screen! 
     251. Install either via the WordPress.org plugin directory, or by uploading the files to your server. 
     261. Activate the plugin through the 'Plugins' menu in WordPress. 
     271. Get to work adding and editing users with automatically generated, secure passwords! 
    2628 
    2729== Screenshots == 
    2830 
    29311. New "Generate Password" button and "Encourage user to change their password" features seen on the add new users screen. 
     32 
     33== Changelog == 
     34 
     35= 2.0 = 
     36* Adds password generation and email notification support when editing existing users. 
     37* Removes unnecessary code for resetting password on the actual profile editing screen. 
  • simple-user-password-generator/trunk/simple-user-password-generator.js

    r441580 r590527  
    22    jQuery.post( ajaxurl, { action: 'simple_user_generate_password' }, function(response){ 
    33        jQuery('#pass2').val(response); 
    4         jQuery('#pass1').val(response).keyup(); 
     4        jQuery('#pass1').val(response).trigger('keyup'); 
    55        jQuery('#send_password').attr('checked',true); 
    66        jQuery('#reset_password_notice').attr('checked',true); 
     
    99 
    1010jQuery(document).ready(function(){ 
    11     var pass_wrap = jQuery('#pass1').closest('td'); 
    12     pass_wrap.append('<input type="button" name="simple-user-generate-password" id="simple-user-generate-password" value="' + simple_user_password_generator_l10n.Generate + '" onclick="simple_user_generate_password();" class="button" style="width: auto;" />'); 
    13     var send_wrap = jQuery('#send_password').closest('td'); 
    14     send_wrap.append('<br /><label for="reset_password_notice"><input type="checkbox" id="reset_password_notice" name="reset_password_notice" /> ' + simple_user_password_generator_l10n.PassChange + '</label>') 
     11    jQuery('#pass1').closest('td').append('<p style="clear:both;margin:0;"><input type="button" name="simple-user-generate-password" id="simple-user-generate-password" value="' + simple_user_password_generator_l10n.Generate + '" onclick="simple_user_generate_password();" class="button" style="width: auto;" /></p>'); 
     12    jQuery('#send_password').closest('td').append('<br /><label for="reset_password_notice"><input type="checkbox" id="reset_password_notice" name="reset_password_notice" /> ' + simple_user_password_generator_l10n.PassChange + '</label>') 
    1513}); 
  • simple-user-password-generator/trunk/simple-user-password-generator.php

    r441580 r590527  
    22/** 
    33 Plugin Name: Simple User Password Generator 
    4  Plugin URI: http://www.get10up.com/plugins/simple-user-password-generator-wordpress/ 
     4 Plugin URI: http://10up.com/plugins/simple-user-password-generator-wordpress/ 
    55 Description: Allows administrators to generate a secure password when adding new users. 
    6  Version: 1.0 
     6 Version: 2.0 
    77 Author: Jake Goldman (10up LLC) 
    8  Author URI: http://get10up.com 
     8 Author URI: http://10up.com 
    99 
    10     Plugin: Copyright 2011 10up LLC (email : jake@get10up.com) 
     10    Plugin: Copyright 2011 10up LLC (email : jake@10up.com) 
    1111 
    1212    This program is free software; you can redistribute it and/or modify 
     
    3535        add_action( 'wp_ajax_simple_user_generate_password', array( $this, 'ajax_generate_password' ) ); 
    3636        add_action( 'admin_print_scripts-user-new.php', array( $this, 'enqueue_script' ) ); 
     37        add_action( 'admin_print_scripts-user-edit.php', array( $this, 'enqueue_script' ) ); 
    3738        add_action( 'user_register', array( $this, 'user_register' ) ); 
    38         add_action( 'load-profile.php', array( $this, 'load_profile' ) ); 
     39        add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ), 1 ); 
     40        add_action( 'user_profile_update_errors', array( $this, 'user_profile_update_errors' ), 10, 3 ); 
    3941    } 
    4042     
     
    4446     
    4547    public function enqueue_script() { 
    46         if ( ! apply_filters('show_password_fields', true) ) 
     48        if ( !apply_filters( 'show_password_fields', true ) || !current_user_can( 'edit_users' ) ) 
    4749            return; 
    4850             
     
    6163     
    6264    public function user_register( $user_id ) { 
    63         if ( current_user_can( 'add_users' ) && ! empty( $_POST['reset_password_notice'] ) ) 
     65        if ( current_user_can( 'add_users' ) && !empty( $_POST['reset_password_notice'] ) ) 
    6466            update_user_option( $user_id, 'default_password_nag', true, true ); 
    6567    } 
    66      
    67     public function load_profile() { 
    68         if ( get_user_option( 'default_password_nag' ) ) 
    69             add_action( 'admin_notices', array( $this, 'default_password_nag_profile' ) ); 
     68 
     69    public function edit_user_profile( $profileuser ) { 
     70        wp_nonce_field( 'simple-user-password-generator-reset', '_simple_user_password_generator' ); 
     71    ?> 
     72    <table class="form-table"> 
     73        <tr> 
     74            <th scope="row"><label for="send_password"><?php _e('Send Password?') ?></label></th> 
     75            <td><label for="send_password"><input type="checkbox" name="send_password" id="send_password" disabled="disabled" /> <?php _e('Send this password to the user by email.','simple-user-password-generator'); ?></label></td> 
     76        </tr> 
     77    </table> 
     78    <script type="text/javascript"> 
     79        jQuery('#pass1').keyup(function(){ 
     80            var passval = jQuery(this).val(); 
     81            if ( passval == '' ) jQuery('#send_password').attr('disabled','disabled'); 
     82            else jQuery('#send_password').removeAttr('disabled'); 
     83        }); 
     84    </script> 
     85    <?php 
    7086    } 
    71      
    72     public function default_password_nag_profile() { 
    73         echo '<div class="error default-password-nag"><p><strong>' . __('Notice:') . '</strong> '; 
    74         _e( 'You&rsquo;re using the auto-generated password for your account. Consider changing the password to something easier to remember.', 'simple-user-password-generator' ); 
    75         echo '</p><p>'; 
    76         echo '<a href="#password" onclick="jQuery(\'#pass1\').focus();">' . __('Edit my password','simple-user-password-generator') . '</a> | '; 
    77         printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' ); 
    78         echo '</p></div>'; 
     87 
     88    public function user_profile_update_errors( $errors, $update, $user ) { 
     89        if ( !current_user_can( 'edit_users' ) || empty( $_POST['_simple_user_password_generator'] ) || !wp_verify_nonce( $_POST['_simple_user_password_generator'], 'simple-user-password-generator-reset' ) ) 
     90            return; 
     91 
     92        $this->user_register( $user->ID ); 
     93 
     94        if ( !$update || empty( $user->user_pass ) || empty( $_POST['send_password'] ) ) 
     95            return; 
     96 
     97        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 
     98        $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; 
     99        $message .= sprintf(__('Password: %s'), $user->user_pass) . "\r\n"; 
     100        $message .= wp_login_url() . "\r\n"; 
     101 
     102        wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message); 
    79103    } 
    80104} 
Note: See TracChangeset for help on using the changeset viewer.