‪TYPO3CMS  9.5
SysNoteRepository.php
Go to the documentation of this file.
1 <?php
2 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 
21 
28 {
31 
40  public function ‪findByPidsAndAuthorId($pids, int $author, int $position = null): array
41  {
42  $pids = GeneralUtility::intExplode(',', (string)$pids);
43 
44  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
45  ->getQueryBuilderForTable('sys_note');
46  $queryBuilder->getRestrictions()->removeAll();
47  $res = $queryBuilder
48  ->select(
49  'sys_note.*',
50  'be_users.username AS authorUsername',
51  'be_users.realName AS authorRealName',
52  'be_users.disable AS authorDisabled',
53  'be_users.deleted AS authorDeleted'
54  )
55  ->from('sys_note')
56  ->leftJoin(
57  'sys_note',
58  'be_users',
59  'be_users',
60  $queryBuilder->expr()->eq('sys_note.cruser', $queryBuilder->quoteIdentifier('be_users.uid'))
61  )
62  ->where(
63  $queryBuilder->expr()->eq('sys_note.deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
64  $queryBuilder->expr()->in('sys_note.pid', $queryBuilder->createNamedParameter($pids, Connection::PARAM_INT_ARRAY)),
65  $queryBuilder->expr()->orX(
66  $queryBuilder->expr()->eq('sys_note.personal', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
67  $queryBuilder->expr()->eq('sys_note.cruser', $queryBuilder->createNamedParameter($author, \PDO::PARAM_INT))
68  )
69  )
70  ->orderBy('sorting', 'asc')
71  ->addOrderBy('crdate', 'desc');
72 
73  if ($position !== null) {
74  $res->andWhere(
75  $queryBuilder->expr()->eq('sys_note.position', $queryBuilder->createNamedParameter($position, \PDO::PARAM_INT))
76  );
77  }
78 
79  return $res->execute()->fetchAll();
80  }
81 }
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository\SYS_NOTE_POSITION_BOTTOM
‪const SYS_NOTE_POSITION_BOTTOM
Definition: SysNoteRepository.php:29
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository\findByPidsAndAuthorId
‪array findByPidsAndAuthorId($pids, int $author, int $position=null)
Definition: SysNoteRepository.php:40
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository
Definition: SysNoteRepository.php:28
‪TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository\SYS_NOTE_POSITION_TOP
‪const SYS_NOTE_POSITION_TOP
Definition: SysNoteRepository.php:30
‪TYPO3\CMS\SysNote\Domain\Repository
Definition: SysNoteRepository.php:3
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:31
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45