Commit 4e2c0b25 authored by Dries's avatar Dries

- Introduced a drupal_set_message() and drupal_get_message() function.

  Contributed themes and modules need to be updated:
   - modules: status() is no more; use drupal_set_message() instead.
   - themes: use drupal_get_message() to check for status messages and
     visualize them.
parent 4a5dc7e4
......@@ -27,6 +27,28 @@ function drupal_get_title() {
}
// @}
/**
@name drupal_message
Functions to get and set the message of the current page.
@{
**/
function drupal_set_message($message = NULL, $type = "status") {
static $stored_message;
if (isset($message)) {
$stored_message->message = $message;
$stored_message->type = $type;
}
return $stored_message;
}
function drupal_get_message() {
return drupal_set_message();
}
// @}
/**
@name drupal_breadcrumb
......
......@@ -208,7 +208,7 @@ fieldset {
display: block;
width: 95%;
}
node-form .standard {
.node-form .standard {
clear: both;
}
.node-form textarea {
......
<?php
// $Id$
function status($message) {
if ($message) {
return "<strong>Status:</strong> $message<hr />\n";
}
}
function admin_help($section) {
switch ($section) {
case "admin/system/modules#description":
......
......@@ -588,18 +588,18 @@ function import_admin() {
}
break;
case "remove":
$output = status(import_remove(import_get_feed(arg(5))));
drupal_set_message(import_remove(import_get_feed(arg(5))));
$output .= import_view();
break;
case "update":
$output = status(import_refresh(import_get_feed(arg(5))));
drupal_set_message(import_refresh(import_get_feed(arg(5))));
$output .= import_view();
break;
case "tag":
$output = import_tag();
break;
case t("Save attributes"):
$output = status(import_save_attributes($edit));
drupal_set_message(import_save_attributes($edit));
$output .= import_tag();
break;
case t("Delete"):
......@@ -607,10 +607,10 @@ function import_admin() {
// fall through:
case t("Submit"):
if (arg(5) == "bundle") {
$output = status(import_save_bundle($edit));
drupal_set_message(import_save_bundle($edit));
}
else {
$output = status(import_save_feed($edit));
drupal_set_message(import_save_feed($edit));
}
// fall through:
default:
......
......@@ -588,18 +588,18 @@ function import_admin() {
}
break;
case "remove":
$output = status(import_remove(import_get_feed(arg(5))));
drupal_set_message(import_remove(import_get_feed(arg(5))));
$output .= import_view();
break;
case "update":
$output = status(import_refresh(import_get_feed(arg(5))));
drupal_set_message(import_refresh(import_get_feed(arg(5))));
$output .= import_view();
break;
case "tag":
$output = import_tag();
break;
case t("Save attributes"):
$output = status(import_save_attributes($edit));
drupal_set_message(import_save_attributes($edit));
$output .= import_tag();
break;
case t("Delete"):
......@@ -607,10 +607,10 @@ function import_admin() {
// fall through:
case t("Submit"):
if (arg(5) == "bundle") {
$output = status(import_save_bundle($edit));
drupal_set_message(import_save_bundle($edit));
}
else {
$output = status(import_save_feed($edit));
drupal_set_message(import_save_feed($edit));
}
// fall through:
default:
......
......@@ -295,17 +295,17 @@ function block_admin() {
$output = block_box_form(block_box_get(arg(4)));
break;
case "delete":
$output = status(block_box_delete(arg(4)));
drupal_set_message(block_box_delete(arg(4)));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save block"):
$output = status(block_box_save($edit));
drupal_set_message(block_box_save($edit));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save blocks"):
$output = status(block_admin_save($edit));
drupal_set_message(block_admin_save($edit));
cache_clear_all();
// fall through
default:
......
......@@ -295,17 +295,17 @@ function block_admin() {
$output = block_box_form(block_box_get(arg(4)));
break;
case "delete":
$output = status(block_box_delete(arg(4)));
drupal_set_message(block_box_delete(arg(4)));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save block"):
$output = status(block_box_save($edit));
drupal_set_message(block_box_save($edit));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save blocks"):
$output = status(block_admin_save($edit));
drupal_set_message(block_admin_save($edit));
cache_clear_all();
// fall through
default:
......
......@@ -207,17 +207,17 @@ function book_node_link($node = 0) {
if ($op == t("Add to book outline")) {
db_query("INSERT INTO {book} (nid, parent, weight) VALUES (%d, %d, %d)", $node->nid, $edit["parent"], $edit["weight"]);
$output .= status(t("added the node to the book."));
drupal_set_message(t("added the node to the book."));
}
if ($op == t("Update book outline")) {
db_query("UPDATE {book} SET parent = %d, weight = %d WHERE nid = %d", $edit["parent"], $edit["weight"], $node->nid);
$output .= status(t("updated the book outline."));
drupal_set_message(t("updated the book outline."));
}
if ($op == t("Remove from book outline")) {
db_query("DELETE FROM {book} WHERE nid = %d", $node->nid);
$output .= status(t("removed the node form the book."));
drupal_set_message(t("removed the node form the book."));
}
$output .= "<h3>". t("Edit book outline for node <i>%booktitle</i>", array("%booktitle" => $node->title)) ."</h3>";
......@@ -834,7 +834,7 @@ function book_admin() {
$output = book_admin_orphan();
break;
case t("Save book pages"):
$output = status(book_admin_save(arg(3), $edit));
drupal_set_message(book_admin_save(arg(3), $edit));
// fall through:
default:
$output .= book_admin_view(arg(3));
......
......@@ -207,17 +207,17 @@ function book_node_link($node = 0) {
if ($op == t("Add to book outline")) {
db_query("INSERT INTO {book} (nid, parent, weight) VALUES (%d, %d, %d)", $node->nid, $edit["parent"], $edit["weight"]);
$output .= status(t("added the node to the book."));
drupal_set_message(t("added the node to the book."));
}
if ($op == t("Update book outline")) {
db_query("UPDATE {book} SET parent = %d, weight = %d WHERE nid = %d", $edit["parent"], $edit["weight"], $node->nid);
$output .= status(t("updated the book outline."));
drupal_set_message(t("updated the book outline."));
}
if ($op == t("Remove from book outline")) {
db_query("DELETE FROM {book} WHERE nid = %d", $node->nid);
$output .= status(t("removed the node form the book."));
drupal_set_message(t("removed the node form the book."));
}
$output .= "<h3>". t("Edit book outline for node <i>%booktitle</i>", array("%booktitle" => $node->title)) ."</h3>";
......@@ -834,7 +834,7 @@ function book_admin() {
$output = book_admin_orphan();
break;
case t("Save book pages"):
$output = status(book_admin_save(arg(3), $edit));
drupal_set_message(book_admin_save(arg(3), $edit));
// fall through:
default:
$output .= book_admin_view(arg(3));
......
......@@ -1012,7 +1012,7 @@ function comment_mod_matrix($edit) {
}
}
db_query("INSERT INTO {moderation_roles} (mid, rid, value) VALUES ". implode(", ", $sql));
$output = status("Vote values saved");
drupal_set_message("Vote values saved");
}
$result = db_query("SELECT r.rid, r.name FROM {role} r, {permission} p WHERE r.rid = p.rid AND p.perm LIKE '%moderate comments%'");
......@@ -1048,7 +1048,7 @@ function comment_mod_roles($edit) {
if ($edit) {
variable_set("comment_roles", $edit);
$output = status("Comment scores saved");
drupal_set_message("Comment scores saved");
}
$start_values = variable_get("comment_roles", array());
......@@ -1075,18 +1075,18 @@ function comment_mod_votes($edit) {
if ($op == t("Save vote")) {
db_query("UPDATE {moderation_votes} SET vote = '%s', weight = %d WHERE mid = %d", $edit["vote"], $edit["weight"], $mid);
$mid = 0;
$output = status("Vote saved");
drupal_set_message("Vote saved");
}
else if ($op == t("Delete vote")) {
db_query("DELETE FROM {moderation_votes} WHERE mid = %d", $mid);
db_query("DELETE FROM {moderation_roles} WHERE mid = %d", $mid);
$mid = 0;
$output = status("Vote deleted");
drupal_set_message("Vote deleted");
}
else if ($op == t("Add new vote")) {
db_query("INSERT INTO {moderation_votes} (vote, weight) VALUES ('%s', %d)", $edit["vote"], $edit["weight"]);
$mid = 0;
$output = status("Vote added");
drupal_set_message("Vote added");
}
$output .= "<h3>". t("Moderation votes overview") ."</h3>";
......@@ -1126,17 +1126,17 @@ function comment_mod_filters($edit) {
if ($op == t("Save threshold")) {
db_query("UPDATE {moderation_filters} SET filter = '%s', minimum = %d WHERE fid = %d", $edit["filter"], $edit["minimum"], $fid);
$fid = 0;
$output = status("Saved threshold");
drupal_set_message("Saved threshold");
}
else if ($op == t("Delete threshold")) {
db_query("DELETE FROM {moderation_filters} WHERE fid = %d", $fid);
$fid = 0;
$output = status("Deleted threshold");
drupal_set_message("Deleted threshold");
}
else if ($op == t("Add new threshold")) {
db_query("INSERT INTO {moderation_filters} (filter, minimum) VALUES ('%s', %d)", $edit["filter"], $edit["minimum"]);
$fid = 0;
$output = status("Added threshold");
drupal_set_message("Added threshold");
}
$output .= "<h3>Comment threshold overview</h3>";
......@@ -1222,11 +1222,11 @@ function comment_admin() {
$output = comment_delete(array("cid" => arg(3)));
break;
case t("Delete"):
$output = status(comment_delete($edit));
drupal_set_message(comment_delete($edit));
$output .= comment_admin_overview(0);
break;
case t("Submit"):
$output = status(comment_save(check_query(arg(3)), $edit));
drupal_set_message(comment_save(check_query(arg(3)), $edit));
$output .= comment_admin_overview(0);
break;
default:
......
......@@ -1012,7 +1012,7 @@ function comment_mod_matrix($edit) {
}
}
db_query("INSERT INTO {moderation_roles} (mid, rid, value) VALUES ". implode(", ", $sql));
$output = status("Vote values saved");
drupal_set_message("Vote values saved");
}
$result = db_query("SELECT r.rid, r.name FROM {role} r, {permission} p WHERE r.rid = p.rid AND p.perm LIKE '%moderate comments%'");
......@@ -1048,7 +1048,7 @@ function comment_mod_roles($edit) {
if ($edit) {
variable_set("comment_roles", $edit);
$output = status("Comment scores saved");
drupal_set_message("Comment scores saved");
}
$start_values = variable_get("comment_roles", array());
......@@ -1075,18 +1075,18 @@ function comment_mod_votes($edit) {
if ($op == t("Save vote")) {
db_query("UPDATE {moderation_votes} SET vote = '%s', weight = %d WHERE mid = %d", $edit["vote"], $edit["weight"], $mid);
$mid = 0;
$output = status("Vote saved");
drupal_set_message("Vote saved");
}
else if ($op == t("Delete vote")) {
db_query("DELETE FROM {moderation_votes} WHERE mid = %d", $mid);
db_query("DELETE FROM {moderation_roles} WHERE mid = %d", $mid);
$mid = 0;
$output = status("Vote deleted");
drupal_set_message("Vote deleted");
}
else if ($op == t("Add new vote")) {
db_query("INSERT INTO {moderation_votes} (vote, weight) VALUES ('%s', %d)", $edit["vote"], $edit["weight"]);
$mid = 0;
$output = status("Vote added");
drupal_set_message("Vote added");
}
$output .= "<h3>". t("Moderation votes overview") ."</h3>";
......@@ -1126,17 +1126,17 @@ function comment_mod_filters($edit) {
if ($op == t("Save threshold")) {
db_query("UPDATE {moderation_filters} SET filter = '%s', minimum = %d WHERE fid = %d", $edit["filter"], $edit["minimum"], $fid);
$fid = 0;
$output = status("Saved threshold");
drupal_set_message("Saved threshold");
}
else if ($op == t("Delete threshold")) {
db_query("DELETE FROM {moderation_filters} WHERE fid = %d", $fid);
$fid = 0;
$output = status("Deleted threshold");
drupal_set_message("Deleted threshold");
}
else if ($op == t("Add new threshold")) {
db_query("INSERT INTO {moderation_filters} (filter, minimum) VALUES ('%s', %d)", $edit["filter"], $edit["minimum"]);
$fid = 0;
$output = status("Added threshold");
drupal_set_message("Added threshold");
}
$output .= "<h3>Comment threshold overview</h3>";
......@@ -1222,11 +1222,11 @@ function comment_admin() {
$output = comment_delete(array("cid" => arg(3)));
break;
case t("Delete"):
$output = status(comment_delete($edit));
drupal_set_message(comment_delete($edit));
$output .= comment_admin_overview(0);
break;
case t("Submit"):
$output = status(comment_save(check_query(arg(3)), $edit));
drupal_set_message(comment_save(check_query(arg(3)), $edit));
$output .= comment_admin_overview(0);
break;
default:
......
......@@ -588,18 +588,18 @@ function import_admin() {
}
break;
case "remove":
$output = status(import_remove(import_get_feed(arg(5))));
drupal_set_message(import_remove(import_get_feed(arg(5))));
$output .= import_view();
break;
case "update":
$output = status(import_refresh(import_get_feed(arg(5))));
drupal_set_message(import_refresh(import_get_feed(arg(5))));
$output .= import_view();
break;
case "tag":
$output = import_tag();
break;
case t("Save attributes"):
$output = status(import_save_attributes($edit));
drupal_set_message(import_save_attributes($edit));
$output .= import_tag();
break;
case t("Delete"):
......@@ -607,10 +607,10 @@ function import_admin() {
// fall through:
case t("Submit"):
if (arg(5) == "bundle") {
$output = status(import_save_bundle($edit));
drupal_set_message(import_save_bundle($edit));
}
else {
$output = status(import_save_feed($edit));
drupal_set_message(import_save_feed($edit));
}
// fall through:
default:
......
......@@ -266,7 +266,7 @@ function locale_admin() {
switch ($op) {
case "delete":
$output = status(locale_delete(check_query(arg(3))));
drupal_set_message(locale_delete(check_query(arg(3))));
$output .= locale_seek();
break;
case "edit":
......@@ -283,7 +283,7 @@ function locale_admin() {
$output .= locale_seek_form();
break;
case t("Save translations"):
$output = status(locale_save(check_query(arg(3))));
drupal_set_message(locale_save(check_query(arg(3))));
$output .= locale_seek();
break;
default:
......
......@@ -266,7 +266,7 @@ function locale_admin() {
switch ($op) {
case "delete":
$output = status(locale_delete(check_query(arg(3))));
drupal_set_message(locale_delete(check_query(arg(3))));
$output .= locale_seek();
break;
case "edit":
......@@ -283,7 +283,7 @@ function locale_admin() {
$output .= locale_seek_form();
break;
case t("Save translations"):
$output = status(locale_save(check_query(arg(3))));
drupal_set_message(locale_save(check_query(arg(3))));
$output .= locale_seek();
break;
default:
......
......@@ -643,7 +643,7 @@ function node_admin_nodes() {
}
}
$output = status(t("the update has been performed."));
drupal_set_message(t("the update has been performed."));
}
$filter = $_SESSION["node_overview_filter"];
......@@ -709,7 +709,7 @@ function node_admin_settings($edit) {
foreach ($edit as $name => $value) {
variable_set($name, $value);
}
$output = status(t("the content settings have been saved."));
drupal_set_message(t("the content settings have been saved."));
}
if ($op == t("Reset to defaults")) {
......@@ -720,7 +720,7 @@ function node_admin_settings($edit) {
foreach ($edit as $name => $value) {
variable_del($name);
}
$output = status(t("the content settings have been reset to their default values."));
drupal_set_message(t("the content settings have been reset to their default values."));
}
$header = array_merge(array(t("type")), array_keys(node_invoke_nodeapi($node, "settings")));
......@@ -856,7 +856,7 @@ function node_revision_rollback($nid, $revision) {
node_save($rev, $filter);
return status(t("rollbacked to revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
drupal_set_message(t("rollbacked to revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
}
}
......@@ -873,7 +873,7 @@ function node_revision_delete($nid, $revision) {
node_save($node, array("nid", "revisions"));
return status(t("deleted revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
drupal_set_message(t("deleted revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
}
}
......@@ -1518,14 +1518,12 @@ function node_page() {
print theme("page", node_revision_overview(arg(2)), t("Revisions"));
break;
case "rollback-revision":
$output = node_revision_rollback(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
print theme("page", $output, t("Revisions"));
node_revision_rollback(arg(2), arg(3));
print theme("page", node_revision_overview(arg(2)), t("Revisions"));
break;
case "delete-revision":
$output = node_revision_delete(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
print theme("page", $output, t("Revisions"));
node_revision_delete(arg(2), arg(3));
print theme("page", node_revision_overview(arg(2)), t("Revisions"));
break;
case t("Preview"):
$edit = node_validate($edit, $error);
......
......@@ -643,7 +643,7 @@ function node_admin_nodes() {
}
}
$output = status(t("the update has been performed."));
drupal_set_message(t("the update has been performed."));
}
$filter = $_SESSION["node_overview_filter"];
......@@ -709,7 +709,7 @@ function node_admin_settings($edit) {
foreach ($edit as $name => $value) {
variable_set($name, $value);
}
$output = status(t("the content settings have been saved."));
drupal_set_message(t("the content settings have been saved."));
}
if ($op == t("Reset to defaults")) {
......@@ -720,7 +720,7 @@ function node_admin_settings($edit) {
foreach ($edit as $name => $value) {
variable_del($name);
}
$output = status(t("the content settings have been reset to their default values."));
drupal_set_message(t("the content settings have been reset to their default values."));
}
$header = array_merge(array(t("type")), array_keys(node_invoke_nodeapi($node, "settings")));
......@@ -856,7 +856,7 @@ function node_revision_rollback($nid, $revision) {
node_save($rev, $filter);
return status(t("rollbacked to revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
drupal_set_message(t("rollbacked to revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
}
}
......@@ -873,7 +873,7 @@ function node_revision_delete($nid, $revision) {
node_save($node, array("nid", "revisions"));
return status(t("deleted revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
drupal_set_message(t("deleted revision #%revision of '%title'", array("%revision" => $revision, "%title" => $node->title)));
}
}
......@@ -1518,14 +1518,12 @@ function node_page() {
print theme("page", node_revision_overview(arg(2)), t("Revisions"));
break;
case "rollback-revision":
$output = node_revision_rollback(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
print theme("page", $output, t("Revisions"));
node_revision_rollback(arg(2), arg(3));
print theme("page", node_revision_overview(arg(2)), t("Revisions"));
break;
case "delete-revision":
$output = node_revision_delete(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
print theme("page", $output, t("Revisions"));
node_revision_delete(arg(2), arg(3));
print theme("page", node_revision_overview(arg(2)), t("Revisions"));
break;
case t("Preview"):
$edit = node_validate($edit, $error);
......
......@@ -25,13 +25,13 @@ function path_admin() {
break;
case "delete":
$output = status(path_delete(arg(3)));
drupal_set_message(path_delete(arg(3)));
$output .= path_overview();
break;
case t("Create new alias"):
case t("Update alias"):
$output .= status(path_save($edit));
drupal_set_message(path_save($edit));
break;
default:
......
......@@ -25,13 +25,13 @@ function path_admin() {
break;
case "delete":
$output = status(path_delete(arg(3)));
drupal_set_message(path_delete(arg(3)));
$output .= path_overview();
break;
case t("Create new alias"):
case t("Update alias"):
$output .= status(path_save($edit));
drupal_set_message(path_save($edit));
break;
default:
......
......@@ -206,7 +206,7 @@ function system_save_settings($edit = array()) {
}
cache_clear_all();
return t("the configuration options have been saved.");
drupal_set_message(t("the configuration options have been saved."));
}
function system_reset_default($edit = array()) {
......@@ -216,7 +216,7 @@ function system_reset_default($edit = array()) {
cache_clear_all();
return t("the configuration options have been reset to their default values.");
drupal_set_message(t("the configuration options have been reset to their default values."));
}
function system_view($type, $arg = "") {
......@@ -348,14 +348,14 @@ function system_admin() {
if (user_access("administer site configuration")) {
if ($op == t("Reset to defaults")) {
$output = status(system_reset_default($edit));
system_reset_default($edit);
}
if ($op == t("Save configuration")) {
$output = status(system_save_settings($edit));
system_save_settings($edit);
}
$output .= system_view(arg(2), arg(3));
$output = system_view(arg(2), arg(3));
print theme("page", $output);
}
else {
......
......@@ -206,7 +206,7 @@ function system_save_settings($edit = array()) {
}
cache_clear_all();
return t("the configuration options have been saved.");
drupal_set_message(t("the configuration options have been saved."));
}
function system_reset_default($edit = array()) {
......@@ -216,7 +216,7 @@ function system_reset_default($edit = array()) {
cache_clear_all();
return t("the configuration options have been reset to their default values.");
drupal_set_message(t("the configuration options have been reset to their default values."));
}
function system_view($type, $arg = "") {
......@@ -348,14 +348,14 @@ function system_admin() {
if (user_access("administer site configuration")) {
if ($op == t("Reset to defaults")) {
$output = status(system_reset_default($edit));
system_reset_default($edit);
}
if ($op == t("Save configuration")) {
$output = status(system_save_settings($edit));
system_save_settings($edit);
}