Exemplo n.º 1
0
         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 {
             //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);
         }
     }
 } else {
     if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
         require_capability('mod/webinar:removeattendees', $context);
         foreach ($frm->removeselect as $removeuser) {
             if (!($removeuser = clean_param($removeuser, PARAM_INT))) {
                 continue;
Exemplo n.º 2
0
/**
 * Mark users' booking requests as declined or approved
 *
 * @param array $data array containing the sessionid under the 's' key
 *                    and an array of request approval/denies
 */
function webinar_approve_requests($data)
{
    global $USER, $DB;
    // Check request data
    if (empty($data->requests) || !is_array($data->requests)) {
        error_log('WEBINAR: No request data supplied');
        return false;
    }
    $sessionid = $data->s;
    // Load session
    if (!($session = webinar_get_session($sessionid))) {
        error_log('WEBINAR: Could not load webinar session');
        return false;
    }
    // Load webinar
    if (!($webinar = $DB->get_record('webinar', array('id' => $session->webinar)))) {
        error_log('WEBINAR: Could not load webinar instance');
        return false;
    }
    // Load course
    if (!($course = $DB->get_record('course', array('id' => $webinar->course)))) {
        error_log('WEBINAR: Could nto load course');
        return false;
    }
    // Loop through requests
    foreach ($data->requests as $key => $value) {
        // Check key/value
        if (!is_numeric($key) || !is_numeric($value)) {
            continue;
        }
        // Load user submission
        if (!($attendee = webinar_get_attendee($sessionid, $key))) {
            error_log('WEBINAR: User ' . $key . ' not an attendee of this session');
            continue;
        }
        // Update status
        switch ($value) {
            // Decline
            case 1:
                webinar_update_signup_status($attendee->submissionid, WEBINAR_STATUS_DECLINED, $USER->id);
                // Send a cancellation notice to the user
                webinar_send_cancellation_notice($webinar, $session, $attendee->id);
                break;
                // Approve
            // Approve
            case 2:
                webinar_update_signup_status($attendee->submissionid, WEBINAR_STATUS_APPROVED, $USER->id);
                // Check if there is capacity
                if (webinar_session_has_capacity($session)) {
                    $status = WEBINAR_STATUS_BOOKED;
                } else {
                    $status = WEBINAR_STATUS_WAITLISTED;
                }
                // Signup user
                if (!webinar_user_signup($session, $webinar, $course, $attendee->discountcode, $attendee->notificationtype, $status, $attendee->id)) {
                    continue;
                }
                break;
            case 0:
            default:
                // Change nothing
                continue;
        }
    }
    return true;
}
Exemplo n.º 3
0
     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);
     $PAGE->set_pagetype('webinar');
     $PAGE->set_title($webinar->name);
     $PAGE->set_heading($webinar->name);
     echo $OUTPUT->header();
     $heading = get_string('registersuccess', 'webinar');
     echo $OUTPUT->heading($heading);
     $message = get_string('registrationsuccessful', 'webinar', $webinar->name);
     $timemessage = 4;
     $message = '<div style="height: 10px;">&nbsp;</div>' . $message;
     redirect($returnurl, $message, $timemessage);