From: Dan Kalowsky Date: Tue, 20 May 2003 17:37:53 +0000 (+0000) Subject: Adding imap_getacl, patch provided by Holger Burbach X-Git-Tag: RELEASE_1_0_2~683 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53c90b2344e4b3c60e126ba32f5c1be4f696a727;p=php Adding imap_getacl, patch provided by Holger Burbach (holger.burbach@gonicus.de) @ Adding imap_getacl functionality. Function provided by Holger Burbach --- diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index b30ab3ee80..a8182768e5 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -136,6 +136,7 @@ function_entry imap_functions[] = { 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) @@ -360,6 +361,24 @@ void mail_getquota(MAILSTREAM *stream, char *qroot, QUOTALIST *qlist) } } /* }}} */ + + +/* {{{ mail_getquota + * + * 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); + } +} +/* }}} */ + #endif @@ -387,6 +406,7 @@ static void php_imap_init_globals(zend_imap_globals *imap_globals) imap_globals->folderlist_style = FLIST_ARRAY; #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001) imap_globals->quota_return = NIL; + imap_globals->imap_acl_list = NIL; #endif } /* }}} */ @@ -946,6 +966,38 @@ PHP_FUNCTION(imap_setacl) } /* }}} */ + +/* {{{ proto array imap_get_quota(int 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 */ + array_init(return_value); + + 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"); + RETURN_FALSE; + } + + IMAPG(imap_acl_list) = NIL; +} +/* }}} */ + #endif /* HAVE_IMAP2000 || HAVE_IMAP2001 */ diff --git a/ext/imap/php_imap.h b/ext/imap/php_imap.h index abfb87c4b8..a21fcddcba 100644 --- a/ext/imap/php_imap.h +++ b/ext/imap/php_imap.h @@ -171,6 +171,7 @@ PHP_FUNCTION(imap_get_quota); PHP_FUNCTION(imap_get_quotaroot); PHP_FUNCTION(imap_set_quota); PHP_FUNCTION(imap_setacl); +PHP_FUNCTION(imap_getacl); #endif @@ -201,6 +202,7 @@ ZEND_BEGIN_MODULE_GLOBALS(imap) unsigned long status_uidvalidity; #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001) zval **quota_return; + zval *imap_acl_list; #endif ZEND_END_MODULE_GLOBALS(imap)