1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Include banned members in total member count?

Discussion in 'XenForo Development Discussions' started by dutchbb, Apr 10, 2011.

  1. dutchbb

    dutchbb Well-Known Member

    I want the banned members to be included in the total member statistics. How can I do this?
     
  2. Tilkißey

    Tilkißey Well-Known Member


    XenForo_Model_User file
    line 899-907
    PHP:
    public function countTotalUsers()
    {
    return 
    $this->_getDb()->fetchOne('
    SELECT COUNT(*)
    FROM xf_user
    WHERE user_state = \'valid\'
     AND is_banned = 0
    '
    );
    }
    you can change it to
    PHP:
    public function countTotalUsers()
    {
    return 
    $this->_getDb()->fetchOne('
    SELECT COUNT(*)
    FROM xf_user
    WHERE user_state = \'valid\'
    '
    );
    }
    but, if u ask me, i dont recommend this, coz, you ve to re-edit this file after all updates
     
  3. ragtek

    ragtek Guest

    You can overwrite/extend the original classes/methods without editing the files.

    that's why it's important to use xenforo_model::create('model_name') to initialize the models instead of $foo = new model_name... (what your add-ons still aren't making, even it was recommended several times by shamil and other developers...)
     
  4. Tilkißey

    Tilkißey Well-Known Member

    i am not sure that i know overwrite to an original class via listener

    PS: i use create('blabla') in my add-ons' updated versions ;)
     
    ragtek likes this.
  5. ragtek

    ragtek Guest

    finally:)
    thx
     
    Tilkißey likes this.
  6. ragtek

    ragtek Guest

    dutchbb likes this.
  7. ragtek

    ragtek Guest

    PHP:
    class Ragtek_C1_Model_User extends XFCP_Ragtek_C1_Model_User
    {
        public function 
    countTotalUsers()
        {
            return 
    $this->_getDb()->fetchOne('
                SELECT COUNT(*)
                FROM xf_user
                WHERE user_state = \'valid\'
            '
    );
        }
    }
    that's it.

    1. create the listener to extend the user model
    2. use the proxy class system to overwrite the method (extending the class from an non existing proxy class)
    (class Ragtek_C1_Model_User extends XFCP_Ragtek_C1_Model_User

    to see how it's working, check xenforo_application:: resolveDynamicClass line 330
     

Share This Page