The app which enables the users to edit office documents from Nextcloud using ONLYOFFICE Document Server, allows multiple users to collaborate in real time and to save back those changes to Nextcloud
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
onlyoffice-nextcloud/controller/federationcontroller.php

112 lines
3.0 KiB

7 years ago
<?php
/**
*
6 years ago
* (c) Copyright Ascensio System SIA 2020
7 years ago
*
6 years ago
* 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
7 years ago
*
6 years ago
* http://www.apache.org/licenses/LICENSE-2.0
7 years ago
*
6 years ago
* 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.
7 years ago
*
*/
namespace OCA\Onlyoffice\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\ISession;
use OCP\Share\IManager;
use OCA\Onlyoffice\AppConfig;
use OCA\Onlyoffice\DocumentService;
7 years ago
use OCA\Onlyoffice\FileUtility;
/**
* OCS handler
*/
class FederationController extends OCSController {
/**
* Logger
*
* @var ILogger
*/
private $logger;
/**
* Application configuration
*
6 years ago
* @var AppConfig
7 years ago
*/
public $config;
/**
* File utility
*
6 years ago
* @var FileUtility
7 years ago
*/
private $fileUtility;
/**
* @param string $AppName - application name
* @param IRequest $request - request object
* @param IL10N $trans - l10n service
* @param ILogger $logger - logger
* @param IManager $shareManager - Share manager
* @param IManager $ISession - Session
*/
public function __construct($AppName,
IRequest $request,
IL10N $trans,
ILogger $logger,
IManager $shareManager,
ISession $session
) {
parent::__construct($AppName, $request);
$this->logger = $logger;
$this->config = new AppConfig($this->appName);
$this->fileUtility = new FileUtility($AppName, $trans, $logger, $this->config, $shareManager, $session);
}
/**
* Returns the origin document key for editor
*
* @param string $shareToken - access token
* @param string $path - file path
7 years ago
*
* @return DataResponse
*
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
*/
public function key($shareToken, $path) {
list ($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path);
7 years ago
if (isset($error)) {
$this->logger->error("Federated getFileByToken: $error", ["app" => $this->appName]);
7 years ago
return new DataResponse(["error" => $error]);
}
$key = $this->fileUtility->getKey($file, true);
$key = DocumentService::GenerateRevisionId($key);
$this->logger->debug("Federated request get for " . $file->getId() . " key $key", ["app" => $this->appName]);
7 years ago
return new DataResponse(["key" => $key]);
}
7 years ago
}