‪TYPO3CMS  9.5
BackendUserStartModuleUpdate.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  */
16 
19 
25 {
29  public function ‪getIdentifier(): string
30  {
31  return 'cshmanualBackendUsers';
32  }
33 
37  public function ‪getTitle(): string
38  {
39  return 'Update backend user setting "startModule"';
40  }
41 
45  public function ‪getDescription(): string
46  {
47  return 'The backend user setting startModule is changed for the extensions about/aboutmodules'
48  . ' and help/cshmanual. Update all backend users that use EXT:aboutmodules and'
49  . ' EXT:cshmanual as startModule.';
50  }
51 
57  public function ‪updateNecessary(): bool
58  {
59  $statement = GeneralUtility::makeInstance(ConnectionPool::class)
60  ->getConnectionForTable('be_users')
61  ->select(['uid', 'uc'], 'be_users', []);
62  $needsExecution = false;
63  while ($backendUser = $statement->fetch()) {
64  if ($backendUser['uc'] !== null) {
65  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
66  if ($userConfig['startModule'] === 'help_aboutmodules'
67  || $userConfig['startModule'] === 'help_AboutmodulesAboutmodules'
68  || $userConfig['startModule'] === 'help_AboutAboutmodules'
69  || $userConfig['startModule'] === 'help_CshmanualCshmanual'
70  || $userConfig['startModule'] === 'help_DocumentationCshmanual'
71  ) {
72  $needsExecution = true;
73  break;
74  }
75  }
76  }
77  return $needsExecution;
78  }
79 
83  public function ‪getPrerequisites(): array
84  {
85  return [
86  DatabaseUpdatedPrerequisite::class
87  ];
88  }
89 
96  public function ‪executeUpdate(): bool
97  {
98  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
99  $statement = $queryBuilder->select('uid', 'uc')->from('be_users')->execute();
100  while ($backendUser = $statement->fetch()) {
101  if ($backendUser['uc'] !== null) {
102  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
103  if ($userConfig['startModule'] === 'help_aboutmodules'
104  || $userConfig['startModule'] === 'help_AboutmodulesAboutmodules'
105  || $userConfig['startModule'] === 'help_AboutAboutmodules'
106  || $userConfig['startModule'] === 'help_CshmanualCshmanual'
107  || $userConfig['startModule'] === 'help_DocumentationCshmanual'
108  ) {
109  $userConfig['startModule'] = 'help_AboutAbout';
110  if ($userConfig['startModule'] === 'help_CshmanualCshmanual' || $userConfig['startModule'] === 'help_DocumentationCshmanual') {
111  $userConfig['startModule'] = 'help_BackendCshmanual';
112  }
113  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
114  $queryBuilder->update('be_users')
115  ->where(
116  $queryBuilder->expr()->eq(
117  'uid',
118  $queryBuilder->createNamedParameter($backendUser['uid'], \PDO::PARAM_INT)
119  )
120  )
121  ->set('uc', $queryBuilder->createNamedParameter(serialize($userConfig), \PDO::PARAM_LOB))
122  ->execute();
123  }
124  }
125  }
126  return true;
127  }
128 }
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate
Definition: BackendUserStartModuleUpdate.php:25
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getIdentifier
‪string getIdentifier()
Definition: BackendUserStartModuleUpdate.php:29
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getDescription
‪string getDescription()
Definition: BackendUserStartModuleUpdate.php:45
‪TYPO3\CMS\Install\Updates
Definition: AbstractDownloadExtensionUpdate.php:3
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getTitle
‪string getTitle()
Definition: BackendUserStartModuleUpdate.php:37
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\updateNecessary
‪bool updateNecessary()
Definition: BackendUserStartModuleUpdate.php:57
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\getPrerequisites
‪string[] getPrerequisites()
Definition: BackendUserStartModuleUpdate.php:83
‪TYPO3\CMS\Install\Updates\BackendUserStartModuleUpdate\executeUpdate
‪bool executeUpdate()
Definition: BackendUserStartModuleUpdate.php:96
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:22
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45