charset encode /decode fixes
[squirrelmail.git] / class / mime / AddressStructure.class.php
CommitLineData
19d470aa 1<?php
2
3/**
4 * AddressStructure.class.php
5 *
76911253 6 * Copyright (c) 2003 The SquirrelMail Project Team
19d470aa 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$
12 */
13
14class AddressStructure {
15 var $personal = '',
16 $adl = '',
17 $mailbox = '',
18 $host = '',
19 $group = '';
20
2c9ecd11 21 function getAddress($full = true, $encoded = false) {
19d470aa 22 $result = '';
23
24 if (is_object($this)) {
53bd5aa2 25 $email = ($this->host ? $this->mailbox.'@'.$this->host
26 : $this->mailbox);
2c9ecd11 27 $personal = trim($this->personal);
28 if ($personal) {
29 if ($encoded) {
30 $personal_encoded = encodeHeader($personal);
31 if ($personal !== $personal_encoded) {
32 $personal = $personal_encoded;
33 } else {
34 $personal = '"'.$this->personal.'"';
35 }
36 } else {
37 $personal = '"'.$this->personal.'"';
38 }
39 $addr = ($email ? $personal . ' <' .$email.'>'
53bd5aa2 40 : $this->personal);
19d470aa 41 $best_dpl = $this->personal;
42 } else {
43 $addr = $email;
44 $best_dpl = $email;
45 }
46 $result = ($full ? $addr : $best_dpl);
47 }
48 return $result;
49 }
2c9ecd11 50
51 function getEncodedAddress() {
52 return $this->getAddress(true, true);
53 }
19d470aa 54}
55
56?>