Esempio n. 1
0
/**
 * Import user and signup to session
 *
 * @access  public
 * @param   object  $course             Record from the course table
 * @param   object  $facetoface         Record from the facetoface table
 * @param   object  $session            Session to signup user to
 * @param   mixed   $userid             User to signup (normally int)
 * @param   array   $params             Optional suppressemail, ignoreconflicts, bulkaddsource, discountcode, notificationtype
 *          boolean $suppressemail      Suppress notifications flag
 *          boolean $ignoreconflicts    Ignore booking conflicts flag
 *          string  $bulkaddsource      Flag to indicate if $userid is actually another field
 *          string  $discountcode       Optional A user may specify a discount code
 *          integer $notificationtype   Optional A user may choose the type of notifications they will receive
 * @return  array
 */
function facetoface_user_import($course, $facetoface, $session, $userid, $params = array()) {
    global $DB, $CFG, $USER;

    $result = array();
    $result['id'] = $userid;

    $suppressemail    = (isset($params['suppressemail'])    ? $params['suppressemail']    : false);
    $ignoreconflicts  = (isset($params['ignoreconflicts'])  ? $params['ignoreconflicts']  : false);
    $bulkaddsource    = (isset($params['bulkaddsource'])    ? $params['bulkaddsource']    : 'bulkaddsourceuserid');
    $discountcode     = (isset($params['discountcode'])     ? $params['discountcode']     : '');
    $notificationtype = (isset($params['notificationtype']) ? $params['notificationtype'] : MDL_F2F_BOTH);

    if (isset($params['approvalreqd'])) {
        // Overwrite default behaviour as bulkadd_* is requested
        $facetoface->approvalreqd = $params['approvalreqd'];
        $facetoface->ccmanager = (isset($params['ccmanager']) ? $params['ccmanager'] : 0);
    }

    // Check parameters.
    if ($bulkaddsource == 'bulkaddsourceuserid') {
        if (!is_int($userid) && !ctype_digit($userid)) {
            $result['name'] = '';
            $result['result'] = get_string('error:userimportuseridnotanint', 'facetoface', $userid);
            return $result;
        }
    }

    // Get user.
    switch ($bulkaddsource) {
        case 'bulkaddsourceuserid':
            $user = $DB->get_record('user', array('id' => $userid));
            break;
        case 'bulkaddsourceidnumber':
            $user = $DB->get_record('user', array('idnumber' => $userid));
            break;
        case 'bulkaddsourceusername':
            $user = $DB->get_record('user', array('username' => $userid));
            break;
    }
    if (!$user) {
        $result['name'] = '';
        $a = array('fieldname' => get_string($bulkaddsource, 'facetoface'), 'value' => $userid);
        $result['result'] = get_string('userdoesnotexist', 'facetoface', $a);
        return $result;
    }

    $result['name'] = fullname($user);

    if (isguestuser($user)) {
        $a = array('fieldname' => get_string($bulkaddsource, 'facetoface'), 'value' => $userid);
        $result['result'] = get_string('cannotsignupguest', 'facetoface', $a);
        return $result;
    }

    // Make sure that the user is enroled in the course
    $context   = context_course::instance($course->id);
    if (!is_enrolled($context, $user)) {

        $defaultlearnerrole = $DB->get_record('role', array('id' => $CFG->learnerroleid));

        if (!enrol_try_internal_enrol($course->id, $user->id, $defaultlearnerrole->id, time())) {
            $result['result'] = get_string('error:enrolmentfailed', 'facetoface', fullname($user));
            return $result;
        }
    }

    // Check if they are already signed up
    $minimumstatus = ($session->datetimeknown) ? MDL_F2F_STATUS_BOOKED : MDL_F2F_STATUS_REQUESTED;
    // If multiple sessions are allowed then just check against this session
    // Otherwise check against all sessions
    $multisessionid = ($facetoface->multiplesessions ? $session->id : null);
    if (facetoface_get_user_submissions($facetoface->id, $user->id, $minimumstatus, MDL_F2F_STATUS_FULLY_ATTENDED, $multisessionid)) {
        if ($user->id == $USER->id) {
            $result['result'] = get_string('error:addalreadysignedupattendeeaddself', 'facetoface');
        } else {
            $result['result'] = get_string('error:addalreadysignedupattendee', 'facetoface');
        }
        return $result;
    }

    if (!facetoface_session_has_capacity($session, $context)) {
        if ($session->allowoverbook) {
            $status = MDL_F2F_STATUS_WAITLISTED;
        } else {
            $result['result'] = get_string('full', 'facetoface');
            return $result;
        }
    }

    // Check if we are waitlisting or booking
    if ($session->datetimeknown) {
        if (!isset($status)) {
            $status = MDL_F2F_STATUS_BOOKED;
        }

        // Check if there are any date conflicts
        if (!$ignoreconflicts) {
            $dates = facetoface_get_session_dates($session->id);
            if ($availability = facetoface_get_sessions_within($dates, $user->id)) {
                $result['result'] = facetoface_get_session_involvement($user, $availability);
                $result['conflict'] = true;
                return $result;
            }
        }
    } else {
        $status = MDL_F2F_STATUS_WAITLISTED;
    }

    // Finally attempt to enrol
    if (!facetoface_user_signup(
        $session,
        $facetoface,
        $course,
        $discountcode,
        $notificationtype,
        $status,
        $user->id,
        !$suppressemail)) {
            $result['result'] = get_string('error:addattendee', 'facetoface', fullname($user));
            return $result;
    }

    $result['result'] = true;
    return $result;
}
Esempio n. 2
0
/**
 * Used by course/lib.php to display a few sessions besides the
 * facetoface activity on the course page
 *
 * @param object $cm the cm_info object for the F2F instance
 * @global class $USER used to get the current userid
 * @global class $CFG used to get the path to the module
 */
