Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2021-01-20 19:41:32 +0300
committerPhie <phie@phie.ovh>2021-01-20 19:41:32 +0300
commitab19f9c79df0a602a0c06e9dc86ff0ab9e2b09ad (patch)
tree57681a323a476d38c732e34bb95cfc2d79c5e49a
parente94f50bec2f7d4e9e2bdbd698b95aeb6a271611e (diff)
new option to create folder notes by default
-rwxr-xr-xappinfo/routes.php5
-rwxr-xr-xlib/Controller/NoteController.php59
2 files changed, 56 insertions, 8 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 30a2f98..d1c3226 100755
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -71,5 +71,10 @@ return [
['name' => 'note#importArchive', 'url' => '/note/import_archive', 'verb' => 'POST'],
['name' => 'note#getNote', 'url' => '/note/get_note', 'verb' => 'GET'],
+
+ ['name' => 'note#setShouldUseFolderNotes', 'url' => '/settings/note_folder', 'verb' => 'POST' ],
+ ['name' => 'note#shouldUseFolderNotes', 'url' => '/settings/note_folder', 'verb' => 'GET' ],
+
+
]
]; \ No newline at end of file
diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php
index b28f1dc..be4a6e1 100755
--- a/lib/Controller/NoteController.php
+++ b/lib/Controller/NoteController.php
@@ -777,21 +777,52 @@ public function getOpusEncoder(){
try{
$outFolder = $this->CarnetFolder->get($path);
if($this->CarnetFolder->get($path)->getType() === "dir"){
- $meta = array();
- foreach($files as $file){
- $inFolder->get($file)->copy($outFolder->getFullPath($file));
- }
-
-
- return $outFolder->getFileInfo()->getMtime();
+ return $this->saveOpenNoteAsDir($inFolder, $files, $path, $id);
+ } else {
+ $this->saveOpenNote($_POST['path'],$id);
+ return false;
}
} catch(\OCP\Files\NotFoundException $e) {
+ if($this->shouldUseFolderNotes()){
+ return $this->saveOpenNoteAsDir($inFolder, $files, $path, $id);
+ } else {
+ $this->saveOpenNote($_POST['path'],$id);
+ return false;
+ }
}
- $this->saveOpenNote($_POST['path'],$id);
+
return false;
}
+ private function saveOpenNoteAsDir($inFolder, $files, $path, $id){
+ if($this->CarnetFolder->nodeExists($path)){
+ $outFolder = $this->CarnetFolder->get($path);
+ }
+ else {
+ $outFolder = $this->CarnetFolder->newFolder($path);
+ }
+
+
+
+ $meta = array();
+ foreach($files as $file){
+ $parent = dirname($file);
+ if($parent != "/" AND $parent != "" AND $parent != Null AND !empty($parent) AND $parent != "."){
+ if(!$outFolder->nodeExists($parent)){
+ $outFolder->newFolder($parent);
+
+ }
+
+ //
+
+
+ }
+ $inFolder->get($file)->copy($outFolder->getFullPath($file));
+ }
+ return $outFolder->getFileInfo()->getMtime();
+ }
+
/*
returns false if target note is not a folder or mTime if it is
*/
@@ -1250,6 +1281,18 @@ public function getOpusEncoder(){
// empty for now
}
+ public function shouldUseFolderNotes(){
+ return $this->Config->getUserValue($this->userId, $this->appName, "should_use_folder_notes",false);
+ }
+
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ */
+ public function setShouldUseFolderNotes($useFolder){
+ return $this->Config->setUserValue($this->userId, $this->appName, "should_use_folder_notes", $useFolder);
+ }
+
/**
* @NoAdminRequired
* @NoCSRFRequired