Beispiel #1
0
 public function edit($taleID)
 {
     $model = new \Models\Tales();
     $data['tale'] = $model->getTale($taleID);
     $data['title'] = $data['tale'][0]->title;
     if (isset($_POST['submit'])) {
         $title = $_POST['title'];
         $author = $_POST['author'];
         $file = $_FILES['tale'];
         $path = UPLOADDIR . Session::get('username') . $file['name'];
         $allowed = array('application/pdf');
         if ($title != "") {
             if ($author != "") {
                 if (in_array($file['type'], $allowed)) {
                     move_uploaded_file($file['tmp_name'], $path);
                     $postdata = array('title' => $title, 'author' => $author, 'path' => $path);
                     $where = array('taleID' => $taleID);
                     $model->update($postdata, $where);
                     Url::redirect('tales');
                 } else {
                     $error[] = "Nepovolený formát souboru!";
                 }
             } else {
                 $error[] = "Autor je prázdný!";
             }
         } else {
             $error[] = "Název je prázdný!";
         }
     }
     View::renderTemplate('header', $data);
     View::render('users\\talesEdit', $data, $error);
     View::renderTemplate('footer', $data);
 }
Beispiel #2
0
 public function accept($taleID)
 {
     if (Session::get('role') != "admin") {
         Url::redirect('');
     }
     $model = new \Models\Tales();
     $postdata = array('accepted' => 1);
     $where = array('taleID' => $taleID);
     $model->update($postdata, $where);
     Url::redirect('admin');
 }