Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: margarett on October 01, 2013, 06:55:20 AM

Title: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 06:55:20 AM
EDIT: This is now available as a MOD:
http://custom.simplemachines.org/mods/index.php?mod=3786

First of all, I hope this hasn't been issued before, but a quick search brought no results, so...

I'm sure everyone already found himself in this situation: 2 "unread posts since last visit", plus 4 pages of "All unread posts" and just when you are to click the "ALL UNREAD POSTS", you actually click the "MARK ALL MESSAGES AS READ".

First you curse like hell, then you realize there's nothing to to about it :P

This happened to me just today on this very forum, so I tried to find a way to have the confirmation message that we get in many other places also available in this little button. And it's quite easy.
So:

languages/index.english.php
Add at the end of the file (before ?>)
$txt['are_sure_mark_read'] = 'Are you sure you want to mark messages as read?';
Of course, you can change the text to anywhere you like.

BoardIndex.template.php
Find:
'markread' => array('text' => 'mark_as_read', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=all;' . $context['session_var'] . '=' . $context['session_id']),
Replace with:
'markread' => array('text' => 'mark_as_read', 'image' => 'markread.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_mark_read'] . '\');"', 'url' => $scripturl . '?action=markasread;sa=all;' . $context['session_var'] . '=' . $context['session_id']),

MessageIndex.template.php
Find:
'markread' => array('text' => 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
Replace with:
'markread' => array('text' => 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_mark_read'] . '\');"', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),

Recent.template.php
Find
'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
Replace with:
'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_mark_read'] . '\');"', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),

Find:
'markread' => array('text' => 'mark_as_read', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
Replace with:
'markread' => array('text' => 'mark_as_read', 'image' => 'markread.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_mark_read'] . '\');"', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),

And now, a nice confirmation message is shown when you click the "MARK ALL MESSAGES AS READ" button.
This is valid for SMF 2.0.x.
Title: Re: Confirmation message to "Mark as Read"
Post by: ziycon on October 01, 2013, 07:06:15 AM
PR on github...?
Title: Re: Confirmation message to "Mark as Read"
Post by: kat on October 01, 2013, 07:07:23 AM
Can we have that, here? Can we? Huh? Can we? Huh? PLEEEEEEEEZ!
Title: Re: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 07:07:48 AM
Some day I will have to register and learn how to use it :P
Title: Re: Confirmation message to "Mark as Read"
Post by: Burke ♞ Knight on October 01, 2013, 07:41:59 AM
Great tip! :)
Title: Re: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 09:16:56 AM
Quote from: ziycon on October 01, 2013, 07:06:15 AM
PR on github...?
Quote from: margarett on October 01, 2013, 07:07:48 AM
Some day I will have to register and learn how to use it :P
Well, I've just registered myself on GH. Now what to do next a totally different story :P
And I still need to check if those buttons are generated the same way in 2.1. I'll give it a go. I hope :P

Quote from: K@ on October 01, 2013, 07:07:23 AM
Can we have that, here? Can we? Huh? Can we? Huh? PLEEEEEEEEZ!
To have this in 2.0 is now unlikely as this, for sure, is not a security fix :P
Title: Re: Confirmation message to "Mark as Read"
Post by: kat on October 01, 2013, 09:17:54 AM
I'd love to have that, here, on this site, coz I keep hitting that pig, by mistake. :P
Title: Re: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 09:19:20 AM
That's what happened to me, just today...

You'd have to bring it "upstairs" :P
Title: Re: Confirmation message to "Mark as Read"
Post by: ziycon on October 01, 2013, 09:21:27 AM
Throw it into a mod for the time being :)
Title: Re: Confirmation message to "Mark as Read"
Post by: kat on October 01, 2013, 09:23:20 AM
Quote from: margarett on October 01, 2013, 09:19:20 AMYou'd have to bring it "upstairs" :P

They'll say "Piss off!". :(
Title: Re: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 09:34:45 AM
Quote from: ziycon on October 01, 2013, 09:21:27 AM
Throw it into a mod for the time being :)
I'm still to learn how to do that :P

Quote from: K@ on October 01, 2013, 09:23:20 AM
They'll say "Piss off!". :(
You'll never know if you don't try :P
Title: Re: Confirmation message to "Mark as Read"
Post by: kat on October 01, 2013, 09:42:08 AM
Oh, but I do.

I kinda already asked.

Title: Re: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 11:03:59 AM
Whooo I released a MOD ;D ;D ;D
Title: Re: Confirmation message to "Mark as Read"
Post by: kat on October 01, 2013, 11:04:30 AM
Yay!
Title: Re: Confirmation message to "Mark as Read"
Post by: Burke ♞ Knight on October 01, 2013, 11:08:12 AM
/me goes to look...
Title: Re: Confirmation message to "Mark as Read"
Post by: Burke ♞ Knight on October 01, 2013, 11:10:24 AM
margarett

Check you PM's. :)
Title: Re: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 11:11:36 AM
I did. TY ;)
Title: Re: Confirmation message to "Mark as Read"
Post by: Burke ♞ Knight on October 01, 2013, 11:13:33 AM
May want to post links to the mod and support topic here and lock this?
Title: Re: Confirmation message to "Mark as Read"
Post by: margarett on October 01, 2013, 11:15:53 AM
Good idea.

Please find the MOD here:
http://custom.simplemachines.org/mods/index.php?mod=3786
Locking this.