Passed
Push — master ( 645109...008e6d )
by Christoph
12:14 queued 12s
created
core/templates/installation.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 script('core', [
3
-	'dist/install'
3
+    'dist/install'
4 4
 ]);
5 5
 ?>
6 6
 <input type='hidden' id='hasMySQL' value='<?php p($_['hasMySQL']) ?>'>
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 		<legend><strong><?php p($l->t('Security warning'));?></strong></legend>
30 30
 		<p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.'));?><br>
31 31
 		<?php print_unescaped($l->t(
32
-			'For information how to properly configure your server, please see the <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.',
33
-			[link_to_docs('admin-install')]
34
-		)); ?></p>
32
+            'For information how to properly configure your server, please see the <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.',
33
+            [link_to_docs('admin-install')]
34
+        )); ?></p>
35 35
 	</fieldset>
36 36
 	<?php endif; ?>
37 37
 	<fieldset id="adminaccount">
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	<?php if(!$_['dbIsSet'] or count($_['errors']) > 0): ?>
76 76
 	<fieldset id='databaseBackend'>
77 77
 		<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'])
78
-			$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite?>
78
+            $hasOtherDB = true; else $hasOtherDB =false; //other than SQLite?>
79 79
 		<legend><?php p($l->t('Configure the database')); ?></legend>
80 80
 		<div id="selectDbType">
81 81
 		<?php foreach($_['databases'] as $type => $label): ?>
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 <input type='hidden' id='hasOracle' value='<?php p($_['hasOracle']) ?>'>
10 10
 <form action="index.php" method="post">
11 11
 <input type="hidden" name="install" value="true">
12
-	<?php if(count($_['errors']) > 0): ?>
12
+	<?php if (count($_['errors']) > 0): ?>
13 13
 	<fieldset class="warning">
14
-		<legend><strong><?php p($l->t('Error'));?></strong></legend>
15
-		<?php foreach($_['errors'] as $err): ?>
14
+		<legend><strong><?php p($l->t('Error')); ?></strong></legend>
15
+		<?php foreach ($_['errors'] as $err): ?>
16 16
 		<p>
17
-			<?php if(is_array($err)):?>
17
+			<?php if (is_array($err)):?>
18 18
 				<?php p($err['error']); ?>
19 19
 				<span class='hint'><?php p($err['hint']); ?></span>
20 20
 			<?php else: ?>
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 		<?php endforeach; ?>
25 25
 	</fieldset>
26 26
 	<?php endif; ?>
27
-	<?php if(!$_['htaccessWorking']): ?>
27
+	<?php if (!$_['htaccessWorking']): ?>
28 28
 	<fieldset class="warning">
