@@ -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 | } |
@@ -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 | } |
@@ -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 | } |