Commit adfbda3d authored by Dries's avatar Dries
Browse files

- Tidied up some stuff in account.php and theme.inc.
- Tidied up the box() API.
parent 7cbd6cf0
......@@ -72,7 +72,7 @@ function account_session_close() {
unset($user);
}
function account_user_edit() {
function account_info_edit() {
global $theme, $user;
if ($user->id) {
......@@ -100,7 +100,7 @@ function account_user_edit() {
}
}
function account_user_save($edit) {
function account_info_save($edit) {
global $user;
if ($user->id) {
$user = user_save($user, array("name" => $edit[name], "fake_email" => $edit[fake_email], "url" => $edit[url], "bio" => $edit[bio], "signature" => $edit[signature]));
......@@ -108,7 +108,7 @@ function account_user_save($edit) {
}
}
function account_site_edit() {
function account_settings_edit() {
global $cmodes, $corder, $theme, $themes, $languages, $user;
if ($user->id) {
......@@ -138,14 +138,14 @@ function account_site_edit() {
}
}
function account_site_save($edit) {
function account_settings_save($edit) {
global $user;
if ($user->id) {
$user = user_save($user, array("theme" => $edit[theme], "timezone" => $edit[timezone], "language" => $edit[language], "nodes" => $edit[nodes], "mode" => $edit[mode], "sort" => $edit[sort], "threshold" => $edit[threshold]));
}
}
function account_content_edit() {
function account_blocks_edit() {
global $theme, $user;
if ($user->id) {
......@@ -157,7 +157,7 @@ function account_content_edit() {
}
$form .= form_item(t("Blocks in side bars"), $options, t("Enable the blocks you would like to see displayed in the side bars."));
$form .= form_submit(t("Save content settings"));
$form .= form_submit(t("Save block settings"));
// display form:
$theme->header();
......@@ -172,7 +172,7 @@ function account_content_edit() {
}
}
function account_content_save($edit) {
function account_blocks_save($edit) {
global $user;
if ($user->id) {
db_query("DELETE FROM layout WHERE user = '$user->id'");
......@@ -337,7 +337,7 @@ function account_track_comments() {
$theme->footer();
}
function account_track_nodes() {
function account_track_contributions() {
global $theme, $user;
$result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM node n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '". node_status("posted") ."' AND n.author = '$user->id' GROUP BY n.nid DESC ORDER BY n.nid DESC LIMIT 25");
......@@ -352,7 +352,7 @@ function account_track_nodes() {
}
$theme->header();
$theme->box(t("Track your nodes"), ($output ? $output : t("You have not posted any nodes.")));
$theme->box(t("Track your contributions"), ($output ? $output : t("You have not posted any nodes.")));
$theme->footer();
}
......@@ -401,15 +401,15 @@ function account_track_site() {
if (variable_get("account_register", 1)) account_create_submit(check_input($userid), check_input($email));
break;
case t("Save user information"):
account_user_save($edit);
account_info_save($edit);
account_user($user->userid);
break;
case t("Save site settings"):
account_site_save($edit);
account_settings_save($edit);
header("Location: account.php?op=info");
break;
case t("Save content settings"):
account_content_save($edit);
case t("Save block settings"):
account_blocks_save($edit);
account_user($user->userid);
break;
case "confirm":
......@@ -424,36 +424,33 @@ function account_track_site() {
header("Location: account.php?op=info");
break;
case "view":
switch ($topic) {
case "info":
switch ($type) {
case "information":
account_user($user->userid);
break;
default:
account_user(check_input($name));
}
break;
case "track":
switch ($topic) {
case "site":
account_track_site();
break;
case "nodes":
account_track_nodes();
case "contributions":
account_track_contributions();
break;
default:
case "comments":
account_track_comments();
break;
default:
account_user(check_input($name));
}
break;
case "edit":
switch ($topic) {
case "content":
account_content_edit();
switch ($type) {
case "blocks":
account_blocks_edit();
break;
case "site":
account_site_edit();
case "settings":
account_settings_edit();
break;
default:
account_user_edit();
account_info_edit();
}
break;
default:
......
......@@ -23,41 +23,42 @@ function theme_account($theme) {
if ($user->id) {
// Display account settings:
$content .= "<A HREF=\"account.php?op=track&topic=comments\">". t("track your comments") ."</A><BR>\n";
$content .= "<A HREF=\"account.php?op=track&topic=nodes\">". t("track your nodes") ."</A><BR>\n";
$content .= "<A HREF=\"account.php?op=track&topic=site\">". strtr(t("track %a"), array("%a" => variable_get("site_name", "drupal"))) ."</A><BR>\n";
$content .= "<P>\n";
$content .= "<A HREF=\"account.php?op=edit&topic=user\">". t("edit your information") ."</A><BR>\n";
$content .= "<A HREF=\"account.php?op=edit&topic=site\">". t("edit your preferences") ."</A><BR>\n";
$content .= "<A HREF=\"account.php?op=edit&topic=content\">". t("edit your content") ."</A><BR>\n";
$content .= "<P>\n";
$content .= "<table><tr><td nowrap=\"nowrap\">\n";
$content .= "<a href=\"account.php?op=edit&type=information\">". t("your information") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=edit&type=settings\">". t("your settings") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=edit&type=blocks\">". t("your blocks") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=view&type=comments\">". t("your comments") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=view&type=contributions\">". t("your contributions") ."</a><BR>\n";
$content .= "<a href=\"account.php?op=view&type=site\">". strtr(t("your %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a><BR>\n";
$content .= "<p />\n";
if (user_access("access administration pages")) {
$content .= "<A HREF=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</A><BR>\n";
$content .= "<P>\n";
$content .= "<a href=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</a><BR>\n";
$content .= "<p />\n";
}
foreach (module_list() as $name) {
if (module_hook($name, "link")) {
$links = module_invoke($name, "link", "menu");
foreach ($links as $link) $content .= "$link<BR>\n";
foreach ($links as $link) $content .= "$link<br />\n";
}
}
if ($link) $content .= "<P>\n";
if ($link) $content .= "<p />\n";
$content .= "<A HREF=\"account.php?op=logout\">". t("logout") ."</A><BR>\n";
$content .= "<a href=\"account.php?op=logout\">". t("logout") ."</a>\n";
$content .= "</td></tr></table>\n";
$theme->box(strtr(t("%a's configuration"), array("%a" => $user->userid)), "$content");
$theme->box($user->userid, $content);
}
else {
$output .= "<DIV ALIGN=\"center\">\n";
$output .= " <FORM ACTION=\"account.php?op=login\" METHOD=\"post\">\n";
$output .= " <B>". t("Username") .":</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"><P>\n";
$output .= " <B>". t("Password") .":</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"><BR>\n";
$output .= " <INPUT TYPE=\"submit\" VALUE=\"". t("Login") ."\"><BR>\n";
if (variable_get("account_register", 1)) $output .= " <A HREF=\"account.php\">". t("REGISTER") ."</A>\n";
$output .= " </FORM>\n";
$output .= "</DIV>\n";
$output .= "<div align=\"center\">\n";
$output .= " <form action=\"account.php?op=login\" method=\"post\">\n";
$output .= " <b>". t("Username") .":</b><br /><input name=\"userid\" size=\"15\"><p />\n";
$output .= " <b>". t("Password") .":</b><br /><input name=\"passwd\" size=\"15\" TYPE=\"password\"><br />\n";
$output .= " <input type=\"submit\" value=\"". t("Login") ."\"><br />\n";
if (variable_get("account_register", 1)) $output .= " <a href=\"account.php\">". t("REGISTER") ."</a>\n";
$output .= " </form>\n";
$output .= "</div>\n";
$theme->box(t("Login"), $output);
}
......@@ -72,7 +73,6 @@ function theme_blocks($region, $theme) {
if ($region != "left") {
if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM node WHERE nid = '$id'"));
if ($node->status == $status[queued]) theme_moderation_results($theme, $node);
// else theme_new_headlines($theme);
}
break;
case "/index.php":
......@@ -90,7 +90,7 @@ function theme_moderation_results($theme, $node) {
foreach (explode(",", $node->users) as $vote) {
if ($vote) {
$data = explode("=", $vote);
$output .= format_username($data[0]) ." voted '$data[1]'.<BR>";
$output .= format_username($data[0]) ." voted '$data[1]'.<br />";
}
}
......
......@@ -136,7 +136,7 @@ function comment($comment, $link = "") {
echo "</TABLE>";
} // close comment function
function box($subject, $content, $options = "") {
function box($subject, $content) {
?>
......
......@@ -129,7 +129,7 @@ function stripbreaks($a) { // helper function for generating the javascripted bo
} // close stripbreaks function
function box($subject, $content, $options = "") {
function box($subject, $content) {
print "<script language=\"JavaScript\"><!--\nb(\"". $this->stripbreaks(addslashes($subject)) ."\",\"". $this->stripbreaks(addslashes($content)) ."\"); // -->\n</script>\n";
} // close box function
......
......@@ -226,7 +226,7 @@ function comment($comment, $link = "") {
} // close comment function
function box($subject, $content, $options = "") {
function box($subject, $content) {
$img = (rand(0, 50) == 25) ? "boxbottomright2.gif" : "boxbottomright1.gif";
$width = rand(10, 200);
$img2 = (rand(0, 100) == 50) ? "boxtopleftside2.gif" : "boxtopleftside1.gif";
......
......@@ -115,7 +115,7 @@ function comment($comment, $link = "") {
print "<br />\n\n";
}
function box($subject, $content, $options = "") {
function box($subject, $content) {
print "\n<!-- box: \"$subject\" -->\n";
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#000000\" width=\"100%\">\n";
print " <tr>\n";
......
......@@ -192,7 +192,7 @@ function comment($comment, $link = "") {
} // close comment function
function box($subject, $content, $options = "") {
function box($subject, $content) {
switch (rand(0,7)) {
case 0: $img = "square.gif"; break;
......
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