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/README.md b/plugin/zoom/README.md index 941ac5ddc5..d41620b68d 100644 --- a/plugin/zoom/README.md +++ b/plugin/zoom/README.md @@ -37,10 +37,16 @@ required to authenticate with JWT. To get them, create a JWT App: ## Changelog +**v0.5** + +* Added the ability to create a system announcement. + **v0.4** -Added signed attendance to allow you to configure an attendance sheet where participants register their signature. The +* The creation of webinars is now allowed. +* Added signed attendance to allow you to configure an attendance sheet where participants register their signature. The signed attendance functionality is similar to that found in the Exercise Signature plugin but does not reuse it. +* Allows you to use multiple accounts and subaccounts to create meetings/webinars ## Meetings - Webinars @@ -77,16 +83,21 @@ For a non-paying Zoom user, this plugin still works but participants will join a The user that starts the meeting/webinar will be identified as the Zoom account that is defined in the plugin. Socreate a generic account that works for all the users that start meetings. -# Changelog +# Databace changelog -## v0.4 +Please, execute this queries in your database: -* The creation of webinars is now allowed. -* Allows you to use multiple accounts and subaccounts to create meetings/webinars +**Updating to v0.5 from v.0.4** -**Updating to v0.4 from v0.3** +```sql +ALTER TABLE plugin_zoom_meeting + ADD sys_announcement_id INT DEFAULT NULL; +ALTER TABLE plugin_zoom_meeting + ADD CONSTRAINT FK_3448092778FB10C FOREIGN KEY (sys_announcement_id) REFERENCES sys_announcement (id) ON DELETE SET NULL; +CREATE INDEX IDX_3448092778FB10C ON plugin_zoom_meeting (sys_announcement_id); +``` -Please, execute this queries in your database: +**Updating to v0.4 from v0.3** ```sql ALTER TABLE plugin_zoom_meeting 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/lib/ZoomPlugin.php b/plugin/zoom/lib/ZoomPlugin.php index 1ee6b2cc70..721e52181b 100644 --- a/plugin/zoom/lib/ZoomPlugin.php +++ b/plugin/zoom/lib/ZoomPlugin.php @@ -53,7 +53,7 @@ class ZoomPlugin extends Plugin public function __construct() { parent::__construct( - '0.4', + '0.5', 'Sébastien Ducoulombier, Julio Montoya, Angel Fernando Quiroz Campos', [ 'tool_enable' => 'boolean', @@ -93,7 +93,7 @@ class ZoomPlugin extends Plugin * * @return ZoomPlugin the instance to use */ - public static function create() + public static function create(): ZoomPlugin { static $instance = null; 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 %}