Mage_Adminhtml_NotificationController Class Reference

Inheritance diagram for Mage_Adminhtml_NotificationController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 markAsReadAction ()
 massMarkAsReadAction ()
 removeAction ()
 massRemoveAction ()

Protected Member Functions

 _isAllowed ()


Detailed Description

Definition at line 29 of file NotificationController.php.


Member Function Documentation

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 162 of file NotificationController.php.

00163     {
00164         switch ($this->getRequest()->getActionName()) {
00165             case 'markAsRead':
00166                 $acl = 'system/adminnotification/mark_as_read';
00167                 break;
00168 
00169             case 'massMarkAsRead':
00170                 $acl = 'system/adminnotification/mark_as_read';
00171                 break;
00172 
00173             case 'remove':
00174                 $acl = 'system/adminnotification/remove';
00175                 break;
00176 
00177             case 'massRemove':
00178                 $acl = 'system/adminnotification/remove';
00179                 break;
00180 
00181             default:
00182                 $acl = 'system/adminnotification/show_list';
00183         }
00184         return Mage::getSingleton('admin/session')->isAllowed($acl);
00185     }

indexAction (  ) 

Definition at line 31 of file NotificationController.php.

00032     {
00033         $this->loadLayout()
00034             ->_setActiveMenu('system/notification')
00035             ->_addBreadcrumb(Mage::helper('adminnotification')->__('Messages Inbox'), Mage::helper('adminhtml')->__('Messages Inbox'))
00036             ->_addContent($this->getLayout()->createBlock('adminhtml/notification_inbox'))
00037             ->renderLayout();
00038     }

markAsReadAction (  ) 

Definition at line 40 of file NotificationController.php.

00041     {
00042         if ($id = $this->getRequest()->getParam('id')) {
00043             $session = Mage::getSingleton('adminhtml/session');
00044             $model = Mage::getModel('adminnotification/inbox')
00045                 ->load($id);
00046 
00047             if (!$model->getId()) {
00048                 $session->addError(Mage::helper('adminnotification')->__('Unable to proceed. Please, try again'));
00049                 $this->_redirect('*/*/');
00050                 return ;
00051             }
00052 
00053             try {
00054                 $model->setIsRead(1)
00055                     ->save();
00056                 $session->addSuccess(Mage::helper('adminnotification')->__('Message was successfully marked as read'));
00057             }
00058             catch (Mage_Core_Exception $e) {
00059                 $session->addError($e->getMessage());
00060             }
00061             catch (Exception $e) {
00062                 $session->addException($e, Mage::helper('adminnotification')->__('Error while marking as read. Please try again later.'));
00063             }
00064 
00065             $this->_redirectReferer();
00066             return;
00067         }
00068         $this->_redirect('*/*/');
00069     }

massMarkAsReadAction (  ) 

Definition at line 71 of file NotificationController.php.

00072     {
00073         $session = Mage::getSingleton('adminhtml/session');
00074         $ids = $this->getRequest()->getParam('notification');
00075         if (!is_array($ids)) {
00076             $session->addError(Mage::helper('adminnotification')->__('Please select messages'));
00077         }
00078         else {
00079             try {
00080                 foreach ($ids as $id) {
00081                     $model = Mage::getModel('adminnotification/inbox')
00082                         ->load($id);
00083                     if ($model->getId()) {
00084                         $model->setIsRead(1)
00085                             ->save();
00086                     }
00087                 }
00088                 $this->_getSession()->addSuccess(
00089                     Mage::helper('adminnotification')->__('Total of %d record(s) were successfully marked as read', count($ids))
00090                 );
00091             } catch (Mage_Core_Exception $e) {
00092                 $session->addError($e->getMessage());
00093             }
00094             catch (Exception $e) {
00095                 $session->addException($e, Mage::helper('adminnotification')->__('Error while marking as read. Please try again later.'));
00096             }
00097         }
00098         $this->_redirect('*/*/');
00099     }

massRemoveAction (  ) 

Definition at line 132 of file NotificationController.php.

00133     {
00134         $session = Mage::getSingleton('adminhtml/session');
00135         $ids = $this->getRequest()->getParam('notification');
00136         if (!is_array($ids)) {
00137             $session->addError(Mage::helper('adminnotification')->__('Please select messages'));
00138         }
00139         else {
00140             try {
00141                 foreach ($ids as $id) {
00142                     $model = Mage::getModel('adminnotification/inbox')
00143                         ->load($id);
00144                     if ($model->getId()) {
00145                         $model->setIsRemove(1)
00146                             ->save();
00147                     }
00148                 }
00149                 $this->_getSession()->addSuccess(
00150                     Mage::helper('adminnotification')->__('Total of %d record(s) were successfully removed', count($ids))
00151                 );
00152             } catch (Mage_Core_Exception $e) {
00153                 $session->addError($e->getMessage());
00154             }
00155             catch (Exception $e) {
00156                 $session->addException($e, Mage::helper('adminnotification')->__('Error while marking. Please try again later.'));
00157             }
00158         }
00159         $this->_redirectReferer();
00160     }

removeAction (  ) 

Definition at line 101 of file NotificationController.php.

00102     {
00103         if ($id = $this->getRequest()->getParam('id')) {
00104             $session = Mage::getSingleton('adminhtml/session');
00105             $model = Mage::getModel('adminnotification/inbox')
00106                 ->load($id);
00107 
00108             if (!$model->getId()) {
00109                 $session->addError(Mage::helper('adminnotification')->__('Unable to proceed. Please, try again'));
00110                 $this->_redirect('*/*/');
00111                 return ;
00112             }
00113 
00114             try {
00115                 $model->setIsRemove(1)
00116                     ->save();
00117                 $session->addSuccess(Mage::helper('adminnotification')->__('Message was successfully removed'));
00118             }
00119             catch (Mage_Core_Exception $e) {
00120                 $session->addError($e->getMessage());
00121             }
00122             catch (Exception $e) {
00123                 $session->addException($e, Mage::helper('adminnotification')->__('Error while removing. Please try again later.'));
00124             }
00125 
00126             $this->_redirectReferer();
00127             return;
00128         }
00129         $this->_redirect('*/*/');
00130     }


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

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