Use entities, fix setters/getters, update doc, fix type hint

pull/3844/head
Julio Montoya 5 years ago
parent de0fbe1266
commit d2acd03ca3
  1. 11
      public/main/forum/forumfunction.inc.php
  2. 21
      public/main/gradebook/lib/be/abstractlink.class.php
  3. 8
      public/main/gradebook/lib/be/category.class.php
  4. 8
      public/main/gradebook/lib/be/evaluation.class.php
  5. 4
      src/CoreBundle/Controller/Admin/AdminController.php
  6. 4
      src/CoreBundle/Controller/Admin/SettingsController.php
  7. 11
      src/CoreBundle/Controller/CourseController.php
  8. 11
      src/CoreBundle/Controller/CourseHomeController.php
  9. 12
      src/CoreBundle/Entity/GradebookEvaluation.php
  10. 31
      src/CoreBundle/Entity/GradebookLink.php
  11. 12
      src/CoreBundle/Entity/GradebookResult.php
  12. 5
      src/CoreBundle/Entity/Listener/CourseListener.php
  13. 4
      src/CoreBundle/Entity/Listener/SessionListener.php
  14. 2
      src/CoreBundle/Entity/ResourceNode.php
  15. 51
      src/CoreBundle/Entity/Session.php
  16. 4
      src/CoreBundle/Entity/Tool.php
  17. 54
      src/CoreBundle/Entity/User.php
  18. 5
      src/CoreBundle/Entity/Usergroup.php
  19. 1
      src/CoreBundle/EventListener/CourseListener.php
  20. 15
      src/CoreBundle/Repository/Node/UserRepository.php
  21. 5
      src/CoreBundle/Repository/ResourceRepository.php
  22. 4
      src/CoreBundle/Security/Authorization/Voter/CourseVoter.php
  23. 2
      src/CoreBundle/Security/Authorization/Voter/GroupVoter.php
  24. 2
      src/CoreBundle/Security/Authorization/Voter/SessionVoter.php
  25. 16
      src/CoreBundle/Security/LoginFormAuthenticator.php
  26. 16
      src/CoreBundle/Settings/SettingsManager.php
  27. 12
      src/CoreBundle/Settings/SettingsResolver.php

