Mage_Adminhtml_RatingController Class Reference

Inheritance diagram for Mage_Adminhtml_RatingController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 editAction ()
 newAction ()
 saveAction ()
 deleteAction ()

Protected Member Functions

 _initEnityId ()
 _isAllowed ()


Detailed Description

Definition at line 35 of file RatingController.php.


Member Function Documentation

_initEnityId (  )  [protected]

Definition at line 136 of file RatingController.php.

00137     {
00138         Mage::register('entityId', Mage::getModel('rating/rating_entity')->getIdByCode('product'));
00139     }

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 141 of file RatingController.php.

00142     {
00143         return Mage::getSingleton('admin/session')->isAllowed('catalog/reviews_ratings/ratings');
00144     }

deleteAction (  ) 

Definition at line 118 of file RatingController.php.

00119     {
00120         if( $this->getRequest()->getParam('id') > 0 ) {
00121             try {
00122                 $model = Mage::getModel('rating/rating');
00123                 /* @var $model Mage_Rating_Model_Rating */
00124                 $model->setId($this->getRequest()->getParam('id'))
00125                     ->delete();
00126                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Rating was successfully deleted'));
00127                 $this->_redirect('*/*/');
00128             } catch (Exception $e) {
00129                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00130                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
00131             }
00132         }
00133         $this->_redirect('*/*/');
00134     }

editAction (  ) 

Definition at line 49 of file RatingController.php.

00050     {
00051         $this->_initEnityId();
00052         $this->loadLayout();
00053 
00054         $this->_setActiveMenu('catalog/ratings');
00055         $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Ratings'), Mage::helper('adminhtml')->__('Manage Ratings'));
00056 
00057         $this->_addContent($this->getLayout()->createBlock('adminhtml/rating_edit'))
00058             ->_addLeft($this->getLayout()->createBlock('adminhtml/rating_edit_tabs'));
00059         $this->renderLayout();
00060     }

indexAction (  ) 

Definition at line 37 of file RatingController.php.

00038     {
00039         $this->_initEnityId();
00040         $this->loadLayout();
00041 
00042         $this->_setActiveMenu('catalog/ratings');
00043         $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Ratings'), Mage::helper('adminhtml')->__('Manage Ratings'));
00044         $this->_addContent($this->getLayout()->createBlock('adminhtml/rating_rating'));
00045 
00046         $this->renderLayout();
00047     }

newAction (  ) 

Definition at line 62 of file RatingController.php.

00063     {
00064         $this->_forward('edit');
00065     }

saveAction (  ) 

Definition at line 67 of file RatingController.php.

00068     {
00069         $this->_initEnityId();
00070 
00071         if ( $this->getRequest()->getPost() ) {
00072             try {
00073                 $ratingModel = Mage::getModel('rating/rating');
00074 
00075                 $stores = $this->getRequest()->getParam('stores');
00076                 $stores[] = 0;
00077                 $ratingModel->setRatingCode($this->getRequest()->getParam('rating_code'))
00078                       ->setRatingCodes($this->getRequest()->getParam('rating_codes'))
00079                       ->setStores($stores)
00080                       ->setId($this->getRequest()->getParam('id'))
00081                       ->setEntityId(Mage::registry('entityId'))
00082                       ->save();
00083 
00084                 $options = $this->getRequest()->getParam('option_title');
00085 
00086                 if( is_array($options) ) {
00087                     $i = 1;
00088                     foreach( $options as $key => $optionCode ) {
00089                         $optionModel = Mage::getModel('rating/rating_option');
00090                         if( !preg_match("/^add_([0-9]*?)$/", $key) ) {
00091                             $optionModel->setId($key);
00092                         }
00093 
00094                         $optionModel->setCode($optionCode)
00095                             ->setValue($i)
00096                             ->setRatingId($ratingModel->getId())
00097                             ->setPosition($i)
00098                             ->save();
00099                         $i++;
00100                     }
00101                 }
00102 
00103                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Rating was successfully saved'));
00104                 Mage::getSingleton('adminhtml/session')->setRatingData(false);
00105 
00106                 $this->_redirect('*/*/');
00107                 return;
00108             } catch (Exception $e) {
00109                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00110                 Mage::getSingleton('adminhtml/session')->setRatingData($this->getRequest()->getPost());
00111                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
00112                 return;
00113             }
00114         }
00115         $this->_redirect('*/*/');
00116     }


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

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