function facetoface_cm_info_view(cm_info $cm)
{
    global $CFG, $USER, $DB, $OUTPUT;
    $contextmodule = context_module::instance($cm->id);
    if (!has_capability('mod/facetoface:view', $contextmodule)) {
        return '';
        // Not allowed to view this activity.
    }
    $timenow = time();
    $facetoface = $DB->get_record('facetoface', array('id' => $cm->instance));
    if (!$facetoface) {
        error_log("mod/facetoface: ask to print coursemodule info for a non-existent activity ({$cm->instance})");
        return '';
    }
    // View all sessions link.
    $htmlviewallsessions = html_writer::link(new moodle_url('/mod/facetoface/view.php', array('f' => $facetoface->id)), get_string('viewallsessions', 'facetoface'), array('class' => 'f2fsessionlinks f2fviewallsessions', 'title' => get_string('viewallsessions', 'facetoface')));
    $table = new html_table();
    $table->attributes['class'] = 'table90 inlinetable';
    $table->data[] = array(html_writer::empty_tag('hr'));
    if ($submissions = facetoface_get_user_submissions($facetoface->id, $USER->id)) {
        $submission = array_shift($submissions);
        // First submission.
        // User has signedup for the instance.
        if ($session = facetoface_get_session($submission->sessionid)) {
            $sessiondate = '';
            $sessiontime = '';
            if ($session->datetimeknown) {
                foreach ($session->sessiondates as $date) {
                    if (!empty($sessiondate)) {
                        $sessiondate .= html_writer::empty_tag('br');
                    }
                    $sessiondate .= userdate($date->timestart, get_string('strftimedate'));
                    if (!empty($sessiontime)) {
                        $sessiontime .= html_writer::empty_tag('br');
                    }
                    $sessiontime .= userdate($date->timestart, get_string('strftimetime')) . ' - ' . userdate($date->timefinish, get_string('strftimetime'));
                }
            } else {
                $sessiondate = get_string('wait-listed', 'facetoface');
                $sessiontime = get_string('wait-listed', 'facetoface');
            }
            $location = ' ';
            $customfielddata = facetoface_get_customfielddata($session->id);
            if (!empty($customfielddata['location'])) {
                $location = ' ' . $customfielddata['location']->data;
            }
            $venue = ' ';
            if (!empty($customfielddata['venue'])) {
                $venue = ' ' . $customfielddata['venue']->data;
            }
            // Don't include the link to view attendees if user is lacking capability.
            $attendeeslink = '';
            if (has_capability('mod/facetoface:viewattendees', context_course::instance($cm->course))) {
                $strattendees = get_string('seeattendees', 'facetoface');
                $attendeesurl = new moodle_url('/mod/facetoface/attendees.php', array('s' => $session->id));
                $attendeeslink = ' ' . html_writer::link($attendeesurl, $strattendees, array('class' => 'f2fsessionlinks f2fviewattendees', 'title' => $strattendees));
            }
            // Don't include the link to cancel a session if it has already occurred.
            $cancellink = '';
            if (!facetoface_has_session_started($session, $timenow)) {
                $strcancel = get_string('cancelbooking', 'facetoface');
                $cancelurl = new moodle_url('/mod/facetoface/cancelsignup.php', array('s' => $session->id));
                $cancellink = ' ' . html_writer::link($cancelurl, $strcancel, array('class' => 'f2fsessionlinks f2fcancel', 'title' => $strcancel));
            }
            // Add table data.
            $table->data[] = array(get_string('bookingstatus', 'facetoface') . ': ');
            $table->data[] = array($location, $venue, $sessiondate, $sessiontime);
            $table->data[] = array(html_writer::tag('span', get_string('options', 'facetoface') . ': ' . html_writer::link(new moodle_url('/mod/facetoface/signup.php', array('s' => $session->id)), get_string('moreinfo', 'facetoface'), array('class' => 'f2fsessionlinks f2fsessioninfolink', 'title' => get_string('moreinfo', 'facetoface'))) . "{$attendeeslink}{$cancellink}"));
            $table->data[] = array($htmlviewallsessions);
        }
    } else {
        if ($facetoface->display > 0 && ($sessions = facetoface_get_sessions($facetoface->id))) {
            $table->data[] = array(get_string('signupforsession', 'facetoface'));
            $count = 0;
            foreach ($sessions as $session) {
                // Don't display past or in-progress sessions.
                if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) {
                    continue;
                }
                // Don't diisplay full sessions.
                if (!facetoface_session_has_capacity($session, $contextmodule)) {
                    continue;
                }
                // Check display count.
                $count++;
                if ($count > $facetoface->display) {
                    break;
                }
                $multiday = '';
                $sessiondate = '';
                $sessiontime = '';
                if ($session->datetimeknown) {
                    if (empty($session->sessiondates)) {
                        $sessiondate = get_string('unknowndate', 'facetoface');
                        $sessiontime = get_string('unknowntime', 'facetoface');
                    } 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', 'facetoface') . ')';
                        }
                    }
                } else {
                    $sessiondate = get_string('wait-listed', 'facetoface');
                }
                $locationstr = '';
                $customfielddata = facetoface_get_customfielddata($session->id);
                if (!empty($customfielddata['location']) && trim($customfielddata['location']->data) != '') {
                    $locationstr = $customfielddata['location']->data . ', ';
                }
                if ($cm->uservisible) {
                    $signupurl = new moodle_url('/mod/facetoface/signup.php', array('s' => $session->id));
                    $row = array(html_writer::link($signupurl, "{$locationstr} {$sessiondate} {$sessiontime} {$multiday}", array('class' => 'f2fsessiontime')));
                } else {
                    $row = array(html_writer::tag('span', "{$locationstr} {$sessiondate} {$sessiontime} {$multiday}", array('class' => 'f2fsessiontime')));
                }
                // Add to table.
                $table->data[] = $row;
            }
            if ($cm->uservisible) {
                $table->data[] = array($htmlviewallsessions);
            } else {
                $table->data[] = array($strviewallsessions);
            }
        } else {
            // Nothing to display to this user.
            return;
        }
    }
    $cm->set_after_link(html_writer::table($table));
}
Esempio n. 3
0
 // 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 (!enrol_try_internal_enrol($course->id, $user->id, 5)) {
         $errors[] = get_string('error:enrolmentfailed', 'facetoface', fullname($user));
         $errors[] = get_string('error:addattendee', 'facetoface', fullname($user));
         continue;
         // Don't sign the user up.
     }
 }
 $usernamefields = get_all_user_name_fields(true);
 if (facetoface_get_user_submissions($facetoface->id, $adduser)) {
     $erruser = $DB->get_record('user', array('id' => $adduser), "id, {$usernamefields}");
     $errors[] = get_string('error:addalreadysignedupattendee', 'facetoface', fullname($erruser));
 } else {
     if (!facetoface_session_has_capacity($session, $context)) {
         $errors[] = get_string('full', 'facetoface');
         break;
         // No point in trying to add other people.
     }
     // Check if we are waitlisting or booking.
     if ($session->datetimeknown) {
         $status = MDL_F2F_STATUS_BOOKED;
     } else {
         $status = MDL_F2F_STATUS_WAITLISTED;
     }
     if (!facetoface_user_signup($session, $facetoface, $course, '', MDL_F2F_BOTH, $status, $adduser, !$suppressemail)) {
         $erruser = $DB->get_record('user', array('id' => $adduser), "id, {$usernamefields}");
         $errors[] = get_string('error:addattendee', 'facetoface', fullname($erruser));
     }
 }
