add option to disable avatar loading
[phorkie.git] / src / phorkie / HtmlHelper.php
index ca5f98981be818febdd84e50286fc368161b21c2..d23468547bbb98ab3726d87eff807437e3ee39aa 100644 (file)
@@ -5,7 +5,9 @@ class HtmlHelper
 {
     public function getIconUrl($email, $size = 32)
     {
-        if ($email == 'anonymous@phorkie') {
+        if ($email == 'anonymous@phorkie'
+            || !$GLOBALS['phorkie']['cfg']['avatars']
+        ) {
             return 'phorkie/anonymous.png';
         }
 
@@ -49,6 +51,28 @@ class HtmlHelper
     {
         return Tools::fullUrl($path);
     }
+
+    public function mayWriteLocally()
+    {
+        if ($GLOBALS['phorkie']['auth']['securityLevel'] == 0) {
+            //everyone may do everything
+            return true;
+        }
+
+        $logged_in = false;
+        if (!isset($_SESSION['identity'])) {
+            //not logged in
+        } else if ($GLOBALS['phorkie']['auth']['listedUsersOnly']) {
+            if (in_array($_SESSION['identity'], $GLOBALS['phorkie']['auth']['users'])) {
+                $logged_in = true;
+            }
+        } else {
+            //session identity exists, no special checks required
+            $logged_in = true;
+        }
+
+        return $logged_in;
+    }
 }
 
 ?>