News:

Wondering if this will always be free?  See why free is better.

Main Menu

Count unread replies on index

Started by Rudolf, May 18, 2007, 08:36:50 PM

Previous topic - Next topic

Boxer2

Bump. anyone with similar problem???
SMF je zakon a zakon se mora poštivati.

www.alfisti.hr

WilK

It doesn't work on SMF 2.0, try what I wrote.
Per aspera ad astra

Boxer2

Im trying but no result for now...Is correct that information??

QuoteFind: [Select]

}

// Check for moderators and see if they have access to the board.

Add Before: [Select]

Bolded part is confusing me ???
SMF je zakon a zakon se mora poštivati.

www.alfisti.hr

WilK

Quote from: WilK on September 24, 2009, 10:46:10 AM
If anyone needs, with a little bit help from Arantor I managed to convert mod to work with SMF 2.0

It's not fully tested, so if you run across some bugs and errors please PM me, I will try to fix them.

//Count unread replies on index MOD- Start
    $user_info['unread_topics'] = 0;
    $user_info['unread_replies'] = 0;
    //Only count for members, and those who can see at least one board
    if (!$user_info['is_guest'] && !empty($user_info['query_wanna_see_board']))
    {
            $request = $smcFunc['db_query']('', '
                SELECT MIN(lmr.id_msg), member_groups
                FROM {db_prefix}boards AS b
                    LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:id_member})
                WHERE {query_wanna_see_board}',
                array(
                    'id_member' => $id_member,
                )
            );
        list ($earliest_msg) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);

        // This is needed in case of topics marked unread.
        if (empty($earliest_msg))
          $earliest_msg = 0;
        else
        {
            // This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
            $request = $smcFunc['db_query']('', '
                SELECT MIN(id_msg)
                FROM {db_prefix}log_topics
                WHERE id_member = {int:id_member}',
array(
'id_member' => $id_member,
)
);
            list ($earliest_msg2) = $smcFunc['db_fetch_row']($request);
            $smcFunc['db_free_result']($request);

            if ($earliest_msg2 == 0)
                $earliest_msg2 = -1;
            $earliest_msg = min($earliest_msg2, $earliest_msg);
        }


        //Select the boards to choose from... all
        $request = $smcFunc['db_query']('', '
            SELECT b.id_board
            FROM {db_prefix}boards AS b
            WHERE {query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
                AND b.id_board != ' . (int) $modSettings['recycle_board'] : ''));
        $boards = array();
        while ($row = $smcFunc['db_fetch_assoc']($request))
            $boards[] = $row['id_board'];
        $smcFunc['db_free_result']($request);

        if (empty($boards))
          fatal_lang_error('error_no_boards_selected');

        $query_this_board = 'id_board IN (' . implode(', ', $boards) . ')';

        //Count unread topics
        $request = $smcFunc['db_query']('', '
            SELECT COUNT(*)
           FROM {db_prefix}boards AS b
                LEFT JOIN {db_prefix}topics AS t ON (b.id_board = t.id_board)
                LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
                LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:id_member})
            WHERE {query_see_board}
                AND t.id_last_msg > {int:earliest_msg}
                AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg',
            array(
'earliest_msg' => $earliest_msg,
                'id_member' => $id_member,
                'query_see_board' => $query_this_board,
                )
             );
        list ($user_info['unread_topics']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);

//Count unread replies
        $request = $smcFunc['db_query']('', '
            SELECT COUNT(DISTINCT t.id_topic)
            FROM ({db_prefix}boards AS b, {db_prefix}messages AS m)
                LEFT JOIN {db_prefix}topics AS t ON (b.id_board = t.id_board)
                LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
                LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:id_member})
            WHERE {query_see_board}
                AND m.id_topic = t.id_topic
                AND m.id_member = {int:id_member}
                AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg',
            array(
                'id_member' => $id_member,
                'query_see_board' => $query_this_board,
                )
            );
        list ($user_info['unread_replies']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
    }
//Count unread replies on index MOD- End


Follow all steps of mod installation, except first one. Use code I quoted here. It's tested on RC1.2, but I guess it should work on RC2 too.

And yes, this is correct. It is important to put this code BEFORE "}".
Per aspera ad astra

Am'

اذا أحس أحد انه لم يخطأ ابدا في حياته, فهذا يعني أنه لم يجرب أي جديد في حياته
My Mods For SMF 2 RC3 : XQuote XCode - Vbulletin Style New Meta Tags

danielseeksGod

Quote from: WilK on September 24, 2009, 10:46:10 AM
If anyone needs, with a little bit help from Arantor I managed to convert mod to work with SMF 2.0

It's not fully tested, so if you run across some bugs and errors please PM me, I will try to fix them.

