1
samuels
Mark all messages read hack practically finished
  • 2003/10/30 19:00

  • samuels

  • Quite a regular

  • Posts: 249

  • Since: 2003/10/30


It´s not the final version and it can be plenty of bugs. I need help to improve it.

Open modules/newbb/viewforum.php

After line 34 add:
le="color: #000000"><?php $mark_read = intval($HTTP_GET_VARS['mark_read']);



After line 50 add:
le="color: #000000"><?php //hack mark all messages read by Samuels if ($mark_read==1) { $topic_lastread = !empty($HTTP_COOKIE_VARS['newbb_topic_lastread']) ? unserialize($HTTP_COOKIE_VARS['newbb_topic_lastread']) : array(); $consulta=$xoopsDB->query("SELECT topic_id FROM " . $xoopsDB->prefix( "bb_topics" ). " WHERE forum_id=$forum order by topic_time desc"); while ($contenido=$xoopsDB->fetchArray($consulta)) { $topic_lastread[$contenido["topic_id"]] = time(); setcookie("newbb_topic_lastread", serialize($topic_lastread), time()+365*24*3600, $bbCookie['path'], $bbCookie['domain'], $bbCookie['secure']); } $url=XOOPS_URL . "/modules/newbb/viewforum.php?forum=".$forum; redirect_header($url,4,"Todos los mensajes marcados como leídos"); } //end hack mark all messages read by Samuels


After line:
include XOOPS_ROOT_PATH."/header.php";

Add:
le="color: #000000"><?php $xoopsTpl->assign('mark_read', "<a href="viewforum.php?forum=".$forum."&mark_read=1">Mark all messages read</a>");


Now you can edit your newbb_viewforum.html theme and add <{$mark_read}> to put the link for mark all post read.

I´m waiting for suggestions.

2
samuels
Re: Mark all messages read hack practically finished
  • 2003/11/11 14:40

  • samuels

  • Quite a regular

  • Posts: 249

  • Since: 2003/10/30


Thanks for nothing

3
Mithrandir
Re: Mark all messages read hack practically finished

Haven't had time to look at it yet to see if it works.

Possibly Predator, Scooby or Draven are very interested - if it works (of course, the Spanish should be replaced with a language constant, but apart from that, I have no idea, how the mark-read function works, so can't really help anymore than that)

4
samuels
Re: Mark all messages read hack practically finished
  • 2003/11/11 15:11

  • samuels

  • Quite a regular

  • Posts: 249

  • Since: 2003/10/30


I'm sorry for my last comment but i´m a noob programming and a can't find documentation. Only two or three documents at wiki section.

5
samuels
Re: Mark all messages read hack practically finished
  • 2003/11/11 15:19

  • samuels

  • Quite a regular

  • Posts: 249

  • Since: 2003/10/30


It´s not a good solution because it makes a heavy BD query.
Perhaps it´s easiest to save the actual date in the cookie and consider all posts before the date readed.

6
Anonymous
Re: Mark all messages read hack practically finished
  • 2003/11/13 22:43

  • Anonymous

  • Posts: 0

  • Since: 0


@samuels

Thanks for your work, I collect your starting point for an 'Mark all Messages as Read' expansion of the newBB Module and see what we can use.

Quote:
It´s not a good solution because it makes a heavy BD query.


That`s right, so this part has to be changed to a cookie request:

for example like this

le="color: #000000"><?php if(isset($_GET['id'])) { if(isset($_COOKIE['boardvisit'])) $boardvisit=decode_cookie($_COOKIE['boardvisit']); else $boardvisit=array(); $boardvisit[$_GET['id']]=time(); if($xoopconfig['usecookies']==1) encode_cookie("boardvisit"); } else { if($user['uid']) $db->query("UPDATE xoops_users SET lastvisit='".time()."' WHERE uid = '$xoopsuser[uid]'"); else cookie("lastvisit",time(),0); } if(isset($_GET['id'])) header("Location: index.php?boardid=$_GET[id]&sid=$session[hash]"); else header("Location: index.php?sid=$session[hash]");



7
samuels
Re: Mark all messages read hack practically finished
  • 2003/11/19 11:51

  • samuels

  • Quite a regular

  • Posts: 249

  • Since: 2003/10/30


Thank´s for the answer i'll try at home.

8
Anonymous
Re: Mark all messages read hack practically finished
  • 2003/12/31 13:25

  • Anonymous

  • Posts: 0

  • Since: 0


Hi all!
I've put the code into viewforum.php and changed the template file (/modules/newbb/templates/newbb_viewforum.html). I also deleted the cached version (/templates_c/db:newbb_viewforum.html), but at the moment the link ("Mark all messages as read") doesn't appear on the page.

I activated the debug mode for Smarty templates in Admin > System > Preferences > General Settings.

When I enter viewforum.php a popup page with the "Smarty console" appears and {mark_read} is there...:

Quote:

{$mark_read} <a href="viewforum.php?forum=16&mark_...


So, in your opinion, why does the link not appear in the viewforum.php page?

waiting hints ;)

9
Dave_L
Re: Mark all messages read hack practically finished
  • 2004/1/1 20:56

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Quote:
changed the template file (/modules/newbb/templates/newbb_viewforum.html)


Instead of changing that file, don't you need to edit the template from the admin page? (Control Panel >> System Admin >> Templates)

10
Anonymous
Re: Mark all messages read hack practically finished
  • 2004/1/2 0:06

  • Anonymous

  • Posts: 0

  • Since: 0


yes sure, if i had an "edit" or "save" or "submit" button in that page...

i only have a view button.

and when i exit that "screen", the template isn't edited. that's why i edited it by hand.