Esempio n. 1
0
}
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
$PAGE->set_context(context_system::instance());
$PAGE->set_title($heading);
$PAGE->set_heading($heading);
// The page contents
echo $OUTPUT->header();
echo $OUTPUT->heading($heading);
$process = $home . 'local/obu_forms/process.php';
$redirect = $home . 'local/obu_forms/redirect.php';
$auths = get_form_auths($authoriser_id);
// Get outstanding authorisation requests
foreach ($auths as $auth) {
    if ($authoriser_id != 0 || $auth->authoriser != $authoriser->id) {
        read_form_data($auth->data_id, $data);
        $template = read_form_template_by_id($data->template_id);
        $form = read_form_settings($template->form_id);
        // Check first that the user is a manager of this type of form and that it hasn't already been finally approved or rejected
        if (is_manager($form) && $data->authorisation_state == 0) {
            get_form_status($USER->id, $form, $data, $text, $button);
            // Get the authorisation trail and the next action (from the user's perspective)
            // If a staff form, extract any given student number
            $student_number = '';
            if (!$form->student) {
                load_form_fields($data, $fields);
                if (array_key_exists('student_number', $fields)) {
                    $student_number = ' [' . $fields['student_number'] . ']';
                }
            }
            echo '<h4><a href="' . $process . '?id=' . $data->id . '">' . $form->formref . ': ' . $form->name . $student_number . '</a></h4>';
function load_form_data($data_id, &$record, &$fields)
{
    if (!read_form_data($data_id, $record)) {
        return false;
    }
    load_form_fields($record, $fields);
    return true;
}
    $authoriser_id = $user->id;
    $authoriser_name = $user->firstname . ' ' . $user->lastname;
} else {
    $authoriser = null;
    $authoriser_id = 0;
    $authoriser_name = null;
}
$dir = $home . '/local/obu_forms/';
$program = $dir . 'redirect.php?id=' . $data_id;
$heading = get_string('redirect_form', 'local_obu_forms');
$PAGE->set_pagelayout('standard');
$PAGE->set_url($program);
$PAGE->set_context(context_system::instance());
$PAGE->set_heading($SITE->fullname);
$PAGE->set_title($heading);
read_form_data($data_id, $data);
$template = read_form_template_by_id($data->template_id);
$form = read_form_settings($template->form_id);
// If a staff form, extract any given student number
$student_number = '';
if (!$form->student) {
    load_form_fields($data, $fields);
    if (array_key_exists('student_number', $fields)) {
        $student_number = ' [' . $fields['student_number'] . ']';
    }
}
get_form_status($USER->id, $form, $data, $text, $button);
// get the authorisation trail and the next action (from the user's perspective)
$form_status = '<h4>' . $form->formref . ': ' . $form->name . $student_number . '</h4>' . $text;
$parameters = ['data_id' => $data_id, 'form_status' => $form_status, 'authoriser' => $authoriser, 'authoriser_name' => $authoriser_name];
// Check that they have both the authority and the ability to redirect this form