Fix as discussed on the developer list:

Check for the availability of mailpreferences before using them.
This commit is contained in:
Ralf Becker 2010-11-10 18:26:55 +00:00
parent ab3a32399b
commit e2d2534fda

View File

@ -224,17 +224,19 @@
*/
function addAccount($_hookValues)
{
$icServer = $this->mailPreferences->getIncomingServer(0);
if(is_a($icServer,'defaultimap')) {
// if not connected, try opening an admin connection
if (!$icServer->_connected) $this->openConnection(0,true);
$icServer->addAccount($_hookValues);
if ($icServer->_connected) $this->closeConnection(); // close connection afterwards
}
if ($this->mailPreferences) {
$icServer = $this->mailPreferences->getIncomingServer(0);
if(is_a($icServer,'defaultimap')) {
// if not connected, try opening an admin connection
if (!$icServer->_connected) $this->openConnection(0,true);
$icServer->addAccount($_hookValues);
if ($icServer->_connected) $this->closeConnection(); // close connection afterwards
}
$ogServer = $this->mailPreferences->getOutgoingServer(0);
if(is_a($ogServer,'defaultsmtp')) {
$ogServer->addAccount($_hookValues);
$ogServer = $this->mailPreferences->getOutgoingServer(0);
if(is_a($ogServer,'defaultsmtp')) {
$ogServer->addAccount($_hookValues);
}
}
}
@ -529,17 +531,19 @@
function deleteAccount($_hookValues)
{
$icServer = $this->mailPreferences->getIncomingServer(0);
if(is_a($icServer,'defaultimap')) {
//try to connect with admin rights, when not connected
if (!$icServer->_connected) $this->openConnection(0,true);
$icServer->deleteAccount($_hookValues);
if ($icServer->_connected) $this->closeConnection(); // close connection
}
if ($this->mailPreferences) {
$icServer = $this->mailPreferences->getIncomingServer(0);
if(is_a($icServer,'defaultimap')) {
//try to connect with admin rights, when not connected
if (!$icServer->_connected) $this->openConnection(0,true);
$icServer->deleteAccount($_hookValues);
if ($icServer->_connected) $this->closeConnection(); // close connection
}
$ogServer = $this->mailPreferences->getOutgoingServer(0);
if(is_a($ogServer,'defaultsmtp')) {
$ogServer->deleteAccount($_hookValues);
$ogServer = $this->mailPreferences->getOutgoingServer(0);
if(is_a($ogServer,'defaultsmtp')) {
$ogServer->deleteAccount($_hookValues);
}
}
}