Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 15.19.3 #417

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use oat\taoLti\scripts\install\CreateLti1p3RegistrationSnapshotSchema;
use oat\taoLti\scripts\install\GenerateKeys;
use oat\taoLti\scripts\install\GenerisSearchWhitelist;
use oat\taoLti\scripts\install\RegisterPortalTheme;
use oat\taoLti\scripts\install\SetupServices;
use oat\taoLti\scripts\install\MapLtiSectionVisibility;
use oat\taoLti\scripts\update\Updater;
Expand Down Expand Up @@ -66,6 +67,7 @@
MapLtiSectionVisibility::class,
GenerisSearchWhitelist::class,
CreateLti1p3RegistrationSnapshotSchema::class,
RegisterPortalTheme::class
]
],
'update' => Updater::class,
Expand Down
33 changes: 33 additions & 0 deletions migrations/Version202406060802293772_taoLti.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace oat\taoLti\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\taoLti\scripts\install\RegisterPortalTheme;
use oat\taoQtiTest\scripts\install\RegisterQtiPackageExporter;

/**
* Auto-generated Migration: Please modify to your needs!
*
* phpcs:disable Squiz.Classes.ValidClassName
*/
final class Version202406060802293772_taoLti extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$this->runAction(new RegisterPortalTheme());
}

public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException();
}
}
48 changes: 48 additions & 0 deletions models/classes/theme/PortalThemeService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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\taoLti\models\classes\theme;

use common_session_SessionManager;
use oat\tao\model\session\Context\TenantDataSessionContext;
use oat\tao\model\theme\PortalTheme;
use oat\tao\model\theme\ThemeService;
use oat\taoLti\models\classes\TaoLtiSession;

class PortalThemeService extends ThemeService
{
public function getCurrentThemeId()
{
if ($this->isSessionFromPortal()) {
return PortalTheme::THEME_ID;
}

return $this->getOption(static::OPTION_CURRENT);
}

private function isSessionFromPortal(): bool
{
$session = common_session_SessionManager::getSession();
return $session instanceof TaoLtiSession
&& !empty($session->getContexts(TenantDataSessionContext::class));
}
}
45 changes: 45 additions & 0 deletions scripts/install/RegisterPortalTheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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\taoLti\scripts\install;

use oat\oatbox\config\ConfigurationService;
use oat\oatbox\extension\InstallAction;
use oat\tao\model\theme\PortalTheme;
use oat\tao\model\theme\ThemeServiceInterface;
use oat\taoLti\models\classes\theme\PortalThemeService;

class RegisterPortalTheme extends InstallAction
{
public function __invoke($params = [])
{
/** @var ConfigurationService $previousThemeService */
$previousThemeService = $this->getServiceManager()->get(ThemeServiceInterface::SERVICE_ID);

/** @var ThemeServiceInterface $service */
$service = $this->propagate(new PortalThemeService());
$service->setOptions($previousThemeService->getOptions());
$service->addTheme(new PortalTheme(), false);

$this->getServiceManager()->register(ThemeServiceInterface::SERVICE_ID, $service);
}
}
Loading