Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions js/mindmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ var FilesMindMap = {
plugin.encode(data).then(function(data2) {
var putObject = {
filecontents: data2,
path: path
path: path,
mtime: OCA.FilesMindMap._file.mtime // send modification time of currently loaded file
};

if ($('#isPublic').val()){
Expand All @@ -180,7 +181,11 @@ var FilesMindMap = {
type: 'PUT',
url: url,
data: putObject
}).done(function(){
}).done(function(data){
// update modification time
try {
OCA.FilesMindMap._file.mtime = data.mtime;
} catch(e) {}
success(t('files_mindmap', 'File Saved'));
}).fail(function(jqXHR){
var message = t('files_mindmap', 'Save failed');
Expand Down
3 changes: 2 additions & 1 deletion l10n/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OC.L10N.register(
"Unsaved file": "Ungespeicherte Datei",
"AutoSave": "AutoSave",
"Does not support saving {extension} files.": "Speichern für den Dateityp {extension} nicht unterstützt.",
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}"
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}",
"The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.": "Jemand hat in der Zwischenzeit die Datei aktualisiert, daher kannst du deine Änderungen leider nicht speichern. Bitte lade die Datei neu, um weiteren Datenverlust zu vermeiden."
}, "nplurals=1; plural=0;"
);
3 changes: 2 additions & 1 deletion l10n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"Unsaved file": "Ungespeicherte Datei",
"AutoSave": "AutoSave",
"Does not support saving {extension} files.": "Speichern für den Dateityp {extension} nicht unterstützt.",
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}"
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}",
"The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.": "Jemand hat in der Zwischenzeit die Datei aktualisiert, daher kannst du deine Änderungen leider nicht speichern. Bitte lade die Datei neu, um weiteren Datenverlust zu vermeiden."
},
"pluralForm": "nplurals=1; plural=0;"
}
3 changes: 2 additions & 1 deletion l10n/de_DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OC.L10N.register(
"Unsaved file": "Ungespeicherte Datei",
"AutoSave": "AutoSave",
"Does not support saving {extension} files.": "Speichern für den Dateityp {extension} nicht unterstützt.",
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}"
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}",
"The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.": "Jemand hat in der Zwischenzeit die Datei aktualisiert, daher kannst du deine Änderungen leider nicht speichern. Bitte lade die Datei neu, um weiteren Datenverlust zu vermeiden."
}, "nplurals=1; plural=0;"
);
3 changes: 2 additions & 1 deletion l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"Unsaved file": "Ungespeicherte Datei",
"AutoSave": "AutoSave",
"Does not support saving {extension} files.": "Speichern für den Dateityp {extension} nicht unterstützt.",
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}"
"Unsupported file type: {mimetype}": "Nicht unterstützter Dateityp: {mimetype}",
"The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.": "Jemand hat in der Zwischenzeit die Datei aktualisiert, daher kannst du deine Änderungen leider nicht speichern. Bitte lade die Datei neu, um weiteren Datenverlust zu vermeiden."
},
"pluralForm": "nplurals=1; plural=0;"
}
6 changes: 5 additions & 1 deletion lib/Controller/FileHandlingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function load($dir, $filename) {
* @param string $filecontents
* @return DataResponse
*/
public function save($path, $filecontents) {
public function save($path, $filecontents, $mtime) {
try {
if($path !== '') {

Expand All @@ -128,6 +128,10 @@ public function save($path, $filecontents) {
}

if($file->isUpdateable()) {
if ($mtime != $file->getMTime()) {
$this->logger->error("User cannot save shared mindmap (someone updated it in the meantime): {$mtime} vs. {$file->getMTime()} {$file->getPath()}", ['app' => 'files_mindmap']);
return new DataResponse([ 'message' => $this->l->t('The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.')],Http::STATUS_BAD_REQUEST);
}
try {
$file->putContent($filecontents);
} catch (LockedException $e) {
Expand Down
12 changes: 11 additions & 1 deletion lib/Controller/PublicFileHandlingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\Files\GenericFileException;
use OCP\Files\NotFoundException;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\ISession;
use OCP\Lock\LockedException;
Expand All @@ -41,6 +42,9 @@ class PublicFileHandlingController extends Controller{
/** @var IL10N */
private $l;

/** @var ILogger */
private $logger;

/** @var ShareManager */
private $shareManager;

Expand All @@ -58,10 +62,12 @@ class PublicFileHandlingController extends Controller{
public function __construct($AppName,
IRequest $request,
IL10N $l10n,
ILogger $logger,
ShareManager $shareManager,
ISession $session) {
parent::__construct($AppName, $request);
$this->l = $l10n;
$this->logger = $logger;
$this->shareManager = $shareManager;
$this->session = $session;
}
Expand Down Expand Up @@ -155,7 +161,7 @@ public function load($token) {
* @throws \OCP\Files\InvalidPathException
* @throws \OCP\Files\NotPermittedException
*/
public function save($token, $filecontents, $path) {
public function save($token, $filecontents, $path, $mtime) {
try {
$share = $this->shareManager->getShareByToken($token);
} catch (ShareNotFound $e) {
Expand Down Expand Up @@ -193,6 +199,10 @@ public function save($token, $filecontents, $path) {
}

if($file->isUpdateable()) {
if ($mtime != $file->getMTime()) {
$this->logger->error("Anonymous cannot save shared mindmap (someone updated it in the meantime): {$mtime} vs. {$file->getMTime()} {$file->getPath()}", ['app' => 'files_mindmap']);
return new DataResponse([ 'message' => $this->l->t('The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.')],Http::STATUS_BAD_REQUEST);
}
try {
$file->putContent($filecontents);
} catch (LockedException $e) {
Expand Down
4 changes: 2 additions & 2 deletions templates/viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/hotbox/hotbox.css')) ?>?v=<?php p($version) ?>" />
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/kityminder-core/dist/kityminder.core.css')) ?>?v=<?php p($version) ?>" />
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/color-picker/dist/color-picker.min.css')) ?>?v=<?php p($version) ?>" />


<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/kityminder-editor/kityminder.editor.min.css')) ?>?v=<?php p($version) ?>">
<link rel="stylesheet" href="<?php echo(\OC::$WEBROOT . "/themes/" . \OC_Util::getTheme() . "/apps/files_mindmap/css/style.css") /* add custom css to iframe */ ?>" />


<style>
html, body {
Expand Down