Announcements: Use resource node to CRUD (WIP)

pull/3124/head
Julio Montoya 5 years ago
parent fba8cdb48c
commit 2c308e1507
  1. 48
      public/main/announcements/announcements.php
  2. 17
      public/main/inc/ajax/announcement.ajax.php
  3. 97
      public/main/inc/lib/AnnouncementEmail.php
  4. 273
      public/main/inc/lib/AnnouncementManager.php
  5. 4
      src/CoreBundle/Repository/ResourceRepository.php

@ -2,6 +2,9 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CAnnouncement;
/**
* @author Frederik Vermeire <frederik.vermeire@pandora.be>, UGent Internship
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: code cleaning
@ -12,7 +15,6 @@
* as there was no title field (the title was merged into the content field)
*/
// use anonymous mode when accessing this course tool
$use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -28,6 +30,7 @@ $group_id = api_get_group_id();
$current_course_tool = TOOL_ANNOUNCEMENT;
$this_section = SECTION_COURSES;
$nameTools = get_lang('Announcements');
$repo = Container::getAnnouncementRepository();
$allowToEdit = (
api_is_allowed_to_edit(false, true) ||
@ -110,7 +113,7 @@ switch ($action) {
}
$sql = "SELECT DISTINCT announcement.id, announcement.display_order
FROM $tbl_announcement announcement
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property itemproperty
ON (announcement.c_id = itemproperty.c_id)
WHERE
@ -494,14 +497,15 @@ switch ($action) {
$announcement_to_modify = '';
}
$announcementInfo = [];
$announcementInfo = null;
if (!empty($id)) {
$announcementInfo = AnnouncementManager::get_by_id($courseId, $id);
/** @var CAnnouncement $announcementInfo */
$announcementInfo = $repo->find($id);
}
$showSubmitButton = true;
if (!empty($announcementInfo)) {
$to = AnnouncementManager::loadEditUsers('announcement', $id);
$to = AnnouncementManager::loadEditUsers($announcementInfo);
if (!empty($group_id)) {
$separated = CourseManager::separateUsersGroups($to);
@ -513,9 +517,9 @@ switch ($action) {
}
$defaults = [
'title' => $announcementInfo['title'],
'content' => $announcementInfo['content'],
'id' => $announcementInfo['id'],
'title' => $announcementInfo->getTitle(),
'content' => $announcementInfo->getContent(),
'id' => $announcementInfo->getIid(),
'users' => $to,
];
} else {
@ -530,22 +534,22 @@ switch ($action) {
$form->addHtml("
<script>
$(function () {
$('#announcement_preview').on('click', function() {
$('#announcement_preview').on('click', function() {
var users = [];
$('#users_to option').each(function() {
users.push($(this).val());
users.push($(this).val());
});
var form = $('#announcement').serialize();
$.ajax({
type: 'POST',
dataType: 'json',
url: '".$ajaxUrl."',
data: {users : JSON.stringify(users), form: form},
data: {users : JSON.stringify(users), form: form},
beforeSend: function() {
$('#announcement_preview_result').html('<i class=\"fa fa-spinner\"></i>');
$('#send_button').hide();
},
},
success: function(result) {
var resultToString = '';
$.each(result, function(index, value) {
@ -555,7 +559,7 @@ switch ($action) {
'".addslashes(get_lang('Announcement will be sent to'))."<br/>' + resultToString
);
$('#announcement_preview_result').show();
$('#send_button').show();
$('#send_button').show();
}
});
});
@ -655,7 +659,7 @@ switch ($action) {
$file_comment = $_POST['file_comment'];
$file = $_FILES['user_upload'];
AnnouncementManager::edit_announcement(
$announcement = AnnouncementManager::edit_announcement(
$id,
$data['title'],
$data['content'],
@ -671,14 +675,14 @@ switch ($action) {
$messageSentTo = AnnouncementManager::sendEmail(
api_get_course_info(),
api_get_session_id(),
$id,
$announcement,
$sendToUsersInSession,
isset($data['send_to_hrm_users'])
);
}
if ($sendMeCopy && !in_array(api_get_user_id(), $messageSentTo)) {
$email = new AnnouncementEmail(api_get_course_info(), api_get_session_id(), $id);
$email = new AnnouncementEmail(api_get_course_info(), api_get_session_id(), $announcement);
$email->sendAnnouncementEmailToMySelf();
}
@ -699,7 +703,7 @@ switch ($action) {
$file_comment = $data['file_comment'];
if (empty($group_id)) {
$insert_id = AnnouncementManager::add_announcement(
$announcement = AnnouncementManager::add_announcement(
api_get_course_info(),
api_get_session_id(),
$data['title'],
@ -711,7 +715,7 @@ switch ($action) {
$sendToUsersInSession
);
} else {
$insert_id = AnnouncementManager::addGroupAnnouncement(
$announcement = AnnouncementManager::addGroupAnnouncement(
$data['title'],
$data['content'],
$group_id,
@ -722,7 +726,7 @@ switch ($action) {
);
}
if ($insert_id) {
if ($announcement) {
Display::addFlash(
Display::return_message(
get_lang('Announcement has been added'),
@ -736,13 +740,13 @@ switch ($action) {
$messageSentTo = AnnouncementManager::sendEmail(
api_get_course_info(),
api_get_session_id(),
$insert_id,
$announcement,
$sendToUsersInSession
);
}
if ($sendMeCopy && !in_array(api_get_user_id(), $messageSentTo)) {
$email = new AnnouncementEmail(api_get_course_info(), api_get_session_id(), $insert_id);
$email = new AnnouncementEmail(api_get_course_info(), api_get_session_id(), $announcement);
$email->sendAnnouncementEmailToMySelf();
}

@ -4,6 +4,9 @@
/**
* Responses to AJAX calls.
*/
use Chamilo\CoreBundle\Framework\Container;
require_once __DIR__.'/../global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
@ -194,18 +197,18 @@ switch ($action) {
}
$list = explode(',', $_REQUEST['id']);
$repo = Container::getAnnouncementRepository();
foreach ($list as $itemId) {
if (!api_is_session_general_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $itemId)) {
$result = AnnouncementManager::get_by_id(
api_get_course_int_id(),
$itemId
);
if (!empty($result)) {
$announcement = $repo->find($itemId);
if (!empty($announcement)) {
$delete = true;
if (!empty($groupId) && $isTutor) {
if ($groupId != $result['to_group_id']) {
/*if ($groupId != $result['to_group_id']) {
$delete = false;
}
}*/
}
if ($delete) {
AnnouncementManager::delete_announcement($courseInfo, $itemId);

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CAnnouncement;
/**
* Announcement Email.
*
@ -9,18 +11,19 @@
*/
class AnnouncementEmail
{
public $session_id = null;
public $session_id;
public $logger;
protected $course = null;
protected $announcement = null;
protected $course;
/** @var CAnnouncement */
protected $announcement;
/**
* @param array $courseInfo
* @param int $sessionId
* @param int $announcementId
* @param CAnnouncement $announcement
* @param \Monolog\Logger $logger
*/
public function __construct($courseInfo, $sessionId, $announcementId, $logger = null)
public function __construct($courseInfo, $sessionId, CAnnouncement $announcement, $logger = null)
{
if (empty($courseInfo)) {
$courseInfo = api_get_course_info();
@ -28,43 +31,10 @@ class AnnouncementEmail
$this->course = $courseInfo;
$this->session_id = empty($sessionId) ? api_get_session_id() : (int) $sessionId;
if (is_numeric($announcementId)) {
$this->announcement = AnnouncementManager::get_by_id($courseInfo['real_id'], $announcementId);
}
$this->announcement = $announcement;
$this->logger = $logger;
}
/**
* Course info.
*
* @param string $key
*
* @return string|null
*/
public function course($key = '')
{
$result = $key ? $this->course[$key] : $this->course;
$result = $key == 'id' ? intval($result) : $result;
return $result;
}
/**
* Announcement info.
*
* @param string $key
*
* @return array
*/
public function announcement($key = '')
{
$result = $key ? $this->announcement[$key] : $this->announcement;
$result = $key == 'id' ? intval($result) : $result;
return $result;
}
/**
* Returns either all course users or all session users depending on whether
* session is turned on or not.
@ -73,7 +43,7 @@ class AnnouncementEmail
*/
public function all_users()
{
$courseCode = $this->course('code');
$courseCode = $this->course['code'];
if (empty($this->session_id)) {
$group_id = api_get_group_id();
if (empty($group_id)) {
@ -103,15 +73,9 @@ class AnnouncementEmail
*/
public function sent_to_info()
{
$result = [];
$result['groups'] = [];
$result['users'] = [];
$result = AnnouncementManager::getSenders($this->announcement);
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tool = TOOL_ANNOUNCEMENT;
$id = $this->announcement('id');
$course_id = $this->course('real_id');
$sessionCondition = api_get_session_condition($this->session_id);
return $result;
$sql = "SELECT to_group_id, to_user_id
FROM $table
@ -197,10 +161,11 @@ class AnnouncementEmail
*/
public function subject($directMessage = false)
{
$title = $this->announcement->getTitle();
if ($directMessage) {
$result = $this->announcement('title');
$result = $title;
} else {
$result = $this->course('title').' - '.$this->announcement('title');
$result = $this->course['title'].' - '.$title;
}
$result = stripslashes($result);
@ -217,9 +182,9 @@ class AnnouncementEmail
*/
public function message($receiverUserId)
{
$content = $this->announcement('content');
$content = $this->announcement->getContent();
$session_id = $this->session_id;
$courseCode = $this->course('code');
$courseCode = $this->course['code'];
$content = AnnouncementManager::parseContent(
$receiverUserId,
@ -230,7 +195,7 @@ class AnnouncementEmail
// Build the link by hand because api_get_cidreq() doesn't accept course params
$course_param = 'cidReq='.$courseCode.'&id_session='.$session_id.'&gidReq='.api_get_group_id();
$course_name = $this->course('title');
$course_name = $this->course['title'];
$result = "<div>$content</div>";
@ -264,12 +229,12 @@ class AnnouncementEmail
{
$result = [];
$table = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
$id = $this->announcement('id');
$course_id = $this->course('real_id');
$sql = "SELECT * FROM $table
$id = $this->announcement->getIid();
$course_id = $this->course['real_id'];
$sql = "SELECT * FROM $table
WHERE c_id = $course_id AND announcement_id = $id ";
$rs = Database::query($sql);
$course_path = $this->course('directory');
$course_path = $this->course['directory'];
while ($row = Database::fetch_array($rs)) {
$path = api_get_path(SYS_COURSE_PATH).$course_path.'/upload/announcements/'.$row['path'];
$filename = $row['filename'];
@ -331,7 +296,7 @@ class AnnouncementEmail
if ($wasSent === false) {
if (!empty($this->logger)) {
$this->logger->addInfo(
'Announcement: #'.$this->announcement('id').'. Send email to user: #'.$user['user_id']
'Announcement: #'.$this->announcement->getIid().'. Send email to user: #'.$user['user_id']
);
}
@ -347,7 +312,7 @@ class AnnouncementEmail
} else {
if (!empty($this->logger)) {
$this->logger->addInfo(
'Message "'.$subject.'" was already sent. Announcement: #'.$this->announcement('id').'.
'Message "'.$subject.'" was already sent. Announcement: #'.$this->announcement->getIid().'.
User: #'.$user['user_id']
);
}
@ -398,15 +363,15 @@ class AnnouncementEmail
*/
public function logMailSent()
{
$id = $this->announcement('id');
$courseId = $this->course('real_id');
$id = $this->announcement->getIid();
$courseId = $this->course['real_id'];
$table = Database::get_course_table(TABLE_ANNOUNCEMENT);
$sql = "UPDATE $table SET
$sql = "UPDATE $table SET
email_sent = 1
WHERE
c_id = $courseId AND
id = $id AND
session_id = {$this->session_id}
WHERE
c_id = $courseId AND
id = $id AND
session_id = {$this->session_id}
";
Database::query($sql);
}

@ -7,7 +7,6 @@ use Chamilo\CoreBundle\Entity\ExtraFieldValues;
use Chamilo\CoreBundle\Entity\Resource\ResourceLink;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CAnnouncement;
use Chamilo\CourseBundle\Entity\CItemProperty;
/**
* Include file with functions for the announcements module.
@ -165,6 +164,14 @@ class AnnouncementManager
$session_id = (int) $session_id;
$courseId = $course_info['real_id'];
$repo = Container::getAnnouncementRepository();
$criteria = [
'cId' => $courseId,
];
return $repo->findBy($criteria);
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
@ -242,13 +249,23 @@ class AnnouncementManager
*/
public static function delete_announcement($courseInfo, $id)
{
$repo = Container::getAnnouncementRepository();
$criteria = [
'cId' => $courseInfo['real_id'],
'id' =>$id
];
$announcement = $repo->findOneBy($criteria);
$repo->getEntityManager()->remove($announcement);
$repo->getEntityManager()->flush();
/*
api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
'delete',
api_get_user_id()
);
);*/
}
/**
@ -258,21 +275,25 @@ class AnnouncementManager
*/
public static function delete_all_announcements($courseInfo)
{
$repo = Container::getAnnouncementRepository();
$announcements = self::get_all_annoucement_by_course(
$courseInfo,
api_get_session_id()
);
if (!empty($announcements)) {
foreach ($announcements as $annon) {
api_item_property_update(
foreach ($announcements as $announcement) {
$repo->getEntityManager()->remove($announcement);
/*api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$annon['id'],
'delete',
api_get_user_id()
);
);*/
}
}
$repo->getEntityManager()->flush();
}
/**
@ -331,6 +352,7 @@ class AnnouncementManager
$announcementId = (int) $announcementId;
$repo = Container::getAnnouncementRepository();
return $repo->find($announcementId);
$courseId = (int) $courseId;
@ -607,18 +629,6 @@ class AnnouncementManager
$order = self::getLastAnnouncementOrder($courseInfo);
// store in the table announcement
$params = [
'c_id' => $courseId,
'content' => $newContent,
'title' => $title,
'end_date' => $end_date,
'display_order' => $order,
'session_id' => (int) $sessionId,
];
$last_id = Database::insert($tbl_announcement, $params);
$announcement = new CAnnouncement();
$announcement
->setCId($courseId)
@ -716,7 +726,7 @@ class AnnouncementManager
self::addAnnouncementToAllUsersInSessions($last_id);
}
return $last_id;
return $announcement;
}
/**
@ -747,18 +757,30 @@ class AnnouncementManager
$now = api_get_utc_datetime();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$authorId = api_get_user_id();
// store in the table announcement
$params = [
'c_id' => $courseId,
'content' => $newContent,
'title' => $title,
'end_date' => $now,
'display_order' => $order,
'session_id' => api_get_session_id(),
];
$announcement = new CAnnouncement();
$announcement
->setCId($courseId)
->setContent($newContent)
->setTitle($title)
->setEndDate(new DateTime($now))
->setDisplayOrder($order)
->setSessionId($sessionId)
;
$last_id = Database::insert($table, $params);
$repo = Container::getAnnouncementRepository();
$repo->addResourceToCourse(
$announcement,
ResourceLink::VISIBILITY_PUBLISHED,
api_get_user_entity($authorId),
api_get_course_entity($courseId),
api_get_session_entity($sessionId),
api_get_group_entity()
);
$repo->getEntityManager()->flush();
$last_id = $announcement->getIid();
// Store the attach file
if ($last_id) {
@ -852,21 +874,18 @@ class AnnouncementManager
$sendToUsersInSession = false
) {
$courseInfo = api_get_course_info();
$courseId = api_get_course_int_id();
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$table = Database::get_course_table(TABLE_ANNOUNCEMENT);
$id = (int) $id;
$params = [
'title' => $title,
'content' => $newContent,
];
$repo = Container::getAnnouncementRepository();
/** @var CAnnouncement $announcement */
$announcement = $repo->find($id);
Database::update(
$table,
$params,
['c_id = ? AND id = ?' => [$courseId, $id]]
);
$announcement
->setTitle($title)
->setContent($newContent)
;
$repo->getEntityManager()->persist($announcement);
$repo->getEntityManager()->flush();
// save attachment file
$row_attach = self::get_attachment($id);
@ -893,9 +912,9 @@ class AnnouncementManager
}
// We remove everything from item_property for this
$sql = "DELETE FROM $tbl_item_property
/*$sql = "DELETE FROM $tbl_item_property
WHERE c_id = $courseId AND ref='$id' AND tool='announcement'";
Database::query($sql);
Database::query($sql);*/
if ($sendToUsersInSession) {
self::addAnnouncementToAllUsersInSessions($id);
@ -905,15 +924,14 @@ class AnnouncementManager
if (!empty($to)) {
// !is_null($to): when no user is selected we send it to everyone
$send_to = CourseManager::separateUsersGroups($to);
$resourceNode = $announcement->getResourceNode();
// storing the selected groups
if (is_array($send_to['groups'])) {
foreach ($send_to['groups'] as $group) {
$groupInfo = GroupManager::get_group_properties($group);
if (empty($groupInfo)) {
// Probably the group id and iid are different try checking the iid
$groupInfo = GroupManager::get_group_properties($group, true);
}
$groupInfo = api_get_group_entity($group);
$repo->addResourceToCourseGroup($resourceNode, $groupInfo);
/*
if ($groupInfo) {
api_item_property_update(
$courseInfo,
@ -923,14 +941,16 @@ class AnnouncementManager
api_get_user_id(),
$groupInfo
);
}
}*/
}
}
// storing the selected users
if (is_array($send_to['users'])) {
foreach ($send_to['users'] as $user) {
api_item_property_update(
$user = api_get_user_entity($user);
$repo->addResourceToUser($resourceNode, $user);
/*api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
@ -938,32 +958,36 @@ class AnnouncementManager
api_get_user_id(),
0,
$user
);
);*/
}
}
// Send to everyone
if (isset($to[0]) && $to[0] === 'everyone') {
api_item_property_update(
/*api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
'AnnouncementUpdated',
api_get_user_id(),
0
);
);*/
}
} else {
// the message is sent to everyone, so we set the group to 0
api_item_property_update(
/*api_item_property_update(
$courseInfo,
TOOL_ANNOUNCEMENT,
$id,
'AnnouncementUpdated',
api_get_user_id(),
0
);
);*/
}
$repo->getEntityManager()->flush();
return $announcement;
}
/**
@ -1068,46 +1092,6 @@ class AnnouncementManager
return $result;
}
/**
* Returns announcement info from its id.
*
* @param int $courseId
* @param int $id
*
* @return array
*/
public static function get_by_id($courseId, $id)
{
$id = (int) $id;
$courseId = $courseId ? (int) $courseId : api_get_course_int_id();
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql = "SELECT DISTINCT
announcement.id,
announcement.title,
announcement.content,
ip.to_group_id
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON
announcement.id = ip.ref AND
announcement.c_id = ip.c_id
WHERE
announcement.c_id = $courseId AND
ip.tool='announcement' AND
announcement.id = $id
";
$result = Database::query($sql);
if (Database::num_rows($result)) {
return Database::fetch_array($result);
}
return [];
}
/**
* this function gets all the groups of the course,
* not including linked courses.
@ -1132,66 +1116,47 @@ class AnnouncementManager
return $new_group_list;
}
public static function getSenders(CAnnouncement $announcement)
{
$result = [];
$result['groups'] = [];
$result['users'] = [];
$links = $announcement->getResourceNode()->getResourceLinks();
/** @var ResourceLink $link */
foreach ($links as $link) {
if ($link->getUser()) {
$result['users'][] = $link->getUser()->getId();
}
if ($link->getGroup()) {
$result['groups'][] = $link->getGroup()->getId();
}
}
return $result;
}
/**
* This tools loads all the users and all the groups who have received
* a specific item (in this case an announcement item).
*
* @param string $tool
* @param int $id
* @param bool $includeGroupWhenLoadingUser
* @param CAnnouncement $announcement
* @param bool $includeGroupWhenLoadingUser
*
* @return array
*/
public static function loadEditUsers($tool, $id, $includeGroupWhenLoadingUser = false)
public static function loadEditUsers($announcement, $includeGroupWhenLoadingUser = false)
{
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tool = Database::escape_string($tool);
$id = (int) $id;
$courseId = api_get_course_int_id();
$groupId = api_get_group_id();
$sql = "SELECT to_user_id, to_group_id FROM $table
WHERE c_id = $courseId AND tool='$tool' AND ref = $id";
$result = Database::query($sql);
$result = self::getSenders($announcement);
$to = [];
while ($row = Database::fetch_array($result)) {
// This is the iid of c_group_info
$toGroup = $row['to_group_id'];
if (empty($row['to_user_id']) && !empty($groupId) && $groupId != $toGroup) {
//continue;
}
switch ($toGroup) {
// it was send to one specific user
case null:
if (isset($row['to_user_id']) && !empty($row['to_user_id'])) {
if (!in_array('USER:'.$row['to_user_id'], $to)) {
$to[] = 'USER:'.$row['to_user_id'];
}
}
break;
// it was sent to everyone
case 0:
return 'everyone';
break;
default:
if (isset($row['to_user_id']) && !empty($row['to_user_id'])) {
if (!in_array('USER:'.$row['to_user_id'], $to)) {
$to[] = 'USER:'.$row['to_user_id'];
}
} else {
if (!in_array('GROUP:'.$toGroup, $to)) {
$to[] = 'GROUP:'.$toGroup;
}
}
if ($includeGroupWhenLoadingUser) {
if (!in_array('GROUP:'.$toGroup, $to)) {
$to[] = 'GROUP:'.$toGroup;
}
}
break;
}
foreach ($result['users'] as $itemId) {
$to[] = 'USER:'.$itemId;
}
foreach ($result['groups'] as $itemId) {
$to[] = 'GROUP:'.$itemId;
}
return $to;
@ -1391,7 +1356,7 @@ class AnnouncementManager
$courseInfo = api_get_course_info();
$table = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
$return = 0;
$announcement_id = intval($announcement_id);
$announcement_id = (int) $announcement_id;
$courseId = api_get_course_int_id();
if (is_array($file) && $file['error'] == 0) {
@ -1530,28 +1495,28 @@ class AnnouncementManager
}
/**
* @param array $courseInfo
* @param int $sessionId
* @param int $announcementId
* @param bool $sendToUsersInSession
* @param bool $sendToDrhUsers
* @param array $courseInfo
* @param int $sessionId
* @param CAnnouncement $announcement
* @param bool $sendToUsersInSession
* @param bool $sendToDrhUsers
* @param Monolog\Handler\HandlerInterface logger
* @param int $senderId
* @param bool $directMessage
* @param int $senderId
* @param bool $directMessage
*
* @return array
*/
public static function sendEmail(
$courseInfo,
$sessionId,
$announcementId,
$announcement,
$sendToUsersInSession = false,
$sendToDrhUsers = false,
$logger = null,
$senderId = 0,
$directMessage = false
) {
$email = new AnnouncementEmail($courseInfo, $sessionId, $announcementId, $logger);
$email = new AnnouncementEmail($courseInfo, $sessionId, $announcement, $logger);
return $email->send($sendToUsersInSession, $sendToDrhUsers, $senderId, $directMessage);
}

@ -360,6 +360,7 @@ class ResourceRepository extends BaseEntityRepository
$resourceLink = new ResourceLink();
$resourceLink
->setResourceNode($resourceNode)
->setVisibility(ResourceLink::VISIBILITY_PUBLISHED)
->setUser($toUser);
return $resourceLink;
@ -380,7 +381,8 @@ class ResourceRepository extends BaseEntityRepository
$resourceLink
->setResourceNode($resourceNode)
->setGroup($group)
->setVisibility(ResourceLink::VISIBILITY_PUBLISHED);
->setVisibility(ResourceLink::VISIBILITY_PUBLISHED)
;
$this->getEntityManager()->persist($resourceLink);
return $resourceLink;

Loading…
Cancel
Save