コード例 #1
0
ファイル: gates.php プロジェクト: AholibamaSI/plymouth-webapp
    $response->redirect($request->uri() . '/');
});
/**
 * display gate browser
 */
respond('GET', '/', function ($request, $response, $app) {
    $gates = new Gates();
    $gates->load();
    $app->tpl->assign('gates', $gates);
    $app->tpl->display('gates.tpl');
});
/**
 * add gate browser
 */
respond('POST', '/', function ($request, $response, $app) {
    $gate = new Gate($_POST);
    if ($gate->save()) {
        $_SESSION['successes'][] = 'Gate added successfully!';
    } else {
        $_SESSION['errors'][] = 'The Gate failed to save.';
    }
    //end else
    $response->redirect($request->uri());
});
/**
 * view specific gate
 */
respond('GET', '/[i:gate](/[:action])?', function ($request, $response, $app) {
    $gate = preg_replace('/[^a-zA-Z0-9\\-_]/', '', $request->param('gate'));
    $action = $request->param('action');
    $gate = new Gatesystem($gate);
コード例 #2
0
/**
 * teacher-cert/gate-system/*
 */
use PSU\TeacherCert\Student\GateSystem as StudentGateSystem, PSU\Student\Test, PSU\TeacherCert;
respond('/[:gate_system]/?[*]?', function ($request, $response, $app) {
    $gate_system_id = $request->param('gate_system');
    $app->populate(new TeacherCert\GateSystem($gate_system_id));
    $app->breadcrumbs->push(new \PSU\Template\Breadcrumb($app->gate_system->name, $app->resolver($app->gate_system)));
});
respond('/[:gate_system]/?', function ($request, $response, $app) {
    $app->tpl->display('gate-system.tpl');
});
respond('/[:gate_system]/gate/[:gate]/?[*]?', function ($request, $response, $app) {
    $gate_id = $request->param('gate');
    $gate = TeacherCert\Gate::get($gate_id);
    $app->populate('gate', $gate);
    $app->breadcrumbs->push($app->gate->name);
    $app->tpl->display('gate.tpl');
});
respond('POST', '/[:gate_system](/gate/[:gate])?/add-student/?', function ($request, $response, $app) {
    $response->deny_to_readonly();
    $student_id = $request->param('student_id');
    $person = \PSUPerson::get($student_id);
    $redirect = $GLOBALS['BASE_URL'] . '/gate-system/' . $app->gate_system->slug;
    if ($gate) {
        $redirect .= '/gate/' . $gate->slug;
    }
    //end if
    if ($app->gate_system->level_code == 'ug' && !$person->student->ug) {
        $_SESSION['errors'][] = "{$person->formatName('l, f m')} is not an active UG student!";