예제 #1
0
 public static function destroy($trap_id)
 {
     self::check_logged_in();
     $trap = new Trap(array('trap_id' => $trap_id));
     $success = $trap->destroy();
     if ($success) {
         Redirect::to('/trapList', array('message' => "Pyydystieto poistettiin onnistuneesti"));
     } else {
         $trap = Trap::find($trap_id);
         View::make('trap/trap.html', array('trap' => $trap, 'message' => "Pyydys on liitetty saalistietoon, joten sitä ei voida poistaa. Jos pyydys ei ole enää käytössä, merkitse se käytöstä poistetuksi Muokkaa -pyydystä -näkymässä."));
     }
 }
예제 #2
0
 public static function store()
 {
     self::check_logged_in();
     $params = $_POST;
     $attributes = array('date' => $params['date'], 'time' => $params['time'], 'species' => $params['species'], 'count' => $params['count'], 'length' => $params['length'], 'weight' => $params['weight'], 'water_sys' => $params['water_sys'], 'location' => $params['location'], 'wind_speed' => $params['wind_speed'], 'wind_dir' => $params['wind_dir'], 'air_temp' => $params['air_temp'], 'water_temp' => $params['water_temp'], 'cloudiness' => $params['cloudiness'], 'notes' => $params['notes'], 'picture_url' => $params['picture_url'], 'trap_type' => $params['trap_type'], 'trap_id' => $params['trap_model']);
     if (isset($params['friends'])) {
         $attributes['friends'] = $params['friends'];
     }
     //Kint::dump($attributes);
     $catch = new CatchModel($attributes);
     $errors = $catch->errors();
     //Kint::dump($errors);
     if (count($errors) === 0) {
         $catch->save();
         //Kint::dump($catch->catch_id);
         Redirect::to("/catchList/" . $catch->catch_id . "", array('message' => 'Saalistieto lisättiin onnistuneesti!'));
     } else {
         $traps = Trap::in_use();
         $trap_types = Trap::types();
         View::make('catch/newCatch.html', array('errors' => $errors, 'attributes' => $attributes, 'traps' => $traps, 'trap_types' => $trap_types, 'friend_of' => $_SESSION['friend_of']));
     }
 }