Merge remote-tracking branch 'origin/master' into upgrade-sf5

This commit is contained in:
2024-04-04 18:45:01 +02:00
162 changed files with 3849 additions and 713 deletions

View File

@@ -15,7 +15,6 @@ use ChampsLibres\WopiLib\Contract\Service\Configuration\ConfigurationInterface;
use ChampsLibres\WopiLib\Contract\Service\Discovery\DiscoveryInterface;
use ChampsLibres\WopiLib\Contract\Service\DocumentManagerInterface;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\MainBundle\Entity\User;
use Chill\WopiBundle\Service\Controller\ResponderInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
use loophp\psr17\Psr17Interface;
@@ -41,13 +40,11 @@ final readonly class Editor
public function __invoke(string $fileId, Request $request): Response
{
if (null === $user = $this->security->getUser()) {
if (!($this->security->isGranted('ROLE_USER') || $this->security->isGranted('ROLE_ADMIN'))) {
throw new AccessDeniedHttpException('Please authenticate to access this feature');
}
if (!$user instanceof User) {
throw new AccessDeniedHttpException('Please authenticate as a user to access this feature');
}
$user = $this->security->getUser();
$configuration = $this->wopiConfiguration->jsonSerialize();
/** @var StoredObject $storedObject */
@@ -75,7 +72,12 @@ final readonly class Editor
}
if ([] === $discoverExtension = $this->wopiDiscovery->discoverMimeType($storedObject->getType())) {
throw new \Exception(sprintf('Unable to find mime type %s', $storedObject->getType()));
return new Response(
$this->engine
->render('@ChillWopi/Editor/unable_to_edit_such_document.html.twig', [
'document' => $storedObject,
])
);
}
$configuration['favIconUrl'] = '';

View File

@@ -0,0 +1,34 @@
{% extends '@ChillMain/layout.html.twig' %}
{% block js %}
{{ parent() }}
{{ encore_entry_script_tags('mod_document_action_buttons_group') }}
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('mod_document_action_buttons_group') }}
{% endblock %}
{% block content %}
<div class="alert alert-danger text-center">
<div>
<p>
{{ 'wopi_editor.document unsupported for edition'|trans }}
</p>
</div>
<div>
<p>{{ document|chill_document_button_group(document.title|default('Document'), false) }}</p>
</div>
</div>
<ul class="sticky-form-buttons record_actions">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_main_homepage') }}" class="btn btn-cancel">
{{ 'Cancel'|trans|chill_return_path_label }}
</a>
</li>
</ul>
{% endblock content %}

View File

@@ -36,7 +36,7 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori
$user = $this->security->getUser();
if (!$user instanceof User) {
if (!($user instanceof User || $this->security->isGranted('ROLE_ADMIN'))) {
return false;
}

View File

@@ -23,6 +23,10 @@ class UserManager implements \ChampsLibres\WopiBundle\Contracts\UserManagerInter
{
$user = $this->security->getUser();
if (!$user instanceof User && $this->security->isGranted('ROLE_ADMIN')) {
return $user->getUsername();
}
if (!$user instanceof User) {
return null;
}
@@ -34,6 +38,10 @@ class UserManager implements \ChampsLibres\WopiBundle\Contracts\UserManagerInter
{
$user = $this->security->getUser();
if (!$user instanceof User && $this->security->isGranted('ROLE_ADMIN')) {
return $user->getUsername();
}
if (!$user instanceof User) {
return null;
}

View File

@@ -0,0 +1,2 @@
wopi_editor:
document unsupported for edition: Ce format de document n'est pas éditable