$module = array("help" => "section_help",
"block" => "section_block",
"admin" => "section_admin");
// global variables:
$_section = array("status" => array(2 => "enabled: always", 1 => "enabled: custom", 0 => "disabled"),
"timout" => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100),
"post" => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100),
"dump" => array(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -20, -25, -30));
function section_help() {
?>
When submitting new stories, every story is assigned a section or category. These sections can be maintained from the administration pages.
For moderation purpose, you can specify a post, dump and expiration thresholds for each available section according to type and urgency level a section. 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.
}
function section_block() {
$result = db_query("SELECT se.name, COUNT(st.id) AS stories FROM sections se LEFT JOIN stories st ON se.name = st.section GROUP BY se.name");
while ($_section = db_fetch_object($result)) {
$content .= "name) ."\">$_section->name (". format_data($_section->stories, 0) .")\n";
}
$block[0]["subject"] = "Sections";
$block[0]["content"] = $content;
$block[0]["info"] = "Section list";
return $block;
}
function section_add() {
global $_section;
$output .= " \n";
print $output;
}
function section_add_save($edit) {
db_query("INSERT INTO sections (name, post, dump, timout) VALUES ('". check_input($edit[name]) ."', '". check_input($edit[post]) ."', '". check_input($edit[dump]) ."', '". check_input($edit[timout]) ."')");
}
function section_delete($name) {
db_query("DELETE FROM sections WHERE name = '$name'");
}
function section_display() {
global $_section;
$status = $_section[status];
$timout = $_section[timout];
$post = $_section[post];
$dump = $_section[dump];
// Perform query:
$result = db_query("SELECT * FROM sections ORDER BY name");
// Generate output:
$output .= "\n";
print $output;
}
function section_display_save($edit) {
foreach ($edit as $key=>$value) {
db_query("UPDATE sections SET status = '". $value[status] ."', post = '". $value[post] ."', dump = '". $value[dump] ."', timout = '". $value[timout] ."' WHERE name = '$key'");
}
}
function section_admin() {
global $op, $edit, $name;
print "add new section | overview | help
\n";
switch($op) {
case "add":
section_add($edit);
break;
case "help":
section_help();
break;
case "delete":
section_delete($name);
section_display();
break;
case "Add section":
section_add_save($edit);
section_display();
break;
case "Save sections":
section_display_save($edit);
// fall through
default:
section_display();
}
}
?>