Beispiel #1
0
    $mentee_wpid = $_POST['data'][0];
    $mentor_wpid = $_POST['data'][1];
    if (TrainingTracker::valid_wpid($mentee_wpid)) {
        if (TrainingTracker::valid_wpid($mentor_wpid)) {
            $result = TrainingTracker::get_teams($mentee_wpid, 'mentee');
            if (isset($result[0])) {
                TrainingTracker::team_set_mentee($mentee_wpid, $mentor_wpid);
                // if team exists with that mentee replace mentor
            } else {
                TrainingTracker::team_insert($mentee_wpid, $mentor_wpid);
                //if the mentee isn't in a team make them a team
            }
        } else {
            if ($mentor_wpid == 'unassigned') {
                //if you move the mentee back to the mentee category in the team builder, it removes their database entry.
                TrainingTracker::team_delete($mentee_wpid);
            }
        }
    }
});
//view teams
respond('GET', '/list/[:wpid]', function ($request, $responce, $app) {
    if (!$app->is_mentor) {
        $responce->redirect('../list');
    }
    $wpid = $request->wpid;
    if (!TrainingTracker::valid_wpid($wpid)) {
        $responce->redirect('../list');
    }
    $teams = TrainingTracker::get_teams();
    if (isset($teams["{$wpid}"])) {