? Drupal-differentiate-content-markers.patch ? Drupal-differentiate-content-markers2.patch ? Drupal-differentiate-content-markers3.patch Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.222 diff -u -r1.222 theme.inc --- includes/theme.inc 27 Jan 2005 12:57:08 -0000 1.222 +++ includes/theme.inc 29 Jan 2005 17:34:08 -0000 @@ -12,6 +12,18 @@ * @see themeable */ + /** + * @name Content markers + * @{ + * Markers used to designate content. + */ +define('MARK_READ', 0); +define('MARK_NEW', 1); +define('MARK_UPDATED', 2); +/** + * @} End of "Content markers". + */ + /** * Hook Help - returns theme specific help and information. * @@ -695,16 +707,22 @@ } /** - * Return a themed marker, useful for marking new comments or required form - * elements. + * Return a themed marker, useful for marking new or updated + * content, and required form elements. * * @param $type - * Type of marker to return: 'new' or 'required' + * Type of marker to return: 'content' or 'required' + * @param $mark + * Number representing the marker to display + * @see MARK_NEW, MARK_UPDATED, MARK_READ * @return * A string containing the marker. */ -function theme_mark($type = 'new') { - return '*'; +function theme_mark($type = 'content', $mark = MARK_NEW) { + global $user; + if ($type == 'required' || ($user->uid && $mark != MARK_READ)) { + return '*'; + } } /** Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.329 diff -u -r1.329 comment.module --- modules/comment.module 27 Jan 2005 12:57:08 -0000 1.329 +++ modules/comment.module 29 Jan 2005 17:34:10 -0000 @@ -1017,7 +1017,7 @@ while ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $rows[] = array( - l($comment->subject, "node/$comment->nid", array('title' => htmlspecialchars(truncate_utf8($comment->comment, 128))), NULL, "comment-$comment->cid") ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme('mark', 'new') : ''), + l($comment->subject, "node/$comment->nid", array('title' => htmlspecialchars(truncate_utf8($comment->comment, 128))), NULL, "comment-$comment->cid") ." ". theme('mark', 'content', node_mark($comment->nid, $comment->timestamp)), format_name($comment), ($comment->status == 0 ? t('Published') : t('Not published')), format_date($comment->timestamp, 'small'), @@ -1428,7 +1428,7 @@ // Emit selectors: $output = ''; - if (node_is_new($comment->nid, $comment->timestamp)) { + if (node_mark($comment->nid, $comment->timestamp) != MARK_READ) { $comment->new = 1; $output .= "\n"; } @@ -1549,7 +1549,7 @@ function theme_comment($comment, $links = 0) { $output = "
\n"; - $output .= '
'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ($comment->new ? ' '. theme('mark', 'new') : '') ."
\n"; + $output .= '
'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ($comment->new ? ' '. theme('mark', 'content') : '') ."
\n"; $output .= '
'. $comment->moderation ."
\n"; $output .= '
'. t('by %a on %b', array('%a' => format_name($comment), '%b' => format_date($comment->timestamp))) ."
\n"; $output .= "
$comment->comment
\n"; @@ -1560,7 +1560,7 @@ function theme_comment_folded($comment) { $output = "
\n"; - $output .= ' '. l($comment->subject, comment_node_url() .'/'. $comment->cid, NULL, NULL, "comment-$comment->cid") . ($comment->new ? ' '. theme('mark', 'new') : '') .' '; + $output .= ' '. l($comment->subject, comment_node_url() .'/'. $comment->cid, NULL, NULL, "comment-$comment->cid") . ($comment->new ? ' '. theme('mark', 'content') : '') .' '; $output .= ''. t('by') .' '. format_name($comment) ."\n"; $output .= "
\n"; return $output; Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.452 diff -u -r1.452 node.module --- modules/node.module 27 Jan 2005 14:45:42 -0000 1.452 +++ modules/node.module 29 Jan 2005 17:34:12 -0000 @@ -125,28 +125,32 @@ } /** - * Determine whether the supplied timestamp is newer than the user's last view - * of a given node. + * Decide on the type of marker to be displayed for a given node. * * @param $nid * Node ID whose history supplies the "last viewed" timestamp. * @param $timestamp * Time which is compared against node's "last viewed" timestamp. + * @return + * One of the MARK constants. */ -function node_is_new($nid, $timestamp) { +function node_mark($nid, $timestamp) { global $user; static $cache; + if (!$user->uid) { + return MARK_READ; + } if (!isset($cache[$nid])) { - if ($user->uid) { - $cache[$nid] = node_last_viewed($nid); - } - else { - $cache[$nid] = time(); - } + $cache[$nid] = node_last_viewed($nid); } - - return ($timestamp > $cache[$nid] && $timestamp > NODE_NEW_LIMIT); + if ($cache[$nid] == 0 && $timestamp > NODE_NEW_LIMIT) { + return MARK_NEW; + } + elseif ($timestamp > $cache[$nid] && $timestamp > NODE_NEW_LIMIT) { + return MARK_UPDATED; + } + return MARK_READ; } /** @@ -807,7 +811,7 @@ $header = array(NULL, t('Title'), t('Type'), t('Author'), t('Status'), array('data' => t('Operations'), 'colspan' => '2')); while ($node = db_fetch_object($result)) { - $rows[] = array(form_checkbox(NULL, 'status]['. $node->nid, 1, 0), l($node->title, 'node/'. $node->nid) .' '. (node_is_new($node->nid, $node->changed) ? theme_mark() : ''), node_invoke($node, 'node_name'), format_name($node), ($node->status ? t('published') : t('not published')), l(t('edit'), 'node/'. $node->nid .'/edit'), l(t('delete'), 'admin/node/delete/'. $node->nid)); + $rows[] = array(form_checkbox(NULL, 'status]['. $node->nid, 1, 0), l($node->title, 'node/'. $node->nid) .' '. theme('mark', 'content', node_mark($node->nid, $node->changed)), node_invoke($node, 'node_name'), format_name($node), ($node->status ? t('published') : t('not published')), l(t('edit'), 'node/'. $node->nid .'/edit'), l(t('delete'), 'admin/node/delete/'. $node->nid)); } if ($pager = theme('pager', NULL, 50, 0)) { Index: modules/tracker.module =================================================================== RCS file: /cvs/drupal/drupal/modules/tracker.module,v retrieving revision 1.109 diff -u -r1.109 tracker.module --- modules/tracker.module 27 Jan 2005 12:57:08 -0000 1.109 +++ modules/tracker.module 29 Jan 2005 17:34:12 -0000 @@ -101,7 +101,7 @@ $rows[] = array( node_invoke($node->type, 'node_name'), - l($node->title, "node/$node->nid") .' '. (node_is_new($node->nid, $node->changed) ? theme('mark', 'new') : ''), + l($node->title, "node/$node->nid") .' '. theme('mark', 'content', node_mark($node->nid, $node->changed)), format_name($node), array('class' => 'replies', 'data' => $comments), t('%time ago', array('%time' => format_interval(time() - $node->last_post)))