From 4c815497b093a561e992b4abbb69877927f01578 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Sat, 3 Aug 2019 23:59:02 +0200 Subject: [PATCH] add SEO url --- docs/install.sql | 4 ++++ src/Setup/Installation.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/docs/install.sql b/docs/install.sql index fa144ca..a1aeb40 100644 --- a/docs/install.sql +++ b/docs/install.sql @@ -21,3 +21,7 @@ CREATE TABLE IF NOT EXISTS `d3totp_backupcodes` ( ) ENGINE=InnoDB COMMENT='totp backup codes'; + +INSERT INTO `oxseo` (`OXOBJECTID`, `OXIDENT`, `OXSHOPID`, `OXLANG`, `OXSTDURL`, `OXSEOURL`, `OXTYPE`, `OXFIXED`, `OXEXPIRED`, `OXPARAMS`, `OXTIMESTAMP`) VALUES +('39f744f17e974988e515558698a29df4', '76282e134ad4e40a3578e121a6cb1f6a', 1, 1, 'index.php?cl=d3_account_totp', 'en/2-factor-authintication/', 'static', 0, 0, '', NOW()), +('39f744f17e974988e515558698a29df4', 'c1f8b5506e2b5d6ac184dcc5ebdfb591', 1, 0, 'index.php?cl=d3_account_totp', '2-faktor-authentisierung/', 'static', 0, 0, '', NOW()); diff --git a/src/Setup/Installation.php b/src/Setup/Installation.php index d5b709e..03d0a31 100644 --- a/src/Setup/Installation.php +++ b/src/Setup/Installation.php @@ -18,6 +18,7 @@ namespace D3\Totp\Setup; use D3\ModCfg\Application\Model\d3database; use D3\ModCfg\Application\Model\Install\d3install_updatebase; use Doctrine\DBAL\DBALException; +use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\Exception\ConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; @@ -33,6 +34,8 @@ class Installation extends d3install_updatebase 'do' => 'fixFields'), array('check' => 'checkIndizes', 'do' => 'fixIndizes'), + array('check' => 'checkSEONotExists', + 'do' => 'addSEO'), ); public $aMultiLangTables = array(); @@ -245,4 +248,31 @@ class Installation extends d3install_updatebase return $blRet; } + + /** + * @return bool + * @throws DatabaseConnectionException + */ + public function checkSEONotExists() + { + $query = "SELECT 1 FROM " . getViewName('oxseo') . " WHERE oxstdurl = 'index.php?cl=d3_account_totp'"; + + return !DatabaseProvider::getDb()->getOne($query); + } + + /** + * @return bool + * @throws DatabaseConnectionException + * @throws DatabaseErrorException + */ + public function addSEO() + { + $query = [ + "INSERT INTO `oxseo` (`OXOBJECTID`, `OXIDENT`, `OXSHOPID`, `OXLANG`, `OXSTDURL`, `OXSEOURL`, `OXTYPE`, `OXFIXED`, `OXEXPIRED`, `OXPARAMS`, `OXTIMESTAMP`) VALUES +('39f744f17e974988e515558698a29df4', '76282e134ad4e40a3578e121a6cb1f6a', 1, 1, 'index.php?cl=d3_account_totp', 'en/2-factor-authintication/', 'static', 0, 0, '', NOW()), +('39f744f17e974988e515558698a29df4', 'c1f8b5506e2b5d6ac184dcc5ebdfb591', 1, 0, 'index.php?cl=d3_account_totp', '2-faktor-authentisierung/', 'static', 0, 0, '', NOW());" + ]; + + return $this->_executeMultipleQueries($query); + } } \ No newline at end of file