Merge pull request #5281 from christianbeeznest/GH-5145

User: Remove PersonalAgenda and related tables - refs #5145
pull/5283/head
christianbeeznest 2 years ago committed by GitHub
commit 911b2b1a14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      public/main/inc/ajax/agenda.ajax.php
  2. 30
      public/main/inc/lib/agenda.lib.php
  3. 144
      src/CoreBundle/Entity/PersonalAgenda.php
  4. 132
      src/CoreBundle/Entity/PersonalAgendaRepeat.php
  5. 71
      src/CoreBundle/Entity/PersonalAgendaRepeatNot.php
  6. 20
      src/CoreBundle/Entity/User.php
  7. 39
      src/CoreBundle/Migrations/Schema/V200/Version20240321142500.php
  8. 2
      src/CoreBundle/Repository/Node/UserRepository.php

@ -187,7 +187,7 @@ switch ($action) {
); );
if ('true' === api_get_setting('allow_personal_agenda')) { if ('true' === api_get_setting('allow_personal_agenda')) {
$agendaitems = Agenda::get_personal_agenda_items( /*$agendaitems = Agenda::get_personal_agenda_items(
$user_id, $user_id,
$agendaitems, $agendaitems,
$day, $day,
@ -195,7 +195,7 @@ switch ($action) {
$year, $year,
$week, $week,
"month_view" "month_view"
); );*/
} }
Agenda::display_mymonthcalendar( Agenda::display_mymonthcalendar(
$user_id, $user_id,

@ -3,7 +3,7 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\PersonalAgenda; //use Chamilo\CoreBundle\Entity\PersonalAgenda;
use Chamilo\CoreBundle\Entity\SysCalendar; use Chamilo\CoreBundle\Entity\SysCalendar;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CCalendarEvent; use Chamilo\CourseBundle\Entity\CCalendarEvent;
@ -58,7 +58,7 @@ class Agenda
) { ) {
// Table definitions // Table definitions
$this->tbl_global_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); $this->tbl_global_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
$this->tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA); //$this->tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$this->tbl_course_agenda = Database::get_course_table(TABLE_AGENDA); $this->tbl_course_agenda = Database::get_course_table(TABLE_AGENDA);
$this->table_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT); $this->table_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT);
@ -271,7 +271,7 @@ class Agenda
$em = Database::getManager(); $em = Database::getManager();
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$event = new PersonalAgenda(); /*$event = new PersonalAgenda();
$event $event
->setTitle($title) ->setTitle($title)
->setText($content) ->setText($content)
@ -283,7 +283,7 @@ class Agenda
; ;
$em->persist($event); $em->persist($event);
$em->flush(); $em->flush();
$id = $event->getId(); $id = $event->getId();*/
break; break;
case 'course': case 'course':
$sessionId = $this->getSessionId(); $sessionId = $this->getSessionId();
@ -636,7 +636,7 @@ class Agenda
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$eventInfo = $this->get_event($id); /*$eventInfo = $this->get_event($id);
if ($eventInfo['user'] != api_get_user_id()) { if ($eventInfo['user'] != api_get_user_id()) {
break; break;
} }
@ -659,7 +659,7 @@ class Agenda
$this->tbl_personal_agenda, $this->tbl_personal_agenda,
$attributes, $attributes,
['id = ?' => $id] ['id = ?' => $id]
); );*/
break; break;
case 'course': case 'course':
$repo = Container::getCalendarEventRepository(); $repo = Container::getCalendarEventRepository();
@ -842,13 +842,13 @@ class Agenda
{ {
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$eventInfo = $this->get_event($id); /*$eventInfo = $this->get_event($id);
if ($eventInfo['user'] == api_get_user_id()) { if ($eventInfo['user'] == api_get_user_id()) {
Database::delete( Database::delete(
$this->tbl_personal_agenda, $this->tbl_personal_agenda,
['id = ?' => $id] ['id = ?' => $id]
); );
} }*/
break; break;
case 'course': case 'course':
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
@ -1003,7 +1003,7 @@ class Agenda
if (false == $sessionFilterActive) { if (false == $sessionFilterActive) {
// Getting personal events // Getting personal events
$this->getPersonalEvents($start, $end); //$this->getPersonalEvents($start, $end);
// Getting platform/admin events // Getting platform/admin events
$this->getPlatformEvents($start, $end); $this->getPlatformEvents($start, $end);
@ -1158,10 +1158,10 @@ class Agenda
if (!empty($event)) { if (!empty($event)) {
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$sql = "UPDATE $this->tbl_personal_agenda SET /*$sql = "UPDATE $this->tbl_personal_agenda SET
enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE) enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE)
WHERE id = ".$id; WHERE id = ".$id;
Database::query($sql); Database::query($sql);*/
break; break;
case 'course': case 'course':
$sql = "UPDATE $this->tbl_course_agenda SET $sql = "UPDATE $this->tbl_course_agenda SET
@ -1206,11 +1206,11 @@ class Agenda
if (!empty($event)) { if (!empty($event)) {
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$sql = "UPDATE $this->tbl_personal_agenda SET /*$sql = "UPDATE $this->tbl_personal_agenda SET
all_day = $allDay, date = DATE_ADD(date, INTERVAL $delta MINUTE), all_day = $allDay, date = DATE_ADD(date, INTERVAL $delta MINUTE),
enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE) enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE)
WHERE id=".$id; WHERE id=".$id;
Database::query($sql); Database::query($sql);*/
break; break;
case 'course': case 'course':
$sql = "UPDATE $this->tbl_course_agenda SET $sql = "UPDATE $this->tbl_course_agenda SET
@ -1250,7 +1250,7 @@ class Agenda
$event = null; $event = null;
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$sql = "SELECT * FROM ".$this->tbl_personal_agenda." /*$sql = "SELECT * FROM ".$this->tbl_personal_agenda."
WHERE id = $id AND user = ".api_get_user_id(); WHERE id = $id AND user = ".api_get_user_id();
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
@ -1259,7 +1259,7 @@ class Agenda
$event['content'] = $event['text']; $event['content'] = $event['text'];
$event['start_date'] = $event['date']; $event['start_date'] = $event['date'];
$event['end_date'] = $event['enddate']; $event['end_date'] = $event['enddate'];
} }*/
break; break;
case 'course': case 'course':
$repo = Container::getCalendarEventRepository(); $repo = Container::getCalendarEventRepository();

@ -1,144 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* PersonalAgenda.
*/
#[ORM\Table(name: 'personal_agenda')]
#[ORM\Index(columns: ['user'], name: 'idx_personal_agenda_user')]
#[ORM\Index(columns: ['parent_event_id'], name: 'idx_personal_agenda_parent')]
#[ORM\Entity]
class PersonalAgenda
{
use UserTrait;
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue]
protected ?int $id = null;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'personalAgendas')]
#[ORM\JoinColumn(name: 'user', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected User $user;
#[Assert\NotBlank]
#[ORM\Column(name: 'title', type: 'text', nullable: true)]
protected ?string $title = null;
#[ORM\Column(name: 'text', type: 'text', nullable: true)]
protected ?string $text = null;
#[ORM\Column(name: 'date', type: 'datetime', nullable: true)]
protected ?DateTime $date = null;
#[ORM\Column(name: 'enddate', type: 'datetime', nullable: true)]
protected ?DateTime $endDate = null;
#[ORM\Column(name: 'parent_event_id', type: 'integer', nullable: true)]
protected ?int $parentEventId = null;
#[ORM\Column(name: 'all_day', type: 'integer', nullable: false)]
protected int $allDay;
#[ORM\Column(name: 'color', type: 'string', length: 20, nullable: true)]
protected ?string $color = null;
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getText(): string
{
return $this->text;
}
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
public function getDate(): ?DateTime
{
return $this->date;
}
public function setDate(DateTime $date): self
{
$this->date = $date;
return $this;
}
public function getEndDate(): ?DateTime
{
return $this->endDate;
}
public function setEndDate(DateTime $value): self
{
$this->endDate = $value;
return $this;
}
public function getParentEventId(): ?int
{
return $this->parentEventId;
}
public function setParentEventId(int $parentEventId): self
{
$this->parentEventId = $parentEventId;
return $this;
}
public function getAllDay(): int
{
return $this->allDay;
}
public function setAllDay(int $allDay): self
{
$this->allDay = $allDay;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(string $color): self
{
$this->color = $color;
return $this;
}
}

