Пример #1
0
 public function createAction()
 {
     // only members can upload music
     if (!$this->_helper->requireUser()->isValid()) {
         return;
     }
     if (!$this->_helper->requireAuth()->setAuthParams('music_playlist', null, 'create')->isValid()) {
         return;
     }
     // catch uploads from FLASH fancy-uploader and redirect to uploadSongAction()
     if ($this->getRequest()->getQuery('ul', false)) {
         return $this->_forward('upload-song', null, null, array('format' => 'json'));
     }
     $this->view->form = $form = new Music_Form_Create();
     $this->view->playlist_id = $this->_getParam('playlist_id', '0');
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     // Process
     $db = Engine_Api::_()->getDbTable('playlists', 'music')->getAdapter();
     $db->beginTransaction();
     try {
         $playlist = $this->view->form->saveValues();
         $db->commit();
     } catch (Exception $e) {
         $db->rollback();
         throw $e;
     }
     return $this->_helper->redirector->gotoUrl($playlist->getHref(), array('prependBase' => false));
 }