Public Member Functions | |
editAction () | |
saveAction () | |
gridAction () | |
jsonSaveAction () | |
jsonDeleteAction () | |
Protected Member Functions | |
_isAllowed () |
Definition at line 35 of file AnswerController.php.
_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 }