Patch imap_myrights.patch for IMAP related Bug #43948
Patch version 2010-07-29 08:48 UTC
Return to Bug #43948 |
Download this patch
Patch Revisions:
Developer: mkoppanen@php.net
Index: ext/imap/tests/imap_myrights.phpt
===================================================================
--- ext/imap/tests/imap_myrights.phpt (revision 0)
+++ ext/imap/tests/imap_myrights.phpt (revision 0)
@@ -0,0 +1,45 @@
+--TEST--
+Test imap_myrights() function : basic functionality
+--CREDITS--
+Mikko Koppanen
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+if (!function_exists('imap_myrights'))
+ die("SKIP imap_myrights does not exist");
+?>
+--FILE--
+<?php
+
+require_once(dirname(__FILE__).'/imap_include.inc');
+
+$mbox_name = "";
+
+$imap_stream = setup_test_mailbox("", 1, $mbox_name);
+if (!is_resource($imap_stream)) {
+ exit("TEST FAILED: Unable to create test mailbox\n");
+}
+
+$check = imap_check($imap_stream);
+$rights = @imap_myrights($imap_stream, $mbox_name);
+
+if (!$rights) {
+ imap_errors();
+ echo "Rights: not supported\n";
+} else {
+ echo "Rights: $rights\n";
+}
+
+imap_close($imap_stream);
+
+echo "OK\n";
+?>
+--CLEAN--
+<?php
+require_once('clean.inc');
+?>
+--EXPECTF--
+Create a temporary mailbox and add 1 msgs
+.. mailbox '%s.phpttest' created
+Rights: %s
+OK
\ No newline at end of file
Index: ext/imap/php_imap.h
===================================================================
--- ext/imap/php_imap.h (revision 301655)
+++ ext/imap/php_imap.h (working copy)
@@ -179,6 +179,7 @@
PHP_FUNCTION(imap_set_quota);
PHP_FUNCTION(imap_setacl);
PHP_FUNCTION(imap_getacl);
+PHP_FUNCTION(imap_myrights);
#endif
Index: ext/imap/php_imap.c
===================================================================
--- ext/imap/php_imap.c (revision 301655)
+++ ext/imap/php_imap.c (working copy)
@@ -163,6 +163,11 @@
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_myrights, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_expunge, 0, 0, 1)
@@ -536,6 +541,7 @@
PHP_FE(imap_set_quota, arginfo_imap_set_quota)
PHP_FE(imap_setacl, arginfo_imap_setacl)
PHP_FE(imap_getacl, arginfo_imap_getacl)
+ PHP_FE(imap_myrights, arginfo_imap_myrights)
#endif
PHP_FE(imap_mail, arginfo_imap_mail)
@@ -796,6 +802,18 @@
}
}
/* }}} */
+
+/* {{{ mail_myrights
+ *
+ * Mail MYRIGHTS callback
+ * Called via the mail_parameter function in c-client:src/c-client/mail.c
+ */
+static void mail_myrights(MAILSTREAM *stream, char *mailbox, char *rights)
+{
+ TSRMLS_FETCH();
+ ZVAL_STRING(IMAPG(imap_acl_list), rights, 1);
+}
+/* }}} */
#endif
/* {{{ PHP_GINIT_FUNCTION
@@ -1536,6 +1554,36 @@
IMAPG(imap_acl_list) = NIL;
}
/* }}} */
+
+/* {{{ proto string imap_myrights(resource stream_id, string mailbox)
+ Gets my rights (ACL) for a given mailbox */
+PHP_FUNCTION(imap_myrights)
+{
+ zval *streamind;
+ char *mailbox;
+ int mailbox_len;
+ pils *imap_le_struct;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &mailbox, &mailbox_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
+
+ IMAPG(imap_acl_list) = return_value;
+
+ /* set the callback for the GET_ACL function */
+ mail_parameters(NIL, GET_MYRIGHTS, (void *) mail_myrights);
+ if(!imap_myrights(imap_le_struct->imap_stream, mailbox)) {
+ php_error(E_WARNING, "c-client imap_myrights failed");
+ zval_dtor(return_value);
+ RETURN_FALSE;
+ }
+
+ IMAPG(imap_acl_list) = NIL;
+}
+/* }}} */
+
#endif /* HAVE_IMAP2000 || HAVE_IMAP2001 */
/* {{{ proto bool imap_expunge(resource stream_id)
|