3 # Copyright (C) 2007 Jason Woofenden
5 # This file is part of wfpl.
7 # wfpl is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU Lesser General Public License as published by the Free
9 # Software Foundation; either version 2.1 of the License, or (at your option)
12 # wfpl is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with wfpl; if not, write to the Free Software Foundation, Inc., 51
19 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 # require_once() this file instead of messages.php if you'd like to store
23 # save/restore messages in the session accross redirect()s. That's all you have
24 # to do. These functions are called when needed (from redirect() and
25 # display_messages()) if they are defined.
27 # see messages.php for documentation on how to use it.
29 require_once('code/wfpl/session.php');
30 require_once('code/wfpl/string_array.php');
31 require_once('code/wfpl/messages.php');
33 function session_save_messages() {
34 if(!isset($GLOBALS['wfpl_messages'])) {
37 if(!is_array($GLOBALS['wfpl_messages'])) {
42 session_set('wfpl_messages', array_to_string($GLOBALS['wfpl_messages']);
45 function session_restore_messages() {
49 $messages = session_get('wfpl_messages');
50 if($messages !== false) {
51 $messages = string_to_array($messages);
52 # messages from the previous run happened first
53 $GLOBALS['wfpl_messages'] = array_merge($messages, $GLOBALS['wfpl_messages']);
55 session_clear('wfpl_messages');