We're living in 2004 now... perl is your friend for these kinds of things :)
[squirrelmail.git] / class / mime / AddressStructure.class.php
1 <?php
2
3 /**
4 * AddressStructure.class.php
5 *
6 * Copyright (c) 2003-2004 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 * @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 ?>