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

Commit

Permalink
Set Inbox workspace rw (not only r) and manage various actions by eit…
Browse files Browse the repository at this point in the history
…her not importing them or disabling them. Disable "write" in stat based on shared repository permission.
  • Loading branch information
cdujeu committed Mar 17, 2016
1 parent dc8749b commit 6f39bb2
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 33 deletions.
2 changes: 1 addition & 1 deletion core/src/conf/bootstrap_repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"AJXP_SLUG" => "inbox",
"DRIVER" => "inbox",
"DRIVER_OPTIONS" => array(
"DEFAULT_RIGHTS" => "r"
"DEFAULT_RIGHTS" => "rw"
)
);

Expand Down
24 changes: 24 additions & 0 deletions core/src/plugins/access.inbox/class.inboxAccessDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public static function getNodeData($nodePath){
}catch (Exception $e){
$stat = stat(AJXP_Utils::getAjxpTmpDir());
}
if(is_array($stat) && AuthService::getLoggedUser() != null){
$acl = AuthService::getLoggedUser()->mergedRole->getAcl($nodeData["meta"]["shared_repository_id"]);
if($acl == "r"){
self::disableWriteInStat($stat);
}
}
}
$nodeData["stat"] = $stat;
}
Expand Down Expand Up @@ -167,6 +173,13 @@ public static function getNodes($checkStats = false){
}else if($ext == "error"){
$label .= " (".$mess["inbox_driver.5"].")";
}
if(is_array($stat) && AuthService::getLoggedUser() != null){
$acl = AuthService::getLoggedUser()->mergedRole->getAcl($repoId);
if($acl == "r"){
self::disableWriteInStat($stat);
}

}

}

Expand Down Expand Up @@ -198,4 +211,15 @@ public static function getNodes($checkStats = false){
}
return $output;
}

/**
* @param array $stat
*/
protected static function disableWriteInStat(&$stat){
$octRights = decoct($stat["mode"]);
$last = (strlen($octRights)) - 1;
$octRights[$last] = $octRights[$last-1] = $octRights[$last-2] = 5;
$stat["mode"] = $stat[2] = octdec($octRights);
}

}
27 changes: 0 additions & 27 deletions core/src/plugins/access.inbox/class.inboxAccessWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,33 +407,6 @@ public function url_stat($path, $flags)
{
$nodeData = inboxAccessDriver::getNodeData($path);
return $nodeData["stat"];

$url = self::translateURL($path);
if(strpos($url, "invitation") === 0){
return stat(__FILE__);
}
if($url == null){
return false;
}
$stat = stat($url);
if($stat === false){
return false;
}
if(self::$linkNode !== null){
ConfService::loadDriverForRepository(self::$linkNode->getRepository());
}
//$this->disableWriteInStat($stat);
return $stat;
}

/**
* @param array $stat
*/
protected function disableWriteInStat(&$stat){
$octRights = decoct($stat["mode"]);
$last = (strlen($octRights)) - 1;
$octRights[$last] = $octRights[$last-1] = $octRights[$last-2] = 5;
$stat["mode"] = $stat[2] = octdec($octRights);
}

}
122 changes: 121 additions & 1 deletion core/src/plugins/access.inbox/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
</client_settings>
<registry_contributions>
<external_file filename="plugins/access.fs/fsTemplatePart.xml" include="client_configs/*" exclude=""/>
<external_file filename="plugins/access.fs/fsActions.xml" include="actions/*" exclude="actions/action[@name='download_all']|actions/action[@name='download']"/>
<external_file filename="plugins/access.fs/fsActions.xml"
include="actions/*"
exclude="actions/action[@name='download_all']|actions/action[@name='download']|actions/action[@name='download_chunk']|actions/action[@name='rename']|actions/action[@name='move']|actions/action[@name='copy']|actions/action[@name='delete']|actions/action[@name='chmod']|actions/action[@name='compress']|actions/action[@name='compress_ui']"/>
<external_file filename="plugins/access.fs/fsActions.xml" include="client_configs/*" exclude=""/>
<external_file filename="plugins/access.fs/manifest.xml" include="registry_contributions/hooks/*" exclude=""/>

