コード例 #1
0
function local_obu_application_extend_navigation($navigation)
{
    global $CFG, $USER;
    if (!isloggedin() || isguestuser()) {
        return;
    }
    $applicant = read_applicant($USER->id, false) !== false;
    if (!has_capability('local/obu_application:manage', context_system::instance()) && !$applicant) {
        return;
    }
    // Find the 'applications' node
    $nodeParent = $navigation->find(get_string('applications', 'local_obu_application'), navigation_node::TYPE_SYSTEM);
    // If necessary, add the 'applications' node to 'home'
    if (!$nodeParent) {
        $nodeHome = $navigation->children->get('1')->parent;
        if ($nodeHome) {
            $nodeParent = $nodeHome->add(get_string('applications', 'local_obu_application'), null, navigation_node::TYPE_SYSTEM);
        }
    }
    if ($nodeParent) {
        if (has_capability('local/obu_application:manage', context_system::instance())) {
            $node = $nodeParent->add(get_string('application_approvals', 'local_obu_application'), '/local/obu_application/mdl_approvals.php');
            $node = $nodeParent->add(get_string('hls_approvals', 'local_obu_application'), '/local/obu_application/mdl_approvals.php?approver=hls');
            $node = $nodeParent->add(get_string('list_applications', 'local_obu_application'), '/local/obu_application/mdl_list.php');
            $node = $nodeParent->add(get_string('data_xfer', 'local_obu_application'), '/local/obu_application/mdl_xfer.php');
        }
        if (has_capability('local/obu_application:admin', context_system::instance())) {
            $node = $nodeParent->add(get_string('courses', 'local_obu_application'), '/local/obu_application/mdl_course.php');
            $node = $nodeParent->add(get_string('supplements', 'local_obu_application'), '/local/obu_application/mdl_supplement.php');
            $node = $nodeParent->add(get_string('organisations', 'local_obu_application'), '/local/obu_application/mdl_organisation.php');
        }
        if (is_siteadmin()) {
            $node = $nodeParent->add(get_string('parameters', 'local_obu_application'), '/local/obu_application/mdl_param.php');
        }
        if ($applicant) {
            $node = $nodeParent->add(get_string('hls_applications', 'local_obu_application'), '/local/obu_application/');
        }
    }
}
コード例 #2
0
 * @author     Peter Welham
 * @copyright  2016, Oxford Brookes University
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 *
 */
require '../../config.php';
require_once './hide_moodle.php';
require_once './locallib.php';
require_once './profile_form.php';
require_obu_login();
$url = new moodle_url('/local/obu_application/');
$PAGE->set_title($CFG->pageheading . ': ' . get_string('profile', 'local_obu_application'));
// HTTPS is required in this page when $CFG->loginhttps enabled
$PAGE->https_required();
$PAGE->set_url('/local/obu_application/profile.php');
$record = read_applicant($USER->id, false);
// May not exist yet
if ($record === false || $record->address_1 == '') {
    // Must complete the contact details first
    $message = get_string('complete_contact_details', 'local_obu_application');
} else {
    $message = '';
}
$nationalities = get_nationalities();
$parameters = ['record' => $record, 'nationalities' => $nationalities];
$mform = new profile_form(null, $parameters);
if ($mform->is_cancelled()) {
    redirect($url);
} else {
    if ($mform_data = $mform->get_data()) {
        if ($mform_data->submitbutton == get_string('save', 'local_obu_application')) {
コード例 #3
0
 *
 */
require '../../config.php';
require_once './hide_moodle.php';
require_once './locallib.php';
require_once './contact_form.php';
require_obu_login();
$home = new moodle_url('/local/obu_application/');
$url = $home . 'contact.php';
$PAGE->set_title($CFG->pageheading . ': ' . get_string('contactdetails', 'local_obu_application'));
// HTTPS is required in this page when $CFG->loginhttps enabled
$PAGE->https_required();
$PAGE->set_url($url);
$message = '';
$counties = get_counties();
$parameters = ['user' => read_user($USER->id), 'applicant' => read_applicant($USER->id, false), 'counties' => $counties];
$mform = new contact_form(null, $parameters);
if ($mform->is_cancelled()) {
    redirect($home);
} else {
    if ($mform_data = $mform->get_data()) {
        if ($mform_data->submitbutton == get_string('save', 'local_obu_application')) {
            $mform_data->county = $counties[$mform_data->domicile_code];
            write_user($USER->id, $mform_data);
            write_contact_details($USER->id, $mform_data);
        }
        redirect($home);
    }
}
echo $OUTPUT->header();
if ($message) {
コード例 #4
0
function write_application($user_id, $form_data)
{
    global $DB;
    $user = read_user($user_id);
    // Contact details
    $applicant = read_applicant($user_id, true);
    // Profile & course must exist
    // Initialise the new record
    $record = new stdClass();
    $record->id = 0;
    $record->userid = $user_id;
    // Contact details
    $record->title = $applicant->title;
    $record->firstname = $user->firstname;
    $record->lastname = $user->lastname;
    $record->address_1 = $applicant->address_1;
    $record->address_2 = $applicant->address_2;
    $record->address_3 = $applicant->address_3;
    $record->town = $applicant->town;
    $record->domicile_code = $applicant->domicile_code;
    $record->county = $applicant->county;
    $record->postcode = $applicant->postcode;
    $record->phone = $user->phone1;
    $record->email = $user->email;
    // Profile
    $record->birthdate = $applicant->birthdate;
    $record->nationality_code = $applicant->nationality_code;
    $record->nationality = $applicant->nationality;
    $record->p16school = $applicant->p16school;
    $record->p16schoolperiod = $applicant->p16schoolperiod;
    $record->p16fe = $applicant->p16fe;
    $record->p16feperiod = $applicant->p16feperiod;
    $record->training = $applicant->training;
    $record->trainingperiod = $applicant->trainingperiod;
    $record->prof_level = $applicant->prof_level;
    $record->prof_award = $applicant->prof_award;
    $record->prof_date = $applicant->prof_date;
    $record->emp_place = $applicant->emp_place;
    $record->emp_area = $applicant->emp_area;
    $record->emp_title = $applicant->emp_title;
    $record->emp_prof = $applicant->emp_prof;
    $record->prof_reg_no = $applicant->prof_reg_no;
    if ($applicant->criminal_record == '1') {
        // '1' = yes, '2' = no
        $record->criminal_record = '1';
        // Yes
    } else {
        $record->criminal_record = '0';
        // No
    }
    // Course
    $record->course_code = $applicant->course_code;
    $record->course_name = $applicant->course_name;
    $record->course_date = $applicant->course_date;
    $record->statement = $applicant->statement;
    $course = read_course_record($applicant->course_code);
    if ($course->supplement != '') {
        // There should be supplementary data
        $record->supplement_data = $applicant->supplement_data;
    }
    // Final details
    $record->self_funding = $form_data->self_funding;
    //	$record->manager_email = $form_data->email;
    if (isset($form_data->declaration)) {
        // Only set if checked
        $record->declaration = 1;
    } else {
        $record->declaration = 0;
    }
    $record->application_date = time();
    return $DB->insert_record('local_obu_application', $record);
    // The remaining fields will have default values
}