ispman/lib mailbox_actions_cyrus.lib,1.1.2.2,1.1.2.3
Pedro Algarvio <[email protected]> Sat, 16 Sep 2006 19:20:23 +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-serv13521/lib
Modified Files:
Tag: dev_1_3-cyrus_virtdomain
mailbox_actions_cyrus.lib
Log Message:
Branch re-updated to current trunk. Debugging is still needed for other stuff than createMailbox and createSubMailbox.
Index: mailbox_actions_cyrus.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/mailbox_actions_cyrus.lib,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- mailbox_actions_cyrus.lib 11 Sep 2006 23:31:27 -0000 1.1.2.2
+++ mailbox_actions_cyrus.lib 16 Sep 2006 19:20:21 -0000 1.1.2.3
@@ -28,11 +28,11 @@
# 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 += '/';
+ $imap_mailbox_prefix .= '/';
} else {
- $imap_mailbox_prefix += '.';
+ $imap_mailbox_prefix .= '.';
}
sub _connect {
@@ -52,7 +52,11 @@
$imap_conn or _connect($server);
- return $imap_conn->create($mailbox);
+ if ( $imap_conn->create($mailbox) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ return 0;
}
sub delete_mailbox {
@@ -62,7 +66,66 @@
$imap_conn or _connect($server);
$imap_conn->set_acl( $mailbox, $ispman->getConf("imapAdminUsername"),
"lrswipcda" );
- return $imap_conn->delete($mailbox);
+ if ( $imap_conn->delete($mailbox) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ return 0;
+}
+
+sub create_folder {
+ my $server = shift;
+ my $mailbox = $imap_mailbox_prefix . shift;
+ my $folder = shift;
+
+ $imap_conn or _connect($server);
+
+ 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;
}
sub get_quota {
@@ -70,7 +133,11 @@
my $mailbox = $imap_mailbox_prefix . shift;
$imap_conn or _connect($server);
- return $imap_conn->get_quota($mailbox);
+ if ( $imap_conn->get_quota($mailbox) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ return 0;
}
sub set_quota {
@@ -79,7 +146,11 @@
my $quota = shift;
$imap_conn or _connect($server);
- return $imap_conn->set_quota( $mailbox, $quota );
+ if ( $imap_conn->set_quota( $mailbox, $quota ) ) {
+ print $imap_conn->error."\n";
+ return 1;
+ }
+ return 0;
}
sub list_mailboxes {
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642