Mark All Read functionality
pyromanfo - June 13, 2005 - 00:54
| Project: | Drupal |
| Version: | 6.x-dev |
| Component: | node system |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Description
This patch adds URLs in the form of 'node/readall' and 'node/readall/$tid' that mark all nodes, or all nodes within a given category, as read by the current user.
This also adds "mark all read" and "mark this forum read" links to the forums.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| mark_read.patch | 2.25 KB | Ignored | None | None |

#1
1) new features go into cvs, not stable
2) does not conform to codign standards
3) uses REPLACE, does not work with pgsql
I recommend making this a contrib module if possible.
#2
I am very interested in seeing this / functionality added...
I have tried to apply the patch above & it says "There was nothing but garbage found". Any updates on this?
Thank alot,
-- Marand B
#3
I didn't like the way that this was marking things as a result of a GET request, so I modified it to accept POST instead.
Added this code to template.php to create the associated UI buttons.
function phptemplate_forum_display($forums, $topics, $parents, $tid,$sortby, $forum_per_page)
{
$forum_display = theme_forum_display($forums, $topics, $parents,
$tid, $sortby, $forum_per_page);
$markbutton = form(form_hidden('tid', $tid)
. form_button($tid ? t('Mark this thread as read') :
t('Mark all as read')),
'post', url('node/markasread'));
return $forum_display .$markbutton;
}
#4
Agreed, this belongs in a contrib module (perhaps someone has written a contrib module for this by now? :P).
Closing issue.
#5
How would one add a button to the forum page to trigger the "mark as read" action from a module? forum.module does not seem to ever call module_invoke()
#6
hook_link_alter() is your friend, at least in Drupal 5.x
#7
I believe that hook_link etc are insufficient because:
1. This should be a POST button, not a link, because it modifies data
2. Links are associated with nodes and comments. The button needs to be on the main forum page and on each individual forum page
#8
#9
Any chance of anyone updating this for 5.x? IMO this is a much needed and missing feature in drupal. Without this functionality on any sizeable site the "Updated" notations become somewhat worthless. Just my opinion.
Regardless, how can we implement this in drupal 5.x?
Thanks,
-- Marandb
#10
I just looked through the module in #3 -- it looks like it should still work in 5.0 as well as it did before (i.e. mysql specific, and what appears to be a few bugs)
Also see: http://drupal.org/node/63416
#11
Is this bug a duplicate of bug 1672?
> Any chance of anyone updating this for 5.x?
I see -- the 4.6 specific code is the snippet in comment #3
You might try out these instructions: http://ofb.net/~wtanaka/drupal/markasread
#12
marking as duplicate:
http://drupal.org/node/1762
#13
This is in relation to the module markasread available at http://wtanaka.com/drupal/markasread
I unfortunately do not have a PostgreSQL drupal setup at the moment to verify this test but I believe this should work...
I modified the REPLACE INTO query to a switch test for db_type and used a slightly different query for PostgreSQL. Adding a join to the history table for the user will ensure that the INSERT will not attempt to insert duplicate rows. At least that's the theory :)
switch($GLOBALS['db_type']) {case 'mysql':
case 'mysqli':
$sql = 'REPLACE INTO {history} (uid,nid,timestamp)'
.' SELECT %d, n.nid, %d FROM {node} n'
.($tid ? ' INNER JOIN {term_node} r ON n.nid=r.nid' : '')
.' INNER JOIN {node_comment_statistics} l ON l.nid=n.nid'
.' WHERE (n.created > %d'
.' OR l.last_comment_timestamp > %d)';
$args = array($user->uid, time(), NODE_NEW_LIMIT, NODE_NEW_LIMIT);
break;
case 'pgsql':
$sql = 'INSERT INTO {history} (uid,nid,timestamp)'
.' SELECT %d, n.nid, %d FROM {node} n'
.($tid ? ' INNER JOIN {term_node} r ON n.nid=r.nid' : '')
.' INNER JOIN {node_comment_statistics} l ON l.nid=n.nid'
.' LEFT JOIN {history} h ON n.nid=h.nid AND h.uid = %d'
.' WHERE (n.created > %d'
.' OR l.last_comment_timestamp > %d)'
.' AND h.uid IS NULL';
$args = array($user->uid, time(), $user->uid, NODE_NEW_LIMIT, NODE_NEW_LIMIT);
break;
}
#14
+1 for this, although...
We have a 'my unread' view on site. Kindof like the regular 'tracker' page but with only nodes/comments unseen by user listed.
It would therfore be better, IMHO, to have this module:
- Ask for simple confirmation
- Show a 'all posts marked as read' info message rather than as a page
- Redirect back to the previous page after this
This shouldn't be too hard. We're on 5.x so if I get round to sorting this will post the module here.
#15
The given SQL wasn't working here so I tweaked it as follows:
$sql = <<<EOFREPLACE INTO {history} (uid, nid, timestamp)
SELECT '%d', n.nid, UNIX_TIMESTAMP()
FROM {node} n
LEFT JOIN {history} h ON (h.nid = n.nid AND h.uid = %d)
LEFT JOIN {node_comment_statistics} ncs ON (ncs.nid = n.nid)
WHERE (h.timestamp is null or h.timestamp < n.changed)
OR (h.timestamp IS NOT NULL AND ncs.last_comment_timestamp > h.timestamp)
EOF;
db_query($sql, $user->uid, $user->uid);
As for the request for a confirmation & redirect. Well - the redirect was easily handled with a change to the
drupal_gotofunction and the confirmation by adrupal_set_messagecall.I added a link to the footer of our 'my unseen' view which asks for confirmation before marking nodes. Of course the input format has to be 'php' for this to work:
<?php
$links['mark_all'] = array(
'title' => t('Mark all content as read'),
'href' => 'node/markasread',
'attributes' => array('onclick' => "return confirm('". t('Are you sure you want to mark all content as read?') ."')")
);
print theme('links', $links);
?>