1382493124a76dfaee676735c6d362b755491482
[squirrelmail.git] / class / mime / AddressStructure.class.php
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$
12 */
13
14 class AddressStructure {
15 var $personal = '',
16 $adl = '',
17 $mailbox = '',
18 $host = '',
19 $group = '';
20
21 function getAddress($full = true, $encoded = false) {
22 $result = '';
23
24 if (is_object($this)) {
25 $email = ($this->host ? $this->mailbox.'@'.$this->host
26 : $this->mailbox);
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.'>'
40 : $this->personal);
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 }
50
51 function getEncodedAddress() {
52 return $this->getAddress(true, true);
53 }
54 }
55
56 ?>