‪TYPO3CMS  10.4
BackendUserStartModuleUpdate.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
26 {
30  public function ‪getIdentifier(): string
31  {
32  return 'cshmanualBackendUsers';
33  }
34 
38  public function ‪getTitle(): string
39  {
40  return 'Update backend user setting "startModule"';
41  }
42 
46  public function ‪getDescription(): string
47  {
48  return 'The backend user setting startModule is changed for the extensions about/aboutmodules'
49  . ' and help/cshmanual. Update all backend users that use EXT:aboutmodules and'
50  . ' EXT:cshmanual as startModule.';
51  }
52 
58  public function ‪updateNecessary(): bool
59  {
60  $statement = GeneralUtility::makeInstance(ConnectionPool::class)
61  ->getConnectionForTable('be_users')
62  ->select(['uid', 'uc'], 'be_users', []);
63  $needsExecution = false;
64  while ($backendUser = $statement->fetch()) {
65  if ($backendUser['uc'] !== null) {
66  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
67  if ($userConfig['startModule'] === 'help_aboutmodules'
68  || $userConfig['startModule'] === 'help_AboutmodulesAboutmodules'
69  || $userConfig['startModule'] === 'help_AboutAboutmodules'
70  || $userConfig['startModule'] === 'help_CshmanualCshmanual'
71  || $userConfig['startModule'] === 'help_DocumentationCshmanual'
72  ) {
73  $needsExecution = true;
74  break;
75  }
76  }
77  }
78  return $needsExecution;
79  }
80 
84  public function ‪getPrerequisites(): array
85  {
86  return [
87  DatabaseUpdatedPrerequisite::class
88  ];
89  }
90 
97  public function ‪executeUpdate(): bool
98  {
99  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
100  $statement = $queryBuilder->select('uid', 'uc')->from('be_users')->execute();
101  while ($backendUser = $statement->fetch()) {
102  if ($backendUser['uc'] !== null) {
103  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
104  if ($userConfig['startModule'] === 'help_aboutmodules'
105  || $userConfig['startModule'] === 'help_AboutmodulesAboutmodules'
106  || $userConfig['startModule'] === 'help_AboutAboutmodules'
107  || $userConfig['startModule'] === 'help_CshmanualCshmanual'
108  || $userConfig['startModule'] === 'help_DocumentationCshmanual'
109  ) {
110  $userConfig['startModule'] = 'help_AboutAbout';
111  if ($userConfig['startModule'] === 'help_CshmanualCshmanual' || $userConfig['startModule'] === 'help_DocumentationCshmanual') {
112  $userConfig['startModule'] = 'help_BackendCshmanual';
113  }
114  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
115  $queryBuilder->update('be_users')
116  ->where(
117  $queryBuilder->expr()->eq(
118  'uid',
119  $queryBuilder->createNamedParameter($backendUser['uid'], \PDO::PARAM_INT)
120  )
121  )
122  ->set('uc', $queryBuilder->createNamedParameter(serialize($userConfig), \PDO::PARAM_LOB))
123  ->execute();
124  }
125  }
126  }
127  return true;
128  }
129 }
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate
Definition: BackendUserStartModuleUpdate.php:26
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getIdentifier
‪string getIdentifier()
Definition: BackendUserStartModuleUpdate.php:30
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getDescription
‪string getDescription()
Definition: BackendUserStartModuleUpdate.php:46
‪TYPO3\CMS\Install\Updates
Definition: AbstractDownloadExtensionUpdate.php:16
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getTitle
‪string getTitle()
Definition: BackendUserStartModuleUpdate.php:38
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\updateNecessary
‪bool updateNecessary()
Definition: BackendUserStartModuleUpdate.php:58
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getPrerequisites
‪string[] getPrerequisites()
Definition: BackendUserStartModuleUpdate.php:84
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\executeUpdate
‪bool executeUpdate()
Definition: BackendUserStartModuleUpdate.php:97
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:24
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46