After getting the ACL's from imap_getacl you want to set them for a user on any mailbox folder like this:
foreach ( $Folders as $key => $Maildir ) {
imap_setacl($domains , "user/john.doe/".$Maildir , $userid, "lrswipkxte");
}
You can use a form that translates the ACLs like the following (thanks to cyradm manual):
switch ($right) {
case "read" : $aclstring = "lrs";
break;
case "post" : $aclstring = "lrsp";
break;
case "append" : $aclstring = "lrsip";
break;
case "write" : $aclstring = "lrswipkxte";
break;
case "delete" : $aclstring = "lrxte";
break;
case "all" : $aclstring = "lrswipkxte";
break;
case "admin" : $aclstring = "lrswipkxtea";
break;
case "none" : $aclstring = "";
break;
}