// end default
     case 'toggle':
         $ERRORS = array();
         $color_id = stripinput($_POST['color']['id']);
         $color = new PetSpecieColor($db);
         $color = $color->findOneByPetSpecieColorId($color_id);
         if ($color == null) {
             $ERRORS[] = 'Invalid color specified.';
         }
         if (sizeof($ERRORS) > 0) {
             draw_errors($ERRORS);
         } else {
             $mapping = new PetSpecie_PetSpecieColor($db);
             $mapping = $mapping->findOneBy(array('pet_specie_id' => $specie->getPetSpecieId(), 'pet_specie_color_id' => $color->getPetSpecieColorId()));
             if ($mapping == null) {
                 $mapping = new PetSpecie_PetSpecieColor($db);
                 $mapping->setPetSpecieId($specie->getPetSpecieId());
                 $mapping->setPetSpecieColorId($color->getPetSpecieColorId());
                 $mapping->save();
                 $_SESSION['petadmin_notice'] = "{$color->getColorName()} enabled.";
             } else {
                 $mapping->destroy();
                 $_SESSION['petadmin_notice'] = "{$color->getColorName()} disabled.";
             }
             redirect(null, null, "admin-pet-specie-colors/?specie[id]={$specie->getPetSpecieId()}");
         }
         // end no errors
         break;
         // end toggle
 }
 // end switch
Example #2
0
             foreach ($colors as $color) {
                 // $COLOR_LIST[$color->getPetSpeciePetSpecieColorId()] = $color->getColorName();
                 $COLOR_LIST[$color->getColorImg()] = $color->getColorName();
             }
             if (sizeof($COLOR_LIST) == 1) {
                 $ERRORS[] = 'Since there are no available colors for this pet, you cannot adopt it!';
             }
         }
         // end try to load color
     }
     // end user has acceptable number of pets
     if (sizeof($ERRORS) > 0) {
         draw_errors($ERRORS);
     } else {
         $PET = array('id' => $specie->getPetSpecieId(), 'name' => $specie->getSpecieName(), 'description' => $specie->getSpecieDescr(), 'image' => null, 'image_dir' => $specie->getRelativeImageDir());
         $color = PetSpecie_PetSpecieColor::randomColor($specie->getPetSpecieId(), $db);
         if ($color != null) {
             $PET['image'] = "{$APP_CONFIG['public_dir']}/resources/pets/{$specie->getRelativeImageDir()}/{$color->getColorImg()}";
         }
         $renderer->assign('pet', $PET);
         $renderer->assign('colors', $COLOR_LIST);
         $renderer->display('pets/create_details.tpl');
     }
     // end pet is valid
     break;
     // end details
 // end details
 case 'spawn':
     $ERRORS = array();
     $specie_id = stripinput($_POST['pet']['specie_id']);
     $color_id = stripinput($_POST['pet']['color_id']);