From ee02e434af73eb8986b3a43cffb92c42651ac577 Mon Sep 17 00:00:00 2001
From: PanosParalakis
Date: Wed, 5 Nov 2014 16:28:54 +0000
Subject: [PATCH] Created renderer Fixed WYSIWYG settings editors (Description,
Agenda)
---
ChangeLog.txt | 2 +-
editattendees.php | 48 ++--
lib.php | 129 ++++++++++-
mod_form.php | 89 +++++--
renderer.php | 577 ++++++++++++++++++++++++++++++++++++++++++++++
signup.php | 14 +-
signupmeeting.php | 6 +-
updatemeeting.php | 22 +-
version.php | 4 +-
view.php | 470 +------------------------------------
10 files changed, 830 insertions(+), 531 deletions(-)
create mode 100644 renderer.php
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 9c1382d..a218a4d 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,4 +1,4 @@
-
+2.1 (2014-05-22) - Panos Paralakis - Fixed WYSIWYG settings editors and added missing renderer file and logic
2.0 (2014-05-22) - Moodle 2.6 release, support for Adobe Connect 9 added
1.2 (2012-10-29) - Backup / restore functionality included, fixes made to enable single host Adobe Connect accounts
1.1 (2012-08-21) - Portuguese/Brazilian translation provided by Herbert de Carvalho
diff --git a/editattendees.php b/editattendees.php
index 7ae9885..38c8d42 100644
--- a/editattendees.php
+++ b/editattendees.php
@@ -71,7 +71,7 @@
// Check if we are waitlisting or booking
//if ($session->datetimeknown) {
// $status = WEBINAR_STATUS_BOOKED;
- //}
+ //}
//else {
$status = WEBINAR_STATUS_WAITLISTED;
//}
@@ -84,7 +84,7 @@
else {
//Sign up user to this webinar through Adobe Connect API call
signup_meeting($webinar, $session, $user);
-
+
//Send registration email to user
send_email_signup($webinar, $session, $cm, $user);
}
@@ -115,12 +115,12 @@
// Update attendees
webinar_update_attendees($session);
-
+
$user = $DB->get_record('user', array('id' => $removeuser));
-
+
//Unregister this user from this webinar through Adobe Connect API call
cancelsignup_meeting($webinar, $session, $user);
-
+
//Send cancel registration email to user
send_email_cancelsignup($webinar, $session, $cm, $user);
}
@@ -140,7 +140,7 @@
$navigation = build_navigation($navlinks);
/*print_header_simple($pagetitle, '', $navigation, '', '', true,
update_module_button($cm->id, $course->id, $strwebinar), navmenu($course, $cm));*/
-
+
$PAGE->set_pagetype('webinar');
$PAGE->set_title($webinar->name);
$PAGE->set_heading($webinar->name);
@@ -171,24 +171,24 @@
/// All non-signed up system users
-$availableusers = $DB->get_recordset_sql('SELECT u.id, u.firstname, u.lastname, u.email
- FROM '.$CFG->prefix.'user u, '.$CFG->prefix.'enrol e, '.$CFG->prefix.'user_enrolments ue
- WHERE
+$availableusers = $DB->get_recordset_sql('SELECT u.id, u.firstname, u.lastname, u.email
+ FROM '.$CFG->prefix.'user u, '.$CFG->prefix.'enrol e, '.$CFG->prefix.'user_enrolments ue
+ WHERE
e.courseid = '.$course->id.'
- AND
- ue.enrolid = e.id
- AND
- u.id = ue.userid
- ORDER BY u.lastname ASC, u.firstname ASC');
-
+ AND
+ ue.enrolid = e.id
+ AND
+ u.id = ue.userid
+ ORDER BY u.lastname ASC, u.firstname ASC');
+
$availablecount = $DB->get_recordset_sql('SELECT COUNT(u.id) AS avusers
- FROM '.$CFG->prefix.'user u, '.$CFG->prefix.'enrol e, '.$CFG->prefix.'user_enrolments ue
- WHERE
+ FROM '.$CFG->prefix.'user u, '.$CFG->prefix.'enrol e, '.$CFG->prefix.'user_enrolments ue
+ WHERE
e.courseid = '.$course->id.'
- AND
- ue.enrolid = e.id
- AND
- u.id = ue.userid');
+ AND
+ ue.enrolid = e.id
+ AND
+ u.id = ue.userid');
foreach ($availablecount as $ac) {
$potential_users = $ac->avusers;
@@ -237,13 +237,13 @@
if ($na_rs = $DB->get_recordset_sql($nonattendees_sql)) {
foreach ($na_rs as $record) {
$data[] = $record->firstname . ' ' . $record->lastname;
-
+
$data[] = $record->email;
//$data[] = get_string('status_'.webinar_get_status($user->statuscode), 'webinar');
-
+
$table->data[] = $data;
}
-
+
$na_rs->close();
}
diff --git a/lib.php b/lib.php
index 3a3c89b..c12ca29 100644
--- a/lib.php
+++ b/lib.php
@@ -256,11 +256,42 @@ function webinar_add_instance($webinar) {
global $DB;
$webinar->timemodified = time();
+ $cmid = $webinar->coursemodule;
+ $context = context_module::instance($cmid);
webinar_fix_settings($webinar);
if ($webinar->id = $DB->insert_record('webinar', $webinar)) {
webinar_grade_item_update($webinar);
}
+
+ if (!empty($webinar->description['itemid'])) {
+
+ $draftitemid = file_get_submitted_draft_itemid('description');
+
+ $file = file_save_draft_area_files($draftitemid, $context->id, 'mod_webinar', 'description', $webinar->id, webinar_get_editor_options($context), $webinar->description['text']);
+
+ $text = file_rewrite_pluginfile_urls($file, 'pluginfile.php',
+ $context->id, 'mod_webinar', 'description', $webinar->id);
+
+ $webinar->description = $text;
+
+ $DB->update_record('webinar', $webinar);
+ }
+
+ if (!empty($webinar->agenda['itemid'])) {
+
+ $draftitemid = file_get_submitted_draft_itemid('itemid');
+
+ $file = file_save_draft_area_files($draftitemid, $context->id, 'mod_webinar', 'agenda', $webinar->id, webinar_get_editor_options($context), $webinar->agenda['text']);
+
+ $text = file_rewrite_pluginfile_urls($file, 'pluginfile.php',
+ $context->id, 'mod_webinar', 'agenda', $webinar->id);
+
+ $webinar->agenda = $text;
+
+ $DB->update_record('webinar', $webinar);
+ }
+
return $webinar->id;
}
@@ -269,18 +300,53 @@ function webinar_add_instance($webinar) {
* form in mod.html) this function will update an existing instance
* with new data.
*/
-function webinar_update_instance($webinar) {
+function webinar_update_instance($webinar, $mform = null) {
global $DB;
$webinar->id = $webinar->instance;
+ $cmid = $webinar->coursemodule;
+ $context = context_module::instance($cmid);
+
webinar_fix_settings($webinar);
if ($return = $DB->update_record('webinar', $webinar)) {
webinar_grade_item_update($webinar);
}
+
+ if (is_array($webinar->description) && $webinar->description['itemid']!='') {
+
+ $draftitemid = file_get_submitted_draft_itemid('description');
+
+ $file = file_save_draft_area_files($draftitemid, $context->id, 'mod_webinar', 'description', $webinar->id, webinar_get_editor_options($context), $webinar->description['text']);
+
+ $text = file_rewrite_pluginfile_urls($file, 'pluginfile.php',
+ $context->id, 'mod_webinar', 'description', $webinar->id);
+
+ $webinar->description = $text;
+
+ $DB->update_record('webinar', $webinar);
+
+ }
+
+ if (is_array($webinar->agenda) && $webinar->agenda['itemid']!='') {
+
+ $draftitemid = file_get_submitted_draft_itemid('itemid');
+
+ $file = file_save_draft_area_files($draftitemid, $context->id, 'mod_webinar', 'agenda', $webinar->id, webinar_get_editor_options($context), $webinar->agenda['text']);
+
+ $text = file_rewrite_pluginfile_urls($file, 'pluginfile.php',
+ $context->id, 'mod_webinar', 'agenda', $webinar->id);
+
+ $webinar->agenda = $text;
+
+ $DB->update_record('webinar', $webinar);
+ }
+
+
return $return;
}
+
/**
* Given an ID of an instance of this module, this function will
* permanently delete the instance and any data that depends on it.
@@ -709,7 +775,7 @@ function webinar_email_substitutions($msg, $webinarname, $reminderperiod, $user,
$msg = str_replace($placeholder, $data, $msg);
}
- $msg = str_replace('£','£',$msg);
+ $msg = str_replace('£','�',$msg);
return $msg;
}
@@ -802,6 +868,7 @@ function webinar_get_sessions($webinarid, $location='')
$fromclause = "FROM {$CFG->prefix}webinar_sessions s";
$locationwhere = '';
+
if (!empty($location)) {
$fromclause = "FROM {$CFG->prefix}webinar_session_data d
JOIN {$CFG->prefix}webinar_sessions s ON s.id = d.sessionid";
@@ -3666,4 +3733,62 @@ function webinar_supports($feature) {
case FEATURE_BACKUP_MOODLE2: return true;
default: return null;
}
+}
+
+function webinar_get_editor_options($context) {
+
+ return array('subdirs'=>false,
+ 'maxfiles'=>EDITOR_UNLIMITED_FILES,
+ 'trusttext'=>false,
+ 'forcehttps' => false,
+ 'context'=>$context,
+ 'maxbytes' => 0,
+ 'changeformat' => 0,
+ 'noclean' => false);
+}
+
+function webinar_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
+ // Check the contextlevel is as expected - if your plugin is a block, this becomes CONTEXT_BLOCK, etc.
+ if ($context->contextlevel != CONTEXT_MODULE) {
+ return false;
+ }
+
+ // Make sure the filearea is one of those used by the plugin.
+ if ($filearea !== 'description' && $filearea !== 'agenda') {
+ return false;
+ }
+
+ // Make sure the user is logged in and has access to the module (plugins that are not course modules should leave out the 'cm' part).
+ require_login($course, true, $cm);
+
+ // Check the relevant capabilities - these may vary depending on the filearea being accessed.
+ if (!has_capability('mod/webinar:view', $context)) {
+ return false;
+ }
+
+ // Leave this line out if you set the itemid to null in make_pluginfile_url (set $itemid to 0 instead).
+ $itemid = array_shift($args); // The first item in the $args array.
+
+ // Use the itemid to retrieve any relevant data records and perform any security checks to see if the
+ // user really does have access to the file in question.
+
+ // Extract the filename / filepath from the $args array.
+ $filename = array_pop($args); // The last item in the $args array.
+ if (!$args) {
+ $filepath = '/'; // $args is empty => the path is '/'
+ } else {
+ $filepath = '/'.implode('/', $args).'/'; // $args contains elements of the filepath
+ }
+
+ // Retrieve the file from the Files API.
+ $fs = get_file_storage();
+ $file = $fs->get_file($context->id, 'mod_webinar', $filearea, $itemid, $filepath, $filename);
+ if (!$file) {
+ return false; // The file does not exist.
+ }
+
+ // We can now send the file back to the browser - in this case with a cache lifetime of 1 day and no filtering.
+ // From Moodle 2.3, use send_stored_file instead.
+ send_file($file, $filename);
+
}
\ No newline at end of file
diff --git a/mod_form.php b/mod_form.php
index ccca82a..736660c 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -8,10 +8,10 @@ function definition()
{
global $CFG;
- $cfg_webinar = get_config('webinar');
- //print_r($cfg_webinar);
-
- $mform =& $this->_form;
+ $cfg_webinar = get_config('webinar');
+ //print_r($cfg_webinar);
+
+ $mform =&$this->_form;
// GENERAL
$mform->addElement('header', 'general', get_string('general', 'form'));
@@ -22,33 +22,91 @@ function definition()
} else {
$mform->setType('name', PARAM_CLEAN);
}
+
$mform->addRule('name', null, 'required', null, 'client');
- $mform->addElement('htmleditor', 'description', get_string('description'), array('rows' => 10, 'cols' => 64));
+
+ /*
+ * Panos Paralakis - 3/11/2014
+ * Update WYSIWYG editor renders so to support file browsing
+ */
+
+ // Old
+ //$mform->addElement('htmleditor', 'description', get_string('description'), array('rows' => 10, 'cols' => 64));
+
+ // Update 3/11/2014
+ $editoroptions = webinar_get_editor_options($this->context);
+
+ $mform->addElement('editor', 'description', get_string('description'), null, $editoroptions);
+
$mform->setType('description', PARAM_RAW);
+
//$mform->setHelpButton('description', array('description', get_string('description'), 'webinar'));
$mform->disabledIf('description', 'showoncalendar');
- $mform->addElement('htmleditor', 'agenda', 'Agenda', array('rows' => 10, 'cols' => 64));
+ // Added on update 3/11/2014
+ if ($required) {
+ $mform->addRule('description', get_string('required'), 'required', null, 'client');
+ }
+
+ // Old
+ //$mform->addElement('htmleditor', 'agenda', 'Agenda', array('rows' => 10, 'cols' => 64));
+
+ // Update 3/11/2014
+ $mform->addElement('editor', 'agenda', 'Agenda', null, $editoroptions);
$mform->setType('agenda', PARAM_RAW);
+
//$mform->setHelpButton('agenda', array('agenda', get_string('agenda'), 'webinar'));
$mform->disabledIf('agenda', 'showoncalendar');
- //-------------------------------------------------------------------------------
- // Other Settings
+ // Added on update 3/11/2014
+ if ($required) {
+ $mform->addRule('agenda', get_string('required'), 'required', null, 'client');
+ }
+
+ //-------------------------------------------------------------------------------
+ // Other Settings
//$mform->addElement('header', 'advanced', get_string('othersettings', 'form'));
-
- $mform->addElement('hidden', 'sitexmlapiurl', $cfg_webinar->sitexmlapiurl);
- $mform->addElement('hidden', 'adminpassword', $cfg_webinar->adminpassword);
- $mform->addElement('hidden', 'adminemail', $cfg_webinar->adminemail);
- $this->standard_coursemodule_elements();
-
+ $mform->addElement('hidden', 'sitexmlapiurl', $cfg_webinar->sitexmlapiurl);
+ $mform->addElement('hidden', 'adminpassword', $cfg_webinar->adminpassword);
+ $mform->addElement('hidden', 'adminemail', $cfg_webinar->adminemail);
+
+ $this->standard_coursemodule_elements();
+
$this->add_action_buttons();
+
}
function data_preprocessing(&$default_values)
{
+ $editoroptions = webinar_get_editor_options($this->context);
+
+ if ($this->current->instance) {
+ // editing an existing webinar - let us prepare the added editor elements (intro done automatically)
+ $draftitemid = file_get_submitted_draft_itemid('description');
+ $currenttext = file_prepare_draft_area($draftitemid,
+ $this->context->id,
+ 'mod_webinar',
+ 'description',
+ false,
+ $editoroptions,
+ $default_values['description']);
+ $default_values['description'] = array('text'=>$currenttext, 'format'=>FORMAT_HTML, 'itemid'=>$draftitemid);
+
+ $draftitemid = file_get_submitted_draft_itemid('agenda');
+ $currenttext = file_prepare_draft_area($draftitemid,
+ $this->context->id,
+ 'mod_webinar',
+ 'agenda',
+ false,
+ $editoroptions,
+ $default_values['agenda']);
+ $default_values['agenda'] = array('text'=>$currenttext, 'format'=>FORMAT_HTML, 'itemid'=>$draftitemid);
+
+ }
+
+
// Fix manager emails
if (empty($default_values['confirmationinstrmngr'])) {
$default_values['confirmationinstrmngr'] = null;
@@ -71,4 +129,5 @@ function data_preprocessing(&$default_values)
$default_values['emailmanagercancellation'] = 1;
}
}
-}
+
+}
\ No newline at end of file
diff --git a/renderer.php b/renderer.php
new file mode 100644
index 0000000..5da0da5
--- /dev/null
+++ b/renderer.php
@@ -0,0 +1,577 @@
+.
+
+/**
+ * Defines the renderer for the webinar module.
+ *
+ * @package mod
+ * @subpackage webinar
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+
+/**
+ * The renderer for the webinar module.
+ *
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class mod_webinar_renderer extends plugin_renderer_base {
+
+
+ /**
+ * View Page
+ * Generates the view page
+ *
+ * @param int $course The id of the course
+ * @param array $webinar Array conting webinar data
+ * @param int $cm Course Module ID
+ * @param int $context The page context ID
+ * @param string $location
+ * @param mod_webinar_view_object $viewobj
+ * @author Panagiotis Paralakis
+ */
+ public function view_page($course, $webinar, $cm, $context, $location, $viewobj = null) {
+
+ $output = '';
+ $output .= $this->view_information($webinar, $cm, $context, $viewobj->infomessages);
+ $output .= $this->view_locations($webinar,$location);
+ $output .= $this->get_session_list($cm, $webinar, $location, $context);
+
+ return $output;
+ }
+
+ /**
+ * Output the page information
+ *
+ * @param object $webinar the webinar settings.
+ * @param object $cm the course_module object.
+ * @param object $context the webinar context.
+ * @param array $messages any access messages that should be described.
+ * @return string HTML to output.
+ */
+ public function view_information($webinar, $cm, $context, $messages) {
+ global $CFG;
+
+ $output = '';
+
+ // Print webinar name and description.
+ $output .= $this->heading(format_string($webinar->name));
+ $output .= $this->settings($webinar);
+
+ // Output any access messages.
+ if ($messages) {
+ $output .= $this->box($this->access_messages($messages), 'webinarinfo');
+ }
+
+ return $output;
+ }
+
+ /**
+ * Output the page information
+ *
+ * @param object $webinar the webinar settings.
+ * @return string HTML to output.
+ */
+ public function settings($webinar) {
+
+ $table = new html_table();
+ $table->attributes['class'] = 'table';
+
+ $row = new html_table_row();
+
+ $cell1 = new html_table_cell('Description:');
+ $cell1->attributes['valign'] = 'top';
+
+ $cell2 = new html_table_cell(' ');
+ $cell3 = new html_table_cell($webinar->description);
+
+ $row->cells = array($cell1,$cell2,$cell3);
+ $table->data[] = $row;
+
+ $row = new html_table_row();
+
+ $cell1 = new html_table_cell('Agenda:');
+ $cell1->attributes['valign'] = 'top';
+
+ $cell2 = new html_table_cell(' ');
+ $cell3 = new html_table_cell($webinar->agenda);
+
+ $row->cells = array($cell1,$cell2,$cell3);
+ $table->data[] = $row;
+
+ return html_writer::table($table);
+ }
+
+
+ /**
+ * Output the page information
+ *
+ * @param object $webinar the webinar settings.
+ * @return string HTML to output.
+ */
+ public function view_locations($webinar) {
+
+ $output = '';
+
+ $locations = $this->get_locations($webinar->id,$location);
+
+ if (count($locations) > 2) {
+ $output .= '';
+ }
+
+ return $output;
+
+ }
+
+ /**
+ * Get webinar locations
+ *
+ * @param interger $webinarid
+ * @return array
+ */
+ public function get_locations($webinarid)
+ {
+ global $CFG, $DB;
+
+ $locationfieldid = $DB->get_field('webinar_session_field', 'id', array('shortname' => 'location'));
+ if (!$locationfieldid) {
+ return array();
+ }
+
+ $sql = "SELECT DISTINCT d.data AS location
+ FROM {$CFG->prefix}webinar f
+ JOIN {$CFG->prefix}webinar_sessions s ON s.webinar = f.id
+ JOIN {$CFG->prefix}webinar_session_data d ON d.sessionid = s.id
+ WHERE f.id = $webinarid AND d.fieldid = $locationfieldid";
+
+ if ($records = $DB->get_records_sql($sql)) {
+ $locationmenu[''] = get_string('alllocations', 'webinar');
+
+ $i=1;
+ foreach ($records as $record) {
+ $locationmenu[$record->location] = $record->location;
+ $i++;
+ }
+
+ return $locationmenu;
+ }
+
+ return array();
+ }
+
+
+ /**
+ * Generates the sesseions table of data
+ *
+ * @param array $courseid int course id
+ * @param mod_webinar_view_object $viewobj
+ * @param string_$location
+ * @param obj $context The page context
+ */
+ public function get_session_list($courseid, $webinar, $location, $context)
+ {
+ global $USER;
+ global $CFG;
+ global $DB;
+
+ $output = '';
+
+ $timenow = time();
+
+ $webinarid = $webinar->id;
+
+ $viewattendees = has_capability('mod/webinar:viewattendees', $context);
+
+ $editsessions = has_capability('mod/webinar:editsessions', $context);
+
+ $customfields = webinar_get_session_customfields();
+
+ // Table headers
+ $tableheader = array();
+ foreach ($customfields as $field) {
+ if (!empty($field->showinsummary)) {
+ $tableheader[] = format_string($field->name);
+ }
+ }
+
+ // echo '';
+
+ $tableheader[] = get_string('startdatetime', 'webinar');
+ $tableheader[] = get_string('finishdatetime', 'webinar');
+ $tableheader[] = get_string('presenter', 'webinar');
+ $tableheader[] = get_string('maximumattendees', 'webinar');
+ $tableheader[] = get_string('confirmed', 'webinar');
+ $tableheader[] = get_string('status', 'webinar');
+ $tableheader[] = get_string('options', 'webinar');
+
+ $upcomingdata = array();
+ $upcomingtbddata = array();
+ $previousdata = array();
+ $upcomingrowclass = array();
+ $upcomingtbdrowclass = array();
+ $previousrowclass = array();
+
+ if ($sessions = webinar_get_sessions($webinarid, $location) ) {
+
+ // TODO - Break down this code to generate and display methods
+
+ foreach($sessions as $session) {
+ $sessionrow = array();
+
+ $sessionstarted = false;
+ $sessionfull = false;
+ $sessionwaitlisted = false;
+ $isbookedsession = false;
+
+ $bookedsession = null;
+ if ($submissions = webinar_session_get_user_submissions($webinarid, $USER->id, $session->id)) {
+ $submission = array_shift($submissions);
+ $bookedsession = $submission;
+ }
+
+ // Custom fields
+ $customdata = $DB->get_records('webinar_session_data', array('sessionid' => $session->id), 'fieldid, data');
+ foreach ($customfields as $field) {
+ if (empty($field->showinsummary)) {
+ continue;
+ }
+
+ if (empty($customdata[$field->id])) {
+ $sessionrow[] = ' ';
+ }
+ else {
+ $sessionrow[] = format_string($customdata[$field->id]->data);
+ }
+ }
+
+ foreach ($session->sessiondates as $date) {
+ $sessionstart = date('d F Y h:i A', $date->timestart);
+ $sessionfinish = date('d F Y h:i A', $date->timefinish);
+ }
+
+ $sessionrow[] = $sessionstart;
+ $sessionrow[] = $sessionfinish;
+
+ $presenter_name = $DB->get_records_sql("SELECT
+ u.firstname,
+ u.lastname
+ FROM
+ {$CFG->prefix}user u
+ WHERE
+ u.id = $session->presenter
+ LIMIT 1");
+
+
+ if($presenter_name) {
+ foreach($presenter_name as $pname) {
+ $presenter = $pname->firstname . " " . $pname->lastname;
+ }
+ }
+ $sessionrow[] = $presenter;
+
+ // Capacity
+ $signupcount = webinar_get_num_attendees($session->id);
+
+ $sessionrow[] = $session->capacity;
+ $sessionrow[] = $signupcount;
+
+ // Status
+ $status = get_string('bookingopen', 'webinar');
+ if (webinar_has_session_started($session, $timenow) && webinar_is_session_in_progress($session, $timenow)) {
+
+ $status = get_string('sessioninprogress', 'webinar');
+ $sessionstarted = true;
+ }
+ elseif (webinar_has_session_started($session, $timenow)) {
+
+ $status = get_string('closed', 'webinar');
+ $sessionstarted = true;
+ }
+
+ elseif ($bookedsession) {
+ $signupstatus = webinar_get_status($bookedsession->statuscode);
+
+ $status = get_string('status_'.$signupstatus, 'webinar');
+ $isbookedsession = true;
+ }
+ elseif ($signupcount >= $session->capacity) {
+ $status = get_string('bookingfull', 'webinar');
+ $sessionfull = true;
+ }
+
+ $sessionrow[] = $status;
+
+ $url = $webinar->sitexmlapiurl . "?action=login&login=" . $USER->email . "&password=" . $webinar->adminpassword;
+
+ $ch=curl_init($url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+ $breeze_session_first_strip = strstr($response, 'BREEZESESSION');
+ $breeze_session_second_strip = strstr($breeze_session_first_strip, ';', true);
+ $breeze_session = str_replace('BREEZESESSION=', '', $breeze_session_second_strip);
+
+ // Create a stream for HTTP headers, including the BREEZESESSION cookie
+ $opts = array(
+ 'http'=>array(
+ 'method'=>"GET",
+ 'header'=>"Cookie: " . $breeze_session_second_strip . "\r\n"
+ )
+ );
+
+ $context = stream_context_create($opts);
+
+ $meetingurl = str_replace('/api/xml', '', $webinar->sitexmlapiurl) . $session->urlpath;
+ $meetingurlwithsession = $meetingurl . '?session=' . $breeze_session; //$session_value;
+
+ // Options
+ $options = '';
+ if ($editsessions) {
+ $options .= ' '
+ . '
'
+ . ''
+ . '
'
+ . ''
+ . '
';
+ }
+ if ($viewattendees){
+ $options .= '
'.get_string('attendees', 'webinar').'
';
+ }
+
+ if($status == 'Closed') {
+
+ //Give user permission to watch old recordings of a webinar by adding them as a participant
+ //To do this, we must first get their principal ID if they are already added to Adobe Connect, or if not, add them first
+ //Need to temporarily login as admin in order to do this
+
+ /*
+ $url = $webinar->sitexmlapiurl . "?action=login&login=" . $webinar->adminemail . "&password=" . $webinar->adminpassword . "&session=" . $session_value;
+ $xmlstr = file_get_contents($url);
+ $xml = new SimpleXMLElement($xmlstr);
+ */
+
+ $url = $webinar->sitexmlapiurl . "?action=login&login=" . $webinar->adminemail . "&password=" . $webinar->adminpassword;
+ $ch=curl_init($url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+ $breeze_session_first_strip = strstr($response, 'BREEZESESSION');
+ $breeze_session_second_strip = strstr($breeze_session_first_strip, ';', true);
+ $breeze_session = str_replace('BREEZESESSION=', '', $breeze_session_second_strip);
+
+ // Create a stream for HTTP headers, including the BREEZESESSION cookie
+ $opts = array(
+ 'http'=>array(
+ 'method'=>"GET",
+ 'header'=>"Cookie: " . $breeze_session_second_strip . "\r\n"
+ )
+ );
+
+ $context = stream_context_create($opts);
+
+ $url = $webinar->sitexmlapiurl . "?action=principal-list&filter-email=" . $USER->email; //. "&session=" . $session_value;
+ $xmlstr = file_get_contents($url, false, $context);
+ $xml = new SimpleXMLElement($xmlstr);
+
+ if ($xml->{'principal-list'}->principal) {
+ //User email address has been matched on Adobe Connect - get back their principal ID
+ foreach($xml->{'principal-list'}->principal->attributes() as $key => $val) {
+ if($key == 'principal-id') {
+ $principal_id = $val;
+ }
+ }
+ }
+ else {
+ //User email address is not registered yet with Adobe Connect - add them and get back the principal ID
+ $url = $webinar->sitexmlapiurl . "?action=principal-update&first-name=" . str_replace(' ', '%20', $USER->firstname) . "&last-name=" . str_replace(' ', '%20', $USER->lastname) . "&login=" . $USER->email .
+ "&password=" . $webinar->adminpassword . "&type=user&send-email=false&has-children=0&email=" . $USER->email; // . "&session=" . $session_value;
+
+ $xmlstr = file_get_contents($url, false, $context);
+ $xml = new SimpleXMLElement($xmlstr);
+
+ foreach($xml->principal->attributes() as $key => $val) {
+ if($key == 'principal-id') {
+ $principal_id = $val;
+ }
+ }
+ }
+
+ //Now, add user as a meeting participant using the principalID obtained above
+ $url = $webinar->sitexmlapiurl . "?action=permissions-update&principal-id=" . $principal_id . "&acl-id=" . $session->scoid . "&permission-id=view&session=" . $breeze_session; //$session_value;
+ $xmlstr = file_get_contents($url, false, $context);
+ $xml = new SimpleXMLElement($xmlstr);
+
+ //Login BACK in as user, after having logged in as admin to add current user as participant
+ /*
+ $url = $webinar->sitexmlapiurl . "?action=login&login=" . $USER->email . "&password=" . $webinar->adminpassword . "&session=" . $session_value;
+ $xmlstr = file_get_contents($url);
+ $xml = new SimpleXMLElement($xmlstr);
+ */
+
+ $url = $webinar->sitexmlapiurl . "?action=login&login=" . $USER->email . "&password=" . $webinar->adminpassword;
+ $ch=curl_init($url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+ $breeze_session_first_strip = strstr($response, 'BREEZESESSION');
+ $breeze_session_second_strip = strstr($breeze_session_first_strip, ';', true);
+ $breeze_session = str_replace('BREEZESESSION=', '', $breeze_session_second_strip);
+
+ // Create a stream for HTTP headers, including the BREEZESESSION cookie
+ $opts = array(
+ 'http'=>array(
+ 'method'=>"GET",
+ 'header'=>"Cookie: " . $breeze_session_second_strip . "\r\n"
+ )
+ );
+
+ $context = stream_context_create($opts);
+
+ //get back the recording URL path for the meeting SCO ID
+ $url = $webinar->sitexmlapiurl . "?action=sco-contents&sco-id=" . $session->scoid . "&filter-icon=archive"; //&session=" . $session_value;
+ $xmlstr = file_get_contents($url, false, $context);
+ $xml = new SimpleXMLElement($xmlstr);
+
+ foreach ($xml->scos->sco as $sco) {
+
+ $recording_urlpath = $sco->{'url-path'};
+ $recordingurl = str_replace('/api/xml', '', $webinar->sitexmlapiurl) . $recording_urlpath;
+ $recordingurlwithsession = $recordingurl . '?session=' . $breeze_session; //$session_value;
+
+ $options .= '' . get_string('viewrecording', 'webinar') . '
';
+ }
+ }
+
+ //check if the user is the presenter/host of the session - if so, allow them to join the session as host as they are already registered with Adobe Connect
+ if (($session->presenter == $USER->id) and (!$sessionstarted)) {
+ $options .= '' . get_string('joinwebinarashost', 'webinar') . '
';
+ $ishost = true;
+ }
+ else {
+ $ishost = false;
+ }
+
+ if ($isbookedsession) {
+ $options .= ''.get_string('cancelbooking', 'webinar').'
';
+ $options .= '' . get_string('joinwebinar', 'webinar') . '';
+ }
+ elseif (!$sessionstarted and !$ishost) {
+ $options .= ''.get_string('register', 'webinar').'';
+ }
+
+ if (empty($options)) {
+ $options = get_string('none', 'webinar');
+ }
+ $sessionrow[] = $options;
+
+ // Set the CSS class for the row
+ $rowclass = '';
+ if ($sessionstarted) {
+ $rowclass = 'dimmed_text';
+ }
+ elseif ($isbookedsession) {
+ $rowclass = 'highlight';
+ }
+ elseif ($sessionfull) {
+ $rowclass = 'dimmed_text';
+ }
+
+ // Put the row in the right table
+ if ($sessionstarted) {
+ $previousrowclass[] = $rowclass;
+ $previousdata[] = $sessionrow;
+ }
+ elseif ($sessionwaitlisted) {
+ $upcomingtbdrowclass[] = $rowclass;
+ $upcomingtbddata[] = $sessionrow;
+ }
+ else { // Normal scheduled session
+ $upcomingrowclass[] = $rowclass;
+ $upcomingdata[] = $sessionrow;
+ }
+ }
+ }
+
+ // Upcoming sessions
+
+ $this->heading(get_string('upcomingsessions', 'webinar'));
+ //print_heading(get_string('upcomingsessions', 'webinar')); //remove deprecated print_heading()
+
+ if (empty($upcomingdata) and empty($upcomingtbddata)) {
+ $output .= '' . get_string('noupcoming', 'webinar', $webinar->name) . '
';
+ }
+ else {
+ //JoeB - dev upgrade for 2.3, replace deprecated print_table()
+ //$upcomingtable = new object();
+ $upcomingtable = new html_table();
+
+ $upcomingtable->summary = get_string('upcomingsessionslist', 'webinar');
+ $upcomingtable->head = $tableheader;
+ $upcomingtable->rowclasses = array_merge($upcomingrowclass, $upcomingtbdrowclass);
+ $upcomingtable->width = '100%';
+ $upcomingtable->data = array_merge($upcomingdata, $upcomingtbddata);
+
+ $output .= html_writer::table($upcomingtable);
+ }
+
+ if ($editsessions) {
+ $output .= ''.get_string('addsession', 'webinar').'
';
+ }
+
+ // Previous sessions
+ if (!empty($previousdata)) {
+
+ $output .= $this->heading(get_string('previoussessions', 'webinar'));
+
+ //$previoustable = new object();
+ $previoustable = new html_table();
+
+ $previoustable->summary = get_string('previoussessionslist', 'webinar');
+ $previoustable->head = $tableheader;
+ $previoustable->rowclasses = $previousrowclass;
+ $previoustable->width = '100%';
+ $previoustable->data = $previousdata;
+
+ $output .= html_writer::table($previoustable);
+ }
+
+ return $output;
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/signup.php b/signup.php
index 1bcd626..816d6bc 100644
--- a/signup.php
+++ b/signup.php
@@ -41,7 +41,7 @@
// Guests can't signup for a session, so offer them a choice of logging in or going back.
if (isguestuser()) {
$loginurl = $CFG->wwwroot.'/login/index.php';
-
+
if (!empty($CFG->loginhttps)) {
$loginurl = str_replace('http:','https:', $loginurl);
}
@@ -106,22 +106,22 @@
//Sign up user to this webinar through Adobe Connect API call
signup_meeting($webinar, $session, $USER);
-
+
//Send registration email to user
send_email_signup($webinar, $session, $cm, $USER);
-
+
$PAGE->set_pagetype('webinar');
$PAGE->set_title($webinar->name);
$PAGE->set_heading($webinar->name);
echo $OUTPUT->header();
-
-
+
+
$heading = get_string('registersuccess', 'webinar');
echo $OUTPUT->heading($heading);
-
+
$message = get_string('registrationsuccessful', 'webinar', $webinar->name);
$timemessage = 4;
-
+
$message = '
' . $message;
redirect($returnurl, $message, $timemessage);
}
diff --git a/signupmeeting.php b/signupmeeting.php
index f4d9ae5..7f84198 100644
--- a/signupmeeting.php
+++ b/signupmeeting.php
@@ -47,13 +47,13 @@ function signup_meeting($webinar, $session_info, $user) {
$context = stream_context_create($opts);
//Step 3 - as admin user, check if user email exists on Adobe Connect already - if not, add a new user to the system, otherwise get their permission ID
-
+
$url = $webinar->sitexmlapiurl . "?action=principal-list&filter-email=" . $user->email; // . "&session=" . $session;
$xmlstr = file_get_contents($url, false, $context);
$xml = new SimpleXMLElement($xmlstr);
if ($xml->{'principal-list'}->principal) {
-
+
//User email address has been matched on Adobe Connect - get back their principal ID
foreach($xml->{'principal-list'}->principal->attributes() as $key => $val) {
if($key == 'principal-id') {
@@ -63,7 +63,7 @@ function signup_meeting($webinar, $session_info, $user) {
}
else {
//User email address is not registered yet with Adobe Connect - add them and get back the principal ID
- $url = $webinar->sitexmlapiurl . "?action=principal-update&first-name=" . str_replace(' ', '%20', $user->firstname) . "&last-name=" . str_replace(' ', '%20', $user->lastname) . "&login=" . $user->email .
+ $url = $webinar->sitexmlapiurl . "?action=principal-update&first-name=" . str_replace(' ', '%20', $user->firstname) . "&last-name=" . str_replace(' ', '%20', $user->lastname) . "&login=" . $user->email .
"&password=" . $webinar->adminpassword . "&type=user&send-email=false&has-children=0&email=" . $user->email; // . "&session=" . $session;
$xmlstr = file_get_contents($url, false, $context);
$xml = new SimpleXMLElement($xmlstr);
diff --git a/updatemeeting.php b/updatemeeting.php
index f9c3924..ae9159f 100644
--- a/updatemeeting.php
+++ b/updatemeeting.php
@@ -45,21 +45,21 @@ function update_meeting($webinar, $session_info, $date, $presenter_details) {
$datebegin = date('Y-m-d', $date->timestart);
$timebegin = date('H:i', $date->timestart);
$datetimebegin = $datebegin . "T" . $timebegin;
-
+
$dateend = date('Y-m-d', $date->timefinish);
$timeend = date('H:i', $date->timefinish);
$datetimeend = $dateend . "T" . $timeend;
-
+
$meetingname = str_replace(' ', '%20', $webinar->name . ' ' . $datebegin . ' ' . $timebegin);
-
+
$scoid = $session_info->scoid;
-
- $url = $webinar->sitexmlapiurl . "?action=sco-update&type=meeting&name=" . $meetingname .
+
+ $url = $webinar->sitexmlapiurl . "?action=sco-update&type=meeting&name=" . $meetingname .
"&sco-id=" . $scoid . "&date-begin=" . $datetimebegin . "&date-end=" . $datetimeend . "&url-path="; //&session=" . $session;
-
+
$xmlstr = file_get_contents($url, false, $context);
$xml = new SimpleXMLElement($xmlstr);
-
+
//Step 4 - update/add a presenter - pass the presenter email address, check if it exists on Adobe Connect already - if not, add a new user to the system, otherwise get their permission ID
$url = $webinar->sitexmlapiurl . "?action=principal-list&filter-email=" . $presenter_details->email; // . "&session=" . $session;
$xmlstr = file_get_contents($url, false, $context);
@@ -75,7 +75,7 @@ function update_meeting($webinar, $session_info, $date, $presenter_details) {
}
else {
//Presenter email address is not registered yet with Adobe Connect - add them and get back the principal ID
- $url = $webinar->sitexmlapiurl . "?action=principal-update&first-name=" . str_replace(' ', '%20', $presenter_details->firstname) . "&last-name=" . str_replace(' ', '%20', $presenter_details->lastname) . "&login=" . $presenter_details->email .
+ $url = $webinar->sitexmlapiurl . "?action=principal-update&first-name=" . str_replace(' ', '%20', $presenter_details->firstname) . "&last-name=" . str_replace(' ', '%20', $presenter_details->lastname) . "&login=" . $presenter_details->email .
"&password=" . $webinar->adminpassword . "&type=user&send-email=false&has-children=0&email=" . $presenter_details->email; // . "&session=" . $session;
$xmlstr = file_get_contents($url, false, $context);
@@ -87,12 +87,12 @@ function update_meeting($webinar, $session_info, $date, $presenter_details) {
}
}
}
-
+
//take the presenter user's principal ID and assign them as presenter of the session
$url = $webinar->sitexmlapiurl . "?action=permissions-update&principal-id=" . $principal_id . "&acl-id=" . $scoid . "&permission-id=host"; //&session=" . $session;
-
+
$xmlstr = file_get_contents($url, false, $context);
$xml = new SimpleXMLElement($xmlstr);
-
+
}
\ No newline at end of file
diff --git a/version.php b/version.php
index 835dbfd..5d28998 100644
--- a/version.php
+++ b/version.php
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2014052200;
-$module->release = 2.0;
+$module->version = 2014110301;
+$module->release = 2.1;
$module->requires = 2013111801; // Requires this Moodle version
$module->cron = 60;
diff --git a/view.php b/view.php
index 78eaf62..00b80aa 100644
--- a/view.php
+++ b/view.php
@@ -54,481 +54,19 @@
$PAGE->set_title($webinar->name);
$PAGE->set_heading($webinar->name);
$PAGE->navbar->add($webinar->name);
+$output = $PAGE->get_renderer('mod_webinar');
+
echo $OUTPUT->header();
+
if (empty($cm->visible) and !has_capability('mod/webinar:viewemptyactivities', $context)) {
notice(get_string('activityiscurrentlyhidden'));
}
-//print_box_start();
$OUTPUT->box_start();
-echo $OUTPUT->heading($webinar->name);
-
-echo '';
-
-if ($webinar->description !== "") {
- echo '
- | Description: |
- |
- ' . $webinar->description . ' |
-
';
-}
-if ($webinar->agenda !== "") {
- echo '
- | Agenda: |
- |
- ' . $webinar->agenda . ' |
-
';
-}
-
-echo '
';
-
-$locations = get_locations($webinar->id);
-if (count($locations) > 2) {
- echo '';
-}
-
-print_session_list($course->id, $webinar->id, $location, $webinar);
+echo $output->view_page($course, $webinar, $cm, $context, $location);
$OUTPUT->box_end();
echo $OUTPUT->footer();
-
-function print_session_list($courseid, $webinarid, $location, $webinar)
-{
- global $USER;
- global $CFG;
- global $DB;
- global $OUTPUT;
-
- $timenow = time();
-
- //$context = get_context_instance(CONTEXT_COURSE, $courseid, $USER->id);
- $context = context_course::instance($courseid, $USER->id);
-
- $viewattendees = has_capability('mod/webinar:viewattendees', $context);
-
- $editsessions = has_capability('mod/webinar:editsessions', $context);
-
- $customfields = webinar_get_session_customfields();
-
- // Table headers
- $tableheader = array();
- foreach ($customfields as $field) {
- if (!empty($field->showinsummary)) {
- $tableheader[] = format_string($field->name);
- }
- }
-
- echo '
-
- ';
-
- $tableheader[] = get_string('startdatetime', 'webinar');
- $tableheader[] = get_string('finishdatetime', 'webinar');
- $tableheader[] = get_string('presenter', 'webinar');
- $tableheader[] = get_string('maximumattendees', 'webinar');
- $tableheader[] = get_string('confirmed', 'webinar');
- $tableheader[] = get_string('status', 'webinar');
- $tableheader[] = get_string('options', 'webinar');
-
- $upcomingdata = array();
- $upcomingtbddata = array();
- $previousdata = array();
- $upcomingrowclass = array();
- $upcomingtbdrowclass = array();
- $previousrowclass = array();
-
- if ($sessions = webinar_get_sessions($webinarid, $location) ) {
- foreach($sessions as $session) {
- $sessionrow = array();
-
- $sessionstarted = false;
- $sessionfull = false;
- $sessionwaitlisted = false;
- $isbookedsession = false;
-
- $bookedsession = null;
- if ($submissions = webinar_session_get_user_submissions($webinarid, $USER->id, $session->id)) {
- $submission = array_shift($submissions);
- $bookedsession = $submission;
- }
-
- // Custom fields
- $customdata = $DB->get_records('webinar_session_data', array('sessionid' => $session->id), 'fieldid, data');
- foreach ($customfields as $field) {
- if (empty($field->showinsummary)) {
- continue;
- }
-
- if (empty($customdata[$field->id])) {
- $sessionrow[] = ' ';
- }
- else {
- $sessionrow[] = format_string($customdata[$field->id]->data);
- }
- }
-
- foreach ($session->sessiondates as $date) {
- $sessionstart = date('d F Y h:i A', $date->timestart);
- $sessionfinish = date('d F Y h:i A', $date->timefinish);
- }
-
- $sessionrow[] = $sessionstart;
- $sessionrow[] = $sessionfinish;
-
- $presenter_name = $DB->get_records_sql("SELECT
- u.firstname,
- u.lastname
- FROM
- {$CFG->prefix}user u
- WHERE
- u.id = $session->presenter
- LIMIT 1");
-
-
- if($presenter_name) {
- foreach($presenter_name as $pname) {
- $presenter = $pname->firstname . " " . $pname->lastname;
- }
- }
- $sessionrow[] = $presenter;
-
- // Capacity
- $signupcount = webinar_get_num_attendees($session->id);
-
- $sessionrow[] = $session->capacity;
- $sessionrow[] = $signupcount;
-
- // Status
- $status = get_string('bookingopen', 'webinar');
- if (webinar_has_session_started($session, $timenow) && webinar_is_session_in_progress($session, $timenow)) {
-
- $status = get_string('sessioninprogress', 'webinar');
- $sessionstarted = true;
- }
- elseif (webinar_has_session_started($session, $timenow)) {
-
- $status = get_string('closed', 'webinar');
- $sessionstarted = true;
- }
-
- elseif ($bookedsession) {
- $signupstatus = webinar_get_status($bookedsession->statuscode);
-
- $status = get_string('status_'.$signupstatus, 'webinar');
- $isbookedsession = true;
- }
- elseif ($signupcount >= $session->capacity) {
- $status = get_string('bookingfull', 'webinar');
- $sessionfull = true;
- }
-
- $sessionrow[] = $status;
-
- /*
- //Get session value
- $url = $webinar->sitexmlapiurl . "?action=common-info";
- $xmlstr = file_get_contents($url);
- $xml = new SimpleXMLElement($xmlstr);
- $session_value = $xml->common->cookie;
-
- //Login user
- $url = $webinar->sitexmlapiurl . "?action=login&login=" . $USER->email . "&password=" . $webinar->adminpassword . "&session=" . $session_value;
- $xmlstr = file_get_contents($url);
- $xml = new SimpleXMLElement($xmlstr);
- */
-
- $url = $webinar->sitexmlapiurl . "?action=login&login=" . $USER->email . "&password=" . $webinar->adminpassword;
-
- $ch=curl_init($url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- $response = curl_exec($ch);
- curl_close($ch);
-
- $breeze_session_first_strip = strstr($response, 'BREEZESESSION');
- $breeze_session_second_strip = strstr($breeze_session_first_strip, ';', true);
- $breeze_session = str_replace('BREEZESESSION=', '', $breeze_session_second_strip);
-
- // Create a stream for HTTP headers, including the BREEZESESSION cookie
- $opts = array(
- 'http'=>array(
- 'method'=>"GET",
- 'header'=>"Cookie: " . $breeze_session_second_strip . "\r\n"
- )
- );
-
- $context = stream_context_create($opts);
-
-
-
-
-
- $meetingurl = str_replace('/api/xml', '', $webinar->sitexmlapiurl) . $session->urlpath;
- $meetingurlwithsession = $meetingurl . '?session=' . $breeze_session; //$session_value;
-
- // Options
- $options = '';
- if ($editsessions) {
- $options .= ' '
- . '
'
- . ''
- . '
'
- . ''
- . '
';
- }
- if ($viewattendees){
- $options .= '
'.get_string('attendees', 'webinar').'
';
- }
-
- if($status == 'Closed') {
-
- //Give user permission to watch old recordings of a webinar by adding them as a participant
- //To do this, we must first get their principal ID if they are already added to Adobe Connect, or if not, add them first
- //Need to temporarily login as admin in order to do this
-
- /*
- $url = $webinar->sitexmlapiurl . "?action=login&login=" . $webinar->adminemail . "&password=" . $webinar->adminpassword . "&session=" . $session_value;
- $xmlstr = file_get_contents($url);
- $xml = new SimpleXMLElement($xmlstr);
- */
-
- $url = $webinar->sitexmlapiurl . "?action=login&login=" . $webinar->adminemail . "&password=" . $webinar->adminpassword;
- $ch=curl_init($url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- $response = curl_exec($ch);
- curl_close($ch);
-
- $breeze_session_first_strip = strstr($response, 'BREEZESESSION');
- $breeze_session_second_strip = strstr($breeze_session_first_strip, ';', true);
- $breeze_session = str_replace('BREEZESESSION=', '', $breeze_session_second_strip);
-
- // Create a stream for HTTP headers, including the BREEZESESSION cookie
- $opts = array(
- 'http'=>array(
- 'method'=>"GET",
- 'header'=>"Cookie: " . $breeze_session_second_strip . "\r\n"
- )
- );
-
- $context = stream_context_create($opts);
-
- $url = $webinar->sitexmlapiurl . "?action=principal-list&filter-email=" . $USER->email; //. "&session=" . $session_value;
- $xmlstr = file_get_contents($url, false, $context);
- $xml = new SimpleXMLElement($xmlstr);
-
- if ($xml->{'principal-list'}->principal) {
- //User email address has been matched on Adobe Connect - get back their principal ID
- foreach($xml->{'principal-list'}->principal->attributes() as $key => $val) {
- if($key == 'principal-id') {
- $principal_id = $val;
- }
- }
- }
- else {
- //User email address is not registered yet with Adobe Connect - add them and get back the principal ID
- $url = $webinar->sitexmlapiurl . "?action=principal-update&first-name=" . str_replace(' ', '%20', $USER->firstname) . "&last-name=" . str_replace(' ', '%20', $USER->lastname) . "&login=" . $USER->email .
- "&password=" . $webinar->adminpassword . "&type=user&send-email=false&has-children=0&email=" . $USER->email; // . "&session=" . $session_value;
-
- $xmlstr = file_get_contents($url, false, $context);
- $xml = new SimpleXMLElement($xmlstr);
-
- foreach($xml->principal->attributes() as $key => $val) {
- if($key == 'principal-id') {
- $principal_id = $val;
- }
- }
- }
-
- //Now, add user as a meeting participant using the principalID obtained above
- $url = $webinar->sitexmlapiurl . "?action=permissions-update&principal-id=" . $principal_id . "&acl-id=" . $session->scoid . "&permission-id=view&session=" . $breeze_session; //$session_value;
- $xmlstr = file_get_contents($url, false, $context);
- $xml = new SimpleXMLElement($xmlstr);
-
- //Login BACK in as user, after having logged in as admin to add current user as participant
- /*
- $url = $webinar->sitexmlapiurl . "?action=login&login=" . $USER->email . "&password=" . $webinar->adminpassword . "&session=" . $session_value;
- $xmlstr = file_get_contents($url);
- $xml = new SimpleXMLElement($xmlstr);
- */
-
- $url = $webinar->sitexmlapiurl . "?action=login&login=" . $USER->email . "&password=" . $webinar->adminpassword;
- $ch=curl_init($url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- $response = curl_exec($ch);
- curl_close($ch);
-
- $breeze_session_first_strip = strstr($response, 'BREEZESESSION');
- $breeze_session_second_strip = strstr($breeze_session_first_strip, ';', true);
- $breeze_session = str_replace('BREEZESESSION=', '', $breeze_session_second_strip);
-
- // Create a stream for HTTP headers, including the BREEZESESSION cookie
- $opts = array(
- 'http'=>array(
- 'method'=>"GET",
- 'header'=>"Cookie: " . $breeze_session_second_strip . "\r\n"
- )
- );
-
- $context = stream_context_create($opts);
-
- //get back the recording URL path for the meeting SCO ID
- $url = $webinar->sitexmlapiurl . "?action=sco-contents&sco-id=" . $session->scoid . "&filter-icon=archive"; //&session=" . $session_value;
- $xmlstr = file_get_contents($url, false, $context);
- $xml = new SimpleXMLElement($xmlstr);
-
- foreach ($xml->scos->sco as $sco) {
-
- $recording_urlpath = $sco->{'url-path'};
- $recordingurl = str_replace('/api/xml', '', $webinar->sitexmlapiurl) . $recording_urlpath;
- $recordingurlwithsession = $recordingurl . '?session=' . $breeze_session; //$session_value;
-
- $options .= '' . get_string('viewrecording', 'webinar') . '
';
- }
- }
-
- //check if the user is the presenter/host of the session - if so, allow them to join the session as host as they are already registered with Adobe Connect
- if (($session->presenter == $USER->id) and (!$sessionstarted)) {
- $options .= '' . get_string('joinwebinarashost', 'webinar') . '
';
- $ishost = true;
- }
- else {
- $ishost = false;
- }
-
- if ($isbookedsession) {
- $options .= ''.get_string('cancelbooking', 'webinar').'
';
- $options .= '' . get_string('joinwebinar', 'webinar') . '';
- }
- elseif (!$sessionstarted and !$ishost) {
- $options .= ''.get_string('register', 'webinar').'';
- }
-
- if (empty($options)) {
- $options = get_string('none', 'webinar');
- }
- $sessionrow[] = $options;
-
- // Set the CSS class for the row
- $rowclass = '';
- if ($sessionstarted) {
- $rowclass = 'dimmed_text';
- }
- elseif ($isbookedsession) {
- $rowclass = 'highlight';
- }
- elseif ($sessionfull) {
- $rowclass = 'dimmed_text';
- }
-
- // Put the row in the right table
- if ($sessionstarted) {
- $previousrowclass[] = $rowclass;
- $previousdata[] = $sessionrow;
- }
- elseif ($sessionwaitlisted) {
- $upcomingtbdrowclass[] = $rowclass;
- $upcomingtbddata[] = $sessionrow;
- }
- else { // Normal scheduled session
- $upcomingrowclass[] = $rowclass;
- $upcomingdata[] = $sessionrow;
- }
- }
- }
-
- // Upcoming sessions
-
- $OUTPUT->heading(get_string('upcomingsessions', 'webinar'));
- //print_heading(get_string('upcomingsessions', 'webinar')); //remove deprecated print_heading()
-
- if (empty($upcomingdata) and empty($upcomingtbddata)) {
- echo '' . get_string('noupcoming', 'webinar', $webinar->name) . '
';
- }
- else {
- //JoeB - dev upgrade for 2.3, replace deprecated print_table()
- //$upcomingtable = new object();
- $upcomingtable = new html_table();
-
- $upcomingtable->summary = get_string('upcomingsessionslist', 'webinar');
- $upcomingtable->head = $tableheader;
- $upcomingtable->rowclasses = array_merge($upcomingrowclass, $upcomingtbdrowclass);
- $upcomingtable->width = '100%';
- $upcomingtable->data = array_merge($upcomingdata, $upcomingtbddata);
-
- //print_table($upcomingtable);
- echo html_writer::table($upcomingtable);
- }
-
- if ($editsessions) {
- echo ''.get_string('addsession', 'webinar').'
';
- }
-
- // Previous sessions
- if (!empty($previousdata)) {
- echo $OUTPUT->heading(get_string('previoussessions', 'webinar'));
-
- //$previoustable = new object();
- $previoustable = new html_table();
-
- $previoustable->summary = get_string('previoussessionslist', 'webinar');
- $previoustable->head = $tableheader;
- $previoustable->rowclasses = $previousrowclass;
- $previoustable->width = '100%';
- $previoustable->data = $previousdata;
-
- //print_table($previoustable);
- echo html_writer::table($previoustable);
- }
-}
-
-/**
- * Get webinar locations
- *
- * @param interger $webinarid
- * @return array
- */
-function get_locations($webinarid)
-{
- global $CFG, $DB;
-
- $locationfieldid = $DB->get_field('webinar_session_field', 'id', array('shortname' => 'location'));
- if (!$locationfieldid) {
- return array();
- }
-
- $sql = "SELECT DISTINCT d.data AS location
- FROM {$CFG->prefix}webinar f
- JOIN {$CFG->prefix}webinar_sessions s ON s.webinar = f.id
- JOIN {$CFG->prefix}webinar_session_data d ON d.sessionid = s.id
- WHERE f.id = $webinarid AND d.fieldid = $locationfieldid";
-
- if ($records = $DB->get_records_sql($sql)) {
- $locationmenu[''] = get_string('alllocations', 'webinar');
-
- $i=1;
- foreach ($records as $record) {
- $locationmenu[$record->location] = $record->location;
- $i++;
- }
-
- return $locationmenu;
- }
-
- return array();
-}