Loading lib/Db/MailboxMapper.php +21 −9 Original line number Diff line number Diff line Loading @@ -6,11 +6,10 @@ use OCP\IConfig; use OCP\ILogger; use OCA\EcloudAccounts\Exception\DbConnectionParamsException; use Doctrine\DBAL\DriverManager; use Exception; use Throwable; class MailboxMapper { private $config; private $conn; private $logger; Loading @@ -22,22 +21,35 @@ class MailboxMapper $this->initConnection(); } private function initConnection() { private function initConnection() { try { $params = $this->getConnectionParams(); $this->conn = DriverManager::getConnection($params); } catch(Exception $e) { } catch (Throwable $e) { $this->logger->info('Error connecting to SQL raw backend: ' . $e->getMessage()); } } private function isDbConfigValid($config) : bool { if (!$config || !is_array($config)) { return false; } return isset($config['db_name']) && isset($config['mariadb_charset']) && isset($config['db_user']) && isset($config['db_password']) && isset($config['db_host']) && isset($config['db_port']) ; } private function getConnectionParams() { $config = $this->config->getSystemValue('user_backend_sql_raw'); if (!$config) { throw new DbConnectionParamsException('Database connection params for mailbox not available in config.php!'); if (!$this->isDbConfigValid($config)) { throw new DbConnectionParamsException('Invalid SQL raw configuration!'); } $params = [ Loading lib/Listeners/BeforeUserDeletedListener.php +6 −3 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use OCA\EcloudAccounts\AppInfo\Application; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\ILogger; use OCP\IConfig; use OCP\User\Events\BeforeUserDeletedEvent; use OCA\EcloudAccounts\Service\LDAPConnectionService; Loading @@ -18,11 +19,13 @@ require_once 'curl.class.php'; class BeforeUserDeletedListener implements IEventListener { private $logger; private $config; private $LDAPConnectionService; public function __construct(ILogger $logger, LDAPConnectionService $LDAPConnectionService) public function __construct(ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService) { $this->logger = $logger; $this->config = $config; $this->LDAPConnectionService = $LDAPConnectionService; } Loading Loading @@ -71,9 +74,9 @@ class BeforeUserDeletedListener implements IEventListener */ public function ecloudDelete(string $userID, string $welcomeDomain, string $welcomeSecret, string $email, bool $isUserOnLDAP = false) { $endpoint = 'postDelete.php'; $endpoint = '/postDelete.php'; if ($isUserOnLDAP) { $endpoint = 'postDeleteLDAP.php'; $endpoint = '/postDeleteLDAP.php'; } $postDeleteUrl = "https://" . $welcomeDomain . $endpoint; $curl = new Curl(); Loading Loading
lib/Db/MailboxMapper.php +21 −9 Original line number Diff line number Diff line Loading @@ -6,11 +6,10 @@ use OCP\IConfig; use OCP\ILogger; use OCA\EcloudAccounts\Exception\DbConnectionParamsException; use Doctrine\DBAL\DriverManager; use Exception; use Throwable; class MailboxMapper { private $config; private $conn; private $logger; Loading @@ -22,22 +21,35 @@ class MailboxMapper $this->initConnection(); } private function initConnection() { private function initConnection() { try { $params = $this->getConnectionParams(); $this->conn = DriverManager::getConnection($params); } catch(Exception $e) { } catch (Throwable $e) { $this->logger->info('Error connecting to SQL raw backend: ' . $e->getMessage()); } } private function isDbConfigValid($config) : bool { if (!$config || !is_array($config)) { return false; } return isset($config['db_name']) && isset($config['mariadb_charset']) && isset($config['db_user']) && isset($config['db_password']) && isset($config['db_host']) && isset($config['db_port']) ; } private function getConnectionParams() { $config = $this->config->getSystemValue('user_backend_sql_raw'); if (!$config) { throw new DbConnectionParamsException('Database connection params for mailbox not available in config.php!'); if (!$this->isDbConfigValid($config)) { throw new DbConnectionParamsException('Invalid SQL raw configuration!'); } $params = [ Loading
lib/Listeners/BeforeUserDeletedListener.php +6 −3 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use OCA\EcloudAccounts\AppInfo\Application; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\ILogger; use OCP\IConfig; use OCP\User\Events\BeforeUserDeletedEvent; use OCA\EcloudAccounts\Service\LDAPConnectionService; Loading @@ -18,11 +19,13 @@ require_once 'curl.class.php'; class BeforeUserDeletedListener implements IEventListener { private $logger; private $config; private $LDAPConnectionService; public function __construct(ILogger $logger, LDAPConnectionService $LDAPConnectionService) public function __construct(ILogger $logger, IConfig $config, LDAPConnectionService $LDAPConnectionService) { $this->logger = $logger; $this->config = $config; $this->LDAPConnectionService = $LDAPConnectionService; } Loading Loading @@ -71,9 +74,9 @@ class BeforeUserDeletedListener implements IEventListener */ public function ecloudDelete(string $userID, string $welcomeDomain, string $welcomeSecret, string $email, bool $isUserOnLDAP = false) { $endpoint = 'postDelete.php'; $endpoint = '/postDelete.php'; if ($isUserOnLDAP) { $endpoint = 'postDeleteLDAP.php'; $endpoint = '/postDeleteLDAP.php'; } $postDeleteUrl = "https://" . $welcomeDomain . $endpoint; $curl = new Curl(); Loading