pull/4161/head
Angel Fernando Quiroz Campos 3 years ago
parent 96b405135f
commit 6da67da186
  1. 5
      src/CoreBundle/Controller/CourseController.php
  2. 1
      src/CoreBundle/DataProvider/Extension/CourseExtension.php
  3. 4
      src/CoreBundle/EventListener/CourseListener.php
  4. 5
      src/CoreBundle/Form/ExtraFieldType.php
  5. 6
      src/CoreBundle/Repository/LegalRepository.php

@ -10,7 +10,6 @@ use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ExtraField; use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Entity\Tag; use Chamilo\CoreBundle\Entity\Tag;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\ExtraFieldRelTagRepository;
use Chamilo\CoreBundle\Repository\LanguageRepository; use Chamilo\CoreBundle\Repository\LanguageRepository;
use Chamilo\CoreBundle\Repository\LegalRepository; use Chamilo\CoreBundle\Repository\LegalRepository;
use Chamilo\CoreBundle\Repository\Node\IllustrationRepository; use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
@ -93,7 +92,7 @@ class CourseController extends ToolBaseController
$condArray = explode(':', $request->get('legal_accept_type')); $condArray = explode(':', $request->get('legal_accept_type'));
if (!empty($condArray[0]) && !empty($condArray[1])) { if (!empty($condArray[0]) && !empty($condArray[1])) {
$time = time(); $time = time();
$conditionToSave = intval($condArray[0]).':'.intval($condArray[1]).':'.$time; $conditionToSave = (int) ($condArray[0]).':'.(int) ($condArray[1]).':'.$time;
UserManager::update_extra_field_value( UserManager::update_extra_field_value(
$userId, $userId,
'legal_accept', 'legal_accept',
@ -106,7 +105,7 @@ class CourseController extends ToolBaseController
$allow = api_get_configuration_value('allow_public_course_with_no_terms_conditions'); $allow = api_get_configuration_value('allow_public_course_with_no_terms_conditions');
if (true === $allow && if (true === $allow &&
null !== $course->getVisibility() && null !== $course->getVisibility() &&
COURSE_VISIBILITY_OPEN_WORLD == $course->getVisibility() COURSE_VISIBILITY_OPEN_WORLD === $course->getVisibility()
) { ) {
$redirect = false; $redirect = false;
} }

@ -10,7 +10,6 @@ use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryCollectionExtensionInter
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface; //use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface; use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceLink;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;

@ -13,6 +13,7 @@ use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter; use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter; use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter; use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CourseBundle\Controller\CourseControllerInterface; use Chamilo\CourseBundle\Controller\CourseControllerInterface;
use Chamilo\CourseBundle\Entity\CGroup; use Chamilo\CourseBundle\Entity\CGroup;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
@ -26,9 +27,6 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Twig\Environment; use Twig\Environment;
use Chamilo\CoreBundle\Repository\LegalRepository;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Symfony\Component\HttpFoundation\RedirectResponse;
/** /**
* Class CourseListener. * Class CourseListener.

@ -199,16 +199,17 @@ class ExtraFieldType extends AbstractType
break; break;
case \ExtraField::FIELD_TYPE_CHECKBOX: case \ExtraField::FIELD_TYPE_CHECKBOX:
$defaultOptions['data'] = (int) $value === 1; $defaultOptions['data'] = 1 === (int) $value;
$builder->add($variable, CheckboxType::class, $defaultOptions); $builder->add($variable, CheckboxType::class, $defaultOptions);
break; break;
case \ExtraField::FIELD_TYPE_RADIO: case \ExtraField::FIELD_TYPE_RADIO:
case \ExtraField::FIELD_TYPE_SELECT: case \ExtraField::FIELD_TYPE_SELECT:
case \ExtraField::FIELD_TYPE_SELECT_MULTIPLE: case \ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
if (empty($value)) { if (empty($value)) {
$defaultOptions['data'] = null; $defaultOptions['data'] = null;
if ($extraField->getFieldType() === \ExtraField::FIELD_TYPE_CHECKBOX) { if (\ExtraField::FIELD_TYPE_CHECKBOX === $extraField->getFieldType()) {
$defaultOptions['data'] = []; $defaultOptions['data'] = [];
} }
} }

@ -13,6 +13,7 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Exception; use Exception;
use ExtraFieldValue;
class LegalRepository extends ServiceEntityRepository class LegalRepository extends ServiceEntityRepository
{ {
@ -89,11 +90,11 @@ class LegalRepository extends ServiceEntityRepository
{ {
if ('true' === api_get_setting('allow_terms_conditions')) { if ('true' === api_get_setting('allow_terms_conditions')) {
// Check if exists terms and conditions // Check if exists terms and conditions
if (0 == $this->countTerms()) { if (0 === $this->countTerms()) {
return true; return true;
} }
$extraFieldValue = new \ExtraFieldValue('user'); $extraFieldValue = new ExtraFieldValue('user');
$data = $extraFieldValue->get_values_by_handler_and_field_variable( $data = $extraFieldValue->get_values_by_handler_and_field_variable(
$user->getId(), $user->getId(),
'legal_accept' 'legal_accept'
@ -149,6 +150,7 @@ class LegalRepository extends ServiceEntityRepository
; ;
if (!empty($result)) { if (!empty($result)) {
$version = explode(':', $result); $version = explode(':', $result);
return (int) $version[0]; return (int) $version[0];
} }

Loading…
Cancel
Save