roundcubemail/program/lib/Roundcube/rcube_addressbook.php
public static function compose_display_name($contact, $full_email = false)
    {
        $contact = rcube::get_instance()->plugins->exec_hook('contact_displayname', $contact);
        $fn = $contact['name'];

        // default display name composition according to vcard standard
        if (!$fn) {
            $fn = join(' ', array_filter(array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix'])));
            $fn = trim(preg_replace('/\s+/u', ' ', $fn));
        }

        // use email address part for name
        $email = self::get_col_values('email', $contact, true);
        $email = $email[0];

        if ($email && (empty($fn) || $fn == $email)) {
            // return full email
            if ($full_email)
                return $email;

            list($emailname) = explode('@', $email);
            if (preg_match('/(.*)[\.\-\_](.*)/', $emailname, $match))
                $fn = trim(ucfirst($match[1]).' '.ucfirst($match[2]));
            else
                $fn = ucfirst($emailname);
        }

        return $fn;
    }
public static function compose_display_name($contact, $full_email = false)
    {
        $contact = rcube::get_instance()->plugins->exec_hook('contact_displayname', $contact);
        $fn = $contact['name'];

        // default display name composition according to vcard standard
        if (!$fn) {
            $fn = join(' ', array_filter(array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix'])));
            $fn = trim(preg_replace('/\s+/u', ' ', $fn));
        }

        // use email address part for name
        $email = self::get_col_values('email', $contact, true);
        $email = $email[0];

        if ($email && (empty($fn) || $fn == $email)) {
            // return full email
            if ($full_email)
                return $email;

            list($emailname) = explode('@', $email);
            if (preg_match('/(.*)[\.\-\_](.*)/', $emailname, $match))
                $fn = trim(ucfirst($match[1]).' '.ucfirst($match[2]));
            else
                $fn = ucfirst($emailname);
        }

        return $fn;
    }
public static function compose_display_name ( $ contact , $ full_email = false ) { $ contact = rcube :: get_instance ( ) -> plugins -> exec_hook ( 'contact_displayname' , $ contact ) ; $ fn = $ contact [ 'name' ] ; // default display name composition according to vcard standard if ( ! $ fn ) { $ fn = join ( ' ' , array_filter ( array ( $ contact [ 'prefix' ] , $ contact [ 'firstname' ] , $ contact [ 'middlename' ] , $ contact [ 'surname' ] , $ contact [ 'suffix' ] ) ) ) ; $ fn = trim ( preg_replace ( '/\s+/u' , ' ' , $ fn ) ) ; } // use email address part for name $ email = self :: get_col_values ( 'email' , $ contact , true ) ; $ email = $ email [ 0 ] ; if ( $ email && ( empty ( $ fn ) || $ fn == $ email ) ) { // return full email if ( $ full_email ) return $ email ; list ( $ emailname ) = explode ( '@' , $ email ) ; if ( preg_match ( '/(.*)[\.\-\_](.*)/' , $ emailname , $ match ) ) $ fn = trim ( ucfirst ( $ match [ 1 ] ) . ' ' . ucfirst ( $ match [ 2 ] ) ) ; else $ fn = ucfirst ( $ emailname ) ; } return $ fn ; }
Compose a valid display name from the given structured contact data

@param array $contact    Hash array with contact data as key-value pairs
@param bool  $full_email Don't attempt to extract components from the email address

@return string Display name
Compose a valid display name from the given structured contact data