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>2019-09-30 13:58:29 +0300
committerPhie <phie@phie.ovh>2019-09-30 13:58:29 +0300
commit2383e8e81b27c851b7fbf4ffc746002d1bcb04e5 (patch)
tree7de2b1e1ee1b1a16f3d95d1f88939651138b5595
parent8e150cf67ec2ed933e7aeb41fa500ed253e1d3ee (diff)
extract in api
-rwxr-xr-xappinfo/routes.php1
-rwxr-xr-xlib/Controller/NoteController.php44
2 files changed, 44 insertions, 1 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 402ce6e..8a613fb 100755
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -25,6 +25,7 @@ return [
['name' => 'page#do_echo', 'url' => '/echo', 'verb' => 'POST'],
['name' => 'note#openNote', 'url' => '/note/open', 'verb' => 'GET'],
+ ['name' => 'note#extractNote', 'url' => '/note/extract', 'verb' => 'GET'],
['name' => 'note#createNote', 'url' => '/note/create', 'verb' => 'GET'],
['name' => 'note#saveTextToOpenNote', 'url' => '/note/saveText', 'verb' => 'POST'],
['name' => 'note#addMediaToOpenNote', 'url' => '/note/open/{id}/addMedia', 'verb' => 'POST'],
diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php
index 8cf0546..3adbf40 100755
--- a/lib/Controller/NoteController.php
+++ b/lib/Controller/NoteController.php
@@ -901,12 +901,54 @@ public function getOpusEncoder(){
} catch(\OCP\Files\NotFoundException $e) {
$data["error"] = "not found";
}
- shell_exec('php occ carnet:opennote '.escapeshellarg($this->userId).' '.escapeshellarg($path).' '.escapeshellarg($editUniqueID).'> /dev/null 2>/dev/null &');
$data['id'] = $editUniqueID;
return $data;
}
+
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ */
+ public function extractNote(){
+ $path = $_GET['path'];
+ $editUniqueID = $_GET['id'];
+ $cache = $this->getCacheFolder();
+ /*
+ because of an issue with nextcloud, working with a single currentnote folder is impossible...
+ */
+ foreach($cache->getDirectoryListing() as $in){
+ if(substr($in->getName(), 0, strlen("currentnote")) === "currentnote"){
+ $in->delete();
+ }
+ }
+ $folder = $cache->newFolder("currentnote".$editUniqueID);
+ try{
+ $tmppath = tempnam(sys_get_temp_dir(), uniqid().".zip");
+ file_put_contents($tmppath,$this->CarnetFolder->get($path)->fopen("r"));
+ $zipFile = new \PhpZip\ZipFile();
+ $zipFile->openFile($tmppath);
+ foreach($zipFile as $entryName => $contents){
+ if($entryName === ".extraction_finished")
+ continue;
+ if($contents === "" AND $zipFile->isDirectory($entryName)){
+ $folder->newFolder($entryName);
+ }
+ else if($contents !== "" && $contents !== NULL){
+ $parent = dirname($entryName);
+ if($parent !== "." && !$folder->nodeExists($parent)){
+ $folder->newFolder($parent);
+ }
+ $folder->newFile($entryName)->putContent($contents);
+ }
+ }
+ unlink($tmppath);
+ } catch(\OCP\Files\NotFoundException $e) {
+ }
+ $folder->newFile(".extraction_finished");
+ }
+
/**
* @NoAdminRequired
*