David Carter
2013-08-30 de8687f9f11d49d36b322af72f644f7c5a232b9f
program/lib/Roundcube/rcube_user.php
@@ -2,8 +2,6 @@
/*
 +-----------------------------------------------------------------------+
 | program/include/rcube_user.inc                                        |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2012, The Roundcube Dev Team                       |
 |                                                                       |
@@ -14,13 +12,11 @@
 | PURPOSE:                                                              |
 |   This class represents a system user linked and provides access      |
 |   to the related database records.                                    |
 |                                                                       |
 +-----------------------------------------------------------------------+
 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
 | Author: Aleksander Machniak <alec@alec.pl>                            |
 +-----------------------------------------------------------------------+
*/
/**
 * Class representing a system user
@@ -86,12 +82,17 @@
    /**
     * 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
@@ -235,10 +236,12 @@
    /**
     * Return a list of all identities linked with this user
     *
     * @param string $sql_add Optional WHERE clauses
     * @param string $sql_add   Optional WHERE clauses
     * @param bool   $formatted Format identity email and name
     *
     * @return array List of identities
     */
    function list_identities($sql_add = '')
    function list_identities($sql_add = '', $formatted = false)
    {
        $result = array();
@@ -250,6 +253,15 @@
            $this->ID);
        while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
            if ($formatted) {
                $ascii_email = format_email($sql_arr['email']);
                $utf8_email  = format_email(rcube_utils::idn_to_utf8($ascii_email));
                $sql_arr['email_ascii'] = $ascii_email;
                $sql_arr['email']       = $utf8_email;
                $sql_arr['ident']       = format_email_recipient($ascii_email, $sql_arr['name']);
            }
            $result[] = $sql_arr;
        }
@@ -483,9 +495,9 @@
            "INSERT INTO ".$dbh->table_name('users').
            " (created, last_login, username, mail_host, language)".
            " VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?)",
            strip_newlines($data['user']),
            strip_newlines($data['host']),
            strip_newlines($data['language']));
            $data['user'],
            $data['host'],
            $data['language']);
        if ($user_id = $dbh->insert_id('users')) {
            // create rcube_user instance to make plugin hooks work
@@ -505,7 +517,7 @@
                if (empty($user_email)) {
                    $user_email = strpos($data['user'], '@') ? $user : sprintf('%s@%s', $data['user'], $mail_domain);
                }
                $email_list[] = strip_newlines($user_email);
                $email_list[] = $user_email;
            }
            // identities_level check
            else if (count($email_list) > 1 && $rcube->config->get('identities_level', 0) > 1) {
@@ -535,7 +547,6 @@
                    $record['name'] = $user_name != $record['email'] ? $user_name : '';
                }
                $record['name']     = strip_newlines($record['name']);
                $record['user_id']  = $user_id;
                $record['standard'] = $standard;