TYPO3 CMS  TYPO3_7-6
RecordService.php
Go to the documentation of this file.
1 <?php
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  */
17 
22 {
26  protected $records = [];
27 
32  public function add($tableName, $id)
33  {
34  $databaseRecord = DatabaseRecord::create($tableName, $id);
35  if (!isset($this->records[$databaseRecord->getIdentifier()])) {
36  $this->records[$databaseRecord->getIdentifier()] = $databaseRecord;
37  }
38  }
39 
43  public function getIdsPerTable()
44  {
45  $idsPerTable = [];
46  foreach ($this->records as $databaseRecord) {
47  if (!isset($idsPerTable[$databaseRecord->getTable()])) {
48  $idsPerTable[$databaseRecord->getTable()] = [];
49  }
50  $idsPerTable[$databaseRecord->getTable()][] = $databaseRecord->getUid();
51  }
52  return $idsPerTable;
53  }
54 
58  public function getCreateUserIds()
59  {
60  $createUserIds = [];
61  foreach ($this->getIdsPerTable() as $tableName => $ids) {
62  if (empty($GLOBALS['TCA'][$tableName]['ctrl']['cruser_id'])) {
63  continue;
64  }
65  $createUserIdFieldName = $GLOBALS['TCA'][$tableName]['ctrl']['cruser_id'];
66  $records = $this->getDatabaseConnection()->exec_SELECTgetRows(
67  $createUserIdFieldName, $tableName,
68  'uid IN (' . implode(',', $ids) . ')',
69  $createUserIdFieldName,
70  '', '',
71  $createUserIdFieldName
72  );
73  if (!empty($records)) {
74  $createUserIds = array_merge($createUserIds, array_keys($records));
75  }
76  }
77  return array_unique($createUserIds);
78  }
79 
83  protected function getDatabaseConnection()
84  {
85  return $GLOBALS['TYPO3_DB'];
86  }
87 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']