Skip to content

Commit

Permalink
Merge branch 'release_9' of https://github.com/ILIAS-eLearning/ILIAS
Browse files Browse the repository at this point in the history
…into release_9
  • Loading branch information
alex40724 committed Oct 31, 2023
2 parents bd62f1e + 0a13c7a commit 972e800
Show file tree
Hide file tree
Showing 33 changed files with 392 additions and 163 deletions.
7 changes: 5 additions & 2 deletions Modules/File/classes/Versions/class.ilFileVersionsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use ILIAS\Services\WOPI\Embed\EmbeddedApplication;
use ILIAS\Data\URI;
use ILIAS\UI\Component\Modal\Modal;
use ILIAS\Services\WOPI\Discovery\ActionTarget;

/**
* @author Fabian Schmid <[email protected]>
Expand Down Expand Up @@ -200,7 +201,8 @@ public function executeCommand(): void
return;
case strtolower(ilWOPIEmbeddedApplicationGUI::class):
$action = $this->action_repo->getActionForSuffix(
$this->current_revision->getInformation()->getSuffix()
$this->current_revision->getInformation()->getSuffix(),
ActionTarget::EDIT
);

$embeded_application = new EmbeddedApplication(
Expand Down Expand Up @@ -329,7 +331,8 @@ private function index(): void
$suffix = $this->current_revision?->getInformation()?->getSuffix();

if ($this->action_repo->hasActionForSuffix(
$this->current_revision->getInformation()->getSuffix()
$this->current_revision->getInformation()->getSuffix(),
ActionTarget::EDIT
)) {
$external_editor = $this->ui->factory()
->button()
Expand Down
7 changes: 5 additions & 2 deletions Modules/File/classes/class.ilObjFileGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use ILIAS\Services\WOPI\Discovery\ActionDBRepository;
use ILIAS\Services\WOPI\Embed\EmbeddedApplication;
use ILIAS\Data\URI;
use ILIAS\Services\WOPI\Discovery\ActionTarget;

/**
* GUI class for file objects.
Expand Down Expand Up @@ -241,7 +242,8 @@ public function executeCommand(): void
return;
}
$action = $this->action_repo->getActionForSuffix(
$this->object->getFileExtension()
$this->object->getFileExtension(),
ActionTarget::EDIT
);
if (null === $action) {
$this->error->raiseError($this->lng->txt("no_action_avaliable"), $this->error->MESSAGE);
Expand Down Expand Up @@ -784,7 +786,8 @@ public function infoScreenForward(): void
if (
$this->checkPermissionBool("edit_file")
&& $this->action_repo->hasActionForSuffix(
$this->object->getFileExtension()
$this->object->getFileExtension(),
ActionTarget::EDIT
)) {
$external_editor = $this->ui->factory()
->button()
Expand Down
3 changes: 2 additions & 1 deletion Modules/File/classes/class.ilObjFileListGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use ILIAS\ResourceStorage\Services;
use ILIAS\Data\DataSize;
use ILIAS\Services\WOPI\Discovery\ActionDBRepository;
use ILIAS\Services\WOPI\Discovery\ActionTarget;

/**
* Class ilObjFileListGUI
Expand Down Expand Up @@ -252,7 +253,7 @@ public function checkCommandAccess(

$additional_check = match ($cmd) {
ilFileVersionsGUI::CMD_UNZIP_CURRENT_REVISION => ilObjFileAccess::isZIP($data['mime'] ?? null),
'editExternal' => $this->action_repo->hasActionForSuffix($data['suffix'] ?? ''),
'editExternal' => $this->action_repo->hasActionForSuffix($data['suffix'] ?? '', ActionTarget::EDIT),
default => true,
};

Expand Down
18 changes: 15 additions & 3 deletions Services/Authentication/classes/class.ilSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ public static function _exists(string $a_session_id): bool
/**
* Destroy session
*
* @param string|array session id|s
* @param int closing context
* @param int|bool expired at timestamp
* @param string|array $a_session_id session id|s
* @param int|null $a_closing_context closing context
* @param int|bool $a_expired_at expired at timestamp
*/
public static function _destroy($a_session_id, ?int $a_closing_context = null, $a_expired_at = null): bool
{
Expand Down Expand Up @@ -260,6 +260,18 @@ public static function _destroy($a_session_id, ?int $a_closing_context = null, $

$ilDB->manipulate($q);

try {
// only delete session cookie if it is set in the current request
if ($DIC->http()->wrapper()->cookie()->has(session_name()) &&
$DIC->http()->wrapper()->cookie()->retrieve(session_name(), $DIC->refinery()->kindlyTo()->string()) === $a_session_id) {
$cookieJar = $DIC->http()->cookieJar()->without(session_name());
$cookieJar->renderIntoResponseHeader($DIC->http()->response());
}
} catch (\Throwable $e) {
// ignore
// this is needed for "header already" sent errors when the random cleanup of expired sessions is triggered
}

return true;
}

Expand Down
11 changes: 8 additions & 3 deletions Services/Init/classes/class.ilInitialisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,12 @@ protected static function goToLogin(): void
{
global $DIC;

$a_auth_stat = "";
$session_expired = false;
ilLoggerFactory::getLogger('init')->debug('Redirecting to login page.');

if ($DIC['ilAuthSession']->isExpired()) {
ilSession::setClosingContext(ilSession::SESSION_CLOSE_EXPIRE);
$session_expired = true;
}
if (!$DIC['ilAuthSession']->isAuthenticated()) {
ilSession::setClosingContext(ilSession::SESSION_CLOSE_LOGIN);
Expand All @@ -974,8 +975,8 @@ protected static function goToLogin(): void
])
);

