IMP_Compose::_getMatchingIdentity PHP Method

_getMatchingIdentity() protected method

Get "tieto" identity information.
protected _getMatchingIdentity ( Horde_Mime_Headers $h, array $only = [] ) : integer
$h Horde_Mime_Headers The headers object for the message.
$only array Only use these headers.
return integer The matching identity. If no exact match, returns the default identity.
    protected function _getMatchingIdentity($h, array $only = array())
    {
        global $injector;
        $identity = $injector->getInstance('IMP_Identity');
        $msgAddresses = array();
        if (empty($only)) {
            /* Bug #9271: Check 'from' address first; if replying to a message
             * originally sent by user, this should be the identity used for
             * the reply also. */
            $only = array('from', 'to', 'cc', 'bcc');
        }
        foreach ($only as $val) {
            $msgAddresses[] = $h[$val];
        }
        $match = $identity->getMatchingIdentity(array_filter($msgAddresses));
        return is_null($match) ? $identity->getDefault() : $match;
    }