~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to class/mime/AddressStructure.class.php

  • Committer: Bazaar Package Importer
  • Author(s): Sam Johnston
  • Date: 2004-02-04 01:42:12 UTC
  • Revision ID: james.westby@ubuntu.com-20040204014212-ek9533qvd2vo1wa1
Tags: upstream-1.5.0
ImportĀ upstreamĀ versionĀ 1.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * AddressStructure.class.php
 
5
 *
 
6
 * Copyright (c) 2003 The SquirrelMail Project Team
 
7
 * Licensed under the GNU GPL. For full terms see the file COPYING.
 
8
 *
 
9
 * This contains functions needed to handle mime messages.
 
10
 *
 
11
 * $Id: AddressStructure.class.php,v 1.7 2003/10/28 21:30:50 tassium Exp $
 
12
 * @package squirrelmail
 
13
 */
 
14
 
 
15
/**
 
16
 * Undocumented class
 
17
 * @package squirrelmail
 
18
 */
 
19
class AddressStructure {
 
20
    var $personal = '',
 
21
        $adl      = '',
 
22
        $mailbox  = '',
 
23
        $host     = '',
 
24
        $group    = '';
 
25
 
 
26
    function getAddress($full = true, $encoded = false) {
 
27
        $result = '';
 
28
        if (is_object($this)) {
 
29
            $email = ($this->host ? $this->mailbox.'@'.$this->host
 
30
                                  : $this->mailbox);
 
31
            $personal = trim($this->personal);
 
32
            $is_encoded = false;
 
33
            if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$personal,$reg)) {
 
34
                $is_encoded = true;
 
35
            }
 
36
            if ($personal) {
 
37
                if ($encoded && !$is_encoded) {
 
38
                    $personal_encoded = encodeHeader($personal);
 
39
                    if ($personal !== $personal_encoded) {
 
40
                        $personal = $personal_encoded;
 
41
                    } else {
 
42
                        $personal = '"'.$this->personal.'"';
 
43
                    }
 
44
                } else {
 
45
                    if (!$is_encoded) {
 
46
                        $personal = '"'.$this->personal.'"';
 
47
                    }
 
48
                }
 
49
                $addr = ($email ? $personal . ' <' .$email.'>'
 
50
                        : $this->personal);                                    
 
51
                $best_dpl = $this->personal;
 
52
            } else {
 
53
                $addr = $email;
 
54
                $best_dpl = $email;
 
55
            }
 
56
            $result = ($full ? $addr : $best_dpl);
 
57
        }
 
58
        return $result;
 
59
    }
 
60
    
 
61
    function getEncodedAddress() {
 
62
        return $this->getAddress(true, true);
 
63
    }
 
64
}
 
65
 
 
66
?>