ispman/lib mailbox_actions.lib, 1.1, 1.1.4.1 mailbox_actions_cyrus.lib, 1.2, 1.2.2.1
Pedro Algarvio <[email protected]> Tue, 03 Oct 2006 12:29:12 +0000
| Newsgroups | gmane.comp.isp.ispman.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ispman/ispman/lib
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv25777/ispman/lib
Modified Files:
Tag: dev_1_3-cyrus_virtdomain2
mailbox_actions.lib mailbox_actions_cyrus.lib
Log Message:
Initial commit of seccond approach to cyrus virtdomains support.
Index: mailbox_actions.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/mailbox_actions.lib,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- mailbox_actions.lib 7 Sep 2006 21:24:56 -0000 1.1
+++ mailbox_actions.lib 3 Oct 2006 12:29:10 -0000 1.1.4.1
@@ -11,16 +11,5 @@
# load mailbox functions for this particular type
require "mailbox_actions_$imapServerBackend.lib";
-# helper function to convert email into uid notation
-sub email2uid {
- my $str = shift;
- ( $uid, $domain ) = split( '@', $str );
- if ($domain) {
- $domain =~ s/\./_/g;
- $str = join '_', ( $uid, $domain );
- }
- return $str;
-}
-
1;
Index: mailbox_actions_cyrus.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/mailbox_actions_cyrus.lib,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- mailbox_actions_cyrus.lib 12 Sep 2006 13:04:34 -0000 1.2
+++ mailbox_actions_cyrus.lib 3 Oct 2006 12:29:10 -0000 1.2.2.1
@@ -2,10 +2,38 @@
use IMAP::Admin;
+# helper function to convert email into uid notation
+sub email2uid {
+ my $str = shift;
+ ( $uid, $domain ) = split( '@', $str );
+ if ( $ISPMan::Config->{'AllowFullEmailLogins'} ) {
+ if ( $ISPMan::Config->{'CyrusUnixHierarchySep'} ) {
+ if ($uid) {
+ $uid =~s/\./\\./g;
+ }
+ }
+ if ($domain) {
+ $domain =~ s/\./\\./g;
+ $str = join '\@', ( $uid, $domain );
+ }
+ } else {
+ if ($domain) {
+ $domain =~ s/\./_/g;
+ $str = join '_', ( $uid, $domain );
+ }
+ }
+ return $str;
+}
+
# imap connection handle
my $imap_conn;
-my $imap_mailbox_prefix = $ispman->getConf("imapMailboxPrefix");
+my $imap_mailbox_prefix = $ispman->getConf('imapMailboxPrefix');
+if ( $ISPMan::Config->{'CyrusUnixHierarchySep'} ) {
+ $imap_mailbox_prefix .= '/';
+} else {
+ $imap_mailbox_prefix .= '.';
+}
sub _connect {
my $server = shift;
@@ -51,9 +79,51 @@
my $folder = shift;
$imap_conn or _connect($server);
- if ( $imap_conn->create( join ".", ( $mailbox, $folder ) ) ) {
- print $imap_conn->error."\n";
- return 1;
+
+ if ( $imap_conn->list($mailbox) ) {
+ # mailbox exists. Lets continue
+ if ( $ISPMan::Config->{'AllowFullEmailLogins'} ) {
+ if ( $ISPMan::Config->{'CyrusUnixHierarchySep'} ) {
+ $sep = '/';
+ } else {
+ $sep = '.';
+ }
+ ( $tuid, $tdomain ) = split( '@', $uid );
+ $mailbox = join "", ( $imap_mailbox_prefix, $tuid );
+ if ( $imap_conn->list( join '', ( $mailbox, $sep, $folder, '@', $tdomain ) ) ) {
+ # Already Exists
+ print "$folder on $mailbox\@$tdomain already exists. Skipping\n";
+ return 2;
+ } else {
+ my $tmailbox = join '', ( $mailbox, '@', $tdomain );
+ if ( $imap_conn->set_acl( $tmailbox, $ispman->getConf("imapAdminUsername"), "lrswipdca" ) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ print "Creating $folder on $mailbox\@$tdomain\n";
+ my $tmailbox = join '', ( $mailbox, $sep, $folder, '@', $tdomain );
+ if ( $imap_conn->create( $tmailbox ) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ }
+ } else {
+ if ( $imap_conn->list( join '.', ( $mailbox, $folder ) ) ) {
+ # Already Exists
+ print "$folder on $mailbox already exists. Skipping\n";
+ return 2;
+ } else {
+ if ( $imap_conn->set_acl( $mailbox, $ispman->getConf("imapAdminUsername"), "lrswipdca" ) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ print "Creating $folder on $mailbox\n";
+ if ( $imap_conn->create( join '.', ( $mailbox, $folder ) ) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ }
+ }
}
return 0;
}
@@ -72,7 +142,7 @@
sub set_quota {
my $server = shift;
- my $mailbox = $imap_mailbox_prefix . shift;
+ my $mailbox = $imap_mailbox_prefix . email2uid(shift);
my $quota = shift;
$imap_conn or _connect($server);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV