‪TYPO3CMS  10.4
SysNoteRepository.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 
30 {
33 
42  public function ‪findByPidsAndAuthorId($pids, int $author, int $position = null): array
43  {
44  $pids = ‪GeneralUtility::intExplode(',', (string)$pids);
45 
46  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
47  ->getQueryBuilderForTable('sys_note');
48  $queryBuilder->getRestrictions()->removeAll();
49  $res = $queryBuilder
50  ->select(
51  'sys_note.*',
52  'be_users.username AS authorUsername',
53  'be_users.realName AS authorRealName',
54  'be_users.disable AS authorDisabled',
55  'be_users.deleted AS authorDeleted'
56  )
57  ->from('sys_note')
58  ->leftJoin(
59  'sys_note',
60  'be_users',
61  'be_users',
62  $queryBuilder->expr()->eq('sys_note.cruser', $queryBuilder->quoteIdentifier('be_users.uid'))
63  )
64  ->where(
65  $queryBuilder->expr()->eq('sys_note.deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
66  $queryBuilder->expr()->in('sys_note.pid', $queryBuilder->createNamedParameter($pids, Connection::PARAM_INT_ARRAY)),
67  $queryBuilder->expr()->orX(
68  $queryBuilder->expr()->eq('sys_note.personal', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
69  $queryBuilder->expr()->eq('sys_note.cruser', $queryBuilder->createNamedParameter($author, \PDO::PARAM_INT))
70  )
71  )
72  ->orderBy('sorting', 'asc')
73  ->addOrderBy('crdate', 'desc');
74 
75  if ($position !== null) {
76  $res->andWhere(
77  $queryBuilder->expr()->eq('sys_note.position', $queryBuilder->createNamedParameter($position, \PDO::PARAM_INT))
78  );
79  }
80 
81  return $res->execute()->fetchAll();
82  }
83 }
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository\SYS_NOTE_POSITION_BOTTOM
‪const SYS_NOTE_POSITION_BOTTOM
Definition: SysNoteRepository.php:31
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository\findByPidsAndAuthorId
‪array findByPidsAndAuthorId($pids, int $author, int $position=null)
Definition: SysNoteRepository.php:42
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository
Definition: SysNoteRepository.php:30
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository\SYS_NOTE_POSITION_TOP
‪const SYS_NOTE_POSITION_TOP
Definition: SysNoteRepository.php:32
‪TYPO3\CMS\SysNote\Domain\Repository
Definition: SysNoteRepository.php:18
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:36
‪TYPO3\CMS\Core\Utility\GeneralUtility\intExplode
‪static int[] intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:988
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46