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

Commit

Permalink
Add a canWrite attribute on editors declaration, use it in ShareDialo…
Browse files Browse the repository at this point in the history
…g to detect if a file has "writeable" editors and show an additional Edit permission for public links on files.
  • Loading branch information
cdujeu committed Apr 7, 2016
1 parent 7bff85f commit 372cf7e
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 27 deletions.
44 changes: 25 additions & 19 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -907,29 +907,35 @@ public function nodeSharedMetadata(&$ajxpNode)
*/
public function updateNodeSharedData($oldNode=null, $newNode=null, $copy = false){

if($oldNode != null && !$copy){
$this->logDebug("Should update node");
if($oldNode == null || $copy){
// Create or copy, do nothing
return;
}
if($oldNode != null && $newNode != null && $oldNode->getUrl() == $newNode->getUrl()){
// Same path => must be a content update, do nothing
return;
}

$delete = false;
if($newNode == null) {
$this->logDebug("Should update node");
$delete = false;
if($newNode == null) {
$delete = true;
}else{
$repo = $newNode->getRepository();
$recycle = $repo->getOption("RECYCLE_BIN");
if(!empty($recycle) && strpos($newNode->getPath(), $recycle) === 1){
$delete = true;
}else{
$repo = $newNode->getRepository();
$recycle = $repo->getOption("RECYCLE_BIN");
if(!empty($recycle) && strpos($newNode->getPath(), $recycle) === 1){
$delete = true;
}
}
$shareStore = $this->getShareStore();
$modifiedNodes = $shareStore->moveSharesFromMetaRecursive($oldNode, $delete, $oldNode->getPath(), ($newNode != null ? $newNode->getPath() : null));
// Force switching back to correct driver!
if($modifiedNodes > 0){
$oldNode->getRepository()->driverInstance = null;
$oldNode->setDriver(null);
$oldNode->getDriver();
}
return;
}
$shareStore = $this->getShareStore();
$modifiedNodes = $shareStore->moveSharesFromMetaRecursive($oldNode, $delete, $oldNode->getPath(), ($newNode != null ? $newNode->getPath() : null));
// Force switching back to correct driver!
if($modifiedNodes > 0){
$oldNode->getRepository()->driverInstance = null;
$oldNode->setDriver(null);
$oldNode->getDriver();
}
return;

}

Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/ca.php
Expand Up @@ -82,6 +82,7 @@
"72" => "Cercar i previsualitzar",
"73" => "Descarregar",
"74" => "Carregar fitxers",
"74b"=>"Edit",
"75" => "Per favor emprau un nombre positiu tant per la caducitat com per el límit de descàrrega.",
"76" => "Per favor habilitau les Cookies per a accedir a aquesta aplicació",
"77" => "Per favor habilitau JavaScript per a accedir a aquesta aplicació",
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/de.php
Expand Up @@ -83,6 +83,7 @@
"72" => "Ansehen",
"73" => "Herunterladen",
"74" => "Hochladen",
"74b"=>"Edit",
"75"=> "Bitte verwenden Sie eine positive Zahl für die Verfall- und Downloadbegrenzung.",
"76"=> "Bitte Cookies aktivieren um auf diese Anwendung zuzugreifen",
"77"=> "Bitte JavaScript aktivieren um auf diese Anwendung zuzugreifen",
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/en.php
Expand Up @@ -83,6 +83,7 @@
"72"=> "Preview",
"73"=> "Download",
"74"=> "Upload files",
"74b"=>"Edit",
"75"=> "Please use a positive number for both Expiration and Download limit fields.",
"76"=> "Please enable Cookies to access this application",
"77"=> "Please enable JavaScript to access this application",
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/es.php
Expand Up @@ -80,6 +80,7 @@
"72"=> "Previsualizar",
"73"=> "Descargar",
"74"=> "Cargar",
"74b"=>"Edit",
"75"=> "Por favor use un número positivo para Caducidad y Límite de Descargas.",
"76"=> "Por favor, habilite las cookies para acceder a esta aplicación",
"77"=> "Por favor, habilite JavaScript para acceder a esta aplicación",
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/fr.php
Expand Up @@ -82,6 +82,7 @@
"72"=> "Prévisualiser",
"73"=> "Télécharger",
"74"=> "Envoyer",
"74b"=>"Editer",
"75"=> "Veuillez utiliser des entiers positifs pour les champs Expiration et Nombre de téléchargements !",
"76"=> "Merci d'activer les cookies pour accéder à cette application",
"77"=> "Merci d'activer JavaScript pour accéder à cette application",
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/it.php
Expand Up @@ -81,6 +81,7 @@
"72"=> "Sfoglia & Anteprima",
"73"=> "Download",
"74"=> "Upload file",
"74b"=>"Edit",
"75"=> "Usare un numero positivo sia per la Scadenza che per il limite di Download.",
"76"=> "Abilitare i Cookies per accedere a questa applicazione",
"77"=> "Abilitare JavScript per accedere a questa applicazione",
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/pt.php
Expand Up @@ -80,6 +80,7 @@
"72"=> "Navegar & Pré-Visualização",
"73"=> "Transferir",
"74"=> "Enviar ficheiros",
"74b"=>"Edit",
"75"=> "Por favor utilize um número positivo tanto para o campo Validade como para o Limite Máximo de Transferências.",
"76"=> "Por favor active as cookies no seu Navegador para poder aceder a esta aplicação",
"77"=> "Por favor active o Javascript no seu Navegador para aceder a esta aplicação",
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/ru.php
Expand Up @@ -83,6 +83,7 @@
"72"=> "Предпросмотр",
"73"=> "Скачивание",
"74"=> "Загрузка файлов",
"74b"=>"Edit",
"75"=> "Используйте положительные значения для срока окончания и количества скачиваний.",
"76"=> "Включите куки для работы с программой",
"77"=> "Включите JavaScript для работы с программой",
Expand Down
5 changes: 5 additions & 0 deletions core/src/plugins/action.share/res/react/ShareDialog.js
Expand Up @@ -997,6 +997,11 @@
NAME:'write',
LABEL:this.context.getMessage('74')
});
}else if(this.props.shareModel.fileHasWriteableEditors()){
perms.push({
NAME:'write',
LABEL:this.context.getMessage('74b')
});
}
if(this.props.shareModel.isPublicLinkPreviewDisabled() && this.props.shareModel.getPublicLinkPermission(linkId, 'read')){
previewWarning = <div>{this.context.getMessage('195')}</div>;
Expand Down
7 changes: 7 additions & 0 deletions core/src/plugins/action.share/res/react/model/ShareModel.js
Expand Up @@ -63,6 +63,13 @@
return this._data['links'][linkId]['hash_is_shorten'];
}

