Author Topic: Change logo based on login  (Read 22457 times)

Offline jeffshead

  • Full Member
  • ***
  • Posts: 71
Change logo based on login
« on: November 08, 2013, 02:58:57 AM »
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., me@mysite.com, me@mysite2.com) 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?

Offline alec

  • Hero Member
  • *****
  • Posts: 1,160
Re: Change logo based on login
« Reply #1 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';

Offline Dennis1993

  • Full Member
  • ***
  • Posts: 69
Re: Change logo based on login
« Reply #2 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.

Offline jeffshead

  • Full Member
  • ***
  • Posts: 71
Re: Change logo based on login
« Reply #3 on: November 08, 2013, 01:45:15 PM »
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?
« Last Edit: November 08, 2013, 01:50:08 PM by jeffshead »

Offline jeffshead

  • Full Member
  • ***
  • Posts: 71
Re: Change logo based on login
« Reply #4 on: November 08, 2013, 01:48:26 PM »
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.

Offline genevish

  • Newbie
  • *
  • Posts: 1
Re: Change logo based on login
« Reply #5 on: October 05, 2014, 11:11:38 AM »
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';
}

Offline techninja

  • Newbie
  • *
  • Posts: 5
Re: Change logo based on login
« Reply #6 on: October 29, 2014, 06:28:38 PM »
@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.


Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Re: Change logo based on login
« Reply #7 on: October 31, 2014, 09:22:23 AM »
Alec's code works unless you are talking about the login page where the user is not known.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline techninja

  • Newbie
  • *
  • Posts: 5
Re: Change logo based on login
« Reply #8 on: October 31, 2014, 12:25:18 PM »
@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:

Code: [Select]
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.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,556
    • http://SKaero.com/
Re: Change logo based on login
« Reply #9 on: October 31, 2014, 12:46:56 PM »
Whats in the $_SESSION['username'] variable? What is the name of the account you are trying to login as?

Offline techninja

  • Newbie
  • *
  • Posts: 5
Re: Change logo based on login
« Reply #10 on: October 31, 2014, 12:55:54 PM »
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 ninja@domain.com i should get be getting the new logo.... right ?

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Re: Change logo based on login
« Reply #11 on: October 31, 2014, 01:39:25 PM »
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
__________________
MyRoundcube Project (commercial)

Offline techninja

  • Newbie
  • *
  • Posts: 5
Re: Change logo based on login
« Reply #12 on: October 31, 2014, 01:58:38 PM »
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.
 

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Re: Change logo based on login
« Reply #13 on: October 31, 2014, 02:12:52 PM »
After login?
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Re: Change logo based on login
« Reply #14 on: October 31, 2014, 02:20:46 PM »
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
__________________
MyRoundcube Project (commercial)