示例#1
0
} else {
    $o->isactive = 'N';
}
switch ($action) {
    case "create":
        // if the token is exist and not yet expired
        $log->showLog(4, "Accessing create record event, with year name={$o->year_name}");
        if ($s->check(false, $token, "CREATE_RCE")) {
            if ($o->insertYear()) {
                $latest_id = $o->getLatestYearID();
                redirect_header("year.php", $pausetime, "Your data is saved, the new id={$latest_id}. Redirect to create new year.");
            } else {
                $log->showLog(1, "Can't create year '{$o->year_name}', please verified your data!");
                $token = $s->createToken($tokenlife, "CREATE_RCE");
                $o->getInputForm("new", -1, $token);
                $o->showYearTable();
            }
        } else {
            // if the token is not valid or the token is expired, it back to previous form with previous inputed data
            $log->showLog(1, "Can't create year '{$o->year_name}' due to token expired!");
            $token = $s->createToken($tokenlife, "CREATE_RCE");
            $o->getInputForm("new", -1, $token);
            $o->showYearTable();
        }
        break;
    case "edit":
        if ($o->fetchYear($o->year_id)) {
            //create a new token for editing a form
            $token = $s->createToken($tokenlife, "CREATE_RCE");
            $o->getInputForm("edit", $o->year, $token);
            $o->showYearTable();