Plugin: OnlyOffice: Bump plugin to version 1.2.0 (adds support for Forms and JWT) - refs #4639

pull/4737/head
Yannick Warnier 2 years ago
parent d0f9f5f920
commit aecd5c724e
  1. 2
      plugin/onlyoffice/3rdparty/jwt/BeforeValidException.php
  2. 2
      plugin/onlyoffice/3rdparty/jwt/ExpiredException.php
  3. 213
      plugin/onlyoffice/3rdparty/jwt/JWT.php
  4. 2
      plugin/onlyoffice/3rdparty/jwt/SignatureInvalidException.php
  5. 12
      plugin/onlyoffice/CHANGELOG.md
  6. 88
      plugin/onlyoffice/README.md
  7. 86
      plugin/onlyoffice/ajax/saveas.php
  8. 3
      plugin/onlyoffice/assets/README.md
  9. BIN
      plugin/onlyoffice/assets/az-Latn-AZ/docxf.zip
  10. BIN
      plugin/onlyoffice/assets/bg-BG/docxf.zip
  11. BIN
      plugin/onlyoffice/assets/cs-CZ/docxf.zip
  12. BIN
      plugin/onlyoffice/assets/de-DE/docxf.zip
  13. BIN
      plugin/onlyoffice/assets/el-GR/docxf.zip
  14. BIN
      plugin/onlyoffice/assets/en-GB/docxf.zip
  15. BIN
      plugin/onlyoffice/assets/en-US/docxf.zip
  16. BIN
      plugin/onlyoffice/assets/es-ES/docxf.zip
  17. BIN
      plugin/onlyoffice/assets/fr-FR/docxf.zip
  18. BIN
      plugin/onlyoffice/assets/it-IT/docxf.zip
  19. BIN
      plugin/onlyoffice/assets/ja-JP/docxf.zip
  20. BIN
      plugin/onlyoffice/assets/ko-KR/docxf.zip
  21. BIN
      plugin/onlyoffice/assets/lv-LV/docxf.zip
  22. BIN
      plugin/onlyoffice/assets/nl-NL/docxf.zip
  23. BIN
      plugin/onlyoffice/assets/pl-PL/docxf.zip
  24. BIN
      plugin/onlyoffice/assets/pt-BR/docxf.zip
  25. BIN
      plugin/onlyoffice/assets/pt-PT/docxf.zip
  26. BIN
      plugin/onlyoffice/assets/ru-RU/docxf.zip
  27. BIN
      plugin/onlyoffice/assets/sk-SK/docxf.zip
  28. BIN
      plugin/onlyoffice/assets/sv-SE/docxf.zip
  29. BIN
      plugin/onlyoffice/assets/tr-TR/docx.zip
  30. BIN
      plugin/onlyoffice/assets/tr-TR/docxf.zip
  31. BIN
      plugin/onlyoffice/assets/tr-TR/pptx.zip
  32. BIN
      plugin/onlyoffice/assets/tr-TR/xlsx.zip
  33. BIN
      plugin/onlyoffice/assets/uk-UA/docxf.zip
  34. BIN
      plugin/onlyoffice/assets/vi-VN/docxf.zip
  35. BIN
      plugin/onlyoffice/assets/zh-CN/docxf.zip
  36. 62
      plugin/onlyoffice/callback.php
  37. 143
      plugin/onlyoffice/create.php
  38. 90
      plugin/onlyoffice/editor.php
  39. 7
      plugin/onlyoffice/install.php
  40. 4
      plugin/onlyoffice/lang/bulgarian.php
  41. 3
      plugin/onlyoffice/lang/dutch.php
  42. 4
      plugin/onlyoffice/lang/english.php
  43. 4
      plugin/onlyoffice/lang/french.php
  44. 4
      plugin/onlyoffice/lang/german.php
  45. 3
      plugin/onlyoffice/lang/greek.php
  46. 4
      plugin/onlyoffice/lang/italian.php
  47. 3
      plugin/onlyoffice/lang/polish.php
  48. 4
      plugin/onlyoffice/lang/portuguese.php
  49. 4
      plugin/onlyoffice/lang/russian.php
  50. 4
      plugin/onlyoffice/lang/spanish.php
  51. 15
      plugin/onlyoffice/lib/appConfig.php
  52. 18
      plugin/onlyoffice/lib/crypt.php
  53. 172
      plugin/onlyoffice/lib/fileUtility.php
  54. 16
      plugin/onlyoffice/lib/langManager.php
  55. 8
      plugin/onlyoffice/lib/onlyofficeActionObserver.php
  56. 10
      plugin/onlyoffice/lib/onlyofficeItemActionObserver.php
  57. 9
      plugin/onlyoffice/lib/onlyofficeItemViewObserver.php
  58. 10
      plugin/onlyoffice/lib/onlyofficePlugin.php
  59. 57
      plugin/onlyoffice/lib/onlyofficeTools.php
  60. 23
      plugin/onlyoffice/lib/templateManager.php
  61. 8
      plugin/onlyoffice/plugin.php
  62. 9
      plugin/onlyoffice/uninstall.php

@ -1,7 +1,7 @@
<?php
namespace Firebase\JWT;
class BeforeValidException extends \UnexpectedValueException
{
}

@ -1,7 +1,7 @@
<?php
namespace Firebase\JWT;
class ExpiredException extends \UnexpectedValueException
{
}

