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

Commit

Permalink
Another pass on inbox driver. Not sure it will be kept as is.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Mar 1, 2016
1 parent 698e1e4 commit f099d0e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 6 deletions.
20 changes: 20 additions & 0 deletions core/src/plugins/access.inbox/class.inboxAccessDriver.php
Expand Up @@ -53,6 +53,26 @@ public function loadNodeInfo(&$ajxpNode, $parentNode = false, $details = false)
if(!$leaf){
$meta["ajxp_mime"] = "shared_folder";
}
if($ajxpNode->getExtension() == "invitation"){

$label = $ajxpNode->getLabel();
$parts = explode(".", $label);
array_pop($parts);
$shareId = array_pop($parts);
$ajxpNode->setLabel(implode(".", $parts));
$meta["ajxp_mime"] = "invitation";
$meta["remote_share_id"] = $shareId;

}else if(strpos($repoId, "ocs_remote_share_") === 0){

$shareId = str_replace("ocs_remote_share_", "", $repoId);
$label = $ajxpNode->getLabel();
$label.= " (accepted)";
$ajxpNode->setLabel($label);
$meta["remote_share_accepted"] = "true";
$meta["remote_share_id"] = $shareId;

}
$ajxpNode->mergeMetadata($meta);
}
}
Expand Down
38 changes: 32 additions & 6 deletions core/src/plugins/access.inbox/class.inboxAccessWrapper.php
Expand Up @@ -48,14 +48,33 @@ protected static function getNodes(){
if(!$repo->hasOwner()){
continue;
}
$repoId = $repo->getId();
$url = "pydio://".$repoId."/";

if($repo->hasContentFilter()){
$cFilter = $repo->getContentFilter();
$filter = array_keys($cFilter->filters)[0];
self::$output[basename($filter)] = "pydio://".$repo->getId()."/".basename($filter);
$label = basename($filter);
if(strpos($repo->getId(), "ocs_remote_share") !== 0){
$url .= $label;
}
}else{
$label = $repo->getDisplay();
self::$output[$label] = "pydio://".$repo->getId()."/";
}

if(strpos($repoId, "ocs_remote_share_") === 0){
// Check Status
$linkId = str_replace("ocs_remote_share_", "", $repoId);
$ocsStore = new \Pydio\OCS\Model\SQLStore();
$remoteShare = $ocsStore->remoteShareById($linkId);
$status = $remoteShare->getStatus();
if($status == 1){
$label .= " (pending).".str_replace("ocs_remote_share_", "", $repoId).".invitation";
$url = __FILE__;
}
}

self::$output[$label] = $url;
}
return self::$output;
}
Expand Down Expand Up @@ -144,8 +163,11 @@ public static function getRealFSReference($path, $persistent = false)
public static function copyFileInStream($path, $stream)
{
$url = self::translateURL($path);
AJXP_MetaStreamWrapper::copyFileInStream($url, $stream);
/*
$wrapperClass = AJXP_MetaStreamWrapper::actualRepositoryWrapperClass(parse_url($url, PHP_URL_HOST));
call_user_func(array($wrapperClass, "copyFileInStream"), $url, $stream);
*/
if(self::$linkNode !== null){
ConfService::loadDriverForRepository(self::$linkNode->getRepository());
}
Expand Down Expand Up @@ -384,12 +406,16 @@ public function unlink($path)
*/
public function url_stat($path, $flags)
{
$origRepo = parse_url($path, PHP_URL_HOST);
$url = self::translateURL($path);
$targetRepo = parse_url($path, PHP_URL_PATH);
if(strpos($url, "invitation") === 0){
return stat(__FILE__);
}
if($url == null){
return false;
}
$stat = stat($url);
if($targetRepo != $origRepo){
$stat["rdev"] = $stat[6] = $targetRepo;
if($stat === false){
return false;
}
if(self::$linkNode !== null){
ConfService::loadDriverForRepository(self::$linkNode->getRepository());
Expand Down
36 changes: 36 additions & 0 deletions core/src/plugins/access.inbox/manifest.xml
Expand Up @@ -23,6 +23,42 @@
]]></clientCallback>
</processing>
</action>
<action name="accept_invitation">
<gui src="55" text="55" title="55" iconClass="icon-envelope">
<context dir="true" recycle="false" selection="true" actionBar="true" actionBarGroup="get,inline,info_panel_share"/>
<selectionContext dir="false" file="true" recycle="false" unique="true" allowedMimes="invitation"/>
</gui>
<processing>
<clientCallback><![CDATA[
var remoteShareId = pydio.getUserSelection().getUniqueNode().getMetadata().get("remote_share_id");
PydioApi.getClient().request({get_action:'accept_invitation', remote_share_id:remoteShareId});
]]></clientCallback>
</processing>
</action>
<action name="reject_invitation">
<gui src="56" text="56" title="56" iconClass="icon-envelope">
<context dir="true" recycle="false" selection="true" actionBar="true" actionBarGroup="get,inline,info_panel_share"/>
<selectionContext dir="false" file="true" recycle="false" unique="true" allowedMimes="invitation"/>
</gui>
<processing>
<clientCallback><![CDATA[
var remoteShareId = pydio.getUserSelection().getUniqueNode().getMetadata().get("remote_share_id");
PydioApi.getClient().request({get_action:'reject_invitation', remote_share_id:remoteShareId});
]]></clientCallback>
</processing>
</action>
<action name="reject_remote_share">
<gui src="55" text="55" title="55" iconClass="icon-envelope">
<context dir="true" recycle="false" selection="true" actionBar="true" actionBarGroup="get,inline,info_panel_share"/>
<selectionContext dir="false" file="true" recycle="false" unique="true" evalMetadata="metadata.get('remote_share_accepted')"/>
</gui>
<processing>
<clientCallback><![CDATA[
var remoteShareId = pydio.getUserSelection().getUniqueNode().getMetadata().get("remote_share_id");
PydioApi.getClient().request({get_action:'reject_invitation', remote_share_id:remoteShareId});
]]></clientCallback>
</processing>
</action>
<action name="download" fileDefault="false">
<gui text="88" title="88" src="download_manager.png" iconClass="icon-download-alt" accessKey="download_access_key" hasAccessKey="true">
<context selection="true" dir="" recycle="false"
Expand Down

0 comments on commit f099d0e

Please sign in to comment.