Merge pull request #5330 from christianbeeznest/GH-5315-2

Internal: Add Career and Promotion Fields to Calendar Events - refs #5315
pull/5332/head
christianbeeznest 1 year ago committed by GitHub
commit abcd690d8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      src/CoreBundle/Migrations/Schema/V200/Version20201215072917.php
  2. 36
      src/CourseBundle/Entity/CCalendarEvent.php

@ -35,10 +35,14 @@ class Version20201215072917 extends AbstractMigrationChamilo
// Update c_calendar_event table
if (!$schema->getTable('c_calendar_event')->hasColumn('career_id')) {
$this->addSql('ALTER TABLE c_calendar_event ADD career_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_calendar_event ADD CONSTRAINT FK_C_CALENDAR_EVENT_CAREER FOREIGN KEY (career_id) REFERENCES career (id)');
$this->addSql('CREATE INDEX IDX_C_CALENDAR_EVENT_CAREER ON c_calendar_event (career_id)');
}
if (!$schema->getTable('c_calendar_event')->hasColumn('promotion_id')) {
$this->addSql('ALTER TABLE c_calendar_event ADD promotion_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_calendar_event ADD CONSTRAINT FK_C_CALENDAR_EVENT_PROMOTION FOREIGN KEY (promotion_id) REFERENCES promotion (id)');
$this->addSql('CREATE INDEX IDX_C_CALENDAR_EVENT_PROMOTION ON c_calendar_event (promotion_id)');
}
}
@ -64,10 +68,14 @@ class Version20201215072917 extends AbstractMigrationChamilo
$this->addSql("DELETE FROM settings_current WHERE variable = 'allow_careers_in_global_agenda'");
if ($schema->getTable('c_calendar_event')->hasColumn('career_id')) {
$this->addSql('ALTER TABLE c_calendar_event DROP FOREIGN KEY FK_C_CALENDAR_EVENT_CAREER');
$this->addSql('DROP INDEX IDX_C_CALENDAR_EVENT_CAREER ON c_calendar_event');
$this->addSql('ALTER TABLE c_calendar_event DROP COLUMN career_id');
}
if ($schema->getTable('c_calendar_event')->hasColumn('promotion_id')) {
$this->addSql('ALTER TABLE c_calendar_event DROP FOREIGN KEY FK_C_CALENDAR_EVENT_PROMOTION');
$this->addSql('DROP INDEX IDX_C_CALENDAR_EVENT_PROMOTION ON c_calendar_event');
$this->addSql('ALTER TABLE c_calendar_event DROP COLUMN promotion_id');
}
}

@ -19,6 +19,8 @@ use Chamilo\CoreBundle\ApiResource\CalendarEvent;
use Chamilo\CoreBundle\Controller\Api\UpdateCCalendarEventAction;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\AgendaReminder;
use Chamilo\CoreBundle\Entity\Career;
use Chamilo\CoreBundle\Entity\Promotion;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\Room;
use Chamilo\CoreBundle\Filter\CidFilter;
@ -176,20 +178,18 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface, Stri
private Collection $reminders;
/**
* Optional career identifier.
*
* @var int|null
* @var Career|null
*/
#[ORM\Column(name: 'career_id', type: 'integer', nullable: true)]
protected ?int $careerId = null;
#[ORM\ManyToOne(targetEntity: Career::class)]
#[ORM\JoinColumn(name: 'career_id', referencedColumnName: 'id', nullable: true)]
protected ?Career $career = null;
/**
* Optional promotion identifier.
*
* @var int|null
* @var Promotion|null
*/
#[ORM\Column(name: 'promotion_id', type: 'integer', nullable: true)]
protected ?int $promotionId = null;
#[ORM\ManyToOne(targetEntity: Promotion::class)]
#[ORM\JoinColumn(name: 'promotion_id', referencedColumnName: 'id', nullable: true)]
protected ?Promotion $promotion = null;
public function __construct()
{
@ -491,26 +491,26 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface, Stri
return $this;
}
public function getCareerId(): ?int
public function getCareer(): ?Career
{
return $this->careerId;
return $this->career;
}
public function setCareerId(?int $careerId): self
public function setCareer(?Career $career): self
{
$this->careerId = $careerId;
$this->career = $career;
return $this;
}
public function getPromotionId(): ?int
public function getPromotion(): ?Promotion
{
return $this->promotionId;
return $this->promotion;
}
public function setPromotionId(?int $promotionId): self
public function setPromotion(?Promotion $promotion): self
{
$this->promotionId = $promotionId;
$this->promotion = $promotion;
return $this;
}

Loading…
Cancel
Save