Internal - Fix add links to resource in agenda/announcements.

pull/3570/head
Julio Montoya 5 years ago
parent db53d71935
commit b9675b2d4b
  1. 13
      public/main/announcements/announcements.php
  2. 43
      public/main/inc/lib/AnnouncementEmail.php
  3. 166
      public/main/inc/lib/AnnouncementManager.php
  4. 102
      public/main/inc/lib/agenda.lib.php
  5. 95
      src/CoreBundle/Entity/AbstractResource.php
  6. 31
      src/CourseBundle/Entity/CAnnouncement.php
  7. 12
      src/CourseBundle/Entity/CAnnouncementAttachment.php
  8. 26
      src/CourseBundle/Entity/CCalendarEvent.php

@ -612,14 +612,18 @@ switch ($action) {
); );
if (!$announcementAttachmentIsDisabled) { if (!$announcementAttachmentIsDisabled) {
$form->addElement('file', 'user_upload', get_lang('AddAnAttachment')); $form->addElement('file', 'user_upload', get_lang('Add attachment'));
$form->addElement('textarea', 'file_comment', get_lang('FileComment')); $form->addElement('textarea', 'file_comment', get_lang('File comment'));
} }
$form->addHidden('sec_token', $token); $form->addHidden('sec_token', $token);
if (empty($sessionId)) { if (empty($sessionId)) {
$form->addCheckBox('send_to_users_in_session', null, get_lang('Send to users in all sessions of this course')); $form->addCheckBox(
'send_to_users_in_session',
null,
get_lang('Send to users in all sessions of this course')
);
} }
$config = api_get_configuration_value('announcement.hide_send_to_hrm_users'); $config = api_get_configuration_value('announcement.hide_send_to_hrm_users');
@ -659,7 +663,6 @@ switch ($action) {
// there is an Id => the announcement already exists => update mode // there is an Id => the announcement already exists => update mode
$file_comment = $announcementAttachmentIsDisabled ? null : $_POST['file_comment']; $file_comment = $announcementAttachmentIsDisabled ? null : $_POST['file_comment'];
$file = $announcementAttachmentIsDisabled ? [] : $_FILES['user_upload']; $file = $announcementAttachmentIsDisabled ? [] : $_FILES['user_upload'];
$announcement = AnnouncementManager::edit_announcement( $announcement = AnnouncementManager::edit_announcement(
$id, $id,
$data['title'], $data['title'],
@ -765,7 +768,7 @@ if (!empty($_GET['remind_inactive'])) {
$to[] = 'USER:'.(int) ($_GET['remind_inactive']); $to[] = 'USER:'.(int) ($_GET['remind_inactive']);
} }
if (empty($_GET['origin']) or 'learnpath' !== $_GET['origin']) { if (empty($_GET['origin']) || 'learnpath' !== $_GET['origin']) {
// We are not in the learning path // We are not in the learning path
Display::display_header($nameTools, get_lang('Announcements')); Display::display_header($nameTools, get_lang('Announcements'));
} }

@ -62,45 +62,6 @@ class AnnouncementEmail
return $userList; return $userList;
} }
/**
* Returns users and groups an announcement item has been sent to.
*
* @return array Array of users and groups to whom the element has been sent
*/
public function sent_to_info()
{
return AnnouncementManager::getSenders($this->announcement);
$sql = "SELECT to_group_id, to_user_id
FROM $table
WHERE
c_id = $course_id AND
tool = '$tool' AND
ref = $id
$sessionCondition";
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs, 'ASSOC')) {
// if to_user_id <> 0 then it is sent to a specific user
$user_id = $row['to_user_id'];
if (!empty($user_id)) {
$result['users'][] = (int) $user_id;
// If user is set then skip the group
continue;
}
// if to_group_id is null then it is sent to a specific user
// if to_group_id = 0 then it is sent to everybody
$group_id = $row['to_group_id'];
if (!empty($group_id)) {
$result['groups'][] = (int) $group_id;
}
}
return $result;
}
/** /**
* Returns the list of user info to which an announcement was sent. * Returns the list of user info to which an announcement was sent.
* This function returns a list of actual users even when recipient * This function returns a list of actual users even when recipient
@ -110,7 +71,7 @@ class AnnouncementEmail
*/ */
public function sent_to() public function sent_to()
{ {
$sent_to = $this->sent_to_info(); $sent_to = $this->announcement->getUsersAndGroupSubscribedToResource();
$users = $sent_to['users']; $users = $sent_to['users'];
$users = $users ? $users : []; $users = $users ? $users : [];
$groups = $sent_to['groups']; $groups = $sent_to['groups'];
@ -139,7 +100,7 @@ class AnnouncementEmail
$newListUsers = []; $newListUsers = [];
if (!empty($users)) { if (!empty($users)) {
foreach ($users as $user) { foreach ($users as $user) {
$newListUsers[$user['user_id']] = ['user_id' => $user['user_id']]; $newListUsers[$user['id']] = ['user_id' => $user['id']];
} }
} }

@ -531,7 +531,7 @@ class AnnouncementManager
$allow = !api_get_configuration_value('hide_announcement_sent_to_users_info'); $allow = !api_get_configuration_value('hide_announcement_sent_to_users_info');
if ($allow && api_is_allowed_to_edit(false, true)) { if ($allow && api_is_allowed_to_edit(false, true)) {
$sent_to = self::sent_to('announcement', $id); $sent_to = $announcement->getUsersAndGroupSubscribedToResource();
$sentToForm = self::sent_to_form($sent_to); $sentToForm = self::sent_to_form($sent_to);
$html .= Display::tag( $html .= Display::tag(
'td', 'td',
@ -908,61 +908,35 @@ class AnnouncementManager
$repo->getEntityManager()->persist($announcement); $repo->getEntityManager()->persist($announcement);
$repo->getEntityManager()->flush(); $repo->getEntityManager()->flush();
// save attachment file
$row_attach = self::get_attachment($id);
$id_attach = 0;
if ($row_attach) {
$id_attach = (int) $row_attach['id'];
}
if (!empty($file)) { if (!empty($file)) {
if (empty($id_attach)) { self::add_announcement_attachment_file(
self::add_announcement_attachment_file( $announcement,
$announcement, $file_comment,
$file_comment, $file
$file );
); /*if (empty($id_attach)) {
} else { } else {
self::edit_announcement_attachment_file( self::edit_announcement_attachment_file(
$id_attach, $id_attach,
$file, $file,
$file_comment $file_comment
); );
} }*/
} }
// We remove everything from item_property for this
/*$sql = "DELETE FROM $tbl_item_property
WHERE c_id = $courseId AND ref='$id' AND tool='announcement'";
Database::query($sql);*/
if ($sendToUsersInSession) { if ($sendToUsersInSession) {
self::addAnnouncementToAllUsersInSessions($announcement); self::addAnnouncementToAllUsersInSessions($announcement);
} }
// store in item_property (first the groups, then the users // store, first the groups, then the users
if (!empty($to)) { if (!empty($to)) {
// !is_null($to): when no user is selected we send it to everyone // !is_null($to): when no user is selected we send it to everyone
$send_to = CourseManager::separateUsersGroups($to); $send_to = CourseManager::separateUsersGroups($to);
$resourceNode = $announcement->getResourceNode();
// storing the selected groups // storing the selected groups
if (is_array($send_to['groups'])) { if (is_array($send_to['groups'])) {
foreach ($send_to['groups'] as $group) { foreach ($send_to['groups'] as $groupId) {
$groupInfo = api_get_group_entity($group); $announcement->addGroupLink($course, $session, api_get_group_entity($groupId));
$announcement->addGroupLink($course, $session, $groupInfo);
/*
if ($groupInfo) {
api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
'AnnouncementUpdated',
api_get_user_id(),
$groupInfo
);
}*/
} }
} }
@ -971,43 +945,18 @@ class AnnouncementManager
foreach ($send_to['users'] as $user) { foreach ($send_to['users'] as $user) {
$user = api_get_user_entity($user); $user = api_get_user_entity($user);
$announcement->addUserLink($user, $course, $session, $group); $announcement->addUserLink($user, $course, $session, $group);
/*api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
'AnnouncementUpdated',
api_get_user_id(),
0,
$user
);*/
} }
} }
// Send to everyone // Send to everyone
if (isset($to[0]) && 'everyone' === $to[0]) { if (isset($to[0]) && 'everyone' === $to[0]) {
/*api_item_property_update( $announcement->addCourseLink($course, $session, $group);
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
'AnnouncementUpdated',
api_get_user_id(),
0
);*/
} }
} else { } else {
// the message is sent to everyone, so we set the group to 0 $announcement->addCourseLink($course, $session);
/*api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
'AnnouncementUpdated',
api_get_user_id(),
0
);*/
} }
$repo->getEntityManager()->persist($announcement); $repo->updateResource($announcement);
$repo->getEntityManager()->flush();
return $announcement; return $announcement;
} }
@ -1128,31 +1077,6 @@ class AnnouncementManager
return $result;*/ return $result;*/
} }
public static function getSenders(CAnnouncement $announcement)
{
$result = [];
$result['groups'] = [];
$result['users'] = [];
$links = $announcement->getResourceNode()->getResourceLinks();
if (empty($links)) {
return $result;
}
/** @var ResourceLink $link */
foreach ($links as $link) {
if ($link->getUser()) {
$result['users'][] = $link->getUser()->getId();
}
if ($link->getGroup()) {
$result['groups'][] = $link->getGroup()->getIid();
}
}
return $result;
}
/** /**
* This tools loads all the users and all the groups who have received * This tools loads all the users and all the groups who have received
* a specific item (in this case an announcement item). * a specific item (in this case an announcement item).
@ -1164,7 +1088,7 @@ class AnnouncementManager
*/ */
public static function loadEditUsers($announcement, $includeGroupWhenLoadingUser = false) public static function loadEditUsers($announcement, $includeGroupWhenLoadingUser = false)
{ {
$result = self::getSenders($announcement); $result = $announcement->getUsersAndGroupSubscribedToResource();
$to = []; $to = [];
foreach ($result['users'] as $itemId) { foreach ($result['users'] as $itemId) {
@ -1240,7 +1164,7 @@ class AnnouncementManager
} }
} else { } else {
// there is only one user/group // there is only one user/group
if (isset($sent_to_array['users']) && is_array($sent_to_array['users'])) { if (isset($sent_to_array['users']) && !empty($sent_to_array['users'])) {
$user_info = api_get_user_info($sent_to_array['users'][0]); $user_info = api_get_user_info($sent_to_array['users'][0]);
$output[] = api_get_person_name($user_info['firstname'], $user_info['lastname']); $output[] = api_get_person_name($user_info['firstname'], $user_info['lastname']);
} }
@ -1276,57 +1200,6 @@ class AnnouncementManager
} }
} }
/**
* Returns all the users and all the groups a specific announcement item
* has been sent to.
*
* @param string The tool (announcement, agenda, ...)
* @param int ID of the element of the corresponding type
*
* @return array Array of users and groups to whom the element has been sent
*/
public static function sent_to($tool, $id)
{
return [];
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tool = Database::escape_string($tool);
$id = (int) $id;
$sent_to_group = [];
$sent_to = [];
$courseId = api_get_course_int_id();
$sql = "SELECT to_group_id, to_user_id
FROM $table
WHERE c_id = $courseId AND tool = '$tool' AND ref=".$id;
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
// if to_user_id <> 0 then it is sent to a specific user
if (0 != $row['to_user_id']) {
$sent_to_user[] = $row['to_user_id'];
continue;
}
// if to_group_id is null then it is sent to a specific user
// if to_group_id = 0 then it is sent to everybody
if (0 != $row['to_group_id']) {
$sent_to_group[] = $row['to_group_id'];
}
}
if (isset($sent_to_group)) {
$sent_to['groups'] = $sent_to_group;
}
if (isset($sent_to_user)) {
$sent_to['users'] = $sent_to_user;
}
return $sent_to;
}
/** /**
* Show a list with all the attachments according to the post's id. * Show a list with all the attachments according to the post's id.
* *
@ -1363,11 +1236,8 @@ class AnnouncementManager
* *
* @return int -1 if failed, 0 if unknown (should not happen), 1 if success * @return int -1 if failed, 0 if unknown (should not happen), 1 if success
*/ */
public static function add_announcement_attachment_file( public static function add_announcement_attachment_file(CAnnouncement $announcement, $file_comment, $file)
CAnnouncement $announcement, {
$file_comment,
$file
) {
$return = 0; $return = 0;
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();

@ -337,7 +337,7 @@ class Agenda
if ($id) { if ($id) {
// Add announcement. // Add announcement.
if ($addAsAnnouncement) { if ($addAsAnnouncement) {
$this->storeAgendaEventAsAnnouncement($id, $usersToSend); $this->storeAgendaEventAsAnnouncement($event, $usersToSend);
} }
// Add attachment. // Add attachment.
@ -554,50 +554,31 @@ class Agenda
return true; return true;
} }
/** public function storeAgendaEventAsAnnouncement(CCalendarEvent $event, array $sentTo = [])
* @param int $item_id
* @param array $sentTo
*
* @return int
*/
public function storeAgendaEventAsAnnouncement($item_id, $sentTo = [])
{ {
$table_agenda = Database::get_course_table(TABLE_AGENDA); // Sending announcement
$courseId = api_get_course_int_id(); if (!empty($sentTo)) {
$id = AnnouncementManager::add_announcement(
// Get the agenda item. api_get_course_info(),
$item_id = (int) $item_id; api_get_session_id(),
$sql = "SELECT * FROM $table_agenda $event->getTitle(),
WHERE c_id = $courseId AND id = ".$item_id; $event->getContent(),
$res = Database::query($sql); $sentTo,
null,
if (Database::num_rows($res) > 0) { null,
$row = Database::fetch_array($res, 'ASSOC'); $event->getEndDate()->format('Y-m-d H:i:s')
);
// Sending announcement
if (!empty($sentTo)) {
$id = AnnouncementManager::add_announcement(
api_get_course_info(),
api_get_session_id(),
$row['title'],
$row['content'],
$sentTo,
null,
null,
$row['end_date']
);
AnnouncementManager::sendEmail( AnnouncementManager::sendEmail(
api_get_course_info(), api_get_course_info(),
api_get_session_id(), api_get_session_id(),
$id $id
); );
return $id; return true;
}
} }
return -1; return false;
} }
/** /**
@ -680,7 +661,7 @@ class Agenda
return false; return false;
} }
$sentToEvent = $event->getUsersAndGroupSubscribedToEvent(); $sentToEvent = $event->getUsersAndGroupSubscribedToResource();
$courseId = $this->course['real_id']; $courseId = $this->course['real_id'];
if (empty($courseId)) { if (empty($courseId)) {
@ -794,7 +775,7 @@ class Agenda
// Add announcement. // Add announcement.
if (isset($addAnnouncement) && !empty($addAnnouncement)) { if (isset($addAnnouncement) && !empty($addAnnouncement)) {
$this->storeAgendaEventAsAnnouncement($id, $usersToSend); $this->storeAgendaEventAsAnnouncement($event, $usersToSend);
} }
// Add attachment. // Add attachment.
@ -916,7 +897,7 @@ class Agenda
$this->table_repeat, $this->table_repeat,
[ [
'cal_id = ?' => [ 'cal_id = ?' => [
$id $id,
], ],
] ]
); );
@ -1290,7 +1271,7 @@ class Agenda
$event['description'] = $eventEntity->getComment(); $event['description'] = $eventEntity->getComment();
// Getting send to array // Getting send to array
$event['send_to'] = $eventEntity->getUsersAndGroupSubscribedToEvent(); $event['send_to'] = $eventEntity->getUsersAndGroupSubscribedToResource();
// Getting repeat info // Getting repeat info
$event['repeat_info'] = $eventEntity->getRepeatEvents(); $event['repeat_info'] = $eventEntity->getRepeatEvents();
@ -1697,18 +1678,6 @@ class Agenda
$event['unique_id'] = $eventId; $event['unique_id'] = $eventId;
$eventsAdded[] = $eventId; $eventsAdded[] = $eventId;
//$eventId = $row['ref'];
/*$items = $this->getUsersAndGroupSubscribedToEvent(
$eventId,
$courseId,
$this->sessionId
);
$group_to_array = $items['groups'];
$user_to_array = $items['users'];*/
/*$attachmentList = $this->getAttachmentList(
$eventId,
$courseInfo
);*/
$attachmentList = $row->getAttachments(); $attachmentList = $row->getAttachments();
$event['attachment'] = ''; $event['attachment'] = '';
if (!empty($attachmentList)) { if (!empty($attachmentList)) {
@ -2290,23 +2259,18 @@ class Agenda
if (isset($params['attachment']) && !empty($params['attachment'])) { if (isset($params['attachment']) && !empty($params['attachment'])) {
$attachmentList = $params['attachment']; $attachmentList = $params['attachment'];
/** @var CCalendarEventAttachment $attachment */
foreach ($attachmentList as $attachment) { foreach ($attachmentList as $attachment) {
$params['file_comment'] = $attachment['comment']; $form->addElement(
if (!empty($attachment['path'])) { 'checkbox',
$form->addElement( 'delete_attachment['.$attachment->getIid().']',
'checkbox', null,
'delete_attachment['.$attachment['id'].']', get_lang('Delete attachment').': '.$attachment->getFilename()
null, );
get_lang(
'DeleteAttachment'
).': '.$attachment['filename']
);
}
} }
} }
$form->addElement( $form->addTextarea(
'textarea',
'file_comment', 'file_comment',
get_lang('File comment') get_lang('File comment')
); );

@ -112,6 +112,22 @@ abstract class AbstractResource
throw new \Exception('addCourseLink requires to set the parent.'); throw new \Exception('addCourseLink requires to set the parent.');
} }
if ($this->hasResourceNode()) {
$resourceNode = $this->getResourceNode();
$exists = $resourceNode->getResourceLinks()->exists(
function ($key, $element) use ($course, $session, $group) {
return
$course === $element->getCourse() &&
$session === $element->getSession() &&
$group === $element->getGroup();
}
);
if ($exists) {
return $this;
}
}
$resourceLink = new ResourceLink(); $resourceLink = new ResourceLink();
$resourceLink $resourceLink
->setVisibility($visibility) ->setVisibility($visibility)
@ -147,32 +163,51 @@ abstract class AbstractResource
public function addGroupLink(Course $course, Session $session = null, CGroup $group = null) public function addGroupLink(Course $course, Session $session = null, CGroup $group = null)
{ {
$resourceNode = $this->getResourceNode(); if ($this->hasResourceNode()) {
$exists = $resourceNode->getResourceLinks()->exists( $resourceNode = $this->getResourceNode();
function ($key, $element) use ($group) { $exists = $resourceNode->getResourceLinks()->exists(
if ($element->getGroup()) { function ($key, $element) use ($group) {
return $group->getIid() == $element->getGroup()->getIid(); if ($element->getGroup()) {
return $group->getIid() === $element->getGroup()->getIid();
}
} }
);
if ($exists) {
return $this;
} }
);
if (false === $exists) {
$resourceLink = new ResourceLink();
$resourceLink
->setResourceNode($resourceNode)
->setCourse($course)
->setSession($session)
->setGroup($group)
->setVisibility(ResourceLink::VISIBILITY_PUBLISHED)
;
$this->addLink($resourceLink);
} }
$resourceLink = new ResourceLink();
$resourceLink
->setResourceNode($resourceNode)
->setCourse($course)
->setSession($session)
->setGroup($group)
->setVisibility(ResourceLink::VISIBILITY_PUBLISHED)
;
$this->addLink($resourceLink);
return $this; return $this;
} }
public function addUserLink(User $user, Course $course = null, Session $session = null, CGroup $group = null) public function addUserLink(User $user, Course $course = null, Session $session = null, CGroup $group = null)
{ {
if ($this->hasResourceNode()) {
$resourceNode = $this->getResourceNode();
$exists = $resourceNode->getResourceLinks()->exists(
function ($key, $element) use ($user) {
if ($element->getUser()) {
return $user->getId() === $element->getUser()->getId();
}
}
);
if ($exists) {
return $this;
}
}
$resourceLink = new ResourceLink(); $resourceLink = new ResourceLink();
$resourceLink $resourceLink
->setVisibility(ResourceLink::VISIBILITY_PUBLISHED) ->setVisibility(ResourceLink::VISIBILITY_PUBLISHED)
@ -367,4 +402,30 @@ abstract class AbstractResource
return null; return null;
} }
public function getUsersAndGroupSubscribedToResource(): array
{
$users = [];
$groups = [];
$everyone = false;
$links = $this->getResourceNode()->getResourceLinks();
foreach ($links as $link) {
if ($link->getUser()) {
$users[] = $link->getUser()->getId();
}
if ($link->getGroup()) {
$groups[] = $link->getGroup()->getIid();
}
}
if (empty($users) && empty($groups)) {
$everyone = true;
}
return [
'everyone' => $everyone,
'users' => $users,
'groups' => $groups,
];
}
} }

