[TASK] Remove ext:openid and provide Update Wizard
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / OpenidExtractionUpdate.php
1 <?php
2 namespace TYPO3\CMS\Install\Updates;
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
17 /**
18 * Installs and downloads EXT:openid if needed
19 */
20 class OpenidExtractionUpdate extends AbstractDownloadExtensionUpdate
21 {
22 /**
23 * @var string
24 */
25 protected $title = 'Installs extension "openid" from TER if openid is used.';
26
27 /**
28 * @var string
29 */
30 protected $extensionKey = 'openid';
31
32 /**
33 * @var array
34 */
35 protected $extensionDetails = [
36 'openid' => [
37 'title' => 'OpenID authentication',
38 'description' => 'Adds OpenID authentication to TYPO3',
39 'versionString' => '7.6.0',
40 ]
41 ];
42
43 /**
44 * Checks if an update is needed
45 *
46 * @param string $description The description for the update
47 * @return bool Whether an update is needed (true) or not (false)
48 */
49 public function checkForUpdate(&$description)
50 {
51 $updateNeeded = false;
52
53 if (!$this->isWizardDone()) {
54 $columnsExists = false;
55
56 $columns = $this->getDatabaseConnection()->admin_get_fields('fe_users');
57 if (isset($columns['tx_openid_openid'])) {
58 $columnsExists = true;
59 }
60 $columns = $this->getDatabaseConnection()->admin_get_fields('be_users');
61 if (isset($columns['tx_openid_openid'])) {
62 $columnsExists = true;
63 }
64 if ($columnsExists) {
65 $updateNeeded = true;
66 }
67 }
68
69 $description = 'The extension "openid" (OpenID authentication) was extracted into '
70 . 'the TYPO3 Extension Repository. This update checks if openid id used and '
71 . 'downloads the TYPO3 Extension from the TER.';
72
73 return $updateNeeded;
74 }
75
76 /**
77 * Performs the update if EXT:openid is used.
78 *
79 * @param array $databaseQueries Queries done in this update
80 * @param mixed $customMessages Custom messages
81 * @return bool
82 */
83 public function performUpdate(array &$databaseQueries, &$customMessages)
84 {
85 $updateSuccessful = $this->installExtension($this->extensionKey, $customMessages);
86 if ($updateSuccessful) {
87 $this->markWizardAsDone();
88 }
89 return $updateSuccessful;
90 }
91 }