Skip to content

Commit

Permalink
Merge branch 'release-12.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 11, 2024
2 parents 0546df7 + b93e3d1 commit c4db8d7
Show file tree
Hide file tree
Showing 19 changed files with 873 additions and 7 deletions.
24 changes: 23 additions & 1 deletion actions/class.Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use oat\generis\model\OntologyRdfs;
use oat\tao\model\lock\LockManager;
use oat\tao\model\TaoOntology;
use oat\taoItems\model\Form\Modifier\FormModifierProxy;
use oat\taoItems\model\ItemModelStatus;
use oat\tao\model\accessControl\Context;
use oat\generis\model\OntologyAwareTrait;
Expand All @@ -38,6 +39,7 @@
use oat\taoItems\model\event\ItemUpdatedEvent;
use oat\tao\model\controller\SignedFormInstance;
use oat\taoItems\model\event\ItemRdfUpdatedEvent;
use oat\taoItems\model\Translation\Form\Modifier\TranslationFormModifierProxy;
use tao_helpers_form_FormContainer as FormContainer;
use oat\tao\model\Lists\Business\Validation\DependsOnPropertyValidator;

Expand Down Expand Up @@ -185,6 +187,10 @@ public function editItem(): void
$this->getDependsOnPropertyValidator(),
],
],
FormContainer::FORM_MODIFIERS => [
FormModifierProxy::class,
TranslationFormModifierProxy::class,
],
]
);
$myForm = $formContainer->getForm();
Expand Down Expand Up @@ -353,6 +359,22 @@ public function authoring()
LockManager::getImplementation()
->setLock($item, $this->getSession()->getUser()->getIdentifier());

// Add support for the translation and the side-by-side authoring tool
if ($this->getRequestParameter('translation') !== null) {
$authoringUrl = sprintf(
'%s&translation=%s',
$authoringUrl,
$this->getRequestParameter('translation')
);
}
if ($this->getRequestParameter('originResourceUri') !== null) {
$authoringUrl = sprintf(
'%s&originResourceUri=%s',
$authoringUrl,
$this->getRequestParameter('originResourceUri')
);
}

