/** * Print the details of a session * * @param object $session Record from webinar_sessions * @param boolean $showcapacity Show the capacity (true) or only the seats available (false) * @param boolean $calendaroutput Whether the output should be formatted for a calendar event * @param boolean $return Whether to return (true) the html or print it directly (true) * @param boolean $hidesignup Hide any messages relating to signing up */ function webinar_print_session($session, $showcapacity, $calendaroutput = false, $return = false, $hidesignup = false) { global $CFG, $DB; //print_r($session); //$table = new object(); $table = new html_table(); $table->summary = get_string('sessionsdetailstablesummary', 'webinar'); $table->class = 'f2fsession'; $table->width = '50%'; $table->align = array('right', 'left'); if ($calendaroutput) { $table->tablealign = 'left'; } $customfields = webinar_get_session_customfields(); $customdata = $DB->get_records('webinar_session_data', array('sessionid' => $session->id), '', 'fieldid, data'); foreach ($customfields as $field) { $data = ''; if (!empty($customdata[$field->id])) { if (WEBINAR_CUSTOMFIELD_TYPE_MULTISELECT == $field->type) { $values = explode(WEBINAR_CUSTOMFIELD_DELIMITTER, $customdata[$field->id]->data); $data = implode(', ', $values); } else { $data = $customdata[$field->id]->data; } } $table->data[] = array(str_replace(' ', ' ', format_string($field->name)), format_string($data)); } $presenter_name = $DB->get_records_sql("SELECT\n u.firstname,\n u.lastname\n FROM \n\t\t\t\t\t\t{$CFG->prefix}user u \n WHERE \n\t\t\t\t\t\tu.id = {$session->presenter} \n\t\t\t\t\tLIMIT 1"); if ($presenter_name) { foreach ($presenter_name as $pname) { $presenter = $pname->firstname . " " . $pname->lastname; } } $table->data[] = array(get_string('presenter', 'webinar'), $presenter); $strdatetime = str_replace(' ', ' ', get_string('sessiondatetime', 'webinar')); $html = ''; foreach ($session->sessiondates as $date) { if (!empty($html)) { $html .= '<br/>'; } $timestart = userdate($date->timestart, get_string('strftimedatetime')); $timefinish = userdate($date->timefinish, get_string('strftimedatetime')); $html .= "{$timestart} – {$timefinish}"; } $table->data[] = array($strdatetime, $html); $signupcount = webinar_get_num_attendees($session->id); $placesleft = $session->capacity - $signupcount; if ($showcapacity) { //if ($session->allowoverbook) { // $table->data[] = array(get_string('capacity', 'webinar'), $session->capacity . ' ('.strtolower(get_string('allowoverbook', 'webinar')).')'); //} else { $table->data[] = array(get_string('capacity', 'webinar'), $session->capacity); //} } elseif (!$calendaroutput) { $table->data[] = array(get_string('seatsavailable', 'webinar'), max(0, $placesleft)); } /* // Display requires approval notification $webinar = $DB->get_record('webinar', array('id' => $session->webinar)); if ($webinar->approvalreqd) { $table->data[] = array('', get_string('sessionrequiresmanagerapproval', 'webinar')); } // Display waitlist notification if (!$hidesignup && $session->allowoverbook && $placesleft < 1) { $table->data[] = array('', get_string('userwillbewaitlisted', 'webinar')); } if (!empty($session->duration)) { $table->data[] = array(get_string('duration', 'webinar'), webinar_format_duration($session->duration)); } if (!empty($session->normalcost)) { $table->data[] = array(get_string('normalcost', 'webinar'), webinar_format_cost($session->normalcost)); } if (!empty($session->discountcost)) { $table->data[] = array(get_string('discountcost', 'webinar'), webinar_format_cost($session->discountcost)); } if (!empty($session->details)) { $details = clean_text($session->details, FORMAT_HTML); $table->data[] = array(get_string('details', 'webinar'), $details); } // Display trainers $trainerroles = webinar_get_trainer_roles(); if ($trainerroles) { // Get trainers $trainers = webinar_get_trainers($session->id); foreach ($trainerroles as $role => $rolename) { $rolename = $rolename->name; if (empty($trainers[$role])) { continue; } $trainer_names = array(); foreach ($trainers[$role] as $trainer) { $trainer_names[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$trainer->id.'">'.fullname($trainer).'</a>'; } $table->data[] = array($rolename, implode(', ', $trainer_names)); } } */ //return print_table($table, $return); return html_writer::table($table, $return); }
} else { //Show normal if the mod is visible $link = "<a href=\"view.php?f={$webinar->id}\">{$webinar->name}</a>"; } $printsection = ''; if ($webinar->section !== $currentsection) { if ($webinar->section) { $printsection = $webinar->section; } $currentsection = $webinar->section; } $totalsignupcount = 0; if ($sessions = webinar_get_sessions($webinar->id)) { foreach ($sessions as $session) { if (!webinar_has_session_started($session, $timenow)) { $signupcount = webinar_get_num_attendees($session->id); $totalsignupcount += $signupcount; } } } $courselink = '<a title="' . $course->shortname . '" href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . $course->shortname . '</a>'; if ($course->format == 'weeks' or $course->format == 'topics') { if (has_capability('mod/webinar:viewattendees', $context)) { $table->data[] = array($courselink, $link, $totalsignupcount); } else { $table->data[] = array($courselink, $link); } } else { $table->data[] = array($link, $submitted); } }
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 ' <style type="text/css"> .generaltable th { text-align: left; } </style> '; $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\n u.firstname,\n u.lastname\n FROM \n\t\t\t\t\t\t{$CFG->prefix}user u \n WHERE \n\t\t\t\t\t\tu.id = {$session->presenter} \n\t\t\t\t\tLIMIT 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="******"&password="******"&session=" . $session_value; $xmlstr = file_get_contents($url); $xml = new SimpleXMLElement($xmlstr); */ $url = $webinar->sitexmlapiurl . "?action=login&login="******"&password="******"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 .= ' <a href="sessions.php?s=' . $session->id . '" title="' . get_string('editsession', 'webinar') . '">' . '<img src="' . $CFG->wwwroot . '/pix/t/edit.gif" class="iconsmall" alt="' . get_string('edit', 'webinar') . '" /></a> ' . '<a href="sessions.php?s=' . $session->id . '&c=1" title="' . get_string('copysession', 'webinar') . '">' . '<img src="' . $CFG->wwwroot . '/pix/t/copy.gif" class="iconsmall" alt="' . get_string('copy', 'webinar') . '" /></a> ' . '<a href="sessions.php?s=' . $session->id . '&d=1" title="' . get_string('deletesession', 'webinar') . '">' . '<img src="' . $CFG->wwwroot . '/pix/t/delete.gif" class="iconsmall" alt="' . get_string('delete') . '" /></a><br />'; } if ($viewattendees) { $options .= '<br/><a href="attendees.php?s=' . $session->id . '&backtoallsessions=' . $webinarid . '" title="' . get_string('seeattendees', 'webinar') . '">' . get_string('attendees', 'webinar') . '</a><br />'; } 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="******"&password="******"&session=" . $session_value; $xmlstr = file_get_contents($url); $xml = new SimpleXMLElement($xmlstr); */ $url = $webinar->sitexmlapiurl . "?action=login&login="******"&password="******"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="******"&password="******"&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="******"&password="******"&session=" . $session_value; $xmlstr = file_get_contents($url); $xml = new SimpleXMLElement($xmlstr); */ $url = $webinar->sitexmlapiurl . "?action=login&login="******"&password="******"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 .= '<a href="' . $recordingurlwithsession . '" title="' . get_string('viewrecording', 'webinar') . '" onClick="javascript:window.open(\'' . $recordingurlwithsession . '\', \'Breeze\', \'toolbar=no,menubar=no,width=1024,height=768,resizable=yes\'); return false">' . get_string('viewrecording', 'webinar') . '</a><br/>'; } } //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 .= '<a href="' . $meetingurlwithsession . '" title="' . get_string('joinwebinarashost', 'webinar') . '" onClick="javascript:window.open(\'' . $meetingurlwithsession . '\', \'Breeze\', \'toolbar=no,menubar=no,width=1024,height=768,resizable=yes\'); return false">' . get_string('joinwebinarashost', 'webinar') . '</a><br/>'; $ishost = true; } else { $ishost = false; } if ($isbookedsession) { $options .= '<a href="cancelsignup.php?s=' . $session->id . '&backtoallsessions=' . $webinarid . '" title="' . get_string('cancelbooking', 'webinar') . '">' . get_string('cancelbooking', 'webinar') . '</a><br/>'; $options .= '<a href="' . $meetingurlwithsession . '" title="' . get_string('joinwebinar', 'webinar') . '" onClick="javascript:window.open(\'' . $meetingurlwithsession . '\', \'Breeze\', \'toolbar=no,menubar=no,width=1024,height=768,resizable=yes\'); return false">' . get_string('joinwebinar', 'webinar') . '</a>'; } elseif (!$sessionstarted and !$ishost) { $options .= '<a href="signup.php?s=' . $session->id . '&backtoallsessions=' . $webinarid . '">' . get_string('register', 'webinar') . '</a>'; } 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 '<p align="center">' . get_string('noupcoming', 'webinar', $webinar->name) . '</p>'; } 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 '<p align="center"><a href="sessions.php?f=' . $webinarid . '">' . get_string('addsession', 'webinar') . '</a></p>'; } // 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); } }
if ($mform->is_cancelled()) { redirect($returnurl); } if ($fromform = $mform->get_data()) { // Form submitted if (empty($fromform->submitbutton)) { print_error('error:unknownbuttonclicked', 'webinar', $returnurl); } // User can not update Manager's email (depreciated functionality) if (!empty($fromform->manageremail)) { add_to_log($course->id, 'webinar', 'update manageremail (FAILED)', "signup.php?s={$session->id}", $webinar->id, $cm->id); } // Get signup type if (!$session->datetimeknown) { $statuscode = WEBINAR_STATUS_WAITLISTED; } elseif (webinar_get_num_attendees($session->id) < $session->capacity) { // Save available $statuscode = WEBINAR_STATUS_BOOKED; } else { $statuscode = WEBINAR_STATUS_WAITLISTED; } if (!webinar_session_has_capacity($session, $context)) { print_error('sessionisfull', 'webinar', $returnurl); } elseif (webinar_manager_needed($webinar) && !webinar_get_manageremail($USER->id)) { print_error('error:manageremailaddressmissing', 'webinar', $returnurl); } elseif ($submissionid = webinar_user_signup($session, $webinar, $course, $fromform->discountcode, $fromform->notificationtype, $statuscode)) { add_to_log($course->id, 'webinar', 'signup', "signup.php?s={$session->id}", $session->id, $cm->id); //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);