[TYPO3-english] Is using global $BE_USER incorrect?

Bjoern Pedersen bjoern.pedersen at frm2.tum.de
Tue Sep 28 08:52:16 CEST 2010


Am 27.09.2010 19:51, schrieb Nicolas Kuttler:
> On Mon, Sep 27, 2010 at 05:50:13PM +0200, Bjoern Pedersen wrote:
>> Am 27.09.2010 17:41, schrieb Nicolas Kuttler:
>>> Why is global $BE_USER only defined for backend admin users? The
>>> documentation seems to say it should be defined for all BE users.
>>>
>>> http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.3.0/view/3/6/
>>>
>>> I have inspected it from a userfunct and from an extension, it's defined
>>> for BE admin users only (tested in 4.2 and 4.4.).
>>>
>>> Nicolas 
>>
>> $BE_USER is only defined in a BE context (so e.g. BE modules). Your
>> description is a bit unclear, userfunctions and  extensions are normally
>> uses in a FE context.
>>
>> So, what do you want to achieve and how did you try it? Post some code,
>> please.
> 
> I want to run some code when visiting a FE page and any BE user is
> logged in. All examples I found look like:
> 
> typoscript:
> [globalVar = TSFE:beUserLogin>0]
> # do something
> [global]
> 
> This condition is only true for BE admin users, which is rather useless
> in my case.
> 
> From within the constructor of a FE extension (in the pi1/mainfile.php):
> 
>     function __construct() {
>         global $BE_USER;
>         global $TSFE;
>         $this->log( is_object( $BE_USER ) ); // only true for BE admins
>         $this->log( $TSFE->beUserLogin ); // only true for BE admins
>     }
> 
> 
> (I'm using a custom logger method, don't think this is relevant here)
> 
> Nicolas
Looking at the code, it should be working. There are only the following
checks which could cause a failure:

lockIP is set and not fullfilled.
adminOnly is set
lockSSL is set and not fulfilled. (If you have set lockSSL for the
backend, then you will only succeed with this test, if you access the FE
trough SSL as well.)

Björn


More information about the TYPO3-english mailing list