PDA

View Full Version : Simple feature


kinai
24th January 2010, 12:09
Hi all,

Is it possible to add in the top banner, the username of the current login user, near logout button.

For example,

You are 'ISP Admin (user admin)'
You are 'Resellers1 Admin (user resell1)
You are 'Kinaï (user kinai)


Thanks,
kinai

BorderAmigos
4th March 2010, 05:10
Here's a hack that will put the user name under the logo. The page needs to be refreshed once first though so not a perfect hack.

In /var/www/ispconfig/themes/default/templates/main.tpl.htm change line 75

from

<span>hosting control panel</span>


to

<span>hosting control panel</span><?php echo (!($_SESSION['s']['user']['username'] == '')) ? '<br /> user: '.$_SESSION['s']['user']['username'] : '' ; ?>


Add that extra bit of code anywhere you want the user name to show up. No promises that this won't break something. There might be a more direct way to get the user name as well but I just hacked around until something worked.

kinai
4th April 2010, 00:59
I'm applying this hack under this line.


<span><a href="#logout" onclick="loadContent('login/logout.php');">LOGOUT</a><!-- | <a href="#" onclick="capp('help')">Help</a> | <a href="#">Imprint</a>--></span>


and I try to change your code like

<?php echo (!($_SESSION['s']['user']['username'] == '')) ? "<br /> {tmpl_var name='username_txt'}: ".$_SESSION['s']['user']['username'] : '' ; ?>

but it's not working ...
Could you help me ...

Thanks,
Regards,
Kinai

BorderAmigos
4th April 2010, 02:52
Not sure what you're trying to do and your syntax looks messed up.

maybe you want...

<?php
echo "<br>";
echo ($_SESSION['s']['user']['username'] != '') ? {tmpl_var name='username_txt'}:$_SESSION['s']['user']['username'];
?>

kinai
4th April 2010, 09:31
Hi,

I'm trying to display

Username: Admin

under logout link.

a better solution was to have an other field to do it :

in en_EN: current_user_text = "Your are now connected as"
in fr_FR: current_user_text = "Vous êtes actuellement connecté en tant que"

your php code is not working, page is not displaying.

BorderAmigos
4th April 2010, 17:22
The first one posted works but the page needs to be refreshed. The code using the template was just trying to fix the syntax. Didn't try your code to see if it worked.

mike_p
6th April 2010, 11:04
I have just posted an alternative method that does not break the template concept of avoiding mixing PHP into your HTML.

Edit the "public function tpl_defaults()"
in app.inc.php

add this to the bottom of the function:
if(isset($_SESSION['s']['user'])) {
$this->tpl->setVar('cpuser', $_SESSION['s']['user']['username']);
}

Then in your templates you can use
<tmpl_var format="strtoupper" name="cpuser">

for example alongside the word LOGOUT in main.tpl.htm

Hopefully the 'bosses' will include my suggested change to app.inc.php in future versions! :rolleyes:

skoena
8th April 2010, 10:39
I only get the name showed when I hit the refresh button (F5).

BorderAmigos
8th April 2010, 16:27
I only get the name showed when I hit the refresh button (F5).

As stated in #2 above "The page needs to be refreshed once first though so not a perfect hack." It would be interesting to know why if someone has the time to figure it out.

vogelor
7th May 2010, 17:11
Hopefully the 'bosses' will include my suggested change to app.inc.php in future versions! :rolleyes:

i am not "the boss" - just a developer ;-)
But ... your code is in SVN...

Olli