fileHasWriteableEditors(){
console.log(this._previewEditors);
return this._previewEditors.filter(function(entry){
return (entry.canWrite);
}).length > 0;
}

togglePublicLink(){
var publicLinks = this.getPublicLinks();
this._pendingData['enable_public_link'] = !publicLinks.length;
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/core.ajaxplorer/ajxp_registry.xsd
Expand Up @@ -302,6 +302,7 @@
<xs:attribute name="text" use="required" type="xs:NMTOKEN"/>
<xs:attribute name="title" use="required" type="xs:NMTOKEN"/>
<xs:attribute name="write" type="xs:boolean"/>
<xs:attribute name="canWrite" type="xs:boolean"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.ckeditor/manifest.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.ckeditor" enabled="false" openable="true" iconClass="icon-underline"
order="-1" text="319" title="320" icon="ckeditor_images/html_edit.png"
className="AjxpCkEditor" mimes="html,htm" formId="edit_box" write="true"
className="AjxpCkEditor" mimes="html,htm" formId="edit_box" write="true" canWrite="true"
label="CONF_MESSAGE[CKEditor]" description="CONF_MESSAGE[Wysiwyg HTML Editor, requires separate library to be downloaded.]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<dependencies>
<pluginResources pluginName="editor.text"/>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.codemirror/manifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.codemirror" openable="true" text="code_mirror.1" iconClass="icon-text-height" title="code_mirror.2" icon="codemirror_images/source_edit.png" className="CodeMirrorEditor" mimes="xml,html,htm,js,json,css,php,phtml,sparql,txt,py,c#,java,jsp,sql,cgi,pl,inc,xsl," formId="codemirror_box" label="CONF_MESSAGE[Source Viewer]" description="CONF_MESSAGE[Syntax Highlighter for all major code source files]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<editor id="editor.codemirror" openable="true" canWrite="true" text="code_mirror.1" iconClass="icon-text-height" title="code_mirror.2" icon="codemirror_images/source_edit.png" className="CodeMirrorEditor" mimes="xml,html,htm,js,json,css,php,phtml,sparql,txt,py,c#,java,jsp,sql,cgi,pl,inc,xsl," formId="codemirror_box" label="CONF_MESSAGE[Source Viewer]" description="CONF_MESSAGE[Syntax Highlighter for all major code source files]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<client_settings>
<resources>
<i18n namespace="code_mirror" path="plugins/editor.codemirror/i18n" autoload="true"/>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.codepress/manifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.codepress" enabled="false" openable="true" iconClass="icon-text-height" text="317" title="318" icon="codepress_images/source_edit.png" className="CodePressEditor" mimes="php,php3,php4,php4,phtml,js,java,pl,sql,html,htm,xml,css,jsp" formId="edit_box" write="true" label="CONF_MESSAGE[CodePress]" description="CONF_MESSAGE[Legacy Syntax Highlighter]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<editor id="editor.codepress" enabled="false" openable="true" iconClass="icon-text-height" text="317" title="318" icon="codepress_images/source_edit.png" className="CodePressEditor" mimes="php,php3,php4,php4,phtml,js,java,pl,sql,html,htm,xml,css,jsp" formId="edit_box" write="true" canWrite="true" label="CONF_MESSAGE[CodePress]" description="CONF_MESSAGE[Legacy Syntax Highlighter]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<plugin_info>
<core_relation packaged="false" tested_version="4.0.4"/>
<plugin_author>Charles du Jeu</plugin_author>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.etherpad/manifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor enabled="false" id="editor.etherpad" openable="true" iconClass="icon-comments-alt" order="10"
text="etherpad.2" title="etherpad.3" icon="edit.png" className="EtherpadLauncher"
text="etherpad.2" title="etherpad.3" icon="edit.png" className="EtherpadLauncher" canWrite="true"
mimes="pad" formId="ether_box" label="CONF_MESSAGE[Etherpad]" description="CONF_MESSAGE[Collaborative edition of text files]"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<client_settings>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.pixlr/manifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.pixlr" openable="true" iconClass="icon-edit" text="333" title="333" icon="pixlr_images/actions/ICON_SIZE/color_fill.png" className="PixlrEditor" mimes="jpg,jpeg,png,bmp,pxd" formId="pixlr_box" write="true" label="CONF_MESSAGE[Pixlr Editor]" description="CONF_MESSAGE[Bridge to the Pixlr.com webservice that allow online image edition via a photoshop-like GUI.]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<editor id="editor.pixlr" openable="true" iconClass="icon-edit" text="333" title="333" icon="pixlr_images/actions/ICON_SIZE/color_fill.png" className="PixlrEditor" mimes="jpg,jpeg,png,bmp,pxd" formId="pixlr_box" write="true" canWrite="true" label="CONF_MESSAGE[Pixlr Editor]" description="CONF_MESSAGE[Bridge to the Pixlr.com webservice that allow online image edition via a photoshop-like GUI.]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<class_definition filename="plugins/editor.pixlr/class.PixlrEditor.php" classname="PixlrEditor"/>
<server_settings>
<global_param
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.text/manifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.text" openable="true" iconClass="icon-edit" order="10" text="51" title="162" icon="edit.png" className="TextEditor" mimes="none" formId="edit_box" label="CONF_MESSAGE[Text Editor]" description="CONF_MESSAGE[Very basic text editor]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<editor id="editor.text" openable="true" iconClass="icon-edit" order="10" text="51" title="162" canWrite="true" icon="edit.png" className="TextEditor" mimes="none" formId="edit_box" label="CONF_MESSAGE[Text Editor]" description="CONF_MESSAGE[Very basic text editor]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<client_settings>
<resources>
<js file="plugins/editor.text/class.TextEditor.js" className="TextEditor"/>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.zoho/manifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.zoho" order="3" enabled="false" openable="true" text="zoho_editor.1" iconClass="icon-edit" title="zoho_editor.2" description="CONF_MESSAGE[Zoho editor]" icon="zoho_img/zoho.png" label="CONF_MESSAGE[Office Docs]" className="ZohoEditor" mimes="xls,xlsx,ods,sxc,csv,tsv,ppt,pptx,pps,odp,sxi,doc,docx,rtf,odt,sxw" formId="zoho_box" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<editor id="editor.zoho" order="3" enabled="false" openable="true" text="zoho_editor.1" iconClass="icon-edit" title="zoho_editor.2" canWrite="true" description="CONF_MESSAGE[Zoho editor]" icon="zoho_img/zoho.png" label="CONF_MESSAGE[Office Docs]" className="ZohoEditor" mimes="xls,xlsx,ods,sxc,csv,tsv,ppt,pptx,pps,odp,sxi,doc,docx,rtf,odt,sxw" formId="zoho_box" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<class_definition filename="plugins/editor.zoho/class.ZohoEditor.php" classname="ZohoEditor"/>
<server_settings>
<global_param name="ZOHO_LANGUAGE" type="string" description="CONF_MESSAGE[You can change ZOHO menu language (de, en, fr, it, pt, ru, ...)]" label="CONF_MESSAGE[Language]" mandatory="true" default="en"/>
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/gui.ajax/res/js/es6/model/Registry.es6
Expand Up @@ -146,7 +146,8 @@ class Registry{
icon_class : xmlNode.getAttribute("iconClass"),
editorClass : xmlNode.getAttribute("className"),
mimes : xmlNode.getAttribute("mimes").split(","),
write : (xmlNode.getAttribute("write") && xmlNode.getAttribute("write")=="true"?true:false)
write : (xmlNode.getAttribute("write") && xmlNode.getAttribute("write")=="true"?true:false),
canWrite: (xmlNode.getAttribute("canWrite") && xmlNode.getAttribute("canWrite")=="true"?true:false)
};
for(var k in properties){
if(properties.hasOwnProperty(k)){
Expand Down

0 comments on commit 372cf7e

Please sign in to comment.