Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.91 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. if (!empty($_POST))
  2.                 {
  3.                         $book->title = $_POST['title'];
  4.                         $book->isbn = $_POST['isbn'];
  5.                         $book->chapters = $_POST['chapters'];
  6.  
  7.                         $scanned = array();
  8.                         if (isset($_POST['scanned']))
  9.                         {
  10.                                 $scanned = $_POST['scanned'];
  11.                         }
  12.  
  13.                         $edited = array();
  14.                         if (isset($_POST['edited']))
  15.                         {
  16.                                 $edited = $_POST['edited'];
  17.                         }
  18.  
  19.                         $book->setChaptersStatuses($scanned, $edited);
  20.  
  21.                         $valid = $book->save();
  22.  
  23.                         if($valid === TRUE)
  24.                         {
  25.                                 unset($_SESSION['post']['edit']);
  26.                                 unset($_SESSION['formErrors']);
  27.                                 $_SESSION['notice'] = 'Boek opgeslagen.';
  28.                                 header('Location: ' . Core::url('books/view/' . $book->id));
  29.                                 exit;
  30.                         }
  31.                         else
  32.                         {
  33.                                 $_SESSION['post']['edit'] = $_POST;
  34.                                 $_SESSION['formErrors'] = $valid;
  35.                                 $_SESSION['error'] = View::factory('blocks/book_form_errors')->render();
  36.                                 header('Location: ' . Core::url('books/edit/' . $book->id));
  37.                                 exit();
  38.                         }
  39.                 }