} //prevent display of Unix epoch if user never accessed the session if (!$user_joined || strstr($date_joined, "01 January 1970")) { $data[] = "Did not attend"; $data[] = "-"; } else { $data[] = $date_joined; $data[] = $date_left; } foreach ($status_options as $key => $val) { if ($key == $attendee->statuscode) { $data[] = $val; } } } else { $data[] = str_replace(' ', ' ', get_string('status_' . webinar_get_status($attendee->statuscode), 'webinar')); } } $table->data[] = $data; } //print_table($table); echo html_writer::table($table); } else { //JoeB - dev changes for Moodle 2.3 - replace references to deprecated function print_heading() //print_heading(get_string('nosignedupusers', 'webinar')); echo $OUTPUT->heading(get_string('nosignedupusers', 'webinar')); } if ($takeattendance) { echo '<p>'; echo '<input type="submit" value="' . get_string('saveattendance', 'webinar') . '" />'; echo ' <input type="submit" name="cancelform" value="' . get_string('cancel') . '" />';
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); } }