|
|
|
@ -50,7 +50,6 @@ class DocumentController extends Controller {
|
|
|
|
|
private $settings;
|
|
|
|
|
private $cache;
|
|
|
|
|
private $logger;
|
|
|
|
|
|
|
|
|
|
const ODT_TEMPLATE_PATH = '/assets/odttemplate.odt';
|
|
|
|
|
|
|
|
|
|
public function __construct($appName, IRequest $request, IConfig $settings, IL10N $l10n, $uid, ICacheFactory $cache, ILogger $logger){
|
|
|
|
@ -379,7 +378,7 @@ class DocumentController extends Controller {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$view = new \OC\Files\View('/' . $res['user'] . '/files');
|
|
|
|
|
$view = new \OC\Files\View('/' . $res['owner'] . '/files');
|
|
|
|
|
$info = $view->getFileInfo($res['path']);
|
|
|
|
|
|
|
|
|
|
\OC::$server->getLogger()->debug('File info: {info}.', [ 'app' => $this->appName, 'info' => $info ]);
|
|
|
|
@ -412,7 +411,7 @@ class DocumentController extends Controller {
|
|
|
|
|
|
|
|
|
|
//TODO: Support X-WOPIMaxExpectedSize header.
|
|
|
|
|
$res = $row->getPathForToken($fileId, $token);
|
|
|
|
|
return new DownloadResponse($this->request, $res['user'], '/files' . $res['path']);
|
|
|
|
|
return new DownloadResponse($this->request, $res['owner'], '/files' . $res['path']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -431,16 +430,31 @@ class DocumentController extends Controller {
|
|
|
|
|
$row->loadBy('token', $token);
|
|
|
|
|
|
|
|
|
|
$res = $row->getPathForToken($fileId, $token);
|
|
|
|
|
$root = '/' . $res['user'] . '/files';
|
|
|
|
|
|
|
|
|
|
// Log-in as the user to regiser the change under her name.
|
|
|
|
|
$editorid = $res['editor'];
|
|
|
|
|
$users = \OC::$server->getUserManager()->search($editorid, 1, 0);
|
|
|
|
|
if (count($users) > 0)
|
|
|
|
|
{
|
|
|
|
|
$user = array_shift($users);
|
|
|
|
|
if (strcasecmp($user->getUID(),$editorid) === 0)
|
|
|
|
|
{
|
|
|
|
|
\OC::$server->getUserSession()->setUser($user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set up the filesystem view for the owner (where the file actually is).
|
|
|
|
|
$userid = $res['owner'];
|
|
|
|
|
$root = '/' . $userid . '/files';
|
|
|
|
|
$view = new \OC\Files\View($root);
|
|
|
|
|
|
|
|
|
|
// Read the contents of the file from the POST body and store.
|
|
|
|
|
$content = fopen('php://input', 'r');
|
|
|
|
|
\OC::$server->getLogger()->debug('Putting {size} bytes.', [ 'app' => $this->appName, 'size' => strlen($content) ]);
|
|
|
|
|
\OC::$server->getLogger()->debug('Storing file {fileId} by {editor} owned by {owner}.', [ 'app' => $this->appName, 'fileId' => $fileId, 'editor' => $editorid, 'owner' => $userid ]);
|
|
|
|
|
|
|
|
|
|
// Setup the FS which is needed to emit hooks (versioning).
|
|
|
|
|
\OC_Util::tearDownFS();
|
|
|
|
|
\OC_Util::setupFS($res['user'], $root);
|
|
|
|
|
\OC_Util::setupFS($userid, $root);
|
|
|
|
|
|
|
|
|
|
$view->file_put_contents($res['path'], $content);
|
|
|
|
|
|
|
|
|
|