20
20
*/
21
21
namespace Pydio \Mq \Implementation ;
22
22
23
+ use Pydio \Core \Exception \PydioException ;
23
24
use Pydio \Core \Model \ContextInterface ;
24
25
25
26
use Pydio \Core \PluginFramework \SqlTableProvider ;
26
27
use Pydio \Core \Utils \DBHelper ;
27
- use Pydio \Core \Utils \FileHelper ;
28
28
use Pydio \Core \Utils \Vars \OptionsHelper ;
29
29
30
30
use Pydio \Core \PluginFramework \Plugin ;
@@ -162,15 +162,15 @@ public function __destruct()
162
162
* @param $channelName
163
163
* @param $clientId
164
164
* @return mixed
165
- * @throws \Exception
165
+ * @throws PydioException
166
166
*/
167
167
public function suscribeToChannel (ContextInterface $ ctx , $ channelName , $ clientId )
168
168
{
169
169
$ this ->loadChannel ($ channelName , true );
170
170
if ($ ctx ->hasUser ()) {
171
171
$ user = $ ctx ->getUser ();
172
172
if ($ user == null ) {
173
- throw new \ Exception ("You must be logged in " );
173
+ throw new PydioException ("You must be logged in " );
174
174
}
175
175
$ GROUP_PATH = $ user ->getGroupPath ();
176
176
$ USER_ID = $ user ->getId ();
@@ -179,6 +179,14 @@ public function suscribeToChannel(ContextInterface $ctx, $channelName, $clientId
179
179
$ USER_ID = "shared " ;
180
180
}
181
181
if ($ GROUP_PATH == null ) $ GROUP_PATH = false ;
182
+ if (strpos ($ channelName , "nodes: " ) === 0 && $ channelName !== "nodes:* " ){
183
+ $ repositoryId = substr ($ channelName , strlen ("nodes:* " ));
184
+ // Make sure current user has Read access on this workspace
185
+ if (!empty ($ user ) && !$ user ->canRead ($ repositoryId )){
186
+ $ this ->suscribeToChannel ($ ctx , "nodes:* " , $ clientId );
187
+ return ;
188
+ }
189
+ }
182
190
self ::$ channels [$ channelName ]["CLIENTS " ][$ clientId ] = array (
183
191
"ALIVE " => time (),
184
192
"USER_ID " => $ USER_ID ,
@@ -187,11 +195,6 @@ public function suscribeToChannel(ContextInterface $ctx, $channelName, $clientId
187
195
if (strpos ($ channelName , "nodes: " ) === 0 && $ channelName !== "nodes:* " ){
188
196
$ this ->suscribeToChannel ($ ctx , "nodes:* " , $ clientId );
189
197
}
190
- /*
191
- foreach (self::$channels[$channelName]["MESSAGES"] as &$object) {
192
- $object->messageRC[$clientId] = $clientId;
193
- }
194
- */
195
198
}
196
199
197
200
/**
0 commit comments