Plugin Directory

Changeset 487459


Ignore:
Timestamp:
01/10/2012 11:54:12 AM (14 years ago)
Author:
glatze
Message:

Better handling for "prevent email changes"

[Issue 49] http://bt.ecw.de/view.php?id=49

File:
1 edited

Legend:

Unmodified
Added
Removed
  • active-directory-integration/trunk/ad-integration.php

    r487433 r487459  
    401401        // Prevent email change
    402402        if ($this->_prevent_email_change) {
    403             add_action( 'user_profile_update_errors', array(&$this, 'prevent_email_change'), 10, 3 );
     403            add_action( 'edit_user_profile', array(&$this, 'user_profile_prevent_email_change')); // cosmetic
     404            add_action( 'show_user_profile', array(&$this, 'user_profile_prevent_email_change')); // cosmetic
     405            add_action( 'user_profile_update_errors', array(&$this, 'prevent_email_change'), 10, 3 ); // true prevention
    404406        }
    405407    }
     
    14081410            }
    14091411        }
    1410    
    1411         // disable email field if needed (dirty hack)
    1412         if ($this->_prevent_email_change && ($adi_samaccountname != '') && (!current_user_can('level_10'))) {
    1413             ?>
    1414             <script type="text/javascript">
    1415                 var email = document.getElementById('email');
    1416                 if (email) {
    1417                     email.setAttribute('disabled','disabled');
    1418                 }
    1419             </script>
    1420             <?php
    1421         }
    1422        
    1423     }
     1412    }
     1413   
     1414
     1415   
    14241416   
    14251417    /**
     
    15921584   
    15931585    /**
     1586     * Disable email field in user profile if needed (actions edit_user_profile and show_user_profile)
     1587     * This is not safe and only for cosmetic reasons, but we also have the method prevent_email_change() (see below).
     1588     *
     1589     * @param object $user
     1590     */
     1591    public function user_profile_prevent_email_change($user)
     1592    {
     1593        // disable email field if needed (dirty hack)
     1594        if ($this->_prevent_email_change && $this->_is_adi_user($user->ID) && (!current_user_can('level_10'))) {
     1595            ?>
     1596            <script type="text/javascript">
     1597                var email = document.getElementById('email');
     1598                if (email) {
     1599                    email.setAttribute('disabled','disabled');
     1600                }
     1601            </script>
     1602            <?php
     1603        }       
     1604    }   
     1605   
     1606    /**
    15941607     * Prevent ADI users from changing their email (action user_profile_update_errors)
    15951608     *
     
    15981611     * @param object $user
    15991612     */
    1600     public function prevent_email_change(&$errors, $update, &$user) {
     1613    public function prevent_email_change(&$errors, $update, &$user)
     1614    {
    16011615        if ($this->_prevent_email_change && ($this->_is_adi_user($user->ID)) && (!current_user_can('level_10'))) {
    16021616            $old = get_user_by('id', $user->ID);
Note: See TracChangeset for help on using the changeset viewer.