Expand Down Expand Up @@ -82,6 +84,124 @@
</serverCallback>
</processing>
</action>
<action name="copy_inbox" ctrlDragndropDefault="true">
<gui text="inbox_driver.14" title="inbox_driver.15" src="editcopy.png" iconClass="icon-copy" hasAccessKey="false">
<context selection="true" dir="" recycle="hidden"
actionBar="true" contextMenu="true" infoPanel="false"
actionBarGroup="change_main">
</context>
<selectionContext dir="false" file="true" recycle="false" unique="false"/></gui>
<rightsContext noUser="true" userLogged="only" read="true" write="false" adminOnly=""/>
<processing>
<clientCallback prepareModal="true"><![CDATA[
if(pydio.user){
var user = pydio.user;
var activeRepository = user.getActiveRepository();
}
var context = pydio.getController();
var onLoad = function(oForm){
var getAction = oForm.select('input[name="get_action"]')[0];
getAction.value = 'copy';
this.treeSelector = new TreeSelector(oForm, {
nodeFilter : function(ajxpNode){
return (!ajxpNode.isLeaf() && !ajxpNode.hasMetadataInBranch("ajxp_readonly", "true"));
}
});
if(user && user.canCrossRepositoryCopy() && user.hasCrossRepositories()){
var firstKey ;
var reposList = new Hash();
ProtoCompat.map2hash(user.getCrossRepositories()).each(function(pair){
if(!firstKey) firstKey = pair.key;
reposList.set(pair.key, pair.value.getLabel());
}.bind(this));
var nodeProvider = new RemoteNodeProvider();
nodeProvider.initProvider({tmp_repository_id:firstKey});
var rootNode = new AjxpNode("/", false, MessageHash[373], "folder.png", nodeProvider);
this.treeSelector.load(rootNode);
this.treeSelector.setFilterShow(true);
reposList.each(function(pair){
this.treeSelector.appendFilterValue(pair.key, pair.value);
}.bind(this));
this.treeSelector.setFilterSelectedIndex(0);
this.treeSelector.setFilterChangeCallback(function(e){
externalRepo = this.filterSelector.getValue();
var nodeProvider = new RemoteNodeProvider();
nodeProvider.initProvider({tmp_repository_id:externalRepo});
this.resetAjxpRootNode(new AjxpNode("/", false, MessageHash[373], "folder.png", nodeProvider));
});
}else{
this.treeSelector.load();
}
}.bind(context);
var onCancel = function(){
this.treeSelector.unload();
hideLightBox();
}.bind(context);
var onSubmit = function(){
var oForm = modal.getForm();
var getAction = oForm.select('input[name="get_action"]')[0];
var selectedNode = this.treeSelector.getSelectedNode();
if(activeRepository && this.treeSelector.getFilterActive(activeRepository)){
getAction.value = "cross_copy" ;
}
pydio.getUserSelection().updateFormOrUrl(oForm);
this.submitForm(oForm);
this.treeSelector.unload();
hideLightBox();
}.bind(context);
modal.showDialogForm('Move/Copy', 'copymove_form', onLoad, onSubmit, onCancel);
]]></clientCallback>
<clientForm id="copymove_form"><![CDATA[
<div id="copymove_form" action="copy" box_width="272">
<input type="hidden" name="dest_node" value=""/>
<div class="dialogLegend">AJXP_MESSAGE[175]</div>
<select id="external_repository" name="dest_repository_id" style="width: 248px; font-size: 12px; height: 21px; margin-top:5px; margin-bottom:7px; border: 1px solid #ccc;"></select>
<div style="height:200px; width:246px; padding: 0px 0px; border: 1px solid #ccc;">
<div id="treeCopy" style="height:194px; padding: 3px 2px; overflow:auto; text-align:left;" class="treeCopyContainer"></div>
</div>
<input type="text" name="dest" value="/" readonly style="width:248px; border: 1px solid #ccc; margin-top:7px; margin-bottom:2px;background-image:none;"/>
</div>
]]></clientForm>
<clientListener name="contextChange"><![CDATA[
if(pydio){
var action = pydio.getController().getActionByName("copy");
if(action){
action.rightsContext.write = true;
var ajxpUser = pydio.user;
if(ajxpUser && !ajxpUser.canWrite() && ajxpUser.canCrossRepositoryCopy() && ajxpUser.hasCrossRepositories()){
action.rightsContext.write = false;
pydio.getController().defaultActions['delete']('ctrldragndrop');
pydio.getController().defaultActions['delete']('dragndrop');
}
if(ajxpUser && ajxpUser.canWrite() && pydio.getContextNode().hasAjxpMimeInBranch("ajxp_browsable_archive")){
action.rightsContext.write = false;
}
if(pydio.getContextNode().hasAjxpMimeInBranch("ajxp_browsable_archive")){
action.setLabel(247, 248);
action.setIconSrc('ark_extract.png');
}else{
action.setLabel(66, 159);
action.setIconSrc('editcopy.png');
}
}
}
]]></clientListener>
<serverCallback methodName="switchAction" restParams="/" developerComment="Copy one or more items to a given target">
<input_param description="Selection" name="nodes" type="AJXP_NODE[]" mandatory="true"/>
<input_param description="Target folder where to copy" name="dest" type="path" mandatory="true"/>
</serverCallback>
</processing>
</action>
<action name="share_react" forbidOverride="true"/>
<action name="share" forbidOverride="true"/>
<action name="get_my_feed" forbidOverride="true"/>
<action name="mkdir" forbidOverride="true"/>
<action name="upload" forbidOverride="true"/>
<action name="compress" forbidOverride="true"/>
<action name="compress_ui" forbidOverride="true"/>
</actions>
<client_configs>
<component_config className="FilesList">
Expand Down
4 changes: 3 additions & 1 deletion core/src/plugins/access.inbox/res/i18n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"10" => "By Type",
"11" => "Clear",
"12" => "Shared Files",
"13" => "Files shared with me by other users"
"13" => "Files shared with me by other users",
"14" => "Copy to a workspace",
"15" => "Copy file to another of your workspaces",
);
4 changes: 3 additions & 1 deletion core/src/plugins/access.inbox/res/i18n/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"10" => "Par type",
"11" => "Vider",
"12" => "Fichiers Partagés",
"13" => "Les fichiers partagés avec moi par d'autres utilisateurs"
"13" => "Les fichiers partagés avec moi par d'autres utilisateurs",
"14" => "Copier dans un workspace",
"15" => "Copier dans un autre de vos workspaces",
);
5 changes: 3 additions & 2 deletions core/src/plugins/action.share/class.ShareRightsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ public function assignSharedRepositoryPermissions($parentRepository, $childRepos
// ADD "my shared files" REPO OTHERWISE SOME USER CANNOT ACCESS
if( !isSet($userEntry["HIDDEN"]) && $childRepository->hasContentFilter()){
$inboxRepo = ConfService::getRepositoryById("inbox");
if($inboxRepo !== null){
$userObject->personalRole->setAcl("inbox", "r");
$currentAcl = $userObject->mergedRole->getAcl("inbox");
if($inboxRepo !== null && empty($currentAcl)){
$userObject->personalRole->setAcl("inbox", "rw");
}
}

Expand Down

0 comments on commit 6f39bb2

Please sign in to comment.