ispman/lib mailbox_actions_cyrus.lib,1.2.2.2,1.2.2.3
Pedro Algarvio <[email protected]> Thu, 05 Oct 2006 09:43:29 +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-serv13425/lib
Modified Files:
Tag: dev_1_3-cyrus_virtdomain2
mailbox_actions_cyrus.lib
Log Message:
Reverted to original, but while deleting a user, if running in cyrus virtdomains mode, the user's DN branch is not deleted right away, instead it adds a new process which calls a task just for this, why, because mailbox_actions_cyrus.lib fetches the correct mailbox naming from ldap.
Index: mailbox_actions_cyrus.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/mailbox_actions_cyrus.lib,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -d -r1.2.2.2 -r1.2.2.3
--- mailbox_actions_cyrus.lib 3 Oct 2006 16:52:20 -0000 1.2.2.2
+++ mailbox_actions_cyrus.lib 5 Oct 2006 09:43:26 -0000 1.2.2.3
@@ -25,14 +25,25 @@
return $str;
}
+sub get_correct_mailbox {
+ my $mbox = shift;
+ if ( lc( $ISPMan::Config->{'AllowFullEmailLogins'} ) == 'yes' ) {
+ $tmbox = $ispman->getUserInfo($mbox);
+ return $tmbox->{'mailLocalAddress'};
+ }
+ return $mbox;
+}
+
# imap connection handle
my $imap_conn;
my $imap_mailbox_prefix = $ispman->getConf('imapMailboxPrefix');
+my $sep = '.';
if ( lc( $ISPMan::Config->{'CyrusUnixHierarchySep'} ) == 'yes' ) {
- $imap_mailbox_prefix .= '/';
+ $sep = '/';
+ $imap_mailbox_prefix .= $sep;
} else {
- $imap_mailbox_prefix .= '.';
+ $imap_mailbox_prefix .= $sep;
}
sub _connect {
@@ -48,7 +59,7 @@
sub create_mailbox {
my $server = shift;
- my $mailbox = $imap_mailbox_prefix . shift;
+ my $mailbox = $imap_mailbox_prefix . get_correct_mailbox(shift);
$imap_conn or _connect($server);
@@ -61,7 +72,7 @@
sub delete_mailbox {
my $server = shift;
- my $mailbox = $imap_mailbox_prefix . shift;
+ my $mailbox = $imap_mailbox_prefix . get_correct_mailbox(shift);
$imap_conn or _connect($server);
$imap_conn->set_acl( $mailbox, $ispman->getConf("imapAdminUsername"),
@@ -75,7 +86,8 @@
sub create_folder {
my $server = shift;
- my $mailbox = $imap_mailbox_prefix . shift;
+ my $addr = get_correct_mailbox(shift);
+ my $mailbox = $imap_mailbox_prefix . $addr;
my $folder = shift;
$imap_conn or _connect($server);
@@ -83,26 +95,20 @@
if ( $imap_conn->list($mailbox) ) {
# mailbox exists. Lets continue
if ( lc( $ISPMan::Config->{'AllowFullEmailLogins'} ) == 'yes' ) {
- if ( lc( $ISPMan::Config->{'CyrusUnixHierarchySep'} ) == 'yes' ) {
- $sep = '/';
- } else {
- $sep = '.';
- }
- ( $tuid, $tdomain ) = split( '@', $uid );
- $mailbox = join "", ( $imap_mailbox_prefix, $tuid );
- if ( $imap_conn->list( join '', ( $mailbox, $sep, $folder, '@', $tdomain ) ) ) {
+ ( $addr_start, $addr_end ) = split( '@', $addr );
+ if ( $imap_conn->list( join '',
+ ( $imap_mailbox_prefix, $addr_start, $sep, $folder, '@', $addr_end)) ) {
# Already Exists
- print "$folder on $mailbox\@$tdomain already exists. Skipping\n";
+ print "$folder on $addr_start\@$addr_end already exists. Skipping\n";
return 2;
} else {
- my $tmailbox = join '', ( $mailbox, '@', $tdomain );
- if ( $imap_conn->set_acl( $tmailbox, $ispman->getConf("imapAdminUsername"), "lrswipdca" ) ) {
+ if ( $imap_conn->set_acl( $mailbox, $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 "Creating $folder on $addr_start\@$addr_end\n";
+ my $tmbox = join '', ( $imap_mailbox_prefix, $addr_start, $sep, $folder, '@', $addr_end);
+ if ( $imap_conn->create( $tmbox ) ) {
print $imap_conn->error."\n";
return 1;
}
@@ -130,7 +136,7 @@
sub get_quota {
my $server = shift;
- my $mailbox = $imap_mailbox_prefix . shift;
+ my $mailbox = $imap_mailbox_prefix . get_correct_mailbox(shift);
$imap_conn or _connect($server);
if ( $imap_conn->get_quota($mailbox) ) {
@@ -142,7 +148,7 @@
sub set_quota {
my $server = shift;
- my $mailbox = $imap_mailbox_prefix . email2uid(shift);
+ my $mailbox = $imap_mailbox_prefix . get_correct_mailbox(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