Index: vacation/main.php =================================================================== RCS file: /repository/vacation/main.php,v retrieving revision 1.48 diff -u -r1.48 main.php --- vacation/main.php 3 Jan 2005 14:35:40 -0000 1.48 +++ vacation/main.php 2 Sep 2005 03:58:01 -0000 @@ -115,9 +115,11 @@ // can't tell, so just be quiet about it. $pass = Auth::getCredential('password'); $status = $driver->isEnabled($user, $realm, $pass); +$onVacation = false; if ($status == 'Y') { $curmessage = $driver->currentMessage($user, $realm, $pass); $notification->push(_("Your vacation notice is currently enabled."), 'horde.success'); + $onVacation = true; } elseif ($status == 'N') { $curmessage = $driver->currentMessage($user, $realm, $pass); $notification->push(_("Your vacation notice is currently disabled."), 'horde.warning'); Index: vacation/lib/Driver/qmail.php =================================================================== RCS file: /repository/vacation/lib/Driver/qmail.php,v retrieving revision 1.24 diff -u -r1.24 qmail.php --- vacation/lib/Driver/qmail.php 23 Jun 2005 22:13:51 -0000 1.24 +++ vacation/lib/Driver/qmail.php 2 Sep 2005 03:58:03 -0000 @@ -76,7 +76,7 @@ // We need to find out what type of database file to use. $conf = &$GLOBALS['conf']; $dbfile = VACATION_BASE . '/files/empty.' . - $this->_params['dbtype'] . '.bin'; + $this->_params[$realm]['dbtype'] . '.bin'; // Build the ftp array to pass to VFS. $_args = array('hostspec' => $this->_params[$realm]['host'], @@ -97,23 +97,36 @@ return false; } + // clean up old backup and move existing .qmail + if ($_vfs->exists('', '.qmail_horde')) { + $this->err_str = _("Vacation notice already exists."); + return false; + } + if ($_vfs->exists('', '.qmail')) { + $status = $_vfs->rename('', '.qmail', '', '.qmail_horde'); + if (is_a($status, 'PEAR_Error')) { + $this->err_str = $status->getMessage(); + return false; + } + } + // Set up the vacation specific files first. $status = $_vfs->writeData('', '.vacation.msg', $message); if (is_a($status, 'PEAR_Error')) { $this->err_str = $status->getMessage(); return false; } - $status = $_vfs->write('', '.vacation.pag', $dbfile); + $status = $_vfs->writeData('', '.vacation.pag', $dbfile); if (is_a($status, 'PEAR_Error')) { $this->err_str = $status->getMessage(); return false; } - $status = $_vfs->write('', '.vacation.dir', $dbfile); + $status = $_vfs->writeData('', '.vacation.dir', $dbfile); if (is_a($status, 'PEAR_Error')) { $this->err_str = $status->getMessage(); return false; } - $status = $_vfs->write('', '.vacation.db', $dbfile); + $status = $_vfs->writeData('', '.vacation.db', $dbfile); if (is_a($status, 'PEAR_Error')) { $this->err_str = $status->getMessage(); return false; @@ -186,18 +199,30 @@ return false; } - $status = $_vfs->deleteFile('', '.qmail'); - if (is_a($status, 'PEAR_Error')) { - $this->err_str = $status->getMessage(); - $this->err_str .= ' ' . - _("Maybe you didn't have a vacation notice installed?"); + if ($_vfs->exists('', '.vacation.msg')) { + $status = $_vfs->deleteFile('', '.vacation.msg'); + if (is_a($status, 'PEAR_Error')) { + $this->err_str = $status->getMessage(); + return false; + } + } else { + $this->err_str = _("Vacation notice not found."); return false; } - $status = $_vfs->deleteFile('', '.vacation.msg'); - if (is_a($status, 'PEAR_Error')) { - $this->err_str = $status->getMessage(); - return false; + // restore previous .qmail (if any) + if ($_vfs->exists('', '.qmail_horde')) { + $status = $_vfs->rename('', '.qmail_horde', '', '.qmail'); + if (is_a($status, 'PEAR_Error')) { + $this->err_str = $status->getMessage(); + return false; + } + } else { + $status = $_vfs->deleteFile('', '.qmail'); + if (is_a($status, 'PEAR_Error')) { + $this->err_str = $status->getMessage(); + return false; + } } // We could, but don't, check for errors on these. They are Index: vacation/templates/main/main.inc =================================================================== RCS file: /repository/vacation/templates/main/main.inc,v retrieving revision 1.32 diff -u -r1.32 main.inc --- vacation/templates/main/main.inc 7 Aug 2005 01:14:47 -0000 1.32 +++ vacation/templates/main/main.inc 2 Sep 2005 03:58:26 -0000 @@ -1,4 +1,4 @@ -