summaryrefslogtreecommitdiff
path: root/lib/Kolab/Cyrus.pm
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-05-07 20:50:12 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-05-07 20:50:12 (GMT)
commitaec02a3a38b88d01d12bda3469fecb3de20ac067 (patch)
treea4e2138f6c91c2e6c1e309d5b175f138812c9e1c /lib/Kolab/Cyrus.pm
parent48e39bcece647e3f65ab44c7dce8bcb18b052346 (diff)
downloadperl-Kolab-aec02a3a38b88d01d12bda3469fecb3de20ac067.tar.gz
Create 2 new API calls:
Kolab::cyrusMurderCreateMailbox Kolab::cyrusMurderRenameMailbox
Diffstat (limited to 'lib/Kolab/Cyrus.pm')
-rw-r--r--lib/Kolab/Cyrus.pm29
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/Kolab/Cyrus.pm b/lib/Kolab/Cyrus.pm
index f4462af..17b1adf 100644
--- a/lib/Kolab/Cyrus.pm
+++ b/lib/Kolab/Cyrus.pm
@@ -42,6 +42,7 @@ our %EXPORT_TAGS = (
&createMailbox
&createCalendar
&deleteMailbox
+ &renameMailbox
&setQuota
&setACL
) ]
@@ -57,12 +58,15 @@ our $VERSION = '0.9';
sub create
{
- Kolab::log('Y', 'Connecting to local Cyrus admin interface');
- my $cyrus = Cyrus::IMAP::Admin->new($Kolab::config{'connect_addr'});
+ my $connectAddress = shift || $Kolab::config{'connect_addr'};
+
+ Kolab::log('Y', 'Connecting to Cyrus at ' . $connectAddress);
+
+ my $cyrus = Cyrus::IMAP::Admin->new($connectAddress);
if (!$cyrus) {
- Kolab::log('Y', 'Unable to connect to local Cyrus admin interface', KOLAB_ERROR);
+ Kolab::log('Y', 'Unable to connect to Cyrus admin interface', KOLAB_ERROR);
return 0;
}
@@ -101,13 +105,14 @@ sub createMailbox
my $cyruid = &createUid($uid, $sf);
my $mailbox = ($cyrus->list($cyruid))[0];
+
if ($uid && ($uid ne $Kolab::config{'cyrus_admin'}) && ($uid ne "freebusy") && ($uid ne "nobody") && !defined($mailbox)) {
Kolab::log('Y', "Creating mailbox `$cyruid' on ".($partition?"partition `$partition'":"default partition"));
if (!$cyrus->create($cyruid, $partition)) {
Kolab::log('Y', "Unable to create mailbox `$cyruid', Error = `" . $cyrus->error . "'", KOLAB_WARN);
}
} else {
- Kolab::log('Y', "Skipping mailbox creation for $uid (curuid='$cyruid', mailbox='".join(',',@{$mailbox})."'", KOLAB_DEBUG);
+ Kolab::log('Y', "Skipping mailbox creation for $uid (cyruid='$cyruid', mailbox='".join(',',@{$mailbox})."'", KOLAB_DEBUG);
}
}
@@ -189,6 +194,22 @@ sub deleteMailbox
}
}
+sub renameMailbox
+{
+ my $cyrus = shift;
+ my $mailboxName = shift;
+ my $newMailboxName = shift;
+ my $sharedFolder = shift || 0;
+ my $mailboxPath = &createUid($mailboxName, $sharedFolder);
+ my $newMailboxPath = &createUid($newMailboxName, $sharedFolder);
+
+ Kolab::log('Y', "Renaming mailbox from `$mailboxPath' to `$newMailboxPath'");
+
+ if (!$cyrus->renamemailbox($mailboxPath, $newMailboxPath)) {
+ Kolab::log('Y', "Unable to rename mailbox `$mailboxPath' to `$newMailboxPath', Error = `" . $cyrus->error . "'", KOLAB_WARN);
+ }
+}
+
sub setACL
{
my $cyrus = shift;