From: Michael M Slusarz Date: Tue, 27 Oct 2009 23:05:15 +0000 (-0600) Subject: Add Horde_Imap_Client_Utils::createUrl() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=85b5fba2f7116198889fcc24833636e8bd85bfd8;p=horde.git Add Horde_Imap_Client_Utils::createUrl() --- diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php b/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php index 50ef1b28b..239c70e23 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php @@ -335,6 +335,69 @@ class Horde_Imap_Client_Utils } /** + * Create a POP3 (RFC 2384) or IMAP (RFC 5092/5593) URL. + * + * @param array $data The data used to create the URL. See the return + * value from parseUrl() for the available fields. + * REQUIRED: 'type', 'hostspec' + * + * @return string A URL string. + */ + public function createUrl($data) + { + $url = $data['type'] . '://'; + + if (isset($data['username'])) { + $url .= $data['username']; + } + + if (isset($data['auth'])) { + $url .= ';AUTH=' . $data['auth'] . '@'; + } elseif (isset($data['username'])) { + $url .= '@'; + } + + $url .= $data['hostspec']; + + if (isset($data['port']) && ($data['port'] != 143)) { + $url .= ':' . $data['port']; + } + + $url .= '/'; + + if ($data['type'] == 'imap') { + $url .= urlencode($data['mailbox']); + + if (!empty($data['uidvalidity'])) { + $url .= ';UIDVALIDITY=' . $data['uidvalidity']; + } + + if (isset($data['search'])) { + $url .= '?' . urlencode($data['search']); + } else { + if (isset($data['uid'])) { + $url .= '/;UID=' . $data['uid']; + } + + if (isset($data['section'])) { + $url .= '/;SECTION=' . $data['section']; + } + + if (isset($data['partial'])) { + $url .= '/;PARTIAL=' . $data['partial']; + } + + if (isset($data['urlauth'])) { + $url .= '/;URLAUTH=' . $data['urlauth']; + } + } + } + + + return $url; + } + + /** * Remove all prefix text of the subject that matches the subj-leader * ABNF. * diff --git a/framework/Imap_Client/package.xml b/framework/Imap_Client/package.xml index 851a237d5..843a350a5 100644 --- a/framework/Imap_Client/package.xml +++ b/framework/Imap_Client/package.xml @@ -31,7 +31,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> alpha LGPL - * Support SORT=DISPLAY extension. + * Add Horde_Imap_Client_Utils::createUrl(). + * Support SORT=DISPLAY extension. * Added search and thread (message list) caching. * Added PHP socket based POP3 driver. * Initial release