Completed
Push — stable13 ( 2d5d8b...1a016f )
by Roeland
17:00
created
settings/ajax/setquota.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 
35 35
 $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm');
36 36
 if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay
37
-	$l = \OC::$server->getL10N('core');
38
-	OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
39
-	exit();
37
+    $l = \OC::$server->getL10N('core');
38
+    OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
39
+    exit();
40 40
 }
41 41
 
42 42
 $username = isset($_POST["username"]) ? (string)$_POST["username"] : '';
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 $currentUserObject = \OC::$server->getUserSession()->getUser();
46 46
 $targetUserObject = \OC::$server->getUserManager()->get($username);
47 47
 if($targetUserObject !== null && $currentUserObject !== null) {
48
-	$isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($currentUserObject, $targetUserObject);
48
+    $isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($currentUserObject, $targetUserObject);
49 49
 }
50 50
 
51 51
 if(($username === '' && !OC_User::isAdminUser(OC_User::getUser()))
52
-	|| (!OC_User::isAdminUser(OC_User::getUser())
53
-		&& !$isUserAccessible)) {
54
-	$l = \OC::$server->getL10N('core');
55
-	OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
56
-	exit();
52
+    || (!OC_User::isAdminUser(OC_User::getUser())
53
+        && !$isUserAccessible)) {
54
+    $l = \OC::$server->getL10N('core');
55
+    OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
56
+    exit();
57 57
 }
58 58
 
59 59
 //make sure the quota is in the expected format
60 60
 $quota= (string)$_POST["quota"];
61 61
 if($quota !== 'none' and $quota !== 'default') {
62
-	$quota= OC_Helper::computerFileSize($quota);
63
-	$quota=OC_Helper::humanFileSize($quota);
62
+    $quota= OC_Helper::computerFileSize($quota);
63
+    $quota=OC_Helper::humanFileSize($quota);
64 64
 }
65 65
 
66 66
 // Return Success story
67 67
 if($username) {
68
-	$targetUserObject->setQuota($quota);
68
+    $targetUserObject->setQuota($quota);
69 69
 }else{//set the default quota when no username is specified
70
-	if($quota === 'default') {//'default' as default quota makes no sense
71
-		$quota='none';
72
-	}
73
-	\OC::$server->getAppConfig()->setValue('files', 'default_quota', $quota);
70
+    if($quota === 'default') {//'default' as default quota makes no sense
71
+        $quota='none';
72
+    }
73
+    \OC::$server->getAppConfig()->setValue('files', 'default_quota', $quota);
74 74
 }
75 75
 OC_JSON::success(array("data" => array( "username" => $username , 'quota' => $quota)));
76 76
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,42 +35,42 @@
 block discarded – undo
35 35
 $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm');
36 36
 if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay
37 37
 	$l = \OC::$server->getL10N('core');
38
-	OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
38
+	OC_JSON::error(array('data' => array('message' => $l->t('Password confirmation is required'))));
39 39
 	exit();
40 40
 }
41 41
 
42
-$username = isset($_POST["username"]) ? (string)$_POST["username"] : '';
42
+$username = isset($_POST["username"]) ? (string) $_POST["username"] : '';
43 43
 
44 44
 $isUserAccessible = false;
45 45
 $currentUserObject = \OC::$server->getUserSession()->getUser();
46 46
 $targetUserObject = \OC::$server->getUserManager()->get($username);
