mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
Add error message on adminpanel contacts configuration page.
This commit is contained in:
parent
a531846b8f
commit
869e0ed181
9 changed files with 120 additions and 60 deletions
|
|
@ -1942,7 +1942,11 @@ class Actions
|
|||
$this->setConfigFromParams($oConfig, 'ContactsPdoUser', 'contacts', 'pdo_user', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy');
|
||||
|
||||
return $this->DefaultResponse(__FUNCTION__, $this->PersonalAddressBookProvider(null, true)->Test());
|
||||
$sTestMessage = $this->PersonalAddressBookProvider(null, true)->Test();
|
||||
return $this->DefaultResponse(__FUNCTION__, array(
|
||||
'Result' => '' === $sTestMessage,
|
||||
'Message' => \MailSo\Base\Utils::Utf8Clear($sTestMessage, '?')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ abstract class PdoAbstract
|
|||
$oPdo = false;
|
||||
try
|
||||
{
|
||||
$oPdo = new \PDO($sDsn, $sDbLogin, $sDbPassword);
|
||||
$oPdo = @new \PDO($sDsn, $sDbLogin, $sDbPassword);
|
||||
if ($oPdo)
|
||||
{
|
||||
$oPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function Test()
|
||||
{
|
||||
\sleep(1);
|
||||
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface ?
|
||||
$this->oDriver->Test() : false;
|
||||
$this->oDriver->Test() : 'Personal address book driver is not allowed';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -752,8 +752,31 @@ class PdoPersonalAddressBook
|
|||
*/
|
||||
public function Test()
|
||||
{
|
||||
$this->Sync();
|
||||
return 0 < $this->getVersion('mysql-pab-version');
|
||||
$sResult = '';
|
||||
try
|
||||
{
|
||||
$this->Sync();
|
||||
|
||||
if (0 >= $this->getVersion('mysql-pab-version'))
|
||||
{
|
||||
$sResult = 'Unknown database error';
|
||||
}
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
$sResult = $oException->getMessage();
|
||||
if (!empty($sResult) && !\MailSo\Base\Utils::IsAscii($sResult) && !\MailSo\Base\Utils::IsUtf8($sResult))
|
||||
{
|
||||
$sResult = @\utf8_encode($sResult);
|
||||
}
|
||||
|
||||
if (!\is_string($sResult) || empty($sResult))
|
||||
{
|
||||
$sResult = 'Unknown database error';
|
||||
}
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue