Minor: coding standards

pull/4088/head
Angel Fernando Quiroz Campos 4 years ago
parent b26bf9fd25
commit 75495e1454
  1. 133
      main/inc/lib/agenda.lib.php
  2. 23
      src/Chamilo/CoreBundle/Entity/AgendaEventInvitation.php
  3. 22
      src/Chamilo/CoreBundle/Entity/AgendaEventInvitee.php
  4. 2
      src/Chamilo/CoreBundle/Entity/Repository/PersonalAgendaRepository.php
  5. 2
      src/Chamilo/CoreBundle/Traits/EventColletiveTrait.php

@ -715,18 +715,6 @@ class Agenda
return -1;
}
private static function isUserInvitedInEvent(int $id, int $userId): bool
{
$user = api_get_user_entity($userId);
$event = Database::getManager()
->getRepository('ChamiloCoreBundle:PersonalAgenda')
->findOneByIdAndInvitee($id, $user)
;
return null !== $event;
}
/**
* Edits an event.
*
@ -1080,6 +1068,7 @@ class Agenda
/**
* @param int $id
* @param bool $deleteAllItemsFromSerie
*
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
@ -1674,7 +1663,7 @@ class Agenda
$event['invitees'][] = [
'id' => $inviteeUser->getId(),
'name' => $inviteeUser->getCompleteNameWithUsername()
'name' => $inviteeUser->getCompleteNameWithUsername(),
];
}
}
@ -1710,56 +1699,6 @@ class Agenda
return $my_events;
}
private function loadEventsAsInvitee(User $user, ?DateTime $startDate, ?DateTime $endDate)
{
$em = Database::getManager();
$eventRepo = $em->getRepository('ChamiloCoreBundle:PersonalAgenda');
$events = $eventRepo->getEventsForInvitee($user, $startDate, $endDate);
foreach ($events as $event) {
$eventInfo = [];
$eventInfo['id'] = 'personal_'.$event->getId();
$eventInfo['title'] = $event->getTitle();
$eventInfo['className'] = 'personal';
$eventInfo['borderColor'] = $eventInfo['backgroundColor'] = $this->event_personal_color;
$eventInfo['editable'] = $event->isCollective();
$eventInfo['sent_to'] = get_lang('Me');
$eventInfo['type'] = 'personal';
if ($event->getDate()) {
$eventInfo['start'] = $this->formatEventDate($event->getDate()->format('Y-m-d H:i:s'));
$eventInfo['start_date_localtime'] = api_get_local_time($event->getDate());
}
if ($event->getEnddate()) {
$eventInfo['end'] = $this->formatEventDate($event->getEnddate()->format('Y-m-d H:i:s'));
$eventInfo['end_date_localtime'] = api_get_local_time($event->getEnddate());
}
$eventInfo['description'] = $event->getText();
$eventInfo['allDay'] = $event->getAllDay();
$eventInfo['parent_event_id'] = 0;
$eventInfo['has_children'] = 0;
$eventInfo['collective'] = $event->isCollective();
$eventInfo['invitees'] = [];
$invitation = $event->getInvitation();
if ($invitation) {
foreach ($invitation->getInvitees() as $invitee) {
$inviteeUser = $invitee->getUser();
$eventInfo['invitees'][] = [
'id' => $inviteeUser->getId(),
'name' => $inviteeUser->getCompleteNameWithUsername()
];
}
}
$this->events[] = $eventInfo;
}
}
/**
* Get user/group list per event.
*
@ -4371,6 +4310,68 @@ class Agenda
$em->flush();
}
private static function isUserInvitedInEvent(int $id, int $userId): bool
{
$user = api_get_user_entity($userId);
$event = Database::getManager()
->getRepository('ChamiloCoreBundle:PersonalAgenda')
->findOneByIdAndInvitee($id, $user)
;
return null !== $event;
}
private function loadEventsAsInvitee(User $user, ?DateTime $startDate, ?DateTime $endDate)
{
$em = Database::getManager();
$eventRepo = $em->getRepository('ChamiloCoreBundle:PersonalAgenda');
$events = $eventRepo->getEventsForInvitee($user, $startDate, $endDate);
foreach ($events as $event) {
$eventInfo = [];
$eventInfo['id'] = 'personal_'.$event->getId();
$eventInfo['title'] = $event->getTitle();
$eventInfo['className'] = 'personal';
$eventInfo['borderColor'] = $eventInfo['backgroundColor'] = $this->event_personal_color;
$eventInfo['editable'] = $event->isCollective();
$eventInfo['sent_to'] = get_lang('Me');
$eventInfo['type'] = 'personal';
if ($event->getDate()) {
$eventInfo['start'] = $this->formatEventDate($event->getDate()->format('Y-m-d H:i:s'));
$eventInfo['start_date_localtime'] = api_get_local_time($event->getDate());
}
if ($event->getEnddate()) {
$eventInfo['end'] = $this->formatEventDate($event->getEnddate()->format('Y-m-d H:i:s'));
$eventInfo['end_date_localtime'] = api_get_local_time($event->getEnddate());
}
$eventInfo['description'] = $event->getText();
$eventInfo['allDay'] = $event->getAllDay();
$eventInfo['parent_event_id'] = 0;
$eventInfo['has_children'] = 0;
$eventInfo['collective'] = $event->isCollective();
$eventInfo['invitees'] = [];
$invitation = $event->getInvitation();
if ($invitation) {
foreach ($invitation->getInvitees() as $invitee) {
$inviteeUser = $invitee->getUser();
$eventInfo['invitees'][] = [
'id' => $inviteeUser->getId(),
'name' => $inviteeUser->getCompleteNameWithUsername(),
];
}
}
$this->events[] = $eventInfo;
}
}
private function loadSessionsAsEvents(int $start, int $end)
{
if (false === api_get_configuration_value('personal_calendar_show_sessions_occupation')) {
@ -4395,7 +4396,7 @@ class Agenda
$firstAccessDate = new DateTime($courseAccess['login_course_date'], new DateTimeZone('UTC'));
$lastAccessDate = clone $firstAccessDate;
$lastAccessDate->modify('+'.$sessionInfo['duration'].' days');
$lastAccessDate->modify('+' . $sessionInfo['duration'] . ' days');
if ($firstAccessDate->format('Y-m-d H:i:s') > $start
&& $lastAccessDate->format('Y-m-d H:i:s') < $end
@ -4407,7 +4408,7 @@ class Agenda
$firstCourse = current($courseList);
$this->events[] = [
'id' => 'session_'.$sessionInfo['id'],
'id' => 'session_' . $sessionInfo['id'],
'session_id' => $sessionInfo['id'],
'title' => $sessionInfo['name'],
'description' => $sessionInfo['show_description'] ? $sessionInfo['description'] : '',
@ -4440,7 +4441,7 @@ class Agenda
$firstCourse = current($courseList);
$this->events[] = [
'id' => 'session_'.$sessionInfo['id'],
'id' => 'session_' . $sessionInfo['id'],
'session_id' => $sessionInfo['id'],
'title' => $sessionInfo['name'],
'description' => $sessionInfo['show_description'] ? $sessionInfo['description'] : '',

@ -12,7 +12,8 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Add @ to the next lineactivating the agenda_collective_invitations configuration setting.
* ORM\Entity()
* ORM\Entity().
*
* @ORM\Table(name="agenda_event_invitation")
*/
class AgendaEventInvitation
@ -48,29 +49,20 @@ class AgendaEventInvitation
$this->invitees = new ArrayCollection();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Collection
*/
public function getInvitees(): Collection
{
return $this->invitees;
}
/**
* @param Collection $invitees
* @return AgendaEventInvitation
*/
public function setInvitees(Collection $invitees): AgendaEventInvitation
{
$this->invitees = $invitees;
return $this;
}
@ -95,27 +87,20 @@ class AgendaEventInvitation
if ($invitee) {
$this->invitees->removeElement($invitee);
$invitee->setInvitation(null);
}
return $this;
}
/**
* @return User
*/
public function getCreator(): User
{
return $this->creator;
}
/**
* @param User $creator
* @return AgendaEventInvitation
*/
public function setCreator(User $creator): AgendaEventInvitation
{
$this->creator = $creator;
return $this;
}
}