//Count unread replies on index MOD- Start
    $user_info['unread_topics'] = 0;
    $user_info['unread_replies'] = 0;
    //Only count for members, and those who can see at least one board
    if (!$user_info['is_guest'] && !empty($user_info['query_wanna_see_board']))
    {
            $request = $smcFunc['db_query']('', '
                SELECT MIN(lmr.id_msg), member_groups
                FROM {db_prefix}boards AS b
                    LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:id_member})
                WHERE {query_wanna_see_board}',
                array(
                    'id_member' => $id_member,
                )
            );
        list ($earliest_msg) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);

        // This is needed in case of topics marked unread.
        if (empty($earliest_msg))
          $earliest_msg = 0;
        else
        {
            // This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
            $request = $smcFunc['db_query']('', '
                SELECT MIN(id_msg)
                FROM {db_prefix}log_topics
                WHERE id_member = {int:id_member}',
array(
'id_member' => $id_member,
)
);
            list ($earliest_msg2) = $smcFunc['db_fetch_row']($request);
            $smcFunc['db_free_result']($request);

            if ($earliest_msg2 == 0)
                $earliest_msg2 = -1;
            $earliest_msg = min($earliest_msg2, $earliest_msg);
        }


        //Select the boards to choose from... all
        $request = $smcFunc['db_query']('', '
            SELECT b.id_board
            FROM {db_prefix}boards AS b
            WHERE {query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
                AND b.id_board != ' . (int) $modSettings['recycle_board'] : ''));
        $boards = array();
        while ($row = $smcFunc['db_fetch_assoc']($request))
            $boards[] = $row['id_board'];
        $smcFunc['db_free_result']($request);

        if (empty($boards))
          fatal_lang_error('error_no_boards_selected');

        $query_this_board = 'id_board IN (' . implode(', ', $boards) . ')';

        //Count unread topics
        $request = $smcFunc['db_query']('', '
            SELECT COUNT(*)
           FROM {db_prefix}boards AS b
                LEFT JOIN {db_prefix}topics AS t ON (b.id_board = t.id_board)
                LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
                LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:id_member})
            WHERE {query_see_board}
                AND t.id_last_msg > {int:earliest_msg}
                AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg',
            array(
'earliest_msg' => $earliest_msg,
                'id_member' => $id_member,
                'query_see_board' => $query_this_board,
                )
             );
        list ($user_info['unread_topics']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);

//Count unread replies
        $request = $smcFunc['db_query']('', '
            SELECT COUNT(DISTINCT t.id_topic)
            FROM ({db_prefix}boards AS b, {db_prefix}messages AS m)
                LEFT JOIN {db_prefix}topics AS t ON (b.id_board = t.id_board)
                LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
                LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:id_member})
            WHERE {query_see_board}
                AND m.id_topic = t.id_topic
                AND m.id_member = {int:id_member}
                AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg',
            array(
                'id_member' => $id_member,
                'query_see_board' => $query_this_board,
                )
            );
        list ($user_info['unread_replies']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
    }
//Count unread replies on index MOD- End


im getting this error:

Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

hhy89

Seo4Smf 2.0 - Full Top10 Stats(full top10) - Aligned and Bilateral Child Boards(2li 3lü alt bölümler)
http://www.smfmod.com
http://destek.smfmod.com


hhy89

Seo4Smf 2.0 - Full Top10 Stats(full top10) - Aligned and Bilateral Child Boards(2li 3lü alt bölümler)
http://www.smfmod.com
http://destek.smfmod.com



hhy89

Seo4Smf 2.0 - Full Top10 Stats(full top10) - Aligned and Bilateral Child Boards(2li 3lü alt bölümler)
http://www.smfmod.com
http://destek.smfmod.com

fals

Just what i needed!  :)


But I use the counter in the menu bar instead - just use the code from index.template.php in Subs.php

Quote from: hhy89 on April 23, 2011, 05:14:07 AM
http://www.simplemachines.org/community/index.php?topic=171948.msg2862106#msg2862106
for rc5
so its rc4 and rc5 both






500fan.dk - SMF 2.0 ~ custom theme
ls-forum.dk - SMF 2.0.2 ~ custom theme and custom iPhone theme

hhy89

give me ur theme's index.template.php
Seo4Smf 2.0 - Full Top10 Stats(full top10) - Aligned and Bilateral Child Boards(2li 3lü alt bölümler)
http://www.smfmod.com
http://destek.smfmod.com

Alpay

@hhy
Unread : 155 Shows
There is nothing when I click on =)

hhy89

Seo4Smf 2.0 - Full Top10 Stats(full top10) - Aligned and Bilateral Child Boards(2li 3lü alt bölümler)
http://www.smfmod.com
http://destek.smfmod.com

zzion

Very useful plugin, thanks! It works on 2.0.2. I added Russian translate.

Biology Forums

#57
Quote from: zzion on January 18, 2013, 01:00:50 PM
Very useful plugin, thanks! It works on 2.0.2. I added Russian translate.

This worked well.

Biology Forums

Quote from: zzion on January 18, 2013, 01:00:50 PM
Very useful plugin, thanks! It works on 2.0.2. I added Russian translate.

This doesn't count the "unread topics" since last visit correctly. It actually counts *all* unread topics instead, which is wrong.

profzelonka

This is such an under rated mod.. Would be awesome if someone fixed it to stop showing all unread topics. (Only) New topics is what that page is for, not old..

Advertisement: