|
|
@ -780,43 +780,31 @@ class AnnouncementManager |
|
|
|
) { |
|
|
|
) { |
|
|
|
$courseInfo = api_get_course_info(); |
|
|
|
$courseInfo = api_get_course_info(); |
|
|
|
|
|
|
|
|
|
|
|
// Database definitions |
|
|
|
|
|
|
|
$table = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
|
|
|
|
|
|
$order = self::getLastAnnouncementOrder($courseInfo); |
|
|
|
$order = self::getLastAnnouncementOrder($courseInfo); |
|
|
|
|
|
|
|
|
|
|
|
$now = api_get_utc_datetime(); |
|
|
|
$now = api_get_utc_datetime(); |
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
$courseId = api_get_course_int_id(); |
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
$authorId = api_get_user_id(); |
|
|
|
$course = api_get_course_entity($courseId); |
|
|
|
|
|
|
|
|
|
|
|
$announcement = new CAnnouncement(); |
|
|
|
$announcement = new CAnnouncement(); |
|
|
|
$announcement |
|
|
|
$announcement |
|
|
|
->setCId($courseId) |
|
|
|
|
|
|
|
->setContent($newContent) |
|
|
|
->setContent($newContent) |
|
|
|
->setTitle($title) |
|
|
|
->setTitle($title) |
|
|
|
->setEndDate(new DateTime($now)) |
|
|
|
->setEndDate(new DateTime($now)) |
|
|
|
->setDisplayOrder($order) |
|
|
|
->setDisplayOrder($order) |
|
|
|
->setSessionId($sessionId) |
|
|
|
->setParent($course) |
|
|
|
; |
|
|
|
->addCourseLink( |
|
|
|
|
|
|
|
$course, |
|
|
|
|
|
|
|
api_get_session_entity($sessionId), |
|
|
|
|
|
|
|
api_get_group_entity() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$repo = Container::getAnnouncementRepository(); |
|
|
|
$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(); |
|
|
|
$repo->getEntityManager()->flush(); |
|
|
|
$last_id = $announcement->getIid(); |
|
|
|
$last_id = $announcement->getIid(); |
|
|
|
|
|
|
|
|
|
|
|
// Store the attach file |
|
|
|
// Store the attach file |
|
|
|
if ($last_id) { |
|
|
|
if ($last_id) { |
|
|
|
$sql = "UPDATE $table SET id = iid |
|
|
|
|
|
|
|
WHERE iid = $last_id"; |
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($file)) { |
|
|
|
if (!empty($file)) { |
|
|
|
self::add_announcement_attachment_file( |
|
|
|
self::add_announcement_attachment_file( |
|
|
|
$announcement, |
|
|
|
$announcement, |
|
|
|