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

Session Activity Inconstancy?

Discussion in 'XenForo Development Discussions' started by Jaxel, Mar 9, 2011.

  1. Jaxel

    Jaxel Well-Known Member

    The screenshot below shows session activity...

    Untitled-2.jpg

    The top is on a user profile page... the bottom is from the members online page. Why does one of them give a link to the page I am browsing, while the bottom one does not? This is my code...
    Code:
        public static function getSessionActivityDetailsForList(array $activities)
    
        {
            $pageSlugs = array();
            foreach ($activities AS $activity)
            {
                if (!empty($activity['params']['page_slug']))
                {
                    $pageSlugs[$activity['params']['page_slug']] = $activity['params']['page_slug'];
                }
            }
    
            $pageData = array();
            if ($pageSlugs = implode(',', $pageSlugs))
            {
                $pageModel = XenForo_Model::create('EWRcarta_Model_Pages');
                $pages = $pageModel->getPagesBySlugs($pageSlugs);
    
                foreach ($pages AS $page)
                {
                    $pageData[$page['page_slug']] = array(
                        'title' => $page['page_name'],
                        'url' => XenForo_Link::buildPublicLink('wiki', $page)
                    );
                }
            }
    
            $output = array();
            foreach ($activities as $key => $activity)
            {
                $page = false;
                if (!empty($activity['params']['page_slug']))
                {
                    $pageSlug = $activity['params']['page_slug'];
                    if (isset($pageData[$pageSlug]))
                    {
                        $page = $pageData[$pageSlug];
                    }
                }
    
                if ($page)
                {
                    $output[$key] = array(new XenForo_Phrase('viewing_wiki'), $page['title'], $page['url'], false);
                }
                else
                {
                    $output[$key] = new XenForo_Phrase('viewing_wiki');
                }
            }
    
            return $output;
        }
     
  2. ragtek

    ragtek Guest

    o c'mon.

    PHP:
     $output[$key] = new XenForo_Phrase('viewing_wiki');
    you're returning a phrase without any params, so how should the code know, where he should link.

    check the thread session activity method.
    PHP:
    if ($thread)
                {
                    
    $output[$key] = array(
                        new 
    XenForo_Phrase('viewing_thread'),
                        
    $thread['title'],
                        
    $thread['url'],
                        
    $thread['previewUrl']
                    );
                }
     
  3. Jaxel

    Jaxel Well-Known Member

    I don't think you looked over my code very carefully...
    I am already doing exactly what you said at the bottom of your post...
    PHP:
                if ($page)
                {
                    
    $output[$key] = array(
                        new 
    XenForo_Phrase('viewing_wiki'),
                        
    $page['title'],
                        
    $page['url'],
                        
    false
                    
    );
                }
                else
                {
                    
    $output[$key] = new XenForo_Phrase('viewing_wiki');
                }
    It clearly works, as on the profile pages, it lists what page I am browsing.
    Its only on the members online page that it doesnt.
     
  4. ragtek

    ragtek Guest

    Ups.

    Sorry:oops:
    It's early in the morning, i should drink 2 red bulls, before i check threads:D

    Have you started debugging and checked what's stored in $page
     
  5. Jaxel

    Jaxel Well-Known Member

    $page works... its showing correctly on profile pages... just not members online pages.
     
  6. Jaxel

    Jaxel Well-Known Member

    I've figured out what the issue is... its in my getPagesBySlugs function...
    PHP:
    $pages $this->fetchAllKeyed("
                SELECT *
                    FROM EWRcarta_pages
                WHERE page_slug IN (" 
    $this->_getDb()->quote($pageSlugs) . ")
            "
    'page_slug')
    The problem is that $this->_getDb()->quote($pageSlugs) leads to 'algol, abyss, hilde'... instead of 'algol','abyss','hilde'.

    However, this is the same function that is being used in XenForo_Model_Thread->getThreadsByIds... so why does it work there, and not here?
     
  7. Jaxel

    Jaxel Well-Known Member

    Okay... I figured it out... I was imploding the $pageSlugs into a string... as it turns out, that magic quote fuction takes in an array, not a string. So I simply stopped imploding the ID list.
     

Share This Page