- Extended rcube_user::get_username (#1486707)

release-0.6
alecpl 15 years ago
parent f767654478
commit 8dfe51ef4e

@ -5,7 +5,7 @@
| program/include/rcube_user.inc | | program/include/rcube_user.inc |
| | | |
| This file is part of the RoundCube Webmail client | | This file is part of the RoundCube Webmail client |
| Copyright (C) 2005-2009, RoundCube Dev. - Switzerland | | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL | | Licensed under the GNU GPL |
| | | |
| PURPOSE: | | PURPOSE: |
@ -62,15 +62,30 @@ class rcube_user
/** /**
* Build a user name string (as e-mail address) * Build a user name string (as e-mail address)
* *
* @return string Full user name * @param string Username part (empty or 'local' or 'domain')
* @return string Full user name or its part
*/ */
function get_username() function get_username($part = null)
{ {
if ($this->data['username']) { if ($this->data['username']) {
if (!strpos($this->data['username'], '@')) list($local, $domain) = explode('@', $this->data['username']);
return $this->data['username'] . '@' . $this->data['mail_host'];
// at least we should always have the local part
if ($part == 'local') {
return $local;
}
// if no domain was provided use the default if available
if (empty($domain))
$domain = $this->data['mail_host'];
if ($part == 'domain') {
return $domain;
}
if (!empty($domain))
return $local . '@' . $domain;
else else
return $this->data['username']; return $local;
} }
return false; return false;

Loading…
Cancel
Save