@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'edition' => '', |
96 | 96 | ); |
97 | 97 | |
98 | - if($this->userSession->isLoggedIn()) { |
|
98 | + if ($this->userSession->isLoggedIn()) { |
|
99 | 99 | $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
100 | 100 | } else { |
101 | 101 | $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function getIdentityProof($cloudId) { |
139 | 139 | $userObject = $this->userManager->get($cloudId); |
140 | 140 | |
141 | - if($userObject !== null) { |
|
141 | + if ($userObject !== null) { |
|
142 | 142 | $key = $this->keyManager->getKey($userObject); |
143 | 143 | $data = [ |
144 | 144 | 'public' => $key->getPublic(), |
@@ -30,122 +30,122 @@ |
||
30 | 30 | |
31 | 31 | class OCSController extends \OCP\AppFramework\OCSController { |
32 | 32 | |
33 | - /** @var CapabilitiesManager */ |
|
34 | - private $capabilitiesManager; |
|
35 | - /** @var IUserSession */ |
|
36 | - private $userSession; |
|
37 | - /** @var IUserManager */ |
|
38 | - private $userManager; |
|
39 | - /** @var Manager */ |
|
40 | - private $keyManager; |
|
33 | + /** @var CapabilitiesManager */ |
|
34 | + private $capabilitiesManager; |
|
35 | + /** @var IUserSession */ |
|
36 | + private $userSession; |
|
37 | + /** @var IUserManager */ |
|
38 | + private $userManager; |
|
39 | + /** @var Manager */ |
|
40 | + private $keyManager; |
|
41 | 41 | |
42 | - /** |
|
43 | - * OCSController constructor. |
|
44 | - * |
|
45 | - * @param string $appName |
|
46 | - * @param IRequest $request |
|
47 | - * @param CapabilitiesManager $capabilitiesManager |
|
48 | - * @param IUserSession $userSession |
|
49 | - * @param IUserManager $userManager |
|
50 | - * @param Manager $keyManager |
|
51 | - */ |
|
52 | - public function __construct($appName, |
|
53 | - IRequest $request, |
|
54 | - CapabilitiesManager $capabilitiesManager, |
|
55 | - IUserSession $userSession, |
|
56 | - IUserManager $userManager, |
|
57 | - Manager $keyManager) { |
|
58 | - parent::__construct($appName, $request); |
|
59 | - $this->capabilitiesManager = $capabilitiesManager; |
|
60 | - $this->userSession = $userSession; |
|
61 | - $this->userManager = $userManager; |
|
62 | - $this->keyManager = $keyManager; |
|
63 | - } |
|
42 | + /** |
|
43 | + * OCSController constructor. |
|
44 | + * |
|
45 | + * @param string $appName |
|
46 | + * @param IRequest $request |
|
47 | + * @param CapabilitiesManager $capabilitiesManager |
|
48 | + * @param IUserSession $userSession |
|
49 | + * @param IUserManager $userManager |
|
50 | + * @param Manager $keyManager |
|
51 | + */ |
|
52 | + public function __construct($appName, |
|
53 | + IRequest $request, |
|
54 | + CapabilitiesManager $capabilitiesManager, |
|
55 | + IUserSession $userSession, |
|
56 | + IUserManager $userManager, |
|
57 | + Manager $keyManager) { |
|
58 | + parent::__construct($appName, $request); |
|
59 | + $this->capabilitiesManager = $capabilitiesManager; |
|
60 | + $this->userSession = $userSession; |
|
61 | + $this->userManager = $userManager; |
|
62 | + $this->keyManager = $keyManager; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @PublicPage |
|
67 | - * |
|
68 | - * @return DataResponse |
|
69 | - */ |
|
70 | - public function getConfig() { |
|
71 | - $data = [ |
|
72 | - 'version' => '1.7', |
|
73 | - 'website' => 'Nextcloud', |
|
74 | - 'host' => $this->request->getServerHost(), |
|
75 | - 'contact' => '', |
|
76 | - 'ssl' => 'false', |
|
77 | - ]; |
|
65 | + /** |
|
66 | + * @PublicPage |
|
67 | + * |
|
68 | + * @return DataResponse |
|
69 | + */ |
|
70 | + public function getConfig() { |
|
71 | + $data = [ |
|
72 | + 'version' => '1.7', |
|
73 | + 'website' => 'Nextcloud', |
|
74 | + 'host' => $this->request->getServerHost(), |
|
75 | + 'contact' => '', |
|
76 | + 'ssl' => 'false', |
|
77 | + ]; |
|
78 | 78 | |
79 | - return new DataResponse($data); |
|
80 | - } |
|
79 | + return new DataResponse($data); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @PublicPage |
|
84 | - * |
|
85 | - * @return DataResponse |
|
86 | - */ |
|
87 | - public function getCapabilities() { |
|
88 | - $result = []; |
|
89 | - list($major, $minor, $micro) = \OCP\Util::getVersion(); |
|
90 | - $result['version'] = array( |
|
91 | - 'major' => $major, |
|
92 | - 'minor' => $minor, |
|
93 | - 'micro' => $micro, |
|
94 | - 'string' => \OC_Util::getVersionString(), |
|
95 | - 'edition' => '', |
|
96 | - ); |
|
82 | + /** |
|
83 | + * @PublicPage |
|
84 | + * |
|
85 | + * @return DataResponse |
|
86 | + */ |
|
87 | + public function getCapabilities() { |
|
88 | + $result = []; |
|
89 | + list($major, $minor, $micro) = \OCP\Util::getVersion(); |
|
90 | + $result['version'] = array( |
|
91 | + 'major' => $major, |
|
92 | + 'minor' => $minor, |
|
93 | + 'micro' => $micro, |
|
94 | + 'string' => \OC_Util::getVersionString(), |
|
95 | + 'edition' => '', |
|
96 | + ); |
|
97 | 97 | |
98 | - if($this->userSession->isLoggedIn()) { |
|
99 | - $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
|
100 | - } else { |
|
101 | - $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
|
102 | - } |
|
98 | + if($this->userSession->isLoggedIn()) { |
|
99 | + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
|
100 | + } else { |
|
101 | + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
|
102 | + } |
|
103 | 103 | |
104 | - return new DataResponse($result); |
|
105 | - } |
|
104 | + return new DataResponse($result); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @PublicPage |
|
109 | - * @BruteForceProtection(action=login) |
|
110 | - * |
|
111 | - * @param string $login |
|
112 | - * @param string $password |
|
113 | - * @return DataResponse |
|
114 | - */ |
|
115 | - public function personCheck($login = '', $password = '') { |
|
116 | - if ($login !== '' && $password !== '') { |
|
117 | - if ($this->userManager->checkPassword($login, $password)) { |
|
118 | - return new DataResponse([ |
|
119 | - 'person' => [ |
|
120 | - 'personid' => $login |
|
121 | - ] |
|
122 | - ]); |
|
123 | - } |
|
107 | + /** |
|
108 | + * @PublicPage |
|
109 | + * @BruteForceProtection(action=login) |
|
110 | + * |
|
111 | + * @param string $login |
|
112 | + * @param string $password |
|
113 | + * @return DataResponse |
|
114 | + */ |
|
115 | + public function personCheck($login = '', $password = '') { |
|
116 | + if ($login !== '' && $password !== '') { |
|
117 | + if ($this->userManager->checkPassword($login, $password)) { |
|
118 | + return new DataResponse([ |
|
119 | + 'person' => [ |
|
120 | + 'personid' => $login |
|
121 | + ] |
|
122 | + ]); |
|
123 | + } |
|
124 | 124 | |
125 | - $response = new DataResponse([], 102); |
|
126 | - $response->throttle(); |
|
127 | - return $response; |
|
128 | - } |
|
129 | - return new DataResponse([], 101); |
|
130 | - } |
|
125 | + $response = new DataResponse([], 102); |
|
126 | + $response->throttle(); |
|
127 | + return $response; |
|
128 | + } |
|
129 | + return new DataResponse([], 101); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @PublicPage |
|
134 | - * |
|
135 | - * @param string $cloudId |
|
136 | - * @return DataResponse |
|
137 | - */ |
|
138 | - public function getIdentityProof($cloudId) { |
|
139 | - $userObject = $this->userManager->get($cloudId); |
|
132 | + /** |
|
133 | + * @PublicPage |
|
134 | + * |
|
135 | + * @param string $cloudId |
|
136 | + * @return DataResponse |
|
137 | + */ |
|
138 | + public function getIdentityProof($cloudId) { |
|
139 | + $userObject = $this->userManager->get($cloudId); |
|
140 | 140 | |
141 | - if($userObject !== null) { |
|
142 | - $key = $this->keyManager->getKey($userObject); |
|
143 | - $data = [ |
|
144 | - 'public' => $key->getPublic(), |
|
145 | - ]; |
|
146 | - return new DataResponse($data); |
|
147 | - } |
|
141 | + if($userObject !== null) { |
|
142 | + $key = $this->keyManager->getKey($userObject); |
|
143 | + $data = [ |
|
144 | + 'public' => $key->getPublic(), |
|
145 | + ]; |
|
146 | + return new DataResponse($data); |
|
147 | + } |
|
148 | 148 | |
149 | - return new DataResponse(['User not found'], 404); |
|
150 | - } |
|
149 | + return new DataResponse(['User not found'], 404); |
|
150 | + } |
|
151 | 151 | } |
@@ -38,71 +38,71 @@ |
||
38 | 38 | */ |
39 | 39 | class GroupManagement extends Action { |
40 | 40 | |
41 | - /** |
|
42 | - * log add user to group event |
|
43 | - * |
|
44 | - * @param IGroup $group |
|
45 | - * @param IUser $user |
|
46 | - */ |
|
47 | - public function addUser(IGroup $group, IUser $user) { |
|
48 | - $this->log('User "%s" added to group "%s"', |
|
49 | - [ |
|
50 | - 'group' => $group->getGID(), |
|
51 | - 'user' => $user->getUID() |
|
52 | - ], |
|
53 | - [ |
|
54 | - 'user', 'group' |
|
55 | - ] |
|
56 | - ); |
|
57 | - } |
|
41 | + /** |
|
42 | + * log add user to group event |
|
43 | + * |
|
44 | + * @param IGroup $group |
|
45 | + * @param IUser $user |
|
46 | + */ |
|
47 | + public function addUser(IGroup $group, IUser $user) { |
|
48 | + $this->log('User "%s" added to group "%s"', |
|
49 | + [ |
|
50 | + 'group' => $group->getGID(), |
|
51 | + 'user' => $user->getUID() |
|
52 | + ], |
|
53 | + [ |
|
54 | + 'user', 'group' |
|
55 | + ] |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * log remove user from group event |
|
61 | - * |
|
62 | - * @param IGroup $group |
|
63 | - * @param IUser $user |
|
64 | - */ |
|
65 | - public function removeUser(IGroup $group, IUser $user) { |
|
66 | - $this->log('User "%s" removed from group "%s"', |
|
67 | - [ |
|
68 | - 'group' => $group->getGID(), |
|
69 | - 'user' => $user->getUID() |
|
70 | - ], |
|
71 | - [ |
|
72 | - 'user', 'group' |
|
73 | - ] |
|
74 | - ); |
|
75 | - } |
|
59 | + /** |
|
60 | + * log remove user from group event |
|
61 | + * |
|
62 | + * @param IGroup $group |
|
63 | + * @param IUser $user |
|
64 | + */ |
|
65 | + public function removeUser(IGroup $group, IUser $user) { |
|
66 | + $this->log('User "%s" removed from group "%s"', |
|
67 | + [ |
|
68 | + 'group' => $group->getGID(), |
|
69 | + 'user' => $user->getUID() |
|
70 | + ], |
|
71 | + [ |
|
72 | + 'user', 'group' |
|
73 | + ] |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * log create group to group event |
|
79 | - * |
|
80 | - * @param IGroup $group |
|
81 | - */ |
|
82 | - public function createGroup(IGroup $group) { |
|
83 | - $this->log('Group created: "%s"', |
|
84 | - [ |
|
85 | - 'group' => $group->getGID() |
|
86 | - ], |
|
87 | - [ |
|
88 | - 'group' |
|
89 | - ] |
|
90 | - ); |
|
91 | - } |
|
77 | + /** |
|
78 | + * log create group to group event |
|
79 | + * |
|
80 | + * @param IGroup $group |
|
81 | + */ |
|
82 | + public function createGroup(IGroup $group) { |
|
83 | + $this->log('Group created: "%s"', |
|
84 | + [ |
|
85 | + 'group' => $group->getGID() |
|
86 | + ], |
|
87 | + [ |
|
88 | + 'group' |
|
89 | + ] |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * log delete group to group event |
|
95 | - * |
|
96 | - * @param IGroup $group |
|
97 | - */ |
|
98 | - public function deleteGroup(IGroup $group) { |
|
99 | - $this->log('Group deleted: "%s"', |
|
100 | - [ |
|
101 | - 'group' => $group->getGID() |
|
102 | - ], |
|
103 | - [ |
|
104 | - 'group' |
|
105 | - ] |
|
106 | - ); |
|
107 | - } |
|
93 | + /** |
|
94 | + * log delete group to group event |
|
95 | + * |
|
96 | + * @param IGroup $group |
|
97 | + */ |
|
98 | + public function deleteGroup(IGroup $group) { |
|
99 | + $this->log('Group deleted: "%s"', |
|
100 | + [ |
|
101 | + 'group' => $group->getGID() |
|
102 | + ], |
|
103 | + [ |
|
104 | + 'group' |
|
105 | + ] |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | } |
@@ -32,163 +32,163 @@ |
||
32 | 32 | * @package OCA\AdminAudit\Actions |
33 | 33 | */ |
34 | 34 | class Sharing extends Action { |
35 | - /** |
|
36 | - * Logs sharing of data |
|
37 | - * |
|
38 | - * @param array $params |
|
39 | - */ |
|
40 | - public function shared(array $params) { |
|
41 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
42 | - $this->log( |
|
43 | - 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
|
44 | - $params, |
|
45 | - [ |
|
46 | - 'itemType', |
|
47 | - 'itemTarget', |
|
48 | - 'itemSource', |
|
49 | - 'permissions', |
|
50 | - 'id', |
|
51 | - ] |
|
52 | - ); |
|
53 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
54 | - $this->log( |
|
55 | - 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
|
56 | - $params, |
|
57 | - [ |
|
58 | - 'itemType', |
|
59 | - 'itemTarget', |
|
60 | - 'itemSource', |
|
61 | - 'shareWith', |
|
62 | - 'permissions', |
|
63 | - 'id', |
|
64 | - ] |
|
65 | - ); |
|
66 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
67 | - $this->log( |
|
68 | - 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
|
69 | - $params, |
|
70 | - [ |
|
71 | - 'itemType', |
|
72 | - 'itemTarget', |
|
73 | - 'itemSource', |
|
74 | - 'shareWith', |
|
75 | - 'permissions', |
|
76 | - 'id', |
|
77 | - ] |
|
78 | - ); |
|
79 | - } |
|
80 | - } |
|
35 | + /** |
|
36 | + * Logs sharing of data |
|
37 | + * |
|
38 | + * @param array $params |
|
39 | + */ |
|
40 | + public function shared(array $params) { |
|
41 | + if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
42 | + $this->log( |
|
43 | + 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
|
44 | + $params, |
|
45 | + [ |
|
46 | + 'itemType', |
|
47 | + 'itemTarget', |
|
48 | + 'itemSource', |
|
49 | + 'permissions', |
|
50 | + 'id', |
|
51 | + ] |
|
52 | + ); |
|
53 | + } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
54 | + $this->log( |
|
55 | + 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
|
56 | + $params, |
|
57 | + [ |
|
58 | + 'itemType', |
|
59 | + 'itemTarget', |
|
60 | + 'itemSource', |
|
61 | + 'shareWith', |
|
62 | + 'permissions', |
|
63 | + 'id', |
|
64 | + ] |
|
65 | + ); |
|
66 | + } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
67 | + $this->log( |
|
68 | + 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
|
69 | + $params, |
|
70 | + [ |
|
71 | + 'itemType', |
|
72 | + 'itemTarget', |
|
73 | + 'itemSource', |
|
74 | + 'shareWith', |
|
75 | + 'permissions', |
|
76 | + 'id', |
|
77 | + ] |
|
78 | + ); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Logs unsharing of data |
|
84 | - * |
|
85 | - * @param array $params |
|
86 | - */ |
|
87 | - public function unshare(array $params) { |
|
88 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
89 | - $this->log( |
|
90 | - 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
|
91 | - $params, |
|
92 | - [ |
|
93 | - 'itemType', |
|
94 | - 'fileTarget', |
|
95 | - 'itemSource', |
|
96 | - 'id', |
|
97 | - ] |
|
98 | - ); |
|
99 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
100 | - $this->log( |
|
101 | - 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
|
102 | - $params, |
|
103 | - [ |
|
104 | - 'itemType', |
|
105 | - 'fileTarget', |
|
106 | - 'itemSource', |
|
107 | - 'shareWith', |
|
108 | - 'id', |
|
109 | - ] |
|
110 | - ); |
|
111 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
112 | - $this->log( |
|
113 | - 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
|
114 | - $params, |
|
115 | - [ |
|
116 | - 'itemType', |
|
117 | - 'fileTarget', |
|
118 | - 'itemSource', |
|
119 | - 'shareWith', |
|
120 | - 'id', |
|
121 | - ] |
|
122 | - ); |
|
123 | - } |
|
124 | - } |
|
82 | + /** |
|
83 | + * Logs unsharing of data |
|
84 | + * |
|
85 | + * @param array $params |
|
86 | + */ |
|
87 | + public function unshare(array $params) { |
|
88 | + if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
89 | + $this->log( |
|
90 | + 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
|
91 | + $params, |
|
92 | + [ |
|
93 | + 'itemType', |
|
94 | + 'fileTarget', |
|
95 | + 'itemSource', |
|
96 | + 'id', |
|
97 | + ] |
|
98 | + ); |
|
99 | + } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
100 | + $this->log( |
|
101 | + 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
|
102 | + $params, |
|
103 | + [ |
|
104 | + 'itemType', |
|
105 | + 'fileTarget', |
|
106 | + 'itemSource', |
|
107 | + 'shareWith', |
|
108 | + 'id', |
|
109 | + ] |
|
110 | + ); |
|
111 | + } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
112 | + $this->log( |
|
113 | + 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
|
114 | + $params, |
|
115 | + [ |
|
116 | + 'itemType', |
|
117 | + 'fileTarget', |
|
118 | + 'itemSource', |
|
119 | + 'shareWith', |
|
120 | + 'id', |
|
121 | + ] |
|
122 | + ); |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Logs the updating of permission changes for shares |
|
128 | - * |
|
129 | - * @param array $params |
|
130 | - */ |
|
131 | - public function updatePermissions(array $params) { |
|
132 | - $this->log( |
|
133 | - 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"', |
|
134 | - $params, |
|
135 | - [ |
|
136 | - 'itemType', |
|
137 | - 'path', |
|
138 | - 'itemSource', |
|
139 | - 'permissions', |
|
140 | - ] |
|
141 | - ); |
|
142 | - } |
|
126 | + /** |
|
127 | + * Logs the updating of permission changes for shares |
|
128 | + * |
|
129 | + * @param array $params |
|
130 | + */ |
|
131 | + public function updatePermissions(array $params) { |
|
132 | + $this->log( |
|
133 | + 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"', |
|
134 | + $params, |
|
135 | + [ |
|
136 | + 'itemType', |
|
137 | + 'path', |
|
138 | + 'itemSource', |
|
139 | + 'permissions', |
|
140 | + ] |
|
141 | + ); |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * Logs the password changes for a share |
|
146 | - * |
|
147 | - * @param array $params |
|
148 | - */ |
|
149 | - public function updatePassword(array $params) { |
|
150 | - $this->log( |
|
151 | - 'The password of the publicly shared %s "%s" with ID "%s" has been changed', |
|
152 | - $params, |
|
153 | - [ |
|
154 | - 'itemType', |
|
155 | - 'token', |
|
156 | - 'itemSource', |
|
157 | - ] |
|
158 | - ); |
|
159 | - } |
|
144 | + /** |
|
145 | + * Logs the password changes for a share |
|
146 | + * |
|
147 | + * @param array $params |
|
148 | + */ |
|
149 | + public function updatePassword(array $params) { |
|
150 | + $this->log( |
|
151 | + 'The password of the publicly shared %s "%s" with ID "%s" has been changed', |
|
152 | + $params, |
|
153 | + [ |
|
154 | + 'itemType', |
|
155 | + 'token', |
|
156 | + 'itemSource', |
|
157 | + ] |
|
158 | + ); |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * Logs the expiration date changes for a share |
|
163 | - * |
|
164 | - * @param array $params |
|
165 | - */ |
|
166 | - public function updateExpirationDate(array $params) { |
|
167 | - $this->log( |
|
168 | - 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"', |
|
169 | - $params, |
|
170 | - [ |
|
171 | - 'itemType', |
|
172 | - 'itemSource', |
|
173 | - 'date', |
|
174 | - ] |
|
175 | - ); |
|
176 | - } |
|
161 | + /** |
|
162 | + * Logs the expiration date changes for a share |
|
163 | + * |
|
164 | + * @param array $params |
|
165 | + */ |
|
166 | + public function updateExpirationDate(array $params) { |
|
167 | + $this->log( |
|
168 | + 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"', |
|
169 | + $params, |
|
170 | + [ |
|
171 | + 'itemType', |
|
172 | + 'itemSource', |
|
173 | + 'date', |
|
174 | + ] |
|
175 | + ); |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Logs access of shared files |
|
180 | - * |
|
181 | - * @param array $params |
|
182 | - */ |
|
183 | - public function shareAccessed(array $params) { |
|
184 | - $this->log( |
|
185 | - 'The shared %s with the token "%s" by "%s" has been accessed.', |
|
186 | - $params, |
|
187 | - [ |
|
188 | - 'itemType', |
|
189 | - 'token', |
|
190 | - 'uidOwner', |
|
191 | - ] |
|
192 | - ); |
|
193 | - } |
|
178 | + /** |
|
179 | + * Logs access of shared files |
|
180 | + * |
|
181 | + * @param array $params |
|
182 | + */ |
|
183 | + public function shareAccessed(array $params) { |
|
184 | + $this->log( |
|
185 | + 'The shared %s with the token "%s" by "%s" has been accessed.', |
|
186 | + $params, |
|
187 | + [ |
|
188 | + 'itemType', |
|
189 | + 'token', |
|
190 | + 'uidOwner', |
|
191 | + ] |
|
192 | + ); |
|
193 | + } |
|
194 | 194 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param array $params |
36 | 36 | */ |
37 | 37 | public function shared(array $params) { |
38 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
38 | + if ($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
39 | 39 | $this->log( |
40 | 40 | 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
41 | 41 | $params, |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'id', |
48 | 48 | ] |
49 | 49 | ); |
50 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
50 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
51 | 51 | $this->log( |
52 | 52 | 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
53 | 53 | $params, |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'id', |
61 | 61 | ] |
62 | 62 | ); |
63 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
63 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
64 | 64 | $this->log( |
65 | 65 | 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
66 | 66 | $params, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param array $params |
83 | 83 | */ |
84 | 84 | public function unshare(array $params) { |
85 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
85 | + if ($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
86 | 86 | $this->log( |
87 | 87 | 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
88 | 88 | $params, |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | 'id', |
94 | 94 | ] |
95 | 95 | ); |
96 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
96 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
97 | 97 | $this->log( |
98 | 98 | 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
99 | 99 | $params, |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'id', |
106 | 106 | ] |
107 | 107 | ); |
108 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
108 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
109 | 109 | $this->log( |
110 | 110 | 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
111 | 111 | $params, |
@@ -29,137 +29,137 @@ |
||
29 | 29 | * @package OCA\AdminAudit\Actions |
30 | 30 | */ |
31 | 31 | class Files extends Action { |
32 | - /** |
|
33 | - * Logs file read actions |
|
34 | - * |
|
35 | - * @param array $params |
|
36 | - */ |
|
37 | - public function read(array $params) { |
|
38 | - $this->log( |
|
39 | - 'File accessed: "%s"', |
|
40 | - $params, |
|
41 | - [ |
|
42 | - 'path', |
|
43 | - ] |
|
44 | - ); |
|
45 | - } |
|
32 | + /** |
|
33 | + * Logs file read actions |
|
34 | + * |
|
35 | + * @param array $params |
|
36 | + */ |
|
37 | + public function read(array $params) { |
|
38 | + $this->log( |
|
39 | + 'File accessed: "%s"', |
|
40 | + $params, |
|
41 | + [ |
|
42 | + 'path', |
|
43 | + ] |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Logs rename actions of files |
|
49 | - * |
|
50 | - * @param array $params |
|
51 | - */ |
|
52 | - public function rename(array $params) { |
|
53 | - $this->log( |
|
54 | - 'File renamed: "%s" to "%s"', |
|
55 | - $params, |
|
56 | - [ |
|
57 | - 'oldpath', |
|
58 | - 'newpath', |
|
59 | - ] |
|
60 | - ); |
|
61 | - } |
|
47 | + /** |
|
48 | + * Logs rename actions of files |
|
49 | + * |
|
50 | + * @param array $params |
|
51 | + */ |
|
52 | + public function rename(array $params) { |
|
53 | + $this->log( |
|
54 | + 'File renamed: "%s" to "%s"', |
|
55 | + $params, |
|
56 | + [ |
|
57 | + 'oldpath', |
|
58 | + 'newpath', |
|
59 | + ] |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Logs creation of files |
|
65 | - * |
|
66 | - * @param array $params |
|
67 | - */ |
|
68 | - public function create(array $params) { |
|
69 | - if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) { |
|
70 | - return; |
|
71 | - } |
|
63 | + /** |
|
64 | + * Logs creation of files |
|
65 | + * |
|
66 | + * @param array $params |
|
67 | + */ |
|
68 | + public function create(array $params) { |
|
69 | + if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) { |
|
70 | + return; |
|
71 | + } |
|
72 | 72 | |
73 | - $this->log( |
|
74 | - 'File created: "%s"', |
|
75 | - $params, |
|
76 | - [ |
|
77 | - 'path', |
|
78 | - ] |
|
79 | - ); |
|
80 | - } |
|
73 | + $this->log( |
|
74 | + 'File created: "%s"', |
|
75 | + $params, |
|
76 | + [ |
|
77 | + 'path', |
|
78 | + ] |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Logs copying of files |
|
84 | - * |
|
85 | - * @param array $params |
|
86 | - */ |
|
87 | - public function copy(array $params) { |
|
88 | - $this->log( |
|
89 | - 'File copied: "%s" to "%s"', |
|
90 | - $params, |
|
91 | - [ |
|
92 | - 'oldpath', |
|
93 | - 'newpath', |
|
94 | - ] |
|
95 | - ); |
|
96 | - } |
|
82 | + /** |
|
83 | + * Logs copying of files |
|
84 | + * |
|
85 | + * @param array $params |
|
86 | + */ |
|
87 | + public function copy(array $params) { |
|
88 | + $this->log( |
|
89 | + 'File copied: "%s" to "%s"', |
|
90 | + $params, |
|
91 | + [ |
|
92 | + 'oldpath', |
|
93 | + 'newpath', |
|
94 | + ] |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Logs writing of files |
|
100 | - * |
|
101 | - * @param array $params |
|
102 | - */ |
|
103 | - public function write(array $params) { |
|
104 | - if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) { |
|
105 | - return; |
|
106 | - } |
|
98 | + /** |
|
99 | + * Logs writing of files |
|
100 | + * |
|
101 | + * @param array $params |
|
102 | + */ |
|
103 | + public function write(array $params) { |
|
104 | + if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) { |
|
105 | + return; |
|
106 | + } |
|
107 | 107 | |
108 | - $this->log( |
|
109 | - 'File written to: "%s"', |
|
110 | - $params, |
|
111 | - [ |
|
112 | - 'path', |
|
113 | - ] |
|
114 | - ); |
|
115 | - } |
|
108 | + $this->log( |
|
109 | + 'File written to: "%s"', |
|
110 | + $params, |
|
111 | + [ |
|
112 | + 'path', |
|
113 | + ] |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Logs update of files |
|
119 | - * |
|
120 | - * @param array $params |
|
121 | - */ |
|
122 | - public function update(array $params) { |
|
123 | - $this->log( |
|
124 | - 'File updated: "%s"', |
|
125 | - $params, |
|
126 | - [ |
|
127 | - 'path', |
|
128 | - ] |
|
129 | - ); |
|
130 | - } |
|
117 | + /** |
|
118 | + * Logs update of files |
|
119 | + * |
|
120 | + * @param array $params |
|
121 | + */ |
|
122 | + public function update(array $params) { |
|
123 | + $this->log( |
|
124 | + 'File updated: "%s"', |
|
125 | + $params, |
|
126 | + [ |
|
127 | + 'path', |
|
128 | + ] |
|
129 | + ); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Logs deletions of files |
|
134 | - * |
|
135 | - * @param array $params |
|
136 | - */ |
|
137 | - public function delete(array $params) { |
|
138 | - $this->log( |
|
139 | - 'File deleted: "%s"', |
|
140 | - $params, |
|
141 | - [ |
|
142 | - 'path', |
|
143 | - ] |
|
144 | - ); |
|
145 | - } |
|
132 | + /** |
|
133 | + * Logs deletions of files |
|
134 | + * |
|
135 | + * @param array $params |
|
136 | + */ |
|
137 | + public function delete(array $params) { |
|
138 | + $this->log( |
|
139 | + 'File deleted: "%s"', |
|
140 | + $params, |
|
141 | + [ |
|
142 | + 'path', |
|
143 | + ] |
|
144 | + ); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Logs preview access to a file |
|
149 | - * |
|
150 | - * @param array $params |
|
151 | - */ |
|
152 | - public function preview(array $params) { |
|
153 | - $this->log( |
|
154 | - 'Preview accessed: "%s" (width: "%s", height: "%s" crop: "%s", mode: "%s")', |
|
155 | - $params, |
|
156 | - [ |
|
157 | - 'path', |
|
158 | - 'width', |
|
159 | - 'height', |
|
160 | - 'crop', |
|
161 | - 'mode' |
|
162 | - ] |
|
163 | - ); |
|
164 | - } |
|
147 | + /** |
|
148 | + * Logs preview access to a file |
|
149 | + * |
|
150 | + * @param array $params |
|
151 | + */ |
|
152 | + public function preview(array $params) { |
|
153 | + $this->log( |
|
154 | + 'Preview accessed: "%s" (width: "%s", height: "%s" crop: "%s", mode: "%s")', |
|
155 | + $params, |
|
156 | + [ |
|
157 | + 'path', |
|
158 | + 'width', |
|
159 | + 'height', |
|
160 | + 'crop', |
|
161 | + 'mode' |
|
162 | + ] |
|
163 | + ); |
|
164 | + } |
|
165 | 165 | } |
@@ -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 | } |
@@ -126,7 +126,7 @@ |
||
126 | 126 | |
127 | 127 | /** |
128 | 128 | * @param string $data |
129 | - * @return int |
|
129 | + * @return boolean |
|
130 | 130 | */ |
131 | 131 | public function stream_write($data) { |
132 | 132 | return false; |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | |
67 | 67 | $nodes = $this->nodes; |
68 | 68 | // http://stackoverflow.com/a/10985500 |
69 | - @usort($nodes, function (IFile $a, IFile $b) { |
|
69 | + @usort($nodes, function(IFile $a, IFile $b) { |
|
70 | 70 | return strnatcmp($a->getName(), $b->getName()); |
71 | 71 | }); |
72 | 72 | $this->nodes = array_values($nodes); |
73 | 73 | if (count($this->nodes) > 0) { |
74 | 74 | $this->currentStream = $this->getStream($this->nodes[0]); |
75 | 75 | } |
76 | - $this->size = array_reduce($this->nodes, function ($size, IFile $file) { |
|
76 | + $this->size = array_reduce($this->nodes, function($size, IFile $file) { |
|
77 | 77 | return $size + $file->getSize(); |
78 | 78 | }, 0); |
79 | 79 | return true; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | if (isset($context[$name])) { |
203 | 203 | $context = $context[$name]; |
204 | 204 | } else { |
205 | - throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); |
|
205 | + throw new \BadMethodCallException('Invalid context, "'.$name.'" options not set'); |
|
206 | 206 | } |
207 | 207 | if (isset($context['nodes']) and is_array($context['nodes'])) { |
208 | 208 | $this->nodes = $context['nodes']; |
@@ -39,218 +39,218 @@ |
||
39 | 39 | */ |
40 | 40 | class AssemblyStream implements \Icewind\Streams\File { |
41 | 41 | |
42 | - /** @var resource */ |
|
43 | - private $context; |
|
42 | + /** @var resource */ |
|
43 | + private $context; |
|
44 | 44 | |
45 | - /** @var IFile[] */ |
|
46 | - private $nodes; |
|
45 | + /** @var IFile[] */ |
|
46 | + private $nodes; |
|
47 | 47 | |
48 | - /** @var int */ |
|
49 | - private $pos = 0; |
|
48 | + /** @var int */ |
|
49 | + private $pos = 0; |
|
50 | 50 | |
51 | - /** @var int */ |
|
52 | - private $size = 0; |
|
51 | + /** @var int */ |
|
52 | + private $size = 0; |
|
53 | 53 | |
54 | - /** @var resource */ |
|
55 | - private $currentStream = null; |
|
54 | + /** @var resource */ |
|
55 | + private $currentStream = null; |
|
56 | 56 | |
57 | - /** @var int */ |
|
58 | - private $currentNode = 0; |
|
57 | + /** @var int */ |
|
58 | + private $currentNode = 0; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $path |
|
62 | - * @param string $mode |
|
63 | - * @param int $options |
|
64 | - * @param string &$opened_path |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function stream_open($path, $mode, $options, &$opened_path) { |
|
68 | - $this->loadContext('assembly'); |
|
60 | + /** |
|
61 | + * @param string $path |
|
62 | + * @param string $mode |
|
63 | + * @param int $options |
|
64 | + * @param string &$opened_path |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function stream_open($path, $mode, $options, &$opened_path) { |
|
68 | + $this->loadContext('assembly'); |
|
69 | 69 | |
70 | - $nodes = $this->nodes; |
|
71 | - // http://stackoverflow.com/a/10985500 |
|
72 | - @usort($nodes, function (IFile $a, IFile $b) { |
|
73 | - return strnatcmp($a->getName(), $b->getName()); |
|
74 | - }); |
|
75 | - $this->nodes = array_values($nodes); |
|
76 | - if (count($this->nodes) > 0) { |
|
77 | - $this->currentStream = $this->getStream($this->nodes[0]); |
|
78 | - } |
|
79 | - $this->size = array_reduce($this->nodes, function ($size, IFile $file) { |
|
80 | - return $size + $file->getSize(); |
|
81 | - }, 0); |
|
82 | - return true; |
|
83 | - } |
|
70 | + $nodes = $this->nodes; |
|
71 | + // http://stackoverflow.com/a/10985500 |
|
72 | + @usort($nodes, function (IFile $a, IFile $b) { |
|
73 | + return strnatcmp($a->getName(), $b->getName()); |
|
74 | + }); |
|
75 | + $this->nodes = array_values($nodes); |
|
76 | + if (count($this->nodes) > 0) { |
|
77 | + $this->currentStream = $this->getStream($this->nodes[0]); |
|
78 | + } |
|
79 | + $this->size = array_reduce($this->nodes, function ($size, IFile $file) { |
|
80 | + return $size + $file->getSize(); |
|
81 | + }, 0); |
|
82 | + return true; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $offset |
|
87 | - * @param int $whence |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function stream_seek($offset, $whence = SEEK_SET) { |
|
91 | - return false; |
|
92 | - } |
|
85 | + /** |
|
86 | + * @param string $offset |
|
87 | + * @param int $whence |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function stream_seek($offset, $whence = SEEK_SET) { |
|
91 | + return false; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return int |
|
96 | - */ |
|
97 | - public function stream_tell() { |
|
98 | - return $this->pos; |
|
99 | - } |
|
94 | + /** |
|
95 | + * @return int |
|
96 | + */ |
|
97 | + public function stream_tell() { |
|
98 | + return $this->pos; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param int $count |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function stream_read($count) { |
|
106 | - if (is_null($this->currentStream)) { |
|
107 | - return ''; |
|
108 | - } |
|
101 | + /** |
|
102 | + * @param int $count |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function stream_read($count) { |
|
106 | + if (is_null($this->currentStream)) { |
|
107 | + return ''; |
|
108 | + } |
|
109 | 109 | |
110 | - do { |
|
111 | - $data = fread($this->currentStream, $count); |
|
112 | - $read = strlen($data); |
|
110 | + do { |
|
111 | + $data = fread($this->currentStream, $count); |
|
112 | + $read = strlen($data); |
|
113 | 113 | |
114 | - if (feof($this->currentStream)) { |
|
115 | - fclose($this->currentStream); |
|
116 | - $this->currentNode++; |
|
117 | - if ($this->currentNode < count($this->nodes)) { |
|
118 | - $this->currentStream = $this->getStream($this->nodes[$this->currentNode]); |
|
119 | - } else { |
|
120 | - $this->currentStream = null; |
|
121 | - } |
|
122 | - } |
|
123 | - // if no data read, try again with the next node because |
|
124 | - // returning empty data can make the caller think there is no more |
|
125 | - // data left to read |
|
126 | - } while ($read === 0 && !is_null($this->currentStream)); |
|
114 | + if (feof($this->currentStream)) { |
|
115 | + fclose($this->currentStream); |
|
116 | + $this->currentNode++; |
|
117 | + if ($this->currentNode < count($this->nodes)) { |
|
118 | + $this->currentStream = $this->getStream($this->nodes[$this->currentNode]); |
|
119 | + } else { |
|
120 | + $this->currentStream = null; |
|
121 | + } |
|
122 | + } |
|
123 | + // if no data read, try again with the next node because |
|
124 | + // returning empty data can make the caller think there is no more |
|
125 | + // data left to read |
|
126 | + } while ($read === 0 && !is_null($this->currentStream)); |
|
127 | 127 | |
128 | - // update position |
|
129 | - $this->pos += $read; |
|
130 | - return $data; |
|
131 | - } |
|
128 | + // update position |
|
129 | + $this->pos += $read; |
|
130 | + return $data; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * @param string $data |
|
135 | - * @return int |
|
136 | - */ |
|
137 | - public function stream_write($data) { |
|
138 | - return false; |
|
139 | - } |
|
133 | + /** |
|
134 | + * @param string $data |
|
135 | + * @return int |
|
136 | + */ |
|
137 | + public function stream_write($data) { |
|
138 | + return false; |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * @param int $option |
|
143 | - * @param int $arg1 |
|
144 | - * @param int $arg2 |
|
145 | - * @return bool |
|
146 | - */ |
|
147 | - public function stream_set_option($option, $arg1, $arg2) { |
|
148 | - return false; |
|
149 | - } |
|
141 | + /** |
|
142 | + * @param int $option |
|
143 | + * @param int $arg1 |
|
144 | + * @param int $arg2 |
|
145 | + * @return bool |
|
146 | + */ |
|
147 | + public function stream_set_option($option, $arg1, $arg2) { |
|
148 | + return false; |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @param int $size |
|
153 | - * @return bool |
|
154 | - */ |
|
155 | - public function stream_truncate($size) { |
|
156 | - return false; |
|
157 | - } |
|
151 | + /** |
|
152 | + * @param int $size |
|
153 | + * @return bool |
|
154 | + */ |
|
155 | + public function stream_truncate($size) { |
|
156 | + return false; |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * @return array |
|
161 | - */ |
|
162 | - public function stream_stat() { |
|
163 | - return []; |
|
164 | - } |
|
159 | + /** |
|
160 | + * @return array |
|
161 | + */ |
|
162 | + public function stream_stat() { |
|
163 | + return []; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * @param int $operation |
|
168 | - * @return bool |
|
169 | - */ |
|
170 | - public function stream_lock($operation) { |
|
171 | - return false; |
|
172 | - } |
|
166 | + /** |
|
167 | + * @param int $operation |
|
168 | + * @return bool |
|
169 | + */ |
|
170 | + public function stream_lock($operation) { |
|
171 | + return false; |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * @return bool |
|
176 | - */ |
|
177 | - public function stream_flush() { |
|
178 | - return false; |
|
179 | - } |
|
174 | + /** |
|
175 | + * @return bool |
|
176 | + */ |
|
177 | + public function stream_flush() { |
|
178 | + return false; |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * @return bool |
|
183 | - */ |
|
184 | - public function stream_eof() { |
|
185 | - return $this->pos >= $this->size; |
|
186 | - } |
|
181 | + /** |
|
182 | + * @return bool |
|
183 | + */ |
|
184 | + public function stream_eof() { |
|
185 | + return $this->pos >= $this->size; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @return bool |
|
190 | - */ |
|
191 | - public function stream_close() { |
|
192 | - return true; |
|
193 | - } |
|
188 | + /** |
|
189 | + * @return bool |
|
190 | + */ |
|
191 | + public function stream_close() { |
|
192 | + return true; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | |
196 | - /** |
|
197 | - * Load the source from the stream context and return the context options |
|
198 | - * |
|
199 | - * @param string $name |
|
200 | - * @return array |
|
201 | - * @throws \Exception |
|
202 | - */ |
|
203 | - protected function loadContext($name) { |
|
204 | - $context = stream_context_get_options($this->context); |
|
205 | - if (isset($context[$name])) { |
|
206 | - $context = $context[$name]; |
|
207 | - } else { |
|
208 | - throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); |
|
209 | - } |
|
210 | - if (isset($context['nodes']) and is_array($context['nodes'])) { |
|
211 | - $this->nodes = $context['nodes']; |
|
212 | - } else { |
|
213 | - throw new \BadMethodCallException('Invalid context, nodes not set'); |
|
214 | - } |
|
215 | - return $context; |
|
216 | - } |
|
196 | + /** |
|
197 | + * Load the source from the stream context and return the context options |
|
198 | + * |
|
199 | + * @param string $name |
|
200 | + * @return array |
|
201 | + * @throws \Exception |
|
202 | + */ |
|
203 | + protected function loadContext($name) { |
|
204 | + $context = stream_context_get_options($this->context); |
|
205 | + if (isset($context[$name])) { |
|
206 | + $context = $context[$name]; |
|
207 | + } else { |
|
208 | + throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); |
|
209 | + } |
|
210 | + if (isset($context['nodes']) and is_array($context['nodes'])) { |
|
211 | + $this->nodes = $context['nodes']; |
|
212 | + } else { |
|
213 | + throw new \BadMethodCallException('Invalid context, nodes not set'); |
|
214 | + } |
|
215 | + return $context; |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @param IFile[] $nodes |
|
220 | - * @return resource |
|
221 | - * |
|
222 | - * @throws \BadMethodCallException |
|
223 | - */ |
|
224 | - public static function wrap(array $nodes) { |
|
225 | - $context = stream_context_create([ |
|
226 | - 'assembly' => [ |
|
227 | - 'nodes' => $nodes |
|
228 | - ] |
|
229 | - ]); |
|
230 | - stream_wrapper_register('assembly', self::class); |
|
231 | - try { |
|
232 | - $wrapped = fopen('assembly://', 'r', null, $context); |
|
233 | - } catch (\BadMethodCallException $e) { |
|
234 | - stream_wrapper_unregister('assembly'); |
|
235 | - throw $e; |
|
236 | - } |
|
237 | - stream_wrapper_unregister('assembly'); |
|
238 | - return $wrapped; |
|
239 | - } |
|
218 | + /** |
|
219 | + * @param IFile[] $nodes |
|
220 | + * @return resource |
|
221 | + * |
|
222 | + * @throws \BadMethodCallException |
|
223 | + */ |
|
224 | + public static function wrap(array $nodes) { |
|
225 | + $context = stream_context_create([ |
|
226 | + 'assembly' => [ |
|
227 | + 'nodes' => $nodes |
|
228 | + ] |
|
229 | + ]); |
|
230 | + stream_wrapper_register('assembly', self::class); |
|
231 | + try { |
|
232 | + $wrapped = fopen('assembly://', 'r', null, $context); |
|
233 | + } catch (\BadMethodCallException $e) { |
|
234 | + stream_wrapper_unregister('assembly'); |
|
235 | + throw $e; |
|
236 | + } |
|
237 | + stream_wrapper_unregister('assembly'); |
|
238 | + return $wrapped; |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * @param IFile $node |
|
243 | - * @return resource |
|
244 | - */ |
|
245 | - private function getStream(IFile $node) { |
|
246 | - $data = $node->get(); |
|
247 | - if (is_resource($data)) { |
|
248 | - return $data; |
|
249 | - } else { |
|
250 | - $tmp = fopen('php://temp', 'w+'); |
|
251 | - fwrite($tmp, $data); |
|
252 | - rewind($tmp); |
|
253 | - return $tmp; |
|
254 | - } |
|
255 | - } |
|
241 | + /** |
|
242 | + * @param IFile $node |
|
243 | + * @return resource |
|
244 | + */ |
|
245 | + private function getStream(IFile $node) { |
|
246 | + $data = $node->get(); |
|
247 | + if (is_resource($data)) { |
|
248 | + return $data; |
|
249 | + } else { |
|
250 | + $tmp = fopen('php://temp', 'w+'); |
|
251 | + fwrite($tmp, $data); |
|
252 | + rewind($tmp); |
|
253 | + return $tmp; |
|
254 | + } |
|
255 | + } |
|
256 | 256 | } |
@@ -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 | } |