Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: neugi on January 10, 2012, 11:20:19 AM

Title: Board Marked Read but unread Messages in it
Post by: neugi on January 10, 2012, 11:20:19 AM
Hi,

i've got a costumer that is now using smf 2.0.2 before he used phpbb3.

in phpbb3 in a board where 3 posts are marked as unread he took a look into one of the posts, but not in the 2 other, when he gosed back to the overview the board still was marke unread.

in smf, when he reads one post in a board, the whole board is marked read, but there are still 2 unread posts in this board.

he is now claiming this is a but in smf and he want's to have such a feature in smf.

is there something i can do extend oder activate?

best
Title: Re: Board Marked Read but unread Messages in it
Post by: Oldiesmann on January 10, 2012, 12:58:04 PM
It isn't a bug at all. That's how SMF works - when you view the list of topics in a board (or view a topic in the board itself), the board is marked as read. It means that there haven't been any new topics in the board since you last read it.

If it really is that important to have the old functionality, you can make the following code changes, but I can't guarantee that this won't mess up other functionality...

Sources/Display.php

Find and remove
// Mark board as seen if we came using last post link from BoardIndex. (or other places...)
if (isset($_REQUEST['boardseen']))
{
$smcFunc['db_insert']('replace',
'{db_prefix}log_boards',
array('id_msg' => 'int', 'id_member' => 'int', 'id_board' => 'int'),
array($modSettings['maxMsgID'], $user_info['id'], $board),
array('id_member', 'id_board')
);
}


Sources/MessageIndex.php

Find and remove
// We can't know they read it if we allow prefetches.
if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
{
ob_end_clean();
header('HTTP/1.1 403 Prefetch Forbidden');
die;
}

$smcFunc['db_insert']('replace',
'{db_prefix}log_boards',
array('id_msg' => 'int', 'id_member' => 'int', 'id_board' => 'int'),
array($modSettings['maxMsgID'], $user_info['id'], $board),
array('id_member', 'id_board')
);

if (!empty($board_info['parent_boards']))
{
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_boards
SET id_msg = {int:id_msg}
WHERE id_member = {int:current_member}
AND id_board IN ({array_int:board_list})',
array(
'current_member' => $user_info['id'],
'board_list' => array_keys($board_info['parent_boards']),
'id_msg' => $modSettings['maxMsgID'],
)
);

// We've seen all these boards now!
foreach ($board_info['parent_boards'] as $k => $dummy)
if (isset($_SESSION['topicseen_cache'][$k]))
unset($_SESSION['topicseen_cache'][$k]);
}

if (isset($_SESSION['topicseen_cache'][$board]))
unset($_SESSION['topicseen_cache'][$board]);
Title: Re: Board Marked Read but unread Messages in it
Post by: neugi on January 13, 2012, 04:18:19 AM
Hi,

thx for the repley i'll implement this solution and will have a look if the costumer ist okay with it.

thx
Title: Re: Board Marked Read but unread Messages in it
Post by: JimM on February 09, 2012, 09:45:28 PM

If this is solved, please mark it solved by clicking the Mark Topic Solved link at the bottom left.

Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on October 07, 2012, 03:13:13 AM
Hi!
I was looking excaclty for this and I post here just to confirm that it is working!!!
Thank you :)
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on October 24, 2012, 08:02:53 AM
In fact this method  is working with a little small issue;
It shows as unread your own posts/messages! You can only mark them as read only if you hit the button "mark as read".

I mean that I reply to a topic and then it shows my own answer as unread.

Could this be resolved? Perhaps if I add something or remove something from the above files?

I really need  this "old way" of handling read/unread posts but without this small issue that I describe.

Can you help me please?
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on October 24, 2012, 03:40:58 PM
I bump this just to clarify this issue; it shows as unread, my own post, to me. It should show my own post as unread at the others and not me, right?
Title: Re: Board Marked Read but unread Messages in it
Post by: Arantor on October 24, 2012, 04:44:46 PM
Well, it's kind of rude to bump only after a few hours ;)

Your own posts should not be marked unread. It doesn't do it here for example.
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on October 24, 2012, 04:51:44 PM
You're right Arandor. Sorry :-[

