Beispiel #1
0
$errors = array();
/// Handle the POST actions sent to the page
if ($frm = data_submitted()) {
    // Add button
    if ($add and !empty($frm->addselect) and confirm_sesskey()) {
        require_capability('mod/webinar:addattendees', $context);
        foreach ($frm->addselect as $adduser) {
            if (!($adduser = clean_param($adduser, PARAM_INT))) {
                continue;
                // invalid userid
            }
            // Make sure that the user is enroled in the course
            if (!has_capability('moodle/course:view', $context, $adduser)) {
                $user = $DB->get_record('user', array('id' => $adduser));
            }
            if (!webinar_session_has_capacity($session, $context)) {
                $errors[] = get_string('full', 'webinar');
                break;
                // no point in trying to add other people
            }
            // Check if we are waitlisting or booking
            //if ($session->datetimeknown) {
            //      $status = WEBINAR_STATUS_BOOKED;
            //}
            //else {
            $status = WEBINAR_STATUS_WAITLISTED;
            //}
            if (!webinar_user_signup($session, $webinar, $course, '', WEBINAR_BOTH, $status, $adduser, !$suppressemail)) {
                $erruser = $DB->get_record('user', array('id' => $adduser), 'id, firstname, lastname');
                $errors[] = get_string('error:addattendee', 'webinar', fullname($erruser));
            } else {
Beispiel #2
0
/**
 * 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;
}
Beispiel #3
0
  update_module_button($cm->id, $course->id, get_string('modulename', 'webinar')));*/
$PAGE->set_pagetype('webinar');
$PAGE->set_title($webinar->name);
$PAGE->set_heading($webinar->name);
echo $OUTPUT->header();
$heading = get_string('registeron', 'webinar', $webinar->name);
$viewattendees = has_capability('mod/webinar:viewattendees', $context);
$signedup = webinar_check_signup($webinar->id);
/*
if ($signedup and $signedup != $session->id) {
    print_error('error:signedupinothersession', 'webinar', $returnurl);
}
*/
echo $OUTPUT->box_start();
echo $OUTPUT->heading($heading);
if (!$signedup and !webinar_session_has_capacity($session, $context)) {
    print_error('sessionisfull', 'webinar', $returnurl);
    echo $OUTPUT->box_end();
    echo $OUTPUT->footer($course);
    exit;
}
//print_r($webinar);
webinar_print_session($session, $viewattendees);
/*
if ($signedup) {
    // Cancellation link
    echo '<a href="'.$CFG->wwwroot.'/mod/webinar/cancelsignup.php?s='.$session->id.'&amp;backtoallsessions='.$backtoallsessions.'" title="'.get_string('cancelbooking','webinar').'">'.get_string('cancelbooking', 'webinar').'</a>';

    // See attendees link
    if ($viewattendees) {
        echo ' &ndash; <a href="'.$CFG->wwwroot.'/mod/webinar/attendees.php?s='.$session->id.'&amp;backtoallsessions='.$backtoallsessions.'" title="'.get_string('seeattendees', 'webinar').'">'.get_string('seeattendees', 'webinar').'</a>';