29
-		<legend><strong><?php p($l->t('Security warning'));?></strong></legend>
30
-		<p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.'));?><br>
29
+		<legend><strong><?php p($l->t('Security warning')); ?></strong></legend>
30
+		<p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.')); ?><br>
31 31
 		<?php print_unescaped($l->t(
32 32
 			'For information how to properly configure your server, please see the <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.',
33 33
 			[link_to_docs('admin-install')]
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 		</p>
55 55
 	</fieldset>
56 56
 
57
-	<?php if(!$_['directoryIsSet'] or !$_['dbIsSet'] or count($_['errors']) > 0): ?>
57
+	<?php if (!$_['directoryIsSet'] or !$_['dbIsSet'] or count($_['errors']) > 0): ?>
58 58
 	<fieldset id="advancedHeader">
59 59
 		<legend><a id="showAdvanced" tabindex="0" href="#"><?php p($l->t('Storage & database')); ?><img src="<?php print_unescaped(image_path('', 'actions/caret-white.svg')); ?>" /></a></legend>
60 60
 	</fieldset>
61 61
 	<?php endif; ?>
62 62
 
63
-	<?php if(!$_['directoryIsSet'] or count($_['errors']) > 0): ?>
63
+	<?php if (!$_['directoryIsSet'] or count($_['errors']) > 0): ?>
64 64
 	<fieldset id="datadirField">
65 65
 		<div id="datadirContent">
66 66
 			<label for="directory"><?php p($l->t('Data folder')); ?></label>
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 	</fieldset>
73 73
 	<?php endif; ?>
74 74
 
75
-	<?php if(!$_['dbIsSet'] or count($_['errors']) > 0): ?>
75
+	<?php if (!$_['dbIsSet'] or count($_['errors']) > 0): ?>
76 76
 	<fieldset id='databaseBackend'>
77
-		<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'])
78
-			$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite?>
77
+		<?php if ($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'])
78
+			$hasOtherDB = true; else $hasOtherDB = false; //other than SQLite?>
79 79
 		<legend><?php p($l->t('Configure the database')); ?></legend>
80 80
 		<div id="selectDbType">
81
-		<?php foreach($_['databases'] as $type => $label): ?>
82
-		<?php if(count($_['databases']) === 1): ?>
81
+		<?php foreach ($_['databases'] as $type => $label): ?>
82
+		<?php if (count($_['databases']) === 1): ?>
83 83
 		<p class="info">
84 84
 			<?php p($l->t('Only %s is available.', [$label])); ?>
85 85
 			<?php p($l->t('Install and activate additional PHP modules to choose other database types.')); ?><br>
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		</div>
97 97
 	</fieldset>
98 98
 
99
-		<?php if($hasOtherDB): ?>
99
+		<?php if ($hasOtherDB): ?>
100 100
 		<fieldset id='databaseField'>
101 101
 		<div id="use_other_db">
102 102
 			<p class="grouptop">
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 					autocomplete="off" autocapitalize="none" autocorrect="off"
124 124
 					pattern="[0-9a-zA-Z$_-]+">
125 125
 			</p>
126
-			<?php if($_['hasOracle']): ?>
126
+			<?php if ($_['hasOracle']): ?>
127 127
 			<div id="use_oracle_db">
128 128
 				<p class="groupmiddle">
129 129
 					<label for="dbtablespace" class="infield"><?php p($l->t('Database tablespace')); ?></label>
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 		<?php endif; ?>
150 150
 	<?php endif; ?>
151 151
 
152
-	<?php if(!$_['dbIsSet'] or count($_['errors']) > 0): ?>
152
+	<?php if (!$_['dbIsSet'] or count($_['errors']) > 0): ?>
153 153
 		<fieldset id="sqliteInformation" class="warning">
154
-			<legend><?php p($l->t('Performance warning'));?></legend>
155
-			<p><?php p($l->t('You chose SQLite as database.'));?></p>
156
-			<p><?php p($l->t('SQLite should only be used for minimal and development instances. For production we recommend a different database backend.'));?></p>
154
+			<legend><?php p($l->t('Performance warning')); ?></legend>
155
+			<p><?php p($l->t('You chose SQLite as database.')); ?></p>
156
+			<p><?php p($l->t('SQLite should only be used for minimal and development instances. For production we recommend a different database backend.')); ?></p>
157 157
 			<p><?php p($l->t('If you use clients for file syncing, the use of SQLite is highly discouraged.')); ?></p>
158 158
 		</fieldset>
159 159
 	<?php endif ?>
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 	<p class="info">
176 176
 		<span class="icon-info-white"></span>
177
-		<?php p($l->t('Need help?'));?>
178
-		<a target="_blank" rel="noreferrer noopener" href="<?php p(link_to_docs('admin-install')); ?>"><?php p($l->t('See the documentation'));?> ↗</a>
177
+		<?php p($l->t('Need help?')); ?>
178
+		<a target="_blank" rel="noreferrer noopener" href="<?php p(link_to_docs('admin-install')); ?>"><?php p($l->t('See the documentation')); ?> ↗</a>
179 179
 	</p>
180 180
 </form>
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,8 +17,11 @@  discard block
 block discarded – undo
17 17
 			<?php if(is_array($err)):?>
18 18
 				<?php p($err['error']); ?>
19 19
 				<span class='hint'><?php p($err['hint']); ?></span>
20
-			<?php else: ?>
21
-				<?php p($err); ?>
20
+			<?php else {
21
+    : ?>
22
+				<?php p($err);
23
+}
24
+?>
22 25
 			<?php endif; ?>
23 26
 		</p>
24 27
 		<?php endforeach; ?>
@@ -74,8 +77,12 @@  discard block
 block discarded – undo
74 77
 
75 78
 	<?php if(!$_['dbIsSet'] or count($_['errors']) > 0): ?>
76 79
 	<fieldset id='databaseBackend'>
77
-		<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'])
78
-			$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite?>
80
+		<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle']) {
81
+			$hasOtherDB = true;
82
+} else {
83
+			    $hasOtherDB =false;
84
+			}
85
+			//other than SQLite?>
79 86
 		<legend><?php p($l->t('Configure the database')); ?></legend>
80 87
 		<div id="selectDbType">
81 88
 		<?php foreach($_['databases'] as $type => $label): ?>
@@ -87,11 +94,14 @@  discard block
 block discarded – undo
87 94
 				<?php p($l->t('For more details check out the documentation.')); ?> ↗</a>
88 95
 		</p>
89 96
 		<input type="hidden" id="dbtype" name="dbtype" value="<?php p($type) ?>">
90
-		<?php else: ?>
97
+		<?php else {
98
+    : ?>
91 99
 		<input type="radio" name="dbtype" value="<?php p($type) ?>" id="<?php p($type) ?>"
92 100
 			<?php print_unescaped($_['dbtype'] === $type ? 'checked="checked" ' : '') ?>/>
93 101
 		<label class="<?php p($type) ?>" for="<?php p($type) ?>"><?php p($label) ?></label>
94
-		<?php endif; ?>
102
+		<?php endif;
103
+}
104
+?>
95 105
 		<?php endforeach; ?>
96 106
 		</div>
97 107
 	</fieldset>
Please login to merge, or discard this patch.
core/templates/layout.guest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		<?php emit_script_loading_tags($_); ?>
24 24
 		<?php print_unescaped($_['headers']); ?>
25 25
 	</head>
26
-	<body id="<?php p($_['bodyid']);?>">
26
+	<body id="<?php p($_['bodyid']); ?>">
27 27
 		<?php include 'layout.noscript.warning.php'; ?>
28 28
 		<?php foreach ($_['initialStates'] as $app => $initialState) { ?>
29 29
 			<input type="hidden" id="initial-state-<?php p($app); ?>" value="<?php p(base64_encode($initialState)); ?>">
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 								<h1 class="hidden-visually">
38 38
 									<?php p($theme->getName()); ?>
39 39
 								</h1>
40
-								<?php if(\OC::$server->getConfig()->getSystemValue('installed', false)
40
+								<?php if (\OC::$server->getConfig()->getSystemValue('installed', false)
41 41
 									&& \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
42 42
 									<img src="<?php p($theme->getLogo()); ?>"/>
43 43
 								<?php endif; ?>
Please login to merge, or discard this patch.
core/templates/layout.user.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 		<meta charset="utf-8">
5 5
 		<title>
6 6
 			<?php
7
-				p(!empty($_['application'])?$_['application'].' - ':'');
7
+				p(!empty($_['application']) ? $_['application'].' - ' : '');
8 8
 				p($theme->getTitle());
9 9
 			?>
10 10
 		</title>
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		<?php } ?>
16 16
 		<meta name="apple-mobile-web-app-capable" content="yes">
17 17
 		<meta name="apple-mobile-web-app-status-bar-style" content="black">
18
-		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid']!='files')? $_['application']:$theme->getTitle()); ?>">
18
+		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid'] != 'files') ? $_['application'] : $theme->getTitle()); ?>">
19 19
 		<meta name="mobile-web-app-capable" content="yes">
20 20
 		<meta name="theme-color" content="<?php p($theme->getColorPrimary()); ?>">
21 21
 		<link rel="icon" href="<?php print_unescaped(image_path($_['appid'], 'favicon.ico')); /* IE11+ supports png */ ?>">
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		<?php emit_script_loading_tags($_); ?>
27 27
 		<?php print_unescaped($_['headers']); ?>
28 28
 	</head>
29
-	<body id="<?php p($_['bodyid']);?>">
29
+	<body id="<?php p($_['bodyid']); ?>">
30 30
 	<?php include 'layout.noscript.warning.php'; ?>
31 31
 
32 32
 		<?php foreach ($_['initialStates'] as $app => $initialState) { ?>
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 					id="nextcloud">
46 46
 					<div class="logo logo-icon">
47 47
 						<h1 class="hidden-visually">
48
-							<?php p($theme->getName()); ?> <?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?>
48
+							<?php p($theme->getName()); ?> <?php p(!empty($_['application']) ? $_['application'] : $l->t('Apps')); ?>
49 49
 						</h1>
50 50
 					</div>
51 51
 				</a>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 										<?php if ($_['themingInvertMenu']) { ?>
61 61
 										<defs><filter id="invertMenuMain-<?php p($entry['id']); ?>"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" /></filter></defs>
62 62
 										<?php } ?>
63
-										<image x="0" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet"<?php if ($_['themingInvertMenu']) { ?> filter="url(#invertMenuMain-<?php p($entry['id']); ?>)"<?php } ?> xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon"></image>
63
+										<image x="0" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet"<?php if ($_['themingInvertMenu']) { ?> filter="url(#invertMenuMain-<?php p($entry['id']); ?>)"<?php } ?> xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon"></image>
64 64
 									</svg>
65 65
 								<span>
66 66
 									<?php p($entry['name']); ?>
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 					<div id="navigation" style="display: none;"  aria-label="<?php p($l->t('More apps menu')); ?>">
82 82
 						<div id="apps">
83 83
 							<ul>
84
-								<?php foreach($_['navigation'] as $entry): ?>
84
+								<?php foreach ($_['navigation'] as $entry): ?>
85 85
 									<li data-id="<?php p($entry['id']); ?>">
86 86
 									<a href="<?php print_unescaped($entry['href']); ?>"
87
-										<?php if($entry['active']): ?> class="active"<?php endif; ?>
87
+										<?php if ($entry['active']): ?> class="active"<?php endif; ?>
88 88
 										aria-label="<?php p($entry['name']); ?>">
89 89
 										<svg width="16" height="16" viewBox="0 0 16 16" alt="">
90 90
 											<defs><filter id="invertMenuMore-<?php p($entry['id']); ?>"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>
91
-											<image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invertMenuMore-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon"></image>
91
+											<image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invertMenuMore-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon"></image>
92 92
 										</svg>
93 93
 										<span><?php p($entry['name']); ?></span>
94 94
 									</a>
@@ -104,43 +104,43 @@  discard block
 block discarded – undo
104 104
 			<div class="header-right">
105 105
 				<form class="searchbox" action="#" method="post" role="search" novalidate>
106 106
 					<label for="searchbox" class="hidden-visually">
107
-						<?php p($l->t('Search'));?>
107
+						<?php p($l->t('Search')); ?>
108 108
 					</label>
109 109
 					<input id="searchbox" type="search" name="query"
110 110
 						value="" required class="hidden icon-search-white icon-search-force-white"
111 111
 						autocomplete="off">
112
-					<button class="icon-close-white" type="reset"><span class="hidden-visually"><?php p($l->t('Reset search'));?></span></button>
112
+					<button class="icon-close-white" type="reset"><span class="hidden-visually"><?php p($l->t('Reset search')); ?></span></button>
113 113
 				</form>
114 114
 				<div id="contactsmenu">
115 115
 					<div class="icon-contacts menutoggle" tabindex="0" role="button"
116 116
 					aria-haspopup="true" aria-controls="contactsmenu-menu" aria-expanded="false">
117
-						<span class="hidden-visually"><?php p($l->t('Contacts'));?></span>
117
+						<span class="hidden-visually"><?php p($l->t('Contacts')); ?></span>
118 118
 					</div>
119 119
 					<div id="contactsmenu-menu" class="menu"
120
-						aria-label="<?php p($l->t('Contacts menu'));?>"></div>
120
+						aria-label="<?php p($l->t('Contacts menu')); ?>"></div>
121 121
 				</div>
122 122
 				<div id="settings">
123 123
 					<div id="expand" tabindex="0" role="button" class="menutoggle"
124
-						aria-label="<?php p($l->t('Settings'));?>"
124
+						aria-label="<?php p($l->t('Settings')); ?>"
125 125
 						aria-haspopup="true" aria-controls="expanddiv" aria-expanded="false">
126 126
 						<div class="avatardiv<?php if ($_['userAvatarSet']) { print_unescaped(' avatardiv-shown'); } else { print_unescaped('" style="display: none'); } ?>">
127 127
 							<?php if ($_['userAvatarSet']): ?>
128 128
 								<img alt="" width="32" height="32"
129
-								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']]));?>"
130
-								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']]));?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']]));?> 4x"
129
+								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']])); ?>"
130
+								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']])); ?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']])); ?> 4x"
131 131
 								>