Esempio n. 4
0
    /**
     * Builds session list table given an array of sessions
     */
    public function print_session_list_table($customfields, $sessions, $viewattendees, $editsessions) {
        $output = '';

        $tableheader = array();
        foreach ($customfields as $field) {
            if (!empty($field->showinsummary)) {
                $tableheader[] = format_string($field->name);
            }
        }
        $tableheader[] = get_string('date', 'facetoface');
        $tableheader[] = get_string('time', 'facetoface');
        $tableheader[] = get_string('room', 'facetoface');
        if ($viewattendees) {
            $tableheader[] = get_string('capacity', 'facetoface');
        } else {
            $tableheader[] = get_string('seatsavailable', 'facetoface');
        }
        $tableheader[] = get_string('status', 'facetoface');
        $tableheader[] = get_string('options', 'facetoface');

        $timenow = time();

        $table = new html_table();
        $table->summary = get_string('previoussessionslist', 'facetoface');
        $table->attributes['class'] = 'generaltable fullwidth';
        $table->head = $tableheader;
        $table->data = array();

        foreach ($sessions as $session) {

            $isbookedsession = false;
            $bookedsession = $session->bookedsession;
            $sessionstarted = false;
            $sessionfull = false;

            $sessionrow = array();

            // Custom fields
            $customdata = $session->customfielddata;
            foreach ($customfields as $field) {
                if (empty($field->showinsummary)) {
                    continue;
                }

                if (empty($customdata[$field->id])) {
                    $sessionrow[] = ' ';
                } else {
                    if (CUSTOMFIELD_TYPE_MULTISELECT == $field->type) {
                        $sessionrow[] = str_replace(CUSTOMFIELD_DELIMITER, html_writer::empty_tag('br'), format_string($customdata[$field->id]->data));
                    } else {
                        $sessionrow[] = format_string($customdata[$field->id]->data);
                    }
                }
            }

            // Dates/times
            $allsessiondates = '';
            $allsessiontimes = '';
            if ($session->datetimeknown) {
                foreach ($session->sessiondates as $date) {
                    if (!empty($allsessiondates)) {
                        $allsessiondates .= html_writer::empty_tag('br');
                        $allsessiontimes .= html_writer::empty_tag('br');
                    }
                    $sessionobj = facetoface_format_session_times($date->timestart, $date->timefinish, $date->sessiontimezone);
                    if ($sessionobj->startdate == $sessionobj->enddate) {
                        $allsessiondates .= $sessionobj->startdate;
                    } else {
                        $allsessiondates .= $sessionobj->startdate . ' - ' . $sessionobj->enddate;
                    }
                    $allsessiontimes .= $sessionobj->starttime . ' - ' . $sessionobj->endtime . ' ' . $sessionobj->timezone;
                }
            } else {
                $allsessiondates = get_string('wait-listed', 'facetoface');
                $allsessiontimes = get_string('wait-listed', 'facetoface');
                $sessionwaitlisted = true;
            }
            $sessionrow[] = $allsessiondates;
            $sessionrow[] = $allsessiontimes;

            // Room.
            if (isset($session->room)) {
                $roomhtml = '';
                $roomhtml .= isset($session->room->name) ? format_string($session->room->name) . html_writer::empty_tag('br') : '';
                $roomhtml .= isset($session->room->building) ? format_string($session->room->building) . html_writer::empty_tag('br') : '';
                $roomhtml .= isset($session->room->address) ? format_string($session->room->address) . html_writer::empty_tag('br') : '';
                $sessionrow[] = $roomhtml;
            } else {
                $sessionrow[] = '';
            }

            // Capacity.
            if ($session->datetimeknown) {
                $signupcount = facetoface_get_num_attendees($session->id, MDL_F2F_STATUS_BOOKED);
            } else {
                $signupcount = facetoface_get_num_attendees($session->id, MDL_F2F_STATUS_APPROVED);
            }
            if ($viewattendees) {
                if ($session->datetimeknown) {
                    $a = array('current' => $signupcount, 'maximum' => $session->capacity);
                    $stats = get_string('capacitycurrentofmaximum', 'facetoface', $a);
                    if ($signupcount > $session->capacity) {
                        $stats .= get_string('capacityoverbooked', 'facetoface');
                    }
                    $waitlisted = facetoface_get_num_attendees($session->id, MDL_F2F_STATUS_APPROVED) - $signupcount;
                    if ($waitlisted > 0) {
                        $stats .= " (" . $waitlisted . " " . get_string('status_waitlisted', 'facetoface') . ")";
                    }
                } else {
                    $stats = $session->capacity . " (" . $signupcount . " " . get_string('status_waitlisted', 'facetoface') . ")";
                }
            } else {
                $stats = max(0, $session->capacity - $signupcount);
            }
            $sessionrow[] = $stats;

            // Status.
            $allowcancellation = false;
            $status  = get_string('bookingopen', 'facetoface');
            if ($session->datetimeknown && facetoface_has_session_started($session, $timenow) && facetoface_is_session_in_progress($session, $timenow)) {
                $status = get_string('sessioninprogress', 'facetoface');
                $sessionstarted = true;
                // If user status is wait-listed.
                if ($bookedsession && $bookedsession->statuscode == MDL_F2F_STATUS_WAITLISTED) {
                    $allowcancellation = true;
                }
            } else if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) {
                $status = get_string('sessionover', 'facetoface');
                $sessionstarted = true;
                // If user status is wait-listed.
                if ($bookedsession && $bookedsession->statuscode == MDL_F2F_STATUS_WAITLISTED) {
                    $allowcancellation = true;
                }
            } else if ($bookedsession && $session->id == $bookedsession->sessionid) {
                $signupstatus = facetoface_get_status($bookedsession->statuscode);
                $status = get_string('status_'.$signupstatus, 'facetoface');
                $isbookedsession = true;
            } else if ($signupcount >= $session->capacity) {
                $status = get_string('bookingfull', 'facetoface');
                $sessionfull = true;
            }

            $sessionrow[] = $status;

            // Options.
            $options = '';
            if ($editsessions) {
                $options .= $this->output->action_icon(new moodle_url('sessions.php', array('s' => $session->id)), new pix_icon('t/edit', get_string('edit', 'facetoface')), null, array('title' => get_string('editsession', 'facetoface'))) . ' ';
                $options .= $this->output->action_icon(new moodle_url('sessions.php', array('s' => $session->id, 'c' => 1)), new pix_icon('t/copy', get_string('copy', 'facetoface')), null, array('title' => get_string('copysession', 'facetoface'))) . ' ';
                $options .= $this->output->action_icon(new moodle_url('sessions.php', array('s' => $session->id, 'd' => 1)), new pix_icon('t/delete', get_string('delete', 'facetoface')), null, array('title' => get_string('deletesession', 'facetoface'))) . ' ';
                $options .= html_writer::empty_tag('br');
            }
            if ($viewattendees) {
                $options .= html_writer::link('attendees.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('attendees', 'facetoface'), array('title' => get_string('seeattendees', 'facetoface')));
                $options .= html_writer::empty_tag('br');
            }
            if ($isbookedsession) {
                $options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('moreinfo', 'facetoface'), array('title' => get_string('moreinfo', 'facetoface')));
                $options .= html_writer::empty_tag('br');
                $options .= html_writer::link('cancelsignup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface')));
            } else if (!$sessionstarted and !$bookedsession) {
                if (!facetoface_session_has_capacity($session, $this->context, MDL_F2F_STATUS_WAITLISTED) && !$session->allowoverbook) {
                    $options .= get_string('none', 'facetoface');
                } else {
                    $options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('signup', 'facetoface'));
                }
            }
            if (empty($options)) {
                if ($sessionstarted && $allowcancellation) {
                    $options = html_writer::link('cancelsignup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface')));
                } else {
                    $options = get_string('none', 'facetoface');
                }
            }
            $sessionrow[] = $options;

            $row = new html_table_row($sessionrow);

            // Set the CSS class for the row.
            if ($sessionstarted) {
                $row->attributes = array('class' => 'dimmed_text');
            } else if ($isbookedsession) {
                $row->attributes = array('class' => 'highlight');
            } else if ($sessionfull) {
                $row->attributes = array('class' => 'dimmed_text');
            }

            // Add row to table.
            $table->data[] = $row;
        }

        $output .= html_writer::table($table);

        return $output;
    }