As you can see, I deleted some lines from display.php and messageindex.php as described above. Perhaps...well 99% that is cousing this. But I wonder if somehow I could solve it.
I will wait, if someone knows... no prob. ;)
Title: Re: Board Marked Read but unread Messages in it
Post by: Arantor on October 24, 2012, 04:53:00 PM
It is exactly that - you've removed most of the code that relates to logging things as read.
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on October 26, 2012, 07:59:10 PM
Any advise on this?
Please....
Title: Re: Board Marked Read but unread Messages in it
Post by: Oldiesmann on October 29, 2012, 01:48:22 PM
I'm not sure what could be causing that problem. The code I posted above doesn't deal with marking topics as read. That particular code is in Subs-Post.php.
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on October 29, 2012, 03:41:22 PM
Basicaly I have no idea about coding :(

But if it helps this issue started when I remove those lines (as 3rd post says).
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on October 31, 2012, 11:39:53 AM
As I understand, something is related to those lines I deleted  (as mentioned by Oldiesmann at the 3rd post).

Could this be a server issue? Sorry if I sound silly, but I think this didn't happen to my previous server. You can see that if you check my first post on this topic. I confirmed that the above trick is working! I moved since then to a new server.....

I don't know what else to think or where to check.

Please people, give me your suggestions.

Thank you.
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 04, 2012, 01:56:36 AM
Still nothing?  :-[ :'( :-[ :'( :(

Just a thougt or a suggestion would be appreciated.

Thank you.
Title: Re: Board Marked Read but unread Messages in it
Post by: Colin on November 04, 2012, 03:13:55 AM
We aren't to sure as it isn't the edits that were listed above that would have made this happen. Did you take a backup?
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 04, 2012, 03:29:51 AM
Hello Colin.
The sure thing is that  occurs when I remove the lines. If I get them back everything is ok but I don't like the default behavior of the forum. It marks the boards as read but inside there are left many topics unread.

The removing of that lines , solves this problem but it triggers a new. The poster sees as unread his own post.

I found here something  similar  but I haven't got the knowledge what to do: http://www.simplemachines.org/community/index.php?topic=410322.0
Somewhere it says
"// 1. mark board as unread: delete the board from log_boards - we want to show everyone except us that we've edited something important"

That's what I would like: to show everyone that there is a new post except the poster (for his post).

Best Regards

Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 06, 2012, 09:46:40 AM
Please allow me to bump this once again.

In the meantime I think that this topic had an update from Emmanuelle(?) , couse I saw it in notification mail but I can't find it. Maybe it's deleted?

Anyway I would really appreciate your help-info-ideas-instructions.

Thank you!
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 07, 2012, 12:41:47 PM
While searching I found this topic http://www.simplemachines.org/community/index.php?topic=61428.20
I know that it's for an earlier version of smf so I tried to change it to look like version 2.0.2

On the last lines there is Parse error: syntax error, unexpected T_ELSE in /home/amnizia1/public_html/forum/Sources/MessageIndex.php on line 208
Can you check this code for me, please? What is wrong?

// Mark boards as readed if there aren't any new topics any more
// Search all unreaded topics
$request = db_query("
SELECT COUNT(*)
FROM {$db_prefix}topics AS t
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE t.ID_BOARD = $board
AND IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) < t.ID_LAST_MSG", __FILE__, __LINE__);
list ($unreadtopics) = mysql_fetch_row($request);
mysql_free_result($request);

// All topics are readed, mark them as readed
if ($unreadtopics == 0)
db_query("
REPLACE INTO {$db_prefix}log_boards
(ID_MSG, ID_MEMBER, ID_BOARD)
VALUES ($modSettings[maxMsgID], $ID_MEMBER, $board)", __FILE__, __LINE__);

// We've seen all these boards now!
foreach ($board_info['parent_boards'] as $k => $dummy)
if (isset($_SESSION['topicseen_cache'][$k]))
unset($_SESSION['topicseen_cache'][$k]);
}

if (isset($_SESSION['topicseen_cache'][$board]))
unset($_SESSION['topicseen_cache'][$board]);

$request = $smcFunc['db_query']('', '
SELECT sent
FROM {db_prefix}log_notify
WHERE id_board = {int:current_board}
AND id_member = {int:current_member}
LIMIT 1',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
)
);
$context['is_marked_notify'] = $smcFunc['db_num_rows']($request) != 0;
if ($context['is_marked_notify'])
{
list ($sent) = $smcFunc['db_fetch_row']($request);
if (!empty($sent))
{
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_notify
SET sent = {int:is_sent}
WHERE id_board = {int:current_board}
AND id_member = {int:current_member}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'is_sent' => 0,
)
);
}
}
$smcFunc['db_free_result']($request);
}
else
$context['is_marked_notify'] = false;
}
Title: Re: Board Marked Read but unread Messages in it
Post by: emanuele on November 07, 2012, 03:15:51 PM
The code you posted is a mixture of SMF 1.x and 2.0 code, there are some non matching brackets and column names are wrong.