132 132
 							<?php endif; ?>
133 133
 						</div>
134 134
 						<div id="expandDisplayName" class="icon-settings-white"></div>
135 135
 					</div>
136 136
 					<nav class="settings-menu" id="expanddiv" style="display:none;"
137
-						aria-label="<?php p($l->t('Settings menu'));?>">
137
+						aria-label="<?php p($l->t('Settings menu')); ?>">
138 138
 					<ul>
139
-					<?php foreach($_['settingsnavigation'] as $entry):?>
139
+					<?php foreach ($_['settingsnavigation'] as $entry):?>
140 140
 						<li data-id="<?php p($entry['id']); ?>">
141 141
 							<a href="<?php print_unescaped($entry['href']); ?>"
142
-								<?php if($entry["active"]): ?> class="active"<?php endif; ?>>
143
-								<img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>">
142
+								<?php if ($entry["active"]): ?> class="active"<?php endif; ?>>
143
+								<img alt="" src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>">
144 144
 								<?php p($entry['name']) ?>
145 145
 							</a>
146 146
 						</li>
Please login to merge, or discard this patch.
core/templates/403.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // @codeCoverageIgnoreStart
3
-if(!isset($_)) {//standalone  page is not supported anymore - redirect to /
3
+if (!isset($_)) {//standalone  page is not supported anymore - redirect to /
4 4
 	require_once '../../lib/base.php';
5 5
 
6 6
 	$urlGenerator = \OC::$server->getURLGenerator();
7
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
7
+	header('Location: '.$urlGenerator->getAbsoluteURL('/'));
8 8
 	exit;
9 9
 }
10 10
 // @codeCoverageIgnoreEnd
@@ -12,6 +12,6 @@  discard block
 block discarded – undo
12 12
 <ul>
13 13
 	<li class='error'>
14 14
 		<?php p($l->t('Access forbidden')); ?><br>
15
-		<p class='hint'><?php if(isset($_['message'])) p($_['message'])?></p>
15
+		<p class='hint'><?php if (isset($_['message'])) p($_['message'])?></p>
16 16
 	</li>
17 17
 </ul>
Please login to merge, or discard this patch.
core/Command/Encryption/DecryptAll.php 1 patch
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -42,156 +42,156 @@
 block discarded – undo
42 42
 
43 43
 class DecryptAll extends Command {
44 44
 
45
-	/** @var IManager */
46
-	protected $encryptionManager;
47
-
48
-	/** @var  IAppManager */
49
-	protected $appManager;
50
-
51
-	/** @var IConfig */
52
-	protected $config;
53
-
54
-	/** @var  QuestionHelper */
55
-	protected $questionHelper;
56
-
57
-	/** @var bool */
58
-	protected $wasTrashbinEnabled;
59
-
60
-	/** @var  bool */
61
-	protected $wasMaintenanceModeEnabled;
62
-
63
-	/** @var \OC\Encryption\DecryptAll */
64
-	protected $decryptAll;
65
-
66
-	/**
67
-	 * @param IManager $encryptionManager
68
-	 * @param IAppManager $appManager
69
-	 * @param IConfig $config
70
-	 * @param \OC\Encryption\DecryptAll $decryptAll
71
-	 * @param QuestionHelper $questionHelper
72
-	 */
73
-	public function __construct(
74
-		IManager $encryptionManager,
75
-		IAppManager $appManager,
76
-		IConfig $config,
77
-		\OC\Encryption\DecryptAll $decryptAll,
78
-		QuestionHelper $questionHelper
79
-	) {
80
-		parent::__construct();
81
-
82
-		$this->appManager = $appManager;
83
-		$this->encryptionManager = $encryptionManager;
84
-		$this->config = $config;
85
-		$this->decryptAll = $decryptAll;
86
-		$this->questionHelper = $questionHelper;
87
-	}
88
-
89
-	/**
90
-	 * Set maintenance mode and disable the trashbin app
91
-	 */
92
-	protected function forceMaintenanceAndTrashbin() {
93
-		$this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
94
-		$this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
95
-		$this->config->setSystemValue('maintenance', true);
96
-		$this->appManager->disableApp('files_trashbin');
97
-	}
98
-
99
-	/**
100
-	 * Reset the maintenance mode and re-enable the trashbin app
101
-	 */
102
-	protected function resetMaintenanceAndTrashbin() {
103
-		$this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
104
-		if ($this->wasTrashbinEnabled) {
105
-			$this->appManager->enableApp('files_trashbin');
106
-		}
107
-	}
108
-
109
-	protected function configure() {
110
-		parent::configure();
111
-
112
-		$this->setName('encryption:decrypt-all');
113
-		$this->setDescription('Disable server-side encryption and decrypt all files');
114
-		$this->setHelp(
115
-			'This will disable server-side encryption and decrypt all files for '
116
-			. 'all users if it is supported by your encryption module. '
117
-			. 'Please make sure that no user access his files during this process!'
118
-		);
119
-		$this->addArgument(
120
-			'user',
121
-			InputArgument::OPTIONAL,
122
-			'user for which you want to decrypt all files (optional)',
123
-			''
124
-		);
125
-	}
126
-
127
-	protected function execute(InputInterface $input, OutputInterface $output) {
128
-		if (!$input->isInteractive()) {
129
-			$output->writeln('Invalid TTY.');
130
-			$output->writeln('If you are trying to execute the command in a Docker ');
131
-			$output->writeln("container, do not forget to execute 'docker exec' with");
132
-			$output->writeln("the '-i' and '-t' options.");
133
-			$output->writeln('');
134
-			return;
135
-		}
136
-
137
-		$isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
138
-		if ($isMaintenanceModeEnabled) {
139
-			$output->writeln("Maintenance mode must be disabled when starting decryption,");
140
-			$output->writeln("in order to load the relevant encryption modules correctly.");
141
-			$output->writeln("Your instance will automatically be put to maintenance mode");
142
-			$output->writeln("during the actual decryption of the files.");
143
-			return;
144
-		}
145
-
146
-		try {
147
-			if ($this->encryptionManager->isEnabled() === true) {
148
-				$output->write('Disable server side encryption... ');
149
-				$this->config->setAppValue('core', 'encryption_enabled', 'no');
150
-				$output->writeln('done.');
151
-			} else {
152
-				$output->writeln('Server side encryption not enabled. Nothing to do.');
153
-				return;
154
-			}
155
-
156
-			$uid = $input->getArgument('user');
157
-			if ($uid === '') {
158
-				$message = 'your Nextcloud';
159
-			} else {
160
-				$message = "$uid's account";
161
-			}
162
-
163
-			$output->writeln("\n");
164
-			$output->writeln("You are about to start to decrypt all files stored in $message.");
165
-			$output->writeln('It will depend on the encryption module and your setup if this is possible.');
166
-			$output->writeln('Depending on the number and size of your files this can take some time');
167
-			$output->writeln('Please make sure that no user access his files during this process!');
168
-			$output->writeln('');
169
-			$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
170
-			if ($this->questionHelper->ask($input, $output, $question)) {
171
-				$this->forceMaintenanceAndTrashbin();
172
-				$user = $input->getArgument('user');
173
-				$result = $this->decryptAll->decryptAll($input, $output, $user);
174
-				if ($result === false) {
175
-					$output->writeln(' aborted.');
176
-					$output->writeln('Server side encryption remains enabled');
177
-					$this->config->setAppValue('core', 'encryption_enabled', 'yes');
178
-				} else if ($uid !== '') {
179
-					$output->writeln('Server side encryption remains enabled');
180
-					$this->config->setAppValue('core', 'encryption_enabled', 'yes');
181
-				}
182
-				$this->resetMaintenanceAndTrashbin();
183
-			} else {
184
-				$output->write('Enable server side encryption... ');
185
-				$this->config->setAppValue('core', 'encryption_enabled', 'yes');
186
-				$output->writeln('done.');
187
-				$output->writeln('aborted');
188
-			}
189
-		} catch (\Exception $e) {
190
-			// enable server side encryption again if something went wrong
191
-			$this->config->setAppValue('core', 'encryption_enabled', 'yes');
192
-			$this->resetMaintenanceAndTrashbin();
193
-			throw $e;
194
-		}
195
-
196
-	}
45
+    /** @var IManager */
46
+    protected $encryptionManager;
47
+
48
+    /** @var  IAppManager */
49
+    protected $appManager;
50
+
51
+    /** @var IConfig */
52
+    protected $config;
53
+
54
+    /** @var  QuestionHelper */
55
+    protected $questionHelper;
56
+
57
+    /** @var bool */
58
+    protected $wasTrashbinEnabled;
59
+
60
+    /** @var  bool */
61
+    protected $wasMaintenanceModeEnabled;
62
+
63
+    /** @var \OC\Encryption\DecryptAll */
64
+    protected $decryptAll;
65
+
66
+    /**
67
+     * @param IManager $encryptionManager
68
+     * @param IAppManager $appManager
69
+     * @param IConfig $config
70
+     * @param \OC\Encryption\DecryptAll $decryptAll
71
+     * @param QuestionHelper $questionHelper
72
+     */
73
+    public function __construct(
74
+        IManager $encryptionManager,
75
+        IAppManager $appManager,
76
+        IConfig $config,
77
+        \OC\Encryption\DecryptAll $decryptAll,
78
+        QuestionHelper $questionHelper
79
+    ) {
80
+        parent::__construct();
81
+
82
+        $this->appManager = $appManager;
83
+        $this->encryptionManager = $encryptionManager;
84
+        $this->config = $config;
85
+        $this->decryptAll = $decryptAll;
86
+        $this->questionHelper = $questionHelper;
87
+    }
88
+
89
+    /**
90
+     * Set maintenance mode and disable the trashbin app
91
+     */
92
+    protected function forceMaintenanceAndTrashbin() {
93
+        $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
94
+        $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
95
+        $this->config->setSystemValue('maintenance', true);
96
+        $this->appManager->disableApp('files_trashbin');
97
+    }
98
+
99
+    /**
100
+     * Reset the maintenance mode and re-enable the trashbin app
101
+     */
102
+    protected function resetMaintenanceAndTrashbin() {
103
+        $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
104
+        if ($this->wasTrashbinEnabled) {
105
+            $this->appManager->enableApp('files_trashbin');
106
+        }
107
+    }
108
+
109
+    protected function configure() {
110
+        parent::configure();
111
+
112
+        $this->setName('encryption:decrypt-all');
113
+        $this->setDescription('Disable server-side encryption and decrypt all files');
114
+        $this->setHelp(
115
+            'This will disable server-side encryption and decrypt all files for '
116
+            . 'all users if it is supported by your encryption module. '
117
+            . 'Please make sure that no user access his files during this process!'
118
+        );
119
+        $this->addArgument(
120
+            'user',
121
+            InputArgument::OPTIONAL,
122
+            'user for which you want to decrypt all files (optional)',
123
+            ''
124
+        );
125
+    }
126
+
127
+    protected function execute(InputInterface $input, OutputInterface $output) {
128
+        if (!$input->isInteractive()) {
129
+            $output->writeln('Invalid TTY.');
130
+            $output->writeln('If you are trying to execute the command in a Docker ');
131
+            $output->writeln("container, do not forget to execute 'docker exec' with");
132
+            $output->writeln("the '-i' and '-t' options.");
133
+            $output->writeln('');
134
+            return;
135
+        }
136
+
137
+        $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
138
+        if ($isMaintenanceModeEnabled) {
139
+            $output->writeln("Maintenance mode must be disabled when starting decryption,");
140
+            $output->writeln("in order to load the relevant encryption modules correctly.");
141
+            $output->writeln("Your instance will automatically be put to maintenance mode");
142
+            $output->writeln("during the actual decryption of the files.");
143
+            return;
144
+        }
145
+
146
+        try {
147
+            if ($this->encryptionManager->isEnabled() === true) {
148
+                $output->write('Disable server side encryption... ');
149
+                $this->config->setAppValue('core', 'encryption_enabled', 'no');
150
+                $output->writeln('done.');
151
+            } else {
152
+                $output->writeln('Server side encryption not enabled. Nothing to do.');
153
+                return;
154
+            }
155
+
156
+            $uid = $input->getArgument('user');
157
+            if ($uid === '') {
158
+                $message = 'your Nextcloud';
159
+            } else {
160
+                $message = "$uid's account";
161
+            }
162
+
163
+            $output->writeln("\n");
164
+            $output->writeln("You are about to start to decrypt all files stored in $message.");
165
+            $output->writeln('It will depend on the encryption module and your setup if this is possible.');
166
+            $output->writeln('Depending on the number and size of your files this can take some time');
167
+            $output->writeln('Please make sure that no user access his files during this process!');
168
+            $output->writeln('');
169
+            $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
170
+            if ($this->questionHelper->ask($input, $output, $question)) {
171
+                $this->forceMaintenanceAndTrashbin();
172
+                $user = $input->getArgument('user');
173
+                $result = $this->decryptAll->decryptAll($input, $output, $user);
174
+                if ($result === false) {
175
+                    $output->writeln(' aborted.');
176
+                    $output->writeln('Server side encryption remains enabled');
177
+                    $this->config->setAppValue('core', 'encryption_enabled', 'yes');
178
+                } else if ($uid !== '') {
179
+                    $output->writeln('Server side encryption remains enabled');
180
+                    $this->config->setAppValue('core', 'encryption_enabled', 'yes');
181
+                }
182
+                $this->resetMaintenanceAndTrashbin();
183
+            } else {
184
+                $output->write('Enable server side encryption... ');
185
+                $this->config->setAppValue('core', 'encryption_enabled', 'yes');
186
+                $output->writeln('done.');
187
+                $output->writeln('aborted');
188
+            }
189
+        } catch (\Exception $e) {
190
+            // enable server side encryption again if something went wrong
191
+            $this->config->setAppValue('core', 'encryption_enabled', 'yes');
192
+            $this->resetMaintenanceAndTrashbin();
193
+            throw $e;
194
+        }
195
+
196
+    }
197 197
 }
Please login to merge, or discard this patch.
core/Command/Encryption/EncryptAll.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -37,110 +37,110 @@
 block discarded – undo
37 37
 
38 38
 class EncryptAll extends Command {
39 39
 
40
-	/** @var IManager */
41
-	protected $encryptionManager;
42
-
43
-	/** @var  IAppManager */
44
-	protected $appManager;
45
-
46
-	/** @var IConfig */
47
-	protected $config;
48
-
49
-	/** @var  QuestionHelper */
50
-	protected $questionHelper;
51
-
52
-	/** @var bool */
53
-	protected $wasTrashbinEnabled;
54
-
55
-	/** @var  bool */
56
-	protected $wasMaintenanceModeEnabled;
57
-
58
-	/**
59
-	 * @param IManager $encryptionManager
60
-	 * @param IAppManager $appManager
61
-	 * @param IConfig $config
62
-	 * @param QuestionHelper $questionHelper
63
-	 */
64
-	public function __construct(
65
-		IManager $encryptionManager,
66
-		IAppManager $appManager,
67
-		IConfig $config,
68
-		QuestionHelper $questionHelper
69
-	) {
70
-		parent::__construct();
71
-		$this->appManager = $appManager;
72
-		$this->encryptionManager = $encryptionManager;
73
-		$this->config = $config;
74
-		$this->questionHelper = $questionHelper;
75
-	}
76
-
77
-	/**
78
-	 * Set maintenance mode and disable the trashbin app
79
-	 */
80
-	protected function forceMaintenanceAndTrashbin() {
81
-		$this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
82
-		$this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
83
-		$this->config->setSystemValue('maintenance', true);
84
-		$this->appManager->disableApp('files_trashbin');
85
-	}
86
-
87
-	/**
88
-	 * Reset the maintenance mode and re-enable the trashbin app
89
-	 */
90
-	protected function resetMaintenanceAndTrashbin() {
91
-		$this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
92
-		if ($this->wasTrashbinEnabled) {
93
-			$this->appManager->enableApp('files_trashbin');
94
-		}
95
-	}
96
-
97
-	protected function configure() {
98
-		parent::configure();
99
-
100
-		$this->setName('encryption:encrypt-all');
101
-		$this->setDescription('Encrypt all files for all users');
102
-		$this->setHelp(
103
-			'This will encrypt all files for all users. '
104
-			. 'Please make sure that no user access his files during this process!'
105
-		);
106
-	}
107
-
108
-	protected function execute(InputInterface $input, OutputInterface $output) {
109
-		if (!$input->isInteractive()) {
110
-			$output->writeln('Invalid TTY.');
111
-			$output->writeln('If you are trying to execute the command in a Docker ');
112
-			$output->writeln("container, do not forget to execute 'docker exec' with");
113
-			$output->writeln("the '-i' and '-t' options.");
114
-			$output->writeln('');
115
-			return;
116
-		}
117
-
118
-		if ($this->encryptionManager->isEnabled() === false) {
119
-			throw new \Exception('Server side encryption is not enabled');
120
-		}
121
-
122
-		$output->writeln("\n");
123
-		$output->writeln('You are about to encrypt all files stored in your Nextcloud installation.');
124
-		$output->writeln('Depending on the number of available files, and their size, this may take quite some time.');
125
-		$output->writeln('Please ensure that no user accesses their files during this time!');
126
-		$output->writeln('Note: The encryption module you use determines which files get encrypted.');
127
-		$output->writeln('');
128
-		$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
129
-		if ($this->questionHelper->ask($input, $output, $question)) {
130
-			$this->forceMaintenanceAndTrashbin();
131
-
132
-			try {
133
-				$defaultModule = $this->encryptionManager->getEncryptionModule();
134
-				$defaultModule->encryptAll($input, $output);
135
-			} catch (\Exception $ex) {
136
-				$this->resetMaintenanceAndTrashbin();
137
-				throw $ex;
138
-			}
139
-
140
-			$this->resetMaintenanceAndTrashbin();
141
-		} else {
142
-			$output->writeln('aborted');
143
-		}
144
-	}
40
+    /** @var IManager */
41
+    protected $encryptionManager;
42
+
43
+    /** @var  IAppManager */
44
+    protected $appManager;
45
+
46
+    /** @var IConfig */
47
+    protected $config;
48
+
49
+    /** @var  QuestionHelper */
50
+    protected $questionHelper;
51
+
52
+    /** @var bool */
53
+    protected $wasTrashbinEnabled;
54
+
55
+    /** @var  bool */
56
+    protected $wasMaintenanceModeEnabled;
57
+
58
+    /**
59
+     * @param IManager $encryptionManager
60
+     * @param IAppManager $appManager
61
+     * @param IConfig $config
62
+     * @param QuestionHelper $questionHelper
63
+     */
64
+    public function __construct(
65
+        IManager $encryptionManager,
66
+        IAppManager $appManager,
67
+        IConfig $config,
68
+        QuestionHelper $questionHelper
69
+    ) {
70
+        parent::__construct();
71
+        $this->appManager = $appManager;
72
+        $this->encryptionManager = $encryptionManager;
73
+        $this->config = $config;
74
+        $this->questionHelper = $questionHelper;
75
+    }
76
+
77
+    /**
78
+     * Set maintenance mode and disable the trashbin app
79
+     */
80
+    protected function forceMaintenanceAndTrashbin() {
81
+        $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
82
+        $this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
83
+        $this->config->setSystemValue('maintenance', true);
84
+        $this->appManager->disableApp('files_trashbin');
85
+    }
86
+
87
+    /**
88
+     * Reset the maintenance mode and re-enable the trashbin app
89
+     */
90
+    protected function resetMaintenanceAndTrashbin() {
91
+        $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
92
+        if ($this->wasTrashbinEnabled) {
93
+            $this->appManager->enableApp('files_trashbin');
94
+        }
95
+    }
96
+
97
+    protected function configure() {
98
+        parent::configure();
99
+
100
+        $this->setName('encryption:encrypt-all');
101
+        $this->setDescription('Encrypt all files for all users');
102
+        $this->setHelp(
103
+            'This will encrypt all files for all users. '
104
+            . 'Please make sure that no user access his files during this process!'
105
+        );
106
+    }
107
+
108
+    protected function execute(InputInterface $input, OutputInterface $output) {
109
+        if (!$input->isInteractive()) {
110
+            $output->writeln('Invalid TTY.');
111
+            $output->writeln('If you are trying to execute the command in a Docker ');
112
+            $output->writeln("container, do not forget to execute 'docker exec' with");
113
+            $output->writeln("the '-i' and '-t' options.");
114
+            $output->writeln('');
115
+            return;
116
+        }
117
+
118
+        if ($this->encryptionManager->isEnabled() === false) {
119
+            throw new \Exception('Server side encryption is not enabled');
120
+        }
121
+
122
+        $output->writeln("\n");
123
+        $output->writeln('You are about to encrypt all files stored in your Nextcloud installation.');
124
+        $output->writeln('Depending on the number of available files, and their size, this may take quite some time.');
125
+        $output->writeln('Please ensure that no user accesses their files during this time!');
126
+        $output->writeln('Note: The encryption module you use determines which files get encrypted.');
127
+        $output->writeln('');
128
+        $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
129
+        if ($this->questionHelper->ask($input, $output, $question)) {
130
+            $this->forceMaintenanceAndTrashbin();
131
+
132
+            try {
133
+                $defaultModule = $this->encryptionManager->getEncryptionModule();
134
+                $defaultModule->encryptAll($input, $output);
135
+            } catch (\Exception $ex) {
136
+                $this->resetMaintenanceAndTrashbin();
137
+                throw $ex;
138
+            }
139
+
140
+            $this->resetMaintenanceAndTrashbin();
141
+        } else {
142
+            $output->writeln('aborted');
143
+        }
144
+    }
145 145
 
146 146
 }
Please login to merge, or discard this patch.
core/Command/TwoFactorAuth/State.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -34,75 +34,75 @@
 block discarded – undo
34 34
 
35 35
 class State extends Base {
36 36
 
37
-	/** @var IRegistry */
38
-	private $registry;
39
-
40
-	public function __construct(IRegistry $registry, IUserManager $userManager) {
41
-		parent::__construct('twofactorauth:state');
42
-
43
-		$this->registry = $registry;
44
-		$this->userManager = $userManager;
45
-	}
46
-
47
-	protected function configure() {
48
-		parent::configure();
49
-
50
-		$this->setName('twofactorauth:state');
51
-		$this->setDescription('Get the two-factor authentication (2FA) state of a user');
52
-		$this->addArgument('uid', InputArgument::REQUIRED);
53
-	}
54
-
55
-	protected function execute(InputInterface $input, OutputInterface $output) {
56
-		$uid = $input->getArgument('uid');
57
-		$user = $this->userManager->get($uid);
58
-		if (is_null($user)) {
59
-			$output->writeln("<error>Invalid UID</error>");
60
-			return 1;
61
-		}
62
-
63
-		$providerStates = $this->registry->getProviderStates($user);
64
-		$filtered = $this->filterEnabledDisabledUnknownProviders($providerStates);
65
-		list($enabled, $disabled) = $filtered;
66
-
67
-		if (!empty($enabled)) {
68
-			$output->writeln("Two-factor authentication is enabled for user $uid");
69
-		} else {
70
-			$output->writeln("Two-factor authentication is not enabled for user $uid");
71
-		}
72
-
73
-		$output->writeln("");
74
-		$this->printProviders("Enabled providers", $enabled, $output);
75
-		$this->printProviders("Disabled providers", $disabled, $output);
76
-
77
-		return 0;
78
-	}
79
-
80
-	private function filterEnabledDisabledUnknownProviders(array $providerStates): array {
81
-		$enabled = [];
82
-		$disabled = [];
83
-
84
-		foreach ($providerStates as $providerId => $isEnabled) {
85
-			if ($isEnabled) {
86
-				$enabled[] = $providerId;
87
-			} else {
88
-				$disabled[] = $providerId;
89
-			}
90
-		}
91
-
92
-		return [$enabled, $disabled];
93
-	}
94
-
95
-	private function printProviders(string $title, array $providers,
96
-									OutputInterface $output) {
97
-		if (empty($providers)) {
98
-			// Ignore and don't print anything
99
-			return;
100
-		}
101
-
102
-		$output->writeln($title . ":");
103
-		foreach ($providers as $provider) {
104
-			$output->writeln("- " . $provider);
105
-		}
106
-	}
37
+    /** @var IRegistry */
38
+    private $registry;
39
+
40
+    public function __construct(IRegistry $registry, IUserManager $userManager) {
41
+        parent::__construct('twofactorauth:state');
42
+
43
+        $this->registry = $registry;
44
+        $this->userManager = $userManager;
45
+    }
46
+
47
+    protected function configure() {
48
+        parent::configure();
49
+
50
+        $this->setName('twofactorauth:state');
51
+        $this->setDescription('Get the two-factor authentication (2FA) state of a user');
52
+        $this->addArgument('uid', InputArgument::REQUIRED);
53
+    }
54
+
55
+    protected function execute(InputInterface $input, OutputInterface $output) {
56
+        $uid = $input->getArgument('uid');
57
+        $user = $this->userManager->get($uid);
58
+        if (is_null($user)) {
59
+            $output->writeln("<error>Invalid UID</error>");
60
+            return 1;
61
+        }
62
+
63
+        $providerStates = $this->registry->getProviderStates($user);
64
+        $filtered = $this->filterEnabledDisabledUnknownProviders($providerStates);
65
+        list($enabled, $disabled) = $filtered;
66
+
67
+        if (!empty($enabled)) {
68
+            $output->writeln("Two-factor authentication is enabled for user $uid");
69
+        } else {
70
+            $output->writeln("Two-factor authentication is not enabled for user $uid");
71
+        }
72
+
73
+        $output->writeln("");
74
+        $this->printProviders("Enabled providers", $enabled, $output);
75
+        $this->printProviders("Disabled providers", $disabled, $output);
76
+
77
+        return 0;
78
+    }
79
+
80
+    private function filterEnabledDisabledUnknownProviders(array $providerStates): array {
81
+        $enabled = [];
82
+        $disabled = [];
83
+
84
+        foreach ($providerStates as $providerId => $isEnabled) {
85
+            if ($isEnabled) {
86
+                $enabled[] = $providerId;
87
+            } else {
88
+                $disabled[] = $providerId;
89
+            }
90
+        }
91
+
92
+        return [$enabled, $disabled];
93
+    }
94
+
95
+    private function printProviders(string $title, array $providers,
96
+                                    OutputInterface $output) {
97
+        if (empty($providers)) {
98
+            // Ignore and don't print anything
99
+            return;
100
+        }
101
+
102
+        $output->writeln($title . ":");
103
+        foreach ($providers as $provider) {
104
+            $output->writeln("- " . $provider);
105
+        }
106
+    }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
core/Command/Background/Base.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -39,39 +39,39 @@
 block discarded – undo
39 39
 abstract class Base extends Command {
40 40
 
41 41
 
42
-	abstract protected function getMode();
42
+    abstract protected function getMode();
43 43
 
44
-	/**
45
-	 * @var \OCP\IConfig
46
-	 */
47
-	protected $config;
44
+    /**
45
+     * @var \OCP\IConfig
46
+     */
47
+    protected $config;
48 48
 
49
-	/**
50
-	 * @param \OCP\IConfig $config
51
-	 */
52
-	public function __construct(IConfig $config) {
53
-		$this->config = $config;
54
-		parent::__construct();
55
-	}
49
+    /**
50
+     * @param \OCP\IConfig $config
51
+     */
52
+    public function __construct(IConfig $config) {
53
+        $this->config = $config;
54
+        parent::__construct();
55
+    }
56 56
 
57
-	protected function configure() {
58
-		$mode = $this->getMode();
59
-		$this
60
-			->setName("background:$mode")
61
-			->setDescription("Use $mode to run background jobs");
62
-	}
57
+    protected function configure() {
58
+        $mode = $this->getMode();
59
+        $this
60
+            ->setName("background:$mode")
61
+            ->setDescription("Use $mode to run background jobs");
62
+    }
63 63
 
64
-	/**
65
-	 * Executing this command will set the background job mode for owncloud.
66
-	 * The mode to set is specified by the concrete sub class by implementing the
67
-	 * getMode() function.
68
-	 *
69
-	 * @param InputInterface $input
70
-	 * @param OutputInterface $output
71
-	 */
72
-	protected function execute(InputInterface $input, OutputInterface $output) {
73
-		$mode = $this->getMode();
74
-		$this->config->setAppValue('core', 'backgroundjobs_mode', $mode);
75
-		$output->writeln("Set mode for background jobs to '$mode'");
76
-	}
64
+    /**
65
+     * Executing this command will set the background job mode for owncloud.
66
+     * The mode to set is specified by the concrete sub class by implementing the
67
+     * getMode() function.
68
+     *
69
+     * @param InputInterface $input
70
+     * @param OutputInterface $output
71
+     */
72
+    protected function execute(InputInterface $input, OutputInterface $output) {
73
+        $mode = $this->getMode();
74
+        $this->config->setAppValue('core', 'backgroundjobs_mode', $mode);
75
+        $output->writeln("Set mode for background jobs to '$mode'");
76
+    }
77 77
 }
Please login to merge, or discard this patch.
core/Controller/SetupController.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -36,117 +36,117 @@
 block discarded – undo
36 36
 use OCP\ILogger;
37 37
 
38 38
 class SetupController {
39
-	/** @var Setup */
40
-	protected $setupHelper;
41
-	/** @var string */
42
-	private $autoConfigFile;
43
-
44
-	/**
45
-	 * @param Setup $setupHelper
46
-	 */
47
-	function __construct(Setup $setupHelper) {
48
-		$this->autoConfigFile = \OC::$configDir.'autoconfig.php';
49
-		$this->setupHelper = $setupHelper;
50
-	}
51
-
52
-	/**
53
-	 * @param $post
54
-	 */
55
-	public function run($post) {
56
-		// Check for autosetup:
57
-		$post = $this->loadAutoConfig($post);
58
-		$opts = $this->setupHelper->getSystemInfo();
59
-
60
-		// convert 'abcpassword' to 'abcpass'
61
-		if (isset($post['adminpassword'])) {
62
-			$post['adminpass'] = $post['adminpassword'];
63
-		}
64
-		if (isset($post['dbpassword'])) {
65
-			$post['dbpass'] = $post['dbpassword'];
66
-		}
67
-
68
-		if (!is_file(\OC::$configDir.'/CAN_INSTALL')) {
69
-			$this->displaySetupForbidden();
70
-			return;
71
-		}
72
-
73
-		if(isset($post['install']) and $post['install']=='true') {
74
-			// We have to launch the installation process :
75
-			$e = $this->setupHelper->install($post);
76
-			$errors = ['errors' => $e];
77
-
78
-			if(count($e) > 0) {
79
-				$options = array_merge($opts, $post, $errors);
80
-				$this->display($options);
81
-			} else {
82
-				$this->finishSetup(isset($post['install-recommended-apps']));
83
-			}
84
-		} else {
85
-			$options = array_merge($opts, $post);
86
-			$this->display($options);
87
-		}
88
-	}
89
-
90
-	private function displaySetupForbidden() {
91
-		\OC_Template::printGuestPage('', 'installation_forbidden');
92
-	}
93
-
94
-	public function display($post) {
95
-		$defaults = [
96
-			'adminlogin' => '',
97
-			'adminpass' => '',
98
-			'dbuser' => '',
99
-			'dbpass' => '',
100
-			'dbname' => '',
101
-			'dbtablespace' => '',
102
-			'dbhost' => 'localhost',
103
-			'dbtype' => '',
104
-		];
105
-		$parameters = array_merge($defaults, $post);
106
-
107
-		\OC_Util::addScript('setup');
108
-		\OC_Template::printGuestPage('', 'installation', $parameters);
109
-	}
110
-
111
-	private function finishSetup(bool $installRecommended) {
112
-		if(file_exists($this->autoConfigFile)) {
113
-			unlink($this->autoConfigFile);
114
-		}
115
-		\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
116
-
117
-		if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
118
-			if (!unlink(\OC::$configDir.'/CAN_INSTALL')) {
119
-				\OC_Template::printGuestPage('', 'installation_incomplete');
120
-			}
121
-		}
122
-
123
-		if ($installRecommended) {
124
-			$urlGenerator = \OC::$server->getURLGenerator();
125
-			$location = $urlGenerator->getAbsoluteURL('index.php/core/apps/recommended');
126
-			header('Location: ' . $location);
127
-			exit();
128
-		}
129
-		\OC_Util::redirectToDefaultPage();
130
-	}
131
-
132
-	public function loadAutoConfig($post) {
133
-		if(file_exists($this->autoConfigFile)) {
134
-			\OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO);
135
-			$AUTOCONFIG = [];
136
-			include $this->autoConfigFile;
137
-			$post = array_merge($post, $AUTOCONFIG);
138
-		}
139
-
140
-		$dbIsSet = isset($post['dbtype']);
141
-		$directoryIsSet = isset($post['directory']);
142
-		$adminAccountIsSet = isset($post['adminlogin']);
143
-
144
-		if ($dbIsSet and $directoryIsSet and $adminAccountIsSet) {
145
-			$post['install'] = 'true';
146
-		}
147
-		$post['dbIsSet'] = $dbIsSet;
148
-		$post['directoryIsSet'] = $directoryIsSet;
149
-
150
-		return $post;
151
-	}
39
+    /** @var Setup */
40
+    protected $setupHelper;
41
+    /** @var string */
42
+    private $autoConfigFile;
43
+
44
+    /**
45
+     * @param Setup $setupHelper
46
+     */
47
+    function __construct(Setup $setupHelper) {
48
+        $this->autoConfigFile = \OC::$configDir.'autoconfig.php';
49
+        $this->setupHelper = $setupHelper;
50
+    }
51
+
52
+    /**
53
+     * @param $post
54
+     */
55
+    public function run($post) {
56
+        // Check for autosetup:
57
+        $post = $this->loadAutoConfig($post);
58
+        $opts = $this->setupHelper->getSystemInfo();
59
+
60
+        // convert 'abcpassword' to 'abcpass'
61
+        if (isset($post['adminpassword'])) {
62
+            $post['adminpass'] = $post['adminpassword'];
63
+        }
64
+        if (isset($post['dbpassword'])) {
65
+            $post['dbpass'] = $post['dbpassword'];
66
+        }
67
+
68
+        if (!is_file(\OC::$configDir.'/CAN_INSTALL')) {
69
+            $this->displaySetupForbidden();
70
+            return;
71
+        }
72
+
73
+        if(isset($post['install']) and $post['install']=='true') {
74
+            // We have to launch the installation process :
75
+            $e = $this->setupHelper->install($post);
76
+            $errors = ['errors' => $e];
77
+
78
+            if(count($e) > 0) {
79
+                $options = array_merge($opts, $post, $errors);
80
+                $this->display($options);
81
+            } else {
82
+                $this->finishSetup(isset($post['install-recommended-apps']));
83
+            }
84
+        } else {
85
+            $options = array_merge($opts, $post);
86
+            $this->display($options);
87
+        }
88
+    }
89
+
90
+    private function displaySetupForbidden() {
91
+        \OC_Template::printGuestPage('', 'installation_forbidden');
92
+    }
93
+
94
+    public function display($post) {
95
+        $defaults = [
96
+            'adminlogin' => '',
97
+            'adminpass' => '',
98
+            'dbuser' => '',
99
+            'dbpass' => '',
100
+            'dbname' => '',
101
+            'dbtablespace' => '',
102
+            'dbhost' => 'localhost',
103
+            'dbtype' => '',
104
+        ];
105
+        $parameters = array_merge($defaults, $post);
106
+
107
+        \OC_Util::addScript('setup');
108
+        \OC_Template::printGuestPage('', 'installation', $parameters);
109
+    }
110
+
111
+    private function finishSetup(bool $installRecommended) {
112
+        if(file_exists($this->autoConfigFile)) {
113
+            unlink($this->autoConfigFile);
114
+        }
115
+        \OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
116
+
117
+        if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
118
+            if (!unlink(\OC::$configDir.'/CAN_INSTALL')) {
119
+                \OC_Template::printGuestPage('', 'installation_incomplete');
120
+            }
121
+        }
122
+
123
+        if ($installRecommended) {
124
+            $urlGenerator = \OC::$server->getURLGenerator();
125
+            $location = $urlGenerator->getAbsoluteURL('index.php/core/apps/recommended');
126
+            header('Location: ' . $location);
127
+            exit();
128
+        }
129
+        \OC_Util::redirectToDefaultPage();
130
+    }
131
+
132
+    public function loadAutoConfig($post) {
133
+        if(file_exists($this->autoConfigFile)) {
134
+            \OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO);
135
+            $AUTOCONFIG = [];
136
+            include $this->autoConfigFile;
137
+            $post = array_merge($post, $AUTOCONFIG);
138
+        }
139
+
140
+        $dbIsSet = isset($post['dbtype']);
141
+        $directoryIsSet = isset($post['directory']);
142
+        $adminAccountIsSet = isset($post['adminlogin']);
143
+
144
+        if ($dbIsSet and $directoryIsSet and $adminAccountIsSet) {
145
+            $post['install'] = 'true';
146
+        }
147
+        $post['dbIsSet'] = $dbIsSet;
148
+        $post['directoryIsSet'] = $directoryIsSet;
149
+
150
+        return $post;
151
+    }
152 152
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 			return;
71 71
 		}
