Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2013-05-10 14:41:53

ciropom
Member
Registered: 2013-05-10
Posts: 13

mark as unread

This mod works better on top of the my other "keep unreaded messages" mod.
It adds a "mark as unread" link at the end of each topic that alows an user to mark an already-readed topic as unreaded in order to remember to read it later.

here's the modification

##
##
##        Mod title:  Mark discussion as unread
##
##      Mod version:  1.0.0
##  Works on FluxBB:  1.5.x
##     Release date:  2013-05-10
##          Authors:  Danilo Tomasoni (danilo.tomasoni@cryptolab.net)
##
##
##      Description:  This mod adds the link "mark as unread"
##                    at the end of each topic to alow users to remember to re-read that discussion
##
##   Affected files:  misc.php
##                    lang/<YOURLANGUAGE>/misc.php
##                    lang/<YOURLANGUAGE>/topic.php
##                    viewtopic.php
##
##       Affects DB:  No
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    FluxBB. Installation of this modification is done at
##                    your own risk. Backup your forum database and any and
##                    all applicable files before proceeding.
##
##


#
#---------[ 4. OPEN ]---------------------------------------------------------
#

misc.php


#
#---------[ 5. FIND (line: 414) ]---------------------------------------------
#

                redirect('viewforum.php?id='.$forum_id, $lang_misc['Unsubscribe redirect']);
        }
}


#
#---------[ 6. AFTER, ADD ]---------------------------------------------------
#
#
#---------[ 6. AFTER, ADD ]---------------------------------------------------
#

else if ($action == 'markunread'){

        if( isset($_GET['id']) ){
                $id = $_GET['id'];
                //get last post id
                $result = $db->query('SELECT MAX(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id) or error('Unable to fetch last post info', __FILE__, __LINE__, $db->error());
                $last_post_id = $db->result($result);
                //get last post id time of insertion
                $result = $db->query('SELECT posted FROM '.$db->prefix.'posts WHERE id='.$last_post_id) or error('Unable to fetch first new post info', __FILE__, __LINE__, $db->error());
                $last_post_time = $db->result($result);
                $new_viewing_time = $last_post_time-1;
                //update tracked topics list
                $tracked_topics = get_tracked_topics();
                $tracked_topics['topics'][$id] = $new_viewing_time;
                $tracked_topics['forums'][$id] = $new_viewing_time;
                $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$new_viewing_time.' WHERE id='.$pun_user['id']) or error('Unable to update user last visit data', __FILE__, __LINE__, $db->error());
                set_tracked_topics($tracked_topics);
        }
        redirect('index.php', $lang_misc['Mark unread redirect']);
}



#
#---------[ 7. OPEN ]---------------------------------------------------------
#
lang/<YOURLANGUAGE>/misc.php


#
#---------[ 8. FIND (line: 8) ]---------------------------------------------
#

$lang_misc = array(

#
#---------[ 9. AFTER, ADD ]----------------------------------------------------
#

'Mark unread redirect'                  =>      'Discussion marked as unread',


#
#---------[ 10. OPEN ]--------------------------------------------
#

viewtopic.php


#
#---------[ 11. FIND (line: 450) ]---------------------------------------------------
#
<li><span>»&#160;</span><strong><a href="viewtopic.php?id=<?php echo $id ?>"><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></a></strong></li>

#
#---------[ 12. AFTER, ADD ]--------------------------------------------
#

<li>[<a href="misc.php?action=markunread&amp;id=<?php echo $id ?>"><?php echo $lang_topic['Markunread'] ?></a>]</li>


#
#---------[ 13. OPEN ]---------------------------------------------------------
#

lang/<YOURLANGUAGE>/topic.php


#
#---------[ 14. FIND (line: 6) ]---------------------------------------------
#

$lang_topic = array(

#
#---------[ 15. AFTER, ADD ]----------------------------------------------------
#


'Markunread'            =>      'Mark as unread',

#
#---------[ 12. SAVE/UPLOAD ]-------------------------------------------------
#

Offline

#2 2013-05-10 16:10:27

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 6,648
Website

Re: mark as unread

Cool! Can you upload this to our modification repository so that people searching for modifications in that place can find the mod more easily?


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#3 2013-05-11 15:22:05

ciropom
Member
Registered: 2013-05-10
Posts: 13

Re: mark as unread

Ok I will do it but first I need to test it a little bit more.. smile

Offline

#4 2013-05-12 00:35:20

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: mark as unread

One would think you would have done all your testing before putting it up for people to use hmm

Offline

#5 2013-05-12 10:11:30

ciropom
Member
Registered: 2013-05-10
Posts: 13

Re: mark as unread

Squiggles wrote:

One would think you would have done all your testing before putting it up for people to use hmm

I've not putted it up for people to use..
I've posted it on fluxbb forum.
This only to know if someone have suggestion/this mod can be useful.

Of course I've tested it,
but I think before relasing it in the mods list I should monitor how it works for a litte bit more time.
It's only a precaution.
But if you want to try it your suggestions are appreciated.

Offline

#6 2013-05-13 01:29:30

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: mark as unread

Makes sense circopom, it looks like a great mod so if I get time I'll try it out on a test board and report back.

Offline

#7 2013-05-14 08:37:54

ciropom
Member
Registered: 2013-05-10
Posts: 13

Re: mark as unread

I noticed that this mod does not work properly.
This because to mark a topic as unread it resets the last visit time of the user to 1 second before the
last post insertion of that topic.
This has the drawback that if there are other topics with posts more recent that the one marked,
also these topics will appear as unreaded, even if they were already readed..

In the end I give up trying to make it work using the cookie-based storage and I re-implemented
the mod using a db-based storage of the unreaded messages.

I uploaded the mod to the list because now I'm more confident that it works properly.

http://fluxbb.org/resources/mods/mark-as-unread/

Please try it and let me know.

Offline

Board footer

Powered by FluxBB