Exemplo n.º 1
0
                $ERRORS[] = 'Invalid color specified.';
            }
        }
        // end pet exists
        if (sizeof($ERRORS) > 0) {
            draw_errors($ERRORS);
        } else {
            // Add pet.
            $pet = new Pet($db);
            $pet->setUserId($User->getUserId());
            $pet->setPetSpecieId($specie->getPetSpecieId());
            $pet->setPetSpecieColorId($color->getPetSpecieColorId());
            $pet->setPetName($pet_name);
            $pet->setHunger($specie->getMaxHunger());
            $pet->setHappiness($specie->getMaxHappiness());
            $pet->setCreatedAt($pet->sysdate());
            $pet->save();
            // If the user has no other pets, make this the active one.
            if (sizeof($User->grabPets()) == 0) {
                $pet->makeActive();
            }
            // Session mog
            $_SESSION['hilight_pet_id'] = $pet->getUserPetId();
            // Redirect
            redirect('pets');
        }
        // end no errors; DO IT
        break;
        // end spawn
}
// end state switch