$module = array("help" => "affiliate_help",
"block" => "affiliate_block",
"admin" => "affiliate_admin");
function affiliate_help() {
?>
This is a small module to manage related and/or affiliate sites. The module exports 2 different blocks with links to the affiliate sites.
}
function affiliate_block() {
global $site_url;
$result = db_query("SELECT * FROM affiliates ORDER BY name");
$content .= "\n";
$content .= "\n";
$content .= "\n";
$content .= "\n";
$blocks[0]["subject"] = "Affiliate sites";
$blocks[0]["content"] = $content;
$blocks[0]["info"] = "Affiliate sites (selection)";
unset($content);
$result = db_query("SELECT * FROM affiliates ORDER BY name");
while ($affiliate = db_fetch_object($result)) {
$content .= "link\">$affiliate->name\n";
}
$blocks[1]["subject"] = "Affiliate sites";
$blocks[1]["content"] = $content;
$blocks[1]["info"] = "Affiliate sites (sequential)";
return $blocks;
}
function affiliate_admin_add($name, $link, $contact) {
db_query("INSERT INTO affiliates (name, link, contact) VALUES ('". check_input($name) ."', '". check_input($link) ."', '". check_input($contact) ."')");
}
function affiliate_admin_del($id) {
db_query("DELETE FROM affiliates WHERE id = '$id'");
}
function affiliate_admin_display() {
$result = db_query("SELECT * FROM affiliates ORDER BY name");
$output .= "\n";
print $output;
}
function affiliate_admin() {
global $op, $id, $name, $link, $contact;
print "overview | help
\n";
switch($op) {
case "Add affiliate":
affiliate_admin_add($name, $link, $contact);
affiliate_admin_display();
break;
case "delete":
affiliate_admin_del($id);
affiliate_admin_display();
break;
case "help":
affiliate_help();
break;
default:
affiliate_admin_display();
}
}
?>