summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/password/password.php2
-rw-r--r--program/lib/Roundcube/rcube.php32
-rw-r--r--program/lib/Roundcube/rcube_ldap.php4
-rw-r--r--program/lib/Roundcube/rcube_smtp.php4
-rw-r--r--program/lib/Roundcube/rcube_user.php7
-rw-r--r--program/steps/settings/edit_identity.inc5
-rw-r--r--program/steps/settings/save_identity.inc5
7 files changed, 48 insertions, 11 deletions
diff --git a/plugins/password/password.php b/plugins/password/password.php
index 028a58d3e..806db0586 100644
--- a/plugins/password/password.php
+++ b/plugins/password/password.php
@@ -164,7 +164,7 @@ class password extends rcube_plugin
// Log password change
if ($rcmail->config->get('password_log')) {
write_log('password', sprintf('Password changed for user %s (ID: %d) from %s',
- $rcmail->user->get_username(), $rcmail->user->ID, rcmail_remote_ip()));
+ $rcmail->get_user_name(), $rcmail->user->ID, rcmail_remote_ip()));
}
}
else {
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 0eed6cf67..c798465ed 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -1203,8 +1203,38 @@ class rcube
if (is_object($this->user)) {
return $this->user->get_username();
}
+ else if (isset($_SESSION['username'])) {
+ return $_SESSION['username'];
+ }
+ }
- return null;
+
+ /**
+ * Getter for logged user email (derived from user name not identity).
+ *
+ * @return string User email address
+ */
+ public function get_user_email()
+ {
+ if (is_object($this->user)) {
+ return $this->user->get_username('mail');
+ }
+ }
+
+
+ /**
+ * Getter for logged user password.
+ *
+ * @return string User password
+ */
+ public function get_user_password()
+ {
+ if ($this->password) {
+ return $this->password;
+ }
+ else if ($_SESSION['password']) {
+ return $this->decrypt($_SESSION['password']);
+ }
}
}
diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php
index 34e37e3b9..c9a14d863 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -269,11 +269,11 @@ class rcube_ldap extends rcube_addressbook
if ($this->prop['user_specific']) {
// No password set, use the session password
if (empty($bind_pass)) {
- $bind_pass = $rcube->decrypt($_SESSION['password']);
+ $bind_pass = $rcube->get_user_password();
}
// Get the pieces needed for variable replacement.
- if ($fu = $rcube->get_user_name())
+ if ($fu = $rcube->get_user_email())
list($u, $d) = explode('@', $fu);
else
$d = $this->mail_domain;
diff --git a/program/lib/Roundcube/rcube_smtp.php b/program/lib/Roundcube/rcube_smtp.php
index 490ea8ad6..96534c0b8 100644
--- a/program/lib/Roundcube/rcube_smtp.php
+++ b/program/lib/Roundcube/rcube_smtp.php
@@ -135,8 +135,8 @@ class rcube_smtp
$this->conn->setTimeout($timeout);
}
- $smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']);
- $smtp_pass = str_replace('%p', $rcube->decrypt($_SESSION['password']), $CONFIG['smtp_pass']);
+ $smtp_user = str_replace('%u', $rcube->get_user_name(), $CONFIG['smtp_user']);
+ $smtp_pass = str_replace('%p', $rcube->get_user_password(), $CONFIG['smtp_pass']);
$smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type'];
if (!empty($CONFIG['smtp_auth_cid'])) {
diff --git a/program/lib/Roundcube/rcube_user.php b/program/lib/Roundcube/rcube_user.php
index 7bd73e08c..864f2e098 100644
--- a/program/lib/Roundcube/rcube_user.php
+++ b/program/lib/Roundcube/rcube_user.php
@@ -86,12 +86,17 @@ class rcube_user
/**
* Build a user name string (as e-mail address)
*
- * @param string $part Username part (empty or 'local' or 'domain')
+ * @param string $part Username part (empty or 'local' or 'domain', 'mail')
* @return string Full user name or its part
*/
function get_username($part = null)
{
if ($this->data['username']) {
+ // return real name
+ if (!$part) {
+ return $this->data['username'];
+ }
+
list($local, $domain) = explode('@', $this->data['username']);
// at least we should always have the local part
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
index f82169017..39076f408 100644
--- a/program/steps/settings/edit_identity.inc
+++ b/program/steps/settings/edit_identity.inc
@@ -42,8 +42,9 @@ else {
rcmail_overwrite_action('identities');
return;
}
- else if (IDENTITIES_LEVEL == 1)
- $IDENTITY_RECORD['email'] = $RCMAIL->user->get_username();
+ else if (IDENTITIES_LEVEL == 1) {
+ $IDENTITY_RECORD['email'] = $RCMAIL->get_user_email();
+ }
}
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
index 8515c44f1..d579ee61f 100644
--- a/program/steps/settings/save_identity.inc
+++ b/program/steps/settings/save_identity.inc
@@ -107,8 +107,9 @@ if ($_POST['_iid'])
// insert a new identity record
else if (IDENTITIES_LEVEL < 2)
{
- if (IDENTITIES_LEVEL == 1)
- $save_data['email'] = $RCMAIL->user->get_username();
+ if (IDENTITIES_LEVEL == 1) {
+ $save_data['email'] = $RCMAIL->get_user_email();
+ }
$plugin = $RCMAIL->plugins->exec_hook('identity_create', array('record' => $save_data));
$save_data = $plugin['record'];