Beispiel #1
0
<?php

//the axax post part for checklist check boxes
respond('POST', '/checklist/checkbox', function ($request, $responce, $app) {
    $checked_id = $request->data['checkboxId'];
    if (preg_match('/^\\d{1,3}$/', $checked_id)) {
        $wpid = $request->data['wpid'];
        if (TrainingTracker::valid_wpid($wpid)) {
            $response = $request->data['response'];
            $person = PSUPerson::get($wpid);
            $pidm = $person->pidm;
            $modified_by = $_SESSION['pidm'];
            $checklist_id = TrainingTracker::get_checklist_id($pidm);
            if (!TrainingTracker::checkbox_exists($checked_id, $checklist_id)) {
                TrainingTracker::checkbox_insert($checked_id, $checklist_id, $response, $_SESSION['pidm']);
            } else {
                TrainingTracker::checkbox_update($response, $modified_by, $checked_id, $checklist_id);
            }
        }
    }
});
//the post part for checklist comments
respond('POST', '/checklist/comments/[:wpid]', function ($request, $responce, $app) {
    // TODO: Y U NO REMOVE?
    // TODO: Y U NO RAGE BETTAR?
    $wpid = $request->wpid;
    if (TrainingTracker::valid_wpid($wpid)) {
        if ($_POST['name'] == 'save') {
            $comments = $_POST['comments'];
            $wpid = $request->wpid;
            if (TrainingTracker::valid_wpid($wpid)) {