commit 774aa28f6df080468ca4230794a1d9fc3ec7c34f
parent a1518780b233dbdd0abbbcc5e13b57ae4b820fa0
Author: dankert <devnull@localhost>
Date: Thu, 29 Oct 2009 09:44:27 +0100
Neue globale Funktion 'config()' und 'readonly()'.
Diffstat:
1 file changed, 49 insertions(+), 0 deletions(-)
diff --git a/functions/common.inc.php b/functions/common.inc.php
@@ -43,4 +43,53 @@ function vorzeichen( $nr )
{
return intval($nr)<0 ? $nr : '+'.$nr;
}
+
+
+
+/**
+ * Stellt fest, ob das System in einem schreibgeschuetzten Zustand ist.
+ *
+ * @return boolean true, falls schreibgeschuetzt, sonst false
+ */
+function readonly()
+{
+ global $conf;
+
+ // Gesamtes CMS ist readonly.
+ if ( config('security','readonly') )
+ return true;
+
+ // Aktuelle Datenbankverbindung ist readonly.
+ $db = Session::getDatabase();
+ if ( $db->conf['readonly'] )
+ return true;
+
+ return false;
+}
+
+
+
+/*
+ * Liest einen Schluessel aus der Konfiguration
+ *
+ * @return String, leer falls Schluessel nicht vorhanden
+ */
+function config( $part1,$part2,$part3=null )
+{
+ global $conf;
+
+ if ( $part3 == null)
+ if ( isset($conf[$part1][$part2]))
+ return $conf[$part1][$part2];
+ else
+ return '';
+ else
+ if ( isset($conf[$part1][$part2][$part3]))
+ return $conf[$part1][$part2][$part3];
+ else
+ return '';
+}
+
+
+
?>
\ No newline at end of file