@ -1,29 +1,27 @@
<?php
namespace Firebase\JWT;
use DateTime;
use DomainException;
use InvalidArgumentException;
use UnexpectedValueException;
use \DomainException;
use \InvalidArgumentException;
use \UnexpectedValueException;
use \DateTime;
/**
* JSON Web Token implementation, based on this spec:
* http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06.
* http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
*
* PHP version 5
*
* @category Authentication
* @package Authentication_JWT
*
* @author Neuman Vong <neuman@twilio.com>
* @author Anant Narayanan <anant@php.net>
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
*
* @see https://github.com/firebase/php-jwt
* @link https://github.com/firebase/php-jwt
*/
class JWT
{
/**
* When checking nbf, iat or expiration times,
* we want to provide some extra leeway time to
@ -39,34 +37,34 @@ class JWT
*/
public static $timestamp = null;
public static $supported_algs = [
'HS256' => ['hash_hmac', 'SHA256'],
'HS512' => ['hash_hmac', 'SHA512'],
'HS384' => ['hash_hmac', 'SHA384'],
'RS256' => ['openssl', 'SHA256'],
];
public static $supported_algs = array(
'HS256' => array('hash_hmac', 'SHA256'),
'HS512' => array('hash_hmac', 'SHA512'),
'HS384' => array('hash_hmac', 'SHA384'),
'RS256' => array('openssl', 'SHA256'),
);
/**
* Decodes a JWT string into a PHP object.
*
* @param string $jwt The JWT
* @param string|array $key The key, or map of keys.
* If the algorithm used is asymmetric, this is the public key
* @param array $allowed_algs List of supported verification algorithms
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @throws UnexpectedValueException Provided JWT was invalid
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
* @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
* @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
* @param string $jwt The JWT
* @param string|array $key The key, or map of keys.
* If the algorithm used is asymmetric, this is the public key
* @param array $allowed_algs List of supported verification algorithms
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @return object The JWT's payload as a PHP object
*
* @throws UnexpectedValueException Provided JWT was invalid
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
* @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
* @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
*
* @uses jsonDecode
* @uses urlsafeB64Decode
*/
public static function decode($jwt, $key, $allowed_algs = [])
public static function decode($jwt, $key, $allowed_algs = array())
{
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
@ -88,7 +86,7 @@ class JWT
throw new UnexpectedValueException('Invalid claims encoding');
}
$sig = static::urlsafeB64Decode($cryptob64);
if (empty($header->alg)) {
throw new UnexpectedValueException('Empty algorithm');
}
@ -114,14 +112,18 @@ class JWT
// Check if the nbf if it is defined. This is the time that the
// token can actually be used. If it's not yet that time, abort.
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
throw new BeforeValidException('Cannot handle token prior to '.date(DateTime::ISO8601, $payload->nbf));
throw new BeforeValidException(
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
);
}
// Check that this token has been created before 'now'. This prevents
// using tokens that have been created for later use (and haven't
// correctly used the nbf claim).
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
throw new BeforeValidException('Cannot handle token prior to '.date(DateTime::ISO8601, $payload->iat));
throw new BeforeValidException(
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
);
}
// Check if this token has expired.
@ -135,13 +137,13 @@ class JWT
/**
* Converts and signs a PHP object or array into a JWT string.
*
* @param object|array $payload PHP object or array
* @param string $key The secret key.
* If the algorithm used is asymmetric, this is the private key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
* @param mixed $keyId
* @param array $head An array with header elements to attach
* @param object|array $payload PHP object or array
* @param string $key The secret key.
* If the algorithm used is asymmetric, this is the private key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
* @param mixed $keyId
* @param array $head An array with header elements to attach
*
* @return string A signed JWT
*
@ -150,14 +152,14 @@ class JWT
*/
public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
{
$header = ['typ' => 'JWT', 'alg' => $alg];
$header = array('typ' => 'JWT', 'alg' => $alg);
if ($keyId !== null) {
$header['kid'] = $keyId;
}
if (isset($head) && is_array($head)) {
if ( isset($head) && is_array($head) ) {
$header = array_merge($head, $header);
}
$segments = [];
$segments = array();
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
$signing_input = implode('.', $segments);
@ -171,14 +173,14 @@ class JWT
/**
* Sign a string with a given key and algorithm.
*
* @param string $msg The message to sign
* @param string|resource $key The secret key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @throws DomainException Unsupported algorithm was specified
* @param string $msg The message to sign
* @param string|resource $key The secret key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @return string An encrypted message
*
* @throws DomainException Unsupported algorithm was specified
*/
public static function sign($msg, $key, $alg = 'HS256')
{
@ -186,7 +188,7 @@ class JWT
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch ($function) {
switch($function) {
case 'hash_hmac':
return hash_hmac($algorithm, $msg, $key, true);
case 'openssl':
@ -200,14 +202,60 @@ class JWT
}
}
/**
* Verify a signature with the message, key and method. Not all methods
* are symmetric, so we must have a separate verify and sign method.
*
* @param string $msg The original message (header and body)
* @param string $signature The original signature
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
* @param string $alg The algorithm
*
* @return bool
*
* @throws DomainException Invalid Algorithm or OpenSSL failure
*/
private static function verify($msg, $signature, $key, $alg)
{
if (empty(static::$supported_algs[$alg])) {
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch($function) {
case 'openssl':
$success = openssl_verify($msg, $signature, $key, $algorithm);
if (!$success) {
throw new DomainException("OpenSSL unable to verify data: " . openssl_error_string());
} else {
return $signature;
}
case 'hash_hmac':
default:
$hash = hash_hmac($algorithm, $msg, $key, true);
if (function_exists('hash_equals')) {
return hash_equals($signature, $hash);
}
$len = min(static::safeStrlen($signature), static::safeStrlen($hash));
$status = 0;
for ($i = 0; $i < $len; $i++) {
$status |= (ord($signature[$i]) ^ ord($hash[$i]));
}
$status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash));
return ($status === 0);
}
}
/**
* Decode a JSON string into a PHP object.
*
* @param string $input JSON string
*
* @throws DomainException Provided string was invalid JSON
*
* @return object Object representation of JSON string
*
* @throws DomainException Provided string was invalid JSON
*/
public static function jsonDecode($input)
{
@ -232,7 +280,6 @@ class JWT
} elseif ($obj === null && $input !== 'null') {
throw new DomainException('Null result with non-null input');
}
return $obj;
}
@ -241,9 +288,9 @@ class JWT
*
* @param object|array $input A PHP object or array
*
* @throws DomainException Provided object could not be encoded to valid JSON
*
* @return string JSON representation of the PHP object or array
*
* @throws DomainException Provided object could not be encoded to valid JSON
*/
public static function jsonEncode($input)
{
@ -253,7 +300,6 @@ class JWT
} elseif ($json === 'null' && $input !== null) {
throw new DomainException('Null result with non-null input');
}
return $json;
}
@ -271,7 +317,6 @@ class JWT
$padlen = 4 - $remainder;
$input .= str_repeat('=', $padlen);
}
return base64_decode(strtr($input, '-_', '+/'));
}
@ -287,53 +332,6 @@ class JWT
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}
/**
* Verify a signature with the message, key and method. Not all methods
* are symmetric, so we must have a separate verify and sign method.
*
* @param string $msg The original message (header and body)
* @param string $signature The original signature
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
* @param string $alg The algorithm
*
* @throws DomainException Invalid Algorithm or OpenSSL failure
*
* @return bool
*/
private static function verify($msg, $signature, $key, $alg)
{
if (empty(static::$supported_algs[$alg])) {
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch ($function) {
case 'openssl':
$success = openssl_verify($msg, $signature, $key, $algorithm);
if (!$success) {
throw new DomainException("OpenSSL unable to verify data: ".openssl_error_string());
} else {
return $signature;
}
// no break
case 'hash_hmac':
default:
$hash = hash_hmac($algorithm, $msg, $key, true);
if (function_exists('hash_equals')) {
return hash_equals($signature, $hash);
}
$len = min(static::safeStrlen($signature), static::safeStrlen($hash));
$status = 0;
for ($i = 0; $i < $len; $i++) {
$status |= (ord($signature[$i]) ^ ord($hash[$i]));
}
$status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash));
return $status === 0;
}
}
/**
* Helper method to create a JSON error.
*
@ -343,12 +341,16 @@ class JWT
*/
private static function handleJsonError($errno)
{
$messages = [
$messages = array(
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
];
throw new DomainException(isset($messages[$errno]) ? $messages[$errno] : 'Unknown JSON error: '.$errno);
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
);
throw new DomainException(
isset($messages[$errno])
? $messages[$errno]
: 'Unknown JSON error: ' . $errno
);
}
/**
@ -363,7 +365,6 @@ class JWT
if (function_exists('mb_strlen')) {
return mb_strlen($str, '8bit');
}
return strlen($str);
}
}

@ -1,7 +1,7 @@
<?php
namespace Firebase\JWT;
class SignatureInvalidException extends \UnexpectedValueException
{
}

@ -2,15 +2,19 @@
This plugin is developed and maintained at https://github.com/ONLYOFFICE/onlyoffice-chamilo.
## 2021-08 1.1.1
## 1.2.0
## Added
- support docxf and oform formats
- create blank docxf from creation menu
- "save as" in editor
## 1.1.2
- Add security filtering
- Minor documentation and code style changes
## 2021-04 1.1.0
- View option for DOCX, XLSX, PPTX.
- JWT support
## 2021-03 1.0.0
## 1.0.0
- Ability to create documents
- Edit option for DOCX, XLSX, PPTX.
- Collaboration editing

@ -1,4 +1,4 @@
# Chamilo ONLYOFFICE integration plugin
# Chamilo ONLYOFFICE integration plugin
This app enables users to edit office documents from [Chamilo](https://chamilo.org) using ONLYOFFICE Docs packaged as Document Server - [Community or Enterprise Edition](#onlyoffice-docs-editions).
@ -13,7 +13,7 @@ The plugin allows teachers to:
Supported formats:
* For editing: DOCX, XLSX, PPTX.
* For editing: DOCX, XLSX, PPTX, DOCXF, OFORM.
## Installing ONLYOFFICE Docs
@ -23,21 +23,61 @@ ONLYOFFICE Document Server and Chamilo can be installed either on different comp
You can install the free Community version of ONLYOFFICE Docs or scalable Enterprise Edition with pro features.
To install the 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 the 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 the Enterprise Edition, follow instructions [here](https://helpcenter.onlyoffice.com/server/integration-edition/index.aspx).
To install the Enterprise Edition, follow instructions [here](https://helpcenter.onlyoffice.com/installation/docs-enterprise-index.aspx).
The Community Edition vs Enterprise Edition comparison can be found [here](#onlyoffice-docs-editions).
To use ONLYOFFICE behind a proxy, please refer to [this article](https://helpcenter.onlyoffice.com/server/document/document-server-proxy.aspx).
To use ONLYOFFICE behind a proxy, please refer to [this article](https://helpcenter.onlyoffice.com/installation/docs-community-proxy.aspx).
## Collect Chamilo ONLYOFFICE integration plugin
1. Get the latest version of this repository running the command:
```
git clone https://github.com/ONLYOFFICE/onlyoffice-chamilo
cd onlyoffice-chamilo
```
2. Get a submodule:
```
git submodule update --init --recursive
```
3. Collect all files
```
mkdir /tmp/onlyoffice-deploy
mkdir /tmp/onlyoffice-deploy/onlyoffice
cp -r ./ /tmp/onlyoffice-deploy/onlyoffice
cd /tmp/onlyoffice-deploy/onlyoffice
rm -rf ./.git*
```
4. Archive
```
cd ../
zip onlyoffice.zip -r onlyoffice
```
## Installing Chamilo ONLYOFFICE integration plugin
The plugin comes integrated into Chamilo 1.11.16.
The plugin has been integrated into Chamilo since version 1.11.16.
To enable, go to the plugins list, select the ONLYOFFICE plugin, and click _Enable_ the selected plugins.
If you want more up-to-date versions of the plugin, you can update the plugin/onlyoffice/ folder with the original plugin code [here](https://github.com/ONLYOFFICE/onlyoffice-chamilo) together with the compilation instructions.
If you want more up-to-date versions of the plugin, you need to replace the pre-installed default plugin folder with the newly collected plugin:
`/var/www/html/chamilo-1.11.16/plugin/onlyoffice`
where `chamilo-1.11.16` is your current Chamilo version.
If your Chamilo version is lower than 1.11.16, go to Chamilo Administration -> Plugins -> Upload plugin.
Upload `onlyoffice.zip` (you'll find it in the Releases section). You'll see the plugin list.
Then launch `composer install` from the Chamilo root folder.
Return to the plugin list, select the ONLYOFFICE plugin, and click Enable the selected plugins.
## Configuring Chamilo ONLYOFFICE integration plugin
@ -77,7 +117,7 @@ The table below will help you to make the right choice.
| Pricing and licensing | Community Edition | Enterprise Edition |
| ------------- | ------------- | ------------- |
| | [Get it now](https://www.onlyoffice.com/download.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo) | [Start Free Trial](https://www.onlyoffice.com/enterprise-edition-free.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo) |
| | [Get it now](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo#docs-community) | [Start Free Trial](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo#docs-enterprise) |
| Cost | FREE | [Go to the pricing page](https://www.onlyoffice.com/docs-enterprise-prices.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo) |
| Simultaneous connections | up to 20 maximum | As in chosen pricing plan |
| Number of users | up to 20 recommended | As in chosen pricing plan |
@ -85,18 +125,17 @@ The table below will help you to make the right choice.
| **Support** | **Community Edition** | **Enterprise Edition** |
| Documentation | [Help Center](https://helpcenter.onlyoffice.com/installation/docs-community-index.aspx) | [Help Center](https://helpcenter.onlyoffice.com/installation/docs-enterprise-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=GitHubChamilo) | [Buy Now](https://www.onlyoffice.com/support.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo) |
| Premium support | [Contact us](mailto:sales@onlyoffice.com) | [Contact us](mailto:sales@onlyoffice.com) |
| **Services** | **Community Edition** | **Enterprise Edition** |
| Conversion Service | + | + |
| Document Builder Service | + | + |
| **Interface** | **Community Edition** | **Enterprise Edition** |
| Tabbed interface | + | + |
| Dark theme | + | + |
| 150% scaling | + | + |
| 125%, 150%, 175%, 200% scaling | + | + |
| White Label | - | - |
| Integrated test example (node.js)* | - | + |
| Mobile web editors | - | + |
| Access to pro features via desktop | - | + |
| Integrated test example (node.js) | + | + |
| Mobile web editors | - | +* |
| **Plugins & Macros** | **Community Edition** | **Enterprise Edition** |
| Plugins | + | + |
| Macros | + | + |
@ -110,36 +149,39 @@ The table below will help you to make the right choice.
| **Document Editor features** | **Community Edition** | **Enterprise Edition** |
| Font and paragraph formatting | + | + |
| Object insertion | + | + |
| Adding Content control | - | + |
| Adding Content control | + | + |
| Editing Content control | + | + |
| Layout tools | + | + |
| Table of contents | + | + |
| Navigation panel | + | + |
| Mail Merge | + | + |
| Comparing Documents | - | +* |
| Comparing Documents | + | + |
| **Spreadsheet Editor features** | **Community Edition** | **Enterprise Edition** |
| Font and paragraph formatting | + | + |
| Object insertion | + | + |
| Functions, formulas, equations | + | + |
| Table templates | + | + |
| Pivot tables | + | + |
| Data validation | + | + |
| Conditional formatting for viewing | +** | +** |
| Sheet Views | - | + |
| Data validation | + | + |
| Conditional formatting | + | + |
| Sparklines | + | + |
| Sheet Views | + | + |
| **Presentation Editor features** | **Community Edition** | **Enterprise Edition** |
| Font and paragraph formatting | + | + |
| Object insertion | + | + |
| Transitions | + | + |
| Presenter mode | + | + |
| Notes | + | + |
| | [Get it now](https://www.onlyoffice.com/download.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo) | [Start Free Trial](https://www.onlyoffice.com/enterprise-edition-free.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo) |
\* It's possible to add documents for comparison from your local drive, from URL and from Chamilo storage.
| **Form creator features** | **Community Edition** | **Enterprise Edition** |
| Adding form fields | + | + |
| Form preview | + | + |
| Saving as PDF | + | + |
| | [Get it now](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo#docs-community) | [Start Free Trial](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubChamilo#docs-enterprise) |
\** Support for all conditions and gradient. Adding/Editing capabilities are coming soon
\* If supported by DMS.
## Note on SSL
As for all SSL to non-SSL communication, this plugin will not work fully if your
As for all SSL to non-SSL communication, this plugin will not work fully if your
Chamilo portal works in HTTP and your OnlyOffice Document server works in HTTPS, or vice-versa.
You will need to ensure the same protocol on both sides.

@ -0,0 +1,86 @@
<?php
/**
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__.'/../../../main/inc/global.inc.php';
use ChamiloSession as Session;
$userId = api_get_user_id();
$body = json_decode(file_get_contents('php://input'), true);
$title = $body["title"];
$url = $body["url"];
$folderId = !empty($body["folderId"]) ? $body["folderId"] : 0;
$sessionId = !empty($body["sessionId"]) ? $body["sessionId"] : 0;
$courseId = !empty($body["courseId"]) ? $body["courseId"] : 0;
$groupId = !empty($body["groupId"]) ? $body["groupId"] : 0;
$courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo["code"];
$isMyDir = false;
if (!empty($folderId)) {
$folderInfo = DocumentManager::get_document_data_by_id(
$folderId,
$courseCode,
true,
$sessionId
);
$isMyDir = DocumentManager::is_my_shared_folder(
$userId,
$folderInfo["absolute_path"],
$sessionId
);
}
$groupRights = Session::read("group_member_with_upload_rights");
$isAllowToEdit = api_is_allowed_to_edit(true, true);
if (!($isAllowToEdit || $isMyDir || $groupRights)) {
echo json_encode(["error" => "Not permitted"]);
return;
}
$fileExt = strtolower(pathinfo($title, PATHINFO_EXTENSION));
$baseName = strtolower(pathinfo($title, PATHINFO_FILENAME));
$result = FileUtility::createFile(
$baseName,
$fileExt,
$folderId,
$userId,
$sessionId,
$courseId,
$groupId,
$url
);
if (isset($result["error"])) {
if ($result["error"] === "fileIsExist") {
$result["error"] = "File is exist";
}
if ($result["error"] === "impossibleCreateFile") {
$result["error"] = "Impossible to create file";
}
echo json_encode($result);
return;
}
echo json_encode(["success" => "File is created"]);

@ -3,6 +3,3 @@
Template files used to create new documents and documents with sample content in:
* [Chamilo ONLYOFFICE integration plugin](https://github.com/onlyoffice/onlyoffice-chamilo)

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,13 +14,15 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
use ChamiloSession as Session;
/**
* Status of the document.
* Status of the document
*/
const TrackerStatus_Editing = 1;
const TrackerStatus_MustSave = 2;
@ -32,15 +35,15 @@ $plugin = OnlyofficePlugin::create();
if (isset($_GET["hash"]) && !empty($_GET["hash"])) {
$callbackResponseArray = [];
@header('Content-Type: application/json; charset==utf-8');
@header('X-Robots-Tag: noindex');
@header('X-Content-Type-Options: nosniff');
@header( 'Content-Type: application/json; charset==utf-8');
@header( 'X-Robots-Tag: noindex' );
@header( 'X-Content-Type-Options: nosniff' );
list($hashData, $error) = Crypt::ReadHash($_GET["hash"]);
list ($hashData, $error) = Crypt::ReadHash($_GET["hash"]);
if ($hashData === null) {
$callbackResponseArray["status"] = "error";
$callbackResponseArray["error"] = $error;
exit(json_encode($callbackResponseArray));
die(json_encode($callbackResponseArray));
}
$type = $hashData->type;
@ -57,7 +60,7 @@ if (isset($_GET["hash"]) && !empty($_GET["hash"])) {
$userInfo = api_get_user_info($userId);
} else {
$result["error"] = "User not found";
exit(json_encode($result));
die (json_encode($result));
}
if (api_is_anonymous()) {
@ -73,22 +76,22 @@ if (isset($_GET["hash"]) && !empty($_GET["hash"])) {
$userId = api_get_user_id();
}
switch ($type) {
switch($type) {
case "track":
$callbackResponseArray = track();
exit(json_encode($callbackResponseArray));
die (json_encode($callbackResponseArray));
case "download":
$callbackResponseArray = download();
exit(json_encode($callbackResponseArray));
die (json_encode($callbackResponseArray));
default:
$callbackResponseArray["status"] = "error";
$callbackResponseArray["error"] = "404 Method not found";
exit(json_encode($callbackResponseArray));
die(json_encode($callbackResponseArray));
}
}
/**
* Handle request from the document server with the document status information.
* Handle request from the document server with the document status information
*/
function track(): array
{
@ -104,7 +107,6 @@ function track(): array
if (($body_stream = file_get_contents("php://input")) === false) {
$result["error"] = "Bad Request";
return $result;
}
@ -112,29 +114,27 @@ function track(): array
if ($data === null) {
$result["error"] = "Bad Response";
return $result;
}
if (!empty($plugin->get("jwt_secret"))) {
if (!empty($data["token"])) {
try {
$payload = \Firebase\JWT\JWT::decode($data["token"], $plugin->get("jwt_secret"), ["HS256"]);
$payload = \Firebase\JWT\JWT::decode($data["token"], $plugin->get("jwt_secret"), array("HS256"));
} catch (\UnexpectedValueException $e) {
$result["status"] = "error";
$result["error"] = "403 Access denied";
return $result;
}
} else {
$token = substr($_SERVER[AppConfig::JwtHeader()], strlen("Bearer "));
$token = substr(getallheaders()[AppConfig::JwtHeader()], strlen("Bearer "));
try {
$decodeToken = \Firebase\JWT\JWT::decode($token, $plugin->get("jwt_secret"), ["HS256"]);
$decodeToken = \Firebase\JWT\JWT::decode($token, $plugin->get("jwt_secret"), array("HS256"));
$payload = $decodeToken->payload;
} catch (\UnexpectedValueException $e) {
$result["status"] = "error";
$result["error"] = "403 Access denied";
return $result;
}
}
@ -149,6 +149,7 @@ function track(): array
switch ($status) {
case TrackerStatus_MustSave:
case TrackerStatus_Corrupted:
$downloadUri = $data["url"];
if (!empty($docId) && !empty($courseCode)) {
@ -156,18 +157,16 @@ function track(): array
if ($docInfo === false) {
$result["error"] = "File not found";
return $result;
}
$filePath = $docInfo["absolute_path"];
} else {
$result["error"] = "Bad Request";
return $result;
}
list($isAllowToEdit, $isMyDir, $isGroupAccess, $isReadonly) = getPermissions($docInfo, $userId, $courseCode, $groupId, $sessionId);
list ($isAllowToEdit, $isMyDir, $isGroupAccess, $isReadonly) = getPermissions($docInfo, $userId, $courseCode, $groupId, $sessionId);
if ($isReadonly) {
break;
@ -202,20 +201,19 @@ function track(): array
}
}
// no break
case TrackerStatus_Editing:
case TrackerStatus_Closed:
$track_result = 0;
break;
}
$result["error"] = $track_result;
return $result;
}
/**
* Downloading file by the document service.
* Downloading file by the document service
*/
function download()
{
@ -228,13 +226,13 @@ function download()
global $courseInfo;
if (!empty($plugin->get("jwt_secret"))) {
$token = substr($_SERVER[AppConfig::JwtHeader()], strlen("Bearer "));
$token = substr(getallheaders()[AppConfig::JwtHeader()], strlen("Bearer "));
try {
$payload = \Firebase\JWT\JWT::decode($token, $plugin->get("jwt_secret"), ["HS256"]);
$payload = \Firebase\JWT\JWT::decode($token, $plugin->get("jwt_secret"), array("HS256"));
} catch (\UnexpectedValueException $e) {
$result["status"] = "error";
$result["error"] = "403 Access denied";
return $result;
}
}
@ -244,25 +242,23 @@ function download()
if ($docInfo === false) {
$result["error"] = "File not found";
return $result;
}
$filePath = $docInfo["absolute_path"];
} else {
$result["error"] = "File not found";
return $result;
}
@header("Content-Type: application/octet-stream");
@header("Content-Disposition: attachment; filename=".$docInfo["title"]);
@header("Content-Disposition: attachment; filename=" . $docInfo["title"]);
readfile($filePath);
}
/**
* Method checks access rights to document and returns permissions.
* Method checks access rights to document and returns permissions
*/
function getPermissions(array $docInfo, int $userId, string $courseCode, int $groupId = null, int $sessionId = null): array
{

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,7 +14,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
use ChamiloSession as Session;
@ -24,121 +27,83 @@ $mapFileFormat = [
"text" => $plugin->get_lang("document"),
"spreadsheet" => $plugin->get_lang("spreadsheet"),
"presentation" => $plugin->get_lang("presentation"),
"formTemplate" => $plugin->get_lang("formTemplate")
];
$userId = $_GET["userId"];
$sessionId = $_GET["sessionId"];
$docId = $_GET["folderId"];
$courseId = $_GET["courseId"];
$userId = !empty($_GET["userId"]) ? $_GET['userId'] : 0;
$sessionId = !empty($_GET["sessionId"]) ? $_GET["sessionId"] : 0;
$courseId = !empty($_GET["courseId"]) ? $_GET["courseId"] : 0;
$groupId = !empty($_GET["groupId"]) ? $_GET["groupId"] : 0;
$folderId = !empty($_GET["folderId"]) ? $_GET["folderId"] : 0;
$courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo["code"];
$docInfo = DocumentManager::get_document_data_by_id($docId, $courseCode, true, $sessionId);
$isMyDir = false;
if (!empty($folderId)) {
$folderInfo = DocumentManager::get_document_data_by_id(
$folderId,
$courseCode,
true,
$sessionId
);
$isMyDir = DocumentManager::is_my_shared_folder(
$userId,
$folderInfo["absolute_path"],
$sessionId
);
}
$groupRights = Session::read('group_member_with_upload_rights');
$isAllowToEdit = api_is_allowed_to_edit(true, true);
$isMyDir = DocumentManager::is_my_shared_folder($userId, $docInfo["absolute_path"], $sessionId);
if (!($isAllowToEdit || $isMyDir || $groupRights)) {
api_not_allowed(true);
}
$form = new FormValidator("doc_create",
"post",
api_get_path(WEB_PLUGIN_PATH)."onlyoffice/create.php");
$form = new FormValidator(
"doc_create",
"post",
api_get_path(WEB_PLUGIN_PATH) . "onlyoffice/create.php?userId=" . Security::remove_XSS($userId)
. "&groupId=" . Security::remove_XSS($groupId)
. "&courseId=" . Security::remove_XSS($courseId)
. "&sessionId=" . Security::remove_XSS($sessionId)
. "&folderId=" . Security::remove_XSS($folderId)
);
$form->addText("fileName", $plugin->get_lang("title"), true);
$form->addSelect("fileFormat", $plugin->get_lang("chooseFileFormat"), $mapFileFormat);
$form->addButtonCreate($plugin->get_lang("create"));
$form->addHidden("groupId", (int) $_GET["groupId"]);
$form->addHidden("courseId", (int) $_GET["courseId"]);
$form->addHidden("sessionId", (int) $_GET["sessionId"]);
$form->addHidden("userId", (int) $_GET["userId"]);
$form->addHidden("folderId", (int) $_GET["folderId"]);
$form->addHidden("goBackUrl", $_SERVER["HTTP_REFERER"]);
if ($form->validate()) {
$values = $form->exportValues();
$folderId = $values["folderId"];
$userId = $values["userId"];
$groupId = $values["groupId"];
$sessionId = $values["sessionId"];
$courseId = $values["courseId"];
$goBackUrl = $values["goBackUrl"];
$fileType = $values["fileFormat"];
$fileExt = FileUtility::getDocExt($fileType);
$fileTitle = $values["fileName"].".".$fileExt;
$courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo["code"];
$fileNamePrefix = DocumentManager::getDocumentSuffix($courseInfo, $sessionId, $groupId);
$fileName = $values["fileName"].$fileNamePrefix.".".$fileExt;
$groupInfo = GroupManager::get_group_properties($groupId);
$emptyTemplatePath = TemplateManager::getEmptyTemplate($fileExt);
$fileRelatedPath = "/";
if (!empty($folderId)) {
$document_data = DocumentManager::get_document_data_by_id($folderId, $courseCode, true, $sessionId);
$folderPath = $document_data["absolute_path"];
$fileRelatedPath = $fileRelatedPath.substr($document_data["absolute_path_from_document"], 10)."/".$fileName;
} else {
$folderPath = api_get_path(SYS_COURSE_PATH).api_get_course_path($courseCode)."/document";
if (!empty($groupId)) {
$folderPath = $folderPath."/".$groupInfo["directory"];
$fileRelatedPath = $groupInfo["directory"]."/";
}
$fileRelatedPath = $fileRelatedPath.$fileName;
}
$filePath = $folderPath."/".$fileName;
if (file_exists($filePath)) {
Display::addFlash(Display::return_message($plugin->get_lang("fileIsExist"), "error"));
goto display;
}
if ($fp = @fopen($filePath, "w")) {
$content = file_get_contents($emptyTemplatePath);
fputs($fp, $content);
fclose($fp);
chmod($filePath, api_get_permissions_for_new_files());
$documentId = add_document($courseInfo,
$fileRelatedPath,
"file",
filesize($filePath),
$fileTitle,
null,
false);
if ($documentId) {
api_item_property_update($courseInfo,
TOOL_DOCUMENT,
$documentId,
"DocumentAdded",
$userId,
$groupInfo,
null,
null,
null,
$sessionId);
header("Location: ".$goBackUrl);
exit();
}
$result = FileUtility::createFile(
$values["fileName"],
$fileExt,
$folderId,
$userId,
$sessionId,
$courseId,
$groupId
);
if (isset($result["error"])) {
Display::addFlash(
Display::return_message(
$plugin->get_lang($result["error"]),
"error"
)
);
} else {
Display::addFlash(Display::return_message($plugin->get_lang("impossibleCreateFile"), "error"));
header("Location: " . FileUtility::getUrlToLocation($courseCode, $sessionId, $groupId, $folderId));
exit();
}
}
display:
$goBackUrl = $goBackUrl ?: $_SERVER["HTTP_REFERER"];
$actionsLeft = '<a href="'.$goBackUrl.'">'.Display::return_icon("back.png", get_lang("Back")." ".get_lang("To")." ".get_lang("DocumentsOverview"), "", ICON_SIZE_MEDIUM)."</a>";
$goBackUrl = FileUtility::getUrlToLocation($courseCode, $sessionId, $groupId, $folderId);
$actionsLeft = '<a href="'. $goBackUrl . '">' . Display::return_icon("back.png", get_lang("Back") . " " . get_lang("To") . " " . get_lang("DocumentsOverview"), "", ICON_SIZE_MEDIUM) . "</a>";
Display::display_header($plugin->get_lang("createNewDocument"));
echo Display::toolbarAction("actions-documents", [$actionsLeft]);

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,7 +14,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
const USER_AGENT_MOBILE = "/android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i";
@ -22,21 +25,19 @@ $plugin = OnlyofficePlugin::create();
$isEnable = $plugin->get("enable_onlyoffice_plugin") === 'true';
if (!$isEnable) {
exit("Document server isn't enabled");
die ("Document server isn't enabled");
return;
}
$documentServerUrl = $plugin->get("document_server_url");
if (empty($documentServerUrl)) {
exit("Document server isn't configured");
die ("Document server isn't configured");
return;
}
$config = [];
$docApiUrl = $documentServerUrl."/web-apps/apps/api/documents/api.js";
$docApiUrl = $documentServerUrl . "/web-apps/apps/api/documents/api.js";
$docId = $_GET["docId"];
$groupId = isset($_GET["groupId"]) && !empty($_GET["groupId"]) ? $_GET["groupId"] : null;
@ -67,33 +68,33 @@ $config = [
"fileType" => $extension,
"key" => $key,
"title" => $docInfo["title"],
"url" => $fileUrl,
"url" => $fileUrl
],
"editorConfig" => [
"lang" => $langInfo["isocode"],
"region" => $langInfo["isocode"],
"user" => [
"id" => strval($userId),
"name" => $userInfo["username"],
"name" => $userInfo["username"]
],
"customization" => [
"goback" => [
"blank" => false,
"requestClose" => false,
"text" => get_lang("Back"),
"url" => Security::remove_XSS($_SERVER["HTTP_REFERER"]),
"url" => FileUtility::getUrlToLocation($courseCode, $sessionId, $groupId, $docInfo["parent_id"])
],
"compactHeader" => true,
"toolbarNoTabs" => true,
],
],
"toolbarNoTabs" => true
]
]
];
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$userAgent = $_SERVER["HTTP_USER_AGENT"];
$isMobileAgent = preg_match(USER_AGENT_MOBILE, $userAgent);
if ($isMobileAgent) {
$config['type'] = 'mobile';
$config["type"] = "mobile";
}
$isAllowToEdit = api_is_allowed_to_edit(true, true);
@ -108,7 +109,7 @@ if (!empty($groupId)) {
$groupProperties = GroupManager::get_group_properties($groupId);
$docInfoGroup = api_get_item_property_info(
api_get_course_int_id(),
'document',
"document",
$docId,
$sessionId
);
@ -166,7 +167,7 @@ if (!empty($plugin->get("jwt_secret"))) {
}
/**
* Return callback url.
* Return callback url
*/
function getCallbackUrl(int $docId, int $userId, int $courseId, int $sessionId, int $groupId = null): string
{
@ -177,7 +178,7 @@ function getCallbackUrl(int $docId, int $userId, int $courseId, int $sessionId,
"courseId" => $courseId,
"userId" => $userId,
"docId" => $docId,
"sessionId" => $sessionId,
"sessionId" => $sessionId
];
if (!empty($groupId)) {
@ -186,7 +187,7 @@ function getCallbackUrl(int $docId, int $userId, int $courseId, int $sessionId,
$hashUrl = Crypt::GetHash($data);
return $url.api_get_path(WEB_PLUGIN_PATH)."onlyoffice/callback.php?hash=".$hashUrl;
return $url . api_get_path(WEB_PLUGIN_PATH) . "onlyoffice/callback.php?hash=" . $hashUrl;
}
?>
@ -204,12 +205,57 @@ function getCallbackUrl(int $docId, int $userId, int $courseId, int $sessionId,
display: none;
}
</style>
<script type="text/javascript" src=<?php echo $docApiUrl; ?>></script>
<script type="text/javascript" src=<?php echo $docApiUrl?>></script>
<script type="text/javascript">
var onAppReady = function () {
innerAlert("Document editor ready");
};
var onRequestSaveAs = function (event) {
var url = <?php echo json_encode(api_get_path(WEB_PLUGIN_PATH))?> + "onlyoffice/ajax/saveas.php";
var folderId = <?php echo json_encode($docInfo["parent_id"])?>;
var saveData = {
title: event.data.title,
url: event.data.url,
folderId: folderId ? folderId : 0,
sessionId: <?php echo json_encode($sessionId)?>,
courseId: <?php echo json_encode($courseId)?>,
groupId: <?php echo json_encode($groupId)?>
};
$.ajax(url, {
method: "POST",
data: JSON.stringify(saveData),
processData: false,
contentType: "application/json",
dataType: "json",
success: function (response) {
if (response.error) {
console.error("Create error: ", response.error);
}
},
error: function (e) {
console.error("Create error: ", e);
}
});
};
var connectEditor = function () {
var config = <?php echo json_encode($config)?>;
if ((config.document.fileType === "docxf" || config.document.fileType === "oform")
&& DocsAPI.DocEditor.version().split(".")[0] < 7) {
<?php
echo Display::addFlash(
Display::return_message(
$plugin->get_lang("UpdateOnlyoffice"),
"error"
)
);
?>;
return;
}
$("#cm-content")[0].remove(".container");
$("#main").append('<div id="app-onlyoffice">' +
'<div id="app">' +
@ -218,11 +264,11 @@ function getCallbackUrl(int $docId, int $userId, int $courseId, int $sessionId,
'</div>' +
'</div>');
var config = <?php echo json_encode($config); ?>;
var isMobileAgent = <?php echo json_encode($isMobileAgent); ?>;
var isMobileAgent = <?php echo json_encode($isMobileAgent)?>;
config.events = {
"onAppReady": onAppReady
"onAppReady": onAppReady,
"onRequestSaveAs": onRequestSaveAs
};
docEditor = new DocsAPI.DocEditor("iframeEditor", config);

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,10 +14,12 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
/**
* @package chamilo.plugin.onlyoffice
*/
OnlyofficePlugin::create()->install();
OnlyofficePlugin::create()->install();

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "ONLYOFFICE конекторът ви позволява да преглеждате, редактирате и да си сътрудничите с текстови документи, таблици и презентациив рамките на Chamilo с помощта на ONLYOFFICE Docs.";
@ -18,3 +19,6 @@ $strings["create"] = "Създай";
$strings["fileIsExist"] = "Файлът вече съществува";
$strings["impossibleCreateFile"] = "Не може да се създаде файл";
$strings["createNewDocument"] = "Създай нов документ";
$strings["formTemplate"] = "Шаблон на формуляр";
$strings["fillInFormInOnlyoffice"] = "Попълнете формуляр в ONLYOFFICE";
$strings["UpdateOnlyoffice"] = "Молим да актуализирате ONLYOFFICE Docs към версия 7.0, за да работи с онлайн формуляри за попълване";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "ONLYOFFICE connector maakt het mogelijk om tekstdocumenten, spreadsheets en presentaties te bekijken, te bewerken en samen te werken binnen Chamilo met behulp van ONLYOFFICE Docs.";
@ -17,4 +18,4 @@ $strings["presentation"] = "Presentatie";
$strings["create"] = "Maak";
$strings["fileIsExist"] = "Bestand bestaat al";
$strings["impossibleCreateFile"] = "Onmogelijk om bestand te maken";
$strings["createNewDocument"] = "Nieuw document maken";
$strings["createNewDocument"] = "Nieuw document maken";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "ONLYOFFICE connector allows you to view, edit, and collaborate on text documents, spreadsheets, and presentations within Chamilo using ONLYOFFICE Docs.";
@ -18,3 +19,6 @@ $strings["create"] = "Create";
$strings["fileIsExist"] = "File already exists";
$strings["impossibleCreateFile"] = "Impossible to create file";
$strings["createNewDocument"] = "Create new document";
$strings["formTemplate"] = "Form template";
$strings["fillInFormInOnlyoffice"] = "Fill in form in ONLYOFFICE";
$strings["UpdateOnlyoffice"] = "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "Connecteur ONLYOFFICE vous permet d’afficher, éditer et coéditer les documents texte, les feuilles de calcul et les présentations au sein de Chamilo en utilisant ONLYOFFICE Docs.";
@ -18,3 +19,6 @@ $strings["create"] = "Créer";
$strings["fileIsExist"] = "Le fichier existe déjà";
$strings["impossibleCreateFile"] = "Impossible de créer le fichier";
$strings["createNewDocument"] = "Créer un nouveau document";
$strings["formTemplate"] = "Modèle de formulaire";
$strings["fillInFormInOnlyoffice"] = "Remplir le formulaire dans ONLYOFFICE,";
$strings["UpdateOnlyoffice"] = "Veuillez mettre à jour ONLYOFFICE Docs vers la version 7.0 pour travailler sur les formulaires à remplir en ligne";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "Mit dem ONLYOFFICE-Konnektor können Sie in Chamilo Textdokumente, Tabellenkalkulationen und Präsentationen mit ONLYOFFICE Docs öffnen und bearbeiten";
@ -18,3 +19,6 @@ $strings["create"] = "Erstellen";
$strings["fileIsExist"] = "Die Datei ist bereits vorhanden";
$strings["impossibleCreateFile"] = "Datei kann nicht erstellt werden";
$strings["createNewDocument"] = "Neues Dokument erstellen";
$strings["formTemplate"] = "Formularvorlage";
$strings["fillInFormInOnlyoffice"] = "Formular in ONLYOFFICE ausfüllen";
$strings["UpdateOnlyoffice"] = "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "Ο συνδετήρας ONLYOFFICE σάς επιτρέπει να προβάλετε, να επεξεργαστείτε και να συνεργαστείτε σε έγγραφα κειμένου, υπολογιστικά φύλλα και παρουσιάσεις στο Chamilo χρησιμοποιώντας έγγραφα ONLYOFFICE.";
@ -16,4 +17,4 @@ $strings["presentation"] = "Παρουσίαση";
$strings["create"] = "Δημιουργία";
$strings["fileIsExist"] = "Το αρχείο υπάρχει ήδη";
$strings["impossibleCreateFile"] = "Η δημιουργία αρχείου είναι αδύνατη";
$strings["createNewDocument"] = "Δημιουργία νέου εγγράφου";
$strings["createNewDocument"] = "Δημιουργία νέου εγγράφου";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "Il connettore ONLYOFFICE ti consente di visualizzare, modificare e collaborare su documenti di testo, fogli di calcolo e presentazioni all'interno di Chamilo con ONLYOFFICE Docs.";
@ -18,3 +19,6 @@ $strings["create"] = "Crea";
$strings["fileIsExist"] = "Il file esiste già";
$strings["impossibleCreateFile"] = "Impossibile creare file";
$strings["createNewDocument"] = "Crea nuovo documento";
$strings["formTemplate"] = "Modello di modulo";
$strings["fillInFormInOnlyoffice"] = "Compilare il modulo in ONLYOFFICE";
$strings["UpdateOnlyoffice"] = "Si prega di aggiornare ONLYOFFICE Docs alla versione 7.0 per lavorare su moduli compilabili online";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "ONLYOFFICE connector pozwala na przeglądanie, edytowanie oraz współpracę nad dokumentami tekstowymi, arkuszami kalkulacyjnymi i prezentacjami w Chamilo za pośrednictwem ONLYOFFICE Docs.";
@ -17,4 +18,4 @@ $strings["presentation"] = "Prezentacja";
$strings["create"] = "Utwórz";
$strings["fileIsExist"] = "Plik już istnieje";
$strings["impossibleCreateFile"] = "Nie można utworzyć pliku";
$strings["createNewDocument"] = "Utwórz nowy dokument";
$strings["createNewDocument"] = "Utwórz nowy dokument";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "ONLYOFFICE connector permite que você visualize, edite e colabore em documentos de texto, planilhas e apresentações dentro do Chamilo usando o ONLYOFFICE Docs.";
@ -18,3 +19,6 @@ $strings["create"] = "Criar";
$strings["fileIsExist"] = "Arquivo já existe";
$strings["impossibleCreateFile"] = "Impossível criar arquivo";
$strings["createNewDocument"] = "Criar novo documento";
$strings["formTemplate"] = "Modelo de formulário";
$strings["fillInFormInOnlyoffice"] = "Preencher formulário no ONLYOFFICE";
$strings["UpdateOnlyoffice"] = "Atualize o ONLYOFFICE Docs para a versão 7.0 para trabalhar em formulários preenchíveis online";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "Коннектор ONLYOFFICE позволяет просматривать и редактировать текстовые документы, электронные таблицы и презентации и работать над ними совместно в Chamilo, используя ONLYOFFICE Docs.";
@ -18,3 +19,6 @@ $strings["create"] = "Создать ";
$strings["fileIsExist"] = "Файл уже существует";
$strings["impossibleCreateFile"] = "Невозможно создать файл";
$strings["createNewDocument"] = "Создать новый документ";
$strings["formTemplate"] = "Шаблон формы";
$strings["fillInFormInOnlyoffice"] = "Заполнить форму в ONLYOFFICE";
$strings["UpdateOnlyoffice"] = "Обновите сервер ONLYOFFICE Docs до версии 7.0 для работы с формами онлайн";

@ -1,6 +1,7 @@
<?php
/**
* @author ASENSIO SYSTEM SIA
*
*/
$strings["plugin_title"] = "ONLYOFFICE";
$strings['plugin_comment'] = "El conector de ONLYOFFICE le permite ver, editar y colaborar en documentos de texto, hojas de cálculo y presentaciones dentro de Chamilo utilizando ONLYOFFICE Docs.";
@ -18,3 +19,6 @@ $strings["create"] = "Crear";
$strings["fileIsExist"] = "El archivo ya existe";
$strings["impossibleCreateFile"] = "No es posible crear el archivo";
$strings["createNewDocument"] = "Crear documento nuevo";
$strings["formTemplate"] = "Plantilla de formulario";
$strings["fillInFormInOnlyoffice"] = "Rellenar el formulario en ONLYOFFICE";
$strings["UpdateOnlyoffice"] = "Por favor, actualice ONLYOFFICE Docs a la versión 7.0 para poder trabajar con formularios rellenables en línea";

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,20 +14,22 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__."/../../../main/inc/global.inc.php";
class AppConfig
{
require_once __DIR__ . "/../../../main/inc/global.inc.php";
class AppConfig {
/**
* The config key for the jwt header.
* The config key for the jwt header
*
* @var string
*/
private const jwtHeader = "onlyoffice_jwt_header";
/**
* Get the jwt header setting.
* Get the jwt header setting
*
* @return string
*/

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,13 +14,15 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__."/../../../main/inc/global.inc.php";
class Crypt
{
require_once __DIR__ . "/../../../main/inc/global.inc.php";
class Crypt {
/**
* Generate token for the object.
* Generate token for the object
*
* @param array $object - object to signature
*
@ -31,7 +34,7 @@ class Crypt
}
/**
* Create an object from the token.
* Create an object from the token
*
* @param string $token - token
*
@ -45,11 +48,10 @@ class Crypt
return [$result, "token is empty"];
}
try {
$result = \Firebase\JWT\JWT::decode($token, api_get_security_key(), ["HS256"]);
$result = \Firebase\JWT\JWT::decode($token, api_get_security_key(), array("HS256"));
} catch (\UnexpectedValueException $e) {
$error = $e->getMessage();
}
return [$result, $error];
}
}

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,70 +14,74 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__."/../../../main/inc/global.inc.php";
class FileUtility
{
require_once __DIR__ . "/../../../main/inc/global.inc.php";
class FileUtility {
/**
* Application name.
* Application name
*/
public const app_name = "onlyoffice";
/**
* Extensions of files that can edit.
* Extensions of files that can edit
*
* @var array
*/
public static $can_edit_types = [
"docx",
"docxf",
"oform",
"xlsx",
"pptx",
"ppsx",
"ppsx"
];
/**
* Extensions of files that can view.
* Extensions of files that can view
*
* @var array
*/
public static $can_view_types = [
"docx", "xlsx", "pptx", "ppsx",
"txt", "csv", "odt", "ods", "odp",
"doc", "xls", "ppt", "pps", "epub",
"rtf", "mht", "html", "htm", "xps", "pdf", "djvu",
"docx", "docxf", "oform", "xlsx", "pptx", "ppsx",
"txt", "csv", "odt", "ods","odp",
"doc", "xls", "ppt", "pps","epub",
"rtf", "mht", "html", "htm","xps","pdf","djvu"
];
/**
* Extensions of text files.
* Extensions of text files
*
* @var array
*/
public static $text_doc = [
"docx", "txt", "odt", "doc", "rtf", "html",
"htm", "xps", "pdf", "djvu",
"docx", "docxf", "oform", "txt", "odt", "doc", "rtf", "html",
"htm", "xps", "pdf", "djvu"
];
/**
* Extensions of presentation files.
* Extensions of presentation files
*
* @var array
*/
public static $presentation_doc = [
"pptx", "ppsx", "odp", "ppt", "pps",
public static $presentation_doc = [
"pptx", "ppsx", "odp", "ppt", "pps"
];
/**
* Extensions of spreadsheet files.
* Extensions of spreadsheet files
*
* @var array
*/
public static $spreadsheet_doc = [
"xlsx", "csv", "ods", "xls",
"xlsx", "csv", "ods", "xls"
];
/**
* Return file type by extension.
* Return file type by extension
*/
public static function getDocType(string $extension): string
{
@ -94,7 +99,7 @@ class FileUtility
}
/**
* Return file extension by file type.
* Return file extension by file type
*/
public static function getDocExt(string $type): string
{
@ -107,21 +112,25 @@ class FileUtility
if ($type === "presentation") {
return "pptx";
}
if ($type === "formTemplate") {
return "docxf";
}
return "";
}
/**
* Return file url for download.
* Return file url for download
*/
public static function getFileUrl(int $courseId, int $userId, int $docId, int $sessionId = null, int $groupId = null): string
{
$data = [
"type" => "download",
"courseId" => $courseId,
"userId" => $userId,
"docId" => $docId,
"sessionId" => $sessionId,
"sessionId" => $sessionId
];
if (!empty($groupId)) {
@ -130,33 +139,128 @@ class FileUtility
$hashUrl = Crypt::GetHash($data);
return api_get_path(WEB_PLUGIN_PATH).self::app_name."/"."callback.php?hash=".$hashUrl;
return api_get_path(WEB_PLUGIN_PATH) . self::app_name . "/" . "callback.php?hash=" . $hashUrl;
}
/**
* Return location file in chamilo documents
*/
function getUrlToLocation($courseCode, $sessionId, $groupId, $folderId) {
return api_get_path(WEB_CODE_PATH)."document/document.php"
. "?cidReq=" . Security::remove_XSS($courseCode)
. "&id_session=" . Security::remove_XSS($sessionId)
. "&gidReq=" . Security::remove_XSS($groupId)
. "&id=" . Security::remove_XSS($folderId);
}
/**
* Return file key.
* Return file key
*/
public static function getKey(string $courseCode, int $docId): string
{
$docInfo = DocumentManager::get_document_data_by_id($docId, $courseCode);
$mtime = filemtime($docInfo["absolute_path"]);
$key = $mtime.$courseCode.$docId;
$key = $mtime . $courseCode . $docId;
return self::GenerateRevisionId($key);
}
/**
* Translation key to a supported form.
* Translation key to a supported form
*/
public static function GenerateRevisionId(string $expectedKey): string
{
if (strlen($expectedKey) > 20) {
$expectedKey = crc32($expectedKey);
}
if (strlen($expectedKey) > 20) $expectedKey = crc32( $expectedKey);
$key = preg_replace("[^0-9-.a-zA-Z_=]", "_", $expectedKey);
$key = substr($key, 0, min([strlen($key), 20]));
$key = substr($key, 0, min(array(strlen($key), 20)));
return $key;
}
/**
* Create new file
*/
public static function createFile(
string $basename,
string $fileExt,
int $folderId,
int $userId,
int $sessionId,
int $courseId,
int $groupId,
string $templatePath = ""): array
{
$courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo["code"];
$groupInfo = GroupManager::get_group_properties($groupId);
$fileTitle = Security::remove_XSS($basename). "." .$fileExt;
$fileNamePrefix = DocumentManager::getDocumentSuffix($courseInfo, $sessionId, $groupId);
$fileName = preg_replace('/\.\./', '', $basename) . $fileNamePrefix . "." . $fileExt;
if (empty($templatePath)) {
$templatePath = TemplateManager::getEmptyTemplate($fileExt);
}
$folderPath = '';
$fileRelatedPath = "/";
if (!empty($folderId)) {
$document_data = DocumentManager::get_document_data_by_id(
$folderId,
$courseCode,
true,
$sessionId
);
$folderPath = $document_data["absolute_path"];
$fileRelatedPath = $fileRelatedPath . substr($document_data["absolute_path_from_document"], 10) . "/" . $fileName;
} else {
$folderPath = api_get_path(SYS_COURSE_PATH) . api_get_course_path($courseCode) . "/document";
if (!empty($groupId)) {
$folderPath = $folderPath . "/" . $groupInfo["directory"];
$fileRelatedPath = $groupInfo["directory"] . "/";
}
$fileRelatedPath = $fileRelatedPath . $fileName;
}
$filePath = $folderPath . "/" . $fileName;
if (file_exists($filePath)) {
return ["error" => "fileIsExist"];
}
if ($fp = @fopen($filePath, "w")) {
$content = file_get_contents($templatePath);
fputs($fp, $content);
fclose($fp);
chmod($filePath, api_get_permissions_for_new_files());
$documentId = add_document(
$courseInfo,
$fileRelatedPath,
"file",
filesize($filePath),
$fileTitle,
null,
false
);
if ($documentId) {
api_item_property_update(
$courseInfo,
TOOL_DOCUMENT,
$documentId,
"DocumentAdded",
$userId,
$groupInfo,
null,
null,
null,
$sessionId
);
} else {
return ["error" => "impossibleCreateFile"];
}
}
return ["documentId" => $documentId];
}
}

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,13 +14,15 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__."/../../../main/inc/global.inc.php";
class LangManager
{
require_once __DIR__ . "/../../../main/inc/global.inc.php";
class LangManager {
/**
* Return lang info for current user.
* Return lang info for current user
*/
public static function getLangUser(): array
{
@ -31,12 +34,11 @@ class LangManager
if (empty($userLang)) {
$langId = SubLanguageManager::get_platform_language_id();
$langInfo = api_get_language_info($langId);
return $langInfo;
}
$allLang = SubLanguageManager::getAllLanguages();
foreach ($allLang as $langItem) {
foreach($allLang as $langItem) {
if ($langItem["english_name"] === $userLang) {
$langInfo = $langItem;
break;

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,7 +14,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class OnlyofficeActionObserver extends HookObserver implements HookDocumentActionObserverInterface
{
/**
@ -28,7 +31,7 @@ class OnlyofficeActionObserver extends HookObserver implements HookDocumentActio
}
/**
* Create a Onlyoffice edit tools when the Chamilo loads document tools.
* Create a Onlyoffice edit tools when the Chamilo loads document tools
*
* @param HookDocumentActionEventInterface $event - the hook event
*/
@ -38,7 +41,6 @@ class OnlyofficeActionObserver extends HookObserver implements HookDocumentActio
if ($data["type"] === HOOK_EVENT_TYPE_PRE) {
$data["actions"][] = OnlyofficeTools::getButtonCreateNew();
return $data;
}
}

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,11 +14,13 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class OnlyofficeItemActionObserver extends HookObserver implements HookDocumentItemActionObserverInterface
{
/**
* Constructor.
* Constructor
*/
public function __construct()
{
@ -28,7 +31,7 @@ class OnlyofficeItemActionObserver extends HookObserver implements HookDocumentI
}
/**
* Create a Onlyoffice edit tools when the Chamilo loads document items.
* Create a Onlyoffice edit tools when the Chamilo loads document items
*
* @param HookDocumentItemActionEventInterface $event - the hook event
*/
@ -38,7 +41,6 @@ class OnlyofficeItemActionObserver extends HookObserver implements HookDocumentI
if ($data["type"] === HOOK_EVENT_TYPE_PRE) {
$data["actions"][] = OnlyofficeTools::getButtonEdit($data);
return $data;
}
}

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,11 +14,13 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class OnlyofficeItemViewObserver extends HookObserver implements HookDocumentItemViewObserverInterface
{
/**
* Constructor.
* Constructor
*/
public function __construct()
{
@ -28,7 +31,7 @@ class OnlyofficeItemViewObserver extends HookObserver implements HookDocumentIte
}
/**
* Create a Onlyoffice view tools when the Chamilo loads document items.
* Create a Onlyoffice view tools when the Chamilo loads document items
*
* @param HookDocumentItemViewEventInterface $event - the hook event
*/

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,6 +14,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
@ -28,18 +30,18 @@ class OnlyofficePlugin extends Plugin implements HookPluginInterface
protected function __construct()
{
parent::__construct(
"1.0",
"1.2.0",
"Asensio System SIA",
[
"enable_onlyoffice_plugin" => "boolean",
"document_server_url" => "text",
"jwt_secret" => "text",
"jwt_secret" => "text"
]
);
}
/**
* Create OnlyofficePlugin object.
* Create OnlyofficePlugin object
*/
public static function create(): OnlyofficePlugin
{

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,14 +14,17 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class OnlyofficeTools
{
class OnlyofficeTools {
/**
* Return button-link to onlyoffice editor for file.
* Return button-link to onlyoffice editor for file
*/
public static function getButtonEdit(array $document_data): string
{
$plugin = OnlyofficePlugin::create();
$isEnable = $plugin->get("enable_onlyoffice_plugin") === "true";
@ -28,7 +32,7 @@ class OnlyofficeTools
return '';
}
$urlToEdit = api_get_path(WEB_PLUGIN_PATH)."onlyoffice/editor.php";
$urlToEdit = api_get_path(WEB_PLUGIN_PATH) . "onlyoffice/editor.php";
$extension = strtolower(pathinfo($document_data["title"], PATHINFO_EXTENSION));
@ -37,19 +41,24 @@ class OnlyofficeTools
$groupId = api_get_group_id();
if (!empty($groupId)) {
$urlToEdit = $urlToEdit."?groupId=".$groupId."&";
$urlToEdit = $urlToEdit . "?groupId=" . $groupId . "&";
} else {
$urlToEdit = $urlToEdit."?";
$urlToEdit = $urlToEdit . "?";
}
$documentId = $document_data["id"];
$urlToEdit = $urlToEdit."docId=".$documentId;
$urlToEdit = $urlToEdit . "docId=" . $documentId;
if ($canEdit || $canView) {
$tooltip = $plugin->get_lang('openByOnlyoffice');
if ($extension === "oform") {
$tooltip = $plugin->get_lang('fillInFormInOnlyoffice');
}
return Display::url(
Display::return_icon(
'../../plugin/onlyoffice/resources/onlyoffice_edit.png',
$plugin->get_lang('openByOnlyoffice')
$tooltip
),
$urlToEdit
);
@ -59,10 +68,11 @@ class OnlyofficeTools
}
/**
* Return button-link to onlyoffice editor for view file.
* Return button-link to onlyoffice editor for view file
*/
public static function getButtonView(array $document_data): string
public static function getButtonView (array $document_data): string
{
$plugin = OnlyofficePlugin::create();
$isEnable = $plugin->get("enable_onlyoffice_plugin") === "true";
@ -70,7 +80,7 @@ class OnlyofficeTools
return '';
}
$urlToEdit = api_get_path(WEB_PLUGIN_PATH)."onlyoffice/editor.php";
$urlToEdit = api_get_path(WEB_PLUGIN_PATH) . "onlyoffice/editor.php";
$sessionId = api_get_session_id();
$courseInfo = api_get_course_info();
@ -89,9 +99,9 @@ class OnlyofficeTools
$docInfoGroup = api_get_item_property_info(api_get_course_int_id(), 'document', $documentId, $sessionId);
$isGroupAccess = GroupManager::allowUploadEditDocument($userId, $courseInfo["code"], $groupProperties, $docInfoGroup);
$urlToEdit = $urlToEdit."?groupId=".$groupId."&";
$urlToEdit = $urlToEdit . "?groupId=" . $groupId . "&";
} else {
$urlToEdit = $urlToEdit."?";
$urlToEdit = $urlToEdit . "?";
}
$isAllowToEdit = api_is_allowed_to_edit(true, true);
@ -99,7 +109,7 @@ class OnlyofficeTools
$accessRights = $isAllowToEdit || $isMyDir || $isGroupAccess;
$urlToEdit = $urlToEdit."docId=".$documentId;
$urlToEdit = $urlToEdit . "docId=" . $documentId;
if ($canView && !$accessRights) {
return Display::url(Display::return_icon('../../plugin/onlyoffice/resources/onlyoffice_view.png', $plugin->get_lang('openByOnlyoffice')), $urlToEdit, ["style" => "float:right; margin-right:8px"]);
@ -109,10 +119,11 @@ class OnlyofficeTools
}
/**
* Return button-link to onlyoffice create new.
* Return button-link to onlyoffice create new
*/
public static function getButtonCreateNew(): string
public static function getButtonCreateNew (): string
{
$plugin = OnlyofficePlugin::create();
$isEnable = $plugin->get("enable_onlyoffice_plugin") === "true";
@ -125,12 +136,12 @@ class OnlyofficeTools
$groupId = api_get_group_id();
$userId = api_get_user_id();
$urlToCreate = api_get_path(WEB_PLUGIN_PATH)."onlyoffice/create.php"
."?folderId=".(empty($_GET["id"]) ? '0' : (int) $_GET["id"])
."&courseId=".$courseId
."&groupId=".$groupId
."&sessionId=".$sessionId
."&userId=".$userId;
$urlToCreate = api_get_path(WEB_PLUGIN_PATH) . "onlyoffice/create.php"
."?folderId=" . (empty($_GET["id"])?'0':(int)$_GET["id"])
. "&courseId=" . $courseId
. "&groupId=" . $groupId
. "&sessionId=" . $sessionId
. "&userId=" . $userId;
return Display::url(
Display::return_icon(

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,15 +14,17 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__."/../../../main/inc/global.inc.php";
class TemplateManager
{
require_once __DIR__ . "/../../../main/inc/global.inc.php";
class TemplateManager {
/**
* Mapping local path to templates.
* Mapping local path to templates
*
* @var array
* @var Array
*/
private static $localPath = [
"bg" => "bg-BG",
@ -44,11 +47,11 @@ class TemplateManager
"sv" => "sv-SE",
"uk" => "uk-UA",
"vi" => "vi-VN",
"zh" => "zh-CN",
"zh" => "zh-CN"
];
/**
* Return path to template new file.
* Return path to template new file
*/
public static function getEmptyTemplate($fileExtension): string
{
@ -57,8 +60,8 @@ class TemplateManager
if (!array_key_exists($lang, self::$localPath)) {
$lang = "en";
}
$templateFolder = api_get_path(SYS_PLUGIN_PATH)."onlyoffice/assets/".self::$localPath[$lang];
$templateFolder = api_get_path(SYS_PLUGIN_PATH) . "onlyoffice/assets/" . self::$localPath[$lang];
return $templateFolder."/".ltrim($fileExtension, ".").".zip";
return $templateFolder . "/" . ltrim($fileExtension, ".") . ".zip";
}
}

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,10 +14,13 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
/**
* @author Asensio System SIA
*/
$plugin_info = OnlyofficePlugin::create()->get_info();
$plugin_info = OnlyofficePlugin::create()->get_info();

@ -1,6 +1,7 @@
<?php
/**
* (c) Copyright Ascensio System SIA 2021.
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,10 +14,12 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
require_once __DIR__.'/../../main/inc/global.inc.php';
/**
* uninstall the plugin.
* uninstall the plugin
*/
OnlyofficePlugin::create()->uninstall();
OnlyofficePlugin::create()->uninstall();
Loading…
Cancel
Save