[Typo3] Conditions by using user functioons

tapio tapio.markula at dnainternet.net
Tue Aug 9 15:25:53 CEST 2005


Jean-David Gadina wrote:
> Hello Tapio,
> 
> For you PHP functions, you should create a PHP file, and include it  in 
> localconf.php. This will keep localconf clean.

ok. I got this - and I got a primitive solution for FE editing


$dbConn=mysql_connect($typo_db_host,$typo_db_username,$typo_db_password);

function user_fe_user($ID)
{
     global $dbConn,$_COOKIE, $typo_db;
     mysql_select_db($typo_db, $dbConn);
     if (isset($_COOKIE["be_typo_user"]))
     {
     $userHash=$_COOKIE["be_typo_user"];
	
	$userData=mysql_query("
	SELECT ses_userid FROM be_sessions
	WHERE be_sessions.ses_id='${userHash}'	
	;", $dbConn);
	
	$userId=mysql_fetch_array($userData);
	$userId=$userId['ses_userid'];
	
	if ($ID==$userId)
		return true;
	else
		return false;
     }
     else return false;
}

When I set for this for example the following code

[ userFunc = user_fe_user(5)]
page.headerData.22 = TEXT
page.headerData.22.value =<link rel="stylesheet" type="text/css" 
href="fileadmin/template/main/css/fe-buttons.css" 
media="screen,projection,handheld" />
[global]

That creates the LINK-element only for the user '5'.

The problem is that that works ONLY in frontend editing.

I would need for BE-editing corresponding conditions
to define an additional LINK element for CSS in order to control better 
BE users/ BE user groups in BE-editing.

The BE uses now stylesheet_post.css but I would like to add an extra CSS 
file.


> 
> Then, you need to prefix your functions. By default, the prefix is  
> user_ (this can be changed in the installTool).
> 
> So, for example:
> 
> function user_checkMonday() {
>     if (date('w',time()) == 1) {
>         return true;
>     } else {
>         return false;
>     }
> }
> 
> This will check if the current day is Monday...
> 
> In your TS setup:
> 
> [userFunc = user_checkMonday]
>     page.headerData.10 = TEXT
>     page.headerData.10.value = <link rel="stylesheet" type="text/ css" 
> media="screen" href="fileadmin/css/monday.css"
> [GLOBAL]
> 
> -- 
> Jean-David Gadina (macmade)
> www.gadlab.net - Multimedia Network
> 
> 
> On Aug 9, 2005, at 1:50 PM, tapio wrote:
> 
>> Hi
>>
>> I read this page
>> http://typo3.org/documentation/document-library/doc_core_tsref/ userFunc/
>>
>> But I didn't fully understood everything.
>>
>> I woud like to create
>> [userFunc = be_user(ID)]
>>
>> and
>>
>>
>> [userFunc = be_user_group(ID)]
>>
>> the result, which I would like to get would be like
>>
>> [userFunc = be_user_group(1)]
>> page.headerData.22 = TEXT
>> page.headerData.22.value =<link rel="stylesheet" type="text/css"
>> href="fileadmin/template/main/css/fe-buttons_user_group_1.css"
>> media="screen,projection,handheld" />
>> [global]
>>
>> BUT the code should put to localconf.
>> Does TS work at all?
>> _______________________________________________
>> Typo3-english mailing list
>> Typo3-english at lists.netfielders.de
>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>>
> 



More information about the TYPO3-english mailing list