From 872381995dbcd77b90ac5175ffc7ba51ec75c42a Mon Sep 17 00:00:00 2001
From: Kevin Jardine
Date: Thu, 26 Apr 2012 16:21:00 +0200
Subject: Merges in BBB web conference functionality from now defunct
sched_conf plugin
---
languages/en.php | 10 +++
models/model.php | 79 ++++++++++++++++++++--
views/default/event_calendar/conference_button.php | 32 +++++++++
views/default/forms/event_calendar/edit.php | 9 ++-
views/default/object/event_calendar.php | 4 ++
views/default/plugins/event_calendar/settings.php | 26 +++++++
6 files changed, 152 insertions(+), 8 deletions(-)
create mode 100644 views/default/event_calendar/conference_button.php
diff --git a/languages/en.php b/languages/en.php
index d4cb8ac9e..e23d78924 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -318,6 +318,16 @@ takes place at
You can visit the event page here:
%s
",
+
+ /**
+ * BBB support
+ */
+
+ 'event_calendar:bbb_server_url' => "Big Blue Button server URL (must end with slash)",
+ 'event_calendar:bbb_security_salt' => "Big Blue Button security salt",
+ 'event_calendar:bbb_create_error' => "Error: unable to create BBB conference, message was: %s",
+ 'event_calendar:bbb_settings_error' => "Error: must set conference URL and salt in plugin settings",
+ 'event_calendar:join_conf_button' => "Join conference",
/**
* Event calendar river
diff --git a/models/model.php b/models/model.php
index 0dd72a595..cf00c4b1c 100644
--- a/models/model.php
+++ b/models/model.php
@@ -152,6 +152,7 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) {
$event->send_reminder = get_input('send_reminder');
$event->reminder_number = get_input('reminder_number');
$event->reminder_interval = get_input('reminder_interval');
+ $event->web_conference = get_input('web_conference');
$event->real_end_time = event_calendar_get_end_time($event);
foreach ($required_fields as $fn) {
if (!trim($event->$fn)) {
@@ -160,6 +161,9 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) {
}
}
if ($event->save()) {
+ if (!$event_guid && $event->web_conference) {
+ event_calendar_create_bbb_conf($event);
+ }
if ($group_guid && (elgg_get_plugin_setting('autogroup', 'event_calendar') == 'yes')) {
event_calendar_add_personal_events_from_group($event->guid,$group_guid);
}
@@ -173,12 +177,12 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) {
event_calendar_add_personal_event($event->guid,$user_id);
if (elgg_get_plugin_setting('add_users_notify', 'event_calendar') == 'yes') {
notify_user($user_id, $CONFIG->site->guid, elgg_echo('event_calendar:add_users_notify:subject'),
- sprintf(
- elgg_echo('event_calendar:add_users_notify:body'),
- $user->name,
- $event->title,
- $event->getURL()
- )
+ sprintf(
+ elgg_echo('event_calendar:add_users_notify:body'),
+ $user->name,
+ $event->title,
+ $event->getURL()
+ )
);
}
}
@@ -1598,6 +1602,7 @@ function event_calendar_prepare_edit_form_vars($event = NULL) {
'event-calendar-repeating-saturday-value' => 0,
'event-calendar-repeating-sunday-value' => 0,
'personal_manage' => 'open',
+ 'web_conference' => NULL,
'long_description' => NULL,
'access_id' => ACCESS_DEFAULT,
'group_guid' => NULL,
@@ -2210,3 +2215,65 @@ function event_calendar_queue_reminder($e) {
message_queue_set_for_sending($m->guid);
}
}
+
+function event_calendar_create_bbb_conf($event) {
+ $bbb_security_salt = elgg_get_plugin_setting('bbb_security_salt','event_calendar');
+ $bbb_server_url = rtrim(elgg_get_plugin_setting('bbb_server_url','event_calendar'), '/') . '/';
+ if ($bbb_security_salt) {
+ $day_in_minutes = 60*24;
+ $duration = (int)(($event->real_end_time-$event->start_date)/60)+$day_in_minutes;
+ $title = urlencode($event->title);
+ $params = "name=$title&meetingID={$event->guid}&duration=$duration";
+ $checksum = sha1('create'.$params.$bbb_security_salt);
+ $params .= "&checksum=$checksum";
+
+ // create curl resource
+ $ch = curl_init();
+
+ // set url
+ curl_setopt($ch, CURLOPT_URL, $bbb_server_url.'api/create?'.$params);
+
+ //return the transfer as a string
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+ // $output contains the output string
+ $output = curl_exec($ch);
+
+ // close curl resource to free up system resources
+ curl_close($ch);
+
+ /*error_log("BBB create request:");
+ error_log($bbb_server_url.'api/create?'.$params);
+
+ error_log("BBB create response:");
+ error_log($output);*/
+
+ $xml = new SimpleXMLElement($output);
+ if ($xml->returncode == 'SUCCESS') {
+ $event->bbb_attendee_password = (string) $xml->attendeePW;
+ $event->bbb_moderator_password = (string) $xml->moderatorPW;
+ } else {
+ register_error(elgg_echo('event_calendar:bbb_create_error',array($xml->message)));
+ }
+ } else {
+ register_error(elgg_echo('event_calendar:bbb_settings_error'));
+ }
+}
+
+function event_calendar_get_join_bbb_url($event) {
+ $bbb_security_salt = elgg_get_plugin_setting('bbb_security_salt','event_calendar');
+ $bbb_server_url = rtrim(elgg_get_plugin_setting('bbb_server_url','event_calendar'), '/') . '/';
+ $user = elgg_get_logged_in_user_entity();
+ $full_name = urlencode($user->name);
+ if ($event->canEdit()) {
+ $password = urlencode($event->bbb_moderator_password);
+ } else {
+ $password = urlencode($event->bbb_attendee_password);
+ }
+ $params = "fullName=$full_name&meetingID={$event->guid}&userID={$user->username}&password=$password";
+ $checksum = sha1('join'.$params.$bbb_security_salt);
+ $params .= "&checksum=$checksum";
+ $url = $bbb_server_url.'api/join?'.$params;
+ return $url;
+}
+
diff --git a/views/default/event_calendar/conference_button.php b/views/default/event_calendar/conference_button.php
new file mode 100644
index 000000000..f6fedf4f6
--- /dev/null
+++ b/views/default/event_calendar/conference_button.php
@@ -0,0 +1,32 @@
+real_end_time + 60*60*24;
+ if ($termination_time < time()) {
+ $in_time_window = FALSE;
+ } else if ($event->canEdit()) {
+ $in_time_window = TRUE;
+ } else if (event_calendar_has_personal_event($event->guid, $user_guid) && ($event->start_date - 15*60) >= time()) {
+ $in_time_window = TRUE;
+ } else {
+ $in_time_window = FALSE;
+ }
+ if ( $in_time_window ) {
+ $button = elgg_view('output/url', array(
+ 'href' => event_calendar_get_join_bbb_url($event),
+ 'text' => elgg_echo('event_calendar:join_conf_button'),
+ 'class' => 'elgg-button elgg-button-action',
+ 'target' => '_blank',
+ ));
+
+ echo ''.$button.'
';
+ }
+}
diff --git a/views/default/forms/event_calendar/edit.php b/views/default/forms/event_calendar/edit.php
index 260e8afe0..79e2a5d0b 100644
--- a/views/default/forms/event_calendar/edit.php
+++ b/views/default/forms/event_calendar/edit.php
@@ -26,6 +26,7 @@ $event_calendar_more_required = elgg_get_plugin_setting('more_required', 'event_
$event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
$event_calendar_repeated_events = elgg_get_plugin_setting('repeated_events', 'event_calendar');
$event_calendar_reminders = elgg_get_plugin_setting('reminders', 'event_calendar');
+$event_calendar_bbb_server_url = elgg_get_plugin_setting('bbb_server_url', 'event_calendar');
if ($event_calendar_more_required == 'yes') {
$required_fields = array('title','venue','start_date','start_time',
@@ -168,9 +169,13 @@ $body .= elgg_view('event_calendar/container',array('container_guid'=>$vars['con
$body .= '
';
$body .= ''.$prefix['calendar'].elgg_echo('event_calendar:calendar_description').'
';
-if(elgg_plugin_exists('sched_conf')) {
+if($event_calendar_bbb_server_url) {
$body .= '';
- $body .= elgg_view('input/checkbox',array('name'=>'web_conference','value'=>$web_conference,'options_values'=>array('1')));
+ if ($fd['web_conference']) {
+ $body .= elgg_view('input/checkbox',array('name'=>'web_conference','value'=>1,'checked'=>'checked'));
+ } else {
+ $body .= elgg_view('input/checkbox',array('name'=>'web_conference','value'=>1));
+ }
$body .= elgg_echo('event_calendar:web_conference_label');
$body .= '
';
}
diff --git a/views/default/object/event_calendar.php b/views/default/object/event_calendar.php
index 717e2803e..b72c869ea 100644
--- a/views/default/object/event_calendar.php
+++ b/views/default/object/event_calendar.php
@@ -16,6 +16,10 @@ $full = elgg_extract('full_view', $vars, FALSE);
if ($full) {
$body = elgg_view('event_calendar/strapline',$vars);
+ if ($event->web_conference) {
+ $body .= '
';
+ $body .= elgg_view('event_calendar/conference_button',array('event'=>$event));
+ }
$event_items = event_calendar_get_formatted_full_items($event);
$body .= '
';
diff --git a/views/default/plugins/event_calendar/settings.php b/views/default/plugins/event_calendar/settings.php
index 908818998..2a2e043de 100644
--- a/views/default/plugins/event_calendar/settings.php
+++ b/views/default/plugins/event_calendar/settings.php
@@ -445,4 +445,30 @@ $body .= elgg_echo('event_calendar:ical_auth_file_name:title');
$body .= '
';
$body .= elgg_view('input/text',array('name'=>'params[ical_auth_file_name]','value'=>$ical_auth_file_name, 'class'=>'event-calendar-ical-auth-setting'));
+$body .= '
';
+
+$event_calendar_bbb_server_url = elgg_get_plugin_setting('bbb_server_url', 'event_calendar');
+
+$body .= elgg_echo('event_calendar:bbb_server_url');
+$body .= '
';
+$body .= elgg_view('input/text', array(
+ 'name' => 'params[bbb_server_url]',
+ 'value' => $event_calendar_bbb_server_url,
+ 'class' => 'text_input',
+));
+
+$body .= '
';
+
+$event_calendar_bbb_security_salt = elgg_get_plugin_setting('bbb_security_salt', 'event_calendar');
+
+$body .= elgg_echo('event_calendar:bbb_security_salt');
+$body .= '
';
+$body .= elgg_view('input/text', array(
+ 'name' => 'params[bbb_security_salt]',
+ 'value' => $event_calendar_bbb_security_salt,
+ 'class' => 'text_input',
+));
+
+$body .= '
';
+
echo $body;
--
cgit v1.2.3