Skip to content

Commit

Permalink
Merge pull request #147 from ONLYOFFICE/develop
Browse files Browse the repository at this point in the history
Release/3.0.2
  • Loading branch information
LinneyS authored Sep 30, 2019
2 parents d890a58 + b8dcfa0 commit 2457828
Show file tree
Hide file tree
Showing 29 changed files with 307 additions and 205 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 3.0.2
## Changed
- federated share saving fixed

## 3.0.0
## Added
- "save as" to the folder
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ The table below will help you to make the right choice.
| Simultaneous connections | up to 20 maximum | As in chosen pricing plan |
| Number of users | up to 20 recommended | As in chosen pricing plan |
| License | GNU AGPL v.3 | Proprietary |
| **Support** | **Community Edition** | **Integration Edition** |
| **Support** | **Community Edition** | **Integration Edition** |
| Documentation | [Help Center](https://helpcenter.onlyoffice.com/server/docker/opensource/index.aspx) | [Help Center](https://helpcenter.onlyoffice.com/server/integration-edition/index.aspx) |
| Standard support | [GitHub](https://github.com/ONLYOFFICE/DocumentServer/issues) or paid | One year support included |
| Premium support | [Buy Now](https://www.onlyoffice.com/support.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) | [Buy Now](https://www.onlyoffice.com/support.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) |
| **Services** | **Community Edition** | **Integration Edition** |
| Conversion Service | + | + |
| Document Builder Service | - | + |
| **Services** | **Community Edition** | **Integration Edition** |
| Conversion Service | + | + |
| Document Builder Service | + | + |
| **Interface** | **Community Edition** | **Integration Edition** |
| Tabbed interface | - | + |
| Tabbed interface | + | + |
| White Label | - | - |
| Integrated test example (node.js)* | - | + |
| **Plugins & Macros** | **Community Edition** | **Integration Edition** |
Expand All @@ -70,27 +70,27 @@ The table below will help you to make the right choice.
| Comments | + | + |
| Built-in chat | + | + |
| Review and tracking changes | + | + |
| Display modes of tracking changes | - | + |
| Display modes of tracking changes | + | + |
| Version history | + | + |
| **Document Editor features** | **Community Edition** | **Integration Edition** |
| Font and paragraph formatting | + | + |
| Object insertion | + | + |
| Content control | - | + |
| Content control | + | + |
| Layout tools | + | + |
| Table of contents | + | + |
| Navigation panel | - | + |
| Navigation panel | + | + |
| Mail Merge | + | + |
| **Spreadsheet Editor features** | **Community Edition** | **Integration Edition** |
| Font and paragraph formatting | + | + |
| Object insertion | + | + |
| Functions, formulas, equations | + | + |
| Table templates | + | + |
| Pivot tables | - | +** |
| Pivot tables | +** | +** |
| **Presentation Editor features** | **Community Edition** | **Integration Edition** |
| Font and paragraph formatting | + | + |
| Object insertion | + | + |
| Animations | + | + |
| Presenter mode | - | + |
| Presenter mode | + | + |
| Notes | + | + |
| | [Get it now](https://www.onlyoffice.com/download.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) | [Start Free Trial](https://www.onlyoffice.com/connectors-request.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubNextcloud) |

Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>ONLYOFFICE connector enables you to edit Office documents within ONLYOFFICE from the familiar web interface. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to your file storage.</description>
<licence>agpl</licence>
<author mail="[email protected]" homepage="https://www.onlyoffice.com/">Ascensio System SIA</author>
<version>3.0.0</version>
<version>3.0.2</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
Expand All @@ -29,7 +29,7 @@
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/new.png</screenshot>
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/open.png</screenshot>
<dependencies>
<nextcloud min-version="14" max-version="16"/>
<nextcloud min-version="14" max-version="17"/>
</dependencies>
<settings>
<admin>OCA\Onlyoffice\AdminSettings</admin>
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
["name" => "callback#emptyfile", "url" => "/empty", "verb" => "GET"],
["name" => "callback#track", "url" => "/track", "verb" => "POST"],
["name" => "editor#index", "url" => "/{fileId}", "verb" => "GET"],
["name" => "editor#public_page", "url" => "/s/{token}", "verb" => "GET"],
["name" => "editor#public_page", "url" => "/s/{shareToken}", "verb" => "GET"],
["name" => "editor#config", "url" => "/ajax/config/{fileId}", "verb" => "GET"],
["name" => "editor#create", "url" => "/ajax/new", "verb" => "POST"],
["name" => "editor#convert", "url" => "/ajax/convert", "verb" => "POST"],
Expand Down
102 changes: 63 additions & 39 deletions controller/callbackcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function download($doc) {

list ($hashData, $error) = $this->crypt->ReadHash($doc);
if ($hashData === NULL) {
$this->logger->error("Download with empty or not correct hash: " . $error, array("app" => $this->appName));
$this->logger->error("Download with empty or not correct hash: $error", array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
}
if ($hashData->action !== "download") {
Expand All @@ -188,7 +188,7 @@ public function download($doc) {
}

$fileId = $hashData->fileId;
$this->logger->debug("Download: " . $fileId, array("app" => $this->appName));
$this->logger->debug("Download: $fileId", array("app" => $this->appName));

if (!$this->userSession->isLoggedIn()) {
if (!empty($this->config->GetDocumentServerSecret())) {
Expand All @@ -212,11 +212,20 @@ public function download($doc) {
if ($this->userSession->isLoggedIn()) {
$userId = $this->userSession->getUser()->getUID();
} else {
$userId = $hashData->userId;
$userId = $hashData->ownerId;

if (empty($this->userManager->get($userId))) {
$userId = $hashData->userId;
}

\OC_Util::tearDownFS();
if (!empty($userId)) {
\OC_Util::setupFS($userId);
}
}

$token = isset($hashData->token) ? $hashData->token : NULL;
list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token);
$shareToken = isset($hashData->shareToken) ? $hashData->shareToken : NULL;
list ($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $shareToken);

if (isset($error)) {
return $error;
Expand All @@ -230,7 +239,7 @@ public function download($doc) {
try {
return new DataDownloadResponse($file->getContent(), $file->getName(), $file->getMimeType());
} catch (NotPermittedException $e) {
$this->logger->error("Download Not permitted: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName));
$this->logger->error("Download Not permitted: $fileId " . $e->getMessage(), array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Not permitted")], Http::STATUS_FORBIDDEN);
}
return new JSONResponse(["message" => $this->trans->t("Download failed")], Http::STATUS_INTERNAL_SERVER_ERROR);
Expand All @@ -253,7 +262,7 @@ public function emptyfile($doc) {

list ($hashData, $error) = $this->crypt->ReadHash($doc);
if ($hashData === NULL) {
$this->logger->error("Download empty with empty or not correct hash: " . $error, array("app" => $this->appName));
$this->logger->error("Download empty with empty or not correct hash: $error", array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
}
if ($hashData->action !== "empty") {
Expand Down Expand Up @@ -282,14 +291,14 @@ public function emptyfile($doc) {

$template = file_get_contents($templatePath);
if (!$template) {
$this->logger->info("Template for download empty not found: " . $templatePath, array("app" => $this->appName));
$this->logger->info("Template for download empty not found: $templatePath", array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("File not found")], Http::STATUS_NOT_FOUND);
}

try {
return new DataDownloadResponse($template, "new.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
} catch (NotPermittedException $e) {
$this->logger->error("Download Not permitted: " . $fileId . " " . $e->getMessage(), array("app" => $this->appName));
$this->logger->error("Download Not permitted: $fileId " . $e->getMessage(), array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Not permitted")], Http::STATUS_FORBIDDEN);
}
return new JSONResponse(["message" => $this->trans->t("Download failed")], Http::STATUS_INTERNAL_SERVER_ERROR);
Expand All @@ -303,7 +312,7 @@ public function emptyfile($doc) {
* @param string $key - the edited document identifier
* @param integer $status - the edited status
* @param string $url - the link to the edited document to be saved
* @param string $token - access token
* @param string $token - request signature
*
* @return array
*
Expand All @@ -316,7 +325,7 @@ public function track($doc, $users, $key, $status, $url, $token) {

list ($hashData, $error) = $this->crypt->ReadHash($doc);
if ($hashData === NULL) {
$this->logger->error("Track with empty or not correct hash: " . $error, array("app" => $this->appName));
$this->logger->error("Track with empty or not correct hash: $error", array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
}
if ($hashData->action !== "track") {
Expand All @@ -325,7 +334,7 @@ public function track($doc, $users, $key, $status, $url, $token) {
}

$fileId = $hashData->fileId;
$this->logger->debug("Track: " . $fileId . " status " . $status, array("app" => $this->appName));
$this->logger->debug("Track: $fileId status $status", array("app" => $this->appName));

if (!empty($this->config->GetDocumentServerSecret())) {
if (!empty($token)) {
Expand Down Expand Up @@ -367,35 +376,40 @@ public function track($doc, $users, $key, $status, $url, $token) {
case "MustSave":
case "Corrupted":
if (empty($url)) {
$this->logger->error("Track without url: " . $fileId . " status " . $trackerStatus, array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("Url not found")], Http::STATUS_BAD_REQUEST);
$this->logger->error("Track without url: $fileId status $trackerStatus", array("app" => $this->appName));
return new JSONResponse(["message" => "Url not found"], Http::STATUS_BAD_REQUEST);
}

try {
$ownerId = $hashData->ownerId;
$token = isset($hashData->token) ? $hashData->token : NULL;
if (empty($ownerId) && empty($token)) {
$this->logger->error("Track without owner: " . $fileId . " status " . $trackerStatus, array("app" => $this->appName));
return new JSONResponse(["message" => $this->trans->t("File owner is empty")], Http::STATUS_BAD_REQUEST);
}
$shareToken = isset($hashData->shareToken) ? $hashData->shareToken : NULL;

$userId = $users[0];
$user = $this->userManager->get($userId);
if (!empty($user)) {
$this->userSession->setUser($user);
} else {
$this->logger->debug("Track by anonymous " . $userId, array("app" => $this->appName));
if (empty($shareToken)) {
$this->logger->error("Track without access: $fileId status $trackerStatus", array("app" => $this->appName));
return new JSONResponse(["message" => "User and token is empty"], Http::STATUS_BAD_REQUEST);
}

$this->logger->debug("Track by anonymous $userId", array("app" => $this->appName));
}

$ownerId = $hashData->ownerId;
if (!empty($this->userManager->get($ownerId))) {
$userId = $ownerId;
}

\OC_Util::tearDownFS();
if (!empty($ownerId)) {
\OC_Util::setupFS($ownerId);
if (!empty($userId)) {
\OC_Util::setupFS($userId);
}

list ($file, $error) = !empty($ownerId) ? $this->getFile($ownerId, $fileId) : $this->getFileByToken($fileId, $token);
list ($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $shareToken);

if (isset($error)) {
$this->logger->error("track error" . $fileId ." " . json_encode($error->getData()), array("app" => $this->appName));
$this->logger->error("track error$fileId" ." " . json_encode($error->getData()), array("app" => $this->appName));
return $error;
}

Expand All @@ -410,7 +424,7 @@ public function track($doc, $users, $key, $status, $url, $token) {
$key = DocumentService::GenerateRevisionId($fileId . $url);

try {
$this->logger->debug("Converted from " . $downloadExt . " to " . $curExt, array("app" => $this->appName));
$this->logger->debug("Converted from $downloadExt to $curExt", array("app" => $this->appName));
$url = $documentService->GetConvertedUri($url, $downloadExt, $curExt, $key);
} catch (\Exception $e) {
$this->logger->error("Converted on save error: " . $e->getMessage(), array("app" => $this->appName));
Expand All @@ -424,7 +438,7 @@ public function track($doc, $users, $key, $status, $url, $token) {
$file->putContent($newData);
$result = 0;
} catch (\Exception $e) {
$this->logger->error("Track " . $trackerStatus . " error: " . $e->getMessage(), array("app" => $this->appName));
$this->logger->error("Track $trackerStatus error: " . $e->getMessage(), array("app" => $this->appName));
}
break;

Expand All @@ -434,7 +448,7 @@ public function track($doc, $users, $key, $status, $url, $token) {
break;
}

$this->logger->debug("Track: " . $fileId . " status " . $status . " result " . $result, array("app" => $this->appName));
$this->logger->debug("Track: $fileId status $status result $result", array("app" => $this->appName));

return new JSONResponse(["error" => $result], Http::STATUS_OK);
}
Expand All @@ -453,16 +467,21 @@ private function getFile($userId, $fileId) {
return [NULL, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)];
}

$files = $this->root->getUserFolder($userId)->getById($fileId);
try {
$files = $this->root->getUserFolder($userId)->getById($fileId);
} catch (\Exception $e) {
$this->logger->error("getFile: $fileId " . $e->getMessage(), array("app" => $this->appName));
return [NULL, new JSONResponse(["message" => $this->trans->t("Invalid request")], Http::STATUS_BAD_REQUEST)];
}

if (empty($files)) {
$this->logger->error("Files not found: " . $fileId, array("app" => $this->appName));
$this->logger->error("Files not found: $fileId", array("app" => $this->appName));
return [NULL, new JSONResponse(["message" => $this->trans->t("Files not found")], Http::STATUS_NOT_FOUND)];
}
$file = $files[0];

if (!($file instanceof File)) {
$this->logger->error("File not found: " . $fileId, array("app" => $this->appName));
$this->logger->error("File not found: $fileId", array("app" => $this->appName));
return [NULL, new JSONResponse(["message" => $this->trans->t("File not found")], Http::STATUS_NOT_FOUND)];
}

Expand All @@ -473,12 +492,12 @@ private function getFile($userId, $fileId) {
* Getting file by token
*
* @param integer $fileId - file identifier
* @param string $token - access token
* @param string $shareToken - access token
*
* @return array
*/
private function getFileByToken($fileId, $token) {
list ($share, $error) = $this->getShare($token);
private function getFileByToken($fileId, $shareToken) {
list ($share, $error) = $this->getShare($shareToken);

if (isset($error)) {
return [NULL, $error];
Expand All @@ -492,7 +511,12 @@ private function getFileByToken($fileId, $token) {
}

if ($node instanceof Folder) {
$files = $node->getById($fileId);
try {
$files = $node->getById($fileId);
} catch (\Exception $e) {
$this->logger->error("getFileByToken: $fileId " . $e->getMessage(), array("app" => $this->appName));
return [NULL, new JSONResponse(["message" => $this->trans->t("Invalid request")], Http::STATUS_NOT_FOUND)];
}

if (empty($files)) {
return [NULL, new JSONResponse(["message" => $this->trans->t("File not found")], Http::STATUS_NOT_FOUND)];
Expand All @@ -508,18 +532,18 @@ private function getFileByToken($fileId, $token) {
/**
* Getting share by token
*
* @param string $token - access token
* @param string $shareToken - access token
*
* @return array
*/
private function getShare($token) {
if (empty($token)) {
private function getShare($shareToken) {
if (empty($shareToken)) {
return [NULL, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)];
}

$share;
try {
$share = $this->shareManager->getShareByToken($token);
$share = $this->shareManager->getShareByToken($shareToken);
} catch (ShareNotFound $e) {
$this->logger->error("getShare error: " . $e->getMessage(), array("app" => $this->appName));
$share = NULL;
Expand Down
Loading

0 comments on commit 2457828

Please sign in to comment.