From e19e3aef5743b456d21c068ca2290ba58e67d146 Mon Sep 17 00:00:00 2001 From: christianbeeznst Date: Thu, 21 Mar 2024 14:58:32 -0500 Subject: [PATCH] User: Remove PersonalAgenda and related tables - refs #5145 --- public/main/inc/ajax/agenda.ajax.php | 4 +- public/main/inc/lib/agenda.lib.php | 30 ++-- src/CoreBundle/Entity/PersonalAgenda.php | 144 ------------------ .../Entity/PersonalAgendaRepeat.php | 132 ---------------- .../Entity/PersonalAgendaRepeatNot.php | 71 --------- src/CoreBundle/Entity/User.php | 20 --- .../Schema/V200/Version20240321142500.php | 39 +++++ .../Repository/Node/UserRepository.php | 2 +- 8 files changed, 57 insertions(+), 385 deletions(-) delete mode 100644 src/CoreBundle/Entity/PersonalAgenda.php delete mode 100644 src/CoreBundle/Entity/PersonalAgendaRepeat.php delete mode 100644 src/CoreBundle/Entity/PersonalAgendaRepeatNot.php create mode 100644 src/CoreBundle/Migrations/Schema/V200/Version20240321142500.php diff --git a/public/main/inc/ajax/agenda.ajax.php b/public/main/inc/ajax/agenda.ajax.php index ed4605543c..72ea7f7848 100644 --- a/public/main/inc/ajax/agenda.ajax.php +++ b/public/main/inc/ajax/agenda.ajax.php @@ -187,7 +187,7 @@ switch ($action) { ); if ('true' === api_get_setting('allow_personal_agenda')) { - $agendaitems = Agenda::get_personal_agenda_items( + /*$agendaitems = Agenda::get_personal_agenda_items( $user_id, $agendaitems, $day, @@ -195,7 +195,7 @@ switch ($action) { $year, $week, "month_view" - ); + );*/ } Agenda::display_mymonthcalendar( $user_id, diff --git a/public/main/inc/lib/agenda.lib.php b/public/main/inc/lib/agenda.lib.php index ff4c2d17f9..0144b6f457 100644 --- a/public/main/inc/lib/agenda.lib.php +++ b/public/main/inc/lib/agenda.lib.php @@ -3,7 +3,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\CoreBundle\Entity\PersonalAgenda; +//use Chamilo\CoreBundle\Entity\PersonalAgenda; use Chamilo\CoreBundle\Entity\SysCalendar; use Chamilo\CoreBundle\Framework\Container; use Chamilo\CourseBundle\Entity\CCalendarEvent; @@ -58,7 +58,7 @@ class Agenda ) { // Table definitions $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->table_repeat = Database::get_course_table(TABLE_AGENDA_REPEAT); @@ -271,7 +271,7 @@ class Agenda $em = Database::getManager(); switch ($this->type) { case 'personal': - $event = new PersonalAgenda(); + /*$event = new PersonalAgenda(); $event ->setTitle($title) ->setText($content) @@ -283,7 +283,7 @@ class Agenda ; $em->persist($event); $em->flush(); - $id = $event->getId(); + $id = $event->getId();*/ break; case 'course': $sessionId = $this->getSessionId(); @@ -636,7 +636,7 @@ class Agenda switch ($this->type) { case 'personal': - $eventInfo = $this->get_event($id); + /*$eventInfo = $this->get_event($id); if ($eventInfo['user'] != api_get_user_id()) { break; } @@ -659,7 +659,7 @@ class Agenda $this->tbl_personal_agenda, $attributes, ['id = ?' => $id] - ); + );*/ break; case 'course': $repo = Container::getCalendarEventRepository(); @@ -842,13 +842,13 @@ class Agenda { switch ($this->type) { case 'personal': - $eventInfo = $this->get_event($id); + /*$eventInfo = $this->get_event($id); if ($eventInfo['user'] == api_get_user_id()) { Database::delete( $this->tbl_personal_agenda, ['id = ?' => $id] ); - } + }*/ break; case 'course': $courseId = api_get_course_int_id(); @@ -1003,7 +1003,7 @@ class Agenda if (false == $sessionFilterActive) { // Getting personal events - $this->getPersonalEvents($start, $end); + //$this->getPersonalEvents($start, $end); // Getting platform/admin events $this->getPlatformEvents($start, $end); @@ -1158,10 +1158,10 @@ class Agenda if (!empty($event)) { switch ($this->type) { case 'personal': - $sql = "UPDATE $this->tbl_personal_agenda SET + /*$sql = "UPDATE $this->tbl_personal_agenda SET enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE) WHERE id = ".$id; - Database::query($sql); + Database::query($sql);*/ break; case 'course': $sql = "UPDATE $this->tbl_course_agenda SET @@ -1206,11 +1206,11 @@ class Agenda if (!empty($event)) { switch ($this->type) { 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), enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE) WHERE id=".$id; - Database::query($sql); + Database::query($sql);*/ break; case 'course': $sql = "UPDATE $this->tbl_course_agenda SET @@ -1250,7 +1250,7 @@ class Agenda $event = null; switch ($this->type) { 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(); $result = Database::query($sql); if (Database::num_rows($result)) { @@ -1259,7 +1259,7 @@ class Agenda $event['content'] = $event['text']; $event['start_date'] = $event['date']; $event['end_date'] = $event['enddate']; - } + }*/ break; case 'course': $repo = Container::getCalendarEventRepository(); diff --git a/src/CoreBundle/Entity/PersonalAgenda.php b/src/CoreBundle/Entity/PersonalAgenda.php deleted file mode 100644 index 91bc7038b6..0000000000 --- a/src/CoreBundle/Entity/PersonalAgenda.php +++ /dev/null @@ -1,144 +0,0 @@ -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; - } -} diff --git a/src/CoreBundle/Entity/PersonalAgendaRepeat.php b/src/CoreBundle/Entity/PersonalAgendaRepeat.php deleted file mode 100644 index 4c4a78f5f3..0000000000 --- a/src/CoreBundle/Entity/PersonalAgendaRepeat.php +++ /dev/null @@ -1,132 +0,0 @@ -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; - } -} diff --git a/src/CoreBundle/Entity/PersonalAgendaRepeatNot.php b/src/CoreBundle/Entity/PersonalAgendaRepeatNot.php deleted file mode 100644 index adb1af7e8d..0000000000 --- a/src/CoreBundle/Entity/PersonalAgendaRepeatNot.php +++ /dev/null @@ -1,71 +0,0 @@ -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; - } -} diff --git a/src/CoreBundle/Entity/User.php b/src/CoreBundle/Entity/User.php index c41a6e0714..145be45059 100644 --- a/src/CoreBundle/Entity/User.php +++ b/src/CoreBundle/Entity/User.php @@ -586,17 +586,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso )] protected Collection $userRelTags; - /** - * @var Collection - */ - #[ORM\OneToMany( - mappedBy: 'user', - targetEntity: PersonalAgenda::class, - cascade: ['persist', 'remove'], - orphanRemoval: true - )] - protected Collection $personalAgendas; - /** * @var Collection */ @@ -780,7 +769,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso $this->userCourseCategories = new ArrayCollection(); $this->userRelCourseVotes = new ArrayCollection(); $this->userRelTags = new ArrayCollection(); - $this->personalAgendas = new ArrayCollection(); $this->sessionsRelUser = new ArrayCollection(); $this->sentMessages = new ArrayCollection(); $this->receivedMessages = new ArrayCollection(); @@ -2054,14 +2042,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso return $this->userRelTags; } - /** - * @return Collection - */ - public function getPersonalAgendas(): Collection - { - return $this->personalAgendas; - } - public function getCurriculumItems(): Collection { return $this->curriculumItems; diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20240321142500.php b/src/CoreBundle/Migrations/Schema/V200/Version20240321142500.php new file mode 100644 index 0000000000..3df0d2e431 --- /dev/null +++ b/src/CoreBundle/Migrations/Schema/V200/Version20240321142500.php @@ -0,0 +1,39 @@ +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'); + } + } +} diff --git a/src/CoreBundle/Repository/Node/UserRepository.php b/src/CoreBundle/Repository/Node/UserRepository.php index cebe9ec426..0f875f2466 100644 --- a/src/CoreBundle/Repository/Node/UserRepository.php +++ b/src/CoreBundle/Repository/Node/UserRepository.php @@ -246,7 +246,7 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter ['bundle' => 'CoreBundle', 'entity' => 'MessageTag', 'field' => 'user', 'type' => 'object', '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' => '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' => 'PortfolioCategory', 'field' => 'user', 'type' => 'object', 'action' => 'convert'], ['bundle' => 'CoreBundle', 'entity' => 'PortfolioComment', 'field' => 'author', 'type' => 'object', 'action' => 'convert'],