diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 8cebbff30d538f95a771c1896b425a00bde3222b..6bd76b9bbd278d3e8cf317e3f7b86b49c2a70646 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -309,10 +309,6 @@ config.qfq.php | LDAP_1_RDN | LDAP_1_RDN='ou=Admin,ou=example,dc=com' | Credentials for non-anonymous LDAP access. At the moment only one set of | | LDAP_1_PASSWORD | LDAP_1_PASSWORD=mySecurePassword | | +-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+ -| T3_DB_NAME | T3_DB_NAME=specialt3dbname | Only necessary for inline report editing if the t3 database is not | -| | | anologous to the Data db name (but ending in _t3) - see `inline-report`_. | -+-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+ - Example: *typo3conf/config.qfq.php*: :: @@ -526,6 +522,17 @@ Extension Manager: QFQ Configuration | cssClassColumnId | text-muted | A column in a subrecord with the name id|ID|Id gets this class. | +-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+ +Automatically filled by QFQ: + ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| Keyword | Description | ++===============================+====================================================================================================================================+ +| dbNameData | Use this to get name of the configured 'data'-database. '{{dbNameData:Y}} | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| dbNameQfq | Use this to get name of the configured 'QFQ'-database. '{{dbNameQfq:Y}} | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| dbNameT3 | Use this to get name of the configured 'T3'-database. '{{dbNameT3:Y}} | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ .. _`CustomVariables`: @@ -1515,7 +1522,7 @@ Only variables that are known in a specified store can be substituted. +-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+ | V | :ref:`STORE_VARS`: Generic variables. | See `STORE_VARS`_. | +-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+ - | Y | :ref:`STORE_SYSTEM`: a) Database, b) helper vars for logging/debugging: | See `STORE_SYSTEM`_. | + | Y | :ref:`STORE_SYSTEM`: a) Database, b) helper vars for logging/debugging: | See `STORE_SYSTEM`_. | | | SYSTEM_SQL_RAW ... SYSTEM_FORM_ELEMENT_COLUMN, c) Any custom fields: CONTACT, HELP, ...| | +-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+ | 0 | *Zero* - always value: 0, might be helpful if a variable is empty or undefined and | Any key | @@ -5035,17 +5042,8 @@ For this reason, QFQ offers an inline report editing feature whenever there is a link symbol will appear on the right-hand side of each report record. Please note that the TYPO3 Frontend cache is also deleted upon each inline report save. -In order for the inline report editing to work, QFQ needs to be able to access the T3 database. By default this database -is assumed to be accessible with the same credentials as specified with indexData and is assumed to be named similarly to -the indexData db name, but ending in _t3 instead of _db (e.g., mydb_db and mydb_t3). -For a standard installation and db setup, this should be the case. - -You can however specify a custom T3 db name in config-qfq-php_: - -:: - - T3_DB_NAME = customT3DbName - +In order for the inline report editing to work, QFQ needs to be able to access the T3 database. This database +is assumed to be accessible with the same credentials as specified with indexQfq. Structure --------- diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 8ff85747fce84cf96f254a9ff19c362fb6b0a78e..c0265f5cc70173825f30d1d1fd1b2be711002aae 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -421,8 +421,6 @@ const SYSTEM_DB_1_SERVER = 'DB_1_SERVER'; const SYSTEM_DB_1_PASSWORD = 'DB_1_PASSWORD'; const SYSTEM_DB_1_NAME = 'DB_1_NAME'; -const SYSTEM_T3_DB_NAME = 'T3_DB_NAME'; - const SYSTEM_DB_INIT = 'init'; const SYSTEM_DB_INDEX_DATA = "indexData"; @@ -431,9 +429,11 @@ const SYSTEM_DB_INDEX_QFQ = "indexQfq"; //const SYSTEM_DB_INDEX_DATA_DEPRECATED = "DB_INDEX_DATA"; //const SYSTEM_DB_INDEX_QFQ_DEPRECATED = "DB_INDEX_QFQ"; -// Computed dynamically -const SYSTEM_DB_NAME_DATA = '_dbNameData'; -const SYSTEM_DB_NAME_QFQ = '_dbNameQfq'; +// Automatically filled by QFQ +const SYSTEM_DB_NAME_DATA = 'dbNameData'; +const SYSTEM_DB_NAME_QFQ = 'dbNameQfq'; +const SYSTEM_DB_NAME_T3 = 'dbNameT3'; + const SYSTEM_LOG_DIR = 'logDir'; // Logging to file const SYSTEM_LOG_DIR_DEFAULT = 'fileadmin/protected/log'; // Logging to file diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php index f98f59fb7d9e36480e6788ca8c8f4a5cff3f0873..afc728f7df43a47eb4ba3f7b4da16d6bcfd278af 100644 --- a/extension/qfq/qfq/QuickFormQuery.php +++ b/extension/qfq/qfq/QuickFormQuery.php @@ -178,16 +178,9 @@ class QuickFormQuery { $this->dbArray[$this->dbIndexData] = new Database($this->dbIndexData); - $dbName = $this->dbArray[$this->dbIndexData]->getDbName(); - $this->store->setVar(SYSTEM_DB_NAME_DATA, $dbName, STORE_SYSTEM); - if ($this->dbIndexData != $this->dbIndexQfq) { $this->dbArray[$this->dbIndexQfq] = new Database($this->dbIndexQfq); - - $dbName = $this->dbArray[$this->dbIndexQfq]->getDbName(); } - $this->store->setVar(SYSTEM_DB_NAME_QFQ, $dbName, STORE_SYSTEM); - $this->eval = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]); @@ -213,6 +206,11 @@ class QuickFormQuery { */ public function getForwardMode() { + if (!isset($this->formSpec[F_FORWARD_PAGE])) { + // For QFQ inline editing: no redirect. + return [API_REDIRECT => API_ANSWER_REDIRECT_NO, API_REDIRECT_URL => '']; + } + $forwardPage = $this->formSpec[F_FORWARD_PAGE]; if ($this->formSpec[F_FORWARD_MODE] == F_FORWARD_MODE_URL_SIP) { @@ -1457,7 +1455,7 @@ class QuickFormQuery { } $bodytext = Support::htmlEntityEncodeDecode(MODE_DECODE, $_POST[REPORT_INLINE_BODYTEXT]); - $dbT3 = $this->store->getDbT3Name(); + $dbT3 = $this->store->getVar(SYSTEM_DB_NAME_T3, STORE_SYSTEM); // Update bodytext $sql = "UPDATE $dbT3.tt_content SET bodytext = ?, tstamp = UNIX_TIMESTAMP(NOW()) WHERE uid = ?"; diff --git a/extension/qfq/qfq/exceptions/AbstractException.php b/extension/qfq/qfq/exceptions/AbstractException.php index 802533a923e661b8d916c69030c80a0432b36466..f114ac4bf7d412c050d0b0429b9f522ef1e0d012 100644 --- a/extension/qfq/qfq/exceptions/AbstractException.php +++ b/extension/qfq/qfq/exceptions/AbstractException.php @@ -109,9 +109,9 @@ class AbstractException extends \Exception { $arrDebugShow = array_merge([EXCEPTION_REPORT_FULL_LEVEL => Store::getVar(SYSTEM_REPORT_FULL_LEVEL, STORE_SYSTEM)], $this->messageArrayDebug); $arrDebugShow[EXCEPTION_SIP] = $store->getStore(STORE_SIP); - $arrDebugShow[EXCEPTION_PAGE_ID] = $t3Vars[TYPO3_PAGE_ID]; - $arrDebugShow[EXCEPTION_TT_CONTENT_UID] = $t3Vars[TYPO3_TT_CONTENT_UID]; - $arrDebugShow[EXCEPTION_FE_USER] = $t3Vars[TYPO3_FE_USER]??''; + $arrDebugShow[EXCEPTION_PAGE_ID] = $t3Vars[TYPO3_PAGE_ID] ?? '-'; + $arrDebugShow[EXCEPTION_TT_CONTENT_UID] = $t3Vars[TYPO3_TT_CONTENT_UID] ?? '-'; + $arrDebugShow[EXCEPTION_FE_USER] = $t3Vars[TYPO3_FE_USER] ?? '-'; $arrDebugShow[EXCEPTION_FE_USER_STORE_USER] = Store::getVar(TYPO3_FE_USER, STORE_USER); // Optional existing arrays will be flattened diff --git a/extension/qfq/qfq/report/Download.php b/extension/qfq/qfq/report/Download.php index df69044e40c44b6553dd71e7a65d3c216f0894f2..abeb7035a0303312ad6f8cf870e53bbf5af8d274 100644 --- a/extension/qfq/qfq/report/Download.php +++ b/extension/qfq/qfq/report/Download.php @@ -313,7 +313,7 @@ class Download { $this->store->setVar($key, $paramValue, STORE_SIP); } - $dbT3 = $this->store->getDbT3Name(); + $dbT3 = $this->store->getVar(SYSTEM_DB_NAME_T3,STORE_SYSTEM); $sql = "SELECT bodytext FROM $dbT3.tt_content WHERE uid = ?"; $tt_content = $this->db->sql($sql, ROW_EXPECT_1, [$uid]); diff --git a/extension/qfq/qfq/store/Config.php b/extension/qfq/qfq/store/Config.php index 8a0a1ef7c03d229684af5d03f1e42956d8789f9a..a2980b4065a6f52baf548586846dd93563206797 100644 --- a/extension/qfq/qfq/store/Config.php +++ b/extension/qfq/qfq/store/Config.php @@ -93,11 +93,14 @@ class Config { $pathTypo3Conf = __DIR__ . '/../../..'; } - // In case there is a $configIni given: do not try to include T3 LocalConfiguration.php + // In case of missing $configIni if (empty($configIni)) { + # Read 'LocalConfiguration.php' if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][EXT_KEY])) { $configT3qfq = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][EXT_KEY]); + $configT3qfq[SYSTEM_DB_NAME_T3] = $GLOBALS['TYPO3_CONF_VARS']['DB']['database']; + } else { $all = include($pathTypo3Conf . '/' . CONFIG_T3); if (empty($all) || $all === true) { @@ -108,6 +111,8 @@ class Config { if (!is_array($configT3qfq)) { throw new qfq\UserFormException ("Error read file: " . $pathTypo3Conf . '/' . CONFIG_T3, ERROR_IO_READ_FILE); } + + $configT3qfq[SYSTEM_DB_NAME_T3] = $all['DB']['database']; unset($all); } $configIni = $pathTypo3Conf . '/' . CONFIG_QFQ_INI; diff --git a/extension/qfq/qfq/store/Store.php b/extension/qfq/qfq/store/Store.php index aa30fae38b9189b5b0663816312c852b2f438b92..7ee6fdaf1316806d35cadc259de40362e09842d9 100644 --- a/extension/qfq/qfq/store/Store.php +++ b/extension/qfq/qfq/store/Store.php @@ -455,12 +455,27 @@ class Store { $config = self::doSystemPath($config); $config = self::adjustConfig($config); + $config = self::setAutoConfigValue($config); self::checkMandatoryParameter($config); self::setStore($config, STORE_SYSTEM, true); } + /** + * Set automatic filled values + * + * @param array $config + * @return array + */ + public static function setAutoConfigValue(array $config) { + + $config[SYSTEM_DB_NAME_DATA] = $config['SYSTEM_DB_' . $config[SYSTEM_DB_INDEX_DATA] . '_NAME'] ?? ''; + $config[SYSTEM_DB_NAME_QFQ] = $config['SYSTEM_DB_' . $config[SYSTEM_DB_INDEX_QFQ] . '_NAME'] ?? ''; + + return $config; + } + /** * Copy the BodyText as well as some T3 specific vars to STORE_TYPO3. * Attention: if called through API, there is no T3 environment. The only values which are available are fe_user @@ -959,31 +974,4 @@ class Store { $store = Store::getInstance(); $store->setStore(array_merge($store->getStore($storeName), $append), $storeName, true); } - - /** - * Gets the db T3 name: - * - if defined by T3_DB_NAME in config - * - else: construct databasename_t3 from databasename_db - * - * @return string - * @throws CodeException - * @throws DbException - * @throws UserFormException - * @throws UserReportException - */ - public static function getDbT3Name() { - - $dbT3Name = self::getVar(SYSTEM_T3_DB_NAME, STORE_SYSTEM . STORE_EMPTY, SANITIZE_ALLOW_ALNUMX); - - if (!$dbT3Name) { - $dbIndexData = self::getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM); - $dbData = new Database($dbIndexData); - $dbDataName = $dbData->getDbName(); - - $dbT3Name = substr($dbDataName, 0, strrpos($dbDataName, "_") + 1) . 't3'; - } - - return $dbT3Name; - } - }