[CLEANUP] Unqoute integer in BackendUserSessionRepository
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / Classes / Domain / Repository / BackendUserSessionRepository.php
1 <?php
2 namespace TYPO3\CMS\Beuser\Domain\Repository;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Repository for \TYPO3\CMS\Extbase\Domain\Model\BackendUser
19 *
20 * @author Felix Kopp <felix-source@phorax.com>
21 * @author Pascal Dürsteler <pascal@notionlab.ch>
22 */
23 class BackendUserSessionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
24
25 /**
26 * Find Sessions for specific BackendUser
27 * Delivers an Array, not an ObjectStorage!
28 *
29 * @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser
30 * @return array
31 */
32 public function findByBackendUser(\TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser) {
33 $sessions = array();
34 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
35 'ses_id AS id, ses_iplock AS ip, ses_tstamp AS timestamp',
36 'be_sessions',
37 'ses_userid = ' . (int)$backendUser->getUid(),
38 '',
39 'ses_tstamp ASC'
40 );
41 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
42 $sessions[] = array(
43 'id' => $row['id'],
44 'ip' => $row['ip'],
45 'timestamp' => $row['timestamp']
46 );
47 }
48 $GLOBALS['TYPO3_DB']->sql_free_result($res);
49 return $sessions;
50 }
51
52 /**
53 * Update current session to move back to the original user.
54 *
55 * @param \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication $authentication
56 * @return void
57 */
58 public function switchBackToOriginalUser(\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication $authentication) {
59 $updateData = array(
60 'ses_userid' => $authentication->user['ses_backuserid'],
61 'ses_backuserid' => 0,
62 );
63 $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
64 'be_sessions',
65 'ses_id = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions') .
66 ' AND ses_name = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName(), 'be_sessions') .
67 ' AND ses_userid=' . (int)$GLOBALS['BE_USER']->user['uid'], $updateData
68 );
69 }
70
71 }