summaryrefslogtreecommitdiff
path: root/modules/node/node.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-01-30 09:53:19 +0000
committerDries Buytaert <dries@buytaert.net>2005-01-30 09:53:19 +0000
commit59c2208ea68c4695fe0fa2122b786ac5eb748383 (patch)
tree6a1c3e3d1f1af6565ec7adde526f33e69727d61d /modules/node/node.module
parent9f77077584b592de68ca3e59f92204b715e03006 (diff)
downloadbrdo-59c2208ea68c4695fe0fa2122b786ac5eb748383.tar.gz
brdo-59c2208ea68c4695fe0fa2122b786ac5eb748383.tar.bz2
- Patch #16253 by Goba: incremental improvements to the new content markers.
Goba: it would be nice if one of the core themes would showcase this functionality. ;-)
Diffstat (limited to 'modules/node/node.module')
-rw-r--r--modules/node/node.module28
1 files changed, 16 insertions, 12 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index b21c4ea5e..63bc7b1df 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -125,28 +125,32 @@ function node_last_viewed($nid) {
}
/**
- * 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 @@ function node_admin_nodes() {
$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', 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)) {