$script = "login.php?" . $target . "client_id=" . $client_id .
"&auth_stat=" . $a_auth_stat;
$script = "login.php?" . $target . "client_id=" . $client_id;
$script .= $session_expired ? "&session_expired=1" : "";

self::redirect(
$script,
Expand Down Expand Up @@ -1342,6 +1343,10 @@ public static function resumeUserSession(): void
!$DIC['ilAuthSession']->isAuthenticated() or
$DIC['ilAuthSession']->isExpired()
) {
if ($GLOBALS['DIC']['ilAuthSession']->isExpired()) {
ilSession::_destroy($_COOKIE[session_name()], ilSession::SESSION_CLOSE_EXPIRE);
}

ilLoggerFactory::getLogger('init')->debug('Current session is invalid: ' . $GLOBALS['DIC']['ilAuthSession']->getId());
$current_script = substr(strrchr($_SERVER["PHP_SELF"], "/"), 1);
if (self::blockedAuthentication($current_script)) {
Expand Down
2 changes: 1 addition & 1 deletion Services/Init/classes/class.ilStartUpGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private function showLoginPage(ILIAS\UI\Component\Input\Container\Form\Form $for
$page_editor_html = $this->purgePlaceholders($page_editor_html);

// check expired session and send message
if ($this->authSession->isExpired()) {
if ($this->authSession->isExpired() || $this->http->wrapper()->query()->has('session_expired')) {
$this->mainTemplate->setOnScreenMessage('failure', $this->lng->txt('auth_err_expired'));
} elseif ($this->http->wrapper()->query()->has('reg_confirmation_msg')) {
$this->lng->loadLanguageModule('registration');
Expand Down
2 changes: 1 addition & 1 deletion Services/Mail/classes/class.ilObjMailGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ protected function saveExternalSettingsFormObject(): void
return;
}

// If all forms in ILIAS use the UI/KS forms (here and in Services/Mail), we should move this to a propert constraint/trafo
// If all forms in ILIAS use the UI/KS forms (here and in Services/Mail), we should move this to a proper constraint/trafo
$is_valid_template_syntax = $this->refinery->custom()->constraint(function ($value): bool {
try {
$this->mustache_factory->getBasicEngine()->render((string) $value, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ protected function createUser(int $a_role): string

case "relative":
$rel = unserialize($code_data["alimitdt"], ['allowed_classes' => false]);
$access_limit = $rel["d"] * 86400 + $rel["m"] * 2592000 + $rel["y"] * 31536000 + time();
$access_limit = (int) ($rel["d"] * 86400 + $rel["m"] * 2592000 + $rel["y"] * 31536000 + time());
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Services/Skill/Node/class.ilBasicSkill.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
********************************************************************
*/

use ILIAS\Skill\Usage\SkillUsageManager;
use ILIAS\Skill\Usage;

/**
* Basic Skill
* @author Alex Killing <[email protected]>
*/
class ilBasicSkill extends ilSkillTreeNode implements ilSkillUsageInfo
class ilBasicSkill extends ilSkillTreeNode implements Usage\SkillUsageInfo
{
protected ilObjUser $user;
protected ilSkillLevelRepository $bsc_skl_lvl_db_rep;
Expand Down Expand Up @@ -598,7 +598,7 @@ public static function getUsageInfo(array $a_cskill_ids): array

return $usage_manager->getUsageInfoGeneric(
$a_cskill_ids,
SkillUsageManager::USER_ASSIGNED,
Usage\SkillUsageManager::USER_ASSIGNED,
"skl_user_skill_level",
"user_id"
);
Expand Down
6 changes: 3 additions & 3 deletions Services/Skill/Personal/class.AssignedMaterialManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

namespace ILIAS\Skill\Personal;

use ILIAS\Skill\Usage\SkillUsageManager;
use ILIAS\Skill\Usage;

/**
* @author Thomas Famula <[email protected]>
*/
class AssignedMaterialManager implements \ilSkillUsageInfo
class AssignedMaterialManager implements Usage\SkillUsageInfo
{
protected AssignedMaterialDBRepository $ass_mat_repo;
protected PersonalSkillDBRepository $personal_repo;
Expand Down Expand Up @@ -116,7 +116,7 @@ public static function getUsageInfo(array $a_cskill_ids): array
// material
$usages = $usage_manager->getUsageInfoGeneric(
$a_cskill_ids,
SkillUsageManager::USER_MATERIAL,
Usage\SkillUsageManager::USER_MATERIAL,
"skl_assigned_material",
"user_id"
);
Expand Down
6 changes: 3 additions & 3 deletions Services/Skill/Profile/class.SkillProfileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

namespace ILIAS\Skill\Profile;

use ILIAS\Skill\Usage\SkillUsageManager;
use ILIAS\Skill\Usage;

/**
* @author Thomas Famula <[email protected]>
*/
class SkillProfileManager implements \ilSkillUsageInfo
class SkillProfileManager implements Usage\SkillUsageInfo
{
protected SkillProfileDBRepository $profile_repo;
protected SkillProfileLevelsDBRepository $profile_levels_repo;
Expand Down Expand Up @@ -462,7 +462,7 @@ public static function getUsageInfo(array $a_cskill_ids): array

return $usage_manager->getUsageInfoGeneric(
$a_cskill_ids,
SkillUsageManager::PROFILE,
Usage\SkillUsageManager::PROFILE,
"skl_profile_level",
"profile_id",
"base_skill_id"
Expand Down
6 changes: 3 additions & 3 deletions Services/Skill/Resource/class.SkillResourcesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace ILIAS\Skill\Resource;

use ILIAS\Skill\Usage\SkillUsageManager;
use ILIAS\Skill\Usage;

/**
* Manages resources for skills. This is not about user assigned materials,
Expand All @@ -34,7 +34,7 @@
*
* @author Thomas Famula <[email protected]>
*/
class SkillResourcesManager implements \ilSkillUsageInfo
class SkillResourcesManager implements Usage\SkillUsageInfo
{
protected SkillResourceDBRepository $skill_res_repo;
protected \ilSkillLevelRepository $level_repo;
Expand Down Expand Up @@ -227,7 +227,7 @@ public static function getUsageInfo(array $a_cskill_ids): array

return $usage_manager->getUsageInfoGeneric(
$a_cskill_ids,
SkillUsageManager::RESOURCE,
Usage\SkillUsageManager::RESOURCE,
"skl_skill_resource",
"rep_ref_id",
"base_skill_id"
Expand Down
8 changes: 8 additions & 0 deletions Services/Skill/Service/classes/class.SkillService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ public function personal(): SkillPersonalService
return new SkillPersonalService($this->internal());
}

/**
* External usage service facade
*/
public function usage(): SkillUsageService
{
return new SkillUsageService($this->internal());
}

/**
* @inheritDoc
*/
Expand Down
47 changes: 47 additions & 0 deletions Services/Skill/Service/classes/class.SkillUsageService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\Skill\Service;

use ILIAS\Skill\Usage;

/**
* @author [email protected]
*/
class SkillUsageService
{
protected Usage\SkillUsageManager $usage_manager;

public function __construct(SkillInternalService $internal_service)
{
$this->usage_manager = $internal_service->manager()->getUsageManager();
}

public function addUsage(int $obj_id, int $skill_id, int $tref_id): void
{
$this->usage_manager->addUsage($obj_id, $skill_id, $tref_id);
}

public function removeUsage(int $obj_id, int $skill_id, int $tref_id): void
{
$this->usage_manager->removeUsage($obj_id, $skill_id, $tref_id);
}
}
4 changes: 2 additions & 2 deletions Services/Skill/Usage/class.SkillUsageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*
* @author Alex Killing <[email protected]>
*/
class SkillUsageManager implements \ilSkillUsageInfo
class SkillUsageManager implements SkillUsageInfo
{
public const TYPE_GENERAL = "gen";
public const USER_ASSIGNED = "user";
Expand All @@ -54,7 +54,7 @@ class SkillUsageManager implements \ilSkillUsageInfo
public const RESOURCE = "res";

/**
* @var \ilSkillUsageInfo[]
* @var SkillUsageInfo[]
*/
protected array $classes = [\ilBasicSkill::class, AssignedMaterialManager::class, SkillProfileManager::class,
SkillResourcesManager::class, SkillUsageManager::class];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*
********************************************************************/

namespace ILIAS\Skill\Usage;

/**
* Get info on usages of skills
*
Expand All @@ -25,7 +27,7 @@
*
* @ingroup ServicesSkill
*/
interface ilSkillUsageInfo
interface SkillUsageInfo
{
/**
* Get title of an assigned item
Expand Down
Loading

0 comments on commit 972e800

Please sign in to comment.