From 30ad2effd4d8e45c53906b552bf859420d48ad27 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 5 Aug 2001 14:33:53 +0000 Subject: - various updates --- modules/blog/blog.module | 55 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'modules/blog/blog.module') diff --git a/modules/blog/blog.module b/modules/blog/blog.module index e6748a6ef..fa8f2fbf7 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -71,22 +71,36 @@ function blog_page_user($name = 0, $date = 0) { $name = check_input($name ? $name : $user->userid); $date = check_input($date ? $date : time()); - $result = db_query("SELECT n.nid, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 20"); + $result = db_query("SELECT n.nid, n.title, n.comment, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '$name' AND n.timestamp < '$date' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 20"); $output .= ""; + while ($blog = db_fetch_object($result)) { + if ($date != date("dny", $blog->timestamp)) { $date = date("dny", $blog->timestamp); - if ($user->id && $user->userid == $name) { - $links = array("nid\">". t("edit") .""); - $output .= ""; - } - else { - $output .= ""; - } + $output .= ""; + } + + if ($user->id && $user->userid == $name) { + $links[] = "nid\">". t("edit") .""; + } + + if ($user->id && user_access("post blogs")) { + $links[] = "nid\">". t("blog") .""; + } + + if ($blog->comment) { + $links[] = "nid\">". t("discuss") .""; } - $output .= ""; + + $output .= ""; + $output .= ""; + + unset($links); + } + $output .= "
". format_date($blog->timestamp, custom, "d M Y") .":". $theme->links($links) ."
". format_date($blog->timestamp, custom, "d M Y") .":
timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":
". check_output($blog->body, 1) ."
". check_output($blog->title) ."
". $theme->links($links) ."
". check_output($blog->body, 1) ."

"; $output .= "image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" />\n"; @@ -94,20 +108,34 @@ function blog_page_user($name = 0, $date = 0) { } function blog_page_last() { - global $theme; + global $theme, $user; - $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.userid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 20"); + $result = db_query("SELECT n.author, n.nid, n.title, n.comment, n.timestamp, b.body, u.userid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 20"); $output .= ""; + while ($blog = db_fetch_object($result)) { + $links[] = "userid) ."\">". strtr(t("%a's blog"), array("%a" => $blog->userid)) .""; - $links[] = "nid\">". t("blog") .""; - $links[] = "nid\">". t("discuss") .""; + + if ($blog->author == $user->id) { + $links[] = "nid\">". t("edit") .""; + } + + if ($user->id && user_access("post blogs")) { + $links[] = "nid\">". t("blog") .""; + } + + if ($blog->comment) { + $links[] = "nid\">". t("discuss") .""; + } $output .= ""; $output .= ""; + unset($links); } + $output .= "
". check_output($blog->title) ."". $theme->links($links) ."
". check_output($blog->body, 1) ."

"; $output .= "image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" />\n"; @@ -215,7 +243,6 @@ function blog_edit_history($nid) { function blog_page() { global $theme, $op, $name, $date; - if (user_access("access blogs")) { switch ($op) { case "feed": -- cgit v1.2.3