@ -1,132 +0,0 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* PersonalAgendaRepeat.
*/
#[ORM\Table(name: 'personal_agenda_repeat')]
#[ORM\Entity]
class PersonalAgendaRepeat
{
#[ORM\Column(name: 'cal_id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
protected int $calId;
#[ORM\Column(name: 'cal_type', type: 'string', length: 20, nullable: true)]
protected ?string $calType = null;
#[ORM\Column(name: 'cal_end', type: 'integer', nullable: true)]
protected ?int $calEnd = null;
#[ORM\Column(name: 'cal_frequency', type: 'integer', nullable: true)]
protected ?int $calFrequency = null;
#[ORM\Column(name: 'cal_days', type: 'string', length: 7, nullable: true)]
protected ?string $calDays = null;
/**
* Set calType.
*
* @return PersonalAgendaRepeat
*/
public function setCalType(string $calType)
{
$this->calType = $calType;
return $this;
}
/**
* Get calType.
*
* @return string
*/
public function getCalType()
{
return $this->calType;
}
/**
* Set calEnd.
*
* @return PersonalAgendaRepeat
*/
public function setCalEnd(int $calEnd)
{
$this->calEnd = $calEnd;
return $this;
}
/**
* Get calEnd.
*
* @return int
*/
public function getCalEnd()
{
return $this->calEnd;
}
/**
* Set calFrequency.
*
* @return PersonalAgendaRepeat
*/
public function setCalFrequency(int $calFrequency)
{
$this->calFrequency = $calFrequency;
return $this;
}
/**
* Get calFrequency.
*
* @return int
*/
public function getCalFrequency()
{
return $this->calFrequency;
}
/**
* Set calDays.
*
* @return PersonalAgendaRepeat
*/
public function setCalDays(string $calDays)
{
$this->calDays = $calDays;
return $this;
}
/**
* Get calDays.
*
* @return string
*/
public function getCalDays()
{
return $this->calDays;
}
/**
* Get calId.
*
* @return int
*/
public function getCalId()
{
return $this->calId;
}
}

