commit
						5bd96c08b0
					
				@ -0,0 +1,19 @@ | 
				
			||||
.calendar-event-info { | 
				
			||||
  @apply flex flex-col space-y-4; | 
				
			||||
 | 
				
			||||
  .invitations-info { | 
				
			||||
    @apply space-y-2; | 
				
			||||
 | 
				
			||||
    &__title { | 
				
			||||
      @apply text-gray-50 mb-3; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    &__item { | 
				
			||||
      @apply flex text-body-2 flex-row justify-between; | 
				
			||||
 | 
				
			||||
      p { | 
				
			||||
        @apply first:font-semibold; | 
				
			||||
      } | 
				
			||||
    } | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,32 @@ | 
				
			||||
<script setup> | 
				
			||||
import ShowLinks from "../resource_links/ShowLinks.vue" | 
				
			||||
 | 
				
			||||
defineProps({ | 
				
			||||
  event: { | 
				
			||||
    type: Object, | 
				
			||||
    required: true, | 
				
			||||
  }, | 
				
			||||
}) | 
				
			||||
</script> | 
				
			||||
 | 
				
			||||
<template> | 
				
			||||
  <div class="invitations-info"> | 
				
			||||
    <h6 | 
				
			||||
      v-t="'Invitations'" | 
				
			||||
      class="invitations-info__title" | 
				
			||||
    /> | 
				
			||||
 | 
				
			||||
    <div | 
				
			||||
      v-if="event.resourceLinkListFromEntity.length" | 
				
			||||
      class="invitations-info__item" | 
				
			||||
    > | 
				
			||||
      <p v-t="'Invitees'" /> | 
				
			||||
      <div> | 
				
			||||
        <ShowLinks | 
				
			||||
          :item="event" | 
				
			||||
          :show-status="false" | 
				
			||||
        /> | 
				
			||||
      </div> | 
				
			||||
    </div> | 
				
			||||
  </div> | 
				
			||||
</template> | 
				
			||||
@ -0,0 +1,69 @@ | 
				
			||||
<script setup> | 
				
			||||
import ShowLinks from "../resource_links/ShowLinks.vue" | 
				
			||||
import { subscriptionVisibility } from "../../constants/entity/ccalendarevent" | 
				
			||||
 | 
				
			||||
defineProps({ | 
				
			||||
  event: { | 
				
			||||
    type: Object, | 
				
			||||
    required: true, | 
				
			||||
  }, | 
				
			||||
}) | 
				
			||||
</script> | 
				
			||||
 | 
				
			||||
<template> | 
				
			||||
  <div class="invitations-info"> | 
				
			||||
    <h6 | 
				
			||||
      v-t="'Subscriptions'" | 
				
			||||
      class="invitations-info__title" | 
				
			||||
    /> | 
				
			||||
 | 
				
			||||
    <div class="invitations-info__item"> | 
				
			||||
      <p v-t="'Allow subscriptions'" /> | 
				
			||||
      <p | 
				
			||||
        v-if="subscriptionVisibility.no === event.subscriptionVisibility" | 
				
			||||
        v-text="'No'" | 
				
			||||
      /> | 
				
			||||
      <p | 
				
			||||
        v-else-if="subscriptionVisibility.all === event.subscriptionVisibility" | 
				
			||||
        v-text="'All system users'" | 
				
			||||
      /> | 
				
			||||
      <p | 
				
			||||
        v-else-if="subscriptionVisibility.class === event.subscriptionVisibility" | 
				
			||||
        v-text="'Users inside the class'" | 
				
			||||
      /> | 
				
			||||
      <p | 
				
			||||
        v-if="subscriptionVisibility.class === event.subscriptionVisibility" | 
				
			||||
        v-text="event.subscriptionItemTitle" | 
				
			||||
      /> | 
				
			||||
    </div> | 
				
			||||
 | 
				
			||||
    <div | 
				
			||||
      v-if="event.maxAttendees" | 
				
			||||
      class="invitations-info__item" | 
				
			||||
    > | 
				
			||||
      <p v-t="'Maximum number of subscriptions'" /> | 
				
			||||
      <p v-text="event.maxAttendees" /> | 
				
			||||
    </div> | 
				
			||||
 | 
				
			||||
    <div | 
				
			||||
      v-if="event.maxAttendees" | 
				
			||||
      class="invitations-info__item" | 
				
			||||
    > | 
				
			||||
      <p v-t="'Subscriptions count'" /> | 
				
			||||
      <p v-text="event.resourceLinkListFromEntity.length" /> | 
				
			||||
    </div> | 
				
			||||
 | 
				
			||||
    <div | 
				
			||||
      v-if="event.resourceLinkListFromEntity.length" | 
				
			||||
      class="invitations-info__item" | 
				
			||||
    > | 
				
			||||
      <p v-t="'Subscribers'" /> | 
				
			||||
      <div> | 
				
			||||
        <ShowLinks | 
				
			||||
          :item="event" | 
				
			||||
          :show-status="false" | 
				
			||||
        /> | 
				
			||||
      </div> | 
				
			||||
    </div> | 
				
			||||
  </div> | 
				
			||||
</template> | 
				
			||||
@ -0,0 +1,5 @@ | 
				
			||||
import { post } from "./baseService" | 
				
			||||
 | 
				
			||||
export default { | 
				
			||||
  post, | 
				
			||||
} | 
				
			||||
@ -1,137 +0,0 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
declare(strict_types=1); | 
				
			||||
 | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\CoreBundle\Entity; | 
				
			||||
 | 
				
			||||
use Chamilo\CoreBundle\Traits\TimestampableTypedEntity; | 
				
			||||
use Doctrine\Common\Collections\ArrayCollection; | 
				
			||||
use Doctrine\Common\Collections\Collection; | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
 | 
				
			||||
#[ORM\Table(name: 'agenda_event_invitation')] | 
				
			||||
#[ORM\Entity()] | 
				
			||||
#[ORM\InheritanceType('SINGLE_TABLE')] | 
				
			||||
#[ORM\DiscriminatorColumn(name: 'type', type: 'string')] | 
				
			||||
#[ORM\DiscriminatorMap([ | 
				
			||||
    'invitation' => 'Chamilo\CoreBundle\Entity\AgendaEventInvitation', | 
				
			||||
    'subscription' => 'Chamilo\CoreBundle\Entity\AgendaEventSubscription', | 
				
			||||
])] | 
				
			||||
