ID: 21168 Comment by: dominik at dokdok dot com Reported By: slusarz at colorado dot edu Status: Open Bug Type: Feature/Change Request Operating System: unknown PHP Version: 4.3.3-dev, 5.0.0-dev New Comment:
This is related to http://bugs.php.net/bug.php?id=15238 Previous Comments: ------------------------------------------------------------------------ [2003-06-17 11:10:21] [email protected] reclassified (not bug, a feature request) ------------------------------------------------------------------------ [2003-06-16 17:34:38] [email protected] 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 = '[email protected]'"),imap_search_and(imap_search_criteria("From = '[email protected]'"),imap_search_criteria("To = '[email protected]'")))); which would be the equivalent of: >From = '[email protected]' OR (From = '[email protected]' AND To = '[email protected]') This is not a minor addition either, but is more within PHP's scope... ------------------------------------------------------------------------ [2003-06-16 17:18:36] [email protected] 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 ------------------------------------------------------------------------ [2003-06-16 16:35:15] [email protected] This is really not a php problem to solve, PHP uses mail_criteria(), an imap function used to determine the nature of the search. Unfortunately, this function only supports IMAP2 functionality and does not support IMAP4 directives, which is what prevents you from using OR keyword. Until the author of c-client decided to introduce mail_criteria() equivalent that supports IMAP4 don't expect to see OR keyword support in 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 http://bugs.php.net/21168 -- Edit this bug report at http://bugs.php.net/?id=21168&edit=1
