Beispiel #1
0
 public function action_newSong()
 {
     $this->template->show_logout = TRUE;
     $this->template->title = 'New song';
     $view = $this->template->content = View::factory('dashboard/songs/new');
     $error_message = NULL;
     $filename = NULL;
     $pk = FALSE;
     //            echo '<pre>'; print_r($_POST);exit;
     if ($this->request->method() == Request::POST) {
         if (isset($_FILES['image_name'])) {
             $folderName = $_POST['catalog_id'];
             $filename = $this->_save_image($_FILES['image_name'], $folderName);
         }
         //
         $linkArr = array('url' => $_POST['url'], 'source_id' => $_POST['source_id'] != 0 ? $_POST['source_id'] : 1, 'title' => $_POST['title'], 'catalog_id' => $_POST['catalog_id'], 'image_name' => $_FILES['image_name']['name'], 'language_id' => $_POST['category_id'], 'user_id' => Auth::instance()->get_user()->id, 'agegroup_id' => $_POST['agegroup_id'], 'date_added' => time(), 'is_public' => $_POST['is_public']);
         //
         $pk = Model_Links::addLink($linkArr);
     }
     if (!$filename) {
         $error_message = 'There was a problem while uploading the image.
                 Make sure it is uploaded and must be JPG/PNG/GIF file.';
     }
     if ($pk) {
         $this->redirect('dashboard/editsongs/' . $pk);
     }
     $view->uploaded_file = $filename;
     $view->error_message = $error_message;
     $this->response->body($view);
 }