• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Username Changes

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
Quick note for everybody who's not studying the code^^
Since 1.0.2 it's possible to update automatic tables, which stores the username (for example for commentstables from custom content types,..) and where it's necessary to upgrade the username

You can use the static $usernameChangeUpdates variable from the user datawriter to add your own entries which will be updated if the user gets a new username.

PHP:
/**
    * List of denormalised username fields in tables that should
    * be updated in the event that a username is changed.
    *
    * @var array [query-key => [tablename, username-field, user-id-field]]
    */
    public static $usernameChangeUpdates = array
    (
        // the following fields are set at content creation time and will never change automatically
        'permanent' => array
        (
            'conversation_master_username'
                => array('xf_conversation_master', 'username', 'user_id'),
            'conversation_message_username'
                => array('xf_conversation_message', 'username', 'user_id'),
            'deletion_log_delete_username'
                => array('xf_deletion_log', 'delete_username', 'delete_user_id'),
            'news_feed_username'
                => array('xf_news_feed', 'username', 'user_id'),
            'post_username'
                => array('xf_post', 'username', 'user_id'),
            'profile_post_username'
                => array('xf_profile_post', 'username', 'user_id'),
            'profile_post_comment_username'
                => array('xf_profile_post_comment', 'username', 'user_id'),
            'report_comment_username'
                => array('xf_report_comment', 'username', 'user_id'),
            'spam_cleaner_log_username'
                => array('xf_spam_cleaner_log', 'username', 'user_id'),
            'spam_cleaner_log_applying_usernane'
                => array('xf_spam_cleaner_log', 'applying_username', 'applying_user_id'),
            'thread_username'
                => array('xf_thread', 'username', 'user_id'),
        ),
        // the following are denormalized, but will update over time as more replies etc. are added to the content
        'non-permanent' => array
        (
            'thread_last_post_username'
                => array('xf_thread', 'last_post_username', 'last_post_user_id'),
            'conversation_master_last_message_username'
                => array('xf_conversation_master', 'last_message_username', 'last_message_user_id'),
            'conversation_user_last_message_username'
                => array('xf_conversation_user', 'last_message_username', 'last_message_user_id'),
            'forum_last_post_username'
                => array('xf_forum', 'last_post_username', 'last_post_user_id'),
        )
    );
 
Top Bottom