php7/php-imap-myrights.diff
2025-02-05 21:23:16 +00:00

92 lines
2.8 KiB
Diff

diff -Naurp php-5.3.4RC1/ext/imap/php_imap.c php-5.3.4RC1.oden/ext/imap/php_imap.c
--- php-5.3.4RC1/ext/imap/php_imap.c 2010-11-22 10:39:59.349863220 +0100
+++ php-5.3.4RC1.oden/ext/imap/php_imap.c 2010-11-22 10:40:14.709956619 +0100
@@ -163,6 +163,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_geta
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
#if defined(HAVE_IMAP2005)
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_setannotation, 0, 0, 5)
@@ -558,6 +563,7 @@ const zend_function_entry imap_functions
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
#if defined(HAVE_IMAP2005)
PHP_FE(imap_setannotation, arginfo_imap_setannotation)
@@ -822,6 +828,20 @@ void mail_getacl(MAILSTREAM *stream, cha
}
}
/* }}} */
+
+/* {{{ mail_myrights
+ *
+ * Mail MYRIGHTS callback
+ * Called via the mail_parameter function in c-client:src/c-client/mail.c
+ */
+void mail_myrights(MAILSTREAM *stream, char *mailbox, char *rights)
+{
+ TSRMLS_FETCH();
+
+ ZVAL_STRING(IMAPG(imap_acl_list), rights, 1);
+
+}
+/* }}} */
#endif
#if defined(HAVE_IMAP2005)
@@ -1597,6 +1617,36 @@ PHP_FUNCTION(imap_getacl)
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, **mailbox;
+ pils *imap_le_struct;
+
+ if(ZEND_NUM_ARGS() != 2 || zend_parse_parameters(2 TSRMLS_CC, "zz", &streamind, &mailbox) == FAILURE) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+
+ convert_to_string_ex(mailbox);
+
+ IMAPG(imap_acl_list) = return_value;
+
+ /* set the callback for the GET_ACL function */
+ mail_parameters(NIL, SET_MYRIGHTS, (void *) mail_myrights);
+ if(!imap_myrights(imap_le_struct->imap_stream, Z_STRVAL_P(*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 */
#if defined(HAVE_IMAP2005)
diff -Naurp php-5.3.4RC1/ext/imap/php_imap.h php-5.3.4RC1.oden/ext/imap/php_imap.h
--- php-5.3.4RC1/ext/imap/php_imap.h 2010-11-22 10:39:59.349863220 +0100
+++ php-5.3.4RC1.oden/ext/imap/php_imap.h 2010-11-22 10:40:14.709956619 +0100
@@ -183,6 +183,7 @@ PHP_FUNCTION(imap_get_quotaroot);
PHP_FUNCTION(imap_set_quota);
PHP_FUNCTION(imap_setacl);
PHP_FUNCTION(imap_getacl);
+PHP_FUNCTION(imap_myrights);
#endif
#if defined(HAVE_IMAP2005)
PHP_FUNCTION(imap_setannotation);