From 010656745dd6f7db6b09ec501ad3bb1e202b9a96 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Tue, 29 Oct 2013 20:02:30 +0100
Subject: First version of basic minilinux configuration
---
inc/message.inc.php | 2 ++
inc/permission.inc.php | 25 +++++++++++++++++++++++++
inc/user.inc.php | 6 ++++++
inc/util.inc.php | 10 ++++++++++
4 files changed, 43 insertions(+)
create mode 100644 inc/permission.inc.php
(limited to 'inc')
diff --git a/inc/message.inc.php b/inc/message.inc.php
index b24bf2a1..b90ed630 100644
--- a/inc/message.inc.php
+++ b/inc/message.inc.php
@@ -8,6 +8,8 @@ $error_text = array(
'password-mismatch' => 'Passwort und Passwortbestätigung stimmen nicht überein',
'empty-field' => 'Ein benötigtes Feld wurde nicht ausgefüllt',
'adduser-success' => 'Benutzer erfolgreich hinzugefügt',
+ 'no-permission' => 'Keine ausreichenden Rechte, um auf diese Seite zuzugreifen',
+ 'settings-updated' => 'Einstellungen wurden aktualisiert',
);
class Message
diff --git a/inc/permission.inc.php b/inc/permission.inc.php
new file mode 100644
index 00000000..b63e9d45
--- /dev/null
+++ b/inc/permission.inc.php
@@ -0,0 +1,25 @@
+fetch(PDO::FETCH_ASSOC)) {
+ self::$permissions[$row['identifier']] = $row['mask'];
+ }
+ }
+
+}
+
diff --git a/inc/user.inc.php b/inc/user.inc.php
index b988bbeb..38e57e33 100644
--- a/inc/user.inc.php
+++ b/inc/user.inc.php
@@ -17,6 +17,12 @@ class User
return self::$user['fullname'];
}
+ public static function hasPermission($permission)
+ {
+ if (self::$user === false) return false;
+ return (self::$user['permissions'] & Permission::get($permission)) != 0;
+ }
+
public static function load()
{
if (Session::load()) {
diff --git a/inc/util.inc.php b/inc/util.inc.php
index b4a0036e..0d85b989 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -32,5 +32,15 @@ class Util
Message::addError('token');
return false;
}
+
+ function markup($string)
+ {
+ $string = htmlspecialchars($string);
+ $string = preg_replace('#(^|[\n \-_/\.])\*(.+?)\*($|[ \-_/\.\!\?,])#is', '$1$2$3', $string);
+ $string = preg_replace('#(^|[\n \-\*/\.])_(.+?)_($|[ \-\*/\.\!\?,])#is', '$1$2$3', $string);
+ $string = preg_replace('#(^|[\n \-_\*\.])/(.+?)/($|[ \-_\*\.\!\?,])#is', '$1$2$3', $string);
+ return nl2br($string);
+ }
+
}
--
cgit v1.2.3-55-g7522