]> granicus.if.org Git - php/commitdiff
Adding imap_getacl, patch provided by Holger Burbach
authorDan Kalowsky <kalowsky@php.net>
Tue, 20 May 2003 17:37:53 +0000 (17:37 +0000)
committerDan Kalowsky <kalowsky@php.net>
Tue, 20 May 2003 17:37:53 +0000 (17:37 +0000)
(holger.burbach@gonicus.de)
@  Adding imap_getacl functionality.  Function provided by Holger Burbach

ext/imap/php_imap.c
ext/imap/php_imap.h

index b30ab3ee80dd646c53c944de88a51335df39a630..a8182768e52eb8266af6403c198bc1fbcf6ccb39 100644 (file)
@@ -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 */
 
 
index abfb87c4b8b4e1e6e4f26bd2e41989adfaf9aac4..a21fcddcbae55e464f90fe2d9ddc6cfc90305e19 100644 (file)
@@ -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)