public static function doAction($action, $id) { switch ($action) { case 'showList': $out = Abteilung::getAll(); $out = self::transform($out); break; case 'showUpdate': $out = Abteilung::getById($id); $out = self::transformUpdate($out); break; case 'showInsert': $out = self::transformUpdate(); break; case 'update': $abteilungFiltered = filter_input(INPUT_POST, 'Abteilung', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS & FILTER_SANITIZE_SPECIAL_CHARS & FILTER_SANITIZE_SPECIAL_CHARS); $updateabteilungidFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT & FILTER_SANITIZE_SPECIAL_CHARS); $out = new Abteilung($abteilungFiltered, $updateabteilungidFiltered); $out = Abteilung::update($out); $out = Abteilung::getAll(); $out = self::transform($out); break; case 'insert': $abteilungFiltered = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS & FILTER_SANITIZE_SPECIAL_CHARS & FILTER_SANITIZE_SPECIAL_CHARS & FILTER_SANITIZE_SPECIAL_CHARS); $out = new Abteilung($abteilungFiltered, NULL); $out = Abteilung::insert($out); print_r($out); $out = Abteilung::getAll(); $out = self::transform($out); break; case 'delete': $deleteabteilungidFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS & FILTER_SANITIZE_SPECIAL_CHARS & FILTER_SANITIZE_SPECIAL_CHARS); $out = $deleteabteilungidFiltered; $out = Abteilung::delete($out); $out = Abteilung::getAll(); $out = self::transform($out); break; default: break; } return $out; }
public static function doAction($action, &$view, $id) { switch ($action) { case 'showList': $out = Abteilung::getAll(); $out = self::transform($out); break; case 'showUpdate': $out = Abteilung::getById($id); $out = self::transformUpdate($out); break; case 'showInsert': $out = self::transformUpdate(); break; case 'update': $daten = $_POST['daten']; $daten = json_decode($daten, FALSE); $out = new Abteilung($daten->abteilung, $daten->uabid); $out = Abteilung::update($out); $out = Abteilung::getAll(); $out = self::transform($out); break; case 'insert': $daten = $_POST['daten']; $daten = json_decode($daten, FALSE); $out = new Abteilung($daten->abteilung, NULL); $out = Abteilung::insert($out); $out = Abteilung::getAll(); $out = self::transform($out); break; case 'delete': $out = $_POST['labid']; $out = Abteilung::delete($out); $out = Abteilung::getAll(); $out = self::transform($out); break; default: break; } return $out; }