class AgendaEventInvitation | 
				
			||||
{ | 
				
			||||
    use TimestampableTypedEntity; | 
				
			||||
 | 
				
			||||
    #[ORM\Id] | 
				
			||||
    #[ORM\Column(type: 'integer')] | 
				
			||||
    #[ORM\GeneratedValue(strategy: 'AUTO')] | 
				
			||||
    protected ?int $id = null; | 
				
			||||
 | 
				
			||||
    #[ORM\OneToMany( | 
				
			||||
        mappedBy: 'invitation', | 
				
			||||
        targetEntity: AgendaEventInvitee::class, | 
				
			||||
        cascade: ['persist', 'remove'], | 
				
			||||
        orphanRemoval: true | 
				
			||||
    )] | 
				
			||||
    protected Collection $invitees; | 
				
			||||
 | 
				
			||||
    #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'resourceNodes')] | 
				
			||||
    #[ORM\JoinColumn(name: 'creator_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] | 
				
			||||
    protected User $creator; | 
				
			||||
 | 
				
			||||
    public function __construct() | 
				
			||||
    { | 
				
			||||
        $this->invitees = new ArrayCollection(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function getId(): ?int | 
				
			||||
    { | 
				
			||||
        return $this->id; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function getInvitees(): Collection | 
				
			||||
    { | 
				
			||||
        return $this->invitees; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function setInvitees(Collection $invitees): self | 
				
			||||
    { | 
				
			||||
        $this->invitees = $invitees; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function addInvitee(AgendaEventInvitee $invitee): self | 
				
			||||
    { | 
				
			||||
        $invitee->setInvitation($this); | 
				
			||||
        $this->invitees->add($invitee); | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function removeInviteeUser(User $user): self | 
				
			||||
    { | 
				
			||||
        /** @var AgendaEventInvitee $invitee */ | 
				
			||||
        $invitee = $this | 
				
			||||
            ->invitees | 
				
			||||
            ->filter(function (AgendaEventInvitee $invitee) use ($user) { | 
				
			||||
                return $invitee->getUser() === $user; | 
				
			||||
            }) | 
				
			||||
            ->first() | 
				
			||||
        ; | 
				
			||||
 | 
				
			||||
        if ($invitee) { | 
				
			||||
            $this->invitees->removeElement($invitee); | 
				
			||||
            $invitee->setInvitation(null); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function removeInvitees(): self | 
				
			||||
    { | 
				
			||||
        $this->invitees = new ArrayCollection(); | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function getCreator(): User | 
				
			||||
    { | 
				
			||||
        return $this->creator; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function setCreator(User $creator): self | 
				
			||||
    { | 
				
			||||
        $this->creator = $creator; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function hasUserAsInvitee(User $user): bool | 
				
			||||
    { | 
				
			||||
        return $this->invitees->exists( | 
				
			||||
            function (int $key, AgendaEventInvitee $invitee) use ($user) { | 
				
			||||
                return $invitee->getUser() === $user; | 
				
			||||
            } | 
				
			||||
        ); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function removeInviteesNotInIdList(array $idList): self | 
				
			||||
    { | 
				
			||||
        $toRemove = []; | 
				
			||||
 | 
				
			||||
        /** @var AgendaEventInvitee $invitee */ | 
				
			||||
        foreach ($this->invitees as $key => $invitee) { | 
				
			||||
            if (!\in_array($invitee->getUser()->getId(), $idList, true)) { | 
				
			||||
                $toRemove[] = $key; | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        foreach ($toRemove as $key) { | 
				
			||||
            $this->invitees->remove($key); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,65 +0,0 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
declare(strict_types=1); | 
				
			||||
 | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\CoreBundle\Entity; | 
				
			||||
 | 
				
			||||
use Chamilo\CoreBundle\Traits\TimestampableTypedEntity; | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
 | 
				
			||||
#[ORM\Entity] | 
				
			||||
#[ORM\Table(name: 'agenda_event_invitee')] | 
				
			||||
#[ORM\InheritanceType('SINGLE_TABLE')] | 
				
			||||
#[ORM\DiscriminatorColumn(name: 'type', type: 'string')] | 
				
			||||
#[ORM\DiscriminatorMap([ | 
				
			||||
    'invitee' => AgendaEventInvitee::class, | 
				
			||||
    'subscriber' => AgendaEventSubscriber::class, | 
				
			||||
])] | 
				
			||||
class AgendaEventInvitee | 
				
			||||
{ | 
				
			||||
    use TimestampableTypedEntity; | 
				
			||||
 | 
				
			||||
    #[ORM\Id] | 
				
			||||
    #[ORM\Column(type: 'integer')] | 
				
			||||
    #[ORM\GeneratedValue] | 
				
			||||
    private int $id; | 
				
			||||
 | 
				
			||||
    #[ORM\ManyToOne(targetEntity: AgendaEventInvitation::class, inversedBy: 'invitees')] | 
				
			||||
    #[ORM\JoinColumn(name: 'invitation_id', referencedColumnName: 'id', onDelete: 'CASCADE')] | 
				
			||||
    private ?AgendaEventInvitation $invitation; | 
				
			||||
 | 
				
			||||
    #[ORM\ManyToOne(targetEntity: User::class)] | 
				
			||||
    #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')] | 
				
			||||
    private ?User $user; | 
				
			||||
 | 
				
			||||
    public function getId(): int | 
				
			||||
    { | 
				
			||||
        return $this->id; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function getInvitation(): ?AgendaEventInvitation | 
				
			||||
    { | 
				
			||||
        return $this->invitation; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function setInvitation(?AgendaEventInvitation $invitation): self | 
				
			||||
    { | 
				
			||||
        $this->invitation = $invitation; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function getUser(): ?User | 
				
			||||
    { | 
				
			||||
        return $this->user; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function setUser(?User $user): self | 
				
			||||
    { | 
				
			||||
        $this->user = $user; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,12 +0,0 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
declare(strict_types=1); | 
				
			||||
 | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\CoreBundle\Entity; | 
				
			||||
 | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
 | 
				
			||||
#[ORM\Entity] | 
				
			||||
class AgendaEventSubscriber extends AgendaEventInvitee {} | 
				
			||||
@ -1,32 +0,0 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
declare(strict_types=1); | 
				
			||||
 | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\CoreBundle\Entity; | 
				
			||||
 | 
				
			||||
use Doctrine\ORM\Mapping as ORM; | 
				
			||||
 | 
				
			||||
#[ORM\Entity] | 
				
			||||
class AgendaEventSubscription extends AgendaEventInvitation | 
				
			||||
{ | 
				
			||||
    public const SUBSCRIPTION_NO = 0; | 
				
			||||
    public const SUBSCRIPTION_ALL = 1; | 
				
			||||
    public const SUBSCRIPTION_CLASS = 2; | 
				
			||||
 | 
				
			||||
    #[ORM\Column(name: 'max_attendees', type: 'integer', nullable: false, options: ['default' => 0])] | 
				
			||||
    protected int $maxAttendees = 0; | 
				
			||||
 | 
				
			||||
    public function getMaxAttendees(): int | 
				
			||||
    { | 
				
			||||
        return $this->maxAttendees; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function setMaxAttendees(int $maxAttendees): self | 
				
			||||
    { | 
				
			||||
        $this->maxAttendees = $maxAttendees; | 
				
			||||
 | 
				
			||||
        return $this; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,34 @@ | 
				
			||||
<?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 Version20230904173401 extends AbstractMigrationChamilo | 
				
			||||
{ | 
				
			||||
    public function getDescription(): string | 
				
			||||
    { | 
				
			||||
        return 'Calendar: Cleanup about invitations/subscriptions'; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function up(Schema $schema): void | 
				
			||||
    { | 
				
			||||
        if ($schema->hasTable('agenda_event_invitation')) { | 
				
			||||
            $this->addSql('ALTER TABLE personal_agenda DROP FOREIGN KEY FK_D8612460AF68C6B'); | 
				
			||||
            $this->addSql('DROP INDEX UNIQ_D8612460AF68C6B ON personal_agenda'); | 
				
			||||
 | 
				
			||||
            $this->addSql('ALTER TABLE personal_agenda DROP agenda_event_invitation_id, DROP collective, DROP subscription_visibility, DROP subscription_item_id'); | 
				
			||||
 | 
				
			||||
            $this->addSql('ALTER TABLE agenda_event_invitation DROP FOREIGN KEY FK_52A2D5E161220EA6'); | 
				
			||||
            $this->addSql('DROP TABLE agenda_event_invitation'); | 
				
			||||
 | 
				
			||||
            $this->addSql('ALTER TABLE agenda_event_invitee DROP FOREIGN KEY FK_4F5757FEA76ED395'); | 
				
			||||
            $this->addSql('DROP TABLE agenda_event_invitee'); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,40 @@ | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
declare(strict_types=1); | 
				
			||||
 | 
				
			||||
namespace Chamilo\CoreBundle\Repository; | 
				
			||||
 | 
				
			||||
use Chamilo\CoreBundle\Entity\ColorTheme; | 
				
			||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | 
				
			||||
use Doctrine\Persistence\ManagerRegistry; | 
				
			||||
 | 
				
			||||
class ColorThemeRepository extends ServiceEntityRepository | 
				
			||||
{ | 
				
			||||
    public function __construct(ManagerRegistry $registry) | 
				
			||||
    { | 
				
			||||
        parent::__construct($registry, ColorTheme::class); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function deactivateAll(): void | 
				
			||||
    { | 
				
			||||
        $qb = $this->getEntityManager()->createQueryBuilder(); | 
				
			||||
        $qb | 
				
			||||
            ->update(ColorTheme::class, 'ct') | 
				
			||||
            ->set('ct.active', ':inactive') | 
				
			||||
            ->where( | 
				
			||||
                $qb->expr()->eq('ct.active', ':active') | 
				
			||||
            ) | 
				
			||||
            ->setParameters(['active' => true, 'inactive' => false]) | 
				
			||||
            ->getQuery() | 
				
			||||
            ->execute() | 
				
			||||
        ; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function getActiveOne(): ?ColorTheme | 
				
			||||
    { | 
				
			||||
        return $this->findOneBy( | 
				
			||||
            ['active' => true], | 
				
			||||
            ['createdAt' => 'DESC'] | 
				
			||||
        ); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,18 +1,6 @@ | 
				
			||||
{% extends "@ChamiloCore/Layout/base-layout.html.twig" %} | 
				
			||||
{% block chamilo_wrap %} | 
				
			||||
    {%- autoescape %} | 
				
			||||
        {% if not from_vue %} | 
				
			||||
            <div id="app" data-flashes="{{ app.flashes()|json_encode }}"></div> | 
				
			||||
        {% endif %} | 
				
			||||
    {% endautoescape -%} | 
				
			||||
    {% autoescape false %} | 
				
			||||
        <section id="sectionMainContent" class="section-content"> | 
				
			||||
            {%- block content %} | 
				
			||||
                {% include '@ChamiloCore/Layout/vue_setup.html.twig' %} | 
				
			||||
            {% endblock -%} | 
				
			||||
        </section> | 
				
			||||
    {% endautoescape %} | 
				
			||||
{% endblock %} | 
				
			||||
{% extends "@ChamiloCore/Layout/no_layout.html.twig" %} | 
				
			||||
 | 
				
			||||
{% block chamilo_footer %} | 
				
			||||
{%- block content %} | 
				
			||||
    {% include '@ChamiloCore/Layout/vue_setup.html.twig' %} | 
				
			||||
    {#    {{ encore_entry_script_tags('vue') }}#} | 
				
			||||
{% endblock %} | 
				
			||||
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue