Revert "[CLEANUP] Rework/simplify copyright header and remove @package"
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Security / IfAuthenticatedViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Security;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * *
12 * This script is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15 * General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with the script. *
19 * If not, see http://www.gnu.org/licenses/lgpl.html *
20 * *
21 * The TYPO3 project - inspiring people to share! *
22 * */
23 /**
24 * This view helper implements an ifAuthenticated/else condition for FE users/groups.
25 *
26 * = Examples =
27 *
28 * <code title="Basic usage">
29 * <f:security.ifAuthenticated>
30 * This is being shown whenever a FE user is logged in
31 * </f:security.ifAuthenticated>
32 * </code>
33 * <output>
34 * Everything inside the <f:ifAuthenticated> tag is being displayed if you are authenticated with any FE user account.
35 * </output>
36 *
37 * <code title="IfAuthenticated / then / else">
38 * <f:security.ifAuthenticated>
39 * <f:then>
40 * This is being shown in case you have access.
41 * </f:then>
42 * <f:else>
43 * This is being displayed in case you do not have access.
44 * </f:else>
45 * </f:security.ifAuthenticated>
46 * </code>
47 * <output>
48 * Everything inside the "then" tag is displayed if you have access.
49 * Otherwise, everything inside the "else"-tag is displayed.
50 * </output>
51 *
52 * @api
53 */
54 class IfAuthenticatedViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper {
55
56 /**
57 * Renders <f:then> child if any FE user is currently authenticated, otherwise renders <f:else> child.
58 *
59 * @return string the rendered string
60 * @api
61 */
62 public function render() {
63 if (isset($GLOBALS['TSFE']) && $GLOBALS['TSFE']->loginUser) {
64 return $this->renderThenChild();
65 }
66 return $this->renderElseChild();
67 }
68 }