print_error('error:couldnotaddsession', 'webinar', $returnurl); } } foreach ($customfields as $field) { $fieldname = "custom_{$field->shortname}"; if (!isset($fromform->{$fieldname})) { $fromform->{$fieldname} = ''; // need to be able to clear fields } if (!webinar_save_customfield_value($field->id, $fromform->{$fieldname}, $sessionid, 'session')) { rollback_sql(); print_error('error:couldnotsavecustomfield', 'webinar', $returnurl); } } // Retrieve record that was just inserted/updated if (!($session = webinar_get_session($sessionid))) { rollback_sql(); print_error('error:couldnotfindsession', 'webinar', $returnurl); } // Put the session in the site-wide calendar (needs customfields to be up to date) if (!webinar_add_session_to_site_calendar($session, $webinar)) { rollback_sql(); print_error('error:couldnotupdatecalendar', 'webinar', $returnurl); } if ($update) { add_to_log($course->id, 'webinar', 'update session', "sessions.php?s={$session->id}", $webinar->id, $cm->id); } else { add_to_log($course->id, 'webinar', 'add session', 'webinar', 'sessions.php?f=' . $webinar->id, $webinar->id, $cm->id); } //commit_sql(); redirect($returnurl);
/** * 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 = ' '; $venue = ' '; $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> </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; }