Esempio n. 5
0
if ($signedup and $signedup != $session->id) {
    print_error('error:signedupinothersession', 'facetoface', $returnurl);
}
echo $OUTPUT->box_start();
echo $OUTPUT->heading($heading);
$timenow = time();
if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) {
    $inprogressstr = get_string('cannotsignupsessioninprogress', 'facetoface');
    $overstr = get_string('cannotsignupsessionover', 'facetoface');
    $errorstring = facetoface_is_session_in_progress($session, $timenow) ? $inprogressstr : $overstr;
    echo html_writer::empty_tag('br') . $errorstring;
    echo $OUTPUT->box_end();
    echo $OUTPUT->footer($course);
    exit;
}
if (!$signedup && !facetoface_session_has_capacity($session, $context) && !$session->allowoverbook) {
    print_error('sessionisfull', 'facetoface', $returnurl);
    echo $OUTPUT->box_end();
    echo $OUTPUT->footer($course);
    exit;
}
echo facetoface_print_session($session, $viewattendees);
if ($signedup) {
    if (!($session->datetimeknown && facetoface_has_session_started($session, $timenow))) {
        // Cancellation link.
        $cancellationurl = new moodle_url('cancelsignup.php', array('s' => $session->id, 'backtoallsessions' => $backtoallsessions));
        echo html_writer::link($cancellationurl, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface')));
        echo ' – ';
    }
    // See attendees link.
    if ($viewattendees) {
Esempio n. 6
0
$timenow = time();

if ($session->datetimeknown && facetoface_has_session_started($session, $timenow)) {
    $inprogress_str = get_string('cannotsignupsessioninprogress', 'facetoface');
    $over_str = get_string('cannotsignupsessionover', 'facetoface');

    $errorstring = facetoface_is_session_in_progress($session, $timenow) ? $inprogress_str : $over_str;

    echo $OUTPUT->notification($errorstring, 'notifyproblem');
    echo $OUTPUT->box_end();
    echo $OUTPUT->footer($course);
    exit();
}

if (!facetoface_session_has_capacity($session, $context, MDL_F2F_STATUS_WAITLISTED) && !$session->allowoverbook) {
    echo $OUTPUT->notification(get_string('sessionisfull', 'facetoface'), 'notifyproblem');
    echo $OUTPUT->box_end();
    echo $OUTPUT->footer($course);
    exit();
}

echo facetoface_print_session($session, $viewattendees);

if ($signedup) {
    if (!($session->datetimeknown && facetoface_has_session_started($session, $timenow))) {
        // Cancellation link.
        echo html_writer::link(new moodle_url('cancelsignup.php', array('s' => $session->id, 'backtoallsessions' => $backtoallsessions)), get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface')));
        echo ' – ';
    }
    // See attendees link.
Esempio n. 7
0
}
// Go back.
$url = new moodle_url('/course/view.php', array('id' => $course->id));
if ($backtoallsessions) {
    $url = new moodle_url('/mod/facetoface/view.php', array('f' => $facetoface->id, 'backtoallsessions' => $backtoallsessions));
}
echo html_writer::link($url, get_string('goback', 'facetoface')) . html_writer::end_tag('p');
/*
 * Print unapproved requests (if user able to view)
 */
if ($canapproverequests) {
    echo html_writer::empty_tag('br', array('id' => 'unapproved'));
    if (!$requests) {
        echo $OUTPUT->notification(get_string('noactionableunapprovedrequests', 'facetoface'));
    } else {
        $canbookuser = facetoface_session_has_capacity($session, $contextmodule) || $session->allowoverbook;
        $OUTPUT->heading(get_string('unapprovedrequests', 'facetoface'));
        if (!$canbookuser) {
            echo html_writer::tag('p', get_string('cannotapproveatcapacity', 'facetoface'));
        }
        $action = new moodle_url('attendees.php', array('s' => $s));
        echo html_writer::start_tag('form', array('action' => $action->out(), 'method' => 'post'));
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey));
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 's', 'value' => $s));
        echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'backtoallsessions', 'value' => $backtoallsessions)) . html_writer::end_tag('p');
        $table = new html_table();
        $table->summary = get_string('requeststablesummary', 'facetoface');
        $table->head = array(get_string('name'), get_string('timerequested', 'facetoface'), get_string('decidelater', 'facetoface'), get_string('decline', 'facetoface'), get_string('approve', 'facetoface'));
        $table->align = array('left', 'center', 'center', 'center', 'center');
        foreach ($requests as $attendee) {
            $data = array();
Esempio n. 8
0
    function test_facetoface_session_has_capacity() {
        // Test method - returns boolean.

        // Test variables.
        $session1 = $this->sessions['sess0'];
        $sess0 = $this->array_to_object($session1);

        $session2 = $this->sessions['sess1'];
        $sess1 = $this->array_to_object($session2);

        // Test for valid case.
        $this->assertFalse((bool)facetoface_session_has_capacity($sess0), $this->msgfalse);

        // Test for invalid case.
        $this->assertFalse((bool)facetoface_session_has_capacity($sess1), $this->msgfalse);

        $this->resetAfterTest(true);
    }