Commit 0cce47f1 authored by Dries's avatar Dries

- fixed small glitch in node_del()

- fixed small glitch in comment_del()

- changed the API of the form() function.  The first parameter, the
  "action"-attribute in the <form>-tag has been made optional.  By
  default, it will be set to "$REQUEST_URI".

  Why? Because in 98% of the cases we would do:

    global $REQUEST_URI;
    $form = form($REQUEST_URI, $form_content);

  while we can do:

    $form = form($form_content);

  now.

  Update your modules (and sorry for the inconvenience)!
parent 17c92125
......@@ -48,7 +48,7 @@ function comment_settings($mode, $order, $threshold) {
}
function comment_form($edit) {
global $REQUEST_URI, $user;
global $user;
// name field:
$form .= form_item(t("Your name"), format_name($user));
......@@ -71,7 +71,7 @@ function comment_form($edit) {
$form .= form_submit(t("Post comment"));
}
return form($REQUEST_URI, $form);
return form($form);
}
function comment_reply($pid, $id) {
......@@ -95,7 +95,7 @@ function comment_reply($pid, $id) {
}
function comment_preview($edit) {
global $REQUEST_URI, $theme, $user;
global $theme, $user;
// Preview comment:
comment_view(new Comment($user->uid, $user->name, check_preview($edit[subject]), check_preview($edit[comment]), time(), check_preview($user->homepage), 0, 0, 0, 0), t("reply to this comment"));
......@@ -301,7 +301,6 @@ function comment_render($lid, $cid) {
}
print "<form method=\"post\" action=\"$REQUEST_URI\">\n";
// print " <INPUT TYPE=\"hidden\" NAME=\"id\" value=\"$lid\">\n";
/*
** Render control panel:
......
......@@ -244,8 +244,10 @@ function format_tag($link, $text) {
return "'<a href=\"node.php?title='. urlencode('$link') .'\">'. ('$text' ? '$text' : '$link') .'</a>'";
}
function form($action, $form, $method = "post", $options = 0) {
return "<form action=\"$action\" method=\"$method\"". ($options ? " $options" : "") .">\n$form</form>\n";
function form($form, $method = "post", $action = 0, $options = 0) {
global $REQUEST_URI;
return "<form action=\"". ($action ? $action : $REQUEST_URI) ."\" method=\"$method\"". ($options ? " $options" : "") .">\n$form</form>\n";
}
function form_item($title, $value, $description = 0) {
......
......@@ -53,6 +53,7 @@ function node_del($conditions) {
db_query("DELETE FROM node WHERE nid = '$node->nid'");
db_query("DELETE FROM $node->type WHERE lid = '$node->lid' AND nid = '$node->nid'");
db_query("DELETE FROM comments WHERE lid = '$node->nid'");
db_query("DELETE FROM moderate WHERE nid = '$node->nid'");
watchdog("special", "node: deleted '$node->title'");
return $node;
}
......@@ -199,7 +200,7 @@ function visit(site) {
}
$output .= "<FORM METHOD=\"get\" ACTION=\"\">\n";
foreach ($choices as $key => $value) $options .= "<OPTION VALUE=\"$key\"". (strstr($REQUEST_URI,"/$key") ? " SELECTED" : "") .">". check_form($value) ."</OPTION>\n";
foreach ($choices as $key => $value) $options .= "<OPTION VALUE=\"$key\"". (strstr($REQUEST_URI, "/$key") ? " SELECTED" : "") .">". check_form($value) ."</OPTION>\n";
$output .= " <SELECT NAME=\"op\" ONCHANGE=\"visit(this.options[this.selectedIndex].value)\">$options</SELECT>\n";
$output .= "</FORM>\n";
......
<?php
function search_form($keys) {
global $REQUEST_URI;
$output .= "<form action=\"$REQUEST_URI\" method=\"POST\">\n";
$output .= " <input size=\"50\" value=\"". check_form($keys) ."\" name=\"keys\">";
$output .= " <input type=\"submit\" value=\"". t("Search") ."\">\n";
$output .= "</form>\n";
return $output;
return form($output);
}
function search_data($keys, $type) {
......
......@@ -232,7 +232,6 @@ function import_save_item($edit) {
}
function import_form_bundle($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Title", "title", $edit[title], 50, 64, "The name of the bundle.");
$form .= form_textfield("Attributes", "attributes", $edit[attributes], 50, 128, "A comma-seperated list of keywords describing the bundle.");
......@@ -244,7 +243,7 @@ function import_form_bundle($edit = array()) {
$form .= form_hidden("bid", $edit[bid]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function import_save_bundle($edit) {
......@@ -262,7 +261,6 @@ function import_save_bundle($edit) {
}
function import_form_feed($edit = array()) {
global $REQUEST_URI;
$period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200));
......@@ -282,7 +280,7 @@ function import_form_feed($edit = array()) {
$form .= form_hidden("fid", $edit[fid]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function import_save_feed($edit) {
......@@ -339,16 +337,14 @@ function import_view() {
}
function import_fd_form() {
global $REQUEST_URI;
$form .= form_textfield("Feed directory file", "url", "http://", 64, 128, "The fully-qualified URL of the feed directory file.");
$form .= form_submit("Collect feeds");
return form($REQUEST_URI, $form);
return form($form);
}
function import_fd_collect($edit) {
global $REQUEST_URI;
set_time_limit(180);
......@@ -365,8 +361,6 @@ function import_fd_collect($edit) {
$items = explode("</channel>", $data);
$output .= "<form action=\"$REQUEST_URI\" method=\"POST\">\n";
foreach ($items as $item) {
unset ($link, $title);
......@@ -385,9 +379,8 @@ function import_fd_collect($edit) {
}
$output .= "<input type=\"submit\" name=\"op\" value=\"Import feeds\" />\n";
$output .= "</form>";
return $output;
return form($output);
}
else {
print status("failed to open '$edit[url]': $errstr.");
......@@ -403,11 +396,9 @@ function import_fd_import($edit) {
}
function import_tag() {
global $REQUEST_URI;
$result = db_query("SELECT i.*, f.title AS feed FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT 50");
$output .= "<form action=\"$REQUEST_URI\" method=\"post\">\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><th>time</th><th>feed</th><th>item</th></tr>\n";
while ($item = db_fetch_object($result)) {
......@@ -415,9 +406,8 @@ function import_tag() {
}
$output .= "</table>\n";
$output .= "<input type=\"submit\" name=\"op\" value=\"Save attributes\" />\n";
$output .= "</form>\n";
return $output;
return form($output);
}
function import_admin() {
......
......@@ -232,7 +232,6 @@ function import_save_item($edit) {
}
function import_form_bundle($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Title", "title", $edit[title], 50, 64, "The name of the bundle.");
$form .= form_textfield("Attributes", "attributes", $edit[attributes], 50, 128, "A comma-seperated list of keywords describing the bundle.");
......@@ -244,7 +243,7 @@ function import_form_bundle($edit = array()) {
$form .= form_hidden("bid", $edit[bid]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function import_save_bundle($edit) {
......@@ -262,7 +261,6 @@ function import_save_bundle($edit) {
}
function import_form_feed($edit = array()) {
global $REQUEST_URI;
$period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200));
......@@ -282,7 +280,7 @@ function import_form_feed($edit = array()) {
$form .= form_hidden("fid", $edit[fid]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function import_save_feed($edit) {
......@@ -339,16 +337,14 @@ function import_view() {
}
function import_fd_form() {
global $REQUEST_URI;
$form .= form_textfield("Feed directory file", "url", "http://", 64, 128, "The fully-qualified URL of the feed directory file.");
$form .= form_submit("Collect feeds");
return form($REQUEST_URI, $form);
return form($form);
}
function import_fd_collect($edit) {
global $REQUEST_URI;
set_time_limit(180);
......@@ -365,8 +361,6 @@ function import_fd_collect($edit) {
$items = explode("</channel>", $data);
$output .= "<form action=\"$REQUEST_URI\" method=\"POST\">\n";
foreach ($items as $item) {
unset ($link, $title);
......@@ -385,9 +379,8 @@ function import_fd_collect($edit) {
}
$output .= "<input type=\"submit\" name=\"op\" value=\"Import feeds\" />\n";
$output .= "</form>";
return $output;
return form($output);
}
else {
print status("failed to open '$edit[url]': $errstr.");
......@@ -403,11 +396,9 @@ function import_fd_import($edit) {
}
function import_tag() {
global $REQUEST_URI;
$result = db_query("SELECT i.*, f.title AS feed FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT 50");
$output .= "<form action=\"$REQUEST_URI\" method=\"post\">\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><th>time</th><th>feed</th><th>item</th></tr>\n";
while ($item = db_fetch_object($result)) {
......@@ -415,9 +406,8 @@ function import_tag() {
}
$output .= "</table>\n";
$output .= "<input type=\"submit\" name=\"op\" value=\"Save attributes\" />\n";
$output .= "</form>\n";
return $output;
return form($output);
}
function import_admin() {
......
......@@ -187,7 +187,7 @@ function blog_view($node, $main = 0) {
}
function blog_form($edit = array()) {
global $REQUEST_URI, $id, $mod, $type, $user, $theme;
global $id, $mod, $type, $user, $theme;
if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
if ($mod == "node" || $edit[type] == "blog") {
......@@ -233,7 +233,7 @@ function blog_form($edit = array()) {
$form .= form_submit(t("Submit"));
}
return form($REQUEST_URI, $form);
return form($form);
}
else {
return message_access();
......
......@@ -187,7 +187,7 @@ function blog_view($node, $main = 0) {
}
function blog_form($edit = array()) {
global $REQUEST_URI, $id, $mod, $type, $user, $theme;
global $id, $mod, $type, $user, $theme;
if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
if ($mod == "node" || $edit[type] == "blog") {
......@@ -233,7 +233,7 @@ function blog_form($edit = array()) {
$form .= form_submit(t("Submit"));
}
return form($REQUEST_URI, $form);
return form($form);
}
else {
return message_access();
......
......@@ -122,7 +122,7 @@ function book_toc($parent = "", $indent = "", $toc = array()) {
}
function book_form($edit = array()) {
global $REQUEST_URI, $user;
global $user;
if ($edit[title]) {
$form .= book_view(new Book(node_preview($edit)));
......@@ -161,7 +161,7 @@ function book_form($edit = array()) {
$form .= form_submit(t("Submit"));
}
return form($REQUEST_URI, $form);
return form($form);
}
function book_save($edit) {
......
......@@ -122,7 +122,7 @@ function book_toc($parent = "", $indent = "", $toc = array()) {
}
function book_form($edit = array()) {
global $REQUEST_URI, $user;
global $user;
if ($edit[title]) {
$form .= book_view(new Book(node_preview($edit)));
......@@ -161,7 +161,7 @@ function book_form($edit = array()) {
$form .= form_submit(t("Submit"));
}
return form($REQUEST_URI, $form);
return form($form);
}
function book_save($edit) {
......
......@@ -85,7 +85,6 @@ function box_save($edit) {
}
function box_form($edit = array()) {
global $REQUEST_URI;
$type = array(0 => "ASCII", 1 => "HTML", 2 => "PHP");
......@@ -101,7 +100,7 @@ function box_form($edit = array()) {
$form .= form_submit("Submit");
return form($REQUEST_URI, $form);
return form($form);
}
......
......@@ -68,7 +68,6 @@ function cloud_update($site) {
function cloud_form($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Site name", "name", $edit["name"], 50, 128, "The name of the website you want to monitor for updates.");
$form .= form_textfield("Site URL", "link", $edit["link"], 50, 255, "The URL of the website you want to monitor for updates.");
......@@ -81,7 +80,7 @@ function cloud_form($edit = array()) {
$form .= form_hidden("sid", $edit["sid"]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function cloud_get_site($sid) {
......
......@@ -22,7 +22,6 @@ function comment_link($type) {
}
function comment_edit($id) {
global $REQUEST_URI;
$result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$id'");
$comment = db_fetch_object($result);
......@@ -32,7 +31,7 @@ function comment_edit($id) {
$form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10);
$form .= form_submit(t("Submit"));
return form($REQUEST_URI, $form);
return form($form);
}
function comment_save($id, $edit) {
......@@ -55,6 +54,7 @@ function comment_overview() {
function comment_delete($id) {
db_query("DELETE FROM comments WHERE cid = '$id'");
db_query("DELETE FROM moderate WHERE cid = '$id'");
watchdog("special", "comment: deleted '$id'");
}
......
......@@ -22,7 +22,6 @@ function comment_link($type) {
}
function comment_edit($id) {
global $REQUEST_URI;
$result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$id'");
$comment = db_fetch_object($result);
......@@ -32,7 +31,7 @@ function comment_edit($id) {
$form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10);
$form .= form_submit(t("Submit"));
return form($REQUEST_URI, $form);
return form($form);
}
function comment_save($id, $edit) {
......@@ -55,6 +54,7 @@ function comment_overview() {
function comment_delete($id) {
db_query("DELETE FROM comments WHERE cid = '$id'");
db_query("DELETE FROM moderate WHERE cid = '$id'");
watchdog("special", "comment: deleted '$id'");
}
......
......@@ -19,14 +19,13 @@ function forum_view($node) {
}
function forum_form($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= form_textarea("Body", "body", $edit[body], 70, 10);
$form .= form_hidden("nid", $edit[nid]);
$form .= form_submit(t("Submit"));
return form($REQUEST_URI, $form);
return form($form);
}
function forum_save($edit) {
......
......@@ -19,14 +19,13 @@ function forum_view($node) {
}
function forum_form($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= form_textarea("Body", "body", $edit[body], 70, 10);
$form .= form_hidden("nid", $edit[nid]);
$form .= form_submit(t("Submit"));
return form($REQUEST_URI, $form);
return form($form);
}
function forum_save($edit) {
......
......@@ -232,7 +232,6 @@ function import_save_item($edit) {
}
function import_form_bundle($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Title", "title", $edit[title], 50, 64, "The name of the bundle.");
$form .= form_textfield("Attributes", "attributes", $edit[attributes], 50, 128, "A comma-seperated list of keywords describing the bundle.");
......@@ -244,7 +243,7 @@ function import_form_bundle($edit = array()) {
$form .= form_hidden("bid", $edit[bid]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function import_save_bundle($edit) {
......@@ -262,7 +261,6 @@ function import_save_bundle($edit) {
}
function import_form_feed($edit = array()) {
global $REQUEST_URI;
$period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200));
......@@ -282,7 +280,7 @@ function import_form_feed($edit = array()) {
$form .= form_hidden("fid", $edit[fid]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function import_save_feed($edit) {
......@@ -339,16 +337,14 @@ function import_view() {
}
function import_fd_form() {
global $REQUEST_URI;
$form .= form_textfield("Feed directory file", "url", "http://", 64, 128, "The fully-qualified URL of the feed directory file.");
$form .= form_submit("Collect feeds");
return form($REQUEST_URI, $form);
return form($form);
}
function import_fd_collect($edit) {
global $REQUEST_URI;
set_time_limit(180);
......@@ -365,8 +361,6 @@ function import_fd_collect($edit) {
$items = explode("</channel>", $data);
$output .= "<form action=\"$REQUEST_URI\" method=\"POST\">\n";
foreach ($items as $item) {
unset ($link, $title);
......@@ -385,9 +379,8 @@ function import_fd_collect($edit) {
}
$output .= "<input type=\"submit\" name=\"op\" value=\"Import feeds\" />\n";
$output .= "</form>";
return $output;
return form($output);
}
else {
print status("failed to open '$edit[url]': $errstr.");
......@@ -403,11 +396,9 @@ function import_fd_import($edit) {
}
function import_tag() {
global $REQUEST_URI;
$result = db_query("SELECT i.*, f.title AS feed FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT 50");
$output .= "<form action=\"$REQUEST_URI\" method=\"post\">\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><th>time</th><th>feed</th><th>item</th></tr>\n";
while ($item = db_fetch_object($result)) {
......@@ -415,9 +406,8 @@ function import_tag() {
}
$output .= "</table>\n";
$output .= "<input type=\"submit\" name=\"op\" value=\"Save attributes\" />\n";
$output .= "</form>\n";
return $output;
return form($output);
}
function import_admin() {
......
......@@ -61,7 +61,7 @@ function locale_save($id, $edit) {
}
function locale_edit($id) {
global $languages, $REQUEST_URI;
global $languages;
$result = db_query("SELECT * FROM locales WHERE id = '$id'");
if ($translation = db_fetch_object($result)) {
$form .= form_item(t("Original text"), "<PRE>". wordwrap(check_output($translation->string)) ."</PRE>");
......@@ -69,7 +69,7 @@ function locale_edit($id) {
$form .= form_hidden("id", $id);
$form .= form_submit("Save translations");
return form($REQUEST_URI, $form);
return form($form);
}
}
......@@ -138,7 +138,7 @@ function locale_untranslated($language) {
}
function locale_seek() {
global $edit, $languages, $REQUEST_URI, $op, $locale_settings;
global $edit, $languages, $op, $locale_settings;
if ($edit[id] && session_is_registered("locale_settings")) {
$edit = $locale_settings;
......@@ -184,7 +184,7 @@ function locale_seek() {
$form .= form_textfield("String", "string", $edit[string], 30, 30, "Leave blank to show all strings. This is treated as a regular expression.");
$form .= form_submit("Search");
$output .= form($REQUEST_URI, $form);
$output .= form($form);
return $output;
}
......
......@@ -61,7 +61,7 @@ function locale_save($id, $edit) {
}
function locale_edit($id) {
global $languages, $REQUEST_URI;
global $languages;
$result = db_query("SELECT * FROM locales WHERE id = '$id'");
if ($translation = db_fetch_object($result)) {
$form .= form_item(t("Original text"), "<PRE>". wordwrap(check_output($translation->string)) ."</PRE>");
......@@ -69,7 +69,7 @@ function locale_edit($id) {
$form .= form_hidden("id", $id);
$form .= form_submit("Save translations");
return form($REQUEST_URI, $form);
return form($form);
}
}
......@@ -138,7 +138,7 @@ function locale_untranslated($language) {
}
function locale_seek() {
global $edit, $languages, $REQUEST_URI, $op, $locale_settings;
global $edit, $languages, $op, $locale_settings;
if ($edit[id] && session_is_registered("locale_settings")) {
$edit = $locale_settings;
......@@ -184,7 +184,7 @@ function locale_seek() {
$form .= form_textfield("String", "string", $edit[string], 30, 30, "Leave blank to show all strings. This is treated as a regular expression.");
$form .= form_submit("Search");
$output .= form($REQUEST_URI, $form);
$output .= form($form);
return $output;
}
......
......@@ -60,7 +60,6 @@ function meta_get_tag($tid) {
}
function meta_form_collection($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Collection name", "name", $edit[name], 50, 64, "Required. The name for this group or collection of meta-tags. Example: 'Software'.");
$form .= form_textfield("Types", "types", $edit[types], 50, 64, "Required. A comma-seperated list of node types you want to associate this collection with. Example: 'story, book'.");
......@@ -71,11 +70,10 @@ function meta_form_collection($edit = array()) {
$form .= form_hidden("cid", $edit[cid]);
}
return form($REQUEST_URI, $form);
return form($form);
}
function meta_form_tag($edit = array()) {