[TASK] Replace DatabaseConnection->cleanIntArray()
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / Classes / Domain / Repository / BackendUserRepository.php
index 1bf84cd..fbe3ab1 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Beuser\Domain\Repository;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Repository for \TYPO3\CMS\Beuser\Domain\Model\BackendUser
  */
@@ -28,7 +31,7 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
     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', array_map('intval', $uidList)))->execute();
     }
 
     /**
@@ -46,10 +49,13 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
         $query->setOrderings(array('userName' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING));
         // Username
         if ($demand->getUserName() !== '') {
-            $constraints[] = $query->like(
-                'userName',
-                '%' . $GLOBALS['TYPO3_DB']->escapeStrForLike($demand->getUserName(), 'be_users') . '%'
-            );
+            $searchConstraints = array();
+            foreach (array('userName', 'uid', 'realName') as $field) {
+                $searchConstraints[] = $query->like(
+                    $field, '%' . $GLOBALS['TYPO3_DB']->escapeStrForLike($demand->getUserName(), 'be_users') . '%'
+                );
+            }
+            $constraints[] = $query->logicalOr($searchConstraints);
         }
         // Only display admin users
         if ($demand->getUserType() == \TYPO3\CMS\Beuser\Domain\Model\Demand::USERTYPE_ADMINONLY) {
@@ -98,11 +104,19 @@ class BackendUserRepository extends \TYPO3\CMS\Extbase\Domain\Repository\Backend
     public function findOnline()
     {
         $uids = array();
-        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('DISTINCT ses_userid', 'be_sessions', '');
-        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_sessions');
+
+        $res = $queryBuilder
+            ->select('ses_userid')
+            ->from('be_sessions')
+            ->groupBy('ses_userid')
+            ->execute();
+
+        while ($row = $res->fetch()) {
             $uids[] = $row['ses_userid'];
         }
-        $GLOBALS['TYPO3_DB']->sql_free_result($res);
+
         $query = $this->createQuery();
         $query->matching($query->in('uid', $uids));
         return $query->execute();