예제 #1
0
        break;
        // end default
    // end default
    case 'save':
        $ERRORS = array();
        $class_id = stripinput($_POST['item']['class_id']);
        if ($class_id == null) {
            $ERRORS[] = 'No class specified.';
        } else {
            $class = new ItemClass($db);
            $class = $class->findOneByItemClassId($class_id);
            if ($class == null) {
                $ERRORS[] = 'Invalid class specified.';
            }
        }
        // end id given
        if (sizeof($ERRORS) > 0) {
            draw_errors($ERRORS);
        } else {
            $item = new ItemType($db);
            $item->setItemClassId($class->getItemClassId());
            $item->setUniqueItem('N');
            $item->setTransferableItem('Y');
            $item->save();
            redirect(null, null, "admin-items-edit/?item[id]={$item->getItemTypeId()}");
        }
        // end no errors
        break;
        // end save
}
// end state switch