summaryrefslogtreecommitdiffstats
path: root/lib/class/error.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/class/error.class.php')
-rw-r--r--lib/class/error.class.php64
1 files changed, 34 insertions, 30 deletions
diff --git a/lib/class/error.class.php b/lib/class/error.class.php
index 29c1c885..61202532 100644
--- a/lib/class/error.class.php
+++ b/lib/class/error.class.php
@@ -1,27 +1,5 @@
<?php
/*
-
- Copyright (c) 2001 - 2007 Ampache.org
- All Rights Reserved
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; version 2
- of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-
-/**
Copyright (c) 2001 - 2007 Ampache.org
All Rights Reserved
@@ -38,8 +16,9 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
+*/
-
+/**
* Error class
* This is the baic error class, its better now that we can use php5
* hello static functions and variables
@@ -60,6 +39,19 @@ class Error {
} // __construct
/**
+ * __destruct
+ * This saves all of the errors that are left into the session
+ */
+ public function __destruct() {
+
+
+ foreach (self::$errors as $key=>$error) {
+ $_SESSION['errors'][$key] = $error;
+ }
+
+ } // __destruct
+
+ /**
* add
* This is a public static function it adds a new error message to the array
* It can optionally clobber rather then adding to the error message
@@ -70,24 +62,21 @@ class Error {
if (!isset(Error::$errors[$name])) {
Error::$errors[$name] = $message;
Error::$state = 1;
- return true;
+ $_SESSION['errors'][$key] = $message;
}
-
// They want us to clobber it
- if ($clobber) {
+ elseif ($clobber) {
Error::$state = 1;
Error::$errors[$name] = $message;
- return true;
+ $_SESSION['errors'][$key] = $message;
}
-
// They want us to append the error, add a BR\n and then the message
else {
Error::$state = 1;
Error::$errors[$name] .= "<br />\n" . $message;
- return true;
+ $_SESSION['errors'][$key] .= "<br />\n" . $message;
}
-
} // add
/**
@@ -116,5 +105,20 @@ class Error {
} // display
+ /**
+ * auto_init
+ * This loads the errors from the session back into Ampache
+ */
+ public static function auto_init() {
+
+ if (!is_array($_SESSION['errors'])) { return false; }
+
+ // Re-insert them
+ foreach ($_SESSION['errors'] as $key=>$error) {
+ self::add($key,$error);
+ }
+
+ } // auto_init
+
} // Error