Passed
Push — master ( 1b8637...396e5c )
by John
13:19 queued 12s
created
core/Controller/SetupController.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -35,111 +35,111 @@
 block discarded – undo
35 35
 use OCP\ILogger;
36 36
 
37 37
 class SetupController {
38
-	/** @var Setup */
39
-	protected $setupHelper;
40
-	/** @var string */
41
-	private $autoConfigFile;
42
-
43
-	/**
44
-	 * @param Setup $setupHelper
45
-	 */
46
-	public function __construct(Setup $setupHelper) {
47
-		$this->autoConfigFile = \OC::$configDir.'autoconfig.php';
48
-		$this->setupHelper = $setupHelper;
49
-	}
50
-
51
-	/**
52
-	 * @param $post
53
-	 */
54
-	public function run($post) {
55
-		// Check for autosetup:
56
-		$post = $this->loadAutoConfig($post);
57
-		$opts = $this->setupHelper->getSystemInfo();
58
-
59
-		// convert 'abcpassword' to 'abcpass'
60
-		if (isset($post['adminpassword'])) {
61
-			$post['adminpass'] = $post['adminpassword'];
62
-		}
63
-		if (isset($post['dbpassword'])) {
64
-			$post['dbpass'] = $post['dbpassword'];
65
-		}
66
-
67
-		if (!is_file(\OC::$configDir.'/CAN_INSTALL')) {
68
-			$this->displaySetupForbidden();
69
-			return;
70
-		}
71
-
72
-		if (isset($post['install']) and $post['install'] == 'true') {
73
-			// We have to launch the installation process :
74
-			$e = $this->setupHelper->install($post);
75
-			$errors = ['errors' => $e];
76
-
77
-			if (count($e) > 0) {
78
-				$options = array_merge($opts, $post, $errors);
79
-				$this->display($options);
80
-			} else {
81
-				$this->finishSetup();
82
-			}
83
-		} else {
84
-			$options = array_merge($opts, $post);
85
-			$this->display($options);
86
-		}
87
-	}
88
-
89
-	private function displaySetupForbidden() {
90
-		\OC_Template::printGuestPage('', 'installation_forbidden');
91
-	}
92
-
93
-	public function display($post) {
94
-		$defaults = [
95
-			'adminlogin' => '',
96
-			'adminpass' => '',
97
-			'dbuser' => '',
98
-			'dbpass' => '',
99
-			'dbname' => '',
100
-			'dbtablespace' => '',
101
-			'dbhost' => 'localhost',
102
-			'dbtype' => '',
103
-		];
104
-		$parameters = array_merge($defaults, $post);
105
-
106
-		\OC_Template::printGuestPage('', 'installation', $parameters);
107
-	}
108
-
109
-	private function finishSetup() {
110
-		if (file_exists($this->autoConfigFile)) {
111
-			unlink($this->autoConfigFile);
112
-		}
113
-		\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
114
-
115
-		if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
116
-			if (!unlink(\OC::$configDir.'/CAN_INSTALL')) {
117
-				\OC_Template::printGuestPage('', 'installation_incomplete');
118
-			}
119
-		}
120
-
121
-		header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
122
-		exit();
123
-	}
124
-
125
-	public function loadAutoConfig($post) {
126
-		if (file_exists($this->autoConfigFile)) {
127
-			\OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO);
128
-			$AUTOCONFIG = [];
129
-			include $this->autoConfigFile;
130
-			$post = array_merge($post, $AUTOCONFIG);
131
-		}
132
-
133
-		$dbIsSet = isset($post['dbtype']);
134
-		$directoryIsSet = isset($post['directory']);
135
-		$adminAccountIsSet = isset($post['adminlogin']);
136
-
137
-		if ($dbIsSet and $directoryIsSet and $adminAccountIsSet) {
138
-			$post['install'] = 'true';
139
-		}
140
-		$post['dbIsSet'] = $dbIsSet;
141
-		$post['directoryIsSet'] = $directoryIsSet;
142
-
143
-		return $post;
144
-	}
38
+    /** @var Setup */
39
+    protected $setupHelper;
40
+    /** @var string */
41
+    private $autoConfigFile;
42
+
43
+    /**
44
+     * @param Setup $setupHelper
45
+     */
46
+    public function __construct(Setup $setupHelper) {
47
+        $this->autoConfigFile = \OC::$configDir.'autoconfig.php';
48
+        $this->setupHelper = $setupHelper;
49
+    }
50
+
51
+    /**
52
+     * @param $post
53
+     */
54
+    public function run($post) {
55
+        // Check for autosetup:
56
+        $post = $this->loadAutoConfig($post);
57
+        $opts = $this->setupHelper->getSystemInfo();
58
+
59
+        // convert 'abcpassword' to 'abcpass'
60
+        if (isset($post['adminpassword'])) {
61
+            $post['adminpass'] = $post['adminpassword'];
62
+        }
63
+        if (isset($post['dbpassword'])) {
64
+            $post['dbpass'] = $post['dbpassword'];
65
+        }
66
+
67
+        if (!is_file(\OC::$configDir.'/CAN_INSTALL')) {
68
+            $this->displaySetupForbidden();
69
+            return;
70
+        }
71
+
72
+        if (isset($post['install']) and $post['install'] == 'true') {
73
+            // We have to launch the installation process :
74
+            $e = $this->setupHelper->install($post);
75
+            $errors = ['errors' => $e];
76
+
77
+            if (count($e) > 0) {
78
+                $options = array_merge($opts, $post, $errors);
79
+                $this->display($options);
80
+            } else {
81
+                $this->finishSetup();
82
+            }
83
+        } else {
84
+            $options = array_merge($opts, $post);
85
+            $this->display($options);
86
+        }
87
+    }
88
+
89
+    private function displaySetupForbidden() {
90
+        \OC_Template::printGuestPage('', 'installation_forbidden');
91
+    }
92
+
93
+    public function display($post) {
94
+        $defaults = [
95
+            'adminlogin' => '',
96
+            'adminpass' => '',
97
+            'dbuser' => '',
98
+            'dbpass' => '',
99
+            'dbname' => '',
100
+            'dbtablespace' => '',
101
+            'dbhost' => 'localhost',
102
+            'dbtype' => '',
103
+        ];
104
+        $parameters = array_merge($defaults, $post);
105
+
106
+        \OC_Template::printGuestPage('', 'installation', $parameters);
107
+    }
108
+
109
+    private function finishSetup() {
110
+        if (file_exists($this->autoConfigFile)) {
111
+            unlink($this->autoConfigFile);
112
+        }
113
+        \OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
114
+
115
+        if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
116
+            if (!unlink(\OC::$configDir.'/CAN_INSTALL')) {
117
+                \OC_Template::printGuestPage('', 'installation_incomplete');
118
+            }
119
+        }
120
+
121
+        header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
122
+        exit();
123
+    }
124
+
125
+    public function loadAutoConfig($post) {
126
+        if (file_exists($this->autoConfigFile)) {
127
+            \OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO);
128
+            $AUTOCONFIG = [];
129
+            include $this->autoConfigFile;
130
+            $post = array_merge($post, $AUTOCONFIG);
131
+        }
132
+
133
+        $dbIsSet = isset($post['dbtype']);
134
+        $directoryIsSet = isset($post['directory']);
135
+        $adminAccountIsSet = isset($post['adminlogin']);
136
+
137
+        if ($dbIsSet and $directoryIsSet and $adminAccountIsSet) {
138
+            $post['install'] = 'true';
139
+        }
140
+        $post['dbIsSet'] = $dbIsSet;
141
+        $post['directoryIsSet'] = $directoryIsSet;
142
+
143
+        return $post;
144
+    }
145 145
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@
 block discarded – undo
118 118
 			}
119 119
 		}
120 120
 
121
-		header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
121
+		header('Location: '.\OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
122 122
 		exit();
123 123
 	}
124 124
 
Please login to merge, or discard this patch.