72 72
 
73
-		if(isset($post['install']) and $post['install']=='true') {
73
+		if (isset($post['install']) and $post['install'] == 'true') {
74 74
 			// We have to launch the installation process :
75 75
 			$e = $this->setupHelper->install($post);
76 76
 			$errors = ['errors' => $e];
77 77
 
78
-			if(count($e) > 0) {
78
+			if (count($e) > 0) {
79 79
 				$options = array_merge($opts, $post, $errors);
80 80
 				$this->display($options);
81 81
 			} else {
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	}
110 110
 
111 111
 	private function finishSetup(bool $installRecommended) {
112
-		if(file_exists($this->autoConfigFile)) {
112
+		if (file_exists($this->autoConfigFile)) {
113 113
 			unlink($this->autoConfigFile);
114 114
 		}
115 115
 		\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 		if ($installRecommended) {
124 124
 			$urlGenerator = \OC::$server->getURLGenerator();
125 125
 			$location = $urlGenerator->getAbsoluteURL('index.php/core/apps/recommended');
126
-			header('Location: ' . $location);
126
+			header('Location: '.$location);
127 127
 			exit();
128 128
 		}
129 129
 		\OC_Util::redirectToDefaultPage();
130 130
 	}
131 131
 
132 132
 	public function loadAutoConfig($post) {
133
-		if(file_exists($this->autoConfigFile)) {
133
+		if (file_exists($this->autoConfigFile)) {
134 134
 			\OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO);
135 135
 			$AUTOCONFIG = [];
136 136
 			include $this->autoConfigFile;
Please login to merge, or discard this patch.