Intranet: per-user Configuration
-
Hello Community!
I’d like to have a simple if-then-clause in my Intranet.conf config file to have a per-user variable definition.
I’m not familiar with php-programming, especially I don’t know the PHP variable holding the user name or login name for WebApp. Can somebody please translate the following peudocode to valid php:
if (login_name = "xxx"); then define('PLUGIN_INTRANET_BUTTON_TITLE_3', 'myURL'); define('PLUGIN_INTRANET_URL_3', 'http://myURL.com/'); end if
Thank you very much!
-
I wanted to do something similar, but I don’t think the Username is available via Environment Variables. Luckily I was able to using various VLANs instead. I also have an internal proxy for I needed to look for the source IP and the X-Forwarded-for IP:
if ( strncmp("10.200.150.", $_SERVER['REMOTE_ADDR'], 11) === 0 || strncmp("10.201.150.", $_SERVER['REMOTE_ADDR'], 11) === 0 || strncmp("10.200.200.", $_SERVER['REMOTE_ADDR'], 11) === 0 || strncmp("10.201.200.", $_SERVER['REMOTE_ADDR'], 11) === 0 || strncmp("10.200.150.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 || strncmp("10.201.150.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 || strncmp("10.200.200.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 || strncmp("10.201.200.", $_SERVER['HTTP_X_FORWARDED_FOR'], 11) === 0 ) { define('PLUGIN_INTRANET_USER_DEFAULT_ENABLE', true); define('PLUGIN_INTRANET_BUTTON_TITLE', 'Teams'); define('PLUGIN_INTRANET_URL', 'https://teams/'); } else { define('PLUGIN_INTRANET_USER_DEFAULT_ENABLE', false); define('PLUGIN_INTRANET_BUTTON_TITLE', 'Teams'); define('PLUGIN_INTRANET_URL', 'https://teams/'); }
-
In another plugin, I found the environment variable
$data['username']
It might be as simple as
if ( $data['username'] == 'xxx' ) { define('PLUGIN_INTRANET_BUTTON_TITLE_3', 'myURL'); define('PLUGIN_INTRANET_URL_3', 'http://myURL.com/') }
I will test this when I have access to my System. Right now, i’m on the road.
-
OK, that does not work.
$data[‘username’] is an empty string when the config file is called. Still looking for a solution …
-
@itserv Maybe this will help you:
$GLOBALS[‘mapisession’]->getUserName() -
Great, that did the job. Thank you.
For reference: my config file now more or less like this:
<?php define('PLUGIN_INTRANET_USER_DEFAULT_ENABLE', false); define('PLUGIN_INTRANET_BUTTON_TITLE', 'Kopano.io'); define('PLUGIN_INTRANET_URL', 'http://www.kopano.io/'); define('PLUGIN_INTRANET_AUTOSTART', false); // More buttons can be added by adding a number as follows // Note: Numbers must start with 1 and be sequential define('PLUGIN_INTRANET_BUTTON_TITLE_1', 'Kopano.com'); define('PLUGIN_INTRANET_URL_1', 'http://kopano.com/'); define('PLUGIN_INTRANET_AUTOSTART_1', false); $user_name = $GLOBALS["mapisession"]->getUserName(); if ( $user_name == 'someuser' ) { define('PLUGIN_INTRANET_BUTTON_TITLE_2', 'AnotherTitle'); define('PLUGIN_INTRANET_URL_2', 'https://some_url'); }