(yes, I posted but then deleted the message because not relevant.)
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 07, 2012, 03:45:52 PM
Can you /anyone make it work? Is this a hard job?

Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 12, 2012, 08:37:53 AM
You are my last hope for a solution.

Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 17, 2012, 03:47:22 PM
Everybody seems to give up on this.

I give up, too.
Title: Re: Board Marked Read but unread Messages in it
Post by: emanuele on November 18, 2012, 05:13:15 AM
I kept this unread, so I didn't give up...only time limits...
Attach your MessageIndex.php.

The query in Subs-Boards.php should be:
// This allows Snakehit's mod to detect posts that have
// been changed from the read state to the unread state
$smcFunc['db_insert']('replace',
'{db_prefix}log_boards',
array('id_msg' => 'int', id_member' => 'int', 'id_board' => 'int'),
array($earlyMsg, $user_info['id'], $board),
array()  // Don't remember what I have to put here because I don't remember the indexes of log_boards if any...
);
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on November 18, 2012, 06:09:30 AM
Thank you.
I will try that.

I attach the messageindex.php
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on December 06, 2012, 12:10:22 PM
We finnally moved to phpbb :'(
The only good thing in phpbb is the handling of the new unread posts. Only that!
I will continue to hope that someone can fix this.
I wonder if I should donate someone to do it.

Title: Re: Board Marked Read but unread Messages in it
Post by: Colin on December 06, 2012, 04:43:13 PM
Hi Alsthom,
I am sorry to hear we lost you. I hope this will be added as a mod in the near future and you can give it a try then.

Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on December 06, 2012, 07:46:23 PM
God knows how I am waiting for this!
In fact I was testing smf theese two months but I am really IMPRESSED! Fast, excellent and with simple and powerfull admin panel. Phpbb is a pain to work with, BUT it has this "feature" that my users want. (I want it, too).

Anyway please don't close this topic. I hope that someone, someday will fix it.
Title: Re: Board Marked Read but unread Messages in it
Post by: emanuele on December 16, 2012, 11:13:49 AM
The messageindex should look like the one attached.
Title: Re: Board Marked Read but unread Messages in it
Post by: MrPhil on December 16, 2012, 12:15:20 PM
So, as explained earlier, SMF's philosophy is that looking inside a board causes it to be marked "Read", even if there are still unread messages within it. If you want "Read" to mean "there are no unread messages inside it", that should be quite possible. You would have to look at all the topic "read/unread" flags that will be listed inside the board to see if there are any unread messages. That's probably a bit more of a database load. @emanuele, is that what the MessageIndex.php you just attached doing? If it works for @alsthom, perhaps it could be made a mod?
Title: Re: Board Marked Read but unread Messages in it
Post by: emanuele on December 16, 2012, 12:45:07 PM
It's part of the changes described in the linked topic. It should work, but I didn't check it, just trusted the topic. :P
Title: Re: Board Marked Read but unread Messages in it
Post by: MrPhil on December 19, 2012, 11:32:02 AM
Maybe SMF needs different icons for the boards --
Maybe it could be done better with a base icon or two (current updated/not updated since your last visit), and add-on overlays (locked*, pinned*, unread messages subicons)? Does it cost any more (in processing cycles) to tell if the board has been updated since you were last in there, versus telling if there are any unread messages? If they can both be done on the same pass, it might be worth distinguishing between the two.

* useful for topics, but I don't think they're currently used for boards
Title: Re: Board Marked Read but unread Messages in it
Post by: emanuele on December 19, 2012, 04:36:03 PM
The issue is usually not the icons, but the fact that to obtain that effect you need to run few queries more on each messageindex/boardindex page load.
Of course it may not be an issue, but it could also be...
Title: Re: Board Marked Read but unread Messages in it
Post by: alsthom on December 21, 2012, 03:14:10 AM
I think that the problem is relaying somewhere else, but I don't have the knowledge to look for it.

If you remove some lines of code, as described here
http://www.simplemachines.org/community/index.php?topic=465097.msg3248028#msg3248028
the system is behaving excactly as phpbb (or as I would like it).

But it shows as unread the poster's post to the poster himself. I think this is the point that needs attention.

On the other hand (with the old mod of snakehit) it doesn't work in 2.0.2.
The messageindex that emanuelle has attached  has error in line 215 (can't recall it now)