diff -Naur php-4.4.0/ext/imap/php_imap.c php-4.4.0.oden/ext/imap/php_imap.c --- php-4.4.0/ext/imap/php_imap.c 2005-04-08 17:04:52.000000000 +0200 +++ php-4.4.0.oden/ext/imap/php_imap.c 2005-07-12 00:39:34.932256537 +0200 @@ -139,6 +139,7 @@ PHP_FE(imap_get_quotaroot, NULL) PHP_FE(imap_set_quota, NULL) PHP_FE(imap_setacl, NULL) + PHP_FE(imap_getacl, NULL) #endif PHP_FE(imap_mail, NULL) @@ -378,6 +379,21 @@ /* }}} */ #endif +/* {{{ mail_getacl + * + * Mail GET_ACL callback + * Called via the mail_parameter function in c-client:src/c-client/mail.c + */ +void mail_getacl(MAILSTREAM *stream, char *mailbox, ACLLIST *alist) +{ + TSRMLS_FETCH(); + + /* walk through the ACLLIST */ + for(; alist; alist = alist->next) { + add_assoc_stringl(IMAPG(imap_acl_list), alist->identifier, alist->rights, strlen(alist->rights), 1); + } +} +/* }}} */ /* {{{ php_imap_init_globals */ @@ -988,6 +1004,40 @@ } /* }}} */ +/* {{{ proto array imap_getacl(resource stream_id, string mailbox) + Gets the ACL for a given mailbox */ +PHP_FUNCTION(imap_getacl) +{ + 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); + + /* initializing the special array for the return values */ + if (array_init(return_value) == FAILURE) { + RETURN_FALSE; + } + + IMAPG(imap_acl_list) = return_value; + + /* set the callback for the GET_ACL function */ + 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; +} +/* }}} */ + #endif /* HAVE_IMAP2000 || HAVE_IMAP2001 */ diff -Naur php-4.4.0/ext/imap/php_imap.h php-4.4.0.oden/ext/imap/php_imap.h --- php-4.4.0/ext/imap/php_imap.h 2003-06-13 16:45:36.000000000 +0200 +++ php-4.4.0.oden/ext/imap/php_imap.h 2005-07-12 00:39:34.933256563 +0200 @@ -172,6 +172,7 @@ PHP_FUNCTION(imap_get_quotaroot); PHP_FUNCTION(imap_set_quota); PHP_FUNCTION(imap_setacl); +PHP_FUNCTION(imap_getacl); #endif @@ -202,6 +203,7 @@ unsigned long status_uidvalidity; #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001) zval **quota_return; + zval *imap_acl_list; #endif ZEND_END_MODULE_GLOBALS(imap)