@ -6,6 +6,7 @@ namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CoreBundle\Entity\ResourceInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -64,7 +65,7 @@ class CAnnouncement extends AbstractResource implements ResourceInterface
protected $emailSent; protected $emailSent;
/** /**
* @var CAnnouncementAttachment[] * @var ArrayCollection|CAnnouncementAttachment[]
* *
* @ORM\OneToMany( * @ORM\OneToMany(
* targetEntity="CAnnouncementAttachment", * targetEntity="CAnnouncementAttachment",
@ -73,14 +74,16 @@ class CAnnouncement extends AbstractResource implements ResourceInterface
*/ */
protected $attachments; protected $attachments;
public function __construct()
{
$this->attachments = new ArrayCollection();
}
public function __toString(): string public function __toString(): string
{ {
return $this->getTitle(); return $this->getTitle();
} }
/**
* @return CAnnouncementAttachment[]
*/
public function getAttachments() public function getAttachments()
{ {
return $this->attachments; return $this->attachments;
@ -100,10 +103,8 @@ class CAnnouncement extends AbstractResource implements ResourceInterface
* Set title. * Set title.
* *
* @param string $title * @param string $title
*
* @return CAnnouncement
*/ */
public function setTitle($title) public function setTitle($title): self
{ {
$this->title = $title; $this->title = $title;
@ -124,10 +125,8 @@ class CAnnouncement extends AbstractResource implements ResourceInterface
* Set content. * Set content.
* *
* @param string $content * @param string $content
*
* @return CAnnouncement
*/ */
public function setContent($content) public function setContent($content): self
{ {
$this->content = $content; $this->content = $content;
@ -148,10 +147,8 @@ class CAnnouncement extends AbstractResource implements ResourceInterface
* Set endDate. * Set endDate.
* *
* @param \DateTime $endDate * @param \DateTime $endDate
*
* @return CAnnouncement
*/ */
public function setEndDate($endDate) public function setEndDate($endDate): self
{ {
$this->endDate = $endDate; $this->endDate = $endDate;
@ -172,10 +169,8 @@ class CAnnouncement extends AbstractResource implements ResourceInterface
* Set displayOrder. * Set displayOrder.
* *
* @param int $displayOrder * @param int $displayOrder
*
* @return CAnnouncement
*/ */
public function setDisplayOrder($displayOrder) public function setDisplayOrder($displayOrder): self
{ {
$this->displayOrder = $displayOrder; $this->displayOrder = $displayOrder;
@ -196,10 +191,8 @@ class CAnnouncement extends AbstractResource implements ResourceInterface
* Set emailSent. * Set emailSent.
* *
* @param bool $emailSent * @param bool $emailSent
*
* @return CAnnouncement
*/ */
public function setEmailSent($emailSent) public function setEmailSent($emailSent): self
{ {
$this->emailSent = $emailSent; $this->emailSent = $emailSent;

@ -94,10 +94,8 @@ class CAnnouncementAttachment extends AbstractResource implements ResourceInterf
* Set comment. * Set comment.
* *
* @param string $comment * @param string $comment
*
* @return CAnnouncementAttachment
*/ */
public function setComment($comment) public function setComment($comment): self
{ {
$this->comment = $comment; $this->comment = $comment;
@ -118,10 +116,8 @@ class CAnnouncementAttachment extends AbstractResource implements ResourceInterf
* Set size. * Set size.
* *
* @param int $size * @param int $size
*
* @return CAnnouncementAttachment
*/ */
public function setSize($size) public function setSize($size): self
{ {
$this->size = $size; $this->size = $size;
@ -147,10 +143,8 @@ class CAnnouncementAttachment extends AbstractResource implements ResourceInterf
* Set filename. * Set filename.
* *
* @param string $filename * @param string $filename
*
* @return CAnnouncementAttachment
*/ */
public function setFilename($filename) public function setFilename($filename): self
{ {
$this->filename = $filename; $this->filename = $filename;

@ -385,32 +385,6 @@ class CCalendarEvent extends AbstractResource implements ResourceInterface
return $this; return $this;
} }
public function getUsersAndGroupSubscribedToEvent(): array
{
$users = [];
$groups = [];
$everyone = false;
$links = $this->getResourceNode()->getResourceLinks();
foreach ($links as $link) {
if ($link->getUser()) {
$users[] = $link->getUser()->getId();
}
if ($link->getGroup()) {
$groups[] = $link->getGroup()->getIid();
}
}
if (empty($users) && empty($groups)) {
$everyone = true;
}
return [
'everyone' => $everyone,
'users' => $users,
'groups' => $groups,
];
}
/** /**
* Resource identifier. * Resource identifier.
*/ */

Loading…
Cancel
Save