Bug 4907 - imap acl manage
Summary: imap acl manage
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: php-imap (show other bugs)
Version: unstable
Hardware: all Linux
: P2 normal
Assignee: Alexey Gladkov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-27 18:26 MSD by Igor Muratov
Modified: 2006-11-24 05:46 MSK (History)
1 user (show)

See Also:


Attachments
add acl functionality (3.87 KB, patch)
2004-08-06 09:08 MSD, Igor Muratov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Muratov 2004-07-27 18:26:36 MSD
Plese apply this patch. This add acl management funccionality to the php-imap module


diff -b -r -U5 php4-4.2.3/ext/imap/php_imap.c php-4.2.3.patched/ext/imap/php_ima
p.c
--- php4-4.2.3/ext/imap/php_imap.c      Mon Aug 26 03:58:31 2002
+++ php-4.2.3.patched/ext/imap/php_imap.c       Fri May 16 16:23:12 2003
@@ -133,10 +133,11 @@
 
 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
        PHP_FE(imap_get_quota,                                                  
NULL)
        PHP_FE(imap_set_quota,                                                  
NULL)
        PHP_FE(imap_setacl,                                                     
        NULL)
+       PHP_FE(imap_getacl,                                                     
        NULL)
 #endif
 
        PHP_FE(imap_mail,                                                       
        NULL)
 
        PHP_FALIAS(imap_header,                 imap_headerinfo,        NULL)
@@ -384,10 +385,29 @@
                IMAPG(quota_usage) = qlist->usage;
                IMAPG(quota_limit) = qlist->limit;
        }
 }
 /* }}} */
+
+
+/* {{{ 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
 
 /* {{{ php_imap_init_globals
  */
 static void php_imap_init_globals(zend_imap_globals *imap_globals)
@@ -406,10 +426,11 @@
        imap_globals->imap_messages_tail = NIL;
        imap_globals->imap_folder_objects = NIL;
        imap_globals->imap_folder_objects_tail = NIL;
        imap_globals->imap_sfolder_objects = NIL;
        imap_globals->imap_sfolder_objects_tail = NIL;
+       imap_globals->imap_acl_list = NIL;
 
        imap_globals->folderlist_style = FLIST_ARRAY;
 }
 /* }}} */
 
@@ -1105,10 +1126,41 @@
 
        RETURN_LONG(imap_setacl(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox
), Z_STRVAL_PP(id), Z_STRVAL_PP(rights)));
 }
 /* }}} */
 
+
+/* {{{ 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, &mailb
ox) == FAILURE) {
+               ZEND_WRONG_PARAM_COUNT();
+       }
+
+       ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_im
ap);
+
+       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 */
 
 
 /* {{{ proto int imap_expunge(int stream_id)
    Permanently delete all messages marked for deletion */
diff -b -r -U5 php4-4.2.3/ext/imap/php_imap.h php-4.2.3.patched/ext/imap/php_ima
p.h
--- php4-4.2.3/ext/imap/php_imap.h      Mon Aug 26 03:58:32 2002
+++ php-4.2.3.patched/ext/imap/php_imap.h       Thu Apr 24 16:28:42 2003
@@ -177,10 +177,11 @@
 
 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
 PHP_FUNCTION(imap_get_quota);
 PHP_FUNCTION(imap_set_quota);
 PHP_FUNCTION(imap_setacl);
+PHP_FUNCTION(imap_getacl);
 #endif
 
 
 ZEND_BEGIN_MODULE_GLOBALS(imap)
        char *imap_user;
@@ -208,10 +209,11 @@
        unsigned long status_uidnext;
        unsigned long status_uidvalidity;
 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
        unsigned long quota_usage;
        unsigned long quota_limit;
+       pval *imap_acl_list;
 #endif
 ZEND_END_MODULE_GLOBALS(imap)
 
 #ifdef ZTS
 # define IMAPG(v) TSRMG(imap_globals_id, zend_imap_globals *, v)
Comment 1 Alexey Gladkov 2004-08-05 19:43:40 MSD
Ну ты совсем !!!
А аттачметн сделать было слабо ? 
Добавь в аттач плиз!!!! 
Comment 2 Igor Muratov 2004-08-06 09:08:39 MSD
Created attachment 545 [details]
add acl functionality

Исправляюсь :)
Comment 3 Alexey Gladkov 2004-08-06 13:38:25 MSD
Какова история этого патча?
Откуда он взялся?
Кто его поддерживает?
Comment 4 Alexey Gladkov 2004-08-06 21:02:08 MSD
Патч приложен к php-imap-4.3.9-alt0.cvs20040802 .