Fix: message group should be usergroup not c_group

pull/4161/head
Angel Fernando Quiroz Campos 3 years ago
parent 5f805a1185
commit d1f8ed028c
  1. 4
      public/main/inc/lib/message.lib.php
  2. 19
      src/CoreBundle/Entity/Message.php
  3. 2
      src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php

@ -282,12 +282,14 @@ class MessageManager
}
$messageId = $editMessageId;
} else {
$group = Container::getUsergroupRepository()->find($group_id);
$message = (new Message())
->setSender($userSender)
->addReceiver($userRecipient)
->setTitle($subject)
->setContent($content)
->setGroup(api_get_group_entity($group_id))
->setGroup($group)
->setParent($parent)
;
$em->persist($message);

@ -12,7 +12,6 @@ use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use Chamilo\CourseBundle\Entity\CGroup;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@ -202,10 +201,10 @@ class Message
protected ?MessageRelUser $firstReceiver;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroup")
* @ORM\JoinColumn(name="group_id", referencedColumnName="iid", nullable=true, onDelete="CASCADE")
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Usergroup")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected ?CGroup $group = null;
protected ?Usergroup $group = null;
/**
* @var Collection|Message[]
@ -518,20 +517,12 @@ class Message
return $this;
}
/**
* @return MessageFeedback[]|Collection
*/
public function getLikes()
{
return $this->likes;
}
public function getGroup(): ?CGroup
public function getGroup(): ?Usergroup
{
return $this->group;
}
public function setGroup(?CGroup $group): self
public function setGroup(?Usergroup $group): self
{
// $this->msgType = self::MESSAGE_TYPE_GROUP;
$this->group = $group;

@ -70,7 +70,7 @@ final class Version20200821224242 extends AbstractMigrationChamilo
$this->addSql('DELETE FROM message WHERE user_receiver_id IS NOT NULL AND user_receiver_id NOT IN (SELECT id FROM user)');
if (!$table->hasForeignKey('FK_B6BD307FFE54D947')) {
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307FFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid) ON DELETE CASCADE');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307FFE54D947 FOREIGN KEY (group_id) REFERENCES usergroup (id) ON DELETE CASCADE;');
}
if (!$table->hasForeignKey('FK_B6BD307F727ACA70')) {

Loading…
Cancel
Save