php-imap-myrights.diff 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. diff -Naurp php-5.3.4RC1/ext/imap/php_imap.c php-5.3.4RC1.oden/ext/imap/php_imap.c
  2. --- php-5.3.4RC1/ext/imap/php_imap.c 2010-11-22 10:39:59.349863220 +0100
  3. +++ php-5.3.4RC1.oden/ext/imap/php_imap.c 2010-11-22 10:40:14.709956619 +0100
  4. @@ -163,6 +163,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_geta
  5. ZEND_ARG_INFO(0, stream_id)
  6. ZEND_ARG_INFO(0, mailbox)
  7. ZEND_END_ARG_INFO()
  8. +
  9. +ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_myrights, 0, 0, 2)
  10. + ZEND_ARG_INFO(0, stream_id)
  11. + ZEND_ARG_INFO(0, mailbox)
  12. +ZEND_END_ARG_INFO()
  13. #endif
  14. #if defined(HAVE_IMAP2005)
  15. ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_setannotation, 0, 0, 5)
  16. @@ -558,6 +563,7 @@ const zend_function_entry imap_functions
  17. PHP_FE(imap_set_quota, arginfo_imap_set_quota)
  18. PHP_FE(imap_setacl, arginfo_imap_setacl)
  19. PHP_FE(imap_getacl, arginfo_imap_getacl)
  20. + PHP_FE(imap_myrights, arginfo_imap_myrights)
  21. #endif
  22. #if defined(HAVE_IMAP2005)
  23. PHP_FE(imap_setannotation, arginfo_imap_setannotation)
  24. @@ -822,6 +828,20 @@ void mail_getacl(MAILSTREAM *stream, cha
  25. }
  26. }
  27. /* }}} */
  28. +
  29. +/* {{{ mail_myrights
  30. + *
  31. + * Mail MYRIGHTS callback
  32. + * Called via the mail_parameter function in c-client:src/c-client/mail.c
  33. + */
  34. +void mail_myrights(MAILSTREAM *stream, char *mailbox, char *rights)
  35. +{
  36. + TSRMLS_FETCH();
  37. +
  38. + ZVAL_STRING(IMAPG(imap_acl_list), rights, 1);
  39. +
  40. +}
  41. +/* }}} */
  42. #endif
  43. #if defined(HAVE_IMAP2005)
  44. @@ -1597,6 +1617,36 @@ PHP_FUNCTION(imap_getacl)
  45. IMAPG(imap_acl_list) = NIL;
  46. }
  47. /* }}} */
  48. +
  49. +/* {{{ proto string imap_myrights(resource stream_id, string mailbox)
  50. + Gets my rights (ACL) for a given mailbox */
  51. +PHP_FUNCTION(imap_myrights)
  52. +{
  53. + zval **streamind, **mailbox;
  54. + pils *imap_le_struct;
  55. +
  56. + if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mailbox) == FAILURE) {
  57. + ZEND_WRONG_PARAM_COUNT();
  58. + }
  59. +
  60. + ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
  61. +
  62. + convert_to_string_ex(mailbox);
  63. +
  64. + IMAPG(imap_acl_list) = return_value;
  65. +
  66. + /* set the callback for the GET_ACL function */
  67. + mail_parameters(NIL, SET_MYRIGHTS, (void *) mail_myrights);
  68. + if(!imap_myrights(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox))) {
  69. + php_error(E_WARNING, "c-client imap_myrights failed");
  70. + zval_dtor(return_value);
  71. + RETURN_FALSE;
  72. + }
  73. +
  74. + IMAPG(imap_acl_list) = NIL;
  75. +}
  76. +/* }}} */
  77. +
  78. #endif /* HAVE_IMAP2000 || HAVE_IMAP2001 */
  79. #if defined(HAVE_IMAP2005)
  80. diff -Naurp php-5.3.4RC1/ext/imap/php_imap.h php-5.3.4RC1.oden/ext/imap/php_imap.h
  81. --- php-5.3.4RC1/ext/imap/php_imap.h 2010-11-22 10:39:59.349863220 +0100
  82. +++ php-5.3.4RC1.oden/ext/imap/php_imap.h 2010-11-22 10:40:14.709956619 +0100
  83. @@ -183,6 +183,7 @@ PHP_FUNCTION(imap_get_quotaroot);
  84. PHP_FUNCTION(imap_set_quota);
  85. PHP_FUNCTION(imap_setacl);
  86. PHP_FUNCTION(imap_getacl);
  87. +PHP_FUNCTION(imap_myrights);
  88. #endif
  89. #if defined(HAVE_IMAP2005)
  90. PHP_FUNCTION(imap_setannotation);