return $this->forwardUrl($authoringUrl);
}
}
Expand All @@ -366,7 +388,7 @@ public function authoring()
if (!empty($itemModel) && $itemModel instanceof core_kernel_classes_Resource) {
$errorMsg = __(
'No item authoring tool available for the selected type of item: %s'
. $itemModel->getLabel()
. $itemModel->getLabel()
);
} else {
$errorMsg = __('No item type selected for the current item.')
Expand Down
3 changes: 3 additions & 0 deletions actions/structures.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<action id="item-move-all" name="Move To" url="/taoItems/Items/moveAll" context="resource" multiple="true" group="tree" binding="moveTo">
<icon id="icon-move-item"/>
</action>
<action id="item-translate" name="Translate" url="/tao/Translation/translate" context="instance" group="tree" binding="translateItem">
<icon id="icon-replace"/>
</action>
</actions>
</section>
</sections>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
},
"require": {
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/generis": ">=15.36.1",
"oat-sa/tao-core": ">=53.0.0",
"oat-sa/generis": ">=15.39.0",
"oat-sa/tao-core": ">=54.23.0",
"oat-sa/extension-tao-backoffice": ">=6.0.0"
},
"autoload": {
Expand Down
17 changes: 15 additions & 2 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

use oat\tao\model\user\TaoRoles;
use oat\taoBackOffice\controller\Lists;
use oat\taoItems\model\search\ItemClassListService;
use oat\taoItems\model\Form\ServiceProvider\FormServiceProvider;
use oat\taoItems\model\search\ItemClassListServiceProvider;
use oat\taoItems\model\Translation\ServiceProvider\TranslationServiceProvider;
use oat\taoItems\model\user\TaoItemsRoles;
use oat\tao\model\accessControl\func\AccessRule;
use oat\taoItems\scripts\install\RegisterNpmPaths;
Expand All @@ -37,6 +38,7 @@
use oat\taoItems\scripts\install\RegisterCategoryService;
use oat\taoItems\scripts\install\RegisterAssetTreeBuilder;
use oat\taoItems\scripts\install\RegisterItemPreviewerRegistryService;
use oat\taoItems\scripts\install\SetupEventListeners;

/*
* @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
Expand Down Expand Up @@ -67,6 +69,7 @@
RegisterItemPreviewerRegistryService::class,
RegisterAssetTreeBuilder::class,
SetRolesPermissions::class,
SetupEventListeners::class,
],
],
'update' => taoItems_scripts_update_Updater::class,
Expand Down Expand Up @@ -227,6 +230,14 @@
TaoItemsRoles::RESTRICTED_ITEM_AUTHOR,
['ext' => 'taoItems', 'mod' => 'ItemExport']
],
[
AccessRule::GRANT,
TaoItemsRoles::ITEM_TRANSLATOR,
[
'ext' => 'tao',
'mod' => 'Translation'
]
]
],
'optimizableClasses' => [
'http://www.tao.lu/Ontologies/TAOItem.rdf#Item',
Expand Down Expand Up @@ -254,6 +265,8 @@
],
'containerServiceProviders' => [
CopierServiceProvider::class,
ItemClassListServiceProvider::class
ItemClassListServiceProvider::class,
TranslationServiceProvider::class,
FormServiceProvider::class,
],
];
107 changes: 107 additions & 0 deletions migrations/Version202409060743452142_taoItems.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

declare(strict_types=1);

namespace oat\taoItems\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\oatbox\event\EventManager;
use oat\oatbox\reporting\Report;
use oat\tao\model\accessControl\func\AccessRule;
use oat\tao\model\accessControl\func\AclProxy;
use oat\tao\model\menu\SectionVisibilityFilter;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\tao\scripts\update\OntologyUpdater;
use oat\taoItems\model\event\ItemCreatedEvent;
use oat\taoItems\model\event\ItemRemovedEvent;
use oat\taoItems\model\event\ItemUpdatedEvent;
use oat\taoItems\model\Translation\Listener\TranslationItemEventListener;
use oat\taoItems\model\user\TaoItemsRoles;

final class Version202409060743452142_taoItems extends AbstractMigration
{
public function getDescription(): string
{
return 'Add new Item Translator Role, sync models and add new listener';
}

public function up(Schema $schema): void
{
OntologyUpdater::syncModels();

AclProxy::applyRule($this->getRule());

$this->addReport(Report::createSuccess('Applied rules for role ' . TaoItemsRoles::ITEM_TRANSLATOR));

/** @var SectionVisibilityFilter $sectionVisibilityFilter */
$sectionVisibilityFilter = $this->getServiceManager()->get(SectionVisibilityFilter::SERVICE_ID);

$sectionVisibilityFilter->showSectionByFeatureFlag(
$sectionVisibilityFilter->createSectionPath(
[
'manage_items',
'item-translate'
]
),
'FEATURE_FLAG_TRANSLATION_ENABLED'
);
$this->getServiceManager()->register(SectionVisibilityFilter::SERVICE_ID, $sectionVisibilityFilter);

$this->addReport(
Report::createSuccess('Hide item section for feature flag FEATURE_FLAG_TRANSLATION_ENABLED')
);

/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->attach(
ItemCreatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$eventManager->attach(
ItemUpdatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$eventManager->attach(
ItemRemovedEvent::class,
[TranslationItemEventListener::class, 'deleteTranslations']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);

$this->addReport(
Report::createSuccess('Listen to ' . ItemCreatedEvent::class . ' at ' . TranslationItemEventListener::class)
);
}

public function down(Schema $schema): void
{
AclProxy::revokeRule($this->getRule());

/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->detach(
ItemCreatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$eventManager->detach(
ItemUpdatedEvent::class,
[TranslationItemEventListener::class, 'populateTranslationProperties']
);
$eventManager->detach(
ItemRemovedEvent::class,
[TranslationItemEventListener::class, 'deleteTranslations']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);
}

private function getRule(): AccessRule
{
return new AccessRule(
AccessRule::GRANT,
TaoItemsRoles::ITEM_TRANSLATOR,
[
'ext' => 'tao',
'mod' => 'Translation'
]
);
}
}
6 changes: 6 additions & 0 deletions models/classes/Copier/CopierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public function __invoke(ContainerConfigurator $configurator): void
[
tagged_iterator('tao.copier.permissions'),
]
)
->call(
'withEventManager',
[
service(EventManager::class),
]
);

$services
Expand Down
29 changes: 29 additions & 0 deletions models/classes/Form/Modifier/FormModifierProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoItems\model\Form\Modifier;

use oat\tao\model\form\Modifier\AbstractFormModifier;

final class FormModifierProxy extends AbstractFormModifier
{
}
51 changes: 51 additions & 0 deletions models/classes/Form/ServiceProvider/FormServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoItems\model\Form\ServiceProvider;

use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\tao\model\form\Modifier\UniqueIdFormModifier;
use oat\taoItems\model\Form\Modifier\FormModifierProxy;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

class FormServiceProvider implements ContainerServiceProviderInterface
{
public function __invoke(ContainerConfigurator $configurator): void
{
$services = $configurator->services();

$services
->set(FormModifierProxy::class, FormModifierProxy::class)
->public();

$services
->get(FormModifierProxy::class)
->call(
'addModifier',
[
service(UniqueIdFormModifier::class),
]
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoItems\model\Translation\Form\Modifier;

use oat\tao\model\form\Modifier\AbstractFormModifier;

final class TranslationFormModifierProxy extends AbstractFormModifier
{
}
Loading

0 comments on commit c4db8d7

Please sign in to comment.