public static function lisaaRyhma() { self::check_yllapito(); $nimi = $_POST['ryhma']; $ryhma = new Kayttajaryhma(array('kuvaus' => $nimi)); $errors = $ryhma->errors(); if (count($errors) == 0) { $ryhma->lisaa(); Redirect::to('/kayttajaryhma/' . $ryhma->id); } View::make('ryhmahallinta.html', array('virheet' => $errors, 'ryhmat' => Kayttajaryhma::haeKaikki())); }
public static function muokkaa($id) { self::check_yllapito(); $lomakkeenTiedot = $_POST; $aihealue = Aihealue::haeYksi($id); $aihealue->otsikko = $lomakkeenTiedot['otsikko']; $aihealue->kuvaus = $lomakkeenTiedot['kuvaus']; $errors = $aihealue->errors(); if (count($errors) == 0) { $aihealue->muokkaa(); $aihealue->poistaAlueenRyhmat(); if (array_key_exists('ryhmat', $lomakkeenTiedot)) { $ryhmat = $lomakkeenTiedot['ryhmat']; for ($i = 0; $i < count($ryhmat); $i++) { $aihealue->lisaaAlueelleRyhma($ryhmat[$i]); } } Redirect::to('/aihealue/' . $aihealue->id); } else { $kayttajaryhmat = Kayttajaryhma::haeKaikki(); View::make('muokkaaAihealue.html', array('aihealue' => $aihealue, 'virheet' => $errors, 'kayttajaryhmat' => $kayttajaryhmat)); } }