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

Commit

Permalink
Action.quicksend: new experimental plugin to upload, share and send a…
Browse files Browse the repository at this point in the history
…t once. Adds a tab in the user dashboard. To be toughened if some components are missing (share, mailer, etc...)
  • Loading branch information
cdujeu committed Dec 17, 2013
1 parent 8c4017f commit f641276
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 0 deletions.
104 changes: 104 additions & 0 deletions core/src/plugins/action.quicksend/class.QuicksendManager.js
@@ -0,0 +1,104 @@
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*
*/
Class.create("QuicksendManager", AjxpPane, {

initialize: function($super, oFormObject, options){

$super(oFormObject, options);
QuicksendManager.INSTANCE = this;
oFormObject.down('#big_upload_button').observe("click", function(){
QuicksendManager.INSTANCE.applyUpload();
});

},

applyUpload: function(){

var uploaders = ajaxplorer.getActiveExtensionByType("uploader");
if(uploaders.length){
var uploader = uploaders[0];
if(ajaxplorer.actionBar.getActionByName("trigger_remote_copy")){
modal.setCloseAction(function(){
ajaxplorer.fireContextRefresh();
var bgManager = ajaxplorer.actionBar.bgManager;
bgManager.queueAction("trigger_remote_copy", new Hash(), "Copying files to server");
bgManager.next();
});
}
if(uploader.dialogOnOpen){
uploader.resourcesManager.load();
var dialogOnOpen = new Function("oForm", uploader.dialogOnOpen);
}
if(uploader.dialogOnComplete){
uploader.resourcesManager.load();
var dialogOnComplete = new Function("oForm", uploader.dialogOnComplete);
}
var original = ajxpBootstrap.parameters.get('ajxpServerAccess');
var origSecure = Connexion.SECURE_TOKEN;
window.ajxpServerAccessPath = ajxpBootstrap.parameters.set('ajxpServerAccess', original + '&tmp_repository_id=0');
Connexion.SECURE_TOKEN = origSecure + '&tmp_repository_id=0';
document.observeOnce('ajaxplorer:longtask_finished', function(){
var connex = new Connexion();
connex.setParameters({
get_action:'share',
dir:'/',
file:ajaxplorer.getContextHolder().getRootNode().getChildren()[0].getPath()
});
connex.onComplete = function(transport){
var linkURL = transport.responseText;
if(ajaxplorer.hasPluginOfType("mailer")){
var s, message;
s = 'A user from %s shared a file with you: ';
if(s) s = s.replace("%s", ajaxplorer.appTitle);
message = s + "\n\n " + linkURL;
var mailer = new AjxpMailer();
var usersList = null;
ajaxplorer.disableAllKeyBindings();
var mailerPane = mailer.buildMailPane('A user from %s shared a file with you: '.replace("%s", ajaxplorer.appTitle), message, usersList, 'Send the weblink by email');
mailerPane.setStyle({width:'420px'});
modal.showSimpleModal(
$('content_pane'),
mailerPane,
function(){
mailer.postEmail();
ajaxplorer.enableAllKeyBindings();
return true;
},function(){
ajaxplorer.enableAllKeyBindings();
return true;
});
}
ajaxplorer.fireContextRefresh();
};
connex.sendAsync();

ajxpBootstrap.parameters.set('ajxpServerAccess', original);
window.ajxpServerAccessPath = original;
Connexion.SECURE_TOKEN = origSecure;
});
modal.prepareHeader(MessageHash['action.quicksend.3'], '', 'icon-upload-alt');
modal.showDialogForm('Upload', uploader.formId, dialogOnOpen, null, dialogOnComplete, true, true);
}

}


});
27 changes: 27 additions & 0 deletions core/src/plugins/action.quicksend/i18n/en.php
@@ -0,0 +1,27 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/

$mess = array(
"1" => "Quick Send",
"2" => "Send a file, share it and email the link at once",
"3" => "Select a file",
"4" => "Click to select a file, or drop it in the zone below",
);
27 changes: 27 additions & 0 deletions core/src/plugins/action.quicksend/i18n/fr.php
@@ -0,0 +1,27 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/

$mess = array(
"1" => "Envoi rapide",
"2" => "Envoyer un fichier, le partager et envoyer le lien par email d'un coup",
"3" => "Selectionner un fichier",
"4" => "Cliquer pour sélectionner un fichier, ou le glisser dans la zone",
);
56 changes: 56 additions & 0 deletions core/src/plugins/action.quicksend/manifest.xml
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ajxp_plugin enabled="false" id="action.quicksend" label="CONF_MESSAGE[Quick Send (experimental)]" description="CONF_MESSAGE[Send, share and email the link at once, from the user dashboard.]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">

<plugin_info>
<core_relation packaged="true" tested_version="follow_core"/>
<plugin_author>Charles du Jeu</plugin_author>
</plugin_info>

<client_settings>
<resources>
<js className="QuicksendManager" file="plugins/action.quicksend/class.QuicksendManager.js" autoload="true"/>
<i18n namespace="action.quicksend" path="plugins/action.quicksend/i18n"/>
</resources>
</client_settings>

<dependencies>
<activePlugin pluginName="access.ajxp_user"/>
</dependencies>

<registry_contributions>
<client_configs>
<component_config className="AjxpTabulator::userdashboard_main_tab">
<additional_tab id="qsmanager"
tabInfo='{"id":"qsmanager","iconClass":"icon-upload-alt","element":"qsmanager","closeable":false,"label":"action.quicksend.1","title":"action.quicksend.2","dontFocus":true, "position":2}'
paneInfo='{"type":"widget"}'><![CDATA[
<div ajxpClass="QuicksendManager" id="qsmanager" ajxpOptions='{"fit":"height"}'>
<div id="big_upload_button" style="margin: 5px;text-align: center;background-color: #e35d52;color: white;padding: 15px;border-radius: 3px;cursor: pointer;">AJXP_MESSAGE[action.quicksend.4]</div>
<div id="content_pane" ajxpClass="FilesList" ajxpOptions='{"fit":"height", "fitMarginBottom":5}'></div>
</div>
]]></additional_tab>
</component_config>
</client_configs>
<actions>
<action name="upload">
<gui text="27" title="27" src="yast_backup.png" iconClass="icon-upload-alt" accessKey="upload_access_key" hasAccessKey="true">
<context selection="false" dir="true" recycle="hidden"
actionBar="true" contextMenu="true" infoPanel="false"
actionBarGroup="put,minisite" inZip="false">
</context></gui>
<rightsContext noUser="true" userLogged="only" read="false" write="true" adminOnly=""></rightsContext>
<processing>
<clientCallback prepareModal="true"><![CDATA[
if(!window.QuicksendManager.INSTANCE){
window.QuicksendManager.INSTANCE = new QuicksendManager();
}
window.QuicksendManager.INSTANCE.applyUpload();
]]></clientCallback>
<serverCallback methodName="switchAction" restParams="/input_stream/dir+" sdkMethodName="upload" checkParams="false">
<input_param description="filename" name="node" type="string"/>
</serverCallback>
</processing>
</action>
</actions>
</registry_contributions>

</ajxp_plugin>

0 comments on commit f641276

Please sign in to comment.