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

XF 1.2 Members on line (alphabetical order)

Discussion in 'XenForo Questions and Support' started by tommydamic68, Oct 12, 2013.

  1. tommydamic68

    tommydamic68 Well-Known Member

    Is there a way to make this in alphabetical order?

    Screen Shot 2013-10-12 at 10.34.11 AM.png
     
  2. Liam W

    Liam W Well-Known Member

    Nope. It's in the order of the most recently active users, and theres no way to change it in the default software.
     
  3. tommydamic68

    tommydamic68 Well-Known Member

  4. Chris D

    Chris D XenForo Developer Staff Member

    It's possible with a very simple code edit:

    Open the file: library/XenForo/Model/Session.php

    Find:

    PHP:
    public function getSessionActivityQuickList(array $viewingUser, array $conditions = array(), array $forceInclude null)
    Shortly below that you'll see:

    PHP:
            $fetchOptions = array(
                
    'join' => self::FETCH_USER,
                
    'order' => 'view_date'
            
    );
    Change 'view_date' to 'username'.
     
    AndyB and Jake Bunce like this.
  5. tommydamic68

    tommydamic68 Well-Known Member

    Will try shortly. And on your add on "members who visited in the last 24 hrs"? :D
     
  6. tommydamic68

    tommydamic68 Well-Known Member

    Worked! Thanks @Chris Deeming!
     
  7. tommydamic68

    tommydamic68 Well-Known Member

  8. Chris D

    Chris D XenForo Developer Staff Member

    Yes, it's the same premise.

    Almost exactly the same, actually.

    I think the file is WhoHasVisited/Model/WhoHasVisited.php

    I'm sure you'll find it.
     
  9. tommydamic68

    tommydamic68 Well-Known Member

    I didn't fine the exact code as you mentioned above. Do you see anything here that would do the trick?
    Code:
    <?php
    
    
    
    class WhoHasVisited_Model_WhoVisited extends XenForo_Model
    
    {
    
        public function updateWhoVisitedCache()
    
        {
    
            $whoVisited = $this->getWhoVisited();
    
           
    
            XenForo_Application::setSimpleCacheData('whoHasVisited', $whoVisited);
    
           
    
            return $whoVisited;
    
        }
    
       
    
        public function getWhoVisited()
    
        {
    
            $timeRange = $this->getTimeRange();
    
           
    
            $users = $this->fetchAllKeyed("
    
                SELECT
    
                    user.user_id, user.username,
    
                    user.avatar_date, user.last_activity,
    
                    user.visible, user.is_banned,
    
                    user.display_style_group_id, activity.view_date
    
                FROM xf_user AS user
    
                LEFT JOIN xf_session_activity AS activity ON
    
                    (user.user_id = activity.user_id)
    
                WHERE last_activity BETWEEN
    
                    $timeRange[from] AND $timeRange[to]
    
                ORDER BY last_activity DESC
    
            ", 'user_id');
    
           
    
            $whoHasVisited = array(
    
                'time' => XenForo_Application::$time,
    
                'users' => $users,
    
            );
    
           
    
            foreach ($whoHasVisited['users'] AS &$user)
    
            {
    
                $user['last_activity'] = $user['view_date'] > $user['last_activity'] ? $user['view_date'] : $user['last_activity'];
    
            }
    
           
    
            return $whoHasVisited;
    
        }
    
       
    
        public function getWhoVisitedFromCache()
    
        {
    
            $options = XenForo_Application::get('options');
    
            $currentTime = XenForo_Application::$time;
    
           
    
            if ($options->whoHasVisitedCached)
    
            {
    
                $whoHasVisited = XenForo_Application::getSimpleCacheData('whoHasVisited');
    
               
    
                if (empty($whoHasVisited))
    
                {
    
                    return $this->updateWhoVisitedCache();
    
                }
    
               
    
                if (!empty($whoHasVisited['time']) && ($currentTime - $whoHasVisited['time']) <= ($options->whoHasVisitedCached * 60))
    
                {
    
                    return $whoHasVisited;
    
                }
    
               
    
                return $this->updateWhoVisitedCache();
    
            }
    
           
    
            return $this->getWhoVisited();
    
        }   
    
       
    
        public function getTimeRange()
    
        {
    
            $options = XenForo_Application::get('options');
    
           
    
            $timeRange = array(
    
                'to' => XenForo_Application::$time,
    
                'from' => XenForo_Application::$time - ($options->whoHasVisitedHours * 60 * 60)
    
            );
    
           
    
            return $timeRange;
    
        }
    
       
    
        public function prepareWhoHasVisited(array $whoHasVisited)
    
        {
    
            foreach ($whoHasVisited['users'] AS $key => &$user)
    
            {
    
                if (!$this->getModelFromCache('XenForo_Model_User')->canBypassUserPrivacy())
    
                {
    
                    if (!$user['visible'])
    
                    {
    
                        unset($whoHasVisited['users'][$key]);
    
                    }
    
                   
    
                    if ($user['is_banned'])
    
                    {
    
                        unset($whoHasVisited['users'][$key]);
    
                    }                   
    
                }
    
            }
    
           
    
            $options = XenForo_Application::get('options');
    
           
    
            $whoHasVisited['count'] = count($whoHasVisited['users']);
    
           
    
            $whoHasVisited['display_users'] = array_slice($whoHasVisited['users'], 0, $options->whoHasVisitedLimit, true);
    
            $whoHasVisited['display_count'] = count($whoHasVisited['display_users']);
    
           
    
            $whoHasVisited['hide_users'] = array_slice($whoHasVisited['users'], $options->whoHasVisitedLimit, NULL, true);
    
            $whoHasVisited['hide_count'] = count($whoHasVisited['hide_users']);
    
           
    
            return $whoHasVisited;
    
        }
    
       
    
        public function canViewWhoVisited(array $viewingUser = null)
    
        {
    
            $this->standardizeViewingUserReference($viewingUser);
    
           
    
            $userGroups = XenForo_Application::get('options')->whoHasVisitedGroup;
    
           
    
            return $this->getModelFromCache('XenForo_Model_User')->isMemberOfUserGroup($viewingUser, $userGroups);
    
        }
    
    }
    
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    Search for:

    PHP:
    ORDER BY last_activity DESC
    Replace with:

    PHP:
    ORDER BY user.username DESC
     
  11. tommydamic68

    tommydamic68 Well-Known Member

    Will give it a try. Guess I have to wait until it refreshes? I have it set for 360 minutes.
     
  12. Chris D

    Chris D XenForo Developer Staff Member

    Set it to 0. Change it back when it has refreshed.
     
  13. tommydamic68

    tommydamic68 Well-Known Member

    I did that yesterday and i got a horrible error, sort of scared me, once set back to 360 it fixed itself...?
     
  14. Chris D

    Chris D XenForo Developer Staff Member

    What was the error?
     
  15. tommydamic68

    tommydamic68 Well-Known Member

    shall i do it again and screen shot it?
     
  16. Chris D

    Chris D XenForo Developer Staff Member

    Yeah... I would ask you to get it from the Server Error log in the Admin CP, but I don't why you would get an error there so it would be good to see if that error still happens.
     
  17. tommydamic68

    tommydamic68 Well-Known Member

    ok - one sec.
     
  18. tommydamic68

    tommydamic68 Well-Known Member

    Hmmm. Didn't get that time - a good thing! However, the the members are listed from Z at the top to A at the bottom?
     
  19. Chris D

    Chris D XenForo Developer Staff Member

    Could you get the error out of the Server Error log in the Admin CP?

    I'm still intrigued!

    Sorry, my bad.

    Change:

    PHP:
    ORDER BY user.username DESC
    to

    PHP:
    ORDER BY user.username ASC
     
  20. tommydamic68

    tommydamic68 Well-Known Member

Share This Page