Skip to content
Snippets Groups Projects
Commit 717a9d9e authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Some visual improvements.  More suggestions welcome.
parent b87c83b3
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -6,7 +6,7 @@ function tracker_help() { ...@@ -6,7 +6,7 @@ function tracker_help() {
return $output; return $output;
} }
function tracker_system($field){ function tracker_system($field) {
$system["description"] = t("Enables tracking of recent posts for users."); $system["description"] = t("Enables tracking of recent posts for users.");
return $system[$field]; return $system[$field];
} }
...@@ -23,35 +23,45 @@ function tracker_link($type) { ...@@ -23,35 +23,45 @@ function tracker_link($type) {
function tracker_posts($id = 0) { function tracker_posts($id = 0) {
if ($id) { if ($id) {
$sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, c.timestamp) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.uid = '". check_query($id) ."' AND n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.nid, u.name ORDER BY last_activity DESC", 0, 15); $sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, MAX(GREATEST(n.changed, c.timestamp)) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.uid = '". check_query($id) ."' AND n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.uid, u.name ORDER BY last_activity DESC", 0, 15);
} }
else { else {
$sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, c.timestamp) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.nid, u.name ORDER BY last_activity DESC", 0, 15); $sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, MAX(GREATEST(n.changed, c.timestamp)) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.uid, u.name ORDER BY last_activity DESC", 0, 15);
} }
$header = array(t("Type"), t("Title"), t("Author"));
while ($node = db_fetch_object($sresult)) { while ($node = db_fetch_object($sresult)) {
if ($id) { if ($id) {
$cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.timestamp > %d AND c.uid = '%d' AND c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", time() - 259200, $id, $node->nid); $cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.uid = '%d' AND c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", $id, $node->nid);
} }
else { else {
$cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.timestamp > %d AND c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", time() - 259200, $node->nid); $cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", $node->nid);
} }
$type = ucfirst(module_invoke($node->type, "node", "name"));
$title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : ""); $title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$type = module_invoke($node->type, "node", "name"); $author = format_name($node);
$comments = array(); $comments = array();
while ($comment = db_fetch_object($cresult)) { while ($comment = db_fetch_object($cresult)) {
$comments[] = "<li>". l($comment->subject, "node/view/$node->nid#$comment->cid") ." ". t("by") ." ". format_name($comment) ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme("theme_mark") : "") ."</li>\n"; $comments[] = "<li>". l($comment->subject, "node/view/$node->nid#$comment->cid") ." ". t("by") ." ". format_name($comment) ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme("theme_mark") : "") ."</li>\n";
} }
$output .= "<p>". t("%type %title by %author", array("%type" => ucfirst($type), "%title" => $title, "%author" => format_name($node))) ."</p>";
if ($comments) { if ($comments) {
$output .= "<ul>". implode("\n", $comments) ."</ul>"; $comments = "<ul>". implode("\n", $comments) ."</ul>";
}
else {
$comments = "";
} }
$rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title . $comments, "class" => "content"), array("data" => $author, "class" => "author"));
} }
$output = "<div id=\"tracker\">";
$output .= table($header, $rows);
$output .= "</div>";
return $output; return $output;
} }
......
...@@ -6,7 +6,7 @@ function tracker_help() { ...@@ -6,7 +6,7 @@ function tracker_help() {
return $output; return $output;
} }
function tracker_system($field){ function tracker_system($field) {
$system["description"] = t("Enables tracking of recent posts for users."); $system["description"] = t("Enables tracking of recent posts for users.");
return $system[$field]; return $system[$field];
} }
...@@ -23,35 +23,45 @@ function tracker_link($type) { ...@@ -23,35 +23,45 @@ function tracker_link($type) {
function tracker_posts($id = 0) { function tracker_posts($id = 0) {
if ($id) { if ($id) {
$sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, c.timestamp) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.uid = '". check_query($id) ."' AND n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.nid, u.name ORDER BY last_activity DESC", 0, 15); $sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, MAX(GREATEST(n.changed, c.timestamp)) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.uid = '". check_query($id) ."' AND n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.uid, u.name ORDER BY last_activity DESC", 0, 15);
} }
else { else {
$sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, c.timestamp) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.nid, u.name ORDER BY last_activity DESC", 0, 15); $sresult = db_query_range("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, MAX(GREATEST(n.changed, c.timestamp)) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.uid, u.name ORDER BY last_activity DESC", 0, 15);
} }
$header = array(t("Type"), t("Title"), t("Author"));
while ($node = db_fetch_object($sresult)) { while ($node = db_fetch_object($sresult)) {
if ($id) { if ($id) {
$cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.timestamp > %d AND c.uid = '%d' AND c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", time() - 259200, $id, $node->nid); $cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.uid = '%d' AND c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", $id, $node->nid);
} }
else { else {
$cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.timestamp > %d AND c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", time() - 259200, $node->nid); $cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.nid = '%d' AND c.status = 0 ORDER BY cid DESC", $node->nid);
} }
$type = ucfirst(module_invoke($node->type, "node", "name"));
$title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : ""); $title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$type = module_invoke($node->type, "node", "name"); $author = format_name($node);
$comments = array(); $comments = array();
while ($comment = db_fetch_object($cresult)) { while ($comment = db_fetch_object($cresult)) {
$comments[] = "<li>". l($comment->subject, "node/view/$node->nid#$comment->cid") ." ". t("by") ." ". format_name($comment) ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme("theme_mark") : "") ."</li>\n"; $comments[] = "<li>". l($comment->subject, "node/view/$node->nid#$comment->cid") ." ". t("by") ." ". format_name($comment) ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme("theme_mark") : "") ."</li>\n";
} }
$output .= "<p>". t("%type %title by %author", array("%type" => ucfirst($type), "%title" => $title, "%author" => format_name($node))) ."</p>";
if ($comments) { if ($comments) {
$output .= "<ul>". implode("\n", $comments) ."</ul>"; $comments = "<ul>". implode("\n", $comments) ."</ul>";
}
else {
$comments = "";
} }
$rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title . $comments, "class" => "content"), array("data" => $author, "class" => "author"));
} }
$output = "<div id=\"tracker\">";
$output .= table($header, $rows);
$output .= "</div>";
return $output; return $output;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment