コード例 #1
0
$o->defaultlevel = $_POST['defaultlevel'];
$o->createdby = $xoopsUser->getVar('uid');
$o->updatedby = $xoopsUser->getVar('uid');
if ($isactive == 1 or $isactive == "on") {
    $o->isactive = 1;
} else {
    $o->isactive = 0;
}
switch ($action) {
    //When user submit new organization
    case "create":
        // if the token is exist and not yet expired
        $log->showLog(4, "Accessing create record event, with accountgroup name={$o->accountgroup_name}");
        if ($s->check(false, $token, "CREATE_ACG")) {
            if ($o->insertAccountGroup()) {
                $latest_id = $o->getLatestAccountGroupID();
                redirect_header("accountgroup.php?action=edit&accountgroup_id={$latest_id}", $pausetime, "Your data is saved, the new id={$latest_id}");
            } else {
                $token = $s->createToken($tokenlife, "CREATE_ACG");
                $o->orgctrl = $ctrl->selectionOrg($o->createdby, $o->organization_id, 'N', "", 'Y');
                $o->accounclassctrl = $ctrl->getAccClass($o->accountclass_id, 'N');
                $o->getInputForm("new", -1, $token);
                $o->showAccountGroupTable("WHERE accountgroup_id>0 and organization_id={$defaultorganization_id}", "ORDER BY initial,defaultlevel,accountgroup_name");
            }
        } else {
            // if the token is not valid or the token is expired, it back to previous form with previous inputed data
            $token = $s->createToken($tokenlife, "CREATE_ACG");
            $o->orgctrl = $ctrl->selectionOrg($o->createdby, $o->organization_id, 'N', "", 'Y');
            $o->accounclassctrl = $ctrl->getAccClass($o->accountclass_id, 'N');
            $o->getInputForm("new", -1, $token);
            $o->showAccountGroupTable("WHERE accountgroup_id>0 and organization_id={$defaultorganization_id}", "ORDER BY initial,defaultlevel,accountgroup_name");