On Wed, August 20, 2008 10:55 pm, Jani Taskinen wrote:
> Diego Woitasen kirjoitti:
>> Hi,
>> I attach the patch that adds imap_myrights function to IMAP module.
>> MYRIGHTS is a standard IMAP command defined in RFC 2086.
>>
>> diff -u -r php-5.2.6/ext/imap/php_imap.c
>> php-myrights/ext/imap/php_imap.c
>> --- php-5.2.6/ext/imap/php_imap.c Thu Apr 17 13:04:49 2008
>> +++ php-myrights/ext/imap/php_imap.c Tue Jun 3 18:06:37 2008
>> @@ -154,6 +154,7 @@
>> PHP_FE(imap_set_quota,
>> NULL)
>> PHP_FE(imap_setacl,
>> NULL)
>> PHP_FE(imap_getacl,
>> NULL)
>> + PHP_FE(imap_myrights,
>> NULL)
>> #endif
>>
>> PHP_FE(imap_mail,
>> NULL)
>> @@ -413,6 +414,20 @@
>> }
>> /* }}} */
>>
>> +/* {{{ mail_myrights
>> + *
>> + * Mail MYRIGHTS callback
>> + * Called via the mail_parameter function in
>> c-client:src/c-client/mail.c
>> + */
>> +void mail_myrights(MAILSTREAM *stream, char *mailbox, char *rights)
>> +{
>> + TSRMLS_FETCH();
>> +
>> + ZVAL_STRING(IMAPG(imap_acl_list), rights, 1)
>> +
>> +}
>> +/* }}} */
>> +
>> #endif
>
> Does this really work? You're blindly overwriting the acl global,
> AFAICT..?
> Or is that intentional?
Yes, it works. I use the imap_getacl() function as example to write
imap_myrights(). What's the problem with overwriting acl global?
>
>>
>>
>> @@ -1087,6 +1102,35 @@
>> mail_parameters(NIL, SET_ACL, (void *) mail_getacl);
>> if(!imap_getacl(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox))) {
>> php_error(E_WARNING, "c-client imap_getacl failed");
>> + zval_dtor(return_value);
>> + RETURN_FALSE;
>> + }
>> +
>> + IMAPG(imap_acl_list) = NIL;
>> +}
>> +/* }}} */
>
> ..and again..
>
>> +
>> +/* {{{ proto string imap_myrights(resource stream_id, string mailbox)
>> + Gets my rights (ACL) for a given mailbox */
>> +PHP_FUNCTION(imap_myrights)
>> +{
>> + zval **streamind, **mailbox;
>> + pils *imap_le_struct;
>> +
>> + if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind,
>> &mailbox) == FAILURE) {
>> + ZEND_WRONG_PARAM_COUNT();
>> + }
>> +
>> + ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap",
>> le_imap);
>> +
>> + convert_to_string_ex(mailbox);
>> +
>> + IMAPG(imap_acl_list) = return_value;
>> +
>> + /* set the callback for the GET_ACL function */
>> + mail_parameters(NIL, SET_MYRIGHTS, (void *) mail_myrights);
>
> SET? Not GET? In what c-client version was this added anyway..?
Yes, if I didn't misundertand the API. GET/SET are used to set or get API
parameters, they don't anything at IMAP protocol. See imap_getacl()
function for example.
I'm using imap 2006k.
>
> --Jani
>
>
>> + if(!imap_myrights(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox)))
>> {
>> + php_error(E_WARNING, "c-client imap_myrights failed");
>> zval_dtor(return_value);
>> RETURN_FALSE;
>> }
>> diff -u -r php-5.2.6/ext/imap/php_imap.h
>> php-myrights/ext/imap/php_imap.h
>> --- php-5.2.6/ext/imap/php_imap.h Mon Dec 31 08:20:07 2007
>> +++ php-myrights/ext/imap/php_imap.h Tue Jun 3 18:05:14 2008
>> @@ -174,6 +174,7 @@
>> PHP_FUNCTION(imap_set_quota);
>> PHP_FUNCTION(imap_setacl);
>> PHP_FUNCTION(imap_getacl);
>> +PHP_FUNCTION(imap_myrights);
>> #endif
>>
>>
>>
>>
>
>
--
Diego Woitasen
XTECH - Soluciones Linux para empresas
(54) 011 5219-0678
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php