@@ -117,7 +117,7 @@ protected function parseSpecificContributions(&$contribNode)
117
117
$ xpathesToRemove [] = 'action[contains(@name, "share-")] ' ;
118
118
}else {
119
119
$ folderSharingAllowed = $ this ->getAuthorization ("folder " , "any " );
120
- $ fileSharingAllowed = $ this ->getAuthorization ("file " );
120
+ $ fileSharingAllowed = $ this ->getAuthorization ("file " , " any " );
121
121
if ($ fileSharingAllowed === false ){
122
122
// Share file button
123
123
$ xpathesToRemove [] = 'action[@name="share-file-minisite"] ' ;
@@ -143,10 +143,23 @@ protected function parseSpecificContributions(&$contribNode)
143
143
/**
144
144
* Compute right to create shares based on plugin options
145
145
* @param string $nodeType "file"|"folder"
146
- * @param string $shareType
146
+ * @param string $shareType "any"|"minisite"|"workspace"
147
147
* @return bool
148
148
*/
149
149
protected function getAuthorization ($ nodeType , $ shareType = "any " ){
150
+ $ filesMini = $ this ->getFilteredOption ("ENABLE_FILE_PUBLIC_LINK " );
151
+ $ filesInternal = $ this ->getFilteredOption ("ENABLE_FILE_INTERNAL_SHARING " );
152
+ $ foldersMini = $ this ->getFilteredOption ("ENABLE_FOLDER_PUBLIC_LINK " );
153
+ $ foldersInternal = $ this ->getFilteredOption ("ENABLE_FOLDER_INTERNAL_SHARING " );
154
+ if ($ shareType == "any " ){
155
+ return ($ nodeType == "file " ? $ filesInternal || $ filesMini : $ foldersInternal || $ foldersMini );
156
+ }else if ($ shareType == "minisite " ){
157
+ return ($ nodeType == "file " ? $ filesMini : $ foldersMini );
158
+ }else if ($ shareType == "workspace " ){
159
+ return ($ nodeType == "file " ? $ filesInternal : $ foldersInternal );
160
+ }
161
+ return false ;
162
+ /*
150
163
if($nodeType == "file"){
151
164
return $this->getFilteredOption("ENABLE_FILE_PUBLIC_LINK") !== false;
152
165
}else{
@@ -159,6 +172,7 @@ protected function getAuthorization($nodeType, $shareType = "any"){
159
172
return ($opt !== "disable");
160
173
}
161
174
}
175
+ */
162
176
}
163
177
164
178
/**
@@ -431,7 +445,8 @@ public function switchAction($action, $httpVars, $fileVars)
431
445
432
446
$ auth = $ this ->getAuthorization ("folder " , "workspace " );
433
447
if (!$ auth ){
434
- throw new Exception (103 );
448
+ $ mess = ConfService::getMessages ();
449
+ throw new Exception ($ mess ["351 " ]);
435
450
}
436
451
437
452
$ users = array (); $ groups = array ();
@@ -496,8 +511,9 @@ public function switchAction($action, $httpVars, $fileVars)
496
511
497
512
$ httpVars ["return_json " ] = true ;
498
513
if (isSet ($ httpVars ["hash " ]) && !empty ($ httpVars ["hash " ])) $ httpHash = $ httpVars ["hash " ];
514
+ $ ajxpNode ->loadNodeInfo ();
499
515
500
- $ results = $ this ->shareNode ($ httpVars , $ isUpdate );
516
+ $ results = $ this ->shareNode ($ ajxpNode , $ httpVars , $ isUpdate );
501
517
if (is_array ($ results ) && $ ajxpNode ->hasMetaStore () && !$ ajxpNode ->isRoot ()){
502
518
foreach ($ results as $ shareObject ){
503
519
if ($ shareObject instanceof \Pydio \OCS \Model \TargettedLink){
@@ -641,11 +657,17 @@ public function switchAction($action, $httpVars, $fileVars)
641
657
$ file = AJXP_Utils::decodeSecureMagic ($ httpVars ["file " ]);
642
658
$ node = new AJXP_Node ($ this ->urlBase .$ file );
643
659
if (!file_exists ($ node ->getUrl ())){
644
- throw new Exception ("Cannot find file " .$ file .": share may be lost. " );
660
+ $ mess = ConfService::getMessages ();
661
+ throw new Exception (str_replace ('%s ' , "Cannot find file " .$ file , $ mess ["share_center.219 " ]));
662
+ }
663
+ if (isSet ($ httpVars ["tmp_repository_id " ]) && AuthService::getLoggedUser ()->isAdmin ()){
664
+ $ compositeShare = $ this ->getShareStore ()->getMetaManager ()->getCompositeShareForNode ($ node , true );
665
+ }else {
666
+ $ compositeShare = $ this ->getShareStore ()->getMetaManager ()->getCompositeShareForNode ($ node );
645
667
}
646
- $ compositeShare = $ this ->getShareStore ()->getMetaManager ()->getCompositeShareForNode ($ node );
647
668
if (empty ($ compositeShare )){
648
- throw new Exception ("Cannot find share for node " .$ file );
669
+ $ mess = ConfService::getMessages ();
670
+ throw new Exception (str_replace ('%s ' , "Cannot find share for node " .$ file , $ mess ["share_center.219 " ]));
649
671
}
650
672
header ("Content-type:application/json " );
651
673
$ json = $ this ->compositeShareToJson ($ compositeShare );
@@ -850,7 +872,7 @@ public function nodeSharedMetadata(&$ajxpNode)
850
872
$ this ->getShareStore ()->getMetaManager ()->getSharesFromMeta ($ ajxpNode , $ shares , false );
851
873
if (!empty ($ shares )){
852
874
$ compositeShare = $ this ->getShareStore ()->getMetaManager ()->getCompositeShareForNode ($ ajxpNode );
853
- if (empty ($ compositeShare )){
875
+ if (empty ($ compositeShare ) || $ compositeShare -> isInvalid () ){
854
876
$ this ->getShareStore ()->getMetaManager ()->clearNodeMeta ($ ajxpNode );
855
877
return ;
856
878
}
@@ -1219,6 +1241,23 @@ public function filterHttpVarsForLeafPath(&$httpVars, $userSelection){
1219
1241
1220
1242
}
1221
1243
1244
+ /**
1245
+ * @param array $httpVars
1246
+ * @param AJXP_Node $ajxpNode
1247
+ */
1248
+ public function filterHttpVarsFromUniqueNode (&$ httpVars , $ ajxpNode ){
1249
+ $ httpVars ["minisite " ] = true ;
1250
+ $ httpVars ["selection " ] = true ;
1251
+ if ($ ajxpNode ->isLeaf ()){
1252
+ $ httpVars ["filter_nodes " ] = [$ ajxpNode ];
1253
+ $ httpVars ["file " ] = "/ " ;
1254
+ $ httpVars ["nodes " ] = array ("/ " );
1255
+ }
1256
+ if (!isSet ($ httpVars ["repo_label " ])){
1257
+ $ httpVars ["repo_label " ] = SystemTextEncoding::toUTF8 ($ ajxpNode ->getLabel ());
1258
+ }
1259
+ }
1260
+
1222
1261
/**
1223
1262
* @param array $httpVars
1224
1263
* @param bool $update
@@ -1228,7 +1267,8 @@ public function filterHttpVarsForLeafPath(&$httpVars, $userSelection){
1228
1267
protected function createOrLoadSharedRepository ($ httpVars , &$ update ){
1229
1268
1230
1269
if (!isSet ($ httpVars ["repo_label " ]) || $ httpVars ["repo_label " ] == "" ) {
1231
- throw new Exception (100 );
1270
+ $ mess = ConfService::getMessages ();
1271
+ throw new Exception ($ mess ["349 " ]);
1232
1272
}
1233
1273
1234
1274
if (isSet ($ httpVars ["repository_id " ])) {
@@ -1241,7 +1281,8 @@ protected function createOrLoadSharedRepository($httpVars, &$update){
1241
1281
$ description = AJXP_Utils::sanitize (AJXP_Utils::securePath ($ httpVars ["repo_description " ]), AJXP_SANITIZE_HTML );
1242
1282
$ exists = $ this ->checkRepoWithSameLabel ($ label , isSet ($ editingRepo )?$ editingRepo :null );
1243
1283
if ($ exists ){
1244
- throw new Exception (101 );
1284
+ $ mess = ConfService::getMessages ();
1285
+ throw new Exception ($ mess ["share_center.352 " ]);
1245
1286
}
1246
1287
1247
1288
$ loggedUser = AuthService::getLoggedUser ();
@@ -1263,7 +1304,8 @@ protected function createOrLoadSharedRepository($httpVars, &$update){
1263
1304
$ oldScope = $ editingRepo ->getOption ("SHARE_ACCESS " );
1264
1305
$ currentOwner = $ editingRepo ->getOwner ();
1265
1306
if ($ newScope != $ oldScope && $ currentOwner != AuthService::getLoggedUser ()->getId ()){
1266
- throw new Exception ("You are not allowed to handle this share. Please ask the owner of the share. " );
1307
+ $ mess = ConfService::getMessages ();
1308
+ throw new Exception ($ mess ["share_center.224 " ]);
1267
1309
}
1268
1310
if ($ newScope !== $ oldScope ){
1269
1311
$ editingRepo ->addOption ("SHARE_ACCESS " , $ newScope );
@@ -1272,7 +1314,8 @@ protected function createOrLoadSharedRepository($httpVars, &$update){
1272
1314
if (isSet ($ httpVars ["transfer_owner " ])){
1273
1315
$ newOwner = $ httpVars ["transfer_owner " ];
1274
1316
if ($ newOwner != $ currentOwner && $ currentOwner != AuthService::getLoggedUser ()->getId ()){
1275
- throw new Exception ("You are not allowed to handle this share. Please ask the owner " );
1317
+ $ mess = ConfService::getMessages ();
1318
+ throw new Exception ($ mess ["share_center.224 " ]);
1276
1319
}
1277
1320
$ editingRepo ->setOwnerData ($ editingRepo ->getParentId (), $ newOwner , $ editingRepo ->getUniqueUser ());
1278
1321
$ replace = true ;
@@ -1390,7 +1433,8 @@ public function createSharedRepository($httpVars, &$update, $users=array(), $gro
1390
1433
$ loggedUser = AuthService::getLoggedUser ();
1391
1434
$ actRights = $ loggedUser ->mergedRole ->listActionsStatesFor ($ this ->repository );
1392
1435
if (isSet ($ actRights ["share " ]) && $ actRights ["share " ] === false ) {
1393
- throw new Exception (103 );
1436
+ $ mess = ConfService::getMessages ();
1437
+ throw new Exception ($ mess ["351 " ]);
1394
1438
}
1395
1439
1396
1440
$ newRepo = $ this ->createOrLoadSharedRepository ($ httpVars , $ update );
@@ -1455,18 +1499,20 @@ protected function shareObjectFromParameters($linkData, &$hiddenUserEntries, &$s
1455
1499
}
1456
1500
1457
1501
/**
1502
+ * @param AJXP_Node $ajxpNode
1458
1503
* @param array $httpVars
1459
1504
* @param bool $update
1460
1505
* @return Repository[]|ShareLink[]
1461
1506
* @throws Exception
1462
1507
*/
1463
- public function shareNode ($ httpVars , &$ update ){
1508
+ public function shareNode ($ ajxpNode , $ httpVars , &$ update ){
1464
1509
1465
1510
$ hiddenUserEntries = array ();
1466
1511
$ originalHttpVars = $ httpVars ;
1467
1512
$ ocsStore = new Pydio \OCS \Model \SQLStore ();
1468
1513
$ ocsClient = new Pydio \OCS \Client \OCSClient ();
1469
1514
$ userSelection = new UserSelection ($ this ->repository , $ httpVars );
1515
+ $ mess = ConfService::getMessages ();
1470
1516
1471
1517
/**
1472
1518
* @var ShareLink[] $shareObjects
@@ -1475,6 +1521,9 @@ public function shareNode($httpVars, &$update){
1475
1521
1476
1522
// PUBLIC LINK
1477
1523
if (isSet ($ httpVars ["enable_public_link " ])){
1524
+ if (!$ this ->getAuthorization ($ ajxpNode ->isLeaf () ? "file " :"folder " , "minisite " )){
1525
+ throw new Exception ($ mess ["share_center. " . ($ ajxpNode ->isLeaf () ? "225 " : "226 " )]);
1526
+ }
1478
1527
$ this ->shareObjectFromParameters ($ httpVars , $ hiddenUserEntries , $ shareObjects , "public " );
1479
1528
}else if (isSet ($ httpVars ["disable_public_link " ])){
1480
1529
$ this ->getShareStore ()->deleteShare ("minisite " , $ httpVars ["disable_public_link " ], true );
@@ -1498,10 +1547,13 @@ public function shareNode($httpVars, &$update){
1498
1547
}
1499
1548
}
1500
1549
1501
- $ this ->filterHttpVarsForLeafPath ($ httpVars , $ userSelection );
1550
+ $ this ->filterHttpVarsFromUniqueNode ($ httpVars , $ ajxpNode );
1502
1551
1503
1552
$ users = array (); $ groups = array ();
1504
1553
$ this ->getRightsManager ()->createUsersFromParameters ($ httpVars , $ users , $ groups );
1554
+ if ((count ($ users ) || count ($ groups )) && !$ this ->getAuthorization ($ ajxpNode ->isLeaf ()?"file " :"folder " , "workspace " )){
1555
+ $ users = $ groups = array ();
1556
+ }
1505
1557
foreach ($ hiddenUserEntries as $ entry ){
1506
1558
$ users [$ entry ["ID " ]] = $ entry ;
1507
1559
}
0 commit comments