Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16352 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84306 invoked by uid 1010); 2 Jun 2005 12:30:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 73725 invoked from network); 2 Jun 2005 12:12:15 -0000 Received: from unknown (HELO pb1.pair.com) (127.0.0.1) by localhost with SMTP; 2 Jun 2005 12:12:15 -0000 X-Host-Fingerprint: 81.169.173.116 rs02.intra2net.com Linux 2.5 (sometimes 2.4) (4) Received: from ([81.169.173.116:45946] helo=rs02.intra2net.com) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id 8C/5C-16559-5B6FE924 for ; Thu, 02 Jun 2005 08:08:21 -0400 Received: from intranator.m.i2n (unknown [172.16.1.99]) by rs02.intra2net.com (Postfix) with ESMTP id 9AE8F417B for ; Thu, 2 Jun 2005 14:08:17 +0200 (CEST) Received: from localhost (intranator.m.i2n [127.0.0.1]) by localhost (Postfix) with ESMTP id 610381AB for ; Thu, 2 Jun 2005 14:07:21 +0200 (CEST) Received: from storm.m.i2n (storm.m.i2n [172.16.1.2]) by intranator.m.i2n (Postfix) with ESMTP id 3FFFD126 for ; Thu, 2 Jun 2005 14:07:20 +0200 (CEST) Organization: Intra2net AG To: internals@lists.php.net Date: Thu, 2 Jun 2005 14:08:15 +0200 User-Agent: KMail/1.7.2 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_vavnCgjwEPEthGS" Message-ID: <200506021408.15687.thomas.jarosch@intra2net.com> X-Virus-Scanned: by Intranator (www.intranator.com) with AMaViS and F-Secure AntiVirus X-Spam-Status: hits=-9.3 tests=[ALL_TRUSTED=-3.3,BAYES_00=-6] X-Spam-Level: 907 Subject: [patch] imap_getacl PHP4 backport + comment typo fix From: thomas.jarosch@intra2net.com (Thomas Jarosch) --Boundary-00=_vavnCgjwEPEthGS Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --Boundary-00=_vavnCgjwEPEthGS Content-Type: text/x-diff; charset="us-ascii"; name="php-getacl-typo.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="php-getacl-typo.patch" 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 --Boundary-00=_vavnCgjwEPEthGS Content-Type: text/x-diff; charset="iso-8859-1"; name="php-getacl-backport.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="php-getacl-backport.patch" 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) --Boundary-00=_vavnCgjwEPEthGS--