diff options
-rw-r--r-- | CHANGELOG | 24 | ||||
-rw-r--r-- | includes/submission.inc | 48 | ||||
-rw-r--r-- | includes/theme.inc | 7 | ||||
-rw-r--r-- | includes/watchdog.inc | 4 | ||||
-rw-r--r-- | modules/diary.module | 3 | ||||
-rw-r--r-- | submission.php | 82 | ||||
-rw-r--r-- | submit.php | 8 |
7 files changed, 21 insertions, 155 deletions
@@ -1,29 +1,23 @@ drupal 1.xx, xx/xx/2001 ----------------------- - rewrote the comment/discussion code: - * comment navigation should be less confusing now additional/alternative - display and order methods have been added. - * modules can be extended with a "comment system" as they can embed the - existing comment code without having to write duplicate code. + * comment navigation should be less confusing now additional/alternative display and order methods have been added. + * modules can be extended with a "comment system" as they can embed the existing comment code without having to write duplicate code. - added section manager: * story sections can be maintained from the administration pages. - * makes the open submission more adaptive in that you can set individual - post, dump and expiration thresholds for each section according to the - story type and urgency level: some section do not really "expire" and - stay interesting and active as time passes by, whereas news-related - stories are only considered "hot" over a short period of time. + * makes the open submission more adaptive in that you can set individual post, dump and expiration thresholds for each section according to the + story type and urgency level: some section do not really "expire" and stay interesting and active as time passes by, whereas news-related stories are only considered "hot" over a short period of time. - multiple vhosts + multiple directories: - * you can setup multiple drupal sites on top of the same physical source - tree either by using vhosts or sub-directories + * you can setup multiple drupal sites on top of the same physical source tree either by using vhosts or sub-directories - added "user ratings" similar to SlashCode's karma or Scoop's mojo. - added "search infractructure": - * improved search page and integrated search functionality in the - administration pages. + * improved search page and integrated search functionality in the administration pages. +- changed the "open submission queue" into an optional module - various updates: * improved cron-module * improved module-module - * revised documentation +- revised documentation drupal 1.00, 15/01/2001 ----------------------- -- initial release
\ No newline at end of file +- initial release diff --git a/includes/submission.inc b/includes/submission.inc deleted file mode 100644 index 78027c109..000000000 --- a/includes/submission.inc +++ /dev/null @@ -1,48 +0,0 @@ -<? - -function submission_count() { - $result = db_query("SELECT COUNT(id) FROM stories WHERE status = 1"); - return ($result) ? db_result($result, 0) : 0; -} - -function submission_score($id) { - $result = db_query("SELECT score FROM stories WHERE id = $id"); - return ($result) ? db_result($result, 0) : 0; -} - -function submission_vote($id, $vote, $comment) { - global $user; - - if (!user_get_history($user->history, "s$id")) { - // Update submission's score- and votes-field: - db_query("UPDATE stories SET score = score $vote, votes = votes + 1 WHERE id = $id"); - - // Update the comments (if required): - if ($comment) { - db_query("INSERT INTO comments (lid, link, author, subject, comment, hostname, timestamp, score) VALUES($id, 'story', $user->id, '". check_input(substr($comment, 0, 29)) ." ...', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '1')"); - watchdog("comment", "moderation: added comment with subject '$subject'"); - } - - // Update user's history record: - user_set_history("s$id", $vote); - - // Update story table (if required): - $result = db_query("SELECT * FROM stories WHERE id = $id"); - if ($submission = db_fetch_object($result)) { - if (section_post_threshold($submission->section) <= $submission->score) { - db_query("UPDATE stories SET status = 2, timestamp = '". time() ."' WHERE id = $id"); - watchdog("message", "posted story '$submission->subject'"); - } - else if (section_dump_threshold($submission->section) >= $submission->score) { - db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id"); - watchdog("message", "dumped story '$submission->subject'"); - } - else if (section_timout_threshold($submission->section) <= $submission->votes) { - db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id"); - watchdog("message", "expired story '$submission->subject'"); - } - } - } -} - -?>
\ No newline at end of file diff --git a/includes/theme.inc b/includes/theme.inc index 5791ed049..1bdff7b41 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -44,11 +44,8 @@ function theme_account($theme) { $content .= "<P>\n"; } - $content .= "<LI><A HREF=\"submission.php\">". t("submission queue") ."</A> (<FONT COLOR=\"red\">". submission_number() ."</FONT>)</LI>\n"; - $content .= "<P>\n"; - - if ($menu && ksort($menu)) { - foreach ($menu as $link=>$url) $content .= "<LI><A HREF=\"$url\">". t($link) ."</A></LI>\n"; + if ($menu) { + foreach ($menu as $link) $content .= "<LI>$link</LI>\n"; $content .= "<P>\n"; } diff --git a/includes/watchdog.inc b/includes/watchdog.inc index fd72d3512..2eb0baf2c 100644 --- a/includes/watchdog.inc +++ b/includes/watchdog.inc @@ -9,7 +9,7 @@ $watchdog = array("comment" => array("0", $submission_rate["comment"]), function watchdog($id, $message) { global $user, $watchdog, $watchdog_history; - +/* if ($watchdog[$id][1] && !user_permission($user)) { if ($log = db_fetch_object(db_query("SELECT * FROM watchdog WHERE hostname = '". getenv("REMOTE_ADDR") ."' AND level = '". $watchdog[$id][0] ."'"))) { if (time() - $log->timestamp < $watchdog[$id][1]) { @@ -19,7 +19,7 @@ function watchdog($id, $message) { } } } - +*/ // Perform query to add new watchdog entry: db_query("INSERT INTO watchdog (level, timestamp, user, message, location, hostname) VALUES ('". $watchdog[$id][0] ."', '". time() ."', '". check_input($user->id) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."')"); } diff --git a/modules/diary.module b/modules/diary.module index 381afc887..c8e93c6be 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -227,8 +227,7 @@ function diary_user($username, $section, $operation) { } function diary_menu() { - global $user; - return array("edit your diary" => "module.php?mod=diary&op=add", "view your diary" => "module.php?mod=diary&op=view"); + return array("<A HREF=\"module.php?mod=diary&op=add\">". t("edit your diary") ."</A>", "<A HREF=\"module.php?mod=diary&op=view\">". t("view your diary") ."</A>"); } function diary_block() { diff --git a/submission.php b/submission.php deleted file mode 100644 index a00f4abf6..000000000 --- a/submission.php +++ /dev/null @@ -1,82 +0,0 @@ -<? - -include_once "includes/submission.inc"; -include_once "includes/common.inc"; - -function submission_display_main() { - global $theme, $user; - - // Perform query: - $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.status = 1 ORDER BY s.id"); - - $content .= "<P>". t("Anyone who happens by, and has some news or some thoughts they'd like to share, can <A HREF=\"submit.php\">submit</A> new content for consideration. After someone has submitted something, their story is added to a queue. All registered users can access this list of pending stories, that is, stories that have been submitted, but do not yet appear on the public front page. Those registered users can vote whether they think the story should be posted or not. When enough people vote to post a story, the story is pushed over the threshold and up it goes on the public page. On the other hand, when too many people voted to drop a story, the story will get trashed."). "</P>"; - $content .= "<P>". t("Basically, this means that you, the community, are truly the editors of this site as you have the final decision on the content of this site. It's you judging the overall quality of a story. But remember, vote on whether the story is interesting, not on whether you agree with it or not. If the story goes up, you can disagree all you want, but don't vote `no' because you think the ideas expressed are wrong. Instead, vote `no' when you think the story is plain boring.") ."</P>"; - $content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n"; - $content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>". t("Subject") ."</TH><TH>". t("Section") ."</TH><TH>". t("Date") ."</TH><TH>". t("Author") ."</TH><TH>". t("Score") ."</TH></TR>\n"; - while ($submission = db_fetch_object($result)) { - if ($user->id == $submission->author || user_get_history($user->history, "s$submission->id")) $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"submission.php?op=view&id=$submission->id\">". check_output($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\">". submission_score($submission->id) ."</TD></TR>\n"; - else $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"submission.php?op=view&id=$submission->id\">". check_output($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\"><A HREF=\"submission.php?op=view&id=$submission->id\">". t("vote") ."</A></TD></TR>\n"; - } - $content .= "</TABLE>\n"; - - $theme->header(); - $theme->box(t("Open submission queue - Pending stories"), $content); - $theme->footer(); -} - -function submission_display_item($id) { - global $theme, $user, $submission_votes; - - $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id"); - $submission = db_fetch_object($result); - - if ($user->id == $submission->author || user_get_history($user->history, "s$submission->id")) { - header("Location: story.php?id=$submission->id"); - } - else { - $output .= "<FORM ACTION=\"submission.php\" METHOD=\"post\">\n"; - $output .= "<P>\n"; - $output .= " <B>Vote:</B><BR>\n"; - $output .= " <SELECT NAME=\"vote\">\n"; - foreach ($submission_votes as $key=>$value) $output .= " <OPTION VALUE=\"$value\">$key</OPTION>\n"; - $output .= " </SELECT>\n"; - $output .= "</P>\n"; - $output .= "<P>\n"; - $output .= " <B>Comment:</B><BR>\n"; - $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"7\" NAME=\"comment\"></TEXTAREA>\n"; - $output .= "</P>\n"; - $output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$submission->id\">\n"; - $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Vote\">\n"; - $output .= "</FORM>\n"; - - $theme->header(); - $theme->article($submission, "[ <A HREF=\"submission.php\"><FONT COLOR=\"$theme->link\">back</FONT></A> ]"); - $theme->box("Moderate story", $output); - $theme->footer(); - } -} - -// Security check: -if (strstr($id, " ")) { - watchdog("error", "submission: attempt to provide malicious input through URI"); - exit(); -} - -if ($user->id) { - - user_rehash(); - - switch($op) { - case "view": - submission_display_item($id); - break; - case "Vote"; - submission_vote($id, $vote, $comment); - // fall through - default: - submission_display_main(); - break; - } -} - -?> diff --git a/submit.php b/submit.php index 337aa69a2..b4fee5668 100644 --- a/submit.php +++ b/submit.php @@ -52,7 +52,7 @@ function submit_preview($subject, $abstract, $article, $section) { $output .= format_username($user->userid) ."<P>"; $output .= "<B>". t("Subject") .":</B><BR>\n"; - $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($subject) ."\"><BR><P>\n"; + $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($subject) ."\"><P>\n"; $output .= "<B>". t("Section") .":</B><BR>\n"; foreach ($sections = section_get() as $value) $options .= " <OPTION VALUE=\"$value\"". ($section == $value ? " SELECTED" : "") .">$value</OPTION>\n"; @@ -66,6 +66,8 @@ function submit_preview($subject, $abstract, $article, $section) { $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"article\">". check_textarea($article) ."</TEXTAREA><BR>\n"; $output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n"; + $duplicate = db_result(db_query("SELECT COUNT(id) FROM stories WHERE subject = '$subject'")); + if (empty($subject)) { $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview submission") ."\">\n"; @@ -74,6 +76,10 @@ function submit_preview($subject, $abstract, $article, $section) { $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview submission") ."\">\n"; } + else if ($duplicate) { + $output .= "<FONT COLOR=\"red\">". t("Warning: there is already a story with that subject.") ."</FONT><P>\n"; + $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview submission") ."\">\n"; + } else { $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview submission") ."\">\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Submit submission") ."\">\n"; |