Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 1bf306a

Browse files
committed
Update restParameters and use UserSelection instead of 'file' variable in ShareCenter.
1 parent 25f4a33 commit 1bf306a

File tree

2 files changed

+24
-39
lines changed

2 files changed

+24
-39
lines changed

core/src/plugins/action.share/class.ShareCenter.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -302,21 +302,19 @@ public function switchAction($action, $httpVars, $fileVars)
302302

303303
case "toggle_link_watch":
304304

305-
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
305+
$userSelection = new UserSelection($this->repository, $httpVars);
306+
$shareNode = $selectedNode = $userSelection->getUniqueNode();
306307
$watchValue = $httpVars["set_watch"] == "true" ? true : false;
307308
$folder = false;
308-
$shNode = new AJXP_Node($this->urlBase.$file);
309309
if (isSet($httpVars["element_type"]) && $httpVars["element_type"] == "folder") {
310310
$folder = true;
311-
$node = new AJXP_Node("pydio://".$httpVars["repository_id"]."/");
312-
} else {
313-
$node = new AJXP_Node($this->urlBase.$file);
311+
$selectedNode = new AJXP_Node("pydio://". AJXP_Utils::sanitize($httpVars["repository_id"], AJXP_SANITIZE_ALPHANUM)."/");
314312
}
315-
316-
$this->getSharesFromMeta($shNode, $shares, false);
313+
$this->getSharesFromMeta($shareNode, $shares, false);
317314
if(!count($shares)){
318315
break;
319316
}
317+
320318
if(isSet($httpVars["element_id"]) && isSet($shares[$httpVars["element_id"]])){
321319
$elementId = $httpVars["element_id"];
322320
}else{
@@ -328,14 +326,14 @@ public function switchAction($action, $httpVars, $fileVars)
328326
if (!$folder) {
329327
if ($watchValue) {
330328
$this->watcher->setWatchOnFolder(
331-
$node,
329+
$selectedNode,
332330
AuthService::getLoggedUser()->getId(),
333331
MetaWatchRegister::$META_WATCH_USERS_READ,
334332
array($elementId)
335333
);
336334
} else {
337335
$this->watcher->removeWatchFromFolder(
338-
$node,
336+
$selectedNode,
339337
AuthService::getLoggedUser()->getId(),
340338
true,
341339
$elementId
@@ -344,13 +342,13 @@ public function switchAction($action, $httpVars, $fileVars)
344342
} else {
345343
if ($watchValue) {
346344
$this->watcher->setWatchOnFolder(
347-
$node,
345+
$selectedNode,
348346
AuthService::getLoggedUser()->getId(),
349347
MetaWatchRegister::$META_WATCH_BOTH
350348
);
351349
} else {
352350
$this->watcher->removeWatchFromFolder(
353-
$node,
351+
$selectedNode,
354352
AuthService::getLoggedUser()->getId());
355353
}
356354
}
@@ -404,8 +402,8 @@ public function switchAction($action, $httpVars, $fileVars)
404402

405403
}else{
406404

407-
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
408-
$ajxpNode = new AJXP_Node($this->urlBase.$file);
405+
$userSelection = new UserSelection($this->repository, $httpVars);
406+
$ajxpNode = $userSelection->getUniqueNode();
409407
$this->getSharesFromMeta($ajxpNode, $shares, false);
410408
if(count($shares)){
411409
if(isSet($httpVars["element_id"]) && isSet($shares[$httpVars["element_id"]])){
@@ -442,8 +440,8 @@ public function switchAction($action, $httpVars, $fileVars)
442440

443441
}else{
444442

445-
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
446-
$ajxpNode = new AJXP_Node($this->urlBase.$file);
443+
$userSelection = new UserSelection($this->repository, $httpVars);
444+
$ajxpNode = $userSelection->getUniqueNode();
447445
$metadata = $ajxpNode->retrieveMetadata(
448446
"ajxp_shared",
449447
true,
@@ -471,10 +469,10 @@ public function switchAction($action, $httpVars, $fileVars)
471469
return null;
472470
}
473471
$hash = AJXP_Utils::decodeSecureMagic($httpVars["element_id"]);
474-
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
472+
$userSelection = new UserSelection($this->repository, $httpVars);
473+
$ajxpNode = $userSelection->getUniqueNode();
475474
if($this->getShareStore()->shareIsLegacy($hash)){
476475
// Store in metadata
477-
$ajxpNode = new AJXP_Node($this->urlBase.$file);
478476
$metadata = $ajxpNode->retrieveMetadata(
479477
"ajxp_shared",
480478
true,
@@ -535,7 +533,8 @@ public function switchAction($action, $httpVars, $fileVars)
535533

536534
case "sharelist-clearExpired":
537535

538-
$currentUser = (ConfService::getRepository()->getAccessType() != "ajxp_conf");
536+
$accessType = ConfService::getRepository()->getAccessType();
537+
$currentUser = ($accessType != "ajxp_conf" && $accessType != "ajxp_admin");
539538
$count = $this->clearExpiredFiles($currentUser);
540539
AJXP_XMLWriter::header();
541540
if($count){
@@ -1623,6 +1622,7 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
16231622
if($node->isLeaf()){
16241623
$setFilter = true;
16251624
$httpVars["file"] = "/";
1625+
$httpVars["nodes"] = array("/");
16261626
}
16271627
}else{
16281628
$setFilter = true;
@@ -1953,7 +1953,8 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
19531953
}
19541954
}
19551955

1956-
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
1956+
$sel = new UserSelection($this->repository, $httpVars);
1957+
$file = $sel->getUniqueFile();
19571958
$newRepoUniqueId = $newRepo->getUniqueId();
19581959

19591960
if (isSet($editingRepo)) {

core/src/plugins/action.share/manifest.xml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
</action>
344344
<action name="unshare">
345345
<processing>
346-
<serverCallback methodName="switchAction" developerComment="Stop sharing a folder, or remove a public link from a file.">
346+
<serverCallback methodName="switchAction" restParams="/file+" developerComment="Stop sharing a folder, or remove a public link from a file.">
347347
<input_param description="Path of the resource to unshare" name="file" type="path" mandatory="true"/>
348348
<input_param description="Type of element to load (file or folder)" name="element_type" type="file|repository" mandatory="true"/>
349349
<input_param description="If the resource is a file, send also the element_id, as many links can be generated for one file" name="element_id" type="string"/>
@@ -352,7 +352,7 @@
352352
</action>
353353
<action name="toggle_link_watch">
354354
<processing>
355-
<serverCallback methodName="switchAction" developerComment="Toggle a shared element status for being watched or not.">
355+
<serverCallback methodName="switchAction" restParams="/file+" developerComment="Toggle a shared element status for being watched or not.">
356356
<input_param description="Path of the resource to unshare" name="file" type="path" mandatory="true"/>
357357
<input_param description="Type of element to load (file or folder)" name="element_type" type="file|repository" mandatory="true"/>
358358
<input_param description="If the resource is a file, send also the element_id, as many links can be generated for one file" name="element_id" type="string"/>
@@ -361,7 +361,7 @@
361361
</action>
362362
<action name="reset_counter">
363363
<processing>
364-
<serverCallback methodName="switchAction" developerComment="Reset download counter for a given link generated on a file.">
364+
<serverCallback methodName="switchAction" restParams="/file+" developerComment="Reset download counter for a given link generated on a file.">
365365
<input_param description="Path of the resource to unshare" name="file" type="path" mandatory="true"/>
366366
<input_param description="Send also the element_id, as many links can be generated for one file" name="element_id" type="string"/>
367367
</serverCallback>
@@ -414,7 +414,7 @@
414414
]]></clientCallback>
415415
</processing>
416416
<processing>
417-
<serverCallback methodName="switchAction" sdkMethodName="loadShareList">
417+
<serverCallback restParams="/" methodName="switchAction" sdkMethodName="loadShareList">
418418
<input_param description="Parent repository ID" name="parent_repository_id" type="string" mandatory="false"/>
419419
<input_param name="user_context" type="string" description="Either global (all users, requires admin right) or current (current user)" default="current"/>
420420
</serverCallback>
@@ -443,22 +443,6 @@
443443
<serverCallback methodName="switchAction" developerComment="Clear expired links" restParams="/"/>
444444
</processing>
445445
</action>
446-
<!--
447-
<action name="sharelist-migrate">
448-
<gui src="share.png" iconClass="icon-sort-by-attributes-alt" text="share_center.127" title="share_center.128">
449-
<context dir="false" recycle="false" selection="false" actionBar="true" actionBarGroup="share_list_toolbar" behaviour="hidden"/>
450-
</gui>
451-
<rightsContext adminOnly="true" noUser="false" read="false" userLogged="true" write="false"/>
452-
<processing>
453-
<clientCallback prepareModal="true"><![CDATA[
454-
if(window.actionManager){
455-
var id = window.actionManager.getDataModel().getRootNode().getPath();
456-
}
457-
]]></clientCallback>
458-
<serverCallback methodName="switchAction" developerComment="Migrate old publiclets to new format"/>
459-
</processing>
460-
</action>
461-
-->
462446
<action name="share_current_page">
463447
<gui src="" iconClass="icon-share" text="share_center.110" title="share_center.110">
464448
<context dir="true" recycle="false" selection="false" actionBarGroup="minisite-share-actions" actionBar="true"/>

0 commit comments

Comments
 (0)