TYPO3 API  SVNRelease
IfAuthenticatedViewHelper.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*                                                                        *
00004  * This script belongs to the FLOW3 package "Fluid".                      *
00005  *                                                                        *
00006  * It is free software; you can redistribute it and/or modify it under    *
00007  * the terms of the GNU Lesser General Public License as published by the *
00008  * Free Software Foundation, either version 3 of the License, or (at your *
00009  * option) any later version.                                             *
00010  *                                                                        *
00011  * This script is distributed in the hope that it will be useful, but     *
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
00013  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
00014  * General Public License for more details.                               *
00015  *                                                                        *
00016  * You should have received a copy of the GNU Lesser General Public       *
00017  * License along with the script.                                         *
00018  * If not, see http://www.gnu.org/licenses/lgpl.html                      *
00019  *                                                                        *
00020  * The TYPO3 project - inspiring people to share!                         *
00021  *                                                                        */
00022 
00023 /**
00024  * This view helper implements an ifAuthenticated/else condition for FE users/groups.
00025  *
00026  * = Examples =
00027  *
00028  * <code title="Basic usage">
00029  * <f:security.ifAuthenticated>
00030  *   This is being shown whenever a FE user is logged in
00031  * </f:security.ifAuthenticated>
00032  * </code>
00033  * <output>
00034  * Everything inside the <f:ifAuthenticated> tag is being displayed if you are authenticated with any FE user account.
00035  * </output>
00036  *
00037  * <code title="IfAuthenticated / then / else">
00038  * <f:security.ifAuthenticated>
00039  *   <f:then>
00040  *     This is being shown in case you have access.
00041  *   </f:then>
00042  *   <f:else>
00043  *     This is being displayed in case you do not have access.
00044  *   </f:else>
00045  * </f:security.ifAuthenticated>
00046  * </code>
00047  * <output>
00048  * Everything inside the "then" tag is displayed if you have access.
00049  * Otherwise, everything inside the "else"-tag is displayed.
00050  * </output>
00051  *
00052  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
00053  * @api
00054  */
00055 class Tx_Fluid_ViewHelpers_Security_IfAuthenticatedViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractConditionViewHelper {
00056 
00057     /**
00058      * Renders <f:then> child if any FE user is currently authenticated, otherwise renders <f:else> child.
00059      *
00060      * @return string the rendered string
00061      * @api
00062      */
00063     public function render() {
00064         if (isset($GLOBALS['TSFE']) && $GLOBALS['TSFE']->loginUser) {
00065             return $this->renderThenChild();
00066         }
00067         return $this->renderElseChild();
00068     }
00069 }
00070 ?>