@@ -80,13 +80,13 @@ protected function parseSpecificContributions(&$contribNode)
80
80
// All share- actions
81
81
$ xpathesToRemove [] = 'action[contains(@name, "share-")] ' ;
82
82
}else {
83
- $ folderSharingMode = $ this ->pluginConf ["ENABLE_FOLDER_SHARING " ];
84
- $ fileSharingAllowed = $ this ->pluginConf ["ENABLE_FILE_PUBLIC_LINK " ];
83
+ $ folderSharingAllowed = $ this -> getAuthorization ( " folder " , " any " ); // $this->pluginConf["ENABLE_FOLDER_SHARING"];
84
+ $ fileSharingAllowed = $ this ->getAuthorization ( " file " ); //$this-> pluginConf["ENABLE_FILE_PUBLIC_LINK"];
85
85
if ($ fileSharingAllowed === false ){
86
86
// Share file button
87
87
$ xpathesToRemove [] = 'action[@name="share-file-minisite"] ' ;
88
88
}
89
- if ($ folderSharingMode == ' disable ' ){
89
+ if (! $ folderSharingAllowed ){
90
90
// Share folder button
91
91
$ xpathesToRemove [] = 'action[@name="share-folder-minisite-public"] ' ;
92
92
}
@@ -116,6 +116,21 @@ public function init($options)
116
116
}
117
117
}
118
118
119
+ protected function getAuthorization ($ nodeType , $ shareType = "any " ){
120
+ if ($ nodeType == "file " ){
121
+ return $ this ->getFilteredOption ("ENABLE_FILE_PUBLIC_LINK " ) !== false ;
122
+ }else {
123
+ $ opt = $ this ->getFilteredOption ("ENABLE_FOLDER_SHARING " );
124
+ if ($ shareType == "minisite " ){
125
+ return ($ opt == "minisite " || $ opt == "both " );
126
+ }else if ($ shareType == "workspace " ){
127
+ return ($ opt == "workspace " || $ opt == "both " );
128
+ }else {
129
+ return ($ opt !== "disabled " );
130
+ }
131
+ }
132
+ }
133
+
119
134
/**
120
135
* @return ShareCenter
121
136
*/
@@ -219,6 +234,11 @@ public function switchAction($action, $httpVars, $fileVars)
219
234
220
235
if ($ subAction == "delegate_repo " ) {
221
236
header ("Content-type:text/plain " );
237
+ $ auth = $ this ->getAuthorization ("folder " , "workspace " );
238
+ if (!$ auth ){
239
+ print 103 ;
240
+ break ;
241
+ }
222
242
$ result = $ this ->createSharedRepository ($ httpVars , $ this ->repository , $ this ->accessDriver );
223
243
if (is_a ($ result , "Repository " )) {
224
244
$ newMeta = array ("id " => $ result ->getUniqueId (), "type " => "repository " );
@@ -1601,8 +1621,18 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
1601
1621
}else {
1602
1622
$ setFilter = true ;
1603
1623
}
1624
+ $ nodes = $ userSelection ->buildNodes ($ this ->accessDriver );
1625
+ $ hasDir = false ; $ hasFile = false ;
1626
+ foreach ($ nodes as $ n ){
1627
+ $ n ->loadNodeInfo ();
1628
+ if ($ n ->isLeaf ()) $ hasFile = true ;
1629
+ else $ hasDir = true ;
1630
+ }
1631
+ if ( ( $ hasDir && !$ this ->getAuthorization ("folder " , "minisite " ) ) || ($ hasFile && !$ this ->getAuthorization ("file " ))){
1632
+ return 103 ;
1633
+ }
1604
1634
if ($ setFilter ){
1605
- $ httpVars ["filter_nodes " ] = $ userSelection -> buildNodes ( $ this -> accessDriver ) ;
1635
+ $ httpVars ["filter_nodes " ] = $ nodes ;
1606
1636
}
1607
1637
if (!isSet ($ httpVars ["repo_label " ])){
1608
1638
$ first = $ userSelection ->getUniqueNode ($ this ->accessDriver );
@@ -1739,10 +1769,15 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
1739
1769
if (!isSet ($ httpVars ["repo_label " ]) || $ httpVars ["repo_label " ] == "" ) {
1740
1770
return 100 ;
1741
1771
}
1772
+ /*
1773
+ // FILE IS ALWAYS THE PARENT FOLDER SO WE NOW CHECK FOLDER_SHARING AT A HIGHER LEVEL
1774
+ $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
1742
1775
$foldersharing = $this->getFilteredOption("ENABLE_FOLDER_SHARING", $this->repository->getId());
1743
- if (isset ($ foldersharing ) && ($ foldersharing === false || (is_string ($ foldersharing ) && $ foldersharing == "disable " ))) {
1776
+ $foldersharingDisabled = isset($foldersharing) && ($foldersharing === false || (is_string($foldersharing) && $foldersharing == "disable"));
1777
+ if (is_dir($this->urlBase.$file) && $foldersharingDisabled) {
1744
1778
return 103;
1745
1779
}
1780
+ */
1746
1781
$ loggedUser = AuthService::getLoggedUser ();
1747
1782
$ actRights = $ loggedUser ->mergedRole ->listActionsStatesFor ($ repository );
1748
1783
if (isSet ($ actRights ["share " ]) && $ actRights ["share " ] === false ) {
@@ -1883,7 +1918,7 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
1883
1918
if (isSet ($ data ["USE_SESSION_CREDENTIALS " ]) && $ data ["USE_SESSION_CREDENTIALS " ] === true ) {
1884
1919
$ options ["META_SOURCES " ][$ index ]["ENCODED_CREDENTIALS " ] = AJXP_Safe::getEncodedCredentialString ();
1885
1920
}
1886
- if ($ index == "meta.syncable " && $ data ["REPO_SYNCABLE " ] === true ){
1921
+ if ($ index == "meta.syncable " && (! isSet ( $ data ["REPO_SYNCABLE " ]) || $ data [ " REPO_SYNCABLE " ] === true ) ){
1887
1922
$ data ["REQUIRES_INDEXATION " ] = true ;
1888
1923
}
1889
1924
}
0 commit comments