summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-01-21 19:41:11 +0000
committerDries Buytaert <dries@buytaert.net>2001-01-21 19:41:11 +0000
commitea9788853352750389307d94999ebe58991929b1 (patch)
tree50634b44ac6bf11dd346d9b6f034e415bea4b8c2 /includes
parent7cc7b405e323f36037dab894b69d6fd739915d5d (diff)
downloadbrdo-ea9788853352750389307d94999ebe58991929b1.tar.gz
brdo-ea9788853352750389307d94999ebe58991929b1.tar.bz2
I know, I know, it is getting nasty lately but I have another large commit after nothing but code.
This time I redid the "category"-stuff. Categories - from now on called sections - are now maintained from the admin pages, can have their own post, dump and timout thresholds as discussed earlier (some weeks ago). By tomorrow evening users will be able to enable or disable section as well - i.e. to customize the content of drop.org.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc2
-rw-r--r--includes/function.inc12
-rw-r--r--includes/hostname.conf16
-rw-r--r--includes/section.inc25
-rw-r--r--includes/story.inc4
-rw-r--r--includes/submission.inc21
-rw-r--r--includes/theme.inc16
-rw-r--r--includes/user.inc4
8 files changed, 54 insertions, 46 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 22338070f..49822a83e 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -10,6 +10,6 @@ include_once "includes/user.inc";
session_start();
-$theme = load_theme();
+$theme = theme_load();
?> \ No newline at end of file
diff --git a/includes/function.inc b/includes/function.inc
index e564b3149..98a9da53e 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -1,17 +1,5 @@
<?
-function load_theme() {
- global $user, $themes;
-
- if ($user->theme && file_exists($themes[$user->theme][0])) {
- include_once $themes[$user->theme][0];
- }
- else {
- include_once $themes[key($themes)][0];
- }
- return new Theme();
-}
-
function check_textfield($message) {
global $allowed_html;
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)), $allowed_html);
diff --git a/includes/hostname.conf b/includes/hostname.conf
index 2b81c326b..d1e83b55f 100644
--- a/includes/hostname.conf
+++ b/includes/hostname.conf
@@ -33,22 +33,6 @@ $comment_votes = array("none" => "none",
"+4" => "+ 4",
"+5" => "+ 5");
-#
-# Categories:
-#
-$categories = array("Announcements",
- "Arts & Humanities",
- "Business & Economy",
- "Coding & Webdesign",
- "Computers & Internet",
- "Drop.org",
- "Entertainment",
- "News & Media",
- "Politics & Freedom",
- "Reviews",
- "Science",
- "Society & Culture");
-
#
# Allowed HTML tags:
#
diff --git a/includes/section.inc b/includes/section.inc
new file mode 100644
index 000000000..0bebaf026
--- /dev/null
+++ b/includes/section.inc
@@ -0,0 +1,25 @@
+<?
+
+function section_get() {
+ $array = array();
+ $result = db_query("SELECT name FROM sections");
+ while ($section = db_fetch_object($result)) array_push($array, $section->name);
+ return $array;
+}
+
+function section_post_threshold($section, $threshold = 5) {
+ $result = db_query("SELECT post FROM sections WHERE name = '$section'");
+ return ($result) ? db_result($result, 0) : $threshold;
+}
+
+function section_dump_threshold($section, $threshold = - 3) {
+ $result = db_query("SELECT dump FROM sections WHERE name = '$section'");
+ return ($result) ? db_result($result, 0) : $threshold;
+}
+
+function section_timout_threshold($section, $threshold = 10) {
+ $result = db_query("SELECT timout FROM sections WHERE name = '$section'");
+ return ($result) ? db_result($result, 0) : $threshold;
+}
+
+?> \ No newline at end of file
diff --git a/includes/story.inc b/includes/story.inc
index d0c40ab14..2ec39ca16 100644
--- a/includes/story.inc
+++ b/includes/story.inc
@@ -1,12 +1,12 @@
<?
class Story {
- function Story($userid, $subject, $abstract, $article, $category, $timestamp) {
+ function Story($userid, $subject, $abstract, $article, $section, $timestamp) {
$this->userid = $userid;
$this->subject = $subject;
$this->abstract = $abstract;
$this->article = $article;
- $this->category = $category;
+ $this->section = $section;
$this->timestamp = $timestamp;
}
}
diff --git a/includes/submission.inc b/includes/submission.inc
index 628aeae75..609dc06d9 100644
--- a/includes/submission.inc
+++ b/includes/submission.inc
@@ -11,7 +11,7 @@ function submission_score($id) {
}
function submission_vote($id, $vote, $comment) {
- global $submission_post_threshold, $submission_dump_threshold, $user;
+ global $user;
if (!user_getHistory($user->history, "s$id")) {
// Update submission's score- and votes-field:
@@ -19,27 +19,30 @@ function submission_vote($id, $vote, $comment) {
// Update the comments (if required):
if ($comment) {
- watchdog("comment", "moderation: added comment with subject '$subject'");
-
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_setHistory($user, "s$id", $vote); // s = submission
+ user_setHistory($user, "s$id", $vote);
// Update story table (if required):
$result = db_query("SELECT * FROM stories WHERE id = $id");
if ($submission = db_fetch_object($result)) {
- if ($submission->score >= $submission_post_threshold) {
+ if ($submission->score >= section_post_threshold($submission->section)) {
db_query("UPDATE stories SET status = 2, timestamp = '". time() ."' WHERE id = $id");
- watchdog("message", "posted story `$submission->subject'");
+ watchdog("message", "posted story '$submission->subject'");
+ }
+ else if ($submission->score <= section_dump_threshold($submission->section)) {
+ db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id");
+ watchdog("message", "dumped story '$submission->subject'");
}
- if ($submission->score <= $submission_dump_threshold) {
+ else if ($submission->votes >= section_timout_threshold($submission->section)) {
db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id");
- watchdog("message", "dumped story `$submission->subject'");
+ watchdog("message", "expired story '$submission->subject'");
}
}
}
}
-?>
+?> \ No newline at end of file
diff --git a/includes/theme.inc b/includes/theme.inc
index 166470e10..bc09e1588 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1,5 +1,17 @@
<?
+function theme_load() {
+ global $user, $themes;
+
+ if ($user->theme && file_exists($themes[$user->theme][0])) {
+ include_once $themes[$user->theme][0];
+ }
+ else {
+ include_once $themes[key($themes)][0];
+ }
+ return new Theme();
+}
+
function theme_account($theme) {
global $user, $site_name, $links, $menu;
@@ -104,8 +116,8 @@ function theme_related_links($theme, $story) {
if (!stristr($link, "mailto:")) $content .= "<LI>$link</LI>";
}
- // Stories in the same category:
- $content .= " <LI>More about <A HREF=\"search.php?category=". urlencode($story->category) ."\">$story->category</A>.</LI>";
+ // Stories in the same section:
+ $content .= " <LI>More about <A HREF=\"index.php?section=". urlencode($story->section) ."\">$story->section</A>.</LI>";
// Stories from the same author:
if ($story->userid) $content .= " <LI>Also by <A HREF=\"search.php?author=". urlencode($story->userid) ."\">$story->userid</A>.</LI>";
diff --git a/includes/user.inc b/includes/user.inc
index 4c640a7c4..6f87df47e 100644
--- a/includes/user.inc
+++ b/includes/user.inc
@@ -71,8 +71,4 @@ function user_setHistory(&$user, $field, $value) {
db_query($query);
}
-function user_clean() {
- // todo - called by cron job
-}
-
?> \ No newline at end of file