TYPO3 CMS  TYPO3_8-7
FileListIsStartModuleUpdate.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of the TYPO3 CMS project.
4  *
5  * It is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License, either version 2
7  * of the License, or any later version.
8  *
9  * For the full copyright and license information, please read the
10  * LICENSE.txt file that was distributed with this source code.
11  *
12  * The TYPO3 project - inspiring people to share!
13  */
14 
16 
19 
24 {
28  protected $title = 'Update filelist user setting "startModule"';
29 
36  public function checkForUpdate(&$description)
37  {
38  if ($this->isWizardDone()) {
39  return false;
40  }
41 
42  $needsExecution = false;
43 
44  $statement = GeneralUtility::makeInstance(ConnectionPool::class)
45  ->getConnectionForTable('be_users')
46  ->select(['uid', 'uc'], 'be_users');
47  while ($backendUser = $statement->fetch()) {
48  if ($backendUser['uc'] !== null) {
49  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
50  if ($userConfig['startModule'] === 'file_list') {
51  $needsExecution = true;
52  break;
53  }
54  }
55  }
56 
57  if ($needsExecution) {
58  $description = 'The backend user setting startModule is changed for the extension filelist.'
59  . ' Update all backend users that use ext:filelist as startModule.';
60  }
61 
62  return $needsExecution;
63  }
64 
72  public function performUpdate(array &$databaseQueries, &$customMessage)
73  {
74  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
75  ->getQueryBuilderForTable('be_users');
76  $statement = $queryBuilder->select('uid', 'uc')->from('be_users')->execute();
77  while ($backendUser = $statement->fetch()) {
78  if ($backendUser['uc'] !== null) {
79  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
80  if ($userConfig['startModule'] === 'file_list') {
81  $userConfig['startModule'] = 'file_FilelistList';
82  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
83  ->getQueryBuilderForTable('be_users');
84  $queryBuilder->update('be_users')
85  ->where(
86  $queryBuilder->expr()->eq(
87  'uid',
88  $queryBuilder->createNamedParameter($backendUser['uid'], \PDO::PARAM_INT)
89  )
90  )
91  ->set('uc', serialize($userConfig));
92  $databaseQueries[] = $queryBuilder->getSQL();
93  $queryBuilder->execute();
94  }
95  }
96  }
97  $this->markWizardAsDone();
98  return true;
99  }
100 }
static makeInstance($className,... $constructorArguments)