Skip to content

Commit a1fd7e2

Browse files
author
olga-kulish
committed
Merge branch 'develop' of https://github.com/oat-sa/tao-core into fix/AUT-3923/textreader-image-figure-support
2 parents 79051d2 + 23e0517 commit a1fd7e2

File tree

112 files changed

+8502
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+8502
-248
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Here you can find the environment variables including feature flags
106106
| DATA_STORE_STATISTIC_PUB_SUB_TOPIC | Topic name for statistic metadata Pub/Sub | - |
107107
| REDIRECT_AFTER_LOGOUT_URL | Allows to configure the redirect after logout via environment variable. The fallback is the configured redirect on urlroute.conf.php | - |
108108
| PORTAL_URL | The Portal url used on the back button of Portal theme | - |
109+
| FEATURE_FLAG_TRANSLATION_ENABLED | Enable access to items/tests translations feature | - |
109110

110111

111112
# Routing

actions/class.Main.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,13 @@ private function getSections($shownExtension, $shownStructure)
521521
$sections = [];
522522
$user = $this->getSession()->getUser();
523523
$structure = MenuService::getPerspective($shownExtension, $shownStructure);
524+
$sectionVisibilityFilter = $this->getSectionVisibilityFilter();
525+
524526
if (!is_null($structure)) {
525527
foreach ($structure->getChildren() as $section) {
526528
$resolver = new ActionResolver($section->getUrl());
527529

528-
if (!$this->getSectionVisibilityFilter()->isVisible($section->getId())) {
530+
if (!$sectionVisibilityFilter->isVisible($section->getId())) {
529531
continue;
530532
}
531533

@@ -540,6 +542,19 @@ private function getSections($shownExtension, $shownStructure)
540542

541543
if (FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {
542544
foreach ($section->getActions() as $action) {
545+
$sectionPath = $sectionVisibilityFilter->createSectionPath(
546+
[
547+
$section->getId(),
548+
$action->getId()
549+
]
550+
);
551+
552+
if (!$sectionVisibilityFilter->isVisible($sectionPath)) {
553+
$section->removeAction($action);
554+
555+
continue;
556+
}
557+
543558
$this->propagate($action);
544559
$resolver = new ActionResolver($action->getUrl());
545560
if (
@@ -580,7 +595,7 @@ protected function getUserService()
580595
return $this->getServiceLocator()->get(tao_models_classes_UserService::SERVICE_ID);
581596
}
582597

583-
private function getSectionVisibilityFilter(): SectionVisibilityFilterInterface
598+
private function getSectionVisibilityFilter(): SectionVisibilityFilter
584599
{
585600
if (empty($this->sectionVisibilityFilter)) {
586601
$this->sectionVisibilityFilter = $this->getServiceLocator()->get(SectionVisibilityFilter::SERVICE_ID);

actions/class.Translation.php

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<?php
2+
3+
/**
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; under version 2
7+
* of the License (non-upgradable).
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*
18+
* Copyright (c) 2024 (original work) Open Assessment Technologies SA;
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
use oat\tao\model\http\HttpJsonResponseTrait;
24+
use oat\tao\model\Translation\Command\UpdateTranslationCommand;
25+
use oat\tao\model\Translation\Service\ResourceTranslationRetriever;
26+
use oat\tao\model\Translation\Service\ResourceTranslatableRetriever;
27+
use oat\tao\model\Translation\Service\TranslationCreationService;
28+
use oat\tao\model\Translation\Service\TranslationDeletionService;
29+
use oat\tao\model\Translation\Service\TranslationSyncService;
30+
use oat\tao\model\Translation\Service\TranslationUpdateService;
31+
32+
class tao_actions_Translation extends tao_actions_CommonModule
33+
{
34+
use HttpJsonResponseTrait;
35+
36+
/**
37+
* @requiresRight id WRITE
38+
*/
39+
public function update(): void
40+
{
41+
try {
42+
$resource = $this->getTranslationUpdateService()->update(
43+
new UpdateTranslationCommand(
44+
$this->getRequestParameter('id'),
45+
$this->getRequestParameter('progress'),
46+
)
47+
);
48+
49+
$this->setSuccessJsonResponse(
50+
[
51+
'resourceUri' => $resource->getUri()
52+
]
53+
);
54+
} catch (Throwable $exception) {
55+
$this->setErrorJsonResponse($exception->getMessage());
56+
}
57+
}
58+
59+
/**
60+
* @requiresRight id WRITE
61+
*/
62+
public function delete(): void
63+
{
64+
try {
65+
$resource = $this->getTranslationDeletionService()->deleteByRequest($this->getPsrRequest());
66+
67+
$this->setSuccessJsonResponse(
68+
[
69+
'resourceUri' => $resource->getUri()
70+
]
71+
);
72+
} catch (Throwable $exception) {
73+
$this->setErrorJsonResponse($exception->getMessage());
74+
}
75+
}
76+
77+
/**
78+
* @requiresRight id WRITE
79+
*/
80+
public function translate(): void
81+
{
82+
try {
83+
$newResource = $this->getTranslationCreationService()->createByRequest($this->getPsrRequest());
84+
85+
$this->setSuccessJsonResponse(
86+
[
87+
'resourceUri' => $newResource->getUri()
88+
]
89+
);
90+
} catch (Throwable $exception) {
91+
$this->setErrorJsonResponse($exception->getMessage());
92+
}
93+
}
94+
95+
/**
96+
* @requiresRight id READ
97+
*/
98+
public function translations(): void
99+
{
100+
try {
101+
$this->setSuccessJsonResponse(
102+
$this->getResourceTranslationRetriever()->getByRequest($this->getPsrRequest())
103+
);
104+
} catch (Throwable $exception) {
105+
$this->setErrorJsonResponse($exception->getMessage());
106+
}
107+
}
108+
109+
/**
110+
* @requiresRight id READ
111+
*/
112+
public function translatable(): void
113+
{
114+
try {
115+
$this->setSuccessJsonResponse(
116+
$this->getResourceTranslatableRetriever()->getByRequest($this->getPsrRequest())
117+
);
118+
} catch (Throwable $exception) {
119+
$this->setErrorJsonResponse($exception->getMessage());
120+
}
121+
}
122+
123+
/**
124+
* @requiresRight id WRITE
125+
*/
126+
public function sync(): void
127+
{
128+
try {
129+
$test = $this->getTranslationSyncService()->syncByRequest($this->getPsrRequest());
130+
131+
$this->setSuccessJsonResponse([
132+
'resourceUri' => $test->getUri(),
133+
]);
134+
} catch (Throwable $exception) {
135+
$this->setErrorJsonResponse($exception->getMessage());
136+
}
137+
}
138+
139+
private function getResourceTranslationRetriever(): ResourceTranslationRetriever
140+
{
141+
return $this->getPsrContainer()->get(ResourceTranslationRetriever::class);
142+
}
143+
144+
private function getResourceTranslatableRetriever(): ResourceTranslatableRetriever
145+
{
146+
return $this->getPsrContainer()->get(ResourceTranslatableRetriever::class);
147+
}
148+
149+
private function getTranslationCreationService(): TranslationCreationService
150+
{
151+
return $this->getPsrContainer()->get(TranslationCreationService::class);
152+
}
153+
154+
private function getTranslationUpdateService(): TranslationUpdateService
155+
{
156+
return $this->getPsrContainer()->get(TranslationUpdateService::class);
157+
}
158+
159+
private function getTranslationSyncService(): TranslationSyncService
160+
{
161+
return $this->getPsrContainer()->get(TranslationSyncService::class);
162+
}
163+
164+
private function getTranslationDeletionService(): TranslationDeletionService
165+
{
166+
return $this->getPsrContainer()->get(TranslationDeletionService::class);
167+
}
168+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"oat-sa/jig": "~0.2",
6868
"oat-sa/composer-npm-bridge": "~0.4.2||dev-master",
6969
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
70-
"oat-sa/generis": ">=15.36.4",
70+
"oat-sa/generis": ">=15.39.0",
7171
"composer/package-versions-deprecated": "^1.11",
7272
"paragonie/random_compat": "^2.0",
7373
"phpdocumentor/reflection-docblock": "^5.2",

0 commit comments

Comments
 (0)