Example #1
0
 public function uploadAction()
 {
     if (isset($_GET['ul']) || isset($_FILES['Filedata'])) {
         return $this->_forward('upload-photo', null, null, array('format' => 'json'));
     }
     if (!$this->_helper->requireAuth()->setAuthParams('album', null, 'create')->isValid()) {
         return;
     }
     // Get navigation
     $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('album_main');
     // Get form
     $this->view->form = $form = new Album_Form_Album();
     if (!$this->getRequest()->isPost()) {
         if (null !== ($album_id = $this->_getParam('album_id'))) {
             $form->populate(array('album' => $album_id));
         }
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     $db = Engine_Api::_()->getItemTable('album')->getAdapter();
     $db->beginTransaction();
     try {
         $album = $form->saveValues();
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
     $this->_helper->redirector->gotoRoute(array('action' => 'editphotos', 'album_id' => $album->album_id), 'album_specific', true);
 }