Merge remote-tracking branch 'origin/master'

pull/5674/head
Angel Fernando Quiroz Campos 1 year ago
commit 3cef176347
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 5
      src/CoreBundle/Controller/ResourceController.php
  2. 5
      src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
  3. 19
      src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php
  4. 2
      src/CoreBundle/Settings/SecuritySettingsSchema.php

@ -146,9 +146,10 @@ class ResourceController extends AbstractResourceController implements CourseCon
$user = $this->userHelper->getCurrent(); $user = $this->userHelper->getCurrent();
$firstResourceLink = $resourceNode->getResourceLinks()->first(); $firstResourceLink = $resourceNode->getResourceLinks()->first();
if ($firstResourceLink && $user) { $firstResourceFile = $resourceNode->getResourceFiles()->first();
if ($firstResourceLink && $user && $firstResourceFile) {
$resourceLinkId = $firstResourceLink->getId(); $resourceLinkId = $firstResourceLink->getId();
$url = $resourceNode->getResourceFiles()->first()->getOriginalName(); $url = $firstResourceFile->getOriginalName();
$downloadRepository = $entityManager->getRepository(TrackEDownloads::class); $downloadRepository = $entityManager->getRepository(TrackEDownloads::class);
$downloadRepository->saveDownload($user->getId(), $resourceLinkId, $url); $downloadRepository->saveDownload($user->getId(), $resourceLinkId, $url);
} }

@ -1302,6 +1302,11 @@ class SettingsCurrentFixtures extends Fixture implements FixtureGroupInterface
'title' => 'Time limit for password reset token', 'title' => 'Time limit for password reset token',
'comment' => 'The number of seconds before the generated token automatically expires and cannot be used anymore (a new token needs to be generated).', 'comment' => 'The number of seconds before the generated token automatically expires and cannot be used anymore (a new token needs to be generated).',
], ],
[
'name' => 'access_to_personal_file_for_all',
'title' => 'Access to personal file for all',
'comment' => 'Allows access to all personal files without restriction',
],
], ],
'tracking' => [ 'tracking' => [
[ [

@ -11,6 +11,7 @@ use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CoreBundle\Entity\ResourceNode; use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\ResourceRight; use Chamilo\CoreBundle\Entity\ResourceRight;
use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CourseBundle\Entity\CGroup; use Chamilo\CourseBundle\Entity\CGroup;
use ChamiloSession; use ChamiloSession;
use Laminas\Permissions\Acl\Acl; use Laminas\Permissions\Acl\Acl;
@ -41,14 +42,11 @@ class ResourceNodeVoter extends Voter
public const ROLE_CURRENT_COURSE_SESSION_TEACHER = 'ROLE_CURRENT_COURSE_SESSION_TEACHER'; public const ROLE_CURRENT_COURSE_SESSION_TEACHER = 'ROLE_CURRENT_COURSE_SESSION_TEACHER';
public const ROLE_CURRENT_COURSE_SESSION_STUDENT = 'ROLE_CURRENT_COURSE_SESSION_STUDENT'; public const ROLE_CURRENT_COURSE_SESSION_STUDENT = 'ROLE_CURRENT_COURSE_SESSION_STUDENT';
private RequestStack $requestStack; public function __construct(
private Security $security; private Security $security,
private RequestStack $requestStack,
public function __construct(Security $security, RequestStack $requestStack) private SettingsManager $settingsManager
{ ) {}
$this->security = $security;
$this->requestStack = $requestStack;
}
public static function getReaderMask(): int public static function getReaderMask(): int
{ {
@ -170,6 +168,11 @@ class ResourceNodeVoter extends Voter
if (0 === $groupId && $firstLink->getGroup() instanceof CGroup) { if (0 === $groupId && $firstLink->getGroup() instanceof CGroup) {
$groupId = (int) $firstLink->getGroup()->getIid(); $groupId = (int) $firstLink->getGroup()->getIid();
} }
if ($firstLink->getUser() instanceof UserInterface
&& 'true' === $this->settingsManager->getSetting('security.access_to_personal_file_for_all')
) {
return true;
}
} }
$linkFound = 0; $linkFound = 0;

@ -42,6 +42,7 @@ class SecuritySettingsSchema extends AbstractSettingsSchema
'allow_online_users_by_status' => '', 'allow_online_users_by_status' => '',
'security_session_cookie_samesite_none' => 'false', 'security_session_cookie_samesite_none' => 'false',
'anonymous_autoprovisioning' => 'false', 'anonymous_autoprovisioning' => 'false',
'access_to_personal_file_for_all' => 'false',
] ]
); );
$allowedTypes = [ $allowedTypes = [
@ -161,6 +162,7 @@ class SecuritySettingsSchema extends AbstractSettingsSchema
) )
->add('security_session_cookie_samesite_none', YesNoType::class) ->add('security_session_cookie_samesite_none', YesNoType::class)
->add('anonymous_autoprovisioning', YesNoType::class) ->add('anonymous_autoprovisioning', YesNoType::class)
->add('access_to_personal_file_for_all', YesNoType::class)
; ;
$this->updateFormFieldsFromSettingsInfo($builder); $this->updateFormFieldsFromSettingsInfo($builder);

Loading…
Cancel
Save