Commit 58abc878 authored by Wouter Wolters's avatar Wouter Wolters Committed by Oliver Hader
Browse files

[TASK] Cleanup "beuser" sysext

This is a non-functional change that reformats the code, removes
unnecessary empty lines and fixes namespaces in phpDoc. In addition
the following to changes are made:
- add $GLOBALS['TYPO3_DB']->sql_free_result() calls to free some memory
- change bu:SpriteIconForRecord to bu:spriteIconForRecord in templates

Change-Id: I6e832921c46f828c9db0c796d662bd8390b5ac5f
Resolves: #45343
Releases: 6.0, 6.1
Reviewed-on: https://review.typo3.org/18190
Reviewed-by: Oliver Klee
Reviewed-by: Markus Günther
Tested-by: Markus Günther
Reviewed-by: Stefan Neufeind
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
parent 4c15ae09
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Controller;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Backend module user administration controller
*
......@@ -66,8 +67,8 @@ class BackendUserController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
*
* @param \TYPO3\CMS\Extbase\Mvc\RequestInterface $request
* @param \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @return void
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
public function processRequest(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response) {
$this->moduleData = $this->moduleDataStorageService->loadModuleData();
......@@ -84,8 +85,8 @@ class BackendUserController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
/**
* Initialize actions
*
* @throws \RuntimeException
* @return void
* @throws \RuntimeException
*/
public function initializeAction() {
// @TODO: Extbase backend modules relies on frontend TypoScript for view, persistence
......@@ -193,7 +194,10 @@ class BackendUserController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
* @return void
*/
protected function terminateBackendUserSessionAction(\TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser, $sessionId) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('be_sessions', 'ses_userid = "' . intval($backendUser->getUid()) . '" AND ses_id = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($sessionId, 'be_sessions') . ' LIMIT 1');
$GLOBALS['TYPO3_DB']->exec_DELETEquery(
'be_sessions',
'ses_userid = "' . intval($backendUser->getUid()) . '" AND ses_id = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($sessionId, 'be_sessions') . ' LIMIT 1'
);
if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 1) {
$message = 'Session successfully terminated.';
$this->flashMessageContainer->add($message, '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
......@@ -204,7 +208,7 @@ class BackendUserController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
/**
* Switches to a given user (SU-mode) and then redirects to the start page of the backend to refresh the navigation etc.
*
* @param array $switchUser BE-user record that will be switched to
* @param string $switchUser BE-user record that will be switched to
* @param boolean $switchBack
* @return void
*/
......@@ -216,7 +220,16 @@ class BackendUserController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
if ($switchBack) {
$updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']);
}
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions') . ' AND ses_name=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName(), 'be_sessions') . ' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']), $updateData);
$whereClause = 'ses_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions');
$whereClause .= ' AND ses_name=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName(), 'be_sessions');
$whereClause .= ' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'be_sessions',
$whereClause,
$updateData
);
$redirectUrl = $GLOBALS['BACK_PATH'] . 'index.php' . ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] ? '' : '?commandLI=1');
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl);
}
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Domain\Model;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Model for backend user
*
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Domain\Model;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Model for backend user group
*
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Domain\Model;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Demand filter for listings
*
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Domain\Model;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Module data object
*
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Domain\Repository;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Repository for \TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup
*
......
......@@ -25,8 +25,9 @@ namespace TYPO3\CMS\Beuser\Domain\Repository;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Repository for Tx_Beuser_Domain_Model_BackendUser
* Repository for \TYPO3\CMS\Beuser\Domain\Model\BackendUser
*
* @author Felix Kopp <felix-source@phorax.com>
*/
......@@ -36,18 +37,18 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
* Finds Backend Users on a given list of uids
*
* @param array $uidList
* @return Tx_Extbase_Persistence_QueryResult<Tx_Beuser_Domain_Model_BackendUser>
* @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult<\TYPO3\CMS\Beuser\Domain\Model\BackendUser>
*/
public function findByUidList($uidList) {
public function findByUidList(array $uidList) {
$query = $this->createQuery();
return $query->matching($query->in('uid', $GLOBALS['TYPO3_DB']::cleanIntArray($uidList)))->execute();
return $query->matching($query->in('uid', $GLOBALS['TYPO3_DB']->cleanIntArray($uidList)))->execute();
}
/**
* Find Backend Users matching to Demand object properties
*
* @param \TYPO3\CMS\Beuser\Domain\Model\Demand $demand
* @return Tx_Extbase_Persistence_QueryResult<Tx_Beuser_Domain_Model_BackendUser>
* @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult<\TYPO3\CMS\Beuser\Domain\Model\BackendUser>
*/
public function findDemanded(\TYPO3\CMS\Beuser\Domain\Model\Demand $demand) {
$constraints = array();
......@@ -104,7 +105,7 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
/**
* Find Backend Users currently online
*
* @return Tx_Extbase_Persistence_QueryResult<Tx_Beuser_Domain_Model_BackendUser>
* @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult<\TYPO3\CMS\Beuser\Domain\Model\BackendUser>
*/
public function findOnline() {
$uids = array();
......@@ -112,6 +113,7 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$uids[] = $row['ses_userid'];
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
$query = $this->createQuery();
$query->matching($query->in('uid', $uids));
return $query->execute();
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Domain\Repository;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Repository for Tx_Beuser_Domain_Model_BackendUser
*
......@@ -34,7 +35,7 @@ class BackendUserSessionRepository extends \TYPO3\CMS\Extbase\Persistence\Reposi
/**
* Find Sessions for specific BackendUser
* Delivers Array, not ObjectStorage!
* Delivers an Array, not an ObjectStorage!
*
* @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser
* @return array
......@@ -55,6 +56,7 @@ class BackendUserSessionRepository extends \TYPO3\CMS\Extbase\Persistence\Reposi
'timestamp' => new \DateTime('@' . $row['timestamp'])
);
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return $sessions;
}
......
......@@ -61,7 +61,8 @@ class SwitchBackUserHook {
'be_sessions',
'ses_id = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions') .
' AND ses_name = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName(), 'be_sessions') .
' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']), $updateData);
' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']), $updateData
);
$redirectUrl = $GLOBALS['BACK_PATH'] . 'index.php' . ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] ? '' : '?commandLI=1');
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl);
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\Service;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Module data storage service.
* Used to store and retrieve module state (eg. checkboxes, selections).
......@@ -72,4 +73,4 @@ class ModuleDataStorageService implements \TYPO3\CMS\Core\SingletonInterface {
}
?>
\ No newline at end of file
?>
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers\Display;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Converts comma separated list of pages uids to html unordered list (<ul>) with speaking titles
*
......@@ -33,6 +34,8 @@ namespace TYPO3\CMS\Beuser\ViewHelpers\Display;
class PagesViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
/**
* Render unordered list for pages
*
* @param string $uids
* @return string
*/
......@@ -51,6 +54,7 @@ class PagesViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelpe
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content .= '<li>' . $row['title'] . ' [' . $row['uid'] . ']</li>';
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return '<ul>' . $content . '</ul>';
}
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers\Display;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Converts comma separated list of sys_filemounts uids to html unordered list (<ul>) with speaking titles
*
......@@ -33,6 +34,8 @@ namespace TYPO3\CMS\Beuser\ViewHelpers\Display;
class SysFileMountsViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
/**
* Render unordered list for sys_filemounts
*
* @param string $uids
* @return string
*/
......@@ -51,6 +54,7 @@ class SysFileMountsViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractV
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content .= '<li>' . $row['title'] . ' [' . $row['uid'] . ']</li>';
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return '<ul>' . $content . '</ul>';
}
......
......@@ -33,6 +33,8 @@ namespace TYPO3\CMS\Beuser\ViewHelpers\Display;
class SysLanguageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
/**
* Render unordered list for sys_language
*
* @param string $uids
* @return string
*/
......@@ -51,6 +53,7 @@ class SysLanguageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractVie
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content .= '<li>' . $row['title'] . ' [' . $row['uid'] . ']</li>';
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return '<ul>' . $content . '</ul>';
}
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Issue command ViewHelper, see TYPO3 Core Engine method issueCommand
*
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Displays a section in backend module template, similar to template::section()
*
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Views sprite icon for a record (object)
*
......@@ -38,7 +39,7 @@ class SpriteIconForRecordViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\Abst
* @param string $table
* @param object $object
* @return string
* @see t3lib_iconWorks::getSpriteIconForRecord($table, $row)
* @see \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row)
*/
public function render($table, $object) {
if (!is_object($object) || !method_exists($object, 'getUid')) {
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Displays sprite icon identified by iconName key
*
......
......@@ -25,6 +25,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Displays 'SwitchUser' link with sprite icon to change current backend user to target (non-admin) backendUser
*
......@@ -33,6 +34,8 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
class SwitchUserViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
/**
* Render link with sprite icon to change current backend user to target
*
* @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser Target backendUser to switch active session to
* @param boolean $emulate Return to current session or logout after target session termination?
* @return string
......
{namespace bu = TYPO3\CMS\Beuser\ViewHelpers}
<bu:Section title="Filter" collapsible="TRUE">
<bu:section title="Filter" collapsible="TRUE">
<f:form action="index" objectName="demand" object="{demand}">
<div>
<label for="tx_Beuser_username"><f:translate key="userName">Username</f:translate></label>
......@@ -44,4 +44,4 @@
</div>
<f:form.submit class="indent" value="{f:translate(key: 'filter')}" />
</f:form>
</bu:Section>
\ No newline at end of file
</bu:section>
\ No newline at end of file
......@@ -3,7 +3,7 @@
<f:layout name="Default" />
<f:section name="iconButtons">
<f:link.action action="index"><bu:SpriteManagerIcon iconName="actions-view-go-back" /></f:link.action>
<f:link.action action="index"><bu:spriteManagerIcon iconName="actions-view-go-back" /></f:link.action>
</f:section>
<f:section name="content">
......@@ -15,7 +15,7 @@
<f:for each="{compareUserList}" as="compareUser">
<td>
<a href="#" onClick="showClickmenu('be_users', '{compareUser.uid}', '1', '', '', ''); return false;" title="id={compareUser.uid}">
<bu:SpriteIconForRecord table="be_users" object="{compareUser}" />
<bu:spriteIconForRecord table="be_users" object="{compareUser}" />
</a>
{compareUser.userName}
</td>
......@@ -64,12 +64,12 @@
<f:if condition="{compareUser.isDisabled} == 1">
<f:then>
<a href="<bu:issueCommand parameters="tce_db.php?&data[be_users][{compareUser.uid}][disable]=0&redirect={redirectUrl}" />">
<bu:SpriteManagerIcon iconName="actions-edit-unhide" options="{title: 'unhide'}" />
<bu:spriteManagerIcon iconName="actions-edit-unhide" options="{title: 'unhide'}" />
</a>
</f:then>
<f:else>
<a href="<bu:issueCommand parameters="tce_db.php?&data[be_users][{compareUser.uid}][disable]=1&redirect={redirectUrl}" />">
<bu:SpriteManagerIcon iconName="actions-edit-hide" options="{title: 'hide'}" />
<bu:spriteManagerIcon iconName="actions-edit-hide" options="{title: 'hide'}" />
</a>
</f:else>
</f:if>
......@@ -127,7 +127,7 @@
<td>
<f:for each="{compareUser.BackendUserGroups}" as="backendUserGroup">
<a href="#" onClick="showClickmenu('be_groups', '{backendUserGroup.uid}', '1', '', '', ''); return false;" title="id={backendUserGroup.uid}">
<bu:SpriteIconForRecord table="be_users" object="{backendUserGroup}" />
<bu:spriteIconForRecord table="be_users" object="{backendUserGroup}" />
</a>
{backendUserGroup.title}<br />
</f:for>
......@@ -195,5 +195,4 @@
</f:for>
</tr>
</table>
</f:section>
\ No newline at end of file
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