コード例 #1
0
ファイル: view.php プロジェクト: pavelsokolov/webinar
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[] = '&nbsp;';
                } 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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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);
    }
}
コード例 #2
0
ファイル: lib.php プロジェクト: pavelsokolov/webinar
/**
 * Used by course/lib.php to display a few sessions besides the
 * webinar activity on the course page
 *
 * @global class $USER used to get the current userid
 * @global class $CFG used to get the path to the module
 */
function webinar_print_coursemodule_info($coursemodule)
{
    global $CFG, $USER, $DB;
    $contextmodule = get_context_instance(CONTEXT_MODULE, $coursemodule->id);
    if (!has_capability('mod/webinar:view', $contextmodule)) {
        return '';
        // not allowed to view this activity
    }
    $contextcourse = get_context_instance(CONTEXT_COURSE, $coursemodule->course);
    // can view attendees
    $viewattendees = has_capability('mod/webinar:viewattendees', $contextcourse);
    $table = '';
    $timenow = time();
    $webinarpath = "{$CFG->wwwroot}/mod/webinar";
    $webinarid = $coursemodule->instance;
    $webinar = $DB->get_record('webinar', array('id' => $webinarid));
    if (!$webinar) {
        error_log("webinar: ask to print coursemodule info for a non-existent activity ({$webinarid})");
        return '';
    }
    $htmlactivitynameonly = '<img src="icon.gif" class="activityicon" alt="' . $webinar->name . '" /> ' . $webinar->name;
    $strviewallsessions = get_string('viewallsessions', 'webinar');
    $htmlviewallsessions = '<a class="f2fsessionlinks" href="' . $webinarpath . '/view.php?f=' . $webinarid . '" title="' . $strviewallsessions . '">' . $strviewallsessions . '</a>';
    if ($submissions = webinar_get_user_submissions($webinarid, $USER->id)) {
        // User has signedup for the instance
        $submission = array_shift($submissions);
        if ($session = webinar_get_session($submission->sessionid)) {
            $sessiondate = '';
            $sessiontime = '';
            foreach ($session->sessiondates as $date) {
                if (!empty($sessiondate)) {
                    $sessiondate .= '<br />';
                }
                $sessiondate .= userdate($date->timestart, get_string('strftimedate'));
                if (!empty($sessiontime)) {
                    $sessiontime .= '<br />';
                }
                $sessiontime .= userdate($date->timestart, get_string('strftimetime')) . ' - ' . userdate($date->timefinish, get_string('strftimetime'));
            }
            // don't include the link to cancel a session if it has already occurred
            $cancellink = '';
            if (!webinar_has_session_started($session, $timenow)) {
                $strcancelbooking = get_string('cancelbooking', 'webinar');
                $cancellink = "<tr><td><a class=\"f2fsessionlinks\" href=\"{$webinarpath}/cancelsignup.php?s={$session->id}\" title=\"{$strcancelbooking}\">{$strcancelbooking}</a></td></tr>";
            }
            $strmoreinfo = get_string('moreinfo', 'webinar');
            $strseeattendees = get_string('seeattendees', 'webinar');
            $location = '&nbsp;';
            $venue = '&nbsp;';
            $customfielddata = webinar_get_customfielddata($session->id);
            if (!empty($customfielddata['location'])) {
                $location = $customfielddata['location']->data;
            }
            if (!empty($customfielddata['venue'])) {
                $venue = $customfielddata['venue']->data;
            }
            // don't include the link to view attendees if user is lacking capability
            $attendeeslink = '';
            if ($viewattendees) {
                $attendeeslink = "<tr><td><a class=\"f2fsessionlinks\" href=\"{$webinarpath}/attendees.php?s={$session->id}\" title=\"{$strseeattendees}\">{$strseeattendees}</a></td></tr>";
            }
            $table = '<table border="0" cellpadding="1" cellspacing="0" width="90%" summary="" style="display:inline-table">' . '<tr>' . '<td class="f2fsessionnotice" colspan="4">' . $htmlactivitynameonly . '</td>' . '</tr>' . '<tr>' . '<td class="f2fsessionnotice" colspan="4">' . get_string('bookingstatus', 'webinar') . ':</td>' . '<td><span class="f2fsessionnotice" >' . get_string('options', 'webinar') . ':</span></td>' . '</tr>' . '<tr>' . '<td>' . $location . '</td>' . '<td>' . $venue . '</td>' . '<td>' . $sessiondate . '</td>' . '<td>' . $sessiontime . '</td>' . "<td><table border=\"0\" summary=\"\"><tr><td><a class=\"f2fsessionlinks\" href=\"{$webinarpath}/signup.php?s={$session->id}\" title=\"{$strmoreinfo}\">{$strmoreinfo}</a></td>" . '</tr>' . $attendeeslink . $cancellink . '<tr>' . "<td>{$htmlviewallsessions}</td>" . '</tr>' . '</table></td></tr>' . '</table>';
        }
    } elseif ($webinar->display > 0 && ($sessions = webinar_get_sessions($webinarid))) {
        $table = '<table border="0" cellpadding="1" cellspacing="0" width="100%" summary="" style="display:inline-table">' . '   <tr>' . '       <td class="f2fsessionnotice" colspan="2">' . $htmlactivitynameonly . '</td>' . '   </tr>' . '   <tr>' . '       <td class="f2fsessionnotice" colspan="2">' . get_string('signupforsession', 'webinar') . ':</td>' . '   </tr>';
        $i = 0;
        foreach ($sessions as $session) {
            if (webinar_has_session_started($session, $timenow)) {
                continue;
            }
            if (!webinar_session_has_capacity($session, $contextmodule)) {
                continue;
            }
            $multiday = '';
            $sessiondate = '';
            $sessiontime = '';
            if (empty($session->sessiondates)) {
                $sessiondate = get_string('unknowndate', 'webinar');
                $sessiontime = get_string('unknowntime', 'webinar');
            } else {
                $sessiondate = userdate($session->sessiondates[0]->timestart, get_string('strftimedate'));
                $sessiontime = userdate($session->sessiondates[0]->timestart, get_string('strftimetime')) . ' - ' . userdate($session->sessiondates[0]->timefinish, get_string('strftimetime'));
                if (count($session->sessiondates) > 1) {
                    $multiday = ' (' . get_string('multiday', 'webinar') . ')';
                }
            }
            if ($i == 0) {
                $table .= '   <tr>';
                $i++;
            } else {
                if ($i++ % 2 == 0) {
                    if ($i > $webinar->display) {
                        break;
                    }
                    $table .= '   </tr>';
                    $table .= '   <tr>';
                }
            }
            $locationstring = '';
            $customfielddata = webinar_get_customfielddata($session->id);
            if (!empty($customfielddata['location']) && trim($customfielddata['location']->data) != '') {
                $locationstring = $customfielddata['location']->data . ', ';
            }
            $table .= "      <td><a href=\"{$webinarpath}/signup.php?s={$session->id}\">{$locationstring}{$sessiondate}<br />{$sessiontime}{$multiday}</a></td>";
        }
        if ($i++ % 2 == 0) {
            $table .= '<td>&nbsp;</td>';
        }
        $table .= '   </tr>' . '   <tr>' . "     <td colspan=\"2\">{$htmlviewallsessions}</td>" . '   </tr>' . '</table>';
    } elseif (has_capability('mod/webinar:viewemptyactivities', $contextmodule)) {
        return '<span class="f2fsessionnotice" style="line-height:1.5">' . $htmlactivitynameonly . '<br />' . $htmlviewallsessions . '</span>';
    } else {
        // Nothing to display to this user
    }
    return $table;
}
コード例 #3
0
ファイル: index.php プロジェクト: pavelsokolov/webinar
 if (!$webinar->visible) {
     //Show dimmed if the mod is hidden
     $link = "<a class=\"dimmed\" href=\"view.php?f={$webinar->id}\">{$webinar->name}</a>";
 } 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 {