Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.4.0 #74

Merged
merged 55 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b940995
call requestClose before closing editors iframe (fixes #24)
Eloncase Apr 5, 2021
98bad9d
format
Eloncase Apr 5, 2021
09c9575
finish event when user presses cancel
Eloncase Apr 5, 2021
aa9db3e
change documentType on word, cell, slide
Antipkin-A Aug 16, 2021
c0b6513
Merge remote-tracking branch 'remotes/origin/feature/filetype-format'…
LinneyS Aug 31, 2021
5699339
Update download links, helpcenter links
svetlana81 Aug 31, 2021
0fe28ce
Merge pull request #54 from ONLYOFFICE/feature/update-readme
LinneyS Aug 31, 2021
19355e9
handle user when maintenance mode
Antipkin-A Sep 3, 2021
eaeb57a
fixed maintenance mode to changelog (Fix #34)
Antipkin-A Sep 3, 2021
eb77e0e
hash url for convert
Antipkin-A Sep 6, 2021
1c40a05
Merge pull request #56 from ONLYOFFICE/bugfix/maintenance-mode
LinneyS Sep 6, 2021
2de721b
Merge remote-tracking branch 'remotes/origin/develop' into feature/on…
LinneyS Sep 13, 2021
e64b41c
requestClose to changelog
LinneyS Sep 13, 2021
dd82ae6
Merge pull request #57 from ONLYOFFICE/feature/on-close
LinneyS Sep 13, 2021
62b33b2
certificate verification to settings
Antipkin-A Sep 24, 2021
9a1dd3c
certificate verification trans
Antipkin-A Sep 24, 2021
74172ec
certificate verification to changelog
Antipkin-A Sep 24, 2021
4717da2
Merge pull request #58 from ONLYOFFICE/feature/cert-verify
LinneyS Sep 27, 2021
d8559ca
add lines (nl, hu, hr, fi)
Maria-Sukhova Sep 29, 2021
de4480a
Merge pull request #59 from ONLYOFFICE/feature/add-lines
LinneyS Oct 1, 2021
425b2aa
load storage url
Antipkin-A Oct 5, 2021
4ee2253
handle evt to callback
Antipkin-A Nov 8, 2021
ee4f93d
refactored modal closing
Eloncase Nov 11, 2021
82e7cf7
get file extension to lowercase
Antipkin-A Nov 15, 2021
3930e05
Added Versioning Support
luke- Nov 29, 2021
b645751
Version compare to v1.10
luke- Nov 29, 2021
e7d0cf2
namespaces revision
Antipkin-A Dec 14, 2021
f6a6044
Merge remote-tracking branch 'remotes/origin/release/2.3.0' into develop
LinneyS Dec 27, 2021
dca095d
Merge remote-tracking branch 'remotes/origin/master' into develop
LinneyS Jan 18, 2022
aee18a1
Merge remote-tracking branch 'remotes/origin/develop' into feature/lo…
LinneyS Jan 20, 2022
dbcf427
Merge pull request #62 from ONLYOFFICE/feature/loader-block
LinneyS Jan 20, 2022
f46ff64
Merge pull request #63 from ONLYOFFICE/feature/filetype
LinneyS Jan 20, 2022
23aef48
update submodule
LinneyS Jan 20, 2022
09c60da
Merge pull request #64 from luke-/enh/versioning
LinneyS Jan 20, 2022
00e90a3
Merge remote-tracking branch 'remotes/origin/develop' into feature/ve…
LinneyS Jan 20, 2022
1f08d90
Merge pull request #68 from ONLYOFFICE/feature/revision
LinneyS Jan 20, 2022
21ff484
Merge pull request #67 from ONLYOFFICE/feature/versioning
LinneyS Jan 20, 2022
a795567
removed header title
Antipkin-A Jan 20, 2022
35fd24b
buttons position on popup header
Antipkin-A Jan 21, 2022
ce47fbb
Merge pull request #69 from ONLYOFFICE/feature/popup-title
LinneyS Jan 25, 2022
17df2c1
Merge remote-tracking branch 'remotes/origin/master' into develop
LinneyS Feb 8, 2022
8440271
error for DS 6.0
Antipkin-A Feb 14, 2022
add39a0
fix close modal
Antipkin-A Feb 15, 2022
5b5a9d6
Merge pull request #70 from ONLYOFFICE/feature/editor-support
LinneyS Feb 15, 2022
c67f162
Merge pull request #71 from ONLYOFFICE/feature/popup-close
LinneyS Feb 15, 2022
05d9290
add nl
Maria-Sukhova Feb 24, 2022
d9f2f4c
Update base.php
Maria-Sukhova Feb 24, 2022
0e24465
Merge pull request #72 from ONLYOFFICE/feature/nl_add
LinneyS Feb 25, 2022
a00989d
copyright
Antipkin-A Feb 18, 2022
8d02ec3
Merge remote-tracking branch 'remotes/origin/feature/copyright' into …
LinneyS Feb 25, 2022
39d3315
check folder permissions when create file
Antipkin-A Mar 4, 2022
65e24aa
gl empty files
LinneyS Mar 5, 2022
41ce90a
tr empty files
LinneyS Mar 5, 2022
e447592
Merge remote-tracking branch 'remotes/origin/feature/permissions' int…
LinneyS Mar 5, 2022
c91a7ae
2.4.0
LinneyS Mar 5, 2022
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## 2.4.0
## Added
- certificate verification setting
- check unsaved changes before closing
- Turkish and Galician empty file templates

## Changed
- document server v6.0 and earlier is no longer supported
- Fixed opening file when maintenance mode
- Added Versioning Support (HumHub v1.10+)

## 2.3.0
## Added
- support docxf and oform formats
Expand Down
5 changes: 5 additions & 0 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @license https://www.humhub.com/licences
*/

/**
* Copyright (c) Ascensio System SIA 2022. All rights reserved.
* http://www.onlyoffice.com
*/

namespace humhub\modules\onlyoffice;

use humhub\modules\file\handler\FileHandlerCollection;
Expand Down
105 changes: 73 additions & 32 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @license https://www.humhub.com/licences
*/

/**
* Copyright (c) Ascensio System SIA 2022. All rights reserved.
* http://www.onlyoffice.com
*/

namespace humhub\modules\onlyoffice;

use Yii;
Expand Down Expand Up @@ -34,9 +39,9 @@ class Module extends \humhub\components\Module
/**
* Only document types
*/
const DOCUMENT_TYPE_TEXT = 'text';
const DOCUMENT_TYPE_PRESENTATION = 'presentation';
const DOCUMENT_TYPE_SPREADSHEET = 'spreadsheet';
const DOCUMENT_TYPE_TEXT = 'word';
const DOCUMENT_TYPE_PRESENTATION = 'slide';
const DOCUMENT_TYPE_SPREADSHEET = 'cell';

/**
* @var string[] allowed spreadsheet extensions
Expand Down Expand Up @@ -101,6 +106,11 @@ public function getStorageUrl()
return $this->settings->get('storageUrl');
}

public function getVerifyPeerOff()
{
return $this->settings->get('verifyPeerOff');
}

/**
*
* @return type
Expand All @@ -112,7 +122,7 @@ public function getServerApiUrl()

public function getDocumentType($file)
{
$fileExtension = FileHelper::getExtension($file);
$fileExtension = strtolower(FileHelper::getExtension($file));

if (in_array($fileExtension, $this->spreadsheetExtensions)) {
return self::DOCUMENT_TYPE_SPREADSHEET;
Expand All @@ -127,13 +137,13 @@ public function getDocumentType($file)

public function canEdit($file)
{
$fileExtension = FileHelper::getExtension($file);
$fileExtension = strtolower(FileHelper::getExtension($file));
return in_array($fileExtension, $this->editableExtensions);
}

public function canConvert($file)
{
$fileExtension = FileHelper::getExtension($file);
$fileExtension = strtolower(FileHelper::getExtension($file));
return in_array($fileExtension, $this->convertableExtensions);
}

Expand Down Expand Up @@ -173,23 +183,19 @@ public function commandService($data)
$url = $this->getInternalServerUrl() . '/coauthoring/CommandService.ashx';

try {
$http = new \Zend\Http\Client($url, [
'adapter' => '\Zend\Http\Client\Adapter\Curl',
'curloptions' => CURLHelper::getOptions(),
'timeout' => 10
]);
$http->setMethod('POST');
$headers = $http->getRequest()->getHeaders();

$headers = [];
$headers['Accept'] = 'application/json';
if ($this->isJwtEnabled()) {
$data['token'] = JWT::encode($data, $this->getJwtSecret());
$headers->addHeaderLine('Authorization', 'Bearer ' . JWT::encode(['payload' => $data], $this->getJwtSecret()));
$headers['Authorization'] = 'Bearer ' . JWT::encode(['payload' => $data], $this->getJwtSecret());
}

$http->setRawBody(Json::encode($data));
$headers->addHeaderLine('Accept', 'application/json');
$options = array(
'headers' => $headers,
'body' => $data
);

$response = $http->send();
$response = $this->request($url, 'POST', $options);
$json = $response->getBody();
} catch (\Exception $ex) {
Yii::error('Could not get document server response! ' . $ex->getMessage());
Expand All @@ -209,34 +215,38 @@ public function convertService($file, $ts)
$url = $this->getInternalServerUrl() . '/ConvertService.ashx';
$key = $this->generateDocumentKey($file);

$ext = FileHelper::getExtension($file);
$user = Yii::$app->user->getIdentity();
$userGuid = null;
if (isset($user->guid)) {
$userGuid = $user->guid;
}

$docHash = $this->generateHash($key, $userGuid);

$ext = strtolower(FileHelper::getExtension($file));
$data = [
'async' => true,
'embeddedfonts' => true,
'filetype' => $ext,
'outputtype' => $this->convertsTo[$ext],
'key' => $key . $ts,
'url' => Url::to(['/onlyoffice/backend/download', 'key' => $key], true),
'url' => Url::to(['/onlyoffice/backend/download', 'doc' => $docHash], true),
];

try {
$http = new \Zend\Http\Client($url, [
'adapter' => '\Zend\Http\Client\Adapter\Curl',
'curloptions' => CURLHelper::getOptions(),
'timeout' => 10
]);
$http->setMethod('POST');
$headers = $http->getRequest()->getHeaders();

$headers = [];
$headers['Accept'] = 'application/json';
if ($this->isJwtEnabled()) {
$data['token'] = JWT::encode($data, $this->getJwtSecret());
$headers->addHeaderLine('Authorization', 'Bearer ' . JWT::encode(['payload' => $data], $this->getJwtSecret()));
$headers['Authorization'] = 'Bearer ' . JWT::encode(['payload' => $data], $this->getJwtSecret());
}

$http->setRawBody(Json::encode($data));
$headers->addHeaderLine('Accept', 'application/json');
$options = array(
'headers' => $headers,
'body' => $data
);

$response = $http->send();
$response = $this->request($url, 'POST', $options);
$json = $response->getBody();
} catch (\Exception $ex) {
$error = 'Could not get document server response! ' . $ex->getMessage();
Expand Down Expand Up @@ -267,6 +277,37 @@ public function getPermissions($contentContainer = null)
return [];
}

/**
* @inheritdoc
*/
public function generateHash($key, $userGuid)
{
$data = [
'key' => $key
];

if (!empty($userGuid)) {
$data['userGuid'] = $userGuid;
}

return JWT::encode($data, Yii::$app->settings->get('secret'));
}

/**
* @inheritdoc
*/
public function readHash($hash)
{
try {
$data = JWT::decode($hash, Yii::$app->settings->get('secret'), array('HS256'));
} catch (\Exception $ex) {
$error = 'Invalid hash ' . $ex->getMessage();
Yii::error($error);
return [null, $error];
}

return [$data, null];
}
/**
* @inheritdoc
*/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ You will need an instance of ONLYOFFICE Docs (Document Server) that is resolvabl

You can install free Community version of ONLYOFFICE Docs or scalable Enterprise Edition with pro features.

To install free Community version, use [Docker](https://github.com/onlyoffice/Docker-DocumentServer) (recommended) or follow [these instructions](https://helpcenter.onlyoffice.com/server/linux/document/linux-installation.aspx) for Debian, Ubuntu, or derivatives.
To install free Community version, use [Docker](https://github.com/onlyoffice/Docker-DocumentServer) (recommended) or follow [these instructions](https://helpcenter.onlyoffice.com/installation/docs-community-install-ubuntu.aspx) for Debian, Ubuntu, or derivatives.

To install Enterprise Edition, follow instructions [here](https://helpcenter.onlyoffice.com/server/integration-edition/index.aspx).
To install Enterprise Edition, follow instructions [here](https://helpcenter.onlyoffice.com/installation/docs-enterprise-index.aspx).

Community Edition vs Enterprise Edition comparison can be found [here](#onlyoffice-docs-editions).

Expand Down
5 changes: 5 additions & 0 deletions assets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @license https://www.humhub.com/licences
*/

/**
* Copyright (c) Ascensio System SIA 2022. All rights reserved.
* http://www.onlyoffice.com
*/

namespace humhub\modules\onlyoffice\assets;

use Yii;
Expand Down
5 changes: 5 additions & 0 deletions components/BaseFileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @license https://www.humhub.com/licences
*/

/**
* Copyright (c) Ascensio System SIA 2022. All rights reserved.
* http://www.onlyoffice.com
*/

namespace humhub\modules\onlyoffice\components;

use Yii;
Expand Down
5 changes: 5 additions & 0 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @license https://www.humhub.com/licences
*/

/**
* Copyright (c) Ascensio System SIA 2022. All rights reserved.
* http://www.onlyoffice.com
*/

namespace humhub\modules\onlyoffice\controllers;

use Yii;
Expand Down
5 changes: 5 additions & 0 deletions controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* @license https://www.humhub.com/licences
*/

/**
* Copyright (c) Ascensio System SIA 2022. All rights reserved.
* http://www.onlyoffice.com
*/

namespace humhub\modules\onlyoffice\controllers;

use Yii;
Expand Down
45 changes: 39 additions & 6 deletions controllers/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
* @license https://www.humhub.com/licences
*/

/**
* Copyright (c) Ascensio System SIA 2022. All rights reserved.
* http://www.onlyoffice.com
*/

namespace humhub\modules\onlyoffice\controllers;

use Yii;
use yii\web\HttpException;
use humhub\modules\file\models\File;
use humhub\modules\user\models\User;
use humhub\components\Controller;
use \humhub\components\Module;
use \Firebase\JWT\JWT;

class BackendController extends Controller
Expand All @@ -28,16 +34,37 @@ class BackendController extends Controller
*/
public $file;

/**
* @var Module
*/
public $module;

/**
* @inheritdoc
*/
public function beforeAction($action)
{
$this->module = Yii::$app->getModule('onlyoffice');
$this->enableCsrfValidation = false;

$key = Yii::$app->request->get('key');
$hash = Yii::$app->request->get('doc');
list ($hashData, $error) = $this->module->readHash($hash);
if (!empty($error)) {
throw new HttpException(404, 'Backend action with empty or invalid hash');
}

$key = $hashData->key;
$userGuid = isset($hashData->userGuid) ? $hashData->userGuid : null;

$this->file = File::findOne(['onlyoffice_key' => $key]);

if (Yii::$app->settings->get('maintenanceMode')) {
$user = User::findOne(['guid' => $userGuid]);
if (!empty($user) && $user->isSystemAdmin()) {
Yii::$app->user->login($user);
}
}

if ($this->file == null) {
throw new HttpException(404, Yii::t('OnlyofficeModule.base', 'Could not find requested file!'));
}
Expand Down Expand Up @@ -79,8 +106,7 @@ public function actionTrack()
throw new \Exception('Could not parse json');
}

$module = Yii::$app->getModule('onlyoffice');
if ($module->isJwtEnabled()) {
if ($this->module->isJwtEnabled()) {
$token = null;
if (!empty($data["token"])) {
$token = $data["token"];
Expand All @@ -96,7 +122,7 @@ public function actionTrack()
}

try {
$ds = JWT::decode($token, $module->getJwtSecret(), array('HS256'));
$ds = JWT::decode($token, $this->module->getJwtSecret(), array('HS256'));
$data = isset($ds->payload) ? (array)$ds->payload : (array)$ds;
} catch (\Exception $ex) {
throw new \Exception('Invalid JWT signature');
Expand All @@ -117,10 +143,17 @@ public function actionTrack()
case "Corrupted":
case "ForceSave":

$newData = file_get_contents($data["url"]);
$newData = $this->module->request($data["url"])->getBody();

if (!empty($newData)) {
$this->file->getStore()->setContent($newData);

if (version_compare(Yii::$app->version, '1.10', '>=')) {
// For HumHub from version 1.10 with versioning support
$this->file->setStoredFileContent($newData);
} else {
// Older HumHub versions
$this->file->getStore()->setContent($newData);
}

if ($status != 'ForceSave') {
$newAttr = [
Expand Down
Loading