Commit c6c49e4c authored by Michal Cygankiewicz's avatar Michal Cygankiewicz

Merge branch 'task/use-direct-calls-for-ter-fe' into 'develop'

Task/use direct calls for ter fe

See merge request !450
parents c18ed3fe 14e27cfb
Pipeline #8004 passed with stages
in 5 minutes and 35 seconds
......@@ -16,7 +16,6 @@ $extensionKey = 'ter';
return [
'ctrl' => [
'label' => 'extensionuid',
'label_userFunc' => 'EXT:ter/class.tx_ter_tcaLabel.php:tx_ter_tcaLabel->getExtensionKey',
'default_sortby' => 'ORDER BY extensionuid',
'title' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensiondetails',
'iconfile' => \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey)) . 'tx_ter_extensiondetails.gif',
......
......@@ -315,7 +315,7 @@ class tx_ter_api
);
}
$extensionKeyRecordArr = $this->helperObj->getExtensionKeyRecord($extensionKey);
if ($extensionKeyRecordArr == false) {
if ($extensionKeyRecordArr === false) {
throw new \T3o\Ter\Exception\NotFoundException(
'Extension does not exist.',
TX_TER_ERROR_DELETEEXTENSION_EXTENSIONDOESNTEXIST
......@@ -414,27 +414,26 @@ class tx_ter_api
{
$extensionKeyDataArr = [];
$whereClause = 'pid=' . (int)$this->parentObj->extensionsPID;
if (!empty($extensionKeyFilterOptions->username)) {
$whereClause .= ' AND ownerusername = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$whereClause = 'ownerusername = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->username,
'tx_ter_extensionkeys'
);
}
if (!empty($extensionKeyFilterOptions->title)) {
$whereClause .= ' AND title = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$whereClause = 'title = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->title,
'tx_ter_extensionkeys'
);
}
if (!empty($extensionKeyFilterOptions->description)) {
$whereClause .= ' AND description = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$whereClause = 'description = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->description,
'tx_ter_extensionkeys'
);
}
if (!empty($extensionKeyFilterOptions->extensionKey)) {
$whereClause .= ' AND extensionkey = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$whereClause = 'extensionkey = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKeyFilterOptions->extensionKey,
'tx_ter_extensionkeys'
);
......@@ -485,9 +484,8 @@ class tx_ter_api
$extensionKeyRecordArr = $this->helperObj->getExtensionKeyRecord($extensionKey);
if (is_array($extensionKeyRecordArr)) {
if (strtolower($extensionKeyRecordArr['ownerusername']) != strtolower(
$accountData->username
) && $userRecordArr['admin'] !== true
if ($userRecordArr['admin'] !== true
&& strtolower($extensionKeyRecordArr['ownerusername']) !== strtolower($accountData->username)
) {
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_DELETEEXTENSIONKEY_ACCESSDENIED);
}
......@@ -498,7 +496,7 @@ class tx_ter_api
'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey,
'tx_ter_extensions'
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
)
);
if ($res) {
......@@ -510,7 +508,7 @@ class tx_ter_api
'extensionkey=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$extensionKey,
'tx_ter_extensions'
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
)
);
if (!$res) {
throw new \T3o\Ter\Exception\InternalServerErrorException(
......@@ -566,9 +564,8 @@ class tx_ter_api
$extensionKeyRecordArr = $this->helperObj->getExtensionKeyRecord($modifyExtensionKeyData->extensionKey);
if (is_array($extensionKeyRecordArr)) {
if (strtolower($extensionKeyRecordArr['ownerusername']) != strtolower(
$accountData->username
) && $userRecordArr['admin'] !== true
if ($userRecordArr['admin'] !== true
&& strtolower($extensionKeyRecordArr['ownerusername']) !== strtolower($accountData->username)
) {
throw new \T3o\Ter\Exception\UnauthorizedException('Access denied.', TX_TER_ERROR_MODIFYEXTENSIONKEY_ACCESSDENIED);
}
......@@ -942,7 +939,7 @@ class tx_ter_api
$extensionRow = [
'tstamp' => $GLOBALS['SIM_EXEC_TIME'],
'crdate' => $GLOBALS['SIM_EXEC_TIME'],
'pid' => (int)$this->parentObj->extensionsPID,
'pid' => 2,
'extensionkey' => $extensionKey,
'version' => $extensionInfoData->version,
'title' => $extensionInfoData->metaData->title,
......@@ -987,7 +984,7 @@ class tx_ter_api
// Prepare details row
$extensionDetailsRow = [
'pid' => (int)$this->parentObj->extensionsPID,
'pid' => 2,
'extensionuid' => (int)$extensionUid,
'uploadcomment' => (string)$extensionInfoData->infoData->uploadComment,
'lastuploadbyusername' => $accountData->username,
......@@ -1023,7 +1020,7 @@ class tx_ter_api
// Put new extension version into queue
$extensionQueue = [
'pid' => (int)$this->parentObj->extensionsPID,
'pid' => 2,
'extensionuid' => (int)$extensionUid,
'extensionkey' => $extensionKey,
];
......@@ -1066,7 +1063,7 @@ class tx_ter_api
) . ' AND version=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$version,
'tx_ter_extensions'
) . ' AND pid=' . (int)$this->parentObj->extensionsPID
)
);
if (!$result) {
throw new \T3o\Ter\Exception\InternalServerErrorException(
......@@ -1325,12 +1322,12 @@ class tx_ter_api
protected function registerExtensionKey_writeExtensionKeyInfoToDB($accountData, $extensionKeyData)
{
$extensionKeysRow = [
'pid' => $this->parentObj->extensionsPID,
'pid' => 2,
'tstamp' => time(),
'crdate' => time(),
'extensionkey' => $extensionKeyData->extensionKey,
'title' => $GLOBALS['TSFE']->csConvObj->strtrunc('utf-8', $extensionKeyData->title, 50),
'description' => $GLOBALS['TSFE']->csConvObj->strtrunc('utf-8', $extensionKeyData->description, 255),
'title' => mb_strcut($extensionKeyData->title, 0, 50, 'utf-8'),
'description' => mb_strcut($extensionKeyData->description, 0, 255, 'utf-8'),
'ownerusername' => $accountData->username,
'maxstoresize' => 0
];
......
......@@ -264,7 +264,7 @@ class tx_ter_helper
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'extensionkey',
'tx_ter_extensionkeys',
'pid=' . intval($this->pluginObj->extensionsPID)
'1'
);
while ($row = $this->getDatabaseConnection()->sql_fetch_row($res)) {
if ($cleanedExtensionKey === str_replace('_', '', $row[0])) {
......@@ -288,7 +288,6 @@ class tx_ter_helper
'*',
'tx_ter_extensionkeys',
'extensionkey=' . $this->getDatabaseConnection()->fullQuoteStr($extKey, 'tx_ter_extensionkeys') .
'AND pid=' . intval($this->pluginObj->extensionsPID) .
$this->getTyposcriptFrontendObject()->sys_page->enableFields('tx_ter_extensionkeys')
);
......
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* TCA label provider
*
* @author Kai Vogel <kai.vogel@speedprogs.de>
*/
class tx_ter_tcaLabel
{
/**
* Returns an extension key by given params
*
* @param array $params Parameters
* @param object $pObj Parent object reference
* @return string
*/
public function getExtensionKey(&$params, &$pObj)
{
if (empty($params['row']['uid'])) {
return;
}
$result = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
->getConnectionForTable('tx_ter_extensions')
->select(
['extensionkey'],
'tx_ter_extensions',
['uid = ' . (int)$params['row']['uid']]
)
->fetch();
if (!empty($result['extensionkey'])) {
$params['title'] = htmlspecialchars($result['extensionkey']);
} else {
$params['title'] = (int)$params['row']['uid'];
}
}
}
......@@ -18,6 +18,7 @@
"issues": "https://git-t3o.typo3.org/t3o/ter/issues"
},
"license": "GPL-2.0+",
"version": "2.0.9",
"require": {
"typo3/cms-core": "^8.7 || ^9.5"
},
......@@ -29,8 +30,7 @@
"Classes",
"pi1",
"class.tx_ter_api.php",
"class.tx_ter_helper.php",
"class.tx_ter_tcaLabel.php"
"class.tx_ter_helper.php"
]
},
"replace": {
......
......@@ -23,20 +23,7 @@
*/
error_reporting(E_ALL ^ E_NOTICE);
define('TYPO3_OS', stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin') ? 'WIN' : '');
define('TYPO3_MODE', 'FE');
define('PATH_thisScript', str_replace('//', '/', str_replace(
'\\',
'/',
(php_sapi_name() == 'cgi' || php_sapi_name() == 'isapi' || php_sapi_name() == 'cgi-fcgi') && ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ? ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) : ($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME'])
)));
define('PATH_site', str_replace(['/wsdl', '/typo3conf/ext/ter'], '', dirname(\TYPO3\CMS\Core\Core\Environment::getCurrentScript())) . '/');
define('PATH_typo3', PATH_site . 'typo3/');
define('PATH_typo3conf', PATH_site . 'typo3conf/');
define('TYPO3_mainDir', 'typo3/');
$serviceLocation = 'https://' . $_SERVER['HTTP_HOST'] . '/index.php?id=ter';
$serviceLocation = 'https://' . $_SERVER['HTTP_HOST'] . '/ter';
$wsdlFileName = 'tx_ter.wsdl';
if (getenv('TYPO3_CONTEXT') === 'Production/Stage') {
......
......@@ -95,17 +95,11 @@ abstract class AbstractTerBasedController extends \T3o\TerFe2\Controller\Abstrac
*/
protected function getTerConnection()
{
// Check the wsdl uri
if (empty($this->terSettings['wsdl'])) {
throw new \Exception('No wsdl set to connect to TER server');
}
if (empty($this->terSettings['httpAuth'])) {
$this->terSettings['httpAuth'] = [];
}
// Create connection
$wsdl = $this->terSettings['wsdl'];
return $this->objectManager->get(\T3o\TerFe2\Service\TerService::class, $wsdl, $this->terAccount['username'], $this->terAccount['password'], $this->terSettings['httpAuth']);
return $this->objectManager->get(\T3o\TerFe2\Service\TerService::class, $this->terAccount['username'], $this->terAccount['password'], $this->terSettings['httpAuth']);
}
}
......@@ -21,43 +21,28 @@ class TerService
{
/**
* @var array
* @var object
*/
protected $userData = [];
protected $userData;
/**
* @var string
* @var \tx_ter_api
*/
protected $wsdlUrl;
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
*/
protected $objectManager;
/**
* @var \T3o\TerFe2\Service\SoapService
*/
protected $soapService;
protected $terApi;
/**
* Load TER connection
*
* @param string $wsdlUrl
* @param string $username
* @param string $password
* @param array $httpAuth
*/
public function __construct($wsdlUrl, $username, $password, array $httpAuth = [])
public function __construct($username, $password, array $httpAuth = [])
{
$this->wsdlUrl = $wsdlUrl;
$this->userData = [
'username' => $username,
'password' => $password,
];
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$this->soapService = $objectManager->get(\T3o\TerFe2\Service\SoapService::class);
$this->soapService->connect($this->wsdlUrl, '', '', true, $httpAuth);
$this->userData = new \stdClass();
$this->userData->username = $username;
$this->userData->password = $password;
$this->terApi = new \tx_ter_api($this);
}
/**
......@@ -69,7 +54,7 @@ class TerService
*/
public function checkExtensionKey($extensionKey, &$error)
{
$result = $this->soapService->checkExtensionKey($this->userData, $extensionKey);
$result = $this->terApi->checkExtensionKey($this->userData, $extensionKey);
// if the result is empty
if (empty($result['resultCode'])) {
......@@ -100,7 +85,7 @@ class TerService
*/
public function registerExtension(array $extensionData)
{
$result = $this->soapService->registerExtensionKey($this->userData, $extensionData);
$result = $this->terApi->registerExtensionKey($this->userData, (object)$extensionData);
// if the result is empty
if (empty($result['resultCode'])) {
......@@ -130,10 +115,13 @@ class TerService
*/
public function assignExtensionKey($extensionKey, $username, &$error = '')
{
$result = $this->soapService->modifyExtensionKey($this->userData, [
'extensionKey' => $extensionKey,
'ownerUsername' => $username,
]);
$params = new \stdClass();
$params->extensionKey = $extensionKey;
$params->ownerUsername = $username;
$result = $this->terApi->modifyExtensionKey(
$this->userData,
$params
);
if (empty($result['resultCode'])) {
$error = 'no_result';
......@@ -169,7 +157,7 @@ class TerService
*/
public function deleteExtensionKey($extensionKey)
{
$result = $this->soapService->deleteExtensionKey($this->userData, $extensionKey);
$result = $this->terApi->deleteExtensionKey($this->userData, $extensionKey);
// 10000 = TX_TER_RESULT_GENERAL_OK
return !empty($result['resultCode']) && $result['resultCode'] === '10000';
}
......@@ -183,7 +171,7 @@ class TerService
*/
public function deleteExtensionVersion($extensionKey, $versionString)
{
$result = $this->soapService->deleteExtension($this->userData, $extensionKey, $versionString);
$result = $this->terApi->deleteExtension($this->userData, $extensionKey, $versionString);
// 10505 = TX_TER_RESULT_EXTENSIONSUCCESSFULLYDELETED
return !empty($result['resultCode']) && $result['resultCode'] === '10505';
}
......@@ -199,14 +187,13 @@ class TerService
*/
public function setReviewState($extensionKey, $versionString, $reviewState, &$error = '')
{
$parameters = [
'extensionKey' => $extensionKey,
'version' => $versionString,
'reviewState' => $reviewState,
];
$parameters = new \stdClass();
$parameters->extensionKey = $extensionKey;
$parameters->version = $versionString;
$parameters->reviewState = $reviewState;
try {
$this->soapService->setReviewState($this->userData, $parameters);
$this->terApi->setReviewState($this->userData, $parameters);
} catch (\SoapFault $exception) {
$error = $exception->faultstring;
return false;
......@@ -223,8 +210,9 @@ class TerService
*/
public function getExtensionKeysByUser(&$error)
{
$parameter = ['username' => $this->userData['username']];
$response = $this->soapService->getExtensionKeys($this->userData, $parameter);
$parameter = new \stdClass();
$parameter->username = $this->userData['username'];
$response = $this->terApi->getExtensionKeys($this->userData, $parameter);
$result = $response['simpleResult'];
$extensionKeys = $response['extensionKeyData'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment