aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-20 22:00:57 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-20 22:00:57 +0000
commit8dc9919079ce498ec4ef5725e67194062a8120a0 (patch)
tree88b2b1895cc5752b4938c8508a433decf5ecf694 /engine/lib/elgglib.php
parente4dd4e889a4ca33e4fadae87895ab6d657ad9ad2 (diff)
downloadelgg-8dc9919079ce498ec4ef5725e67194062a8120a0.tar.gz
elgg-8dc9919079ce498ec4ef5725e67194062a8120a0.tar.bz2
fixed bug where array of messages passed to system_messages caused execution to stop - also displaying only errors if they exist rather than having success and error messages overlapping each other
git-svn-id: http://code.elgg.org/elgg/trunk@3776 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php27
1 files changed, 19 insertions, 8 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 150dcb502..d5d0828b6 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -1174,12 +1174,22 @@ function autoregister_views($view_base, $folder, $base_location_path, $viewtype)
*/
function page_draw($title, $body, $sidebar = "") {
+ // get messages - try for errors first
+ $sysmessages = system_messages(null, "errors");
+ if (count($sysmessages["errors"]) == 0) {
+ // no errors so grab rest of messages
+ $sysmessages = system_messages(null, "");
+ } else {
+ // we have errors - clear out remaining messages
+ system_messages(null, "");
+ }
+
// Draw the page
$output = elgg_view('pageshells/pageshell', array(
'title' => $title,
'body' => $body,
'sidebar' => $sidebar,
- 'sysmessages' => system_messages(null,"")
+ 'sysmessages' => $sysmessages,
)
);
$split_output = str_split($output, 1024);
@@ -1433,15 +1443,16 @@ function menu_item($menu_name, $menu_url) {
/**
* Message register handling
- * If no parameter is given, the function returns the array of messages so far and empties it.
- * Otherwise, any message or array of messages is added.
+ * If a null $message parameter is given, the function returns the array of messages so far and empties it
+ * based on the $register parameters. Otherwise, any message or array of messages is added.
*
- * @param string|array $message Optionally, a single message or array of messages to add
- * @param string $register By default, "errors". This allows for different types of messages, eg errors.
+ * @param string|array $message Optionally, a single message or array of messages to add, (default: null)
+ * @param string $register This allows for different types of messages: "errors", "messages" (default: messages)
+ * @param bool $count Count the number of messages (default: false)
* @return true|false|array Either the array of messages, or a response regarding whether the message addition was successful
*/
-function system_messages($message = "", $register = "messages", $count = false) {
+function system_messages($message = null, $register = "messages", $count = false) {
if (!isset($_SESSION['msg'])) {
$_SESSION['msg'] = array();
}
@@ -1451,14 +1462,14 @@ function system_messages($message = "", $register = "messages", $count = false)
if (!$count) {
if (!empty($message) && is_array($message)) {
$_SESSION['msg'][$register] = array_merge($_SESSION['msg'][$register], $message);
- var_export($_SESSION['msg']); exit;
return true;
} else if (!empty($message) && is_string($message)) {
$_SESSION['msg'][$register][] = $message;
return true;
} else if (is_null($message)) {
if ($register != "") {
- $returnarray = $_SESSION['msg'][$register];
+ $returnarray = array();
+ $returnarray[$register] = $_SESSION['msg'][$register];
$_SESSION['msg'][$register] = array();
} else {
$returnarray = $_SESSION['msg'];