summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-01-23 19:29:38 +0100
committerandi <andi@splitbrain.org>2005-01-23 19:29:38 +0100
commit0396becba66d77cb925a7a46a01af74bf519e7e1 (patch)
treed450d740270e00f96739166d6470151741a6a537 /inc/common.php
parentf59b22f06ff9991411582125e93ead71a4da0a3c (diff)
downloadrpg-0396becba66d77cb925a7a46a01af74bf519e7e1.tar.gz
rpg-0396becba66d77cb925a7a46a01af74bf519e7e1.tar.bz2
allow msg after headers were sent
darcs-hash:20050123182938-9977f-4404c519f6b05550c6ba3d43cea24f246b137dad.gz
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/inc/common.php b/inc/common.php
index fd6fb911c..42fcf82c3 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -142,7 +142,12 @@ function pageinfo(){
}
/**
- * adds a message to the global message array
+ * print a message
+ *
+ * If HTTP headers were not sent yet the message is added
+ * to the global message array else it's printed directly
+ * using html_msgarea()
+ *
*
* Levels can be:
*
@@ -151,6 +156,7 @@ function pageinfo(){
* 1 success
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @see html_msgarea
*/
function msg($message,$lvl=0){
global $MSG;
@@ -158,8 +164,14 @@ function msg($message,$lvl=0){
$errors[0] = 'info';
$errors[1] = 'success';
- if(!isset($MSG)) $MSG = array();
- $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
+ if(!headers_sent){
+ if(!isset($MSG)) $MSG = array();
+ $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
+ }else{
+ $MSG = array();
+ $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
+ html_msgarea();
+ }
}
/**