$qresync = isset($this->_init['enabled']['QRESYNC']);
$seq = !empty($options['sequence']);
+ /* Make sure 'ids' is defined. */
+ if (!isset($options['ids'])) {
+ $options['ids'] = array();
+ }
+
/* The 'vanished' modifier requires QRESYNC, 'changedsince', and
* !'sequence'. */
if (!empty($options['vanished']) &&
* information (RFC 3501 [6.4.8]). Don't add to criteria because it
* simply creates a longer FETCH command. */
- /* If using cache, we store by UID so we need to return UIDs. */
- if ($seq && !empty($cf)) {
- $criteria[Horde_Imap_Client::FETCH_UID] = true;
- }
-
$this->openMailbox($mailbox, Horde_Imap_Client::OPEN_AUTO);
- /* We need the UIDVALIDITY for the current mailbox. */
- $status_res = $this->status($this->_selected, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDVALIDITY);
+ if (!empty($cf)) {
+ /* We need the UIDVALIDITY for the current mailbox. */
+ $status_res = $this->status($this->_selected, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDVALIDITY);
+
+ /* If using cache, we store by UID so we need to return UIDs. */
+ if ($seq) {
+ $criteria[Horde_Imap_Client::FETCH_UID] = true;
+ }
+ }
/* Determine if caching is available and if anything in $criteria is
* cacheable. Do some sanity checking on criteria also. */
* Test script for the Horde_Imap_Client:: library.
*
* Usage:
- * test_client.php [[username] [[password] [[IMAP URL]]]]
+ * test_client.php [[username] [[password] [[IMAP URL] [driver]]]]
*
* Username/password/hostspec on the command line will override the $params
* values.
+ * Driver on the command line will override the $driver value.
*
* TODO:
* + Test for 'charset' searching
$params = array_merge($params, $imap_utils->parseUrl($argv[3]));
}
-function exception_handler($exception) {
+if (!empty($argv[4])) {
+ $driver = $argv[4];
+}
+
+function exception_handler($e) {
print "\n=====================================\n" .
- 'UNCAUGHT EXCEPTION: ' . $exception->getMessage() .
+ 'UNCAUGHT EXCEPTION: ' . $e->getMessage() .
"\n=====================================\n";
}
set_exception_handler('exception_handler');
$imap_client = Horde_Imap_Client::getInstance($driver, $params);
if ($driver == 'Cclient_Pop3') {
+ $pop3 = true;
$test_mbox = $test_mbox_utf8 = 'INBOX';
+} else {
+ $pop3 = false;
}
$use_imapproxy = false;
$simple_fetch = array(
Horde_Imap_Client::FETCH_STRUCTURE => true,
Horde_Imap_Client::FETCH_ENVELOPE => true,
- Horde_Imap_Client::FETCH_FLAGS => true,
Horde_Imap_Client::FETCH_DATE => true,
Horde_Imap_Client::FETCH_SIZE => true
);
+if (!$pop3) {
+ $simple_fetch[Horde_Imap_Client::FETCH_FLAGS] = true;
+}
+
print "\nSimple fetch example:\n";
try {
print_r($imap_client->fetch($test_mbox, $simple_fetch));
print "Fetch: FAILED\n";
// If POP3, try easier fetch criteria
- if ($driver == 'Cclient_Pop3') {
+ if ($pop3) {
try {
print_r($imap_client->fetch('INBOX', array(
Horde_Imap_Client::FETCH_FULLMSG => array(