Commit ea873bc7 authored by Dries's avatar Dries

- some improvements and code polishing
- added a few extra blocks to choose from
parent a0977089
......@@ -10,11 +10,17 @@ function account_get_user($uname) {
function account_email() {
$output .= "<P>Lost your password? Fill out your username and e-mail address, and your password will be mailed to you.</P>\n";
$output .= "<FORM ACTION=\"account.php\" METHOD=\"post\">\n";
$output .= " <TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH ALIGN=\"right\">Username:</TH><TD><INPUT NAME=\"userid\"></TD></TR>\n";
$output .= " <TR><TH ALIGN=\"right\">E-mail addres:</TH><TD><INPUT NAME=\"email\"></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" COLSPAN=\"2\"><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"E-mail password\"></TD></TR>\n";
$output .= " </TABLE>\n";
$output .= "<P>\n";
$output .= " <B>Username:</B><BR>\n";
$output .= " <INPUT NAME=\"userid\"><BR>\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= " <B>E-mail address:</B><BR>\n";
$output .= " <INPUT NAME=\"email\"><BR>\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= " <INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"E-mail password\">\n";
$output .= "</P>\n";
$output .= "</FORM>\n";
return $output;
......@@ -29,12 +35,12 @@ function account_create($user = "", $error = "") {
$output .= "<FORM ACTION=\"account.php\" METHOD=\"post\">\n";
$output .= "<P>\n";
$output .= " <B>Username:</B><BR>\n";
$output .= " <INPUT NAME=\"userid\" VALUE=\"$userid\"><BR>\n";
$output .= " <INPUT NAME=\"userid\"><BR>\n";
$output .= " <SMALL><I>Enter your desired username: only letters, numbers and common special characters are allowed.</I></SMALL><BR>\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= " <B>E-mail address:</B><BR>\n";
$output .= " <INPUT NAME=\"email\" VALUE=\"$email\"><BR>\n";
$output .= " <INPUT NAME=\"email\"><BR>\n";
$output .= " <SMALL><I>You will be sent instructions on how to validate your account via this e-mail address - please make sure it is accurate.</I></SMALL><BR>\n";
$output .= "</P>\n";
$output .= "<P>\n";
......@@ -102,7 +108,7 @@ function account_user_edit() {
### Display output/content:
$theme->header();
$theme->box("Edit your information", $output);
$theme->box("Edit user settings", $output);
$theme->footer();
}
else {
......@@ -185,7 +191,7 @@ function account_site_edit() {
$output .= "</FORM>\n";
$theme->header();
$theme->box("Edit your settings", $output);
$theme->box("Edit site settings", $output);
$theme->footer();
}
else {
......@@ -210,7 +216,7 @@ function account_site_save($edit) {
}
}
function account_block_edit() {
function account_content_edit() {
global $theme, $user;
if ($user->id) {
......@@ -218,7 +224,7 @@ function account_block_edit() {
$output .= "<B>Blocks:</B><BR>\n";
$result = db_query("SELECT * FROM blocks WHERE status = 1");
$result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module");
while ($block = db_fetch_object($result)) {
$entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '$block->name' AND user = '$user->id'"));
......@@ -232,11 +238,11 @@ function account_block_edit() {
}
$output .= "<I>You can more or less position your blocks by assigning them weights. The heavy blocks will sink down whereas the light blocks will be positioned at the top of the page.</I><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save block settings\"><BR>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save content settings\"><BR>\n";
$output .= "</FORM>\n";
$theme->header();
$theme->box("Edit your blocks", $output);
$theme->box("Edit content settings", $output);
$theme->footer();
}
else {
......@@ -247,7 +253,7 @@ function account_block_edit() {
}
}
function account_block_save($edit) {
function account_content_save($edit) {
global $user;
if ($user->id) {
db_query("DELETE FROM layout WHERE user = $user->id");
......@@ -272,7 +278,7 @@ function account_user($uname) {
### Display account information:
$theme->header();
$theme->box("View your information", $output);
$theme->box("View user settings", $output);
$theme->footer();
}
elseif ($uname && $account = account_get_user($uname)) {
......@@ -559,8 +565,8 @@ function account_track_site() {
account_site_save($edit);
header("Location: account.php?op=info");
break;
case "Save block settings":
account_block_save($edit);
case "Save content settings":
account_content_save($edit);
account_user($user->userid);
break;
case "logout":
......@@ -599,8 +605,8 @@ function account_track_site() {
case "site":
account_site_edit();
break;
case "block":
account_block_edit();
case "content":
account_content_edit();
break;
default:
header("Location: module.php?mod=diary&op=add&name=$user->userid");
......
......@@ -18,12 +18,12 @@ function submission_number() {
$content .= "<LI><A HREF=\"submission.php\">submission queue</A> (<FONT COLOR=\"red\">". submission_number() ."</FONT>)</LI>\n";
$content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=diary\">edit your diary</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">edit your information</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">edit your settings</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=block\">edit your blocks</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">edit user settings</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">edit site settings</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=content\">edit content settings</A></LI>\n";
$content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=view&topic=diary\">view your diary</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=view&topic=info\">view your information</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=view&topic=info\">view user settings</A></LI>\n";
$content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=logout\">logout</A></LI>\n";
......
<?
$module = array("admin" => "block_admin");
$module = array("page" => "block_page",
"admin" => "block_admin");
function block_page() {
global $theme;
$result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module");
$theme->header();
print "<TABLE BORDER=\"0\">\n";
while ($block = db_fetch_object($result)) {
if ($state % 3 == 0) print " <TR>\n";
print " <TD ALIGN=\"center\" VALIGN=\"top\" WIDTH=\"33%\">\n";
$blocks = module_execute($block->module, "block");
$theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]);
print " </TD>\n";
if ($state % 3 == 2) print " </TR>\n";
$state += 1;
}
print "</TABLE>\n";
$theme->footer();
}
function block_admin_save($edit) {
foreach ($edit as $key=>$value) {
......@@ -11,7 +32,7 @@ function block_admin_save($edit) {
function block_admin_display() {
global $repository;
$result = db_query("SELECT * FROM blocks");
$result = db_query("SELECT * FROM blocks ORDER BY module");
// Generate output:
$output .= "<FORM ACTION=\"admin.php?mod=block\" METHOD=\"post\">\n";
......@@ -26,7 +47,7 @@ function block_admin_display() {
$status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n";
$status .= "</SELECT>\n";
$output .= " <TR><TD>". $block->name ."</TD><TD>$module</TD><TD>$status</TD></TR>\n";
$output .= " <TR><TD>". $block->name ."</TD><TD ALIGN=\"center\">$module</TD><TD>$status</TD></TR>\n";
unset($status);
}
......
<?
$module = array("admin" => "block_admin");
$module = array("page" => "block_page",
"admin" => "block_admin");
function block_page() {
global $theme;
$result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module");
$theme->header();
print "<TABLE BORDER=\"0\">\n";
while ($block = db_fetch_object($result)) {
if ($state % 3 == 0) print " <TR>\n";
print " <TD ALIGN=\"center\" VALIGN=\"top\" WIDTH=\"33%\">\n";
$blocks = module_execute($block->module, "block");
$theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]);
print " </TD>\n";
if ($state % 3 == 2) print " </TR>\n";
$state += 1;
}
print "</TABLE>\n";
$theme->footer();
}
function block_admin_save($edit) {
foreach ($edit as $key=>$value) {
......@@ -11,7 +32,7 @@ function block_admin_save($edit) {
function block_admin_display() {
global $repository;
$result = db_query("SELECT * FROM blocks");
$result = db_query("SELECT * FROM blocks ORDER BY module");
// Generate output:
$output .= "<FORM ACTION=\"admin.php?mod=block\" METHOD=\"post\">\n";
......@@ -26,7 +47,7 @@ function block_admin_display() {
$status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n";
$status .= "</SELECT>\n";
$output .= " <TR><TD>". $block->name ."</TD><TD>$module</TD><TD>$status</TD></TR>\n";
$output .= " <TR><TD>". $block->name ."</TD><TD ALIGN=\"center\">$module</TD><TD>$status</TD></TR>\n";
unset($status);
}
......
......@@ -5,13 +5,13 @@
function calendar_block() {
global $date;
include "modules/calendar.class";
include_once "modules/calendar.class";
$calendar = new Calendar($date);
$block[0]["subject"] = "Browse archives";
$block[0]["content"] = $calendar->display();
$block[0]["info"] = "calendar";
$block[0]["info"] = "Calendar to browse archives";
return $block;
}
......
......@@ -85,7 +85,7 @@ function diary_page_add() {
$output .= "</FORM>\n";
$theme->header();
$theme->box("Online diary", $output);
$theme->box("Edit you diary", $output);
$theme->footer();
}
......@@ -114,7 +114,7 @@ function diary_page_edit($id) {
$output .= "</FORM>\n";
$theme->header();
$theme->box("Online diary", $output);
$theme->box("Edit your diary", $output);
$theme->footer();
}
......@@ -140,7 +140,7 @@ function diary_page_preview($text, $timestamp, $id = 0) {
$output .= "</FORM>\n";
$theme->header();
$theme->box("Online diary", $output);
$theme->box("Edit your diary", $output);
$theme->footer();
}
......@@ -204,7 +204,7 @@ function diary_block() {
$block[0]["subject"] = "Recent diary entries";
$block[0]["content"] = $content;
$block[0]["info"] = "recent diary entries";
$block[0]["info"] = "Recent diary entries";
$block[0]["link"] = "module.php?mod=diary";
return $block;
......
<?
$module = array("admin" => "story_admin");
$module = array("block" => "story_block",
"admin" => "story_admin");
function story_block() {
$result = db_query("select s.id, COUNT(s.id) as comments, s.subject from stories s left join comments c on s.id = c.sid WHERE s.status = 2 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[0]["subject"] = "Top 10:<BR>all stories";
$blocks[0]["content"] = $content;
$blocks[0]["info"] = "Top 10: all stories";
$result = db_query("select s.id, COUNT(s.id) as comments, s.subject from stories s left join comments c on s.id = c.sid WHERE s.status = 2 AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[1]["subject"] = "Top 10:<BR>recent stories";
$blocks[1]["content"] = $content;
$blocks[1]["info"] = "Top 10: recent stories";
return $blocks;
}
function story_edit($id) {
global $categories;
......@@ -124,4 +147,4 @@ function story_admin() {
}
}
?>
\ No newline at end of file
?>
<?
$module = array("admin" => "story_admin");
$module = array("block" => "story_block",
"admin" => "story_admin");
function story_block() {
$result = db_query("select s.id, COUNT(s.id) as comments, s.subject from stories s left join comments c on s.id = c.sid WHERE s.status = 2 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[0]["subject"] = "Top 10:<BR>all stories";
$blocks[0]["content"] = $content;
$blocks[0]["info"] = "Top 10: all stories";
$result = db_query("select s.id, COUNT(s.id) as comments, s.subject from stories s left join comments c on s.id = c.sid WHERE s.status = 2 AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[1]["subject"] = "Top 10:<BR>recent stories";
$blocks[1]["content"] = $content;
$blocks[1]["info"] = "Top 10: recent stories";
return $blocks;
}
function story_edit($id) {
global $categories;
......@@ -124,4 +147,4 @@ function story_admin() {
}
}
?>
\ No newline at end of file
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment