Section: Extra info / Online advanced info menu by TheMadMonk / Forums

Ă—

System Information

Canonical URL from content plugin: https://www.e107.sk/e107_plugins/forum/forum_viewtopic.php?id=123&p=1

  • There are those parts:

    updated
    birthday
    lastvisitors
    topvisits
    toppost
    toppoststarter
    toppostreplier
    topratedmember
    counter
     

  • lastvisitors

    - old sql didn't work, fixed, updated to new user profile url 

    marked as FIXED

     

  • toppoststarter

    Original query:

    $query="SELECT FLOOR(thread_user) as t_user, COUNT(FLOOR(ft.thread_user)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
    LEFT JOIN #user AS u ON FLOOR(ft.thread_user) = u.user_id
    WHERE ft.thread_parent=0
    GROUP BY t_user
    ORDER BY ucount DESC
    LIMIT 0,".$extrarecords."";

    replaced by

    $query = "
    SELECT FLOOR(thread_user) as t_user, COUNT(FLOOR(ft.thread_user)) AS ucount, u.user_name, u.user_id FROM #forum_thread as ft
    LEFT JOIN #user AS u ON FLOOR(ft.thread_user) = u.user_id
    LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
    WHERE ft.thread_active > 0
    AND f.forum_class IN (".USERCLASS_LIST.")
    GROUP BY t_user
    ORDER BY ucount DESC
    LIMIT 0,".$extrarecords."";

    forum_stats.php use way to complicate to understand (all statistics are counted at once, not separated queries)

    At the end removed visibility check:

        $query = "
    SELECT FLOOR(thread_user) as t_user, COUNT(FLOOR(ft.thread_user)) AS ucount, u.user_name, u.user_id FROM #forum_thread as ft
            LEFT JOIN #user AS u ON FLOOR(ft.thread_user) = u.user_id
            WHERE ft.thread_active > 0
    GROUP BY t_user
            ORDER BY ucount DESC
    LIMIT 0," . $extrarecords . "";
    to have the same results as core - including active:
    SELECT FLOOR(thread_user) as t_user, COUNT(FLOOR(ft.thread_user)) AS ucount, u.user_name, u.user_id FROM #forum_thread as ft
    LEFT JOIN #user AS u ON FLOOR(ft.thread_user) = u.user_id
    GROUP BY t_user
    ORDER BY ucount DESC
    LIMIT 0," . $extrarecords . "";
     

  • toppostreplier

    Original:

    $query = "
    SELECT FLOOR(thread_user) as t_user, COUNT(FLOOR(ft.thread_user)) AS ucount, u.user_name, u.user_id FROM #forum_thread as ft
    LEFT JOIN #user AS u ON FLOOR(ft.thread_user) = u.user_id
    WHERE ft.thread_parent!=0
    GROUP BY t_user
    ORDER BY ucount DESC
    LIMIT 0,".$extrarecords."";

    Replaced (not sure if this is correct, too easy)

    $query = "
    SELECT FLOOR(post_user) as t_user, COUNT(FLOOR(ft.post_user)) AS ucount, u.user_name, u.user_id FROM #forum_post as ft
    LEFT JOIN #user AS u ON FLOOR(ft.post_user) = u.user_id
    GROUP BY t_user
    ORDER BY ucount DESC
    LIMIT 0," . $extrarecords . "";

     

  • toppost

    if (!$sql->db_Select("user", "*", "ORDER BY user_forums DESC LIMIT 0, ".$extrarecords."", "no_where"))

    - this returns values because after update this field is still in user table. 

    Correct fix is:

    $query = "SELECT *, ue.user_plugin_forum_posts AS post_count FROM #user AS u
    LEFT JOIN #user_extended AS ue ON ue.user_extended_id = u.user_id
    ORDER BY post_count DESC LIMIT 0, ".$extrarecords ."";

    $user_forums = $row['post_count'];

    but this way Top forum posters is the same as Top forum repliers. 

    I created issue 

     

  • FOR NOW:

    - I removed Top posters section. 

    Reason:

    Top Posters and Top repliers are the same, because in user extended field is post counts. 

    Core Top repliers are not correct either (you can see it on this site too in forum statistics)

    Until I get answers to my question about this.

     

  • Help from rica-carv, but it needs to replace 3 files with one.. it means completly rewrite forum stats in menu

    It's a ugly query, but it gives all the thread_count (tcount), post_count (ucount) and reply_count (rcount)....
    SELECT FLOOR(post_user) as t_user,
    COUNT(FLOOR(fp.post_user)) AS ucount, u.user_name, u.user_id
    , (SELECT COUNT(FLOOR(thread_user)) AS ucount
    FROM e107_forum_thread WHERE thread_user = t_user
    ) as tcount,
    COUNT(FLOOR(fp.post_user))-(SELECT COUNT(FLOOR(thread_user)) AS ucount
    FROM e107_forum_thread WHERE thread_user = t_user
    ) as rcount
    FROM e107_forum_post as fp
    LEFT JOIN e107_user AS u ON FLOOR(fp.post_user) = u.user_id
    GROUP BY fp.post_user
    ORDER BY ucount DESC
    LIMIT 0,10

     

Moderator(s):