Attached is a patch which would allow the usage of most of the IMAP4 search criteria.
Please let me know if I should contact someone else (IMAP extension maintainer(s) ?) regarding this ... Dominik
On 2010-02-02, at 4:14 PM, Dominik Gehl wrote: > I continued thinking about this and came up with the idea of adding a new > resource 'imap_searchpgm' to the imap extension, which would then have quite > a good number of new functions: imap_searchprogram_new, > imap_searchprogram_sentsince, imap_searchprogram_since, > imap_searchprogram_before, imap_searchprogram_on etc. etc. > > The functions could then be defined along the following lines (untested code > ...): > > PHP_FUNCTION(imap_searchprogram_new) > { > int myargc = ZEND_NUM_ARGS(); > > if (myargc != 0) { > ZEND_WRONG_PARAM_COUNT(); > } > > pgm = mail_newsearchpgm(); > searchpgm = emalloc(sizeof(php_imap_searchpgm)); > searchpgm->searchpgm = pgm; > ZEND_REGISTER_RESOURCE(return_value, searchpgm, le_imap_searchpgm); > } > > PHP_FUNCTION(imap_searchprogram_sentsince) > { > zval *zpgm; > php_imap_searchpgm *pgm; > char *criterion = ""; > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zpgm, > &criterion) == FAILURE) { > RETURN_FALSE; > } > > ZEND_FETCH_RESOURCE(pgm, php_imap_search_pgm*, &zpgm, -1, "imapsearch", > le_imap_searchpgm); > > mail_criteria_date(&pgm->searchpgm->sentsince, &criterion); > > RETURN_TRUE; > } > > etc. etc. > > > And finally, the imap_search function could then accept either the criteria > string OR an imap_searchpgm resource. > > Ideas, comments ? > > Thanks, > Dominik > > > On 2010-02-01, at 10:06 AM, Dominik Gehl wrote: > >> Thanks a lot for your reply. I also found a second bug report related to >> this: http://bugs.php.net/bug.php?id=21168 >> >> Now, how about adding an imap_newsearchpgm function to the PHP imap >> extension which would do a call to mail_nsewsearchpgm inside c-client and >> return a structure allowing to contruct IMAP4 search programs (SEARCHPGM >> inside c-client) ? >> >> Anyone interested in this ? >> >> Dominik >> >> On 2010-01-30, at 6:22 PM, Joey Smith wrote: >> >>> There's an open bug on this, #15238 >>> (http://bugs.php.net/bug.php?id=15238&). I'm >>> sure patches would be welcomed. >>> >>> On Fri, Jan 29, 2010 at 03:49:18PM -0500, Dominik Gehl wrote: >>>> Hi, >>>> >>>> I noticed that the imap extension seems to support only IMAP2 search >>>> criteria. >>>> >>>> This is caused by the fact that in ext/imap/php_imap.c, the imap_search >>>> function uses a call to mail_criteria. And >>>> the University of Washington IMAP toolkit mentions in docs/internal.txt: >>>> >>>> SEARCHPGM *mail_criteria (char *criteria); >>>> criteria IMAP2-format search criteria string >>>> >>>> This function accepts an IMAP2-format search criteria string and >>>> parses it. If the parse is successful, it returns a search program >>>> suitable for use in mail_search_full(). >>>> WARNING: This function does not accept IMAP4 search criteria. >>>> >>>> >>>> Is there any specific reason why PHP uses this mail_criteria call ? It >>>> really would be nice to be able to use IMAP4 search criteria ! >>>> >>>> Thanks, >>>> Dominik >>>> >>>> -- >>>> PHP Internals - PHP Runtime Development Mailing List >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>> >> >
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php