Roundcube Community Forum

Release Support => Pending Issues => Topic started by: jeffshead on November 08, 2013, 02:58:57 AM

Title: Change logo based on login
Post by: jeffshead 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?
Title: Re: Change logo based on login
Post by: 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';
Title: Re: Change logo based on login
Post by: 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.
Title: Re: Change logo based on login
Post by: jeffshead 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?
Title: Re: Change logo based on login
Post by: jeffshead 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.
Title: Re: Change logo based on login
Post by: genevish 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';
}
Title: Re: Change logo based on login
Post by: techninja 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.

Title: Re: Change logo based on login
Post by: rosali 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.
Title: Re: Change logo based on login
Post by: techninja 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.
Title: Re: Change logo based on login
Post by: SKaero 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?
Title: Re: Change logo based on login
Post by: techninja 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 ?
Title: Re: Change logo based on login
Post by: rosali 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'].
Title: Re: Change logo based on login
Post by: techninja 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.
 
Title: Re: Change logo based on login
Post by: rosali on October 31, 2014, 02:12:52 PM
After login?
Title: Re: Change logo based on login
Post by: rosali 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).
Title: Re: Change logo based on login
Post by: techninja on October 31, 2014, 02:25:41 PM
I see. thank you,

 i'll start working on that and will post a solution if i'm able to find one.
Title: Re: Change logo based on login
Post by: Kudalufi on May 30, 2015, 12:26:20 PM
Hope this topic isn't too old to resurrect.

I suspect if anyone comes along looking for a solution to this it will be easier, instead of trying to find a configuration setting or PHP function that will work, to instead use the roundcube database.

All you would need to do to accomplish this goal is a) create a skin for each login domain, and b) create an entry in the roundcube database for each user as you create the user that adds the configuration setting for that user's skin.  This is stored in the preferences column, which holds an array of all user preferences.  If you add the row for a user when that user is created, then you don't need to try and parse that array to add to it, you can just set it with your initial user defaults.  Like this, which sets the skin to "yourskin" and turns on the preview pane:
Code: [Select]
a:2:{s:4:"skin";s:8:"yourskin";s:12:"preview_pane";b:1;}
I, for one, use postfixadmin to create virtual domains, and the virtual domain admins use it to create users.  It has a wonderful capability to have user scripts that are executed after a user is created.  That can be used to insert the row into the roundcube automagically on user creation.
Title: Re: Change logo based on login
Post by: MarzuQnx on August 06, 2015, 09:55:54 AM
Hi, I managed to change the logo in login page but what I'am confusing it's not working in after login

what I do is by editing the skin template login.html :

Code: [Select]
<!-- <roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" /> -->

<roundcube:if condition="$_SERVER['HTTP_HOST'] == 'mail.domain-abc.co'" />
    <roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" />
<roundcube:elseif condition="$_SERVER['HTTP_HOST'] == 'domain-abc.co'" />
    <roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" />
<roundcube:else />
    <roundcube:object name="logo" src="/images/logo-other.png" id="logo" />
<roundcube:endif />


above code doesn't work on header.html.

 :'(

Regards,
MarzuQnx
Title: Re: Change logo based on login
Post by: JohnDoh on August 06, 2015, 10:55:22 AM
I don't think you can use arbitrary PHP in Roundcube template conditions and in any case there is no need since the $config['skin_logo'] (as mentioned elsewhere in this thread) is the proper way of doing what you want.
Title: Re: Change logo based on login
Post by: MarzuQnx on August 06, 2015, 10:52:21 PM
I don't think you can use arbitrary PHP in Roundcube template conditions and in any case there is no need since the $config['skin_logo'] (as mentioned elsewhere in this thread) is the proper way of doing what you want.

please guide me there mate, I already try $config['skin_logo'] and not yet succeed :)

Regards,
Title: Re: Change logo based on login
Post by: maniekandan5 on May 30, 2020, 12:07:04 AM
Actually roundcube is very flexible to change many things. All the attributes are in the main config file to play over.

ref: https://vvcares.com/blog/post/how-to-change-roundcube-webmail-title-logo