Apply cs fixes
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
a546de06b4
Коммит
9bb9661795
|
@ -15,7 +15,6 @@ use OCA\Richdocuments\AppInfo\Application;
|
|||
use \OCP\IConfig;
|
||||
|
||||
class AppConfig {
|
||||
|
||||
public const FEDERATION_USE_TRUSTED_DOMAINS = 'federation_use_trusted_domains';
|
||||
|
||||
public const SYSTEM_GS_TRUSTED_HOSTS = 'gs.trustedHosts';
|
||||
|
@ -30,9 +29,9 @@ class AppConfig {
|
|||
'token_ttl' => 36000, // 10 hours
|
||||
];
|
||||
|
||||
const WATERMARK_APP_NAMESPACE = 'files';
|
||||
public const WATERMARK_APP_NAMESPACE = 'files';
|
||||
|
||||
const APP_SETTING_TYPES = [
|
||||
public const APP_SETTING_TYPES = [
|
||||
'watermark_allGroupsList' => 'array',
|
||||
'watermark_allTagsList' => 'array',
|
||||
'watermark_linkTagsList' => 'array'
|
||||
|
@ -59,7 +58,7 @@ class AppConfig {
|
|||
*/
|
||||
public function getAppValue($key) {
|
||||
$defaultValue = null;
|
||||
if (array_key_exists($key, $this->defaults)){
|
||||
if (array_key_exists($key, $this->defaults)) {
|
||||
$defaultValue = $this->defaults[$key];
|
||||
}
|
||||
return $this->config->getAppValue($this->getAppNamespace($key), $key, $defaultValue);
|
||||
|
@ -124,5 +123,4 @@ class AppConfig {
|
|||
public function isTrustedDomainAllowedForFederation(): bool {
|
||||
return $this->config->getAppValue(Application::APPNAME, self::FEDERATION_USE_TRUSTED_DOMAINS, 'no') === 'yes';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,7 @@
|
|||
namespace OCA\Richdocuments\AppInfo;
|
||||
|
||||
use OC\EventDispatcher\SymfonyAdapter;
|
||||
use OC\Files\Type\Detection;
|
||||
use OC\Security\CSP\ContentSecurityPolicy;
|
||||
use OCA\Files_Sharing\Listener\LoadAdditionalListener;
|
||||
use OCA\Richdocuments\AppConfig;
|
||||
use OCA\Richdocuments\Capabilities;
|
||||
use OCA\Richdocuments\Middleware\WOPIMiddleware;
|
||||
|
@ -57,7 +55,6 @@ use OCP\IL10N;
|
|||
use OCP\IPreview;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
|
||||
public const APPNAME = 'richdocuments';
|
||||
|
||||
public function __construct(array $urlParams = array()) {
|
||||
|
@ -75,15 +72,15 @@ class Application extends App implements IBootstrap {
|
|||
|
||||
public function boot(IBootContext $context): void {
|
||||
$currentUser = \OC::$server->getUserSession()->getUser();
|
||||
if($currentUser !== null) {
|
||||
if ($currentUser !== null) {
|
||||
/** @var PermissionManager $permissionManager */
|
||||
$permissionManager = \OC::$server->query(PermissionManager::class);
|
||||
if(!$permissionManager->isEnabledForUser($currentUser)) {
|
||||
if (!$permissionManager->isEnabledForUser($currentUser)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$context->injectFn(function(ITemplateManager $templateManager, IL10N $l10n, IConfig $config, CapabilitiesService $capabilitiesService) {
|
||||
$context->injectFn(function (ITemplateManager $templateManager, IL10N $l10n, IConfig $config, CapabilitiesService $capabilitiesService) {
|
||||
if (empty($capabilitiesService->getCapabilities())) {
|
||||
return;
|
||||
}
|
||||
|
@ -98,7 +95,7 @@ class Application extends App implements IBootstrap {
|
|||
$odtType->addMimetype('application/vnd.oasis.opendocument.text-template');
|
||||
}
|
||||
$odtType->setIconClass('icon-filetype-document');
|
||||
$odtType->setRatio(21/29.7);
|
||||
$odtType->setRatio(21 / 29.7);
|
||||
return $odtType;
|
||||
});
|
||||
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
|
||||
|
@ -111,7 +108,7 @@ class Application extends App implements IBootstrap {
|
|||
$odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet-template');
|
||||
}
|
||||
$odsType->setIconClass('icon-filetype-spreadsheet');
|
||||
$odsType->setRatio(16/9);
|
||||
$odsType->setRatio(16 / 9);
|
||||
return $odsType;
|
||||
});
|
||||
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
|
||||
|
@ -124,7 +121,7 @@ class Application extends App implements IBootstrap {
|
|||
$odpType->addMimetype('application/vnd.oasis.opendocument.presentation-template');
|
||||
}
|
||||
$odpType->setIconClass('icon-filetype-presentation');
|
||||
$odpType->setRatio(16/9);
|
||||
$odpType->setRatio(16 / 9);
|
||||
return $odpType;
|
||||
});
|
||||
|
||||
|
@ -174,23 +171,23 @@ class Application extends App implements IBootstrap {
|
|||
/** @var IPreview $previewManager */
|
||||
$previewManager = $container->query(IPreview::class);
|
||||
|
||||
$previewManager->registerProvider('/application\/vnd.ms-excel/', function() use ($container) {
|
||||
$previewManager->registerProvider('/application\/vnd.ms-excel/', function () use ($container) {
|
||||
return $container->query(MSExcel::class);
|
||||
});
|
||||
|
||||
$previewManager->registerProvider('/application\/msword/', function() use ($container) {
|
||||
$previewManager->registerProvider('/application\/msword/', function () use ($container) {
|
||||
return $container->query(MSWord::class);
|
||||
});
|
||||
|
||||
$previewManager->registerProvider('/application\/vnd.openxmlformats-officedocument.*/', function() use ($container) {
|
||||
$previewManager->registerProvider('/application\/vnd.openxmlformats-officedocument.*/', function () use ($container) {
|
||||
return $container->query(OOXML::class);
|
||||
});
|
||||
|
||||
$previewManager->registerProvider('/application\/vnd.oasis.opendocument.*/', function() use ($container) {
|
||||
$previewManager->registerProvider('/application\/vnd.oasis.opendocument.*/', function () use ($container) {
|
||||
return $container->query(OpenDocument::class);
|
||||
});
|
||||
|
||||
$previewManager->registerProvider('/application\/pdf/', function() use ($container) {
|
||||
$previewManager->registerProvider('/application\/pdf/', function () use ($container) {
|
||||
return $container->query(Pdf::class);
|
||||
});
|
||||
}
|
||||
|
@ -261,8 +258,9 @@ class Application extends App implements IBootstrap {
|
|||
// Supported only on Linux OS, and x86_64 & ARM64 platforms
|
||||
$supportedArchs = array('x86_64', 'aarch64');
|
||||
$osFamily = PHP_VERSION_ID >= 70200 ? PHP_OS_FAMILY : PHP_OS;
|
||||
if ($osFamily !== 'Linux' || !in_array(php_uname('m'), $supportedArchs))
|
||||
if ($osFamily !== 'Linux' || !in_array(php_uname('m'), $supportedArchs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$CODEAppID = (php_uname('m') === 'x86_64') ? 'richdocumentscode' : 'richdocumentscode_arm64';
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class Cleanup extends TimedJob {
|
|||
$this->db = $db;
|
||||
$this->wopiMapper = $wopiMapper;
|
||||
|
||||
$this->setInterval(60*60);
|
||||
$this->setInterval(60 * 60);
|
||||
}
|
||||
|
||||
protected function run($argument) {
|
||||
|
@ -51,11 +51,9 @@ class Cleanup extends TimedJob {
|
|||
|
||||
// Expired WOPI access tokens
|
||||
$this->cleanUpWopiTokens();
|
||||
|
||||
}
|
||||
|
||||
private function cleanUpWopiTokens()
|
||||
{
|
||||
private function cleanUpWopiTokens() {
|
||||
$tokenIds = $this->wopiMapper->getExpiredTokenIds(1000);
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->delete('richdocuments_wopi')
|
||||
|
|
|
@ -34,7 +34,7 @@ class ObtainCapabilities extends TimedJob {
|
|||
public function __construct(CapabilitiesService $capabilitiesService) {
|
||||
$this->capabilitiesService = $capabilitiesService;
|
||||
|
||||
$this->setInterval(60*60);
|
||||
$this->setInterval(60 * 60);
|
||||
}
|
||||
|
||||
protected function run($argument) {
|
||||
|
|
|
@ -28,8 +28,7 @@ use OCP\Capabilities\ICapability;
|
|||
use OCP\IL10N;
|
||||
|
||||
class Capabilities implements ICapability {
|
||||
|
||||
const MIMETYPES = [
|
||||
public const MIMETYPES = [
|
||||
'application/vnd.oasis.opendocument.text',
|
||||
'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'application/vnd.oasis.opendocument.graphics',
|
||||
|
@ -68,7 +67,7 @@ class Capabilities implements ICapability {
|
|||
'text/csv'
|
||||
];
|
||||
|
||||
const MIMETYPES_OPTIONAL = [
|
||||
public const MIMETYPES_OPTIONAL = [
|
||||
'image/svg+xml',
|
||||
'application/pdf',
|
||||
'text/plain',
|
||||
|
|
|
@ -26,11 +26,9 @@ namespace OCA\RichDocuments\Command;
|
|||
|
||||
use OCA\Richdocuments\AppConfig;
|
||||
use OCA\Richdocuments\Service\CapabilitiesService;
|
||||
use OCA\Richdocuments\TemplateManager;
|
||||
use OCA\Richdocuments\WOPI\DiscoveryManager;
|
||||
use OCA\Richdocuments\WOPI\Parser;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
@ -85,5 +83,4 @@ class ActivateConfig extends Command {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace OCA\RichDocuments\Command;
|
|||
|
||||
use OCA\Richdocuments\TemplateManager;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
@ -58,5 +57,4 @@ class UpdateEmptyTemplates extends Command {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -140,11 +140,10 @@ class DirectViewController extends Controller {
|
|||
}
|
||||
|
||||
$relativePath = '/new.odt';
|
||||
|
||||
} else {
|
||||
try {
|
||||
$item = $folder->getById($direct->getFileid())[0];
|
||||
if(!($item instanceof Node)) {
|
||||
if (!($item instanceof Node)) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
|
@ -190,7 +189,6 @@ class DirectViewController extends Controller {
|
|||
$this->logger->logException($e);
|
||||
return $this->renderErrorPage('Failed to open the requested file.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function showPublicShare(Direct $direct) {
|
||||
|
@ -245,12 +243,11 @@ class DirectViewController extends Controller {
|
|||
return $response;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['app'=>'richdocuments']);
|
||||
$this->logger->logException($e, ['app' => 'richdocuments']);
|
||||
return $this->renderErrorPage('Failed to open the requested file.');
|
||||
}
|
||||
|
||||
return new TemplateResponse('core', '403', [], 'guest');
|
||||
|
||||
}
|
||||
|
||||
private function renderErrorPage($message) {
|
||||
|
|
|
@ -40,7 +40,6 @@ use Psr\Log\LoggerInterface;
|
|||
use Throwable;
|
||||
|
||||
class DocumentAPIController extends \OCP\AppFramework\OCSController {
|
||||
|
||||
private $rootFolder;
|
||||
private $shareManager;
|
||||
private $templateManager;
|
||||
|
|
|
@ -27,7 +27,6 @@ use OCP\Files\NotFoundException;
|
|||
use OCP\Files\NotPermittedException;
|
||||
use \OCP\IRequest;
|
||||
use \OCP\IConfig;
|
||||
use \OCP\IL10N;
|
||||
use \OCP\ILogger;
|
||||
use \OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use \OCP\AppFramework\Http\FeaturePolicy;
|
||||
|
@ -105,7 +104,7 @@ class DocumentController extends Controller {
|
|||
public function extAppGetData($fileId) {
|
||||
$secretToken = $this->request->getParam('secret_token');
|
||||
$apps = array_filter(explode(',', $this->appConfig->getAppValue('external_apps')));
|
||||
foreach($apps as $app) {
|
||||
foreach ($apps as $app) {
|
||||
if ($app !== '' && $secretToken === $app) {
|
||||
$appName = explode(':', $app);
|
||||
$this->logger->debug('External app "{extApp}" authenticated; issuing access token for fileId {fileId}', [
|
||||
|
@ -116,7 +115,7 @@ class DocumentController extends Controller {
|
|||
try {
|
||||
$folder = $this->rootFolder->getUserFolder($this->uid);
|
||||
$item = $folder->getById($fileId)[0];
|
||||
if(!($item instanceof Node)) {
|
||||
if (!($item instanceof Node)) {
|
||||
throw new \Exception();
|
||||
}
|
||||
list($urlSrc, $token) = $this->tokenManager->getToken($item->getId());
|
||||
|
@ -126,7 +125,7 @@ class DocumentController extends Controller {
|
|||
'token' => $token
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['app'=>'richdocuments']);
|
||||
$this->logger->logException($e, ['app' => 'richdocuments']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +183,7 @@ class DocumentController extends Controller {
|
|||
$item = $folder->getById($fileId)[0];
|
||||
}
|
||||
|
||||
if(!($item instanceof File)) {
|
||||
if (!($item instanceof File)) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
|
@ -221,8 +220,7 @@ class DocumentController extends Controller {
|
|||
];
|
||||
|
||||
$encryptionManager = \OC::$server->getEncryptionManager();
|
||||
if ($encryptionManager->isEnabled())
|
||||
{
|
||||
if ($encryptionManager->isEnabled()) {
|
||||
// Update the current file to be accessible with system public shared key
|
||||
$owner = $item->getOwner()->getUID();
|
||||
$absPath = '/' . $owner . '/' . $item->getInternalPath();
|
||||
|
@ -236,7 +234,7 @@ class DocumentController extends Controller {
|
|||
$this->setupPolicy($response);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['app'=>'richdocuments']);
|
||||
$this->logger->logException($e, ['app' => 'richdocuments']);
|
||||
return $this->renderErrorPage('Failed to open the requested file.');
|
||||
}
|
||||
}
|
||||
|
@ -309,7 +307,7 @@ class DocumentController extends Controller {
|
|||
try {
|
||||
$share = $this->shareManager->getShareByToken($shareToken);
|
||||
// not authenticated ?
|
||||
if($share->getPassword()){
|
||||
if ($share->getPassword()) {
|
||||
if (!$this->session->exists('public_link_authenticated')
|
||||
|| $this->session->get('public_link_authenticated') !== (string)$share->getId()
|
||||
) {
|
||||
|
@ -322,7 +320,7 @@ class DocumentController extends Controller {
|
|||
}
|
||||
|
||||
$node = $share->getNode();
|
||||
if($node instanceof Folder) {
|
||||
if ($node instanceof Folder) {
|
||||
$item = $node->getById($fileId)[0];
|
||||
} else {
|
||||
$item = $node;
|
||||
|
@ -355,7 +353,7 @@ class DocumentController extends Controller {
|
|||
return $response;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['app'=>'richdocuments']);
|
||||
$this->logger->logException($e, ['app' => 'richdocuments']);
|
||||
return $this->renderErrorPage('Failed to open the requested file.');
|
||||
}
|
||||
|
||||
|
@ -402,7 +400,7 @@ class DocumentController extends Controller {
|
|||
$this->logger->warning('Failed to connect to remote collabora instance for ' . $fileId);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['app'=>'richdocuments']);
|
||||
$this->logger->logException($e, ['app' => 'richdocuments']);
|
||||
return $this->renderErrorPage('Failed to open the requested file.');
|
||||
}
|
||||
|
||||
|
@ -425,7 +423,7 @@ class DocumentController extends Controller {
|
|||
try {
|
||||
$share = $this->shareManager->getShareByToken($shareToken);
|
||||
// not authenticated ?
|
||||
if($share->getPassword()){
|
||||
if ($share->getPassword()) {
|
||||
if (!$this->session->exists('public_link_authenticated')
|
||||
|| $this->session->get('public_link_authenticated') !== (string)$share->getId()
|
||||
) {
|
||||
|
@ -486,7 +484,7 @@ class DocumentController extends Controller {
|
|||
} catch (ShareNotFound $e) {
|
||||
return new TemplateResponse('core', '404', [], 'guest');
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['app'=>'richdocuments']);
|
||||
$this->logger->logException($e, ['app' => 'richdocuments']);
|
||||
return $this->renderErrorPage('Failed to open the requested file.');
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace OCA\Richdocuments\Controller;
|
|||
use OCA\Richdocuments\Exceptions\ExpiredTokenException;
|
||||
use OCA\Richdocuments\Exceptions\UnknownTokenException;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\TokenExpiredException;
|
||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||
use OCP\AppFramework\OCSController;
|
||||
use OCA\Richdocuments\Db\WopiMapper;
|
||||
|
@ -110,7 +109,7 @@ class FederationController extends OCSController {
|
|||
$initiatorWopi->setGuestDisplayname($initiatorUser['displayName']);
|
||||
} else {
|
||||
$user = $this->userManager->get($initiatorWopi->getEditorUid());
|
||||
if($user !== null) {
|
||||
if ($user !== null) {
|
||||
$initiatorWopi->setGuestDisplayname($user->getDisplayName());
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +141,7 @@ class FederationController extends OCSController {
|
|||
try {
|
||||
$wopi = $this->wopiMapper->getWopiForToken($token);
|
||||
$user = $this->userManager->get($wopi->getEditorUid());
|
||||
if($user !== null) {
|
||||
if ($user !== null) {
|
||||
$wopi->setGuestDisplayname($user->getDisplayName());
|
||||
}
|
||||
$this->logger->debug('COOL-Federation-Initiator-User: Token ' . $token . ' returned');
|
||||
|
@ -159,5 +158,4 @@ class FederationController extends OCSController {
|
|||
throw new OCSNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ use OCA\Richdocuments\Exceptions\UnknownTokenException;
|
|||
use OCA\Richdocuments\Service\FederationService;
|
||||
use OCA\Richdocuments\TemplateManager;
|
||||
use OCA\Richdocuments\TokenManager;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\OCS\OCSBadRequestException;
|
||||
|
@ -345,16 +344,16 @@ class OCSController extends \OCP\AppFramework\OCSController {
|
|||
private function mb_pathinfo($filepath) {
|
||||
$result = [];
|
||||
preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', ltrim('/' . $filepath), $matches);
|
||||
if($matches[1]) {
|
||||
if ($matches[1]) {
|
||||
$result['dirname'] = $matches[1];
|
||||
}
|
||||
if($matches[2]) {
|
||||
if ($matches[2]) {
|
||||
$result['basename'] = $matches[2];
|
||||
}
|
||||
if($matches[5]) {
|
||||
if ($matches[5]) {
|
||||
$result['extension'] = $matches[5];
|
||||
}
|
||||
if($matches[3]) {
|
||||
if ($matches[3]) {
|
||||
$result['filename'] = $matches[3];
|
||||
}
|
||||
return $result;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
namespace OCA\Richdocuments\Controller;
|
||||
|
||||
use Exception;
|
||||
use OCA\Richdocuments\Service\CapabilitiesService;
|
||||
use OCA\Richdocuments\Service\DemoService;
|
||||
use OCA\Richdocuments\Service\FontService;
|
||||
|
@ -35,7 +34,7 @@ use OCP\IConfig;
|
|||
use OCP\PreConditionNotMetException;
|
||||
use OCP\Util;
|
||||
|
||||
class SettingsController extends Controller{
|
||||
class SettingsController extends Controller {
|
||||
// TODO adapt overview generation if we add more font mimetypes
|
||||
public const FONT_MIME_TYPES = [
|
||||
'font/ttf',
|
||||
|
@ -157,11 +156,11 @@ class SettingsController extends Controller{
|
|||
$canonical_webroot) {
|
||||
$message = $this->l10n->t('Saved');
|
||||
|
||||
if ($wopi_url !== null){
|
||||
if ($wopi_url !== null) {
|
||||
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
||||
}
|
||||
|
||||
if ($wopi_allowlist !== null){
|
||||
if ($wopi_allowlist !== null) {
|
||||
$this->appConfig->setAppValue('wopi_allowlist', $wopi_allowlist);
|
||||
}
|
||||
|
||||
|
@ -172,11 +171,11 @@ class SettingsController extends Controller{
|
|||
);
|
||||
}
|
||||
|
||||
if ($edit_groups !== null){
|
||||
if ($edit_groups !== null) {
|
||||
$this->appConfig->setAppValue('edit_groups', $edit_groups);
|
||||
}
|
||||
|
||||
if ($use_groups !== null){
|
||||
if ($use_groups !== null) {
|
||||
$this->appConfig->setAppValue('use_groups', $use_groups);
|
||||
}
|
||||
|
||||
|
@ -201,12 +200,12 @@ class SettingsController extends Controller{
|
|||
if ($public_wopi_url !== null) {
|
||||
$this->appConfig->setAppValue('public_wopi_url', $public_wopi_url);
|
||||
$colon = strpos($public_wopi_url, ':', 0);
|
||||
if ($this->request->getServerProtocol() !== substr($public_wopi_url, 0, $colon)){
|
||||
if ($this->request->getServerProtocol() !== substr($public_wopi_url, 0, $colon)) {
|
||||
$message = $this->l10n->t('Saved with error: Collabora Online should use the same protocol as the server installation.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
if ($wopi_url !== null) {
|
||||
return new JSONResponse([
|
||||
'status' => 'error',
|
||||
|
@ -289,7 +288,7 @@ class SettingsController extends Controller{
|
|||
$message = $this->l10n->t('Saved');
|
||||
$status = 'success';
|
||||
|
||||
if ($templateFolder !== null){
|
||||
if ($templateFolder !== null) {
|
||||
try {
|
||||
$this->config->setUserValue($this->userId, 'richdocuments', 'templateFolder', $templateFolder);
|
||||
} catch (PreConditionNotMetException $e) {
|
||||
|
@ -304,7 +303,6 @@ class SettingsController extends Controller{
|
|||
];
|
||||
|
||||
return new JSONResponse($response);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -381,7 +379,7 @@ class SettingsController extends Controller{
|
|||
} catch (NotFoundException $e) {
|
||||
return new DataDisplayResponse('', Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
|
@ -96,7 +97,6 @@ class TemplatesController extends Controller {
|
|||
$a = false,
|
||||
$forceIcon = true,
|
||||
$mode = 'fill') {
|
||||
|
||||
if ($fileId === '' || $x === 0 || $y === 0) {
|
||||
return new DataResponse([], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
@ -200,7 +200,6 @@ class TemplatesController extends Controller {
|
|||
bool $a = false,
|
||||
bool $forceIcon = true,
|
||||
string $mode = IPreview::MODE_FILL): Http\Response {
|
||||
|
||||
if (!($node instanceof Node) || (!$forceIcon && !$this->preview->isAvailable($node))) {
|
||||
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
|
|
@ -98,9 +98,9 @@ class WopiController extends Controller {
|
|||
private ILockManager $lockManager;
|
||||
|
||||
// Signifies LOOL that document has been changed externally in this storage
|
||||
const LOOL_STATUS_DOC_CHANGED = 1010;
|
||||
public const LOOL_STATUS_DOC_CHANGED = 1010;
|
||||
|
||||
const WOPI_AVATAR_SIZE = 32;
|
||||
public const WOPI_AVATAR_SIZE = 32;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
|
@ -172,7 +172,6 @@ class WopiController extends Controller {
|
|||
*/
|
||||
public function checkFileInfo($fileId, $access_token) {
|
||||
try {
|
||||
|
||||
list($fileId, , $version) = Helper::parseFileId($fileId);
|
||||
|
||||
$wopi = $this->wopiMapper->getWopiForToken($access_token);
|
||||
|
@ -182,7 +181,7 @@ class WopiController extends Controller {
|
|||
} else {
|
||||
$file = $this->getFileForWopiToken($wopi);
|
||||
}
|
||||
if(!($file instanceof File)) {
|
||||
if (!($file instanceof File)) {
|
||||
throw new NotFoundException('No valid file found for ' . $fileId);
|
||||
}
|
||||
} catch (NotFoundException $e) {
|
||||
|
@ -257,7 +256,7 @@ class WopiController extends Controller {
|
|||
}
|
||||
|
||||
$user = $this->userManager->get($wopi->getEditorUid());
|
||||
if($user !== null) {
|
||||
if ($user !== null) {
|
||||
$response['UserExtraInfo']['avatar'] = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $wopi->getEditorUid(), 'size' => self::WOPI_AVATAR_SIZE]);
|
||||
if ($this->groupManager->isAdmin($wopi->getEditorUid())) {
|
||||
$response['UserExtraInfo']['is_admin'] = true;
|
||||
|
@ -428,8 +427,7 @@ class WopiController extends Controller {
|
|||
} else {
|
||||
$response = new StreamResponse($info->fopen('rb'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($file->getSize() === 0) {
|
||||
$response = new Http\Response();
|
||||
} else {
|
||||
|
@ -461,7 +459,7 @@ class WopiController extends Controller {
|
|||
*/
|
||||
public function putFile($fileId,
|
||||
$access_token) {
|
||||
list($fileId, ,) = Helper::parseFileId($fileId);
|
||||
list($fileId, , ) = Helper::parseFileId($fileId);
|
||||
$isPutRelative = ($this->request->getHeader('X-WOPI-Override') === 'PUT_RELATIVE');
|
||||
|
||||
try {
|
||||
|
@ -505,11 +503,9 @@ class WopiController extends Controller {
|
|||
|
||||
if ($suggested[0] === '.') {
|
||||
$path = dirname($file->getPath()) . '/New File' . $suggested;
|
||||
}
|
||||
else if ($suggested[0] !== '/') {
|
||||
} elseif ($suggested[0] !== '/') {
|
||||
$path = dirname($file->getPath()) . '/' . $suggested;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$path = $userFolder->getPath() . $suggested;
|
||||
}
|
||||
|
||||
|
@ -546,7 +542,7 @@ class WopiController extends Controller {
|
|||
$content = fopen('php://input', 'rb');
|
||||
|
||||
try {
|
||||
$this->wrappedFilesystemOperation($wopi, function () use ($file, $content){
|
||||
$this->wrappedFilesystemOperation($wopi, function () use ($file, $content) {
|
||||
return $file->putContent($content);
|
||||
});
|
||||
} catch (LockedException $e) {
|
||||
|
@ -595,7 +591,7 @@ class WopiController extends Controller {
|
|||
try {
|
||||
$wopiOverride = $this->request->getHeader('X-WOPI-Override');
|
||||
$wopiLock = $this->request->getHeader('X-WOPI-Lock');
|
||||
list($fileId, ,) = Helper::parseFileId($fileId);
|
||||
list($fileId, , ) = Helper::parseFileId($fileId);
|
||||
$wopi = $this->wopiMapper->getWopiForToken($access_token);
|
||||
} catch (UnknownTokenException $e) {
|
||||
$this->logger->debug($e->getMessage(), ['app' => 'richdocuments']);
|
||||
|
@ -643,7 +639,7 @@ class WopiController extends Controller {
|
|||
if ($wopi->isTemplateToken()) {
|
||||
$this->templateManager->setUserId($wopi->getOwnerUid());
|
||||
$file = $userFolder->getById($wopi->getTemplateDestination())[0];
|
||||
} else if ($isRenameFile) {
|
||||
} elseif ($isRenameFile) {
|
||||
// the new file needs to be installed in the current user dir
|
||||
$userFolder = $this->rootFolder->getUserFolder($wopi->getEditorUid());
|
||||
$file = $userFolder->getById($fileId)[0];
|
||||
|
@ -654,11 +650,9 @@ class WopiController extends Controller {
|
|||
|
||||
if (strpos($suggested, '.') === 0) {
|
||||
$path = dirname($file->getPath()) . '/New File' . $suggested;
|
||||
}
|
||||
else if (strpos($suggested, '/') !== 0) {
|
||||
} elseif (strpos($suggested, '/') !== 0) {
|
||||
$path = dirname($file->getPath()) . '/' . $suggested;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$path = $userFolder->getPath() . $suggested;
|
||||
}
|
||||
|
||||
|
@ -689,7 +683,7 @@ class WopiController extends Controller {
|
|||
|
||||
if ($suggested[0] === '.') {
|
||||
$path = dirname($file->getPath()) . '/New File' . $suggested;
|
||||
} else if ($suggested[0] !== '/') {
|
||||
} elseif ($suggested[0] !== '/') {
|
||||
$path = dirname($file->getPath()) . '/' . $suggested;
|
||||
} else {
|
||||
$path = $userFolder->getPath() . $suggested;
|
||||
|
@ -718,7 +712,7 @@ class WopiController extends Controller {
|
|||
$this->userScopeService->setFilesystemScope($wopi->getEditorUid());
|
||||
|
||||
try {
|
||||
$this->wrappedFilesystemOperation($wopi, function () use ($file, $content){
|
||||
$this->wrappedFilesystemOperation($wopi, function () use ($file, $content) {
|
||||
return $file->putContent($content);
|
||||
});
|
||||
} catch (LockedException $e) {
|
||||
|
|
|
@ -31,7 +31,7 @@ use OCP\Security\ISecureRandom;
|
|||
|
||||
class AssetMapper extends Mapper {
|
||||
/** @var int Limetime of a token is 10 minutes */
|
||||
const tokenLifeTime = 600;
|
||||
public const tokenLifeTime = 600;
|
||||
|
||||
/** @var ISecureRandom */
|
||||
private $random;
|
||||
|
|
|
@ -28,12 +28,11 @@ use OCP\AppFramework\Db\Mapper;
|
|||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use PhpParser\Node\Scalar\MagicConst\Dir;
|
||||
|
||||
class DirectMapper extends Mapper {
|
||||
|
||||
/** @var int Limetime of a token is 10 minutes */
|
||||
const tokenLifeTime = 600;
|
||||
public const tokenLifeTime = 600;
|
||||
|
||||
/** @var ISecureRandom */
|
||||
protected $random;
|
||||
|
|
|
@ -66,27 +66,27 @@ class Wopi extends Entity implements \JsonSerializable {
|
|||
/**
|
||||
* WOPI token to open a file as a user on the current instance
|
||||
*/
|
||||
const TOKEN_TYPE_USER = 0;
|
||||
public const TOKEN_TYPE_USER = 0;
|
||||
|
||||
/**
|
||||
* WOPI token to open a file as a guest on the current instance
|
||||
*/
|
||||
const TOKEN_TYPE_GUEST = 1;
|
||||
public const TOKEN_TYPE_GUEST = 1;
|
||||
|
||||
/**
|
||||
* WOPI token to open a file as a user from a federated instance
|
||||
*/
|
||||
const TOKEN_TYPE_REMOTE_USER = 2;
|
||||
public const TOKEN_TYPE_REMOTE_USER = 2;
|
||||
|
||||
/**
|
||||
* WOPI token to open a file as a guest from a federated instance
|
||||
*/
|
||||
const TOKEN_TYPE_REMOTE_GUEST = 3;
|
||||
public const TOKEN_TYPE_REMOTE_GUEST = 3;
|
||||
|
||||
/*
|
||||
* Temporary token that is used to share the initiator details to the source instance
|
||||
*/
|
||||
const TOKEN_TYPE_INITIATOR = 4;
|
||||
public const TOKEN_TYPE_INITIATOR = 4;
|
||||
|
||||
/** @var string */
|
||||
protected $ownerUid;
|
||||
|
|
|
@ -139,7 +139,6 @@ class WopiMapper extends Mapper {
|
|||
* @throws ExpiredTokenException
|
||||
*/
|
||||
public function getWopiForToken($token) {
|
||||
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('richdocuments_wopi')
|
||||
|
@ -161,7 +160,7 @@ class WopiMapper extends Mapper {
|
|||
/** @var Wopi $wopi */
|
||||
$wopi = Wopi::fromRow($row);
|
||||
|
||||
if ($wopi->getExpiry() < $this->timeFactory->getTime()){
|
||||
if ($wopi->getExpiry() < $this->timeFactory->getTime()) {
|
||||
throw new ExpiredTokenException('Provided token is expired.');
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace OCA\Richdocuments\Events;
|
||||
|
||||
|
||||
use OCP\Files\Node;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
|
@ -42,5 +41,4 @@ class BeforeFederationRedirectEvent extends Event {
|
|||
public function getRedirectUrl() {
|
||||
return $this->redirectUrl;
|
||||
}
|
||||
|
||||
}
|
|
@ -22,4 +22,5 @@
|
|||
*/
|
||||
namespace OCA\Richdocuments\Exceptions;
|
||||
|
||||
class ExpiredTokenException extends \Exception {}
|
||||
class ExpiredTokenException extends \Exception {
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@
|
|||
*/
|
||||
namespace OCA\Richdocuments\Exceptions;
|
||||
|
||||
class UnknownTokenException extends \Exception {}
|
||||
class UnknownTokenException extends \Exception {
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@ class Helper {
|
|||
$fileId = $arr[0];
|
||||
$instanceId = '';
|
||||
$version = '0';
|
||||
} else if (count($arr) === 2) {
|
||||
} elseif (count($arr) === 2) {
|
||||
list($fileId, $instanceId) = $arr;
|
||||
$version = '0';
|
||||
} else if (count($arr) === 3) {
|
||||
} elseif (count($arr) === 3) {
|
||||
list($fileId, $instanceId, $version) = $arr;
|
||||
} else {
|
||||
throw new \Exception('$fileId has not the expected format');
|
||||
|
@ -61,12 +61,12 @@ class Helper {
|
|||
* WOPI helper function to convert to ISO 8601 round-trip format.
|
||||
* @param integer $time Must be seconds since unix epoch
|
||||
*/
|
||||
public static function toISO8601($time)
|
||||
{
|
||||
public static function toISO8601($time) {
|
||||
// TODO: Be more precise and don't ignore milli, micro seconds ?
|
||||
$datetime = DateTime::createFromFormat('U', $time, new DateTimeZone('UTC'));
|
||||
if ($datetime)
|
||||
if ($datetime) {
|
||||
return $datetime->format('Y-m-d\TH:i:s.u\Z');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -88,5 +88,4 @@ class Helper {
|
|||
}
|
||||
return $_COOKIE['guestUser'];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Richdocuments\Listener;
|
||||
|
||||
|
||||
use OCA\Richdocuments\TemplateManager;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
|
|
|
@ -67,14 +67,14 @@ class WOPIMiddleware extends Middleware {
|
|||
|
||||
public function isWOPIAllowed(): bool {
|
||||
$allowedRanges = $this->config->getAppValue(Application::APPNAME, 'wopi_allowlist');
|
||||
if($allowedRanges === '') {
|
||||
if ($allowedRanges === '') {
|
||||
return true;
|
||||
}
|
||||
$allowedRanges = explode(',', $allowedRanges);
|
||||
|
||||
$userIp = $this->request->getRemoteAddress();
|
||||
foreach($allowedRanges as $range) {
|
||||
if($this->matchCidr($userIp, $range)) {
|
||||
foreach ($allowedRanges as $range) {
|
||||
if ($this->matchCidr($userIp, $range)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class WOPIMiddleware extends Middleware {
|
|||
$binMask = str_pad($binMask, 32, '0');
|
||||
$binMask = pack("H*", $binMask);
|
||||
|
||||
if ( ($ip & $binMask) === $subnet ) {
|
||||
if (($ip & $binMask) === $subnet) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,5 +185,4 @@ class Version2060Date20200302131958 extends SimpleMigrationStep {
|
|||
}
|
||||
return $schema;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version2060Date20200302132145 extends SimpleMigrationStep
|
||||
{
|
||||
class Version2060Date20200302132145 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
|
@ -18,8 +17,7 @@ class Version2060Date20200302132145 extends SimpleMigrationStep
|
|||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
|
||||
{
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
|
@ -33,5 +31,4 @@ class Version2060Date20200302132145 extends SimpleMigrationStep
|
|||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ class Version30704Date20200626072306 extends SimpleMigrationStep {
|
|||
'notnull' => false,
|
||||
'default' => '',
|
||||
]);
|
||||
|
||||
}
|
||||
if (!$table->hasColumn('remote_server_token')) {
|
||||
$table->addColumn('remote_server_token', 'string', [
|
||||
|
|
|
@ -10,7 +10,6 @@ use OCP\Migration\IOutput;
|
|||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version30709Date20201111104147 extends SimpleMigrationStep {
|
||||
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
|
|
@ -10,7 +10,6 @@ use OCP\Migration\IOutput;
|
|||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version30717Date20210310164901 extends SimpleMigrationStep {
|
||||
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
@ -51,5 +50,4 @@ class Version30717Date20210310164901 extends SimpleMigrationStep {
|
|||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@ class PermissionManager {
|
|||
|
||||
public function isEnabledForUser(IUser $user) {
|
||||
$enabledForGroups = $this->config->getAppValue(Application::APPNAME, 'use_groups', '');
|
||||
if($enabledForGroups === '') {
|
||||
if ($enabledForGroups === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$groups = $this->splitGroups($enabledForGroups);
|
||||
$uid = $user->getUID();
|
||||
foreach($groups as $group) {
|
||||
if($this->groupManager->isInGroup($uid, $group)) {
|
||||
foreach ($groups as $group) {
|
||||
if ($this->groupManager->isInGroup($uid, $group)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
*/
|
||||
namespace OCA\Richdocuments\Preview;
|
||||
|
||||
use GuzzleHttp\Psr7\LimitStream;
|
||||
use function GuzzleHttp\Psr7\stream_for;
|
||||
use OC\Preview\Provider;
|
||||
use OCA\Richdocuments\Capabilities;
|
||||
use OCP\Http\Client\IClientService;
|
||||
|
@ -107,7 +105,5 @@ abstract class Office extends Provider {
|
|||
return $image;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class CapabilitiesService {
|
|||
$isCODEInstalled = $this->appManager->isEnabledForUser($CODEAppID);
|
||||
$isCODEEnabled = strpos($this->config->getAppValue('richdocuments', 'wopi_url'), 'proxy.php?req=') !== false;
|
||||
$shouldRecheckCODECapabilities = $isCODEInstalled && $isCODEEnabled && ($this->capabilities === null || count($this->capabilities) === 0);
|
||||
if($this->capabilities === null || $shouldRecheckCODECapabilities) {
|
||||
if ($this->capabilities === null || $shouldRecheckCODECapabilities) {
|
||||
$this->refetch();
|
||||
}
|
||||
|
||||
|
@ -131,16 +131,15 @@ class CapabilitiesService {
|
|||
if (!is_array($capabilities)) {
|
||||
$capabilities = [];
|
||||
}
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$capabilities = [];
|
||||
}
|
||||
|
||||
$this->capabilities = $capabilities;
|
||||
$ttl = 3600;
|
||||
if (count($capabilities) === 0)
|
||||
if (count($capabilities) === 0) {
|
||||
$ttl = 60;
|
||||
}
|
||||
|
||||
$this->cache->set('capabilities', $capabilities, $ttl);
|
||||
}
|
||||
|
|
|
@ -58,5 +58,4 @@ class DemoService {
|
|||
$this->cache->set('richdocuments-demo', json_encode($servers));
|
||||
return $servers;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
namespace OCA\Richdocuments\Service;
|
||||
|
||||
|
||||
use OCA\Federation\TrustedServers;
|
||||
use OCA\Files_Sharing\External\Storage as SharingExternalStorage;
|
||||
use OCA\Richdocuments\AppConfig;
|
||||
|
@ -70,8 +69,9 @@ class FederationService {
|
|||
$this->request = $request;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
try {
|
||||
$this->trustedServers = \OC::$server->query( \OCA\Federation\TrustedServers::class);
|
||||
} catch (QueryException $e) {}
|
||||
$this->trustedServers = \OC::$server->query(\OCA\Federation\TrustedServers::class);
|
||||
} catch (QueryException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
namespace OCA\Richdocuments\Service;
|
||||
|
||||
|
||||
use OCA\Richdocuments\AppInfo\Application;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\Files\NotFoundException;
|
||||
|
|
|
@ -23,12 +23,10 @@
|
|||
|
||||
namespace OCA\Richdocuments\Service;
|
||||
|
||||
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
|
||||
class UserScopeService {
|
||||
|
||||
public function __construct(IUserSession $userSession, IUserManager $userManager) {
|
||||
$this->userSession = $userSession;
|
||||
$this->userManager = $userManager;
|
||||
|
|
|
@ -111,5 +111,4 @@ class Admin implements ISettings {
|
|||
public function getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,14 +26,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Richdocuments\Template;
|
||||
|
||||
|
||||
use OCA\Richdocuments\TemplateManager;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\Template\ICustomTemplateProvider;
|
||||
use OCP\Files\Template\ITemplateManager;
|
||||
use OCP\Files\Template\Template;
|
||||
use OCP\Files\Template\TemplateFileCreator;
|
||||
use OCP\IURLGenerator;
|
||||
|
||||
class CollaboraTemplateProvider implements ICustomTemplateProvider {
|
||||
|
@ -70,7 +68,7 @@ class CollaboraTemplateProvider implements ICustomTemplateProvider {
|
|||
|
||||
$collaboraTemplates = $this->isSameUserTemplateFolder() ? $this->templateManager->getSystem($type) : $this->templateManager->getAll($type);
|
||||
|
||||
return array_map(function(File $file) {
|
||||
return array_map(function (File $file) {
|
||||
$template = new Template(CollaboraTemplateProvider::class, (string)$file->getId(), $file);
|
||||
$template->setCustomPreviewUrl($this->urlGenerator->linkToRouteAbsolute('richdocuments.templates.getPreview', ['fileId' => $file->getId()]));
|
||||
return $template;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
|
@ -66,41 +67,41 @@ class TemplateManager {
|
|||
private $logger;
|
||||
|
||||
/** Accepted templates mime types */
|
||||
const MIMES_DOCUMENTS = [
|
||||
public const MIMES_DOCUMENTS = [
|
||||
'application/vnd.oasis.opendocument.text-template',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'application/msword'
|
||||
];
|
||||
const MIMES_SHEETS = [
|
||||
public const MIMES_SHEETS = [
|
||||
'application/vnd.oasis.opendocument.spreadsheet-template',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'application/vnd.ms-excel'
|
||||
];
|
||||
const MIMES_PRESENTATIONS = [
|
||||
public const MIMES_PRESENTATIONS = [
|
||||
'application/vnd.oasis.opendocument.presentation-template',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'application/vnd.ms-powerpoint'
|
||||
];
|
||||
const MIMES_DRAWINGS = [
|
||||
public const MIMES_DRAWINGS = [
|
||||
'application/vnd.oasis.opendocument.graphics-template',
|
||||
];
|
||||
|
||||
/** @var array Template mime types match */
|
||||
static public $tplTypes = [
|
||||
public static $tplTypes = [
|
||||
'document' => self::MIMES_DOCUMENTS,
|
||||
'spreadsheet' => self::MIMES_SHEETS,
|
||||
'presentation' => self::MIMES_PRESENTATIONS,
|
||||
'drawing' => self::MIMES_DRAWINGS,
|
||||
];
|
||||
|
||||
const TYPE_EXTENTION = [
|
||||
public const TYPE_EXTENTION = [
|
||||
'document' => 'odt',
|
||||
'spreadsheet' => 'ods',
|
||||
'presentation' => 'odp',
|
||||
'drawing' => 'odg',
|
||||
];
|
||||
|
||||
const TYPE_EXTENSION_OOXML = [
|
||||
public const TYPE_EXTENSION_OOXML = [
|
||||
'document' => 'docx',
|
||||
'spreadsheet' => 'xlsx',
|
||||
'presentation' => 'pptx',
|
||||
|
@ -272,11 +273,11 @@ class TemplateManager {
|
|||
$empty = $this->getEmpty($type);
|
||||
$system = $this->getSystem($type);
|
||||
|
||||
$emptyFormatted = array_map(function(File $file) {
|
||||
$emptyFormatted = array_map(function (File $file) {
|
||||
return $this->formatEmpty($file);
|
||||
}, $empty);
|
||||
|
||||
$systemFormatted = array_map(function(File $file) {
|
||||
$systemFormatted = array_map(function (File $file) {
|
||||
return $this->formatNodeReturn($file);
|
||||
}, $system);
|
||||
|
||||
|
@ -294,7 +295,7 @@ class TemplateManager {
|
|||
$templateFiles = $templateDir->getDirectoryListing();
|
||||
|
||||
return $this->filterTemplates($templateFiles, $type);
|
||||
} catch(NotFoundException $e) {
|
||||
} catch (NotFoundException $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +306,7 @@ class TemplateManager {
|
|||
public function getUserFormatted($type) {
|
||||
$templates = $this->getUser($type);
|
||||
|
||||
return array_map(function(File $file) {
|
||||
return array_map(function (File $file) {
|
||||
return $this->formatNodeReturn($file);
|
||||
}, $templates);
|
||||
}
|
||||
|
|
|
@ -21,18 +21,14 @@
|
|||
|
||||
namespace OCA\Richdocuments;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OC\Files\Filesystem;
|
||||
use OCA\Richdocuments\Db\Direct;
|
||||
use OCA\Richdocuments\Db\WopiMapper;
|
||||
use OCA\Richdocuments\Db\Wopi;
|
||||
use OCA\Richdocuments\Service\CapabilitiesService;
|
||||
use OCA\Richdocuments\WOPI\Parser;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\ForbiddenException;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Files\Node;
|
||||
use OCP\IGroupManager;
|
||||
|
@ -41,7 +37,6 @@ use OCP\IUserManager;
|
|||
use OCP\Share\Exceptions\ShareNotFound;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\Share\IShare;
|
||||
use OCP\Util;
|
||||
|
||||
class TokenManager {
|
||||
|
@ -122,7 +117,7 @@ class TokenManager {
|
|||
$updatable = (bool)($share->getPermissions() & \OCP\Constants::PERMISSION_UPDATE);
|
||||
$hideDownload = $share->getHideDownload();
|
||||
$owneruid = $share->getShareOwner();
|
||||
} else if ($this->userId !== null) {
|
||||
} elseif ($this->userId !== null) {
|
||||
try {
|
||||
$editoruid = $this->userId;
|
||||
$rootFolder = $this->rootFolder->getUserFolder($editoruid);
|
||||
|
@ -176,7 +171,6 @@ class TokenManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/** @var File $file */
|
||||
$file = $rootFolder->getById($fileId)[0];
|
||||
|
@ -263,7 +257,7 @@ class TokenManager {
|
|||
$editorUser = $this->userManager->get($editoruid);
|
||||
if ($updatable && count($editGroups) > 0 && $editorUser) {
|
||||
$updatable = false;
|
||||
foreach($editGroups as $editGroup) {
|
||||
foreach ($editGroups as $editGroup) {
|
||||
$editorGroup = $this->groupManager->get($editGroup);
|
||||
if ($editorGroup !== null && $editorGroup->inGroup($editorUser)) {
|
||||
$updatable = true;
|
||||
|
@ -335,5 +329,4 @@ class TokenManager {
|
|||
$wopi->setGuestDisplayname($this->prepareGuestName($guestName));
|
||||
$this->wopiMapper->update($wopi);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,8 +77,9 @@ class DiscoveryManager {
|
|||
$options['verify'] = false;
|
||||
}
|
||||
|
||||
if ($this->isProxyStarting($wopiDiscovery))
|
||||
if ($this->isProxyStarting($wopiDiscovery)) {
|
||||
$options['timeout'] = 180;
|
||||
}
|
||||
|
||||
try {
|
||||
return $client->get($wopiDiscovery, $options);
|
||||
|
@ -98,10 +99,11 @@ class DiscoveryManager {
|
|||
private function isProxyStarting($url) {
|
||||
$usesProxy = false;
|
||||
$proxyPos = strrpos($url, 'proxy.php');
|
||||
if ($proxyPos === false)
|
||||
if ($proxyPos === false) {
|
||||
$usesProxy = false;
|
||||
else
|
||||
} else {
|
||||
$usesProxy = true;
|
||||
}
|
||||
|
||||
if ($usesProxy === true) {
|
||||
$statusUrl = substr($url, 0, $proxyPos);
|
||||
|
|
|
@ -57,7 +57,5 @@ class Parser {
|
|||
}
|
||||
|
||||
throw new \Exception('Could not find urlsrc in WOPI');
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ if (!defined('PHPUNIT_RUN')) {
|
|||
|
||||
require_once __DIR__.'/../../../lib/base.php';
|
||||
|
||||
if(!class_exists('\PHPUnit\Framework\TestCase')) {
|
||||
if (!class_exists('\PHPUnit\Framework\TestCase')) {
|
||||
require_once('PHPUnit/Autoload.php');
|
||||
}
|
||||
\OC_App::loadApp('richdocuments');
|
||||
|
|
|
@ -212,5 +212,4 @@ class DirectContext implements Context {
|
|||
}
|
||||
$this->serverContext->sendOCSRequest('POST', 'apps/richdocuments/api/v1/share', $data, $options);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,5 +74,4 @@ class FederationContext implements Context {
|
|||
$table
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
|
@ -9,8 +10,7 @@ use JuliusHaertl\NextcloudBehat\Context\ServerContext;
|
|||
use JuliusHaertl\NextcloudBehat\Context\SharingContext;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class RichDocumentsContext implements Context
|
||||
{
|
||||
class RichDocumentsContext implements Context {
|
||||
|
||||
/** @var ServerContext */
|
||||
private $serverContext;
|
||||
|
@ -41,8 +41,7 @@ class RichDocumentsContext implements Context
|
|||
/**
|
||||
* @When User :user opens :file
|
||||
*/
|
||||
public function userOpens($user, $file)
|
||||
{
|
||||
public function userOpens($user, $file) {
|
||||
$this->serverContext->usingWebAsUser($user);
|
||||
$davClient = $this->filesContext->getSabreClient($user);
|
||||
$path = $this->filesContext->makeSabrePath($user, $file);
|
||||
|
@ -78,24 +77,21 @@ class RichDocumentsContext implements Context
|
|||
/**
|
||||
* @Then a guest opens the share link
|
||||
*/
|
||||
public function aGuestOpensTheShareLink()
|
||||
{
|
||||
public function aGuestOpensTheShareLink() {
|
||||
$this->aGuestOpensTheShareLinkAs();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then a guest opens the share link as :guestName
|
||||
*/
|
||||
public function aGuestOpensTheShareLinkAs($guestName = null)
|
||||
{
|
||||
public function aGuestOpensTheShareLinkAs($guestName = null) {
|
||||
$this->openTheShareLink(null, $guestName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the user opens the share link
|
||||
*/
|
||||
public function aUserOpensTheShareLink()
|
||||
{
|
||||
public function aUserOpensTheShareLink() {
|
||||
$this->openTheShareLink($this->serverContext->getAuth()[0], null);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ class WopiContext implements Context {
|
|||
private $wopiToken;
|
||||
private $checkFileInfoResult;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->downloadedFile = tempnam(sys_get_temp_dir(), 'downloadedFile');
|
||||
}
|
||||
|
||||
|
@ -91,8 +90,7 @@ class WopiContext implements Context {
|
|||
/**
|
||||
* @Then /^Collabora saved the file with the content of "([^"]*)"$/
|
||||
*/
|
||||
public function collaboraPuts($source)
|
||||
{
|
||||
public function collaboraPuts($source) {
|
||||
$file = Utils::streamFor(fopen($source, 'r'));
|
||||
$client = new Client();
|
||||
$options = [
|
||||
|
@ -133,8 +131,7 @@ class WopiContext implements Context {
|
|||
/**
|
||||
* @Then /^checkFileInfo "([^"]*)" is "([^"]*)"$/
|
||||
*/
|
||||
public function checkfileinfoIs($key, $value)
|
||||
{
|
||||
public function checkfileinfoIs($key, $value) {
|
||||
\PHPUnit\Framework\Assert::assertEquals($value, $this->checkFileInfoResult[$key]);
|
||||
}
|
||||
|
||||
|
@ -142,32 +139,28 @@ class WopiContext implements Context {
|
|||
/**
|
||||
* @Then /^checkFileInfo "([^"]*)" matches "([^"]*)"$/
|
||||
*/
|
||||
public function checkfileinfoMatches($key, $regex)
|
||||
{
|
||||
public function checkfileinfoMatches($key, $regex) {
|
||||
\PHPUnit\Framework\Assert::assertRegExp($regex, $this->checkFileInfoResult[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^checkFileInfo "([^"]*)" is true$/
|
||||
*/
|
||||
public function checkfileinfoIsTrue($key)
|
||||
{
|
||||
public function checkfileinfoIsTrue($key) {
|
||||
\PHPUnit\Framework\Assert::assertTrue($this->checkFileInfoResult[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^checkFileInfo "([^"]*)" is false$/
|
||||
*/
|
||||
public function checkfileinfoIsFalse($key)
|
||||
{
|
||||
public function checkfileinfoIsFalse($key) {
|
||||
\PHPUnit\Framework\Assert::assertFalse($this->checkFileInfoResult[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^checkFileInfo "([^"]*)" is not set/
|
||||
*/
|
||||
public function checkfileinfoIsNotSet($key)
|
||||
{
|
||||
public function checkfileinfoIsNotSet($key) {
|
||||
\PHPUnit\Framework\Assert::assertArrayNotHasKey($key, $this->checkFileInfoResult);
|
||||
}
|
||||
|
||||
|
@ -255,8 +248,8 @@ class WopiContext implements Context {
|
|||
if (count($this->fileIds) <= 1) {
|
||||
throw new \Exception('Less than two file ids available for comparison');
|
||||
}
|
||||
$current = $this->fileIds[count($this->fileIds)-1];
|
||||
$previous = $this->fileIds[count($this->fileIds)-2];
|
||||
$current = $this->fileIds[count($this->fileIds) - 1];
|
||||
$previous = $this->fileIds[count($this->fileIds) - 2];
|
||||
Assert::assertEquals($current, $previous);
|
||||
}
|
||||
|
||||
|
@ -267,8 +260,8 @@ class WopiContext implements Context {
|
|||
if (count($this->fileIds) <= 1) {
|
||||
throw new \Exception('Less than two file ids available for comparison');
|
||||
}
|
||||
$current = $this->fileIds[count($this->fileIds)-1];
|
||||
$previous = $this->fileIds[count($this->fileIds)-2];
|
||||
$current = $this->fileIds[count($this->fileIds) - 1];
|
||||
$previous = $this->fileIds[count($this->fileIds) - 2];
|
||||
Assert::assertNotEquals($current, $previous);
|
||||
}
|
||||
|
||||
|
@ -293,5 +286,4 @@ class WopiContext implements Context {
|
|||
$this->response = $e->getResponse();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче