Public Member Functions | |
indexAction () | |
newAction () | |
editAction () | |
saveAction () | |
deleteAction () | |
Protected Member Functions | |
_initAction () | |
_isAllowed () |
Definition at line 34 of file AgreementController.php.
_initAction | ( | ) | [protected] |
Initialize action
Definition at line 136 of file AgreementController.php.
00137 { 00138 $this->loadLayout() 00139 ->_setActiveMenu('sales/checkoutagreement') 00140 ->_addBreadcrumb(Mage::helper('checkout')->__('Sales'), Mage::helper('checkout')->__('Sales')) 00141 ->_addBreadcrumb(Mage::helper('checkout')->__('Checkout Conditions'), Mage::helper('checkout')->__('Checkout Terms and Conditions')) 00142 ; 00143 return $this; 00144 }
_isAllowed | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 146 of file AgreementController.php.
00147 { 00148 return Mage::getSingleton('admin/session')->isAllowed('sales/checkoutagreement'); 00149 }
deleteAction | ( | ) |
Definition at line 102 of file AgreementController.php.
00103 { 00104 $id = (int)$this->getRequest()->getParam('id'); 00105 $model = Mage::getSingleton('checkout/agreement') 00106 ->load($id); 00107 if (!$model->getId()) { 00108 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('checkout')->__('This condition no longer exists')); 00109 $this->_redirect('*/*/'); 00110 return; 00111 } 00112 00113 try { 00114 $model->delete(); 00115 00116 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('checkout')->__('Condition was successfully deleted')); 00117 $this->_redirect('*/*/'); 00118 00119 return; 00120 } 00121 catch (Mage_Core_Exception $e) { 00122 Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); 00123 } 00124 catch (Exception $e) { 00125 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('checkout')->__('Error while deleting this condition. Please try again later.')); 00126 } 00127 00128 $this->_redirectReferer(); 00129 }
editAction | ( | ) |
Definition at line 49 of file AgreementController.php.
00050 { 00051 $id = $this->getRequest()->getParam('id'); 00052 $agreementModel = Mage::getModel('checkout/agreement'); 00053 $hlp = Mage::helper('checkout'); 00054 if ($id) { 00055 $agreementModel->load($id); 00056 if (!$agreementModel->getId()) { 00057 Mage::getSingleton('adminhtml/session')->addError($hlp->__('This condition no longer exists')); 00058 $this->_redirect('*/*/'); 00059 return; 00060 } 00061 } 00062 00063 $data = Mage::getSingleton('adminhtml/session')->getAgreementData(true); 00064 if (!empty($data)) { 00065 $agreementModel->setData($data); 00066 } 00067 00068 Mage::register('checkout_agreement', $agreementModel); 00069 00070 $this->_initAction() 00071 ->_addBreadcrumb($id ? $hlp->__('Edit Condition') : $hlp->__('New Condition'), $id ? $hlp->__('Edit Condition') : $hlp->__('New Condition')) 00072 ->_addContent($this->getLayout()->createBlock('adminhtml/checkout_agreement_edit')->setData('action', $this->getUrl('*/*/save'))) 00073 ->renderLayout(); 00074 }
indexAction | ( | ) |
Definition at line 36 of file AgreementController.php.
00037 { 00038 $this->_initAction() 00039 ->_addContent($this->getLayout()->createBlock('adminhtml/checkout_agreement')) 00040 ->renderLayout(); 00041 return $this; 00042 }
newAction | ( | ) |
Definition at line 44 of file AgreementController.php.
00045 { 00046 $this->_forward('edit'); 00047 }
saveAction | ( | ) |
Definition at line 76 of file AgreementController.php.
00077 { 00078 if ($postData = $this->getRequest()->getPost()) { 00079 $model = Mage::getSingleton('checkout/agreement'); 00080 $model->setData($postData); 00081 00082 try { 00083 $model->save(); 00084 00085 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('checkout')->__('Condition was successfully saved')); 00086 $this->_redirect('*/*/'); 00087 00088 return; 00089 } 00090 catch (Mage_Core_Exception $e) { 00091 Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); 00092 } 00093 catch (Exception $e) { 00094 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('checkout')->__('Error while saving this condition. Please try again later.')); 00095 } 00096 00097 Mage::getSingleton('adminhtml/session')->setAgreementData($postData); 00098 $this->_redirectReferer(); 00099 } 00100 }