Mage_Adminhtml_Poll_AnswerController Class Reference

Inheritance diagram for Mage_Adminhtml_Poll_AnswerController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 editAction ()
 saveAction ()
 gridAction ()
 jsonSaveAction ()
 jsonDeleteAction ()

Protected Member Functions

 _isAllowed ()


Detailed Description

Definition at line 35 of file AnswerController.php.


Member Function Documentation

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 120 of file AnswerController.php.

00121     {
00122         return Mage::getSingleton('admin/session')->isAllowed('cms/poll');
00123     }

editAction (  ) 

Definition at line 37 of file AnswerController.php.

00038     {
00039         $this->loadLayout();
00040 
00041         $this->_setActiveMenu('cms/poll');
00042         $this->_addBreadcrumb(Mage::helper('poll')->__('Poll Manager'), Mage::helper('poll')->__('Poll Manager'), $this->getUrl('*/*/'));
00043         $this->_addBreadcrumb(Mage::helper('poll')->__('Edit Poll Answer'), Mage::helper('poll')->__('Edit Poll Answer'));
00044 
00045         $this->_addContent($this->getLayout()->createBlock('adminhtml/poll_answer_edit'));
00046 
00047         $this->renderLayout();
00048     }

gridAction (  ) 

Definition at line 72 of file AnswerController.php.

00073     {
00074         $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/poll_edit_tab_answers_grid')->toHtml());
00075     }

jsonDeleteAction (  ) 

Definition at line 99 of file AnswerController.php.

00100     {
00101         $response = new Varien_Object();
00102         $response->setError(0);
00103 
00104         if ( $id = $this->getRequest()->getParam('id') ) {
00105             try {
00106                 $model = Mage::getModel('poll/poll_answer');
00107                 $model->setId(Zend_Json_Decoder::decode($id))
00108                     ->delete();
00109             } catch (Exception $e) {
00110                 $response->setError(1);
00111                 $response->setMessage($e->getMessage());
00112             }
00113         } else {
00114             $response->setError(1);
00115             $response->setMessage(Mage::helper('poll')->__('Unable to find answer to delete.'));
00116         }
00117         $this->getResponse()->setBody( $response->toJson() );
00118     }

jsonSaveAction (  ) 

Definition at line 77 of file AnswerController.php.

00078     {
00079         $response = new Varien_Object();
00080         $response->setError(0);
00081 
00082         if ( $post = $this->getRequest()->getPost() ) {
00083             $data = Zend_Json_Decoder::decode($post['data']);
00084             try {
00085                 if( trim($data['answer_title']) == '' ) {
00086                     throw new Exception(Mage::helper('poll')->__('Invalid Answer'));
00087                 }
00088                 $model = Mage::getModel('poll/poll_answer');
00089                 $model->setData($data)
00090                     ->save();
00091             } catch (Exception $e) {
00092                 $response->setError(1);
00093                 $response->setMessage($e->getMessage());
00094             }
00095         }
00096         $this->getResponse()->setBody( $response->toJson() );
00097     }

saveAction (  ) 

Definition at line 50 of file AnswerController.php.

00051     {
00052         //print '@@';
00053         if ( $post = $this->getRequest()->getPost() ) {
00054             try {
00055                 $model = Mage::getModel('poll/poll_answer');
00056                 $model->setData($post)
00057                     ->setId($this->getRequest()->getParam('id'))
00058                     ->save();
00059 
00060                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('poll')->__('Answer was successfully saved'));
00061                 $this->_redirect('*/poll/edit', array('id' => $this->getRequest()->getParam('poll_id'), 'tab' => 'answers_section'));
00062                 return;
00063             } catch (Exception $e) {
00064                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00065                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
00066                 return;
00067             }
00068         }
00069         $this->_redirect('*/*/');
00070     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:15 2009 for Magento by  doxygen 1.5.8