Agenda - Fix CRUD + update entities, fix repeat events

pull/3844/head
Julio Montoya 5 years ago
parent 539af53a08
commit 1c7bba8b91
  1. 13
      public/main/calendar/agenda.php
  2. 8
      public/main/inc/lib/agenda.lib.php
  3. 51
      src/CoreBundle/Entity/PersonalAgenda.php
  4. 8
      src/CoreBundle/Entity/ResourceFile.php
  5. 12
      src/CoreBundle/Entity/SysCalendar.php
  6. 49
      src/CourseBundle/Entity/CCalendarEvent.php
  7. 6
      src/CourseBundle/Entity/CCalendarEventAttachment.php
  8. 6
      src/CourseBundle/Entity/CCalendarEventRepeat.php
  9. 2
      src/CourseBundle/Entity/CCalendarEventRepeatNot.php

@ -68,7 +68,8 @@ function add_image_form() {
filepaths.appendChild(elem1);
id_elem1 = "filepath_"+counter_image;
id_elem1 = "\'"+id_elem1+"\'";
document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" />&nbsp; <br />'.get_lang('Description').'&nbsp;&nbsp;<input type=\"text\" name=\"legend[]\" /><br /><br />";
document.
getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" />&nbsp; <br />'.get_lang('Description').'&nbsp;&nbsp;<input type=\"text\" name=\"legend[]\" /><br /><br />";
if (filepaths.childNodes.length == 6) {
var link_attach = document.getElementById("link-more-attach");
if (link_attach) {
@ -120,12 +121,12 @@ if ($allowToEdit) {
if ($form->validate()) {
$values = $form->getSubmitValues();
$sendEmail = isset($values['add_announcement']) ? true : false;
$sendEmail = isset($values['add_announcement']);
$allDay = isset($values['all_day']) ? 'true' : 'false';
$sendAttachment = isset($_FILES) && !empty($_FILES) ? true : false;
$attachmentCommentList = isset($values['legend']) ? $values['legend'] : null;
$comment = isset($values['comment']) ? $values['comment'] : null;
$usersToSend = isset($values['users_to_send']) ? $values['users_to_send'] : '';
$sendAttachment = isset($_FILES) && !empty($_FILES);
$attachmentCommentList = $values['legend'] ?? null;
$comment = $values['comment'] ?? null;
$usersToSend = $values['users_to_send'] ?? '';
$startDate = $values['date_range_start'];
$endDate = $values['date_range_end'];

@ -489,7 +489,6 @@ class Agenda
return false;
}
$courseId = $this->course['real_id'];
$eventId = (int) $eventId;
$sql = "SELECT title, content, start_date, end_date, all_day
@ -510,15 +509,15 @@ class Agenda
'yearly',
];
if (!in_array($type, $typeList)) {
if (!in_array($type, $typeList, true)) {
return false;
}
$now = time();
$endTimeStamp = api_strtotime($end, 'UTC');
// The event has to repeat *in the future*. We don't allow repeated
// events in the past
if ($end > $now) {
if ($endTimeStamp < $now) {
return false;
}
@ -530,7 +529,6 @@ class Agenda
$type = Database::escape_string($type);
$end = Database::escape_string($end);
$endTimeStamp = api_strtotime($end, 'UTC');
$sql = "INSERT INTO $t_agenda_r (cal_id, cal_type, cal_end)
VALUES ('$eventId', '$type', '$endTimeStamp')";
Database::query($sql);

@ -75,13 +75,16 @@ class PersonalAgenda
protected ?string $color;
/**
* Set title.
*
* @param string $title
* Get id.
*
* @return PersonalAgenda
* @return int
*/
public function setTitle($title)
public function getId()
{
return $this->id;
}
public function setTitle(string $title): self
{
$this->title = $title;
@ -98,26 +101,14 @@ class PersonalAgenda
return $this->title;
}
/**
* Set text.
*
* @param string $text
*
* @return PersonalAgenda
*/
public function setText($text)
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
/**
* Get text.
*
* @return string
*/
public function getText()
public function getText(): string
{
return $this->text;
}
@ -126,10 +117,8 @@ class PersonalAgenda
* Set date.
*
* @param DateTime $date
*
* @return PersonalAgenda
*/
public function setDate($date)
public function setDate($date): self
{
$this->date = $date;
@ -153,7 +142,7 @@ class PersonalAgenda
*
* @return PersonalAgenda
*/
public function setEndDate($value)
public function setEndDate($value): self
{
$this->endDate = $value;
@ -175,7 +164,7 @@ class PersonalAgenda
*
* @return PersonalAgenda
*/
public function setParentEventId($parentEventId)
public function setParentEventId($parentEventId): self
{
$this->parentEventId = $parentEventId;
@ -199,7 +188,7 @@ class PersonalAgenda
*
* @return PersonalAgenda
*/
public function setAllDay($allDay)
public function setAllDay($allDay): self
{
$this->allDay = $allDay;
@ -216,16 +205,6 @@ class PersonalAgenda
return $this->allDay;
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
@ -239,7 +218,7 @@ class PersonalAgenda
*
* @return PersonalAgenda
*/
public function setColor($color)
public function setColor($color): self
{
$this->color = $color;

@ -218,7 +218,7 @@ class ResourceFile
return $this->name;
}
public function setName($name): self
public function setName(?string $name): self
{
$this->name = $name;
@ -235,8 +235,6 @@ class ResourceFile
/**
* @param string $crop
*
* @return $this
*/
public function setCrop($crop): self
{
@ -245,12 +243,12 @@ class ResourceFile
return $this;
}
public function getSize(): int
public function getSize(): ?int
{
return $this->size;
}
public function setSize(int $size): self
public function setSize(?int $size): self
{
$this->size = $size;

@ -61,7 +61,7 @@ class SysCalendar
*
* @return SysCalendar
*/
public function setTitle($title)
public function setTitle($title): self
{
$this->title = $title;
@ -85,7 +85,7 @@ class SysCalendar
*
* @return SysCalendar
*/
public function setContent($content)
public function setContent($content): self
{
$this->content = $content;
@ -109,7 +109,7 @@ class SysCalendar
*
* @return SysCalendar
*/
public function setStartDate($startDate)
public function setStartDate($startDate): self
{
$this->startDate = $startDate;
@ -133,7 +133,7 @@ class SysCalendar
*
* @return SysCalendar
*/
public function setEndDate($endDate)
public function setEndDate($endDate): self
{
$this->endDate = $endDate;
@ -157,7 +157,7 @@ class SysCalendar
*
* @return SysCalendar
*/
public function setAccessUrlId($accessUrlId)
public function setAccessUrlId($accessUrlId): self
{
$this->accessUrlId = $accessUrlId;
@ -181,7 +181,7 @@ class SysCalendar
*
* @return SysCalendar
*/
public function setAllDay($allDay)
public function setAllDay($allDay): self
{
$this->allDay = $allDay;

@ -11,6 +11,7 @@ use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\Room;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
@ -18,9 +19,9 @@ use Symfony\Component\Validator\Constraints as Assert;
* CCalendarEvent.
*
* @ORM\Table(
* name="c_calendar_event",
* indexes={
* }
* name="c_calendar_event",
* indexes={
* }
* )
* @ORM\Entity
*/
@ -55,7 +56,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
protected ?DateTime $endDate;
/**
* @var ArrayCollection|CCalendarEvent[]
* @var Collection|CCalendarEvent[]
* @ORM\OneToMany(targetEntity="CCalendarEvent", mappedBy="parentEvent")
*/
protected $children;
@ -67,7 +68,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
protected ?CCalendarEvent $parentEvent = null;
/**
* @var ArrayCollection|CCalendarEventRepeat[]
* @var Collection|CCalendarEventRepeat[]
*
* @ORM\OneToMany(targetEntity="CCalendarEventRepeat", mappedBy="event", cascade={"persist"}, orphanRemoval=true)
*/
@ -95,10 +96,10 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
protected ?Room $room = null;
/**
* @var ArrayCollection|CCalendarEventAttachment[]
* @var Collection|CCalendarEventAttachment[]
*
* @ORM\OneToMany(
* targetEntity="CCalendarEventAttachment", mappedBy="event", cascade={"persist", "remove"}, orphanRemoval=true
* targetEntity="CCalendarEventAttachment", mappedBy="event", cascade={"persist", "remove"}
* )
*/
protected $attachments;
@ -106,6 +107,8 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
public function __construct()
{
$this->children = new ArrayCollection();
$this->attachments = new ArrayCollection();
$this->repeatEvents = new ArrayCollection();
}
public function __toString(): string
@ -120,12 +123,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
return $this;
}
/**
* Get title.
*
* @return string
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}
@ -189,7 +187,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
}
/**
* @return ArrayCollection|CCalendarEvent[]
* @return Collection|CCalendarEvent[]
*/
public function getChildren()
{
@ -240,28 +238,19 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
return $this->comment;
}
/**
* @param string $comment
*/
public function setComment($comment): self
public function setComment(string $comment): self
{
$this->comment = $comment;
return $this;
}
/**
* @return Room
*/
public function getRoom()
public function getRoom(): ?Room
{
return $this->room;
}
/**
* @param Room $room
*/
public function setRoom($room): self
public function setRoom(Room $room): self
{
$this->room = $room;
@ -295,7 +284,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
}
/**
* @return ArrayCollection|CCalendarEventAttachment[]
* @return Collection|CCalendarEventAttachment[]
*/
public function getAttachments()
{
@ -303,7 +292,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
}
/**
* @param ArrayCollection|CCalendarEventAttachment[] $attachments
* @param Collection|CCalendarEventAttachment[] $attachments
*/
public function setAttachments($attachments): self
{
@ -320,7 +309,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
}
/**
* @return ArrayCollection|CCalendarEventRepeat[]
* @return Collection|CCalendarEventRepeat[]
*/
public function getRepeatEvents()
{
@ -328,7 +317,7 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
}
/**
* @param ArrayCollection|CCalendarEventRepeat[] $repeatEvents
* @param Collection|CCalendarEventRepeat[] $repeatEvents
*
* @return CCalendarEvent
*/

@ -14,9 +14,9 @@ use Doctrine\ORM\Mapping as ORM;
* CCalendarEventAttachment.
*
* @ORM\Table(
* name="c_calendar_event_attachment",
* indexes={
* }
* name="c_calendar_event_attachment",
* indexes={
* }
* )
* @ORM\Entity
*/

@ -13,9 +13,9 @@ use Symfony\Component\Validator\Constraints as Assert;
* CCalendarEventRepeat.
*
* @ORM\Table(
* name="c_calendar_event_repeat",
* indexes={
* }
* name="c_calendar_event_repeat",
* indexes={
* }
* )
* @ORM\Entity
*/

@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
* CCalendarEventRepeatNot.
*
* @ORM\Table(
* name="c_calendar_event_repeat_not"
* name="c_calendar_event_repeat_not"
* )
* @ORM\Entity
*/

Loading…
Cancel
Save