Internal: Database: Fix internal methods calls with name vs title - refs #3581 #4706

pull/5081/head
Yannick Warnier 2 years ago
parent fabd809047
commit b89051d8d9
  1. 4
      public/main/inc/ajax/sequence.ajax.php
  2. 6
      public/main/inc/lib/agenda.lib.php
  3. 2
      public/main/inc/lib/banner.lib.php
  4. 2
      public/main/inc/lib/myspace.lib.php
  5. 2
      public/main/session/session_add.php
  6. 2
      public/main/survey/survey.lib.php
  7. 2
      public/plugin/buycourses/src/buy_course_plugin.class.php
  8. 2
      public/plugin/buycourses/src/buycourses.ajax.php
  9. 10
      public/plugin/buycourses/src/service_process.php
  10. 4
      src/CoreBundle/Controller/ResourceController.php
  11. 5
      src/CoreBundle/Entity/Course.php
  12. 12
      src/CoreBundle/Entity/Session.php
  13. 2
      src/CoreBundle/Entity/SkillRelUser.php
  14. 2
      src/CoreBundle/EventListener/CourseListener.php
  15. 2
      src/CoreBundle/Repository/ResourceRepository.php
  16. 2
      tests/CoreBundle/Repository/Node/CourseRepositoryTest.php
  17. 2
      tests/CourseBundle/Repository/CDocumentRepositoryTest.php

@ -344,7 +344,7 @@ switch ($action) {
$item = $sequenceRepository->getItem($id, $type); $item = $sequenceRepository->getItem($id, $type);
$main->setAttribute('graphviz.shape', 'record'); $main->setAttribute('graphviz.shape', 'record');
$main->setAttribute('graphviz.label', $item->getName()); $main->setAttribute('graphviz.label', $item->getTitle());
foreach ($parents as $parentId) { foreach ($parents as $parentId) {
$item = $sequenceRepository->getItem($parentId, $type); $item = $sequenceRepository->getItem($parentId, $type);
@ -359,7 +359,7 @@ switch ($action) {
} }
$parent->setAttribute('graphviz.shape', 'record'); $parent->setAttribute('graphviz.shape', 'record');
$parent->setAttribute('graphviz.label', $item->getName()); $parent->setAttribute('graphviz.label', $item->getTitle());
} }
foreach ($parents as $parentId) { foreach ($parents as $parentId) {

@ -1737,13 +1737,13 @@ class Agenda
$sentTo[] = $link->getUser()->getFirstname(); $sentTo[] = $link->getUser()->getFirstname();
} }
if ($link->getCourse()) { if ($link->getCourse()) {
$sentTo[] = $link->getCourse()->getName(); $sentTo[] = $link->getCourse()->getTitle();
} }
if ($link->getSession()) { if ($link->getSession()) {
$sentTo[] = $link->getSession()->getName(); $sentTo[] = $link->getSession()->getTitle();
} }
if ($link->getGroup()) { if ($link->getGroup()) {
$sentTo[] = $link->getGroup()->getName(); $sentTo[] = $link->getGroup()->getTitle();
} }
} }

@ -350,7 +350,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
$sessionName = ''; $sessionName = '';
if (!empty($sessionId)) { if (!empty($sessionId)) {
$session = api_get_session_entity($sessionId); $session = api_get_session_entity($sessionId);
$sessionName = $session ? ' ('.cut($session->getName(), MAX_LENGTH_BREADCRUMB).')' : ''; $sessionName = $session ? ' ('.cut($session->getTitle(), MAX_LENGTH_BREADCRUMB).')' : '';
} }
$courseInfo['name'] = api_htmlentities($courseInfo['name']); $courseInfo['name'] = api_htmlentities($courseInfo['name']);

@ -3105,7 +3105,7 @@ class MySpace
if (!empty($sessionId)) { if (!empty($sessionId)) {
$session = api_get_session_entity($sessionId); $session = api_get_session_entity($sessionId);
if ($session) { if ($session) {
$sessionList[$session->getId()] = $session->getName(); $sessionList[$session->getId()] = $session->getTitle();
} }
} }

