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 .= ' ' + . '
'
+ . ''
+ . '
'
+ . ''
+ . '
' . 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 = '| Description: | -- | ' . $webinar->description . ' | -
| Agenda: | -- | ' . $webinar->agenda . ' | -
'
- . ''
- . '
'
- . ''
- . '
' . 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 ''; - } - - // 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(); -}