Roundcube Community Forum

 

Change logo based on login

Started by jeffshead, November 08, 2013, 02:58:57 AM

Previous topic - Next topic

jeffshead

The website for the 'Custom Logo' plugin that is listed in the repository (http://trac.roundcube.net/wiki/Plugin_Repository) has been down for a very long time.

Can someone share this plugin?

I want to use the same URL (https://www.mysite.com/webmail/) to login and check email for all of my domains. Then I can simply enter the full email address (e.g., [email protected], [email protected]) and the logo changes based on the domain part of the email address that is entered during login.

If the plugin is not available or will not work with RC 0.95, can someone please tell me how to have the logo change based on the domain part of the email address that is entered during login?

alec

You can write PHP code in config file, e.g.:

if (strpos($_SESSION['username'], '@domain1.tld'))
    $rcmail_config['skin_logo'] = 'path/to/logo/file1';
else if (strpos($_SESSION['username'], '@domain2.tld'))
    $rcmail_config['skin_logo'] = 'path/to/logo/file2';

Dennis1993

You don't Need the plugin. You can define various logos to RoundCube by default.

Look into your config:
Quote// replace Roundcube logo with this image
// specify an URL relative to the document root of this Roundcube installation
// an array can be used to specify different logos for specific template files, '*' for default logo
// for example array("*" => "/images/roundcube_logo.png", "messageprint" => "/images/roundcube_logo_print.png")

$config['skin_logo'] = null;

And you can define special config files for every domain you have and set the right logo for all users.

jeffshead

#3
Quote from: alec on November 08, 2013, 04:10:34 AM
You can write PHP code in config file, e.g.:

if (strpos($_SESSION['username'], '@domain1.tld'))
    $rcmail_config['skin_logo'] = 'path/to/logo/file1';
else if (strpos($_SESSION['username'], '@domain2.tld'))
    $rcmail_config['skin_logo'] = 'path/to/logo/file2';

Thanks for the code but it does not work. I did verify the paths for the other logos. The paths are correct. Any suggestions?

jeffshead

Quote from: Dennis1993 on November 08, 2013, 06:48:03 AM
You don't Need the plugin. You can define various logos to RoundCube by default.

Look into your config:
Quote// replace Roundcube logo with this image
// specify an URL relative to the document root of this Roundcube installation
// an array can be used to specify different logos for specific template files, '*' for default logo
// for example array("*" => "/images/roundcube_logo.png", "messageprint" => "/images/roundcube_logo_print.png")

$config['skin_logo'] = null;

And you can define special config files for every domain you have and set the right logo for all users.

As I stated in my original post, I'm using the same URL to access RC for all domains so I don't see how RC will know to include a domain specific config file. Maybe I'm not following you.

genevish

alec's code should work.  Is the right logo showing in the HTML when you login and it's just not displaying, or is it not even getting the correct logo name?

I prefer using different webmail URL's for each site,  That can be done with this:

// replace Roundcube logo with this image
// specify an URL relative to the document root of this Roundcube installation
if (strpos($_SERVER['HTTP_HOST'],'mydomain.com'))
   $rcmail_config['skin_logo'] = 'des-rgb-small.png';
else {
   $rcmail_config['skin_logo'] = 'roundcube_logo_print.png';
}

techninja

@genevish like  jeffshead said, this is intended to a scenario where roundcube is being access from the same url, and as such can not be dependent on the url info.

alec's code does not seem to work, any suggestions ?

it looks like this line :  (strpos($_SESSION['username'], '@domain1.tld'))   does not yield the intended result.


rosali

Alec's code works unless you are talking about the login page where the user is not known.
Regards,
Rosali

techninja

@rosali,

can you help me figure out why it's not working for me?

i'm using cpanel, the path to the config file is : /usr/local/cpanel/base/3rdparty/roundcube/config/
and i'm placing Alec's code to the config.inc.php file:

if (strpos($_SESSION['username'], '@domain.com')) {
   $config['skin_logo'] = 'logo.jpg';
} elseif (strpos($_SESSION['username'], '@domain.com')) {
   $config['skin_logo'] = 'logo2.jpg';
} else {
   $config['skin_logo'] = null;
}


when i'm changing the if condition to 0 == 0 then the logo changes, but with session it doesn't work.
any idea what am i doing wrong ?

thank you.

SKaero

Whats in the $_SESSION['username'] variable? What is the name of the account you are trying to login as?

techninja

I thought the $_SESSION['username'] returns the current user who is logged in,
so in my previous example i was hoping that everyone who is logged in with ANY email ending with @domain.com will get logo.jpg.

so if i'm logging in with [email protected] i should get be getting the new logo.... right ?

rosali

PHP basics ... As skaero said figure out what $_SESSION['username'] returns. To do so, login and then insert in the config file ...

var_dump($_SESSION['username']);
exit;

... and finally refresh the page to see what is assigned to $_SESSION['username'].
Regards,
Rosali

techninja

I'm getting NULL.

I appreciate you spending the time replying. usually i'm able to find my way around those things, but i cant figure this one out.

rosali

Regards,
Rosali

rosali

Yes, it returns NULL. It seems that one of the programmers of Roundcube - ALEC - missed a change and we all trapped in. Obviously Roundcube initiates the session AFTER including the main config. So, the answer is, you can't do that by inserting PHP code into the main configuration file. You have to code a plugin or to jump into the core code in a hacky way. Please don't ask how to do that. That's too complicate to explain in few posts. As a starting point you could examine existing plugins and Roundcube's trac (http://trac.roundcube.net/wiki/Plugin_Hooks).
Regards,
Rosali