diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-02-12 16:12:50 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-02-12 16:12:50 +0000 |
commit | e5edab721ea12ba5ac937a5adeda53f5e3393611 (patch) | |
tree | 719ec8c5ac9b91ae0e536e8d0e375db372a456d1 /engine/lib | |
parent | eba31495c573836877c20fffdd833352738067ec (diff) | |
download | elgg-e5edab721ea12ba5ac937a5adeda53f5e3393611.tar.gz elgg-e5edab721ea12ba5ac937a5adeda53f5e3393611.tar.bz2 |
Sanitisation
git-svn-id: https://code.elgg.org/elgg/trunk@7 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/elgglib.php | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 734407530..3a0d6f2a4 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -143,10 +143,16 @@ *
* @return true|false True if everything is ok (or Elgg is fit enough to run); false if not.
*/
- function sanitise() {
+ function sanitised() {
- if (!file_exists(dirname(dirname(__FILE__)) . "/settings.php"))
+ $sanitised = true;
+
+ if (!file_exists(dirname(dirname(__FILE__)) . "/settings.php")) {
register_error(elgg_view("messages/sanitisation/settings"));
+ $sanitised = false;
+ }
+
+ return $sanitised;
}
@@ -164,30 +170,42 @@ * @return true|false|array Either the array of messages, or a response regarding whether the message addition was successful
*/
- function system_messages($message = null, $register = "messages") {
+ function system_messages($message = null, $register = "messages", $count = false) {
static $messages;
if (!isset($messages)) {
$messages = array();
}
- if (!isset($messages[$register])) {
+ if (!isset($messages[$register]) && !empty($register)) {
$messages[$register] = array();
}
- if (!empty($message) && is_array($message)) {
- $messages[$register] = array_merge($messages[$register], $message);
- return true;
- } else if (!empty($message) && is_string($message)) {
- $messages[$register][] = $message;
- return true;
- } else if (!is_string($message) && !is_array($message)) {
+ if (!$count) {
+ if (!empty($message) && is_array($message)) {
+ $messages[$register] = array_merge($messages[$register], $message);
+ return true;
+ } else if (!empty($message) && is_string($message)) {
+ $messages[$register][] = $message;
+ return true;
+ } else if (!is_string($message) && !is_array($message)) {
+ if (!empty($register)) {
+ $returnarray = $messages[$register];
+ $messages[$register] = array();
+ } else {
+ $returnarray = $messages;
+ $messages = array();
+ }
+ return $returnarray;
+ }
+ } else {
if (!empty($register)) {
- $returnarray = $messages[$register];
- $messages[$register] = array();
+ return sizeof($messages[$register]);
} else {
- $returnarray = $messages;
- $messages = array();
+ $count = 0;
+ foreach($messages as $register => $submessages) {
+ $count += sizeof($submessages);
+ }
+ return $count;
}
- return $returnarray;
}
return false;
@@ -212,5 +230,15 @@ function register_error($error) {
return system_messages($error, "errors");
}
+
+ /**
+ * Counts the number of messages, either globally or in a particular register
+ *
+ * @param string $register Optionally, the register
+ * @return integer The number of messages
+ */
+ function count_messages($register = "") {
+ return system_messages(null,$register,true);
+ }
?>
\ No newline at end of file |