@ -776,6 +776,15 @@ function store_forum($values, $courseInfo = [], $returnId = false)
$repoForumCategory = Container::getForumCategoryRepository();
$forumCategory = $repoForumCategory->find($values['forum_category']);
}
$lpId = $values['lp_id'] ?? 0;
$lpRepo = Container::getLpRepository();
$lp = null;
if (!empty($lpId)) {
/** @var \Chamilo\CourseBundle\Entity\CLp $lp */
$lp = $lpRepo->find($lpId);
}
//'forum_image' => $new_file_name,
$forum
->setForumTitle($values['forum_title'])
@ -793,7 +802,7 @@ function store_forum($values, $courseInfo = [], $returnId = false)
->setStartTime(!empty($values['start_time']) ? api_get_utc_datetime($values['start_time'], true, true) : null)
->setEndTime(!empty($values['end_time']) ? api_get_utc_datetime($values['end_time'], true, true) : null)
->setSessionId($session_id)
->setLpId($values['lp_id'] ?? 0)
->setLp($lp)
;
$course = api_get_course_entity($courseId);

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\GradebookLink;
/**
@ -391,6 +392,11 @@ abstract class AbstractLink implements GradebookItem
if (0 == $row['count']) {
$em = Database::getManager();
$category = null;
if (!empty($this->get_category_id())) {
$category = $em->getRepository(GradebookCategory::class)->find($this->get_category_id());
}
$link = new GradebookLink();
$link
->setType($this->get_type())
@ -398,9 +404,9 @@ abstract class AbstractLink implements GradebookItem
->setWeight(api_float_val($this->get_weight()))
->setUser(api_get_user_entity($this->get_user_id()))
->setRefId($this->get_ref_id())
->setCategoryId($this->get_category_id())
->setCategory($category)
->setCourse(api_get_course_entity())
->setCategoryId($this->get_category_id());
;
$em->persist($link);
$em->flush();
@ -428,14 +434,21 @@ abstract class AbstractLink implements GradebookItem
self::add_link_log($this->id);
$this->save_linked_data();
$course = api_get_course_entity($this->getCourseId());
$category = null;
if (!empty($this->get_category_id())) {
$category = $em->getRepository(GradebookCategory::class)->find($this->get_category_id());
}
$link
->setType($this->get_type())
->setRefId($this->get_ref_id())
->setUser(api_get_user_entity($this->get_user_id()))
->setCourse($course)
->setCategoryId($this->get_category_id())
->setCategory($category)
->setWeight($this->get_weight())
->setVisible($this->is_visible());
->setVisible($this->is_visible())
;
$em->persist($link);
$em->flush();

@ -552,7 +552,11 @@ class Category implements GradebookItem
$category->set_parent_id($gradebookCategory->getParent()->getId());
$category->set_weight($gradebookCategory->getWeight());
$category->set_visible($gradebookCategory->getVisible());
$category->set_session_id($gradebookCategory->getSessionId());
if ($gradebookCategory->getSession()) {
$category->set_session_id($gradebookCategory->getSession()->getId());
}
$category->set_certificate_min_score($gradebookCategory->getCertifMinScore());
$category->set_grade_model_id($gradebookCategory->getGradeModelId());
$category->set_locked($gradebookCategory->getLocked());
@ -590,7 +594,7 @@ class Category implements GradebookItem
$category->setWeight($this->weight);
$category->setVisible($this->visible);
$category->setCertifMinScore($this->certificate_min_score);
$category->setSessionId($this->session_id);
$category->setSession(api_get_session_entity($this->session_id));
$category->setGenerateCertificates($this->generateCertificates);
$category->setGradeModelId($this->grade_model_id);
$category->setIsRequirement($this->isRequirement);

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\GradebookEvaluation;
use ChamiloSession as Session;
@ -319,12 +320,17 @@ class Evaluation implements GradebookItem
}
$em = Database::getManager();
$category = null;
if (!empty($this->get_category_id())) {
$category = $em->getRepository(GradebookCategory::class)->find($this->get_category_id());
}
$evaluation = new GradebookEvaluation();
$evaluation
->setDescription($this->description)
->setCourse(api_get_course_entity())
->setName($this->get_name())
->setCategoryId($this->get_category_id())
->setCategory($category)
->setUser(api_get_user_entity($this->get_user_id()))
->setWeight(api_float_val($this->get_weight()))
->setMax($this->get_max())

@ -30,6 +30,8 @@ class AdminController extends BaseController
if ($this->isGranted('ROLE_ADMIN')) {
return $this->loadAdminMenu();
}
throw $this->createAccessDeniedException();
}
/**
@ -55,7 +57,7 @@ class AdminController extends BaseController
/**
* Move in template.lib.
*/
private function loadAdminMenu()
private function loadAdminMenu(): Response
{
// Access restrictions.
api_protect_admin_script(true);

@ -122,6 +122,7 @@ class SettingsController extends BaseController
$searchForm = $this->getSearchForm();
$keyword = '';
$settingsFromKeyword = null;
$searchForm->handleRequest($request);
if ($searchForm->isSubmitted() && $searchForm->isValid()) {
$values = $searchForm->getData();
@ -164,7 +165,8 @@ class SettingsController extends BaseController
$manager->save($form->getData());
$message = $this->trans('Settings have been successfully updated');
} catch (ValidatorException $exception) {
$message = $this->trans($exception->getMessage(), [], 'validators');
//$message = $this->trans($exception->getMessage(), [], 'validators');
$message = $this->trans($exception->getMessage());
$messageType = 'error';
}

@ -8,6 +8,7 @@ use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Entity\ExtraFieldRelTag;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\ExtraFieldRelTagRepository;
use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
use Chamilo\CourseBundle\Entity\CCourseDescription;
use Doctrine\ORM\EntityRepository;
@ -59,10 +60,10 @@ class CourseController extends AbstractController
/** @var EntityRepository $fieldsRepo */
$fieldsRepo = $em->getRepository(ExtraField::class);
/** @var EntityRepository $fieldTagsRepo */
/** @var ExtraFieldRelTagRepository $fieldTagsRepo */
$fieldTagsRepo = $em->getRepository(ExtraFieldRelTag::class);
/** @var CCourseDescription $courseDescription */
/** @var CCourseDescription[] $courseDescriptionTools */
$courseDescriptionTools = $em->getRepository(CCourseDescription::class)
->findBy(
[
@ -92,19 +93,19 @@ class CourseController extends AbstractController
$teachersData[] = $userData;
}
/** @var ExtraField $tagField */
$tagField = $fieldsRepo->findOneBy([
'extraFieldType' => ExtraField::COURSE_FIELD_TYPE,
'variable' => 'tags',
]);
$courseTags = [];
if (null !== $tagField) {
$courseTags = $fieldTagsRepo->getTags($tagField, $courseId);
}
$courseDescription = $courseObjectives = $courseTopics = $courseMethodology = $courseMaterial = $courseResources = $courseAssessment = '';
$courseDescription = $courseObjectives = $courseTopics = $courseMethodology = '';
$courseMaterial = $courseResources = $courseAssessment = '';
$courseCustom = [];
foreach ($courseDescriptionTools as $descriptionTool) {
switch ($descriptionTool->getDescriptionType()) {

@ -263,17 +263,10 @@ class CourseHomeController extends ToolBaseController
$manager->save($form->getData());
$message = $this->trans('Update');
} catch (ValidatorException $exception) {
$message = $this->trans(
$exception->getMessage(),
[],
'validators'
);
$message = $this->trans($exception->getMessage());
$messageType = 'error';
}
$request->getSession()->getBag('flashes')->add(
$messageType,
$message
);
$this->addFlash($messageType, $message);
if ($request->headers->has('referer')) {
return $this->redirect($request->headers->get('referer'));

@ -417,4 +417,16 @@ class GradebookEvaluation
return $this;
}
public function getCategory(): GradebookCategory
{
return $this->category;
}
public function setCategory(GradebookCategory $category): self
{
$this->category = $category;
return $this;
}
}

@ -122,9 +122,6 @@ class GradebookLink
*/
protected $userScoreList;
/**
* GradebookEvaluation constructor.
*/
public function __construct()
{
$this->locked = 0;
@ -294,10 +291,8 @@ class GradebookLink
/**
* @param float $bestScore
*
* @return GradebookLink
*/
public function setBestScore($bestScore)
public function setBestScore($bestScore): self
{
$this->bestScore = $bestScore;
@ -314,10 +309,8 @@ class GradebookLink
/**
* @param float $averageScore
*
* @return GradebookLink
*/
public function setAverageScore($averageScore)
public function setAverageScore($averageScore): self
{
$this->averageScore = $averageScore;
@ -338,10 +331,8 @@ class GradebookLink
/**
* @param array $userScoreList
*
* @return GradebookLink
*/
public function setUserScoreList($userScoreList)
public function setUserScoreList($userScoreList): self
{
$this->userScoreList = $userScoreList;
@ -358,13 +349,23 @@ class GradebookLink
/**
* @param float $scoreWeight
*
* @return GradebookLink
*/
public function setScoreWeight($scoreWeight)
public function setScoreWeight($scoreWeight): self
{
$this->scoreWeight = $scoreWeight;
return $this;
}
public function getCategory(): GradebookCategory
{
return $this->category;
}
public function setCategory(GradebookCategory $category): self
{
$this->category = $category;
return $this;
}
}

@ -115,4 +115,16 @@ class GradebookResult
{
return $this->id;
}
public function getEvaluation(): GradebookEvaluation
{
return $this->evaluation;
}
public function setEvaluation(GradebookEvaluation $evaluation): self
{
$this->evaluation = $evaluation;
return $this;
}
}

@ -5,7 +5,6 @@
namespace Chamilo\CoreBundle\Entity\Listener;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\AccessUrlRelCourse;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
use Chamilo\CoreBundle\Settings\SettingsManager;
@ -96,7 +95,7 @@ class CourseListener
{
$limit = $url->getLimitCourses();
if (!empty($limit)) {
/*if (!empty($limit)) {
$count = $repo->getCountCoursesByUrl($url);
if ($count >= $limit) {
api_warn_hosting_contact('hosting_limit_courses', $limit);
@ -116,6 +115,6 @@ class CourseListener
throw new \Exception('PortalActiveCoursesLimitReached');
}
}
}
}*/
}
}

@ -62,12 +62,12 @@ class SessionListener
$limit = $url->getLimitSessions();
if (!empty($limit)) {
$count = $repo->getCountSessionByUrl($url);
/*$count = $repo->getCountSessionByUrl($url);
if ($count >= $limit) {
api_warn_hosting_contact('hosting_limit_sessions', $limit);
throw new \Exception('PortalSessionsLimitReached');
}
}*/
}
}
}

@ -388,7 +388,7 @@ class ResourceNode
$pathForDisplay = substr_replace($pathForDisplay, '', -3);
}
*/
var_dump($this->getTitle(), $path);
//var_dump($this->getTitle(), $path);
$pathForDisplay = preg_replace(
'/-\d+'.self::PATH_SEPARATOR.'/',
'/',

@ -277,7 +277,7 @@ class Session
* @ORM\ManyToOne(targetEntity="SessionCategory", inversedBy="session")
* @ORM\JoinColumn(name="session_category_id", referencedColumnName="id")
*/
protected $category;
protected ?SessionCategory $category;
/**
* @var bool
@ -287,7 +287,7 @@ class Session
protected $sendSubscriptionNotification;
/**
* @var ArrayCollection
* @var ArrayCollection|CStudentPublication[]
*
* @ORM\OneToMany(
* targetEntity="Chamilo\CourseBundle\Entity\CStudentPublication",
@ -298,12 +298,13 @@ class Session
*/
protected $studentPublications;
/**
* Constructor.
*/
public function __construct()
{
$this->items = new ArrayCollection();
$this->courses = new ArrayCollection();
$this->users = new ArrayCollection();
$this->userCourseSubscriptions = new ArrayCollection();
$this->studentPublications = new ArrayCollection();
//$this->items = new ArrayCollection();
$this->urls = new ArrayCollection();
$this->description = '';
@ -319,14 +320,10 @@ class Session
$this->coachAccessEndDate = new \DateTime();
$this->visibility = 1;
$this->courses = new ArrayCollection();
$this->users = new ArrayCollection();
$this->userCourseSubscriptions = new ArrayCollection();
$this->showDescription = false;
$this->category = null;
$this->status = 0;
$this->position = 0;
$this->studentPublications = new ArrayCollection();
}
public function __toString(): string
@ -381,12 +378,7 @@ class Session
return $this->users;
}
/**
* @param $users
*
* @return $this
*/
public function setUsers($users)
public function setUsers($users): self
{
$this->users = new ArrayCollection();
@ -451,9 +443,6 @@ class Session
return $this->courses;
}
/**
* @param $courses
*/
public function setCourses(ArrayCollection $courses)
{
$this->courses = new ArrayCollection();
@ -902,12 +891,7 @@ class Session
return $this->generalCoach;
}
/**
* @param $coach
*
* @return $this
*/
public function setGeneralCoach($coach)
public function setGeneralCoach(User $coach): self
{
$this->generalCoach = $coach;
@ -922,12 +906,7 @@ class Session
return $this->category;
}
/**
* @param $category
*
* @return $this
*/
public function setCategory($category)
public function setCategory($category): self
{
$this->category = $category;
@ -1055,7 +1034,7 @@ class Session
}
/**
* @return SessionRelCourse
* @return SessionRelCourse|null
*/
public function getCourseSubscription(Course $course)
{
@ -1063,10 +1042,7 @@ class Session
Criteria::expr()->eq('course', $course)
);
/** @var SessionRelCourse $sessionCourse */
return $this->courses
->matching($criteria)
->current();
return $this->courses->matching($criteria)->current();
}
/**
@ -1268,9 +1244,6 @@ class Session
return $this->urls;
}
/**
* @param $urls
*/
public function setUrls($urls)
{
$this->urls = new ArrayCollection();

@ -146,11 +146,9 @@ class Tool
}
/**
* @param $name
*
* @return ResourceType
*/
public function getResourceTypeByName($name)
public function getResourceTypeByName(string $name)
{
$criteria = Criteria::create()->where(Criteria::expr()->eq('name', $name));

@ -10,6 +10,7 @@ use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use Chamilo\CourseBundle\Entity\CGroupRelTutor;
use Chamilo\CourseBundle\Entity\CGroupRelUser;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@ -369,6 +370,8 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $sessionCourseSubscriptions;
/**
* @var ArrayCollection|SkillRelUser[]
*
* @ORM\OneToMany(
* targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser",
* mappedBy="user",
@ -547,7 +550,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $personalAgendas;
/**
* @var Session[]|ArrayCollection
* @var ArrayCollection|SessionRelUser[]
*
* @ORM\OneToMany(
* targetEntity="Chamilo\CoreBundle\Entity\SessionRelUser",
@ -559,7 +562,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $sessions;
/**
* @var CGroupRelUser[]|ArrayCollection
* @var ArrayCollection|CGroupRelUser[]
*
* @ORM\OneToMany(
* targetEntity="Chamilo\CourseBundle\Entity\CGroupRelUser",
@ -571,7 +574,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $courseGroupsAsMember;
/**
* @var Collection
* @var ArrayCollection|CGroupRelTutor[]
*
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CGroupRelTutor", mappedBy="user", orphanRemoval=true)
*/
@ -592,15 +595,11 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $status;
/**
* @var string
*
* @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false)
*/
protected $officialCode;
protected ?string $officialCode;
/**
* @var string
*
* @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false)
*/
protected ?string $pictureUri;
@ -613,39 +612,29 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $creatorId;
/**
* @var string
*
* @ORM\Column(name="competences", type="text", nullable=true, unique=false)
*/
protected $competences;
protected ?string $competences;
/**
* @var string
*
* @ORM\Column(name="diplomas", type="text", nullable=true, unique=false)
*/
protected $diplomas;
protected ?string $diplomas;
/**
* @var string
*
* @ORM\Column(name="openarea", type="text", nullable=true, unique=false)
*/
protected $openarea;
protected ?string $openarea;
/**
* @var string
*
* @ORM\Column(name="teach", type="text", nullable=true, unique=false)
*/
protected $teach;
protected ?string $teach;
/**
* @var string
*
* @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false)
*/
protected $productions;
protected ?string $productions;
/**
* @var \DateTime
@ -676,11 +665,9 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $openid;
/**
* @var string
*
* @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false)
*/
protected $theme;
protected ?string $theme;
/**
* @var int
@ -704,7 +691,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
protected $updatedAt;
/**
* @var ArrayCollection
* @var ArrayCollection|Message[]
*
* @ORM\OneToMany(
* targetEntity="Chamilo\CoreBundle\Entity\Message",
@ -937,9 +924,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
return $this;
}
/**
* @param $portal
*/
public function setPortal($portal)
{
$this->portals->add($portal);
@ -970,9 +954,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
return $this->isActive();
}
/**
* @param $boolean
*/
public function setEnabled($boolean): self
{
$this->enabled = (bool) $boolean;
@ -1844,9 +1825,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
return $this->locked;
}
/**
* @param $boolean
*/
public function setLocked($boolean): self
{
$this->locked = $boolean;
@ -1870,6 +1848,8 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
return true;
}
return false;
}
/**
@ -2126,7 +2106,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
return $this;
}
public function isUser(UserInterface $user = null)
public function isUser(User $user = null)
{
return null !== $user && $this->getId() === $user->getId();
}

@ -108,9 +108,6 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
return $this->users;
}
/**
* @param $users
*/
public function setUsers($users)
{
$this->users = new ArrayCollection();
@ -239,7 +236,7 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
return $this->authorId;
}
public function setAuthorId(string $authorId): Usergroup
public function setAuthorId(string $authorId): self
{
$this->authorId = $authorId;

@ -15,7 +15,6 @@ use Chamilo\CourseBundle\Controller\CourseControllerInterface;
use Chamilo\CourseBundle\Entity\CGroup;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;

@ -131,6 +131,7 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
{
// this code is only an example; the exact code will depend on
// your own application needs
/** @var User $user */
$user->setPassword($newEncodedPassword);
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();
@ -562,6 +563,7 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
$allowSendMessageToAllUsers = api_get_setting('allow_send_message_to_all_platform_users');
$accessUrlId = api_get_multiple_access_url() ? api_get_current_access_url_id() : 1;
$dql = null;
if ('true' === api_get_setting('allow_social_tool') &&
'true' === api_get_setting('allow_message_tool')
) {
@ -605,8 +607,8 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
U.id != $currentUserId AND
R.url = $accessUrlId";
} else {
$time_limit = api_get_setting('time_limit_whosonline');
$online_time = time() - $time_limit * 60;
$time_limit = (int) api_get_setting('time_limit_whosonline');
$online_time = time() - ($time_limit * 60);
$limit_date = api_get_utc_datetime($online_time);
$dql = "SELECT DISTINCT U
FROM ChamiloCoreBundle:User U
@ -620,7 +622,7 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
$parameters = [];
if (!empty($searchFilter)) {
if (!empty($searchFilter) && !empty($dql)) {
$dql .= ' AND (U.firstname LIKE :search OR U.lastname LIKE :search OR U.email LIKE :search OR U.username LIKE :search)';
$parameters['search'] = "%$searchFilter%";
}
@ -952,7 +954,7 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
foreach ($trackResults['ChamiloCoreBundle:GradebookResult'] as $item) {
$date = $item->getCreatedAt() ? $item->getCreatedAt()->format($dateFormat) : '';
$list = [
'Evaluation id# '.$item->getEvaluationId(),
'Evaluation id# '.$item->getEvaluation()->getId(),
//'Score: '.$item->getScore(),
'Creation date: '.$date,
];
@ -1470,11 +1472,10 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
$normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext);
$serializer = new Serializer(
[$normalizer],
[new JsonEncoder()],
[AbstractNormalizer::IGNORED_ATTRIBUTES => $ignore]
[new JsonEncoder()]
);
return $serializer->serialize($user, 'json');
return $serializer->serialize($user, 'json', [AbstractNormalizer::IGNORED_ATTRIBUTES => $ignore]);
}
/**

@ -984,4 +984,9 @@ abstract class ResourceRepository extends ServiceEntityRepository
{
throw new \Exception('Implement saveUpload');
}
public function getResourceFormType()
{
throw new \Exception('Implement getResourceFormType');
}
}

@ -22,7 +22,7 @@ class CourseVoter extends Voter
public const EDIT = 'EDIT';
public const DELETE = 'DELETE';
//private $entityManager;
private $entityManager;
//private $courseManager;
private $security;
@ -31,7 +31,7 @@ class CourseVoter extends Voter
// CourseRepository $courseManager,
Security $security
) {
//$this->entityManager = $entityManager;
$this->entityManager = $entityManager;
//$this->courseManager = $courseManager;
$this->security = $security;
}

@ -4,6 +4,7 @@
namespace Chamilo\CoreBundle\Security\Authorization\Voter;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
use Chamilo\CourseBundle\Entity\CGroup;
use Chamilo\CourseBundle\Repository\CGroupRepository;
@ -52,6 +53,7 @@ class GroupVoter extends Voter
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
/** @var User $user */
$user = $token->getUser();
// make sure there is a user object (i.e. that the user is logged in)

@ -25,7 +25,7 @@ class SessionVoter extends Voter
public const EDIT = 'EDIT';
public const DELETE = 'DELETE';
//private $entityManager;
private $entityManager;
//private $courseManager;
private $security;
private $settingsManager;

@ -46,7 +46,7 @@ class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements P
//private $formFactory;
// private $hookFactory;
private $userRepository;
//private $csrfTokenManager;
private $csrfTokenManager;
private $urlGenerator;
public function __construct(
@ -65,7 +65,7 @@ class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements P
//$this->formFactory = $formFactory;
//$this->hookFactory = $hookFactory;
$this->userRepository = $userRepository;
//$this->csrfTokenManager = $csrfTokenManager;
$this->csrfTokenManager = $csrfTokenManager;
//$this->entityManager = $entityManager;
$this->urlGenerator = $urlGenerator;
$this->serializer = $serializer;
@ -202,13 +202,15 @@ class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements P
}
return new RedirectResponse($this->urlGenerator->generate('home'));*/
/** @var User $user */
$user = $token->getUser();
$userClone = clone $user;
$userClone->setPassword('');
$data = $this->serializer->serialize($userClone, JsonEncoder::FORMAT);
if ($user) {
$userClone = clone $user;
$userClone->setPassword('');
$data = $this->serializer->serialize($userClone, JsonEncoder::FORMAT);
return new JsonResponse($data, Response::HTTP_OK, [], true);
return new JsonResponse($data, Response::HTTP_OK, [], true);
}
}
public function getLoginUrl(): RedirectResponse

@ -104,11 +104,7 @@ class SettingsManager implements SettingsManagerInterface
{
$this->url = $url;
$schemas = array_keys($this->getSchemas());
/**
* @var string
* @var SchemaInterface $schema
*/
/** @var SchemaInterface $schema */
foreach ($schemas as $schema) {
$settings = $this->load($this->convertServiceToNameSpace($schema));
$this->save($settings);
@ -197,6 +193,7 @@ class SettingsManager implements SettingsManagerInterface
{
$loadFromSession = true;
$session = null;
if ($loadFromSession && $this->request->getCurrentRequest()) {
$session = $this->request->getCurrentRequest()->getSession();
$schemaList = $session->get('schemas');
@ -231,7 +228,7 @@ class SettingsManager implements SettingsManagerInterface
$schemaList[$name] = $settings;
}
$this->schemaList = $schemaList;
if ($loadFromSession && $this->request->getCurrentRequest()) {
if ($session && $loadFromSession && $this->request->getCurrentRequest()) {
$session->set('schemas', $schemaList);
}
}
@ -339,7 +336,7 @@ class SettingsManager implements SettingsManagerInterface
->setAccessUrlLocked(1)
;
/** @var ConstraintViolationListInterface $errors */
// @var ConstraintViolationListInterface $errors
/*$errors = $this->validator->validate($parameter);
if (0 < $errors->count()) {
throw new ValidatorException($errors->get(0)->getMessage());
@ -379,12 +376,11 @@ class SettingsManager implements SettingsManagerInterface
['category' => $this->convertServiceToNameSpace($settings->getSchemaAlias())]
);
$persistedParametersMap = [];
foreach ($persistedParameters as $parameter) {
$persistedParametersMap[$parameter->getTitle()] = $parameter;
}
/** @var SettingsEvent $event */
// @var SettingsEvent $event
/*$event = $this->eventDispatcher->dispatch(
SettingsEvent::PRE_SAVE,
new SettingsEvent($settings, $parameters)
@ -410,7 +406,7 @@ class SettingsManager implements SettingsManagerInterface
->setAccessUrlLocked(1)
;
/** @var ConstraintViolationListInterface $errors */
// @var ConstraintViolationListInterface $errors
/*$errors = $this->validator->validate($parameter);
if (0 < $errors->count()) {
throw new ValidatorException($errors->get(0)->getMessage());

@ -4,20 +4,14 @@
namespace Chamilo\CoreBundle\Settings;
use Doctrine\ORM\NonUniqueResultException;
//use Doctrine\ORM\NonUniqueResultException;
use Sylius\Bundle\SettingsBundle\Resolver\SettingsResolverInterface;
/**
* Class SessionSettingsSchema.
*/
class SettingsResolver implements SettingsResolverInterface
{
public function resolve($schemaAlias, $namespace = null)
{
try {
/*$criteria = [
'category' => $schemaAlias,
];*/
/*try {
$criteria = [];
if (null !== $namespace) {
$criteria['category'] = $namespace;
@ -26,6 +20,6 @@ class SettingsResolver implements SettingsResolverInterface
return $this->settingsRepository->findBy($criteria);
} catch (NonUniqueResultException $e) {
throw new \LogicException(sprintf('Multiple schemas found for "%s". You should probably define a custom settings resolver for this schema.', $schemaAlias));
}
}*/
}
}

Loading…
Cancel
Save