@@ -29,33 +29,33 @@ |
||
29 | 29 | * @package OCA\AdminAudit\Actions |
30 | 30 | */ |
31 | 31 | class Auth extends Action { |
32 | - public function loginAttempt(array $params) { |
|
33 | - $this->log( |
|
34 | - 'Login attempt: "%s"', |
|
35 | - $params, |
|
36 | - [ |
|
37 | - 'uid', |
|
38 | - ], |
|
39 | - true |
|
40 | - ); |
|
41 | - } |
|
32 | + public function loginAttempt(array $params) { |
|
33 | + $this->log( |
|
34 | + 'Login attempt: "%s"', |
|
35 | + $params, |
|
36 | + [ |
|
37 | + 'uid', |
|
38 | + ], |
|
39 | + true |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | - public function loginSuccessful(array $params) { |
|
44 | - $this->log( |
|
45 | - 'Login successful: "%s"', |
|
46 | - $params, |
|
47 | - [ |
|
48 | - 'uid', |
|
49 | - ], |
|
50 | - true |
|
51 | - ); |
|
52 | - } |
|
43 | + public function loginSuccessful(array $params) { |
|
44 | + $this->log( |
|
45 | + 'Login successful: "%s"', |
|
46 | + $params, |
|
47 | + [ |
|
48 | + 'uid', |
|
49 | + ], |
|
50 | + true |
|
51 | + ); |
|
52 | + } |
|
53 | 53 | |
54 | - public function logout(array $params) { |
|
55 | - $this->log( |
|
56 | - 'Logout occurred', |
|
57 | - [], |
|
58 | - [] |
|
59 | - ); |
|
60 | - } |
|
54 | + public function logout(array $params) { |
|
55 | + $this->log( |
|
56 | + 'Logout occurred', |
|
57 | + [], |
|
58 | + [] |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | } |
@@ -29,25 +29,25 @@ |
||
29 | 29 | use OCP\IUserSession; |
30 | 30 | |
31 | 31 | class PersonalSection extends Section { |
32 | - /** @var IUserSession */ |
|
33 | - private $userSession; |
|
32 | + /** @var IUserSession */ |
|
33 | + private $userSession; |
|
34 | 34 | |
35 | - /** @var UserGlobalStoragesService */ |
|
36 | - private $userGlobalStoragesService; |
|
35 | + /** @var UserGlobalStoragesService */ |
|
36 | + private $userGlobalStoragesService; |
|
37 | 37 | |
38 | - /** @var BackendService */ |
|
39 | - private $backendService; |
|
38 | + /** @var BackendService */ |
|
39 | + private $backendService; |
|
40 | 40 | |
41 | - public function __construct( |
|
42 | - IURLGenerator $url, |
|
43 | - IL10N $l, |
|
44 | - IUserSession $userSession, |
|
45 | - UserGlobalStoragesService $userGlobalStoragesService, |
|
46 | - BackendService $backendService |
|
47 | - ) { |
|
48 | - parent::__construct($url, $l); |
|
49 | - $this->userSession = $userSession; |
|
50 | - $this->userGlobalStoragesService = $userGlobalStoragesService; |
|
51 | - $this->backendService = $backendService; |
|
52 | - } |
|
41 | + public function __construct( |
|
42 | + IURLGenerator $url, |
|
43 | + IL10N $l, |
|
44 | + IUserSession $userSession, |
|
45 | + UserGlobalStoragesService $userGlobalStoragesService, |
|
46 | + BackendService $backendService |
|
47 | + ) { |
|
48 | + parent::__construct($url, $l); |
|
49 | + $this->userSession = $userSession; |
|
50 | + $this->userGlobalStoragesService = $userGlobalStoragesService; |
|
51 | + $this->backendService = $backendService; |
|
52 | + } |
|
53 | 53 | } |
@@ -7,49 +7,49 @@ discard block |
||
7 | 7 | <form id="ocDefaultEncryptionModule" class="section"> |
8 | 8 | <h2 data-anchor-name="basic-encryption-module"><?php p($l->t('Basic encryption module')); ?></h2> |
9 | 9 | |
10 | - <?php if ($_["initialized"] === \OCA\Encryption\Session::NOT_INITIALIZED ): ?> |
|
10 | + <?php if ($_["initialized"] === \OCA\Encryption\Session::NOT_INITIALIZED): ?> |
|
11 | 11 | |
12 | 12 | <?php p($l->t("Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.")); ?> |
13 | 13 | |
14 | - <?php elseif ( $_["initialized"] === \OCA\Encryption\Session::INIT_EXECUTED ): ?> |
|
14 | + <?php elseif ($_["initialized"] === \OCA\Encryption\Session::INIT_EXECUTED): ?> |
|
15 | 15 | <p> |
16 | 16 | <a name="changePKPasswd" /> |
17 | 17 | <label for="changePrivateKeyPasswd"> |
18 | - <em><?php p( $l->t( "Your private key password no longer matches your log-in password." ) ); ?></em> |
|
18 | + <em><?php p($l->t("Your private key password no longer matches your log-in password.")); ?></em> |
|
19 | 19 | </label> |
20 | 20 | <br /> |
21 | - <?php p( $l->t( "Set your old private key password to your current log-in password:" ) ); ?> |
|
22 | - <?php if ( $_["recoveryEnabledForUser"] ): |
|
23 | - p( $l->t( " If you don't remember your old password you can ask your administrator to recover your files." ) ); |
|
21 | + <?php p($l->t("Set your old private key password to your current log-in password:")); ?> |
|
22 | + <?php if ($_["recoveryEnabledForUser"]): |
|
23 | + p($l->t(" If you don't remember your old password you can ask your administrator to recover your files.")); |
|
24 | 24 | endif; ?> |
25 | 25 | <br /> |
26 | 26 | <input |
27 | 27 | type="password" |
28 | 28 | name="changePrivateKeyPassword" |
29 | 29 | id="oldPrivateKeyPassword" /> |
30 | - <label for="oldPrivateKeyPassword"><?php p($l->t( "Old log-in password" )); ?></label> |
|
30 | + <label for="oldPrivateKeyPassword"><?php p($l->t("Old log-in password")); ?></label> |
|
31 | 31 | <br /> |
32 | 32 | <input |
33 | 33 | type="password" |
34 | 34 | name="changePrivateKeyPassword" |
35 | 35 | id="newPrivateKeyPassword" /> |
36 | - <label for="newRecoveryPassword"><?php p($l->t( "Current log-in password" )); ?></label> |
|
36 | + <label for="newRecoveryPassword"><?php p($l->t("Current log-in password")); ?></label> |
|
37 | 37 | <br /> |
38 | 38 | <button |
39 | 39 | type="button" |
40 | 40 | name="submitChangePrivateKeyPassword" |
41 | - disabled><?php p($l->t( "Update Private Key Password" )); ?> |
|
41 | + disabled><?php p($l->t("Update Private Key Password")); ?> |
|
42 | 42 | </button> |
43 | 43 | <span class="msg"></span> |
44 | 44 | </p> |
45 | 45 | |
46 | - <?php elseif ( $_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL ): ?> |
|
46 | + <?php elseif ($_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL): ?> |
|
47 | 47 | <br /> |
48 | 48 | <p id="userEnableRecovery"> |
49 | - <label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery:" ) ); ?></label> |
|
49 | + <label for="userEnableRecovery"><?php p($l->t("Enable password recovery:")); ?></label> |
|
50 | 50 | <span class="msg"></span> |
51 | 51 | <br /> |
52 | - <em><?php p( $l->t( "Enabling this option will allow you to reobtain access to your encrypted files in case of password loss" ) ); ?></em> |
|
52 | + <em><?php p($l->t("Enabling this option will allow you to reobtain access to your encrypted files in case of password loss")); ?></em> |
|
53 | 53 | <br /> |
54 | 54 | <input |
55 | 55 | type="radio" |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | id="userEnableRecoveryCheckbox" |
58 | 58 | name="userEnableRecovery" |
59 | 59 | value="1" |
60 | - <?php echo ( $_["recoveryEnabledForUser"] ? 'checked="checked"' : '' ); ?> /> |
|
61 | - <label for="userEnableRecoveryCheckbox"><?php p( $l->t( "Enabled" ) ); ?></label> |
|
60 | + <?php echo ($_["recoveryEnabledForUser"] ? 'checked="checked"' : ''); ?> /> |
|
61 | + <label for="userEnableRecoveryCheckbox"><?php p($l->t("Enabled")); ?></label> |
|
62 | 62 | <br /> |
63 | 63 | |
64 | 64 | <input |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | id="userDisableRecoveryCheckbox" |
68 | 68 | name="userEnableRecovery" |
69 | 69 | value="0" |
70 | - <?php echo ( $_["recoveryEnabledForUser"] === false ? 'checked="checked"' : '' ); ?> /> |
|
71 | - <label for="userDisableRecoveryCheckbox"><?php p( $l->t( "Disabled" ) ); ?></label> |
|
70 | + <?php echo ($_["recoveryEnabledForUser"] === false ? 'checked="checked"' : ''); ?> /> |
|
71 | + <label for="userDisableRecoveryCheckbox"><?php p($l->t("Disabled")); ?></label> |
|
72 | 72 | </p> |
73 | 73 | <?php endif; ?> |
74 | 74 | </form> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | - /** @var array $_ */ |
|
3 | - /** @var \OCP\IL10N $l */ |
|
2 | + /** @var array $_ */ |
|
3 | + /** @var \OCP\IL10N $l */ |
|
4 | 4 | script('encryption', 'settings-personal'); |
5 | 5 | ?> |
6 | 6 | <form id="ocDefaultEncryptionModule" class="section"> |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | <br /> |
20 | 20 | <?php p( $l->t( "Set your old private key password to your current log-in password:" ) ); ?> |
21 | 21 | <?php if ( $_["recoveryEnabledForUser"] ): |
22 | - p( $l->t( " If you don't remember your old password you can ask your administrator to recover your files." ) ); |
|
23 | - endif; ?> |
|
22 | + p( $l->t( " If you don't remember your old password you can ask your administrator to recover your files." ) ); |
|
23 | + endif; ?> |
|
24 | 24 | <br /> |
25 | 25 | <input |
26 | 26 | type="password" |
@@ -26,19 +26,19 @@ |
||
26 | 26 | use OC\Files\Storage\Wrapper\Jail; |
27 | 27 | |
28 | 28 | class JailPropagator extends Propagator { |
29 | - /** |
|
30 | - * @var Jail |
|
31 | - */ |
|
32 | - protected $storage; |
|
29 | + /** |
|
30 | + * @var Jail |
|
31 | + */ |
|
32 | + protected $storage; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param string $internalPath |
|
36 | - * @param int $time |
|
37 | - * @param int $sizeDifference |
|
38 | - */ |
|
39 | - public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
40 | - /** @var \OC\Files\Storage\Storage $storage */ |
|
41 | - list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath); |
|
42 | - $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference); |
|
43 | - } |
|
34 | + /** |
|
35 | + * @param string $internalPath |
|
36 | + * @param int $time |
|
37 | + * @param int $sizeDifference |
|
38 | + */ |
|
39 | + public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
40 | + /** @var \OC\Files\Storage\Storage $storage */ |
|
41 | + list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath); |
|
42 | + $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference); |
|
43 | + } |
|
44 | 44 | } |
@@ -24,29 +24,29 @@ |
||
24 | 24 | use OCP\IRequest; |
25 | 25 | |
26 | 26 | class Capabilities implements IPublicCapability { |
27 | - /** @var IRequest */ |
|
28 | - private $request; |
|
27 | + /** @var IRequest */ |
|
28 | + private $request; |
|
29 | 29 | |
30 | - /** @var Throttler */ |
|
31 | - private $throttler; |
|
30 | + /** @var Throttler */ |
|
31 | + private $throttler; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Capabilities constructor. |
|
35 | - * |
|
36 | - * @param IRequest $request |
|
37 | - * @param Throttler $throttler |
|
38 | - */ |
|
39 | - public function __construct(IRequest $request, |
|
40 | - Throttler $throttler) { |
|
41 | - $this->request = $request; |
|
42 | - $this->throttler = $throttler; |
|
43 | - } |
|
33 | + /** |
|
34 | + * Capabilities constructor. |
|
35 | + * |
|
36 | + * @param IRequest $request |
|
37 | + * @param Throttler $throttler |
|
38 | + */ |
|
39 | + public function __construct(IRequest $request, |
|
40 | + Throttler $throttler) { |
|
41 | + $this->request = $request; |
|
42 | + $this->throttler = $throttler; |
|
43 | + } |
|
44 | 44 | |
45 | - public function getCapabilities() { |
|
46 | - return [ |
|
47 | - 'bruteforce' => [ |
|
48 | - 'delay' => $this->throttler->getDelay($this->request->getRemoteAddress()) |
|
49 | - ] |
|
50 | - ]; |
|
51 | - } |
|
45 | + public function getCapabilities() { |
|
46 | + return [ |
|
47 | + 'bruteforce' => [ |
|
48 | + 'delay' => $this->throttler->getDelay($this->request->getRemoteAddress()) |
|
49 | + ] |
|
50 | + ]; |
|
51 | + } |
|
52 | 52 | } |
@@ -37,122 +37,122 @@ |
||
37 | 37 | * Note that the read permissions can't be masked |
38 | 38 | */ |
39 | 39 | class PermissionsMask extends Wrapper { |
40 | - /** |
|
41 | - * @var int the permissions bits we want to keep |
|
42 | - */ |
|
43 | - private $mask; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param array $arguments ['storage' => $storage, 'mask' => $mask] |
|
47 | - * |
|
48 | - * $storage: The storage the permissions mask should be applied on |
|
49 | - * $mask: The permission bits that should be kept, a combination of the \OCP\Constant::PERMISSION_ constants |
|
50 | - */ |
|
51 | - public function __construct($arguments) { |
|
52 | - parent::__construct($arguments); |
|
53 | - $this->mask = $arguments['mask']; |
|
54 | - } |
|
55 | - |
|
56 | - private function checkMask($permissions) { |
|
57 | - return ($this->mask & $permissions) === $permissions; |
|
58 | - } |
|
59 | - |
|
60 | - public function isUpdatable($path) { |
|
61 | - return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::isUpdatable($path); |
|
62 | - } |
|
63 | - |
|
64 | - public function isCreatable($path) { |
|
65 | - return $this->checkMask(Constants::PERMISSION_CREATE) and parent::isCreatable($path); |
|
66 | - } |
|
67 | - |
|
68 | - public function isDeletable($path) { |
|
69 | - return $this->checkMask(Constants::PERMISSION_DELETE) and parent::isDeletable($path); |
|
70 | - } |
|
71 | - |
|
72 | - public function isSharable($path) { |
|
73 | - return $this->checkMask(Constants::PERMISSION_SHARE) and parent::isSharable($path); |
|
74 | - } |
|
75 | - |
|
76 | - public function getPermissions($path) { |
|
77 | - return $this->storage->getPermissions($path) & $this->mask; |
|
78 | - } |
|
79 | - |
|
80 | - public function rename($path1, $path2) { |
|
81 | - $p = strpos($path1, $path2); |
|
82 | - if ($p === 0) { |
|
83 | - $part = substr($path1, strlen($path2)); |
|
84 | - //This is a rename of the transfer file to the original file |
|
85 | - if (strpos($part, '.ocTransferId') === 0) { |
|
86 | - return $this->checkMask(Constants::PERMISSION_CREATE) and parent::rename($path1, $path2); |
|
87 | - } |
|
88 | - } |
|
89 | - return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::rename($path1, $path2); |
|
90 | - } |
|
91 | - |
|
92 | - public function copy($path1, $path2) { |
|
93 | - return $this->checkMask(Constants::PERMISSION_CREATE) and parent::copy($path1, $path2); |
|
94 | - } |
|
95 | - |
|
96 | - public function touch($path, $mtime = null) { |
|
97 | - $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; |
|
98 | - return $this->checkMask($permissions) and parent::touch($path, $mtime); |
|
99 | - } |
|
100 | - |
|
101 | - public function mkdir($path) { |
|
102 | - return $this->checkMask(Constants::PERMISSION_CREATE) and parent::mkdir($path); |
|
103 | - } |
|
104 | - |
|
105 | - public function rmdir($path) { |
|
106 | - return $this->checkMask(Constants::PERMISSION_DELETE) and parent::rmdir($path); |
|
107 | - } |
|
108 | - |
|
109 | - public function unlink($path) { |
|
110 | - return $this->checkMask(Constants::PERMISSION_DELETE) and parent::unlink($path); |
|
111 | - } |
|
112 | - |
|
113 | - public function file_put_contents($path, $data) { |
|
114 | - $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; |
|
115 | - return $this->checkMask($permissions) ? parent::file_put_contents($path, $data) : false; |
|
116 | - } |
|
117 | - |
|
118 | - public function fopen($path, $mode) { |
|
119 | - if ($mode === 'r' or $mode === 'rb') { |
|
120 | - return parent::fopen($path, $mode); |
|
121 | - } else { |
|
122 | - $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; |
|
123 | - return $this->checkMask($permissions) ? parent::fopen($path, $mode) : false; |
|
124 | - } |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * get a cache instance for the storage |
|
129 | - * |
|
130 | - * @param string $path |
|
131 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
132 | - * @return \OC\Files\Cache\Cache |
|
133 | - */ |
|
134 | - public function getCache($path = '', $storage = null) { |
|
135 | - if (!$storage) { |
|
136 | - $storage = $this; |
|
137 | - } |
|
138 | - $sourceCache = parent::getCache($path, $storage); |
|
139 | - return new CachePermissionsMask($sourceCache, $this->mask); |
|
140 | - } |
|
141 | - |
|
142 | - public function getMetaData($path) { |
|
143 | - $data = parent::getMetaData($path); |
|
144 | - |
|
145 | - if ($data && isset($data['permissions'])) { |
|
146 | - $data['scan_permissions'] = isset($data['scan_permissions']) ? $data['scan_permissions'] : $data['permissions']; |
|
147 | - $data['permissions'] &= $this->mask; |
|
148 | - } |
|
149 | - return $data; |
|
150 | - } |
|
151 | - |
|
152 | - public function getScanner($path = '', $storage = null) { |
|
153 | - if (!$storage) { |
|
154 | - $storage = $this->storage; |
|
155 | - } |
|
156 | - return parent::getScanner($path, $storage); |
|
157 | - } |
|
40 | + /** |
|
41 | + * @var int the permissions bits we want to keep |
|
42 | + */ |
|
43 | + private $mask; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param array $arguments ['storage' => $storage, 'mask' => $mask] |
|
47 | + * |
|
48 | + * $storage: The storage the permissions mask should be applied on |
|
49 | + * $mask: The permission bits that should be kept, a combination of the \OCP\Constant::PERMISSION_ constants |
|
50 | + */ |
|
51 | + public function __construct($arguments) { |
|
52 | + parent::__construct($arguments); |
|
53 | + $this->mask = $arguments['mask']; |
|
54 | + } |
|
55 | + |
|
56 | + private function checkMask($permissions) { |
|
57 | + return ($this->mask & $permissions) === $permissions; |
|
58 | + } |
|
59 | + |
|
60 | + public function isUpdatable($path) { |
|
61 | + return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::isUpdatable($path); |
|
62 | + } |
|
63 | + |
|
64 | + public function isCreatable($path) { |
|
65 | + return $this->checkMask(Constants::PERMISSION_CREATE) and parent::isCreatable($path); |
|
66 | + } |
|
67 | + |
|
68 | + public function isDeletable($path) { |
|
69 | + return $this->checkMask(Constants::PERMISSION_DELETE) and parent::isDeletable($path); |
|
70 | + } |
|
71 | + |
|
72 | + public function isSharable($path) { |
|
73 | + return $this->checkMask(Constants::PERMISSION_SHARE) and parent::isSharable($path); |
|
74 | + } |
|
75 | + |
|
76 | + public function getPermissions($path) { |
|
77 | + return $this->storage->getPermissions($path) & $this->mask; |
|
78 | + } |
|
79 | + |
|
80 | + public function rename($path1, $path2) { |
|
81 | + $p = strpos($path1, $path2); |
|
82 | + if ($p === 0) { |
|
83 | + $part = substr($path1, strlen($path2)); |
|
84 | + //This is a rename of the transfer file to the original file |
|
85 | + if (strpos($part, '.ocTransferId') === 0) { |
|
86 | + return $this->checkMask(Constants::PERMISSION_CREATE) and parent::rename($path1, $path2); |
|
87 | + } |
|
88 | + } |
|
89 | + return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::rename($path1, $path2); |
|
90 | + } |
|
91 | + |
|
92 | + public function copy($path1, $path2) { |
|
93 | + return $this->checkMask(Constants::PERMISSION_CREATE) and parent::copy($path1, $path2); |
|
94 | + } |
|
95 | + |
|
96 | + public function touch($path, $mtime = null) { |
|
97 | + $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; |
|
98 | + return $this->checkMask($permissions) and parent::touch($path, $mtime); |
|
99 | + } |
|
100 | + |
|
101 | + public function mkdir($path) { |
|
102 | + return $this->checkMask(Constants::PERMISSION_CREATE) and parent::mkdir($path); |
|
103 | + } |
|
104 | + |
|
105 | + public function rmdir($path) { |
|
106 | + return $this->checkMask(Constants::PERMISSION_DELETE) and parent::rmdir($path); |
|
107 | + } |
|
108 | + |
|
109 | + public function unlink($path) { |
|
110 | + return $this->checkMask(Constants::PERMISSION_DELETE) and parent::unlink($path); |
|
111 | + } |
|
112 | + |
|
113 | + public function file_put_contents($path, $data) { |
|
114 | + $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; |
|
115 | + return $this->checkMask($permissions) ? parent::file_put_contents($path, $data) : false; |
|
116 | + } |
|
117 | + |
|
118 | + public function fopen($path, $mode) { |
|
119 | + if ($mode === 'r' or $mode === 'rb') { |
|
120 | + return parent::fopen($path, $mode); |
|
121 | + } else { |
|
122 | + $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; |
|
123 | + return $this->checkMask($permissions) ? parent::fopen($path, $mode) : false; |
|
124 | + } |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * get a cache instance for the storage |
|
129 | + * |
|
130 | + * @param string $path |
|
131 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
132 | + * @return \OC\Files\Cache\Cache |
|
133 | + */ |
|
134 | + public function getCache($path = '', $storage = null) { |
|
135 | + if (!$storage) { |
|
136 | + $storage = $this; |
|
137 | + } |
|
138 | + $sourceCache = parent::getCache($path, $storage); |
|
139 | + return new CachePermissionsMask($sourceCache, $this->mask); |
|
140 | + } |
|
141 | + |
|
142 | + public function getMetaData($path) { |
|
143 | + $data = parent::getMetaData($path); |
|
144 | + |
|
145 | + if ($data && isset($data['permissions'])) { |
|
146 | + $data['scan_permissions'] = isset($data['scan_permissions']) ? $data['scan_permissions'] : $data['permissions']; |
|
147 | + $data['permissions'] &= $this->mask; |
|
148 | + } |
|
149 | + return $data; |
|
150 | + } |
|
151 | + |
|
152 | + public function getScanner($path = '', $storage = null) { |
|
153 | + if (!$storage) { |
|
154 | + $storage = $this->storage; |
|
155 | + } |
|
156 | + return parent::getScanner($path, $storage); |
|
157 | + } |
|
158 | 158 | } |
@@ -29,68 +29,68 @@ |
||
29 | 29 | use OCP\Diagnostics\IQueryLogger; |
30 | 30 | |
31 | 31 | class QueryLogger implements IQueryLogger { |
32 | - /** |
|
33 | - * @var \OC\Diagnostics\Query |
|
34 | - */ |
|
35 | - protected $activeQuery; |
|
32 | + /** |
|
33 | + * @var \OC\Diagnostics\Query |
|
34 | + */ |
|
35 | + protected $activeQuery; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @var CappedMemoryCache |
|
39 | - */ |
|
40 | - protected $queries; |
|
37 | + /** |
|
38 | + * @var CappedMemoryCache |
|
39 | + */ |
|
40 | + protected $queries; |
|
41 | 41 | |
42 | - /** |
|
43 | - * QueryLogger constructor. |
|
44 | - */ |
|
45 | - public function __construct() { |
|
46 | - $this->queries = new CappedMemoryCache(1024); |
|
47 | - } |
|
42 | + /** |
|
43 | + * QueryLogger constructor. |
|
44 | + */ |
|
45 | + public function __construct() { |
|
46 | + $this->queries = new CappedMemoryCache(1024); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @var bool - Module needs to be activated by some app |
|
52 | - */ |
|
53 | - private $activated = false; |
|
50 | + /** |
|
51 | + * @var bool - Module needs to be activated by some app |
|
52 | + */ |
|
53 | + private $activated = false; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @inheritdoc |
|
57 | - */ |
|
58 | - public function startQuery($sql, array $params = null, array $types = null) { |
|
59 | - if ($this->activated) { |
|
60 | - $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); |
|
61 | - } |
|
62 | - } |
|
55 | + /** |
|
56 | + * @inheritdoc |
|
57 | + */ |
|
58 | + public function startQuery($sql, array $params = null, array $types = null) { |
|
59 | + if ($this->activated) { |
|
60 | + $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - private function getStack() { |
|
65 | - $stack = debug_backtrace(); |
|
66 | - array_shift($stack); |
|
67 | - array_shift($stack); |
|
68 | - array_shift($stack); |
|
69 | - return $stack; |
|
70 | - } |
|
64 | + private function getStack() { |
|
65 | + $stack = debug_backtrace(); |
|
66 | + array_shift($stack); |
|
67 | + array_shift($stack); |
|
68 | + array_shift($stack); |
|
69 | + return $stack; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @inheritdoc |
|
74 | - */ |
|
75 | - public function stopQuery() { |
|
76 | - if ($this->activated && $this->activeQuery) { |
|
77 | - $this->activeQuery->end(microtime(true)); |
|
78 | - $this->queries[] = $this->activeQuery; |
|
79 | - $this->activeQuery = null; |
|
80 | - } |
|
81 | - } |
|
72 | + /** |
|
73 | + * @inheritdoc |
|
74 | + */ |
|
75 | + public function stopQuery() { |
|
76 | + if ($this->activated && $this->activeQuery) { |
|
77 | + $this->activeQuery->end(microtime(true)); |
|
78 | + $this->queries[] = $this->activeQuery; |
|
79 | + $this->activeQuery = null; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @inheritdoc |
|
85 | - */ |
|
86 | - public function getQueries() { |
|
87 | - return $this->queries->getData(); |
|
88 | - } |
|
83 | + /** |
|
84 | + * @inheritdoc |
|
85 | + */ |
|
86 | + public function getQueries() { |
|
87 | + return $this->queries->getData(); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @inheritdoc |
|
92 | - */ |
|
93 | - public function activate() { |
|
94 | - $this->activated = true; |
|
95 | - } |
|
90 | + /** |
|
91 | + * @inheritdoc |
|
92 | + */ |
|
93 | + public function activate() { |
|
94 | + $this->activated = true; |
|
95 | + } |
|
96 | 96 | } |
@@ -24,15 +24,15 @@ |
||
24 | 24 | namespace OC\Hooks; |
25 | 25 | |
26 | 26 | abstract class LegacyEmitter extends BasicEmitter { |
27 | - /** |
|
28 | - * @param string $scope |
|
29 | - * @param string $method |
|
30 | - * @param array $arguments |
|
31 | - * |
|
32 | - * @suppress PhanAccessMethodProtected |
|
33 | - */ |
|
34 | - protected function emit($scope, $method, array $arguments = array()) { |
|
35 | - \OC_Hook::emit($scope, $method, $arguments); |
|
36 | - parent::emit($scope, $method, $arguments); |
|
37 | - } |
|
27 | + /** |
|
28 | + * @param string $scope |
|
29 | + * @param string $method |
|
30 | + * @param array $arguments |
|
31 | + * |
|
32 | + * @suppress PhanAccessMethodProtected |
|
33 | + */ |
|
34 | + protected function emit($scope, $method, array $arguments = array()) { |
|
35 | + \OC_Hook::emit($scope, $method, $arguments); |
|
36 | + parent::emit($scope, $method, $arguments); |
|
37 | + } |
|
38 | 38 | } |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | $appName = $input->getArgument('app'); |
61 | 61 | $version = $input->getArgument('version'); |
62 | 62 | |
63 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
63 | + if (!preg_match('/^\d{1,16}$/', $version)) { |
|
64 | 64 | $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
65 | 65 | return 1; |
66 | 66 | } |
67 | 67 | |
68 | - $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml'; |
|
68 | + $schemaFile = $this->appManager->getAppPath($appName).'/appinfo/database.xml'; |
|
69 | 69 | if (!file_exists($schemaFile)) { |
70 | - $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>'); |
|
70 | + $output->writeln('<error>App '.$appName.' does not have a database.xml file</error>'); |
|
71 | 71 | return 2; |
72 | 72 | } |
73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
81 | 81 | |
82 | 82 | $date = date('YmdHis'); |
83 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody); |
|
83 | + $path = $this->generateMigration($ms, 'Version'.$version.'Date'.$date, $schemaBody); |
|
84 | 84 | |
85 | 85 | $output->writeln("New migration class has been generated to <info>$path</info>"); |
86 | 86 | return 0; |
@@ -36,170 +36,170 @@ |
||
36 | 36 | |
37 | 37 | class GenerateFromSchemaFileCommand extends GenerateCommand { |
38 | 38 | |
39 | - /** @var IConfig */ |
|
40 | - protected $config; |
|
39 | + /** @var IConfig */ |
|
40 | + protected $config; |
|
41 | 41 | |
42 | - public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) { |
|
43 | - parent::__construct($connection, $appManager); |
|
44 | - $this->config = $config; |
|
45 | - } |
|
42 | + public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) { |
|
43 | + parent::__construct($connection, $appManager); |
|
44 | + $this->config = $config; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - protected function configure() { |
|
49 | - parent::configure(); |
|
48 | + protected function configure() { |
|
49 | + parent::configure(); |
|
50 | 50 | |
51 | - $this->setName('migrations:generate-from-schema'); |
|
52 | - } |
|
51 | + $this->setName('migrations:generate-from-schema'); |
|
52 | + } |
|
53 | 53 | |
54 | - public function execute(InputInterface $input, OutputInterface $output) { |
|
55 | - $appName = $input->getArgument('app'); |
|
56 | - $version = $input->getArgument('version'); |
|
54 | + public function execute(InputInterface $input, OutputInterface $output) { |
|
55 | + $appName = $input->getArgument('app'); |
|
56 | + $version = $input->getArgument('version'); |
|
57 | 57 | |
58 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
59 | - $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
60 | - return 1; |
|
61 | - } |
|
58 | + if (!preg_match('/^\d{1,16}$/',$version)) { |
|
59 | + $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
60 | + return 1; |
|
61 | + } |
|
62 | 62 | |
63 | - $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml'; |
|
64 | - if (!file_exists($schemaFile)) { |
|
65 | - $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>'); |
|
66 | - return 2; |
|
67 | - } |
|
63 | + $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml'; |
|
64 | + if (!file_exists($schemaFile)) { |
|
65 | + $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>'); |
|
66 | + return 2; |
|
67 | + } |
|
68 | 68 | |
69 | - $reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform()); |
|
70 | - $schema = new Schema(); |
|
71 | - $reader->loadSchemaFromFile($schemaFile, $schema); |
|
69 | + $reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform()); |
|
70 | + $schema = new Schema(); |
|
71 | + $reader->loadSchemaFromFile($schemaFile, $schema); |
|
72 | 72 | |
73 | - $schemaBody = $this->schemaToMigration($schema); |
|
73 | + $schemaBody = $this->schemaToMigration($schema); |
|
74 | 74 | |
75 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
75 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
76 | 76 | |
77 | - $date = date('YmdHis'); |
|
78 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody); |
|
77 | + $date = date('YmdHis'); |
|
78 | + $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody); |
|
79 | 79 | |
80 | - $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
81 | - return 0; |
|
82 | - } |
|
80 | + $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
81 | + return 0; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @param Schema $schema |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - protected function schemaToMigration(Schema $schema) { |
|
89 | - $content = <<<'EOT' |
|
84 | + /** |
|
85 | + * @param Schema $schema |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + protected function schemaToMigration(Schema $schema) { |
|
89 | + $content = <<<'EOT' |
|
90 | 90 | /** @var ISchemaWrapper $schema */ |
91 | 91 | $schema = $schemaClosure(); |
92 | 92 | |
93 | 93 | EOT; |
94 | 94 | |
95 | - foreach ($schema->getTables() as $table) { |
|
96 | - $content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT' |
|
95 | + foreach ($schema->getTables() as $table) { |
|
96 | + $content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT' |
|
97 | 97 | |
98 | 98 | if (!$schema->hasTable('{{table-name}}')) { |
99 | 99 | $table = $schema->createTable('{{table-name}}'); |
100 | 100 | |
101 | 101 | EOT |
102 | - ); |
|
102 | + ); |
|
103 | 103 | |
104 | - foreach ($table->getColumns() as $column) { |
|
105 | - $content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT' |
|
104 | + foreach ($table->getColumns() as $column) { |
|
105 | + $content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT' |
|
106 | 106 | $table->addColumn('{{name}}', '{{type}}', [ |
107 | 107 | |
108 | 108 | EOT |
109 | - ); |
|
110 | - if ($column->getAutoincrement()) { |
|
111 | - $content .= <<<'EOT' |
|
109 | + ); |
|
110 | + if ($column->getAutoincrement()) { |
|
111 | + $content .= <<<'EOT' |
|
112 | 112 | 'autoincrement' => true, |
113 | 113 | |
114 | 114 | EOT; |
115 | - } |
|
116 | - $content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT' |
|
115 | + } |
|
116 | + $content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT' |
|
117 | 117 | 'notnull' => {{notnull}}, |
118 | 118 | |
119 | 119 | EOT |
120 | - ); |
|
121 | - if ($column->getLength() !== null) { |
|
122 | - $content .= str_replace('{{length}}', $column->getLength(), <<<'EOT' |
|
120 | + ); |
|
121 | + if ($column->getLength() !== null) { |
|
122 | + $content .= str_replace('{{length}}', $column->getLength(), <<<'EOT' |
|
123 | 123 | 'length' => {{length}}, |
124 | 124 | |
125 | 125 | EOT |
126 | - ); |
|
127 | - } |
|
128 | - $default = $column->getDefault(); |
|
129 | - if ($default !== null) { |
|
130 | - if (is_string($default)) { |
|
131 | - $default = "'$default'"; |
|
132 | - } else if (is_bool($default)) { |
|
133 | - $default = ($default === true) ? 'true' : 'false'; |
|
134 | - } |
|
135 | - $content .= str_replace('{{default}}', $default, <<<'EOT' |
|
126 | + ); |
|
127 | + } |
|
128 | + $default = $column->getDefault(); |
|
129 | + if ($default !== null) { |
|
130 | + if (is_string($default)) { |
|
131 | + $default = "'$default'"; |
|
132 | + } else if (is_bool($default)) { |
|
133 | + $default = ($default === true) ? 'true' : 'false'; |
|
134 | + } |
|
135 | + $content .= str_replace('{{default}}', $default, <<<'EOT' |
|
136 | 136 | 'default' => {{default}}, |
137 | 137 | |
138 | 138 | EOT |
139 | - ); |
|
140 | - } |
|
141 | - if ($column->getUnsigned()) { |
|
142 | - $content .= <<<'EOT' |
|
139 | + ); |
|
140 | + } |
|
141 | + if ($column->getUnsigned()) { |
|
142 | + $content .= <<<'EOT' |
|
143 | 143 | 'unsigned' => true, |
144 | 144 | |
145 | 145 | EOT; |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - $content .= <<<'EOT' |
|
148 | + $content .= <<<'EOT' |
|
149 | 149 | ]); |
150 | 150 | |
151 | 151 | EOT; |
152 | - } |
|
152 | + } |
|
153 | 153 | |
154 | - $content .= <<<'EOT' |
|
154 | + $content .= <<<'EOT' |
|
155 | 155 | |
156 | 156 | EOT; |
157 | 157 | |
158 | - $primaryKey = $table->getPrimaryKey(); |
|
159 | - if ($primaryKey !== null) { |
|
160 | - $content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT' |
|
158 | + $primaryKey = $table->getPrimaryKey(); |
|
159 | + if ($primaryKey !== null) { |
|
160 | + $content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT' |
|
161 | 161 | $table->setPrimaryKey(['{{columns}}']); |
162 | 162 | |
163 | 163 | EOT |
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - foreach ($table->getIndexes() as $index) { |
|
168 | - if ($index->isPrimary()) { |
|
169 | - continue; |
|
170 | - } |
|
171 | - |
|
172 | - if ($index->isUnique()) { |
|
173 | - $content .= str_replace( |
|
174 | - ['{{columns}}', '{{name}}'], |
|
175 | - [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
176 | - <<<'EOT' |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + foreach ($table->getIndexes() as $index) { |
|
168 | + if ($index->isPrimary()) { |
|
169 | + continue; |
|
170 | + } |
|
171 | + |
|
172 | + if ($index->isUnique()) { |
|
173 | + $content .= str_replace( |
|
174 | + ['{{columns}}', '{{name}}'], |
|
175 | + [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
176 | + <<<'EOT' |
|
177 | 177 | $table->addUniqueIndex(['{{columns}}'], '{{name}}'); |
178 | 178 | |
179 | 179 | EOT |
180 | - ); |
|
181 | - } else { |
|
182 | - $content .= str_replace( |
|
183 | - ['{{columns}}', '{{name}}'], |
|
184 | - [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
185 | - <<<'EOT' |
|
180 | + ); |
|
181 | + } else { |
|
182 | + $content .= str_replace( |
|
183 | + ['{{columns}}', '{{name}}'], |
|
184 | + [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
185 | + <<<'EOT' |
|
186 | 186 | $table->addIndex(['{{columns}}'], '{{name}}'); |
187 | 187 | |
188 | 188 | EOT |
189 | - ); |
|
190 | - } |
|
191 | - } |
|
189 | + ); |
|
190 | + } |
|
191 | + } |
|
192 | 192 | |
193 | - $content .= <<<'EOT' |
|
193 | + $content .= <<<'EOT' |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | EOT; |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - $content .= <<<'EOT' |
|
199 | + $content .= <<<'EOT' |
|
200 | 200 | return $schema; |
201 | 201 | EOT; |
202 | 202 | |
203 | - return $content; |
|
204 | - } |
|
203 | + return $content; |
|
204 | + } |
|
205 | 205 | } |