From: Christian Weiske Date: Thu, 8 May 2014 21:09:41 +0000 (+0200) Subject: show remote fork button only if user cannot write X-Git-Tag: v0.4.0~46 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/991497ceb381d1ab6bc79db8bfad4405c8bbd008 show remote fork button only if user cannot write --- diff --git a/data/templates/display-head.htm b/data/templates/display-head.htm index f610f84..aa7daec 100644 --- a/data/templates/display-head.htm +++ b/data/templates/display-head.htm @@ -8,13 +8,19 @@
+ {% if htmlhelper.mayWriteLocally %} + {% else %} + Fork to remote system + {% endif %}
diff --git a/src/phorkie/HtmlHelper.php b/src/phorkie/HtmlHelper.php index ca5f989..c3336c3 100644 --- a/src/phorkie/HtmlHelper.php +++ b/src/phorkie/HtmlHelper.php @@ -49,6 +49,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; + } } ?>