Пример #1
0
 public function editAction()
 {
     if (!$this->_helper->requireSubject('album_photo')->isValid()) {
         return;
     }
     if (!$this->_helper->requireAuth()->setAuthParams(null, null, 'edit')->isValid()) {
         return;
     }
     $viewer = Engine_Api::_()->user()->getViewer();
     $photo = Engine_Api::_()->core()->getSubject('album_photo');
     $this->view->form = $form = new Album_Form_Photo_Edit();
     $form->populate($photo->toArray());
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     $values = $form->getValues();
     $db = $photo->getTable()->getAdapter();
     $db->beginTransaction();
     try {
         $photo->setFromArray($values);
         $photo->save();
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
     return $this->_forward('success', 'utility', 'core', array('messages' => array(Zend_Registry::get('Zend_Translate')->_('Your changes have been saved.')), 'layout' => 'default-simple', 'parentRefresh' => true));
 }