@ -10,7 +10,8 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Add @ to the next lineactivating the agenda_collective_invitations configuration setting.
* ORM\Entity()
* ORM\Entity().
*
* @ORM\Table(name="agenda_event_invitee")
*/
class AgendaEventInvitee
@ -42,47 +43,32 @@ class AgendaEventInvitee
*/
protected $user;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return AgendaEventInvitation|null
*/
public function getInvitation(): ?AgendaEventInvitation
{
return $this->invitation;
}
/**
* @param AgendaEventInvitation|null $invitation
* @return AgendaEventInvitee
*/
public function setInvitation(?AgendaEventInvitation $invitation): AgendaEventInvitee
{
$this->invitation = $invitation;
return $this;
}
/**
* @return User|null
*/
public function getUser(): ?User
{
return $this->user;
}
/**
* @param User|null $user
* @return AgendaEventInvitee
*/
public function setUser(?User $user): AgendaEventInvitee
{
$this->user = $user;
return $this;
}
}

@ -12,7 +12,6 @@ use Doctrine\ORM\NonUniqueResultException;
class PersonalAgendaRepository extends EntityRepository
{
/**
* @param User $user
* @return array<int, PersonalAgenda>
*/
public function getEventsForInvitee(User $user, ?\DateTime $startDate, ?\DateTime $endDate): array
@ -26,7 +25,6 @@ class PersonalAgendaRepository extends EntityRepository
)
;
$params = [
'user' => $user,
];

@ -37,7 +37,6 @@ trait EventColletiveTrait
}
/**
* @param AgendaEventInvitation $invitation
* @return $this
*/
public function setInvitation(AgendaEventInvitation $invitation)
@ -53,7 +52,6 @@ trait EventColletiveTrait
}
/**
* @param bool $collective
* @return $this
*/
public function setCollective(bool $collective)

Loading…
Cancel
Save