@@ -34,136 +34,136 @@ |
||
34 | 34 | |
35 | 35 | class ImageExportPlugin extends ServerPlugin { |
36 | 36 | |
37 | - /** @var Server */ |
|
38 | - protected $server; |
|
39 | - /** @var ILogger */ |
|
40 | - private $logger; |
|
41 | - |
|
42 | - public function __construct(ILogger $logger) { |
|
43 | - $this->logger = $logger; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Initializes the plugin and registers event handlers |
|
48 | - * |
|
49 | - * @param Server $server |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - function initialize(Server $server) { |
|
53 | - |
|
54 | - $this->server = $server; |
|
55 | - $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Intercepts GET requests on addressbook urls ending with ?photo. |
|
60 | - * |
|
61 | - * @param RequestInterface $request |
|
62 | - * @param ResponseInterface $response |
|
63 | - * @return bool|void |
|
64 | - */ |
|
65 | - function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
66 | - |
|
67 | - $queryParams = $request->getQueryParameters(); |
|
68 | - // TODO: in addition to photo we should also add logo some point in time |
|
69 | - if (!array_key_exists('photo', $queryParams)) { |
|
70 | - return true; |
|
71 | - } |
|
72 | - |
|
73 | - $path = $request->getPath(); |
|
74 | - $node = $this->server->tree->getNodeForPath($path); |
|
75 | - |
|
76 | - if (!($node instanceof Card)) { |
|
77 | - return true; |
|
78 | - } |
|
79 | - |
|
80 | - $this->server->transactionType = 'carddav-image-export'; |
|
81 | - |
|
82 | - // Checking ACL, if available. |
|
83 | - if ($aclPlugin = $this->server->getPlugin('acl')) { |
|
84 | - /** @var \Sabre\DAVACL\Plugin $aclPlugin */ |
|
85 | - $aclPlugin->checkPrivileges($path, '{DAV:}read'); |
|
86 | - } |
|
87 | - |
|
88 | - if ($result = $this->getPhoto($node)) { |
|
89 | - $response->setHeader('Content-Type', $result['Content-Type']); |
|
90 | - $response->setHeader('Content-Disposition', 'attachment'); |
|
91 | - $response->setStatus(200); |
|
92 | - |
|
93 | - $response->setBody($result['body']); |
|
94 | - |
|
95 | - // Returning false to break the event chain |
|
96 | - return false; |
|
97 | - } |
|
98 | - return true; |
|
99 | - } |
|
100 | - |
|
101 | - function getPhoto(Card $node) { |
|
102 | - // TODO: this is kind of expensive - load carddav data from database and parse it |
|
103 | - // we might want to build up a cache one day |
|
104 | - try { |
|
105 | - $vObject = $this->readCard($node->get()); |
|
106 | - if (!$vObject->PHOTO) { |
|
107 | - return false; |
|
108 | - } |
|
109 | - |
|
110 | - $photo = $vObject->PHOTO; |
|
111 | - $type = $this->getType($photo); |
|
112 | - |
|
113 | - $val = $photo->getValue(); |
|
114 | - if ($photo->getValueType() === 'URI') { |
|
115 | - $parsed = \Sabre\URI\parse($val); |
|
116 | - //only allow data:// |
|
117 | - if ($parsed['scheme'] !== 'data') { |
|
118 | - return false; |
|
119 | - } |
|
120 | - if (substr_count($parsed['path'], ';') === 1) { |
|
121 | - list($type,) = explode(';', $parsed['path']); |
|
122 | - } |
|
123 | - $val = file_get_contents($val); |
|
124 | - } |
|
125 | - |
|
126 | - $allowedContentTypes = [ |
|
127 | - 'image/png', |
|
128 | - 'image/jpeg', |
|
129 | - 'image/gif', |
|
130 | - ]; |
|
131 | - |
|
132 | - if(!in_array($type, $allowedContentTypes, true)) { |
|
133 | - $type = 'application/octet-stream'; |
|
134 | - } |
|
135 | - |
|
136 | - return [ |
|
137 | - 'Content-Type' => $type, |
|
138 | - 'body' => $val |
|
139 | - ]; |
|
140 | - } catch(\Exception $ex) { |
|
141 | - $this->logger->logException($ex); |
|
142 | - } |
|
143 | - return false; |
|
144 | - } |
|
145 | - |
|
146 | - private function readCard($cardData) { |
|
147 | - return Reader::read($cardData); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @param Binary $photo |
|
152 | - * @return Parameter |
|
153 | - */ |
|
154 | - private function getType($photo) { |
|
155 | - $params = $photo->parameters(); |
|
156 | - if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) { |
|
157 | - /** @var Parameter $typeParam */ |
|
158 | - $typeParam = isset($params['TYPE']) ? $params['TYPE'] : $params['MEDIATYPE']; |
|
159 | - $type = $typeParam->getValue(); |
|
160 | - |
|
161 | - if (strpos($type, 'image/') === 0) { |
|
162 | - return $type; |
|
163 | - } else { |
|
164 | - return 'image/' . strtolower($type); |
|
165 | - } |
|
166 | - } |
|
167 | - return ''; |
|
168 | - } |
|
37 | + /** @var Server */ |
|
38 | + protected $server; |
|
39 | + /** @var ILogger */ |
|
40 | + private $logger; |
|
41 | + |
|
42 | + public function __construct(ILogger $logger) { |
|
43 | + $this->logger = $logger; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Initializes the plugin and registers event handlers |
|
48 | + * |
|
49 | + * @param Server $server |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + function initialize(Server $server) { |
|
53 | + |
|
54 | + $this->server = $server; |
|
55 | + $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Intercepts GET requests on addressbook urls ending with ?photo. |
|
60 | + * |
|
61 | + * @param RequestInterface $request |
|
62 | + * @param ResponseInterface $response |
|
63 | + * @return bool|void |
|
64 | + */ |
|
65 | + function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
66 | + |
|
67 | + $queryParams = $request->getQueryParameters(); |
|
68 | + // TODO: in addition to photo we should also add logo some point in time |
|
69 | + if (!array_key_exists('photo', $queryParams)) { |
|
70 | + return true; |
|
71 | + } |
|
72 | + |
|
73 | + $path = $request->getPath(); |
|
74 | + $node = $this->server->tree->getNodeForPath($path); |
|
75 | + |
|
76 | + if (!($node instanceof Card)) { |
|
77 | + return true; |
|
78 | + } |
|
79 | + |
|
80 | + $this->server->transactionType = 'carddav-image-export'; |
|
81 | + |
|
82 | + // Checking ACL, if available. |
|
83 | + if ($aclPlugin = $this->server->getPlugin('acl')) { |
|
84 | + /** @var \Sabre\DAVACL\Plugin $aclPlugin */ |
|
85 | + $aclPlugin->checkPrivileges($path, '{DAV:}read'); |
|
86 | + } |
|
87 | + |
|
88 | + if ($result = $this->getPhoto($node)) { |
|
89 | + $response->setHeader('Content-Type', $result['Content-Type']); |
|
90 | + $response->setHeader('Content-Disposition', 'attachment'); |
|
91 | + $response->setStatus(200); |
|
92 | + |
|
93 | + $response->setBody($result['body']); |
|
94 | + |
|
95 | + // Returning false to break the event chain |
|
96 | + return false; |
|
97 | + } |
|
98 | + return true; |
|
99 | + } |
|
100 | + |
|
101 | + function getPhoto(Card $node) { |
|
102 | + // TODO: this is kind of expensive - load carddav data from database and parse it |
|
103 | + // we might want to build up a cache one day |
|
104 | + try { |
|
105 | + $vObject = $this->readCard($node->get()); |
|
106 | + if (!$vObject->PHOTO) { |
|
107 | + return false; |
|
108 | + } |
|
109 | + |
|
110 | + $photo = $vObject->PHOTO; |
|
111 | + $type = $this->getType($photo); |
|
112 | + |
|
113 | + $val = $photo->getValue(); |
|
114 | + if ($photo->getValueType() === 'URI') { |
|
115 | + $parsed = \Sabre\URI\parse($val); |
|
116 | + //only allow data:// |
|
117 | + if ($parsed['scheme'] !== 'data') { |
|
118 | + return false; |
|
119 | + } |
|
120 | + if (substr_count($parsed['path'], ';') === 1) { |
|
121 | + list($type,) = explode(';', $parsed['path']); |
|
122 | + } |
|
123 | + $val = file_get_contents($val); |
|
124 | + } |
|
125 | + |
|
126 | + $allowedContentTypes = [ |
|
127 | + 'image/png', |
|
128 | + 'image/jpeg', |
|
129 | + 'image/gif', |
|
130 | + ]; |
|
131 | + |
|
132 | + if(!in_array($type, $allowedContentTypes, true)) { |
|
133 | + $type = 'application/octet-stream'; |
|
134 | + } |
|
135 | + |
|
136 | + return [ |
|
137 | + 'Content-Type' => $type, |
|
138 | + 'body' => $val |
|
139 | + ]; |
|
140 | + } catch(\Exception $ex) { |
|
141 | + $this->logger->logException($ex); |
|
142 | + } |
|
143 | + return false; |
|
144 | + } |
|
145 | + |
|
146 | + private function readCard($cardData) { |
|
147 | + return Reader::read($cardData); |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @param Binary $photo |
|
152 | + * @return Parameter |
|
153 | + */ |
|
154 | + private function getType($photo) { |
|
155 | + $params = $photo->parameters(); |
|
156 | + if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) { |
|
157 | + /** @var Parameter $typeParam */ |
|
158 | + $typeParam = isset($params['TYPE']) ? $params['TYPE'] : $params['MEDIATYPE']; |
|
159 | + $type = $typeParam->getValue(); |
|
160 | + |
|
161 | + if (strpos($type, 'image/') === 0) { |
|
162 | + return $type; |
|
163 | + } else { |
|
164 | + return 'image/' . strtolower($type); |
|
165 | + } |
|
166 | + } |
|
167 | + return ''; |
|
168 | + } |
|
169 | 169 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | 'image/gif', |
130 | 130 | ]; |
131 | 131 | |
132 | - if(!in_array($type, $allowedContentTypes, true)) { |
|
132 | + if (!in_array($type, $allowedContentTypes, true)) { |
|
133 | 133 | $type = 'application/octet-stream'; |
134 | 134 | } |
135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'Content-Type' => $type, |
138 | 138 | 'body' => $val |
139 | 139 | ]; |
140 | - } catch(\Exception $ex) { |
|
140 | + } catch (\Exception $ex) { |
|
141 | 141 | $this->logger->logException($ex); |
142 | 142 | } |
143 | 143 | return false; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if (strpos($type, 'image/') === 0) { |
162 | 162 | return $type; |
163 | 163 | } else { |
164 | - return 'image/' . strtolower($type); |
|
164 | + return 'image/'.strtolower($type); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | return ''; |
@@ -28,15 +28,15 @@ |
||
28 | 28 | |
29 | 29 | class SyncJob extends TimedJob { |
30 | 30 | |
31 | - public function __construct() { |
|
32 | - // Run once a day |
|
33 | - $this->setInterval(24 * 60 * 60); |
|
34 | - } |
|
31 | + public function __construct() { |
|
32 | + // Run once a day |
|
33 | + $this->setInterval(24 * 60 * 60); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function run($argument) { |
|
37 | - $app = new Application(); |
|
38 | - /** @var SyncService $ss */ |
|
39 | - $ss = $app->getSyncService(); |
|
40 | - $ss->syncInstance(); |
|
41 | - } |
|
36 | + protected function run($argument) { |
|
37 | + $app = new Application(); |
|
38 | + /** @var SyncService $ss */ |
|
39 | + $ss = $app->getSyncService(); |
|
40 | + $ss->syncInstance(); |
|
41 | + } |
|
42 | 42 | } |
@@ -37,134 +37,134 @@ |
||
37 | 37 | * Mapping node for system tag to object id |
38 | 38 | */ |
39 | 39 | class SystemTagMappingNode implements \Sabre\DAV\INode { |
40 | - /** |
|
41 | - * @var ISystemTag |
|
42 | - */ |
|
43 | - protected $tag; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - private $objectId; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - private $objectType; |
|
54 | - |
|
55 | - /** |
|
56 | - * User |
|
57 | - * |
|
58 | - * @var IUser |
|
59 | - */ |
|
60 | - protected $user; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var ISystemTagManager |
|
64 | - */ |
|
65 | - protected $tagManager; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var ISystemTagObjectMapper |
|
69 | - */ |
|
70 | - private $tagMapper; |
|
71 | - |
|
72 | - /** |
|
73 | - * Sets up the node, expects a full path name |
|
74 | - * |
|
75 | - * @param ISystemTag $tag system tag |
|
76 | - * @param string $objectId |
|
77 | - * @param string $objectType |
|
78 | - * @param IUser $user user |
|
79 | - * @param ISystemTagManager $tagManager |
|
80 | - * @param ISystemTagObjectMapper $tagMapper |
|
81 | - */ |
|
82 | - public function __construct( |
|
83 | - ISystemTag $tag, |
|
84 | - $objectId, |
|
85 | - $objectType, |
|
86 | - IUser $user, |
|
87 | - ISystemTagManager $tagManager, |
|
88 | - ISystemTagObjectMapper $tagMapper |
|
89 | - ) { |
|
90 | - $this->tag = $tag; |
|
91 | - $this->objectId = $objectId; |
|
92 | - $this->objectType = $objectType; |
|
93 | - $this->user = $user; |
|
94 | - $this->tagManager = $tagManager; |
|
95 | - $this->tagMapper = $tagMapper; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Returns the object id of the relationship |
|
100 | - * |
|
101 | - * @return string object id |
|
102 | - */ |
|
103 | - public function getObjectId() { |
|
104 | - return $this->objectId; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Returns the object type of the relationship |
|
109 | - * |
|
110 | - * @return string object type |
|
111 | - */ |
|
112 | - public function getObjectType() { |
|
113 | - return $this->objectType; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Returns the system tag represented by this node |
|
118 | - * |
|
119 | - * @return ISystemTag system tag |
|
120 | - */ |
|
121 | - public function getSystemTag() { |
|
122 | - return $this->tag; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Returns the id of the tag |
|
127 | - * |
|
128 | - * @return string |
|
129 | - */ |
|
130 | - public function getName() { |
|
131 | - return $this->tag->getId(); |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Renames the node |
|
136 | - * |
|
137 | - * @param string $name The new name |
|
138 | - * |
|
139 | - * @throws MethodNotAllowed not allowed to rename node |
|
140 | - */ |
|
141 | - public function setName($name) { |
|
142 | - throw new MethodNotAllowed(); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Returns null, not supported |
|
147 | - * |
|
148 | - */ |
|
149 | - public function getLastModified() { |
|
150 | - return null; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Delete tag to object association |
|
155 | - */ |
|
156 | - public function delete() { |
|
157 | - try { |
|
158 | - if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
159 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
160 | - } |
|
161 | - if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
162 | - throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
163 | - } |
|
164 | - $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
|
165 | - } catch (TagNotFoundException $e) { |
|
166 | - // can happen if concurrent deletion occurred |
|
167 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
168 | - } |
|
169 | - } |
|
40 | + /** |
|
41 | + * @var ISystemTag |
|
42 | + */ |
|
43 | + protected $tag; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + private $objectId; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + private $objectType; |
|
54 | + |
|
55 | + /** |
|
56 | + * User |
|
57 | + * |
|
58 | + * @var IUser |
|
59 | + */ |
|
60 | + protected $user; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var ISystemTagManager |
|
64 | + */ |
|
65 | + protected $tagManager; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var ISystemTagObjectMapper |
|
69 | + */ |
|
70 | + private $tagMapper; |
|
71 | + |
|
72 | + /** |
|
73 | + * Sets up the node, expects a full path name |
|
74 | + * |
|
75 | + * @param ISystemTag $tag system tag |
|
76 | + * @param string $objectId |
|
77 | + * @param string $objectType |
|
78 | + * @param IUser $user user |
|
79 | + * @param ISystemTagManager $tagManager |
|
80 | + * @param ISystemTagObjectMapper $tagMapper |
|
81 | + */ |
|
82 | + public function __construct( |
|
83 | + ISystemTag $tag, |
|
84 | + $objectId, |
|
85 | + $objectType, |
|
86 | + IUser $user, |
|
87 | + ISystemTagManager $tagManager, |
|
88 | + ISystemTagObjectMapper $tagMapper |
|
89 | + ) { |
|
90 | + $this->tag = $tag; |
|
91 | + $this->objectId = $objectId; |
|
92 | + $this->objectType = $objectType; |
|
93 | + $this->user = $user; |
|
94 | + $this->tagManager = $tagManager; |
|
95 | + $this->tagMapper = $tagMapper; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Returns the object id of the relationship |
|
100 | + * |
|
101 | + * @return string object id |
|
102 | + */ |
|
103 | + public function getObjectId() { |
|
104 | + return $this->objectId; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Returns the object type of the relationship |
|
109 | + * |
|
110 | + * @return string object type |
|
111 | + */ |
|
112 | + public function getObjectType() { |
|
113 | + return $this->objectType; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Returns the system tag represented by this node |
|
118 | + * |
|
119 | + * @return ISystemTag system tag |
|
120 | + */ |
|
121 | + public function getSystemTag() { |
|
122 | + return $this->tag; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns the id of the tag |
|
127 | + * |
|
128 | + * @return string |
|
129 | + */ |
|
130 | + public function getName() { |
|
131 | + return $this->tag->getId(); |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Renames the node |
|
136 | + * |
|
137 | + * @param string $name The new name |
|
138 | + * |
|
139 | + * @throws MethodNotAllowed not allowed to rename node |
|
140 | + */ |
|
141 | + public function setName($name) { |
|
142 | + throw new MethodNotAllowed(); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Returns null, not supported |
|
147 | + * |
|
148 | + */ |
|
149 | + public function getLastModified() { |
|
150 | + return null; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Delete tag to object association |
|
155 | + */ |
|
156 | + public function delete() { |
|
157 | + try { |
|
158 | + if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
159 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
160 | + } |
|
161 | + if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
162 | + throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
163 | + } |
|
164 | + $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
|
165 | + } catch (TagNotFoundException $e) { |
|
166 | + // can happen if concurrent deletion occurred |
|
167 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
168 | + } |
|
169 | + } |
|
170 | 170 | } |
@@ -156,15 +156,15 @@ |
||
156 | 156 | public function delete() { |
157 | 157 | try { |
158 | 158 | if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
159 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
159 | + throw new NotFound('Tag with id '.$this->tag->getId().' not found'); |
|
160 | 160 | } |
161 | 161 | if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
162 | - throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
162 | + throw new Forbidden('No permission to unassign tag '.$this->tag->getId()); |
|
163 | 163 | } |
164 | 164 | $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
165 | 165 | } catch (TagNotFoundException $e) { |
166 | 166 | // can happen if concurrent deletion occurred |
167 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
167 | + throw new NotFound('Tag with id '.$this->tag->getId().' not found', 0, $e); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | } |
@@ -36,59 +36,59 @@ |
||
36 | 36 | |
37 | 37 | class SystemTagsRelationsCollection extends SimpleCollection { |
38 | 38 | |
39 | - /** |
|
40 | - * SystemTagsRelationsCollection constructor. |
|
41 | - * |
|
42 | - * @param ISystemTagManager $tagManager |
|
43 | - * @param ISystemTagObjectMapper $tagMapper |
|
44 | - * @param IUserSession $userSession |
|
45 | - * @param IGroupManager $groupManager |
|
46 | - * @param EventDispatcherInterface $dispatcher |
|
47 | - */ |
|
48 | - public function __construct( |
|
49 | - ISystemTagManager $tagManager, |
|
50 | - ISystemTagObjectMapper $tagMapper, |
|
51 | - IUserSession $userSession, |
|
52 | - IGroupManager $groupManager, |
|
53 | - EventDispatcherInterface $dispatcher |
|
54 | - ) { |
|
55 | - $children = [ |
|
56 | - new SystemTagsObjectTypeCollection( |
|
57 | - 'files', |
|
58 | - $tagManager, |
|
59 | - $tagMapper, |
|
60 | - $userSession, |
|
61 | - $groupManager, |
|
62 | - function($name) { |
|
63 | - $nodes = \OC::$server->getUserFolder()->getById(intval($name)); |
|
64 | - return !empty($nodes); |
|
65 | - } |
|
66 | - ), |
|
67 | - ]; |
|
39 | + /** |
|
40 | + * SystemTagsRelationsCollection constructor. |
|
41 | + * |
|
42 | + * @param ISystemTagManager $tagManager |
|
43 | + * @param ISystemTagObjectMapper $tagMapper |
|
44 | + * @param IUserSession $userSession |
|
45 | + * @param IGroupManager $groupManager |
|
46 | + * @param EventDispatcherInterface $dispatcher |
|
47 | + */ |
|
48 | + public function __construct( |
|
49 | + ISystemTagManager $tagManager, |
|
50 | + ISystemTagObjectMapper $tagMapper, |
|
51 | + IUserSession $userSession, |
|
52 | + IGroupManager $groupManager, |
|
53 | + EventDispatcherInterface $dispatcher |
|
54 | + ) { |
|
55 | + $children = [ |
|
56 | + new SystemTagsObjectTypeCollection( |
|
57 | + 'files', |
|
58 | + $tagManager, |
|
59 | + $tagMapper, |
|
60 | + $userSession, |
|
61 | + $groupManager, |
|
62 | + function($name) { |
|
63 | + $nodes = \OC::$server->getUserFolder()->getById(intval($name)); |
|
64 | + return !empty($nodes); |
|
65 | + } |
|
66 | + ), |
|
67 | + ]; |
|
68 | 68 | |
69 | - $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY); |
|
70 | - $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event); |
|
69 | + $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY); |
|
70 | + $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event); |
|
71 | 71 | |
72 | - foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) { |
|
73 | - $children[] = new SystemTagsObjectTypeCollection( |
|
74 | - $entity, |
|
75 | - $tagManager, |
|
76 | - $tagMapper, |
|
77 | - $userSession, |
|
78 | - $groupManager, |
|
79 | - $entityExistsFunction |
|
80 | - ); |
|
81 | - } |
|
72 | + foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) { |
|
73 | + $children[] = new SystemTagsObjectTypeCollection( |
|
74 | + $entity, |
|
75 | + $tagManager, |
|
76 | + $tagMapper, |
|
77 | + $userSession, |
|
78 | + $groupManager, |
|
79 | + $entityExistsFunction |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | |
83 | - parent::__construct('root', $children); |
|
84 | - } |
|
83 | + parent::__construct('root', $children); |
|
84 | + } |
|
85 | 85 | |
86 | - function getName() { |
|
87 | - return 'systemtags-relations'; |
|
88 | - } |
|
86 | + function getName() { |
|
87 | + return 'systemtags-relations'; |
|
88 | + } |
|
89 | 89 | |
90 | - function setName($name) { |
|
91 | - throw new Forbidden('Permission denied to rename this collection'); |
|
92 | - } |
|
90 | + function setName($name) { |
|
91 | + throw new Forbidden('Permission denied to rename this collection'); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | } |
@@ -31,30 +31,30 @@ |
||
31 | 31 | \OC_Util::obEnd(); |
32 | 32 | |
33 | 33 | $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory( |
34 | - \OC::$server->getConfig(), |
|
35 | - \OC::$server->getLogger(), |
|
36 | - \OC::$server->getDatabaseConnection(), |
|
37 | - \OC::$server->getUserSession(), |
|
38 | - \OC::$server->getMountManager(), |
|
39 | - \OC::$server->getTagManager(), |
|
40 | - \OC::$server->getRequest(), |
|
41 | - \OC::$server->getPreviewManager() |
|
34 | + \OC::$server->getConfig(), |
|
35 | + \OC::$server->getLogger(), |
|
36 | + \OC::$server->getDatabaseConnection(), |
|
37 | + \OC::$server->getUserSession(), |
|
38 | + \OC::$server->getMountManager(), |
|
39 | + \OC::$server->getTagManager(), |
|
40 | + \OC::$server->getRequest(), |
|
41 | + \OC::$server->getPreviewManager() |
|
42 | 42 | ); |
43 | 43 | |
44 | 44 | // Backends |
45 | 45 | $authBackend = new \OCA\DAV\Connector\Sabre\Auth( |
46 | - \OC::$server->getSession(), |
|
47 | - \OC::$server->getUserSession(), |
|
48 | - \OC::$server->getRequest(), |
|
49 | - \OC::$server->getTwoFactorAuthManager(), |
|
50 | - \OC::$server->getBruteForceThrottler(), |
|
51 | - 'principals/' |
|
46 | + \OC::$server->getSession(), |
|
47 | + \OC::$server->getUserSession(), |
|
48 | + \OC::$server->getRequest(), |
|
49 | + \OC::$server->getTwoFactorAuthManager(), |
|
50 | + \OC::$server->getBruteForceThrottler(), |
|
51 | + 'principals/' |
|
52 | 52 | ); |
53 | 53 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
54 | 54 | |
55 | 55 | $server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function() { |
56 | - // use the view for the logged in user |
|
57 | - return \OC\Files\Filesystem::getView(); |
|
56 | + // use the view for the logged in user |
|
57 | + return \OC\Files\Filesystem::getView(); |
|
58 | 58 | }); |
59 | 59 | |
60 | 60 | // And off we go! |
@@ -84,7 +84,7 @@ |
||
84 | 84 | $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
85 | 85 | $server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
86 | 86 | $server->addPlugin(new \Sabre\CalDAV\Schedule\Plugin()); |
87 | -$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin( \OC::$server->getMailer(), \OC::$server->getLogger())); |
|
87 | +$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin(\OC::$server->getMailer(), \OC::$server->getLogger())); |
|
88 | 88 | $server->addPlugin(new ExceptionLoggerPlugin('caldav', \OC::$server->getLogger())); |
89 | 89 | |
90 | 90 | // And off we go! |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | use OCA\DAV\Connector\Sabre\Principal; |
34 | 34 | |
35 | 35 | $authBackend = new Auth( |
36 | - \OC::$server->getSession(), |
|
37 | - \OC::$server->getUserSession(), |
|
38 | - \OC::$server->getRequest(), |
|
39 | - \OC::$server->getTwoFactorAuthManager(), |
|
40 | - \OC::$server->getBruteForceThrottler(), |
|
41 | - 'principals/' |
|
36 | + \OC::$server->getSession(), |
|
37 | + \OC::$server->getUserSession(), |
|
38 | + \OC::$server->getRequest(), |
|
39 | + \OC::$server->getTwoFactorAuthManager(), |
|
40 | + \OC::$server->getBruteForceThrottler(), |
|
41 | + 'principals/' |
|
42 | 42 | ); |
43 | 43 | $principalBackend = new Principal( |
44 | - \OC::$server->getUserManager(), |
|
45 | - \OC::$server->getGroupManager(), |
|
46 | - 'principals/' |
|
44 | + \OC::$server->getUserManager(), |
|
45 | + \OC::$server->getGroupManager(), |
|
46 | + 'principals/' |
|
47 | 47 | ); |
48 | 48 | $db = \OC::$server->getDatabaseConnection(); |
49 | 49 | $calDavBackend = new CalDavBackend($db, $principalBackend); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | $addressBookRoot->disableListing = !$debugging; // Disable listing |
59 | 59 | |
60 | 60 | $nodes = array( |
61 | - $principalCollection, |
|
62 | - $addressBookRoot, |
|
61 | + $principalCollection, |
|
62 | + $addressBookRoot, |
|
63 | 63 | ); |
64 | 64 | |
65 | 65 | // Fire up server |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $server->addPlugin(new LegacyDAVACL()); |
77 | 77 | if ($debugging) { |
78 | - $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
78 | + $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | require '../../../../3rdparty/autoload.php'; |
24 | 24 | |
25 | 25 | if ($argc !== 6) { |
26 | - echo "Invalid number of arguments" . PHP_EOL; |
|
27 | - exit; |
|
26 | + echo "Invalid number of arguments" . PHP_EOL; |
|
27 | + exit; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | 35 | function request($client, $method, $uploadUrl, $data = null, $headers = []) { |
36 | - echo "$method $uploadUrl ... "; |
|
37 | - $t0 = microtime(true); |
|
38 | - $result = $client->request($method, $uploadUrl, $data, $headers); |
|
39 | - $t1 = microtime(true); |
|
40 | - echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL; |
|
41 | - if (!in_array($result['statusCode'], [200, 201])) { |
|
42 | - echo $result['body'] . PHP_EOL; |
|
43 | - } |
|
44 | - return $result; |
|
36 | + echo "$method $uploadUrl ... "; |
|
37 | + $t0 = microtime(true); |
|
38 | + $result = $client->request($method, $uploadUrl, $data, $headers); |
|
39 | + $t1 = microtime(true); |
|
40 | + echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL; |
|
41 | + if (!in_array($result['statusCode'], [200, 201])) { |
|
42 | + echo $result['body'] . PHP_EOL; |
|
43 | + } |
|
44 | + return $result; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $baseUri = $argv[1]; |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | $chunkSize = $argv[5] * 1024 * 1024; |
52 | 52 | |
53 | 53 | $client = new \Sabre\DAV\Client([ |
54 | - 'baseUri' => $baseUri, |
|
55 | - 'userName' => $userName, |
|
56 | - 'password' => $password |
|
54 | + 'baseUri' => $baseUri, |
|
55 | + 'userName' => $userName, |
|
56 | + 'password' => $password |
|
57 | 57 | ]); |
58 | 58 | |
59 | 59 | $transfer = uniqid('transfer', true); |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | |
67 | 67 | $index = 0; |
68 | 68 | while(!feof($stream)) { |
69 | - request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize)); |
|
70 | - $index++; |
|
69 | + request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize)); |
|
70 | + $index++; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $destination = pathinfo($file, PATHINFO_BASENAME); |
74 | 74 | //echo "Moving $uploadUrl/.file to it's final destination $baseUri/files/$userName/$destination" . PHP_EOL; |
75 | 75 | request($client, 'MOVE', "$uploadUrl/.file", null, [ |
76 | - 'Destination' => "$baseUri/files/$userName/$destination" |
|
76 | + 'Destination' => "$baseUri/files/$userName/$destination" |
|
77 | 77 | ]); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | require '../../../../3rdparty/autoload.php'; |
24 | 24 | |
25 | 25 | if ($argc !== 6) { |
26 | - echo "Invalid number of arguments" . PHP_EOL; |
|
26 | + echo "Invalid number of arguments".PHP_EOL; |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | $t0 = microtime(true); |
38 | 38 | $result = $client->request($method, $uploadUrl, $data, $headers); |
39 | 39 | $t1 = microtime(true); |
40 | - echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL; |
|
41 | - if (!in_array($result['statusCode'], [200, 201])) { |
|
42 | - echo $result['body'] . PHP_EOL; |
|
40 | + echo $result['statusCode']." - ".($t1 - $t0).' seconds'.PHP_EOL; |
|
41 | + if (!in_array($result['statusCode'], [200, 201])) { |
|
42 | + echo $result['body'].PHP_EOL; |
|
43 | 43 | } |
44 | 44 | return $result; |
45 | 45 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $stream = fopen($file, 'r'); |
66 | 66 | |
67 | 67 | $index = 0; |
68 | -while(!feof($stream)) { |
|
68 | +while (!feof($stream)) { |
|
69 | 69 | request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize)); |
70 | 70 | $index++; |
71 | 71 | } |
@@ -40,149 +40,149 @@ |
||
40 | 40 | |
41 | 41 | class AuditLogger { |
42 | 42 | |
43 | - /** @var ILogger */ |
|
44 | - private $logger; |
|
43 | + /** @var ILogger */ |
|
44 | + private $logger; |
|
45 | 45 | |
46 | - /** @var IUserSession */ |
|
47 | - private $userSession; |
|
46 | + /** @var IUserSession */ |
|
47 | + private $userSession; |
|
48 | 48 | |
49 | - /** @var IGroupManager */ |
|
50 | - private $groupManager; |
|
51 | - |
|
52 | - /** |
|
53 | - * AuditLogger constructor. |
|
54 | - * |
|
55 | - * @param ILogger $logger |
|
56 | - * @param IUserSession $userSession |
|
57 | - * @param IGroupManager $groupManager |
|
58 | - */ |
|
59 | - public function __construct(ILogger $logger, |
|
60 | - IUserSession $userSession, |
|
61 | - IGroupManager $groupManager) { |
|
62 | - $this->logger = $logger; |
|
63 | - $this->userSession = $userSession; |
|
64 | - $this->groupManager = $groupManager; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * register hooks in order to log them |
|
69 | - */ |
|
70 | - public function registerHooks() { |
|
71 | - $this->userManagementHooks(); |
|
72 | - $this->groupHooks(); |
|
73 | - $this->sharingHooks(); |
|
74 | - $this->authHooks(); |
|
75 | - $this->fileHooks(); |
|
76 | - $this->trashbinHooks(); |
|
77 | - $this->versionsHooks(); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * connect to user management hooks |
|
82 | - */ |
|
83 | - private function userManagementHooks() { |
|
84 | - $userActions = new UserManagement($this->logger); |
|
85 | - |
|
86 | - Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
87 | - Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
88 | - $this->userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']); |
|
89 | - } |
|
49 | + /** @var IGroupManager */ |
|
50 | + private $groupManager; |
|
51 | + |
|
52 | + /** |
|
53 | + * AuditLogger constructor. |
|
54 | + * |
|
55 | + * @param ILogger $logger |
|
56 | + * @param IUserSession $userSession |
|
57 | + * @param IGroupManager $groupManager |
|
58 | + */ |
|
59 | + public function __construct(ILogger $logger, |
|
60 | + IUserSession $userSession, |
|
61 | + IGroupManager $groupManager) { |
|
62 | + $this->logger = $logger; |
|
63 | + $this->userSession = $userSession; |
|
64 | + $this->groupManager = $groupManager; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * register hooks in order to log them |
|
69 | + */ |
|
70 | + public function registerHooks() { |
|
71 | + $this->userManagementHooks(); |
|
72 | + $this->groupHooks(); |
|
73 | + $this->sharingHooks(); |
|
74 | + $this->authHooks(); |
|
75 | + $this->fileHooks(); |
|
76 | + $this->trashbinHooks(); |
|
77 | + $this->versionsHooks(); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * connect to user management hooks |
|
82 | + */ |
|
83 | + private function userManagementHooks() { |
|
84 | + $userActions = new UserManagement($this->logger); |
|
85 | + |
|
86 | + Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
87 | + Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
88 | + $this->userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']); |
|
89 | + } |
|
90 | 90 | |
91 | - private function groupHooks() { |
|
92 | - $groupActions = new GroupManagement($this->logger); |
|
93 | - $this->groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
94 | - $this->groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * connect to sharing events |
|
99 | - */ |
|
100 | - private function sharingHooks() { |
|
101 | - $shareActions = new Sharing($this->logger); |
|
102 | - |
|
103 | - Util::connectHook('OCP\Share', 'post_shared', $shareActions, 'shared'); |
|
104 | - Util::connectHook('OCP\Share', 'post_unshare', $shareActions, 'unshare'); |
|
105 | - Util::connectHook('OCP\Share', 'post_update_permissions', $shareActions, 'updatePermissions'); |
|
106 | - Util::connectHook('OCP\Share', 'post_update_password', $shareActions, 'updatePassword'); |
|
107 | - Util::connectHook('OCP\Share', 'post_set_expiration_date', $shareActions, 'updateExpirationDate'); |
|
108 | - Util::connectHook('OCP\Share', 'share_link_access', $shareActions, 'shareAccessed'); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * connect to authentication event and related actions |
|
113 | - */ |
|
114 | - private function authHooks() { |
|
115 | - $authActions = new Auth($this->logger); |
|
116 | - |
|
117 | - Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt'); |
|
118 | - Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful'); |
|
119 | - Util::connectHook('OC_User', 'logout', $authActions, 'logout'); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * connect to file hooks |
|
125 | - */ |
|
126 | - private function fileHooks() { |
|
127 | - $fileActions = new Files($this->logger); |
|
128 | - |
|
129 | - Util::connectHook( |
|
130 | - Filesystem::CLASSNAME, |
|
131 | - Filesystem::signal_post_rename, |
|
132 | - $fileActions, |
|
133 | - 'rename' |
|
134 | - ); |
|
135 | - Util::connectHook( |
|
136 | - Filesystem::CLASSNAME, |
|
137 | - Filesystem::signal_post_create, |
|
138 | - $fileActions, |
|
139 | - 'create' |
|
140 | - ); |
|
141 | - Util::connectHook( |
|
142 | - Filesystem::CLASSNAME, |
|
143 | - Filesystem::signal_post_copy, |
|
144 | - $fileActions, |
|
145 | - 'copy' |
|
146 | - ); |
|
147 | - Util::connectHook( |
|
148 | - Filesystem::CLASSNAME, |
|
149 | - Filesystem::signal_post_write, |
|
150 | - $fileActions, |
|
151 | - 'write' |
|
152 | - ); |
|
153 | - Util::connectHook( |
|
154 | - Filesystem::CLASSNAME, |
|
155 | - Filesystem::signal_post_update, |
|
156 | - $fileActions, |
|
157 | - 'update' |
|
158 | - ); |
|
159 | - Util::connectHook( |
|
160 | - Filesystem::CLASSNAME, |
|
161 | - Filesystem::signal_read, |
|
162 | - $fileActions, |
|
163 | - 'read' |
|
164 | - ); |
|
165 | - Util::connectHook( |
|
166 | - Filesystem::CLASSNAME, |
|
167 | - Filesystem::signal_delete, |
|
168 | - $fileActions, |
|
169 | - 'delete' |
|
170 | - ); |
|
171 | - } |
|
172 | - |
|
173 | - public function versionsHooks() { |
|
174 | - $versionsActions = new Versions($this->logger); |
|
175 | - Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback'); |
|
176 | - Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete'); |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * connect to trash bin hooks |
|
181 | - */ |
|
182 | - private function trashbinHooks() { |
|
183 | - $trashActions = new Trashbin($this->logger); |
|
184 | - Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete'); |
|
185 | - Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore'); |
|
186 | - } |
|
91 | + private function groupHooks() { |
|
92 | + $groupActions = new GroupManagement($this->logger); |
|
93 | + $this->groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
94 | + $this->groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * connect to sharing events |
|
99 | + */ |
|
100 | + private function sharingHooks() { |
|
101 | + $shareActions = new Sharing($this->logger); |
|
102 | + |
|
103 | + Util::connectHook('OCP\Share', 'post_shared', $shareActions, 'shared'); |
|
104 | + Util::connectHook('OCP\Share', 'post_unshare', $shareActions, 'unshare'); |
|
105 | + Util::connectHook('OCP\Share', 'post_update_permissions', $shareActions, 'updatePermissions'); |
|
106 | + Util::connectHook('OCP\Share', 'post_update_password', $shareActions, 'updatePassword'); |
|
107 | + Util::connectHook('OCP\Share', 'post_set_expiration_date', $shareActions, 'updateExpirationDate'); |
|
108 | + Util::connectHook('OCP\Share', 'share_link_access', $shareActions, 'shareAccessed'); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * connect to authentication event and related actions |
|
113 | + */ |
|
114 | + private function authHooks() { |
|
115 | + $authActions = new Auth($this->logger); |
|
116 | + |
|
117 | + Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt'); |
|
118 | + Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful'); |
|
119 | + Util::connectHook('OC_User', 'logout', $authActions, 'logout'); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * connect to file hooks |
|
125 | + */ |
|
126 | + private function fileHooks() { |
|
127 | + $fileActions = new Files($this->logger); |
|
128 | + |
|
129 | + Util::connectHook( |
|
130 | + Filesystem::CLASSNAME, |
|
131 | + Filesystem::signal_post_rename, |
|
132 | + $fileActions, |
|
133 | + 'rename' |
|
134 | + ); |
|
135 | + Util::connectHook( |
|
136 | + Filesystem::CLASSNAME, |
|
137 | + Filesystem::signal_post_create, |
|
138 | + $fileActions, |
|
139 | + 'create' |
|
140 | + ); |
|
141 | + Util::connectHook( |
|
142 | + Filesystem::CLASSNAME, |
|
143 | + Filesystem::signal_post_copy, |
|
144 | + $fileActions, |
|
145 | + 'copy' |
|
146 | + ); |
|
147 | + Util::connectHook( |
|
148 | + Filesystem::CLASSNAME, |
|
149 | + Filesystem::signal_post_write, |
|
150 | + $fileActions, |
|
151 | + 'write' |
|
152 | + ); |
|
153 | + Util::connectHook( |
|
154 | + Filesystem::CLASSNAME, |
|
155 | + Filesystem::signal_post_update, |
|
156 | + $fileActions, |
|
157 | + 'update' |
|
158 | + ); |
|
159 | + Util::connectHook( |
|
160 | + Filesystem::CLASSNAME, |
|
161 | + Filesystem::signal_read, |
|
162 | + $fileActions, |
|
163 | + 'read' |
|
164 | + ); |
|
165 | + Util::connectHook( |
|
166 | + Filesystem::CLASSNAME, |
|
167 | + Filesystem::signal_delete, |
|
168 | + $fileActions, |
|
169 | + 'delete' |
|
170 | + ); |
|
171 | + } |
|
172 | + |
|
173 | + public function versionsHooks() { |
|
174 | + $versionsActions = new Versions($this->logger); |
|
175 | + Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback'); |
|
176 | + Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete'); |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * connect to trash bin hooks |
|
181 | + */ |
|
182 | + private function trashbinHooks() { |
|
183 | + $trashActions = new Trashbin($this->logger); |
|
184 | + Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete'); |
|
185 | + Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore'); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | } |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | private function userManagementHooks() { |
84 | 84 | $userActions = new UserManagement($this->logger); |
85 | 85 | |
86 | - Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
87 | - Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
86 | + Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
87 | + Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
88 | 88 | $this->userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']); |
89 | 89 | } |
90 | 90 | |
91 | - private function groupHooks() { |
|
91 | + private function groupHooks() { |
|
92 | 92 | $groupActions = new GroupManagement($this->logger); |
93 | - $this->groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
94 | - $this->groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
93 | + $this->groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
94 | + $this->groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function versionsHooks() { |
174 | 174 | $versionsActions = new Versions($this->logger); |
175 | 175 | Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback'); |
176 | - Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete'); |
|
176 | + Util::connectHook('\OCP\Versions', 'delete', $versionsActions, 'delete'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -37,40 +37,40 @@ |
||
37 | 37 | */ |
38 | 38 | class GroupManagement extends Action { |
39 | 39 | |
40 | - /** |
|
41 | - * log add user to group event |
|
42 | - * |
|
43 | - * @param IGroup $group |
|
44 | - * @param IUser $user |
|
45 | - */ |
|
46 | - public function addUser(IGroup $group, IUser $user) { |
|
47 | - $this->log('User "%s" added to group "%s"', |
|
48 | - [ |
|
49 | - 'group' => $group->getGID(), |
|
50 | - 'user' => $user->getUID() |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'user', 'group' |
|
54 | - ] |
|
55 | - ); |
|
56 | - } |
|
40 | + /** |
|
41 | + * log add user to group event |
|
42 | + * |
|
43 | + * @param IGroup $group |
|
44 | + * @param IUser $user |
|
45 | + */ |
|
46 | + public function addUser(IGroup $group, IUser $user) { |
|
47 | + $this->log('User "%s" added to group "%s"', |
|
48 | + [ |
|
49 | + 'group' => $group->getGID(), |
|
50 | + 'user' => $user->getUID() |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'user', 'group' |
|
54 | + ] |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * log remove user from group event |
|
60 | - * |
|
61 | - * @param IGroup $group |
|
62 | - * @param IUser $user |
|
63 | - */ |
|
64 | - public function removeUser(IGroup $group, IUser $user) { |
|
65 | - $this->log('User "%s" removed from group "%s"', |
|
66 | - [ |
|
67 | - 'group' => $group->getGID(), |
|
68 | - 'user' => $user->getUID() |
|
69 | - ], |
|
70 | - [ |
|
71 | - 'user', 'group' |
|
72 | - ] |
|
73 | - ); |
|
74 | - } |
|
58 | + /** |
|
59 | + * log remove user from group event |
|
60 | + * |
|
61 | + * @param IGroup $group |
|
62 | + * @param IUser $user |
|
63 | + */ |
|
64 | + public function removeUser(IGroup $group, IUser $user) { |
|
65 | + $this->log('User "%s" removed from group "%s"', |
|
66 | + [ |
|
67 | + 'group' => $group->getGID(), |
|
68 | + 'user' => $user->getUID() |
|
69 | + ], |
|
70 | + [ |
|
71 | + 'user', 'group' |
|
72 | + ] |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |