$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>'; echo $text . '<' . $form->formref . '>'; if ($authoriser_username != 'csa') { // They can't redirect away from themselves echo '<p><a href="' . $redirect . '?id=' . $data->id . '">' . get_string('redirect_form', 'local_obu_forms') . '</a></p>'; } } } } echo $OUTPUT->footer();
function update_authoriser($form, $data, $authoriser_id) { // Update the stored authorisation requests read_form_auths($data->id, $auth); if ($authoriser_id == 0) { delete_form_auths($auth); } else { $auth->authoriser = $authoriser_id; $auth->request_date = time(); write_form_auths($auth); } // Determine the URL to use to link to the form $program = new moodle_url('/local/obu_forms/process.php') . '?id=' . $data->id; // Email the new status to the author and to Student Central (if not the next authoriser) $author = get_complete_user_data('id', $data->author); $sc = get_complete_user_data('username', 'csa'); $sc_id = $sc->id; if (!$form->modular) { // Use the default CSA Team contact and notification details (PG) $sc_contact = $sc; $sc_notifications = $sc; } else { // Use the SCAT contact and notification details (UMP) $sc_contact = get_complete_user_data('username', 'scat'); $sc_notifications = get_complete_user_data('username', 'scat_notifications'); } // Add email headers to help prevent auto-responders $author->customheaders = array('Precedence: Bulk', 'X-Auto-Response-Suppress: All', 'Auto-Submitted: auto-generated'); $sc_contact->customheaders = array('Precedence: Bulk', 'X-Auto-Response-Suppress: All', 'Auto-Submitted: auto-generated'); get_form_status($author->id, $form, $data, $text, $button_text); // get the status from the author'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'] . ']'; } } $html = '<h4><a href="' . $program . '">' . $form->formref . ': ' . $form->name . $student_number . '</a></h4>' . $text; email_to_user($author, $sc_contact, 'The Status of Your Form ' . $form->formref . $student_number, html_to_text($html), $html); if ($authoriser_id != $sc_id) { get_form_status($sc_id, $form, $data, $text, $button_text); // get the status from the perspective of Student Central $html = '<h4><a href="' . $program . '">' . $form->formref . ': ' . $form->name . $student_number . '</a></h4>' . $text; email_to_user($sc_notifications, $author, 'Form ' . $form->formref . $student_number . ' Status Update (' . $author->username . ')', html_to_text($html), $html); } // Notify the next authoriser (if there is one) if ($authoriser_id) { if ($authoriser_id == $sc_id) { $authoriser = $sc_notifications; } else { $authoriser = get_complete_user_data('id', $authoriser_id); } if ($authoriser->username != 'csa-tbd') { // No notification possible if authoriser TBD $form_link = '<a href="' . $program . '">' . $form->formref . ' ' . get_string('form_title', 'local_obu_forms') . $student_number . '</a>'; $email_link = '<a href="mailto:' . $sc_contact->email . '?Subject=' . get_string('auths', 'local_obu_forms') . '" target="_top">' . $sc_contact->email . '</a>'; $html = get_string('request_authorisation', 'local_obu_forms', array('form' => $form_link, 'name' => $sc_contact->alternatename, 'phone' => $sc_contact->phone1, 'email' => $email_link)); email_to_user($authoriser, $author, 'Request for Form ' . $form->formref . $student_number . ' Authorisation (' . $author->username . ')', html_to_text($html), $html); } } }
if (!error_list()) { $db->insert(tbl("custom_fields"), $fields_array, $value_array); } } /** * Function used add fields in upload form */ function load_form_fields() { global $db; $results = $db->select(tbl("custom_fields"), "*"); if (count($results[0]) > 0) { foreach ($results as $result) { $name = $result['custom_field_name']; foreach ($result as $field => $value) { $field_array[$name][substr($field, 13, strlen($field))] = $value; } } } if (count($field_array) > 0) { return false; } return $field_array; } //Adding Admin Menu add_admin_menu('Custom Fields', 'Add New Custom Field', 'add_custom_fields.php'); add_admin_menu('Custom Fields', 'Manage Custom Fields', 'manage_custom_fields.php'); if (load_form_fields()) { register_custom_form_field(load_form_fields()); } }