Hi, attached patch backports PHP5's imap_getacl function to PHP4.
I also noticed a small typo in PHP5's mail_getacl() comment. Please CC: comments. Best regards, Thomas Jarosch
diff -u -r php-5.0.4/ext/imap/php_imap.c php-5.0.4.typo/ext/imap/php_imap.c --- php-5.0.4/ext/imap/php_imap.c 2005-01-25 15:22:13.000000000 +0100 +++ php-5.0.4.typo/ext/imap/php_imap.c 2005-06-02 13:31:54.750972809 +0200 @@ -373,7 +373,7 @@ /* }}} */ -/* {{{ mail_getquota +/* {{{ mail_getacl * * Mail GET_ACL callback * Called via the mail_parameter function in c-client:src/c-client/mail.c
diff -u -r php-4.3.11/ext/imap/php_imap.c php-4.3.11.getacl/ext/imap/php_imap.c --- php-4.3.11/ext/imap/php_imap.c 2005-01-25 15:23:37.000000000 +0100 +++ php-4.3.11.getacl/ext/imap/php_imap.c 2005-06-02 13:34:27.412014859 +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 -u -r php-4.3.11/ext/imap/php_imap.h php-4.3.11.getacl/ext/imap/php_imap.h --- php-4.3.11/ext/imap/php_imap.h 2003-06-13 16:45:36.000000000 +0200 +++ php-4.3.11.getacl/ext/imap/php_imap.h 2005-06-02 13:42:19.730013114 +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)
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php