TYPO3 CMS  TYPO3_7-6
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 
21 {
25  protected $title = 'Update backend user setting "startModule"';
26 
33  public function checkForUpdate(&$description)
34  {
35  $backendUsersCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', 'be_users');
36  if ($this->isWizardDone() || $backendUsersCount === 0) {
37  return false;
38  }
39 
40  $description = 'The backend user setting startModule is changed for the extension aboutmodules. Update all backend users that use ext:aboutmodules as startModule.';
41 
42  return true;
43  }
44 
52  public function performUpdate(array &$databaseQueries, &$customMessages)
53  {
54  $db = $this->getDatabaseConnection();
55  $backendUsers = $db->exec_SELECTgetRows('uid,uc', 'be_users', '1=1');
56  if (!empty($backendUsers)) {
57  foreach ($backendUsers as $backendUser) {
58  if ($backendUser['uc'] !== null) {
59  $userConfig = unserialize($backendUser['uc']);
60  if ($userConfig['startModule'] === 'help_aboutmodules') {
61  $userConfig['startModule'] = 'help_AboutmodulesAboutmodules';
62  $db->exec_UPDATEquery(
63  'be_users',
64  'uid=' . (int)$backendUser['uid'],
65  [
66  'uc' => serialize($userConfig),
67  ]
68  );
69  $databaseQueries[] = $db->debug_lastBuiltQuery;
70  }
71  }
72  }
73  }
74 
75  $this->markWizardAsDone();
76  return true;
77  }
78 }