diff --git a/main/admin/system_announcements.php b/main/admin/system_announcements.php
index 8ece2c5203..233fb34b18 100755
--- a/main/admin/system_announcements.php
+++ b/main/admin/system_announcements.php
@@ -7,6 +7,9 @@
*/
// Resetting the course id.
+use Chamilo\CoreBundle\Entity\SysAnnouncement;
+use Chamilo\PluginBundle\Zoom\Meeting;
+
$cidReset = true;
// Including the global initialization file.
@@ -67,6 +70,7 @@ if ($action != 'add' && $action != 'edit') {
/* MAIN CODE */
$show_announcement_list = true;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
+$type = $_REQUEST['type'] ?? null;
// Form was posted?
if (isset($_POST['action'])) {
@@ -153,6 +157,32 @@ if ($action_todo) {
$url = api_get_self().'?id='.intval($_GET['id']);
}
$form = new FormValidator('system_announcement', 'post', $url);
+
+ if ('add' === $action && 'zoom_conference' == $type && $meetingId = $_REQUEST['meeting'] ?? 0) {
+ $plugin = ZoomPlugin::create();
+
+ if ($plugin->isEnabled(true)) {
+ /** @var Meeting $meeting */
+ $meeting = ZoomPlugin::getMeetingRepository()->findOneBy(['meetingId' => $meetingId]);
+ $meetingUrl = api_get_path(WEB_PLUGIN_PATH).'zoom/subscription.php?meetingId='.$meeting->getMeetingId();
+
+ $endDate = new DateTime($meeting->formattedStartTime);
+ $endDate->add($meeting->durationInterval);
+
+ $values['title'] = $meeting->getTopic();
+ $values['content'] = '
'.$meeting->getAgenda().'
'
+ .''.$plugin->get_lang('UrlForSelfRegistration').'
'.Display::url($meetingUrl, $meetingUrl).'
';
+ $values['range_start'] = $meeting->formattedStartTime;
+ $values['range_end'] = $endDate->format('Y-m-d H:i');
+ $values['range'] = "{$values['range_start']} / {$values['range_end']}";
+ $values['send_mail'] = true;
+ $values['add_to_calendar'] = true;
+
+ $form->addHidden('type', 'zoom_conference');
+ $form->addHidden('meeting', $meeting->getMeetingId());
+ }
+ }
+
$form->addHeader($form_title);
$form->addText('title', get_lang('Title'), true);
@@ -269,6 +299,13 @@ if ($action_todo) {
SystemAnnouncementManager::announcement_for_groups($announcement_id, $groupsToSend);
}
+ if (isset($meeting)) {
+ $em = Database::getManager();
+ $sysAnnouncement = $em->find(SysAnnouncement::class, $announcement_id);
+ $meeting->setSysAnnouncement($sysAnnouncement);
+ $em->flush();
+ }
+
echo Display::return_message(get_lang('AnnouncementAdded'), 'confirmation');
} else {
$show_announcement_list = false;
diff --git a/plugin/zoom/Entity/Meeting.php b/plugin/zoom/Entity/Meeting.php
index f5599d0abb..72b7de925d 100644
--- a/plugin/zoom/Entity/Meeting.php
+++ b/plugin/zoom/Entity/Meeting.php
@@ -8,6 +8,7 @@ use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\CourseRelUser;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
+use Chamilo\CoreBundle\Entity\SysAnnouncement;
use Chamilo\CourseBundle\Entity\CGroupInfo;
use Chamilo\PluginBundle\Zoom\API\BaseMeetingTrait;
use Chamilo\PluginBundle\Zoom\API\MeetingInfoGet;
@@ -162,12 +163,21 @@ class Meeting
*/
protected $accountEmail;
+ /**
+ * @var SysAnnouncement|null
+ *
+ * @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\SysAnnouncement")
+ * @ORM\JoinColumn(name="sys_announcement_id", referencedColumnName="id", onDelete="SET NULL")
+ */
+ protected $sysAnnouncement;
+
public function __construct()
{
$this->registrants = new ArrayCollection();
$this->recordings = new ArrayCollection();
$this->activities = new ArrayCollection();
$this->signAttendance = false;
+ $this->sysAnnouncement = null;
}
/**
@@ -616,6 +626,18 @@ class Meeting
return $this->meetingInfoGet->agenda;
}
+ public function getSysAnnouncement(): ?SysAnnouncement
+ {
+ return $this->sysAnnouncement;
+ }
+
+ public function setSysAnnouncement(?SysAnnouncement $sysAnnouncement): Meeting
+ {
+ $this->sysAnnouncement = $sysAnnouncement;
+
+ return $this;
+ }
+
/**
* @throws Exception on unexpected start_time or duration
*/
diff --git a/plugin/zoom/calendar.ajax.php b/plugin/zoom/calendar.ajax.php
index 3a624b9c37..4b2b2a4714 100644
--- a/plugin/zoom/calendar.ajax.php
+++ b/plugin/zoom/calendar.ajax.php
@@ -41,7 +41,7 @@ if ($action == 'get_events') {
$schema = $isWebinar ? $conference->getWebinarSchema() : $conference->getMeetingInfoGet();
$endDate = new DateTime($conference->formattedStartTime);
- $endDate->sub($conference->durationInterval);
+ $endDate->add($conference->durationInterval);
return [
'id' => 'meeting_'.$conference->getId(),
diff --git a/plugin/zoom/join_meeting.php b/plugin/zoom/join_meeting.php
index 6ed4d4e867..24e5df18c1 100644
--- a/plugin/zoom/join_meeting.php
+++ b/plugin/zoom/join_meeting.php
@@ -38,6 +38,7 @@ if ($meeting->isCourseMeeting()) {
$startJoinURL = '';
$detailsURL = '';
$signature = '';
+$btnAnnouncement = '';
$currentUser = api_get_user_entity(api_get_user_id());
$isConferenceManager = $plugin->userIsConferenceManager($meeting);
@@ -60,6 +61,35 @@ try {
if ($isConferenceManager) {
$detailsURL = api_get_path(WEB_PLUGIN_PATH).'zoom/meeting.php?meetingId='.$meeting->getMeetingId();
}
+
+ if (api_is_platform_admin()) {
+ $announcementUrl = '';
+
+ if ($announcement = $meeting->getSysAnnouncement()) {
+ $announcementUrl = api_get_path(WEB_CODE_PATH).'admin/system_announcements.php?'
+ .http_build_query(
+ [
+ 'action' => 'edit',
+ 'id' => $announcement->getId(),
+ ]
+ );
+ } else {
+ $announcementUrl = api_get_path(WEB_CODE_PATH).'admin/system_announcements.php?'
+ .http_build_query(
+ [
+ 'action' => 'add',
+ 'type' => 'zoom_conference',
+ 'meeting' => $meeting->getMeetingId(),
+ ]
+ );
+ }
+
+ $btnAnnouncement = Display::toolbarButton(
+ $announcement ? get_lang('EditSystemAnnouncement') : get_lang('AddSystemAnnouncement'),
+ $announcementUrl,
+ 'bullhorn'
+ );
+ }
} catch (Exception $exception) {
Display::addFlash(
Display::return_message($exception->getMessage(), 'warning')
@@ -72,6 +102,7 @@ $tpl = new Template($meeting->getMeetingId());
$tpl->assign('meeting', $meeting);
$tpl->assign('start_url', $startJoinURL);
$tpl->assign('details_url', $detailsURL);
+$tpl->assign('btn_announcement', $btnAnnouncement);
$tpl->assign('is_conference_manager', $isConferenceManager);
$tpl->assign('signature', $signature);
$content = $tpl->fetch('zoom/view/join.tpl');
diff --git a/plugin/zoom/view/join.tpl b/plugin/zoom/view/join.tpl
index f24904baaa..368ae07203 100644
--- a/plugin/zoom/view/join.tpl
+++ b/plugin/zoom/view/join.tpl
@@ -190,3 +190,7 @@
{{ 'Details'|get_lang }}
{% endif %}
+
+{% if btn_announcement %}
+ {{ btn_announcement }}
+{% endif %}