aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2011-12-18 21:46:24 +0000
committermistic100 <mistic@piwigo.org>2011-12-18 21:46:24 +0000
commitca230a6f53e3a102faf5cb3633465ee8fc326663 (patch)
tree9613ef04023af2927ed452c370af4814fb866fc5 /include
parentf5004995306cb603d63724c98af2d657c3c4a64b (diff)
feature:2538 Make a unified messages management
use only $page['infos'] and $page['errors'] vars and and necessary template to all main pages git-svn-id: http://piwigo.org/svn/trunk@12764 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/common.inc.php5
-rw-r--r--include/page_header.php16
-rw-r--r--include/picture_comment.inc.php13
3 files changed, 24 insertions, 10 deletions
diff --git a/include/common.inc.php b/include/common.inc.php
index 32eb7920a..d4e8984e8 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -63,7 +63,10 @@ if ( !empty($_SERVER["PATH_INFO"]) )
// rewriting of language and otherarray values via URI params
//
$conf = array();
-$page = array();
+$page = array(
+ 'infos' => array(),
+ 'errors' => array(),
+ );
$user = array();
$lang = array();
$header_msgs = array();
diff --git a/include/page_header.php b/include/page_header.php
index 506e93920..55dc3f5c5 100644
--- a/include/page_header.php
+++ b/include/page_header.php
@@ -98,6 +98,22 @@ if ( isset( $refresh ) and intval($refresh) >= 0
));
}
+
+// messages
+foreach (array('errors','infos') as $mode)
+{
+ if (isset($_SESSION['page_'.$mode]))
+ {
+ $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]);
+ unset($_SESSION['page_'.$mode]);
+ }
+
+ if (count($page[$mode]) != 0)
+ {
+ $template->assign($mode, $page[$mode]);
+ }
+}
+
trigger_action('loc_end_page_header');
header('Content-Type: text/html; charset='.get_pwg_charset());
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 064e02056..0273e7b71 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -53,28 +53,23 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
- $comment_action = insert_user_comment($comm, @$_POST['key'], $infos );
+ $comment_action = insert_user_comment($comm, @$_POST['key'], $page['infos']);
switch ($comment_action)
{
case 'moderate':
- array_push( $infos, l10n('An administrator must authorize your comment before it is visible.') );
+ array_push($page['infos'], l10n('An administrator must authorize your comment before it is visible.') );
case 'validate':
- array_push( $infos, l10n('Your comment has been registered'));
+ array_push($page['infos'], l10n('Your comment has been registered'));
break;
case 'reject':
set_status_header(403);
- array_push($infos, l10n('Your comment has NOT been registered because it did not pass the validation rules') );
+ array_push($page['errors'], l10n('Your comment has NOT been registered because it did not pass the validation rules') );
break;
default:
trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
}
- $template->assign(
- ($comment_action=='reject') ? 'errors' : 'infos',
- $infos
- );
-
// allow plugins to notify what's going on
trigger_action( 'user_comment_insertion',
array_merge($comm, array('action'=>$comment_action) )