47
-if($targetUserObject !== null && $currentUserObject !== null) {
47
+if ($targetUserObject !== null && $currentUserObject !== null) {
48 48
 	$isUserAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isUserAccessible($currentUserObject, $targetUserObject);
49 49
 }
50 50
 
51
-if(($username === '' && !OC_User::isAdminUser(OC_User::getUser()))
51
+if (($username === '' && !OC_User::isAdminUser(OC_User::getUser()))
52 52
 	|| (!OC_User::isAdminUser(OC_User::getUser())
53 53
 		&& !$isUserAccessible)) {
54 54
 	$l = \OC::$server->getL10N('core');
55
-	OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
55
+	OC_JSON::error(array('data' => array('message' => $l->t('Authentication error'))));
56 56
 	exit();
57 57
 }
58 58
 
59 59
 //make sure the quota is in the expected format
60
-$quota= (string)$_POST["quota"];
61
-if($quota !== 'none' and $quota !== 'default') {
62
-	$quota= OC_Helper::computerFileSize($quota);
63
-	$quota=OC_Helper::humanFileSize($quota);
60
+$quota = (string) $_POST["quota"];
61
+if ($quota !== 'none' and $quota !== 'default') {
62
+	$quota = OC_Helper::computerFileSize($quota);
63
+	$quota = OC_Helper::humanFileSize($quota);
64 64
 }
65 65
 
66 66
 // Return Success story
67
-if($username) {
67
+if ($username) {
68 68
 	$targetUserObject->setQuota($quota);
69
-}else{//set the default quota when no username is specified
70
-	if($quota === 'default') {//'default' as default quota makes no sense
71
-		$quota='none';
69
+} else {//set the default quota when no username is specified
70
+	if ($quota === 'default') {//'default' as default quota makes no sense
71
+		$quota = 'none';
72 72
 	}
73 73
 	\OC::$server->getAppConfig()->setValue('files', 'default_quota', $quota);
74 74
 }
75
-OC_JSON::success(array("data" => array( "username" => $username , 'quota' => $quota)));
75
+OC_JSON::success(array("data" => array("username" => $username, 'quota' => $quota)));
76 76
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 // Return Success story
67 67
 if($username) {
68 68
 	$targetUserObject->setQuota($quota);
69
-}else{//set the default quota when no username is specified
69
+} else{//set the default quota when no username is specified
70 70
 	if($quota === 'default') {//'default' as default quota makes no sense
71 71
 		$quota='none';
72 72
 	}
Please login to merge, or discard this patch.
settings/Controller/LogSettingsController.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -41,17 +41,17 @@
 block discarded – undo
41 41
  * @package OC\Settings\Controller
42 42
  */
43 43
 class LogSettingsController extends Controller {
44
-	/**
45
-	 * download logfile
46
-	 *
47
-	 * @NoCSRFRequired
48
-	 *
49
-	 * @return StreamResponse
50
-	 */
51
-	public function download() {
52
-		$resp = new StreamResponse(\OC\Log\File::getLogFilePath());
53
-		$resp->addHeader('Content-Type', 'application/octet-stream');
54
-		$resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
55
-		return $resp;
56
-	}
44
+    /**
45
+     * download logfile
46
+     *
47
+     * @NoCSRFRequired
48
+     *
49
+     * @return StreamResponse
50
+     */
51
+    public function download() {
52
+        $resp = new StreamResponse(\OC\Log\File::getLogFilePath());
53
+        $resp->addHeader('Content-Type', 'application/octet-stream');
54
+        $resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
55
+        return $resp;
56
+    }
57 57
 }
Please login to merge, or discard this patch.
settings/Controller/SecuritySettingsController.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -31,41 +31,41 @@
 block discarded – undo
31 31
  * @package OC\Settings\Controller
32 32
  */
33 33
 class SecuritySettingsController extends Controller {
34
-	/** @var \OCP\IConfig */
35
-	private $config;
34
+    /** @var \OCP\IConfig */
35
+    private $config;
36 36
 
37
-	/**
38
-	 * @param string $appName
39
-	 * @param IRequest $request
40
-	 * @param IConfig $config
41
-	 */
42
-	public function __construct($appName,
43
-								IRequest $request,
44
-								IConfig $config) {
45
-		parent::__construct($appName, $request);
46
-		$this->config = $config;
47
-	}
37
+    /**
38
+     * @param string $appName
39
+     * @param IRequest $request
40
+     * @param IConfig $config
41
+     */
42
+    public function __construct($appName,
43
+                                IRequest $request,
44
+                                IConfig $config) {
45
+        parent::__construct($appName, $request);
46
+        $this->config = $config;
47
+    }
48 48
 
49
-	/**
50
-	 * @return array
51
-	 */
52
-	protected function returnSuccess() {
53
-		return array(
54
-			'status' => 'success'
55
-		);
56
-	}
49
+    /**
50
+     * @return array
51
+     */
52
+    protected function returnSuccess() {
53
+        return array(
54
+            'status' => 'success'
55
+        );
56
+    }
57 57
 
58
-	/**
59
-	 * Add a new trusted domain
60
-	 * @param string $newTrustedDomain The newly to add trusted domain
61
-	 * @return array
62
-	 */
63
-	public function trustedDomains($newTrustedDomain) {
64
-		$trustedDomains = $this->config->getSystemValue('trusted_domains', []);
65
-		$trustedDomains[] = $newTrustedDomain;
66
-		$this->config->setSystemValue('trusted_domains', $trustedDomains);
58
+    /**
59
+     * Add a new trusted domain
60
+     * @param string $newTrustedDomain The newly to add trusted domain
61
+     * @return array
62
+     */
63
+    public function trustedDomains($newTrustedDomain) {
64
+        $trustedDomains = $this->config->getSystemValue('trusted_domains', []);
65
+        $trustedDomains[] = $newTrustedDomain;
66
+        $this->config->setSystemValue('trusted_domains', $trustedDomains);
67 67
 
68
-		return $this->returnSuccess();
69
-	}
68
+        return $this->returnSuccess();
69
+    }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
settings/Controller/EncryptionController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@
 block discarded – undo
130 130
 		} catch (\Exception $e) {
131 131
 			return [
132 132
 				'data' => [
133
-					'message' => (string)$this->l10n->t('A problem occurred, please check your log files (Error: %s)', [$e->getMessage()]),
133
+					'message' => (string) $this->l10n->t('A problem occurred, please check your log files (Error: %s)', [$e->getMessage()]),
134 134
 				],
135 135
 				'status' => 'error',
136 136
 			];
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -40,119 +40,119 @@
 block discarded – undo
40 40
  */
41 41
 class EncryptionController extends Controller {
42 42
 
43
-	/** @var IL10N */
44
-	private $l10n;
45
-
46
-	/** @var IDBConnection */
47
-	private $connection;
48
-
49
-	/** @var IConfig */
50
-	private $config;
51
-
52
-	/** @var IUserManager */
53
-	private $userManager;
54
-
55
-	/** @var View */
56
-	private $view;
57
-
58
-	/** @var ILogger */
59
-	private $logger;
60
-
61
-	/** @var IAppManager */
62
-	private $appManager;
63
-
64
-	/**
65
-	 * @param string $appName
66
-	 * @param IRequest $request
67
-	 * @param IL10N $l10n
68
-	 * @param IConfig $config
69
-	 * @param IDBConnection $connection
70
-	 * @param IUserManager $userManager
71
-	 * @param View $view
72
-	 * @param ILogger $logger
73
-	 * @param IAppManager $appManager
74
-	 */
75
-	public function __construct($appName,
76
-								IRequest $request,
77
-								IL10N $l10n,
78
-								IConfig $config,
79
-								IDBConnection $connection,
80
-								IUserManager $userManager,
81
-								View $view,
82
-								ILogger $logger,
83
-								IAppManager $appManager) {
84
-		parent::__construct($appName, $request);
85
-		$this->l10n = $l10n;
86
-		$this->config = $config;
87
-		$this->connection = $connection;
88
-		$this->view = $view;
89
-		$this->userManager = $userManager;
90
-		$this->logger = $logger;
91
-		$this->appManager = $appManager;
92
-	}
93
-
94
-	/**
95
-	 * @param IConfig $config
96
-	 * @param View $view
97
-	 * @param IDBConnection $connection
98
-	 * @param ILogger $logger
99
-	 * @param IAppManager $appManager
100
-	 * @return Migration
101
-	 */
102
-	protected function getMigration(IConfig $config,
103
-								 View $view,
104
-								 IDBConnection $connection,
105
-								 ILogger $logger,
106
-								 IAppManager $appManager) {
107
-		return new Migration($config, $view, $connection, $logger, $appManager);
108
-	}
109
-
110
-	/**
111
-	 * start migration
112
-	 *
113
-	 * @return array
114
-	 */
115
-	public function startMigration() {
43
+    /** @var IL10N */
44
+    private $l10n;
45
+
46
+    /** @var IDBConnection */
47
+    private $connection;
48
+
49
+    /** @var IConfig */
50
+    private $config;
51
+
52
+    /** @var IUserManager */
53
+    private $userManager;
54
+
55
+    /** @var View */
56
+    private $view;
57
+
58
+    /** @var ILogger */
59
+    private $logger;
60
+
61
+    /** @var IAppManager */
62
+    private $appManager;
63
+
64
+    /**
65
+     * @param string $appName
66
+     * @param IRequest $request
67
+     * @param IL10N $l10n
68
+     * @param IConfig $config
69
+     * @param IDBConnection $connection
70
+     * @param IUserManager $userManager
71
+     * @param View $view
72
+     * @param ILogger $logger
73
+     * @param IAppManager $appManager
74
+     */
75
+    public function __construct($appName,
76
+                                IRequest $request,
77
+                                IL10N $l10n,
78
+                                IConfig $config,
79
+                                IDBConnection $connection,
80
+                                IUserManager $userManager,
81
+                                View $view,
82
+                                ILogger $logger,
83
+                                IAppManager $appManager) {
84
+        parent::__construct($appName, $request);
85
+        $this->l10n = $l10n;
86
+        $this->config = $config;
87
+        $this->connection = $connection;
88
+        $this->view = $view;
89
+        $this->userManager = $userManager;
90
+        $this->logger = $logger;
91
+        $this->appManager = $appManager;
92
+    }
93
+
94
+    /**
95
+     * @param IConfig $config
96
+     * @param View $view
97
+     * @param IDBConnection $connection
98
+     * @param ILogger $logger
99
+     * @param IAppManager $appManager
100
+     * @return Migration
101
+     */
102
+    protected function getMigration(IConfig $config,
103
+                                    View $view,
104
+                                    IDBConnection $connection,
105
+                                    ILogger $logger,
106
+                                    IAppManager $appManager) {
107
+        return new Migration($config, $view, $connection, $logger, $appManager);
108
+    }
109
+
110
+    /**
111
+     * start migration
112
+     *
113
+     * @return array
114
+     */
115
+    public function startMigration() {
116 116
         // allow as long execution on the web server as possible
117
-		if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
118
-			@set_time_limit(0);
119
-		}
120
-
121
-		try {
122
-
123
-			$migration = $this->getMigration($this->config, $this->view, $this->connection, $this->logger, $this->appManager);
124
-			$migration->reorganizeSystemFolderStructure();
125
-			$migration->updateDB();
126
-
127
-			foreach ($this->userManager->getBackends() as $backend) {
128
-				$limit = 500;
129
-				$offset = 0;
130
-				do {
131
-					$users = $backend->getUsers('', $limit, $offset);
132
-					foreach ($users as $user) {
133
-						$migration->reorganizeFolderStructureForUser($user);
134
-					}
135
-					$offset += $limit;
136
-				} while (count($users) >= $limit);
137
-			}
138
-
139
-			$migration->finalCleanUp();
140
-
141
-		} catch (\Exception $e) {
142
-			return [
143
-				'data' => [
144
-					'message' => (string)$this->l10n->t('A problem occurred, please check your log files (Error: %s)', [$e->getMessage()]),
145
-				],
146
-				'status' => 'error',
147
-			];
148
-		}
149
-
150
-		return [
151
-			'data' => [
152
-				'message' => (string) $this->l10n->t('Migration Completed'),
153
-				],
154
-			'status' => 'success',
155
-		];
156
-	}
117
+        if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
118
+            @set_time_limit(0);
119
+        }
120
+
121
+        try {
122
+
123
+            $migration = $this->getMigration($this->config, $this->view, $this->connection, $this->logger, $this->appManager);
124
+            $migration->reorganizeSystemFolderStructure();
125
+            $migration->updateDB();
126
+
127
+            foreach ($this->userManager->getBackends() as $backend) {
128
+                $limit = 500;
129
+                $offset = 0;
130
+                do {
131
+                    $users = $backend->getUsers('', $limit, $offset);
132
+                    foreach ($users as $user) {
133
+                        $migration->reorganizeFolderStructureForUser($user);
134
+                    }
135
+                    $offset += $limit;
136
+                } while (count($users) >= $limit);
137
+            }
138
+
139
+            $migration->finalCleanUp();
140
+
141
+        } catch (\Exception $e) {
142
+            return [
143
+                'data' => [
144
+                    'message' => (string)$this->l10n->t('A problem occurred, please check your log files (Error: %s)', [$e->getMessage()]),
145
+                ],
146
+                'status' => 'error',
147
+            ];
148
+        }
149
+
150
+        return [
151
+            'data' => [
152
+                'message' => (string) $this->l10n->t('Migration Completed'),
153
+                ],
154
+            'status' => 'success',
155
+        ];
156
+    }
157 157
 
158 158
 }
Please login to merge, or discard this patch.
settings/Controller/MailSettingsController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
 
98 98
 		$params = get_defined_vars();
99 99
 		$configs = [];
100
-		foreach($params as $key => $value) {
100
+		foreach ($params as $key => $value) {
101 101
 			$configs[$key] = (empty($value)) ? null : $value;
102 102
 		}
103 103
 
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -39,138 +39,138 @@
 block discarded – undo
39 39
  */
40 40
 class MailSettingsController extends Controller {
41 41
 
42
-	/** @var IL10N */
43
-	private $l10n;
44
-	/** @var IConfig */
45
-	private $config;
46
-	/** @var IUserSession */
47
-	private $userSession;
48
-	/** @var IMailer */
49
-	private $mailer;
50
-	/** @var string */
51
-	private $defaultMailAddress;
52
-
53
-	/**
54
-	 * @param string $appName
55
-	 * @param IRequest $request
56
-	 * @param IL10N $l10n
57
-	 * @param IConfig $config
58
-	 * @param IUserSession $userSession
59
-	 * @param IMailer $mailer
60
-	 * @param string $fromMailAddress
61
-	 */
62
-	public function __construct($appName,
63
-								IRequest $request,
64
-								IL10N $l10n,
65
-								IConfig $config,
66
-								IUserSession $userSession,
67
-								IMailer $mailer,
68
-								$fromMailAddress) {
69
-		parent::__construct($appName, $request);
70
-		$this->l10n = $l10n;
71
-		$this->config = $config;
72
-		$this->userSession = $userSession;
73
-		$this->mailer = $mailer;
74
-		$this->defaultMailAddress = $fromMailAddress;
75
-	}
76
-
77
-	/**
78
-	 * Sets the email settings
79
-	 *
80
-	 * @PasswordConfirmationRequired
81
-	 *
82
-	 * @param string $mail_domain
83
-	 * @param string $mail_from_address
84
-	 * @param string $mail_smtpmode
85
-	 * @param string $mail_smtpsecure
86
-	 * @param string $mail_smtphost
87
-	 * @param string $mail_smtpauthtype
88
-	 * @param int $mail_smtpauth
89
-	 * @param string $mail_smtpport
90
-	 * @return DataResponse
91
-	 */
92
-	public function setMailSettings($mail_domain,
93
-									$mail_from_address,
94
-									$mail_smtpmode,
95
-									$mail_smtpsecure,
96
-									$mail_smtphost,
97
-									$mail_smtpauthtype,
98
-									$mail_smtpauth,
99
-									$mail_smtpport) {
100
-
101
-		$params = get_defined_vars();
102
-		$configs = [];
103
-		foreach($params as $key => $value) {
104
-			$configs[$key] = (empty($value)) ? null : $value;
105
-		}
106
-
107
-		// Delete passwords from config in case no auth is specified
108
-		if ($params['mail_smtpauth'] !== 1) {
109
-			$configs['mail_smtpname'] = null;
110
-			$configs['mail_smtppassword'] = null;
111
-		}
112
-
113
-		$this->config->setSystemValues($configs);
114
-
115
-		return new DataResponse();
116
-	}
117
-
118
-	/**
119
-	 * Store the credentials used for SMTP in the config
120
-	 *
121
-	 * @PasswordConfirmationRequired
122
-	 *
123
-	 * @param string $mail_smtpname
124
-	 * @param string $mail_smtppassword
125
-	 * @return DataResponse
126
-	 */
127
-	public function storeCredentials($mail_smtpname, $mail_smtppassword) {
128
-		if ($mail_smtppassword === '********') {
129
-			return new DataResponse($this->l10n->t('Invalid SMTP password.'), Http::STATUS_BAD_REQUEST);
130
-		}
131
-
132
-		$this->config->setSystemValues([
133
-			'mail_smtpname'		=> $mail_smtpname,
134
-			'mail_smtppassword'	=> $mail_smtppassword,
135
-		]);
136
-
137
-		return new DataResponse();
138
-	}
139
-
140
-	/**
141
-	 * Send a mail to test the settings
142
-	 * @return DataResponse
143
-	 */
144
-	public function sendTestMail() {
145
-		$email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', '');
146
-		if (!empty($email)) {
147
-			try {
148
-				$displayName = $this->userSession->getUser()->getDisplayName();
149
-
150
-				$template = $this->mailer->createEMailTemplate('settings.TestEmail', [
151
-					'displayname' => $displayName,
152
-				]);
153
-
154
-				$template->setSubject($this->l10n->t('Email setting test'));
155
-				$template->addHeader();
156
-				$template->addHeading($this->l10n->t('Well done, %s!', [$displayName]));
157
-				$template->addBodyText($this->l10n->t('If you received this email, the email configuration seems to be correct.'));
158
-				$template->addFooter();
159
-
160
-				$message = $this->mailer->createMessage();
161
-				$message->setTo([$email => $displayName]);
162
-				$message->useTemplate($template);
163
-				$errors = $this->mailer->send($message);
164
-				if (!empty($errors)) {
165
-					throw new \RuntimeException($this->l10n->t('Email could not be sent. Check your mail server log'));
166
-				}
167
-				return new DataResponse();
168
-			} catch (\Exception $e) {
169
-				return new DataResponse($this->l10n->t('A problem occurred while sending the email. Please revise your settings. (Error: %s)', [$e->getMessage()]), Http::STATUS_BAD_REQUEST);
170
-			}
171
-		}
172
-
173
-		return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST);
174
-	}
42
+    /** @var IL10N */
43
+    private $l10n;
44
+    /** @var IConfig */
45
+    private $config;
46
+    /** @var IUserSession */
47
+    private $userSession;
48
+    /** @var IMailer */
49
+    private $mailer;
50
+    /** @var string */
51
+    private $defaultMailAddress;
52
+
53
+    /**
54
+     * @param string $appName
55
+     * @param IRequest $request
56
+     * @param IL10N $l10n
57
+     * @param IConfig $config
58
+     * @param IUserSession $userSession
59
+     * @param IMailer $mailer
60
+     * @param string $fromMailAddress
61
+     */
62
+    public function __construct($appName,
63
+                                IRequest $request,
64
+                                IL10N $l10n,
65
+                                IConfig $config,
66
+                                IUserSession $userSession,
67
+                                IMailer $mailer,
68
+                                $fromMailAddress) {
69
+        parent::__construct($appName, $request);
70
+        $this->l10n = $l10n;
71
+        $this->config = $config;
72
+        $this->userSession = $userSession;
73
+        $this->mailer = $mailer;
74
+        $this->defaultMailAddress = $fromMailAddress;
75
+    }
76
+
77
+    /**
78
+     * Sets the email settings
79
+     *
80
+     * @PasswordConfirmationRequired
81
+     *
82
+     * @param string $mail_domain
83
+     * @param string $mail_from_address
84
+     * @param string $mail_smtpmode
85
+     * @param string $mail_smtpsecure
86
+     * @param string $mail_smtphost
87
+     * @param string $mail_smtpauthtype
88
+     * @param int $mail_smtpauth
89
+     * @param string $mail_smtpport
90
+     * @return DataResponse
91
+     */
92
+    public function setMailSettings($mail_domain,
93
+                                    $mail_from_address,
94
+                                    $mail_smtpmode,
95
+                                    $mail_smtpsecure,
96
+                                    $mail_smtphost,
97
+                                    $mail_smtpauthtype,
98
+                                    $mail_smtpauth,
99
+                                    $mail_smtpport) {
100
+
101
+        $params = get_defined_vars();
102
+        $configs = [];
103
+        foreach($params as $key => $value) {
104
+            $configs[$key] = (empty($value)) ? null : $value;
105
+        }
106
+
107
+        // Delete passwords from config in case no auth is specified
108
+        if ($params['mail_smtpauth'] !== 1) {
109
+            $configs['mail_smtpname'] = null;
110
+            $configs['mail_smtppassword'] = null;
111
+        }
112
+
113
+        $this->config->setSystemValues($configs);
114
+
115
+        return new DataResponse();
116
+    }
117
+
118
+    /**
119
+     * Store the credentials used for SMTP in the config
120
+     *
121
+     * @PasswordConfirmationRequired
122
+     *
123
+     * @param string $mail_smtpname
124
+     * @param string $mail_smtppassword
125
+     * @return DataResponse
126
+     */
127
+    public function storeCredentials($mail_smtpname, $mail_smtppassword) {
128
+        if ($mail_smtppassword === '********') {
129
+            return new DataResponse($this->l10n->t('Invalid SMTP password.'), Http::STATUS_BAD_REQUEST);
130
+        }
131
+
132
+        $this->config->setSystemValues([
133
+            'mail_smtpname'		=> $mail_smtpname,
134
+            'mail_smtppassword'	=> $mail_smtppassword,
135
+        ]);
136
+
137
+        return new DataResponse();
138
+    }
139
+
140
+    /**
141
+     * Send a mail to test the settings
142
+     * @return DataResponse
143
+     */
144
+    public function sendTestMail() {
145
+        $email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', '');
146
+        if (!empty($email)) {
147
+            try {
148
+                $displayName = $this->userSession->getUser()->getDisplayName();
149
+
150
+                $template = $this->mailer->createEMailTemplate('settings.TestEmail', [
151
+                    'displayname' => $displayName,
152
+                ]);
153
+
154
+                $template->setSubject($this->l10n->t('Email setting test'));
155
+                $template->addHeader();
156
+                $template->addHeading($this->l10n->t('Well done, %s!', [$displayName]));
157
+                $template->addBodyText($this->l10n->t('If you received this email, the email configuration seems to be correct.'));
158
+                $template->addFooter();
159
+
160
+                $message = $this->mailer->createMessage();
161
+                $message->setTo([$email => $displayName]);
162
+                $message->useTemplate($template);
163
+                $errors = $this->mailer->send($message);
164
+                if (!empty($errors)) {
165
+                    throw new \RuntimeException($this->l10n->t('Email could not be sent. Check your mail server log'));
166
+                }
167
+                return new DataResponse();
168
+            } catch (\Exception $e) {
169
+                return new DataResponse($this->l10n->t('A problem occurred while sending the email. Please revise your settings. (Error: %s)', [$e->getMessage()]), Http::STATUS_BAD_REQUEST);
170
+            }
171
+        }
172
+
173
+        return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST);
174
+    }
175 175
 
176 176
 }
Please login to merge, or discard this patch.
settings/Middleware/SubadminMiddleware.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 	 * @throws \Exception
60 60
 	 */
61 61
 	public function beforeController($controller, $methodName) {
62
-		if(!$this->reflector->hasAnnotation('NoSubadminRequired')) {
63
-			if(!$this->isSubAdmin) {
62
+		if (!$this->reflector->hasAnnotation('NoSubadminRequired')) {
63
+			if (!$this->isSubAdmin) {
64 64
 				throw new NotAdminException('Logged in user must be a subadmin');
65 65
 			}
66 66
 		}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @throws \Exception
76 76
 	 */
77 77
 	public function afterException($controller, $methodName, \Exception $exception) {
78
-		if($exception instanceof NotAdminException) {
78
+		if ($exception instanceof NotAdminException) {
79 79
 			$response = new TemplateResponse('core', '403', array(), 'guest');
80 80
 			$response->setStatus(Http::STATUS_FORBIDDEN);
81 81
 			return $response;
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -38,51 +38,51 @@
 block discarded – undo
38 38
  * @package OC\Settings\Middleware
39 39
  */
40 40
 class SubadminMiddleware extends Middleware {
41
-	/** @var bool */
42
-	protected $isSubAdmin;
43
-	/** @var ControllerMethodReflector */
44
-	protected $reflector;
41
+    /** @var bool */
42
+    protected $isSubAdmin;
43
+    /** @var ControllerMethodReflector */
44
+    protected $reflector;
45 45
 
46
-	/**
47
-	 * @param ControllerMethodReflector $reflector
48
-	 * @param bool $isSubAdmin
49
-	 */
50
-	public function __construct(ControllerMethodReflector $reflector,
51
-								$isSubAdmin) {
52
-		$this->reflector = $reflector;
53
-		$this->isSubAdmin = $isSubAdmin;
54
-	}
46
+    /**
47
+     * @param ControllerMethodReflector $reflector
48
+     * @param bool $isSubAdmin
49
+     */
50
+    public function __construct(ControllerMethodReflector $reflector,
51
+                                $isSubAdmin) {
52
+        $this->reflector = $reflector;
53
+        $this->isSubAdmin = $isSubAdmin;
54
+    }
55 55
 
56
-	/**
57
-	 * Check if sharing is enabled before the controllers is executed
58
-	 * @param Controller $controller
59
-	 * @param string $methodName
60
-	 * @throws \Exception
61
-	 */
62
-	public function beforeController($controller, $methodName) {
63
-		if(!$this->reflector->hasAnnotation('NoSubadminRequired')) {
64
-			if(!$this->isSubAdmin) {
65
-				throw new NotAdminException('Logged in user must be a subadmin');
66
-			}
67
-		}
68
-	}
56
+    /**
57
+     * Check if sharing is enabled before the controllers is executed
58
+     * @param Controller $controller
59
+     * @param string $methodName
60
+     * @throws \Exception
61
+     */
62
+    public function beforeController($controller, $methodName) {
63
+        if(!$this->reflector->hasAnnotation('NoSubadminRequired')) {
64
+            if(!$this->isSubAdmin) {
65
+                throw new NotAdminException('Logged in user must be a subadmin');
66
+            }
67
+        }
68
+    }
69 69
 
70
-	/**
71
-	 * Return 403 page in case of an exception
72
-	 * @param Controller $controller
73
-	 * @param string $methodName
74
-	 * @param \Exception $exception
75
-	 * @return TemplateResponse
76
-	 * @throws \Exception
77
-	 */
78
-	public function afterException($controller, $methodName, \Exception $exception) {
79
-		if($exception instanceof NotAdminException) {
80
-			$response = new TemplateResponse('core', '403', array(), 'guest');
81
-			$response->setStatus(Http::STATUS_FORBIDDEN);
82
-			return $response;
83
-		}
70
+    /**
71
+     * Return 403 page in case of an exception
72
+     * @param Controller $controller
73
+     * @param string $methodName
74
+     * @param \Exception $exception
75
+     * @return TemplateResponse
76
+     * @throws \Exception
77
+     */
78
+    public function afterException($controller, $methodName, \Exception $exception) {
79
+        if($exception instanceof NotAdminException) {
80
+            $response = new TemplateResponse('core', '403', array(), 'guest');
81
+            $response->setStatus(Http::STATUS_FORBIDDEN);
82
+            return $response;
83
+        }
84 84
 
85
-		throw $exception;
86
-	}
85
+        throw $exception;
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
settings/users.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 		];
83 83
 	}
84 84
 	$subAdmins = $result;
85
-}else{
85
+} else{
86 86
 	/* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
87 87
 	$gids = array();
88 88
 	foreach($groups as $group) {
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
 $config = \OC::$server->getConfig();
50 50
 
51 51
 if ($config->getSystemValue('sort_groups_by_name', false)) {
52
-	$sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
52
+    $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
53 53
 } else {
54
-	$isLDAPUsed = false;
55
-	if ($appManager->isEnabledForUser('user_ldap')) {
56
-		$isLDAPUsed =
57
-			$groupManager->isBackendUsed('\OCA\User_LDAP\Group_LDAP')
58
-			|| $groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy');
59
-		if ($isLDAPUsed) {
60
-			// LDAP user count can be slow, so we sort by group name here
61
-			$sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
62
-		}
63
-	}
54
+    $isLDAPUsed = false;
55
+    if ($appManager->isEnabledForUser('user_ldap')) {
56
+        $isLDAPUsed =
57
+            $groupManager->isBackendUsed('\OCA\User_LDAP\Group_LDAP')
58
+            || $groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy');
59
+        if ($isLDAPUsed) {
60
+            // LDAP user count can be slow, so we sort by group name here
61
+            $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
62
+        }
63
+    }
64 64
 }
65 65
 
66 66
 $isAdmin = OC_User::isAdminUser(OC_User::getUser());
@@ -68,58 +68,58 @@  discard block
 block discarded – undo
68 68
 $isDisabled = !OC_User::isEnabled(OC_User::getUser());
69 69
 
70 70
 $groupsInfo = new \OC\Group\MetaData(
71
-	OC_User::getUser(),
72
-	$isAdmin,
73
-	$groupManager,
74
-	\OC::$server->getUserSession()
71
+    OC_User::getUser(),
72
+    $isAdmin,
73
+    $groupManager,
74
+    \OC::$server->getUserSession()
75 75
 );
76 76
 
77 77
 $groupsInfo->setSorting($sortGroupsBy);
78 78
 list($adminGroup, $groups) = $groupsInfo->get();
79 79
 
80 80
 $recoveryAdminEnabled = $appManager->isEnabledForUser('encryption') &&
81
-					    $config->getAppValue( 'encryption', 'recoveryAdminEnabled', '0');
81
+                        $config->getAppValue( 'encryption', 'recoveryAdminEnabled', '0');
82 82
 
83 83
 if($isAdmin) {
84
-	$subAdmins = \OC::$server->getGroupManager()->getSubAdmin()->getAllSubAdmins();
85
-	// New class returns IUser[] so convert back
86
-	$result = [];
87
-	foreach ($subAdmins as $subAdmin) {
88
-		$result[] = [
89
-			'gid' => $subAdmin['group']->getGID(),
90
-			'uid' => $subAdmin['user']->getUID(),
91
-		];
92
-	}
93
-	$subAdmins = $result;
84
+    $subAdmins = \OC::$server->getGroupManager()->getSubAdmin()->getAllSubAdmins();
85
+    // New class returns IUser[] so convert back
86
+    $result = [];
87
+    foreach ($subAdmins as $subAdmin) {
88
+        $result[] = [
89
+            'gid' => $subAdmin['group']->getGID(),
90
+            'uid' => $subAdmin['user']->getUID(),
91
+        ];
92
+    }
93
+    $subAdmins = $result;
94 94
 }else{
95
-	/* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
96
-	$gids = array();
97
-	foreach($groups as $group) {
98
-		if (isset($group['id'])) {
99
-			$gids[] = $group['id'];
100
-		}
101
-	}
102
-	$subAdmins = false;
95
+    /* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
96
+    $gids = array();
97
+    foreach($groups as $group) {
98
+        if (isset($group['id'])) {
99
+            $gids[] = $group['id'];
100
+        }
101
+    }
102
+    $subAdmins = false;
103 103
 }
104 104
 
105 105
 $disabledUsers = $isLDAPUsed ? 0 : $userManager->countDisabledUsers();
106 106
 $disabledUsersGroup = [
107
-	'id' => '_disabledUsers',
108
-	'name' => '_disabledUsers',
109
-	'usercount' => $disabledUsers
107
+    'id' => '_disabledUsers',
108
+    'name' => '_disabledUsers',
109
+    'usercount' => $disabledUsers
110 110
 ];
111 111
 
112 112
 // load preset quotas
113 113
 $quotaPreset=$config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
114 114
 $quotaPreset=explode(',', $quotaPreset);
115 115
 foreach($quotaPreset as &$preset) {
116
-	$preset=trim($preset);
116
+    $preset=trim($preset);
117 117
 }
118 118
 $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
119 119
 
120 120
 $defaultQuota=$config->getAppValue('files', 'default_quota', 'none');
121 121
 $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
122
-	&& array_search($defaultQuota, array('none', 'default'))===false;
122
+    && array_search($defaultQuota, array('none', 'default'))===false;
123 123
 
124 124
 \OC::$server->getEventDispatcher()->dispatch('OC\Settings\Users::loadAdditionalScripts');
125 125
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 list($adminGroup, $groups) = $groupsInfo->get();
79 79
 
80 80
 $recoveryAdminEnabled = $appManager->isEnabledForUser('encryption') &&
81
-					    $config->getAppValue( 'encryption', 'recoveryAdminEnabled', '0');
81
+					    $config->getAppValue('encryption', 'recoveryAdminEnabled', '0');
82 82
 
83
-if($isAdmin) {
83
+if ($isAdmin) {
84 84
 	$subAdmins = \OC::$server->getGroupManager()->getSubAdmin()->getAllSubAdmins();
85 85
 	// New class returns IUser[] so convert back
86 86
 	$result = [];
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 		];
92 92
 	}
93 93
 	$subAdmins = $result;
94
-}else{
94
+} else {
95 95
 	/* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
96 96
 	$gids = array();
97
-	foreach($groups as $group) {
97
+	foreach ($groups as $group) {
98 98
 		if (isset($group['id'])) {
99 99
 			$gids[] = $group['id'];
100 100
 		}
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 ];
111 111
 
112 112
 // load preset quotas
113
-$quotaPreset=$config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
114
-$quotaPreset=explode(',', $quotaPreset);
115
-foreach($quotaPreset as &$preset) {
116
-	$preset=trim($preset);
113
+$quotaPreset = $config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
114
+$quotaPreset = explode(',', $quotaPreset);
115
+foreach ($quotaPreset as &$preset) {
116
+	$preset = trim($preset);
117 117
 }
118
-$quotaPreset=array_diff($quotaPreset, array('default', 'none'));
118
+$quotaPreset = array_diff($quotaPreset, array('default', 'none'));
119 119
 
120
-$defaultQuota=$config->getAppValue('files', 'default_quota', 'none');
121
-$defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
122
-	&& array_search($defaultQuota, array('none', 'default'))===false;
120
+$defaultQuota = $config->getAppValue('files', 'default_quota', 'none');
121
+$defaultQuotaIsUserDefined = array_search($defaultQuota, $quotaPreset) === false
122
+	&& array_search($defaultQuota, array('none', 'default')) === false;
123 123
 
124 124
 \OC::$server->getEventDispatcher()->dispatch('OC\Settings\Users::loadAdditionalScripts');
125 125
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 $tmpl->assign('sortGroups', $sortGroupsBy);
129 129
 $tmpl->assign('adminGroup', $adminGroup);
130 130
 $tmpl->assign('disabledUsersGroup', $disabledUsersGroup);
131
-$tmpl->assign('isAdmin', (int)$isAdmin);
131
+$tmpl->assign('isAdmin', (int) $isAdmin);
132 132
 $tmpl->assign('subadmins', $subAdmins);
133 133
 $tmpl->assign('numofgroups', count($groups) + count($adminGroup));
134 134
 $tmpl->assign('quota_preset', $quotaPreset);
Please login to merge, or discard this patch.
settings/help.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@
 block discarded – undo
36 36
 
37 37
 
38 38
 if(isset($_GET['mode']) and $_GET['mode'] === 'admin') {
39
-	$url=\OCP\Util::linkToAbsolute( 'core', 'doc/admin/index.html' );
40
-	$style1='';
41
-	$style2=' active';
39
+    $url=\OCP\Util::linkToAbsolute( 'core', 'doc/admin/index.html' );
40
+    $style1='';
41
+    $style2=' active';
42 42
 }else{
43
-	$url=\OCP\Util::linkToAbsolute( 'core', 'doc/user/index.html' );
44
-	$style1=' active';
45
-	$style2='';
43
+    $url=\OCP\Util::linkToAbsolute( 'core', 'doc/user/index.html' );
44
+    $style1=' active';
45
+    $style2='';
46 46
 }
47 47
 
48 48
 $url1=\OC::$server->getURLGenerator()->linkToRoute('settings_help').'?mode=user';
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,28 +31,28 @@
 block discarded – undo
31 31
 OC_Util::checkLoggedIn();
32 32
 
33 33
 // Load the files we need
34
-OC_Util::addStyle( "settings", "settings" );
34
+OC_Util::addStyle("settings", "settings");
35 35
 \OC::$server->getNavigationManager()->setActiveEntry('help');
36 36
 
37 37
 
38
-if(isset($_GET['mode']) and $_GET['mode'] === 'admin') {
39
-	$url=\OCP\Util::linkToAbsolute( 'core', 'doc/admin/index.html' );
40
-	$style1='';
41
-	$style2=' active';
42
-}else{
43
-	$url=\OCP\Util::linkToAbsolute( 'core', 'doc/user/index.html' );
44
-	$style1=' active';
45
-	$style2='';
38
+if (isset($_GET['mode']) and $_GET['mode'] === 'admin') {
39
+	$url = \OCP\Util::linkToAbsolute('core', 'doc/admin/index.html');
40
+	$style1 = '';
41
+	$style2 = ' active';
42
+} else {
43
+	$url = \OCP\Util::linkToAbsolute('core', 'doc/user/index.html');
44
+	$style1 = ' active';
45
+	$style2 = '';
46 46
 }
47 47
 
48
-$url1=\OC::$server->getURLGenerator()->linkToRoute('settings_help').'?mode=user';
49
-$url2=\OC::$server->getURLGenerator()->linkToRoute('settings_help').'?mode=admin';
48
+$url1 = \OC::$server->getURLGenerator()->linkToRoute('settings_help').'?mode=user';
49
+$url2 = \OC::$server->getURLGenerator()->linkToRoute('settings_help').'?mode=admin';
50 50
 
51
-$tmpl = new OC_Template( "settings", "help", "user" );
52
-$tmpl->assign( "admin", OC_User::isAdminUser(OC_User::getUser()));
53
-$tmpl->assign( "url", $url );
54
-$tmpl->assign( "url1", $url1 );
55
-$tmpl->assign( "url2", $url2 );
56
-$tmpl->assign( "style1", $style1 );
57
-$tmpl->assign( "style2", $style2 );
51
+$tmpl = new OC_Template("settings", "help", "user");
52
+$tmpl->assign("admin", OC_User::isAdminUser(OC_User::getUser()));
53
+$tmpl->assign("url", $url);
54
+$tmpl->assign("url1", $url1);
55
+$tmpl->assign("url2", $url2);
56
+$tmpl->assign("style1", $style1);
57
+$tmpl->assign("style2", $style2);
58 58
 $tmpl->printPage();
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 	$url=\OCP\Util::linkToAbsolute( 'core', 'doc/admin/index.html' );
40 40
 	$style1='';
41 41
 	$style2=' active';
42
-}else{
42
+} else{
43 43
 	$url=\OCP\Util::linkToAbsolute( 'core', 'doc/user/index.html' );
44 44
 	$style1=' active';
45 45
 	$style2='';
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Delete.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 		try {
69 69
 			$mount = $this->globalService->getStorage($mountId);
70 70
 		} catch (NotFoundException $e) {
71
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
71
+			$output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>');
72 72
 			return 404;
73 73
 		}
74 74
 
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -37,76 +37,76 @@
 block discarded – undo
37 37
 use Symfony\Component\Console\Question\ConfirmationQuestion;
38 38
 
39 39
 class Delete extends Base {
40
-	/**
41
-	 * @var GlobalStoragesService
42
-	 */
43
-	protected $globalService;
40
+    /**
41
+     * @var GlobalStoragesService
42
+     */
43
+    protected $globalService;
44 44
 
45
-	/**
46
-	 * @var UserStoragesService
47
-	 */
48
-	protected $userService;
45
+    /**
46
+     * @var UserStoragesService
47
+     */
48
+    protected $userService;
49 49
 
50
-	/**
51
-	 * @var IUserSession
52
-	 */
53
-	protected $userSession;
50
+    /**
51
+     * @var IUserSession
52
+     */
53
+    protected $userSession;
54 54
 
55
-	/**
56
-	 * @var IUserManager
57
-	 */
58
-	protected $userManager;
55
+    /**
56
+     * @var IUserManager
57
+     */
58
+    protected $userManager;
59 59
 
60
-	function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
61
-		parent::__construct();
62
-		$this->globalService = $globalService;
63
-		$this->userService = $userService;
64
-		$this->userSession = $userSession;
65
-		$this->userManager = $userManager;
66
-	}
60
+    function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
61
+        parent::__construct();
62
+        $this->globalService = $globalService;
63
+        $this->userService = $userService;
64
+        $this->userSession = $userSession;
65
+        $this->userManager = $userManager;
66
+    }
67 67
 
68
-	protected function configure() {
69
-		$this
70
-			->setName('files_external:delete')
71
-			->setDescription('Delete an external mount')
72
-			->addArgument(
73
-				'mount_id',
74
-				InputArgument::REQUIRED,
75
-				'The id of the mount to edit'
76
-			)->addOption(
77
-				'yes',
78
-				'y',
79
-				InputOption::VALUE_NONE,
80
-				'Skip confirmation'
81
-			);
82
-		parent::configure();
83
-	}
68
+    protected function configure() {
69
+        $this
70
+            ->setName('files_external:delete')
71
+            ->setDescription('Delete an external mount')
72
+            ->addArgument(
73
+                'mount_id',
74
+                InputArgument::REQUIRED,
75
+                'The id of the mount to edit'
76
+            )->addOption(
77
+                'yes',
78
+                'y',
79
+                InputOption::VALUE_NONE,
80
+                'Skip confirmation'
81
+            );
82
+        parent::configure();
83
+    }
84 84
 
85
-	protected function execute(InputInterface $input, OutputInterface $output) {
86
-		$mountId = $input->getArgument('mount_id');
87
-		try {
88
-			$mount = $this->globalService->getStorage($mountId);
89
-		} catch (NotFoundException $e) {
90
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
91
-			return 404;
92
-		}
85
+    protected function execute(InputInterface $input, OutputInterface $output) {
86
+        $mountId = $input->getArgument('mount_id');
87
+        try {
88
+            $mount = $this->globalService->getStorage($mountId);
89
+        } catch (NotFoundException $e) {
90
+            $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
91
+            return 404;
92
+        }
93 93
 
94
-		$noConfirm = $input->getOption('yes');
94
+        $noConfirm = $input->getOption('yes');
95 95
 
96
-		if (!$noConfirm) {
97
-			$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
98
-			$listInput = new ArrayInput([], $listCommand->getDefinition());
99
-			$listInput->setOption('output', $input->getOption('output'));
100
-			$listCommand->listMounts(null, [$mount], $listInput, $output);
96
+        if (!$noConfirm) {
97
+            $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
98
+            $listInput = new ArrayInput([], $listCommand->getDefinition());
99
+            $listInput->setOption('output', $input->getOption('output'));
100
+            $listCommand->listMounts(null, [$mount], $listInput, $output);
101 101
 
102
-			$questionHelper = $this->getHelper('question');
103
-			$question = new ConfirmationQuestion('Delete this mount? [y/N] ', false);
102
+            $questionHelper = $this->getHelper('question');
103
+            $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false);
104 104
 
105
-			if (!$questionHelper->ask($input, $output, $question)) {
106
-				return null;
107
-			}
108
-		}
105
+            if (!$questionHelper->ask($input, $output, $question)) {
106
+                return null;
107
+            }
108
+        }
109 109
 
110
-		$this->globalService->removeStorage($mountId);
111
-	}
110
+        $this->globalService->removeStorage($mountId);
111
+    }
112 112
 }
Please login to merge, or discard this patch.