Req #21168 [Opn->Csd]: imap_search() does not support the OR keyword
Edit report at https://bugs.php.net/bug.php?id=21168&edit=1
ID: 21168
Updated by: kalle@php.net
Reported by: slusarz at colorado dot edu
Summary: imap_search() does not support the OR keyword
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: IMAP related
Operating System: *
PHP Version: *
-Assigned To:
+Assigned To: kalle
Block user comment: N
Private report: N
New Comment:
Gonna close this as we should rely on c-client to have the functionality like noted over a decade
ago
Previous Comments:
------------------------------------------------------------------------
[2010-02-01 14:42:28] dominik at dokdok dot com
This is related to http://bugs.php.net/bug.php?id=15238
------------------------------------------------------------------------
[2003-06-17 11:10:21] sniper@php.net
reclassified (not bug, a feature request)
------------------------------------------------------------------------
[2003-06-16 17:34:38] pollita@php.net
The troble is that extending imap_search to support the OR keyword (using the current c-client)
would require ugly lexing of the search parameter and is outside the scope of what PHP should be
doing to interface to the imap library.
That said, it doesn't seem unreasonable to introduce a completely separate interface which
allows the user to generate their own search programs. Something like:
$ret = imap_search_ex($stream, imap_search_or(imap_search_criteria("From =
'joe@example.com'"),imap_search_and(imap_search_criteria("From =
'bob@nowhere.org'"),imap_search_criteria("To =
'joe@example.com'"))));
which would be the equivalent of:
From = 'joe@example.com' OR (From = 'bob@nowhere.org' AND To =
'joe@example.com')
This is not a minor addition either, but is more within PHP's scope...
------------------------------------------------------------------------
[2003-06-16 17:18:36] chagenbu@php.net
Yes, it is a PHP problem. c-client has provided the necessary interfaces for a long time. Excuse the
large documentation dump, but:
Mailbox Searching
void mail_search (MAILSTREAM *stream,char *criteria);
void mail_search_full (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,
long flags);
stream stream to search
charset MIME character set to use when searching strings
pgm search program
flags option flags
This function causes a mailbox search, using the given MIME
charset (NIL means the default, US-ASCII) and the given search program.
A search program is a structure that holds the following data:
SEARCHSET *msgno; a set of message sequence numbers
SEARCHSET *uid; a set of unique identifiers
SEARCHOR *or; OR result of two search programs
SEARCHPGMLIST *not; AND result of list of NOT'ed search programs
SEARCHHEADER *header; message headers
STRINGLIST *bcc; string(s) appear in bcc list
STRINGLIST *body; string(s) appear in message body text
STRINGLIST *cc; string(s) appear in cc list
STRINGLIST *from; string(s) appear in from
STRINGLIST *keyword; user flag string(s) set
STRINGLIST *unkeyword; user flag strings() not set
STRINGLIST *subject; string(s) appear in subject
STRINGLIST *text; string(s) appear in message header or body
STRINGLIST *to; string(s) appear in to list
unsigned long larger; larger than this many octets
unsigned long smaller; smaller than this many octes
The following dates are in form:
((year - BASEYEAR) << 9) + (month << 5) + day
unsigned short sentbefore;
sent before this date
unsigned short senton; sent on this date
unsigned short sentsince;
sent since this date
unsigned short before; received before this date
unsigned short on; received on this date
unsigned short since; received since this date
unsigned int answered : 1;
message answered
unsigned int unanswered : 1;
message not answered
unsigned int deleted : 1;
message deleted
unsigned int undeleted : 1;
message not deleted
unsigned int draft : 1; message is a draft
unsigned int undraft : 1;
message is not a draft
unsigned int flagged : 1;
message flagged as urgent
unsigned int unflagged : 1;
message not flagged as urgent
unsigned int recent : 1;
message recent since last parse of mailbox
unsigned int old : 1; message not recent since last parse of mailbox
unsigned int seen : 1; message read
unsigned int unseen : 1;
message not read
The following auxillary structures are used by search programs:
SEARCHHEADER: header line searching
char *line; header line field name
char *text; text header line
SEARCHHEADER *next; next SEARCHHEADER in list (AND'ed)
SEARCHSET: message number set
unsigned long first; first number in set
unsigned long last; if non-zero, last number in set
SEARCHSET *next; next SEARCHSET in list (AND'ed)
SEARCHOR: two search programs, OR'ed together
SEARCHPGM *first; first program
SEARCHPGM *second; second program
SEARCHOR *next; next SEARCHOR in list
SEARCHPGMLIST: list of search programs
SEARCHPGM *pgm; search program (AND'd with others in list)
SEARCHPGMLIST *next; next SEARCHPGM in list
mail_search(), the older interface, accepts a search criteria
argument as a character string in IMAP2 (RFC-1176) format. Do not try
to use any IMAP4 search criteria with this interface.
So, we just need to use the right calls. It's a pain that c-client doesn't let you just
pass in the right search string, though.
------------------------------------------------------------------------
[2003-06-16 16:46:45] slusarz at colorado dot edu
The workaround we developed, using PHP code, can be found at:
http://cvs.horde.org/cvs.php/horde/lib/IMAP/Search.php
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=21168
--
Edit this bug report at https://bugs.php.net/bug.php?id=21168&edit=1
Thread (9 messages)