@ -1,71 +0,0 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* PersonalAgendaRepeatNot.
*/
#[ORM\Table(name: 'personal_agenda_repeat_not')]
#[ORM\Entity]
class PersonalAgendaRepeatNot
{
#[ORM\Column(name: 'cal_id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
protected int $calId;
#[ORM\Column(name: 'cal_date', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
protected int $calDate;
/**
* Set calId.
*
* @return PersonalAgendaRepeatNot
*/
public function setCalId(int $calId)
{
$this->calId = $calId;
return $this;
}
/**
* Get calId.
*
* @return int
*/
public function getCalId()
{
return $this->calId;
}
/**
* Set calDate.
*
* @return PersonalAgendaRepeatNot
*/
public function setCalDate(int $calDate)
{
$this->calDate = $calDate;
return $this;
}
/**
* Get calDate.
*
* @return int
*/
public function getCalDate()
{
return $this->calDate;
}
}

@ -586,17 +586,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
)] )]
protected Collection $userRelTags; protected Collection $userRelTags;
/**
* @var Collection<int, PersonalAgenda>
*/
#[ORM\OneToMany(
mappedBy: 'user',
targetEntity: PersonalAgenda::class,
cascade: ['persist', 'remove'],
orphanRemoval: true
)]
protected Collection $personalAgendas;
/** /**
* @var Collection<int, CGroupRelUser> * @var Collection<int, CGroupRelUser>
*/ */
@ -780,7 +769,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
$this->userCourseCategories = new ArrayCollection(); $this->userCourseCategories = new ArrayCollection();
$this->userRelCourseVotes = new ArrayCollection(); $this->userRelCourseVotes = new ArrayCollection();
$this->userRelTags = new ArrayCollection(); $this->userRelTags = new ArrayCollection();
$this->personalAgendas = new ArrayCollection();
$this->sessionsRelUser = new ArrayCollection(); $this->sessionsRelUser = new ArrayCollection();
$this->sentMessages = new ArrayCollection(); $this->sentMessages = new ArrayCollection();
$this->receivedMessages = new ArrayCollection(); $this->receivedMessages = new ArrayCollection();
@ -2054,14 +2042,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
return $this->userRelTags; return $this->userRelTags;
} }
/**
* @return Collection<int, PersonalAgenda>
*/
public function getPersonalAgendas(): Collection
{
return $this->personalAgendas;
}
public function getCurriculumItems(): Collection public function getCurriculumItems(): Collection
{ {
return $this->curriculumItems; return $this->curriculumItems;

@ -0,0 +1,39 @@
<?php
/* For licensing terms, see /license.txt */
declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20240321142500 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Remove personal agenda related tables';
}
public function up(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS personal_agenda');
$this->addSql('DROP TABLE IF EXISTS personal_agenda_repeat');
$this->addSql('DROP TABLE IF EXISTS personal_agenda_repeat_not');
}
public function down(Schema $schema): void
{
if (!$schema->hasTable('personal_agenda')) {
$this->addSql('CREATE TABLE personal_agenda (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, title TEXT DEFAULT NULL, text TEXT DEFAULT NULL, date DATETIME DEFAULT NULL, enddate DATETIME DEFAULT NULL, parent_event_id INT DEFAULT NULL, all_day INT NOT NULL, color VARCHAR(20) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
if (!$schema->hasTable('personal_agenda_repeat')) {
$this->addSql('CREATE TABLE personal_agenda_repeat (cal_id INT AUTO_INCREMENT NOT NULL, cal_type VARCHAR(20) DEFAULT NULL, cal_end INT DEFAULT NULL, cal_frequency INT DEFAULT NULL, cal_days VARCHAR(7) DEFAULT NULL, PRIMARY KEY(cal_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
if (!$schema->hasTable('personal_agenda_repeat_not')) {
$this->addSql('CREATE TABLE personal_agenda_repeat_not (cal_id INT NOT NULL, cal_date INT NOT NULL, PRIMARY KEY(cal_id, cal_date)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
}
}

@ -246,7 +246,7 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
['bundle' => 'CoreBundle', 'entity' => 'MessageTag', 'field' => 'user', 'type' => 'object', 'action' => 'delete'], ['bundle' => 'CoreBundle', 'entity' => 'MessageTag', 'field' => 'user', 'type' => 'object', 'action' => 'delete'],
['bundle' => 'CoreBundle', 'entity' => 'Notification', 'field' => 'destUserId', 'type' => 'int', 'action' => 'delete'], ['bundle' => 'CoreBundle', 'entity' => 'Notification', 'field' => 'destUserId', 'type' => 'int', 'action' => 'delete'],
['bundle' => 'CoreBundle', 'entity' => 'PageCategory', 'field' => 'creator', 'type' => 'object', 'action' => 'convert'], ['bundle' => 'CoreBundle', 'entity' => 'PageCategory', 'field' => 'creator', 'type' => 'object', 'action' => 'convert'],
['bundle' => 'CoreBundle', 'entity' => 'PersonalAgenda', 'field' => 'user', 'type' => 'object', 'action' => 'delete'], //['bundle' => 'CoreBundle', 'entity' => 'PersonalAgenda', 'field' => 'user', 'type' => 'object', 'action' => 'delete'],
['bundle' => 'CoreBundle', 'entity' => 'Portfolio', 'field' => 'user', 'type' => 'object', 'action' => 'convert'], ['bundle' => 'CoreBundle', 'entity' => 'Portfolio', 'field' => 'user', 'type' => 'object', 'action' => 'convert'],
['bundle' => 'CoreBundle', 'entity' => 'PortfolioCategory', 'field' => 'user', 'type' => 'object', 'action' => 'convert'], ['bundle' => 'CoreBundle', 'entity' => 'PortfolioCategory', 'field' => 'user', 'type' => 'object', 'action' => 'convert'],
['bundle' => 'CoreBundle', 'entity' => 'PortfolioComment', 'field' => 'author', 'type' => 'object', 'action' => 'convert'], ['bundle' => 'CoreBundle', 'entity' => 'PortfolioComment', 'field' => 'author', 'type' => 'object', 'action' => 'convert'],

Loading…
Cancel
Save