@ -241,7 +241,7 @@ if (!$formSent) {
}, },
$session->getGeneralCoaches()->getValues() $session->getGeneralCoaches()->getValues()
), ),
'session_template' => $session->getName(), 'session_template' => $session->getTitle(),
]; ];
} else { } else {
$formDefaults['access_start_date'] = $formDefaults['display_start_date'] = api_get_local_time(); $formDefaults['access_start_date'] = $formDefaults['display_start_date'] = api_get_local_time();

@ -2306,7 +2306,7 @@ class SurveyManager
$title = Display::url($title, $url); $title = Display::url($title, $url);
$courseTitle = $course->getTitle(); $courseTitle = $course->getTitle();
if (!empty($sessionId)) { if (!empty($sessionId)) {
$courseTitle .= ' ('.$invitation->getSession()->getName().')'; $courseTitle .= ' ('.$invitation->getSession()->getTitle().')';
} }
$surveyData = self::get_survey($survey->getIid(), 0, $courseCode); $surveyData = self::get_survey($survey->getIid(), 0, $courseCode);

@ -1674,7 +1674,7 @@ class BuyCoursesPlugin extends Plugin
$sessionItem = [ $sessionItem = [
'item_id' => null, 'item_id' => null,
'session_id' => $session->getId(), 'session_id' => $session->getId(),
'session_name' => $session->getName(), 'session_name' => $session->getTitle(),
'session_visibility' => $session->getVisibility(), 'session_visibility' => $session->getVisibility(),
'session_display_start_date' => null, 'session_display_start_date' => null,
'session_display_end_date' => null, 'session_display_end_date' => null,

@ -471,7 +471,7 @@ switch ($action) {
if (BuyCoursesPlugin::SERVICE_TYPE_SESSION == $nodeType) { if (BuyCoursesPlugin::SERVICE_TYPE_SESSION == $nodeType) {
$nodeType = get_lang('Session'); $nodeType = get_lang('Session');
$session = api_get_session_entity($serviceSale['node_id']); $session = api_get_session_entity($serviceSale['node_id']);
$nodeName = $session ? $session->getName() : null; $nodeName = $session ? $session->getTitle() : null;
} else { } else {
if (BuyCoursesPlugin::SERVICE_TYPE_LP_FINAL_ITEM == $nodeType) { if (BuyCoursesPlugin::SERVICE_TYPE_LP_FINAL_ITEM == $nodeType) {
$nodeType = get_lang('TemplateTitleCertificate'); $nodeType = get_lang('TemplateTitleCertificate');

@ -124,13 +124,13 @@ if ($typeUser) {
$userSubscriptions = $user->getSessionRelCourseRelUsers(); $userSubscriptions = $user->getSessionRelCourseRelUsers();
foreach ($userSubscriptions as $userSubscription) { foreach ($userSubscriptions as $userSubscription) {
$sessions[$userSubscription->getSession()->getId()] = $userSubscription->getSession()->getName(); $sessions[$userSubscription->getSession()->getId()] = $userSubscription->getSession()->getTitle();
} }
$sessionsAsGeneralCoach = $user->getSessionsAsGeneralCoach(); $sessionsAsGeneralCoach = $user->getSessionsAsGeneralCoach();
/** @var Session $sessionAsGeneralCoach */ /** @var Session $sessionAsGeneralCoach */
foreach ($sessionsAsGeneralCoach as $sessionAsGeneralCoach) { foreach ($sessionsAsGeneralCoach as $sessionAsGeneralCoach) {
$sessions[$sessionAsGeneralCoach->getId()] = $sessionAsGeneralCoach->getName(); $sessions[$sessionAsGeneralCoach->getId()] = $sessionAsGeneralCoach->getTitle();
} }
if (!$sessions) { if (!$sessions) {
@ -150,7 +150,7 @@ if ($typeUser) {
// Now get all the courses lp's // Now get all the courses lp's
$thisLpList = $em->getRepository('ChamiloCourseBundle:CLp')->findBy(['cId' => $course->getCourse()->getId()]); $thisLpList = $em->getRepository('ChamiloCourseBundle:CLp')->findBy(['cId' => $course->getCourse()->getId()]);
foreach ($thisLpList as $lp) { foreach ($thisLpList as $lp) {
$courseLpList[$lp->getCId()] = $lp->getName().' ('.$course->getCourse()->getTitle().')'; $courseLpList[$lp->getCId()] = $lp->getTitle().' ('.$course->getCourse()->getTitle().')';
} }
} }
@ -169,7 +169,7 @@ if ($typeUser) {
//Now only we need the final item and return the current LP //Now only we need the final item and return the current LP
if (TOOL_LP_FINAL_ITEM == $item->getItemType()) { if (TOOL_LP_FINAL_ITEM == $item->getItemType()) {
$checker = true; $checker = true;
$sessionLpList[$lp->getCId()] = $lp->getName().' ('.$session->getSession()->getName().')'; $sessionLpList[$lp->getCId()] = $lp->getTitle().' ('.$session->getSession()->getTitle().')';
} }
} }
} }
@ -183,7 +183,7 @@ if ($typeUser) {
//Now only we need the final item and return the current LP //Now only we need the final item and return the current LP
if (TOOL_LP_FINAL_ITEM == $item->getItemType()) { if (TOOL_LP_FINAL_ITEM == $item->getItemType()) {
$checker = true; $checker = true;
$sessionLpList[$lp->getCId()] = $lp->getName().' ('.$session->getSession()->getName().')'; $sessionLpList[$lp->getCId()] = $lp->getTitle().' ('.$session->getSession()->getTitle().')';
} }
} }
} }

@ -85,7 +85,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
foreach ($sessions as $sessionRelCourse) { foreach ($sessions as $sessionRelCourse) {
$session = $sessionRelCourse->getSession(); $session = $sessionRelCourse->getSession();
$labels[] = $course->getTitle().' - '.$session->getName(); $labels[] = $course->getTitle().' - '.$session->getTitle();
$size = $repository->getResourceNodeRepository()->getSize( $size = $repository->getResourceNodeRepository()->getSize(
$resourceNode, $resourceNode,
$repository->getResourceType(), $repository->getResourceType(),
@ -97,7 +97,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
/*$groups = $course->getGroups(); /*$groups = $course->getGroups();
foreach ($groups as $group) { foreach ($groups as $group) {
$labels[] = $course->getTitle().' - '.$group->getName(); $labels[] = $course->getTitle().' - '.$group->getTitle();
$size = $repository->getResourceNodeRepository()->getSize( $size = $repository->getResourceNodeRepository()->getSize(
$resourceNode, $resourceNode,
$repository->getResourceType(), $repository->getResourceType(),

@ -613,11 +613,6 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
return $this; return $this;
} }
public function getName(): string
{
return $this->getTitle();
}
public function getTitleAndCode(): string public function getTitleAndCode(): string
{ {
return $this->getTitle().' ('.$this->getCode().')'; return $this->getTitle().' ('.$this->getCode().')';

@ -346,18 +346,6 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable
]; ];
} }
public function getName(): string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDuration(): ?int public function getDuration(): ?int
{ {
return $this->duration; return $this->duration;

@ -240,7 +240,7 @@ class SkillRelUser
{ {
$source = ''; $source = '';
if (null !== $this->session) { if (null !== $this->session) {
$source .= sprintf('[%s] ', $this->session->getName()); $source .= sprintf('[%s] ', $this->session->getTitle());
} }
if (null !== $this->course) { if (null !== $this->course) {

@ -138,7 +138,7 @@ class CourseListener
if (false === $checker->isGranted(SessionVoter::VIEW, $session)) { if (false === $checker->isGranted(SessionVoter::VIEW, $session)) {
throw new AccessDeniedException($this->translator->trans('You\'re not allowed in this session')); throw new AccessDeniedException($this->translator->trans('You\'re not allowed in this session'));
} }
$sessionHandler->set('session_name', $session->getName()); $sessionHandler->set('session_name', $session->getTitle());
$sessionHandler->set('sid', $session->getId()); $sessionHandler->set('sid', $session->getId());
$sessionHandler->set('session', $session); $sessionHandler->set('session', $session);

@ -771,7 +771,7 @@ abstract class ResourceRepository extends ServiceEntityRepository
return ''; return '';
} }
return '<img title="'.$session->getName().'" src="/img/icons/22/star.png" />'; return '<img title="'.$session->getTitle().'" src="/img/icons/22/star.png" />';
} }
public function isGranted(string $subject, AbstractResource $resource): bool public function isGranted(string $subject, AbstractResource $resource): bool

@ -86,7 +86,7 @@ class CourseRepositoryTest extends AbstractApiTest
$course = $this->getCourse($course->getId()); $course = $this->getCourse($course->getId());
$this->assertSame('test julio', $course->getName()); $this->assertSame('test julio', $course->getTitle());
$this->assertSame('test julio (TESTJULIO)', $course->getTitleAndCode()); $this->assertSame('test julio (TESTJULIO)', $course->getTitleAndCode());
$this->assertSame('TESTJULIO', $course->getCode()); $this->assertSame('TESTJULIO', $course->getCode());
$this->assertSame(1, $course->getCategories()->count()); $this->assertSame(1, $course->getCategories()->count());

@ -858,7 +858,7 @@ class CDocumentRepositoryTest extends AbstractApiTest
$teacher = $this->createUser('teacher'); $teacher = $this->createUser('teacher');
$session = (new Session()) $session = (new Session())
->setName('session 1') ->setTitle('session 1')
->addGeneralCoach($teacher) ->addGeneralCoach($teacher)
->addAccessUrl($this->getAccessUrl()) ->addAccessUrl($this->getAccessUrl())
; ;

Loading…
Cancel
Save