00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Newsletter_ProblemController extends Mage_Adminhtml_Controller_Action
00035 {
00036 public function indexAction()
00037 {
00038 if ($this->getRequest()->getQuery('ajax')) {
00039 $this->_forward('grid');
00040 return;
00041 }
00042
00043 $this->getLayout()->getMessagesBlock()->setMessages(
00044 Mage::getSingleton('adminhtml/session')->getMessages(true)
00045 );
00046 $this->loadLayout();
00047
00048 $this->_setActiveMenu('newsletter/problem');
00049
00050 $this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Problem Reports'), Mage::helper('newsletter')->__('Newsletter Problem Reports'));
00051
00052 $this->_addContent(
00053 $this->getLayout()->createBlock('adminhtml/newsletter_problem', 'problem')
00054 );
00055
00056 $this->renderLayout();
00057 }
00058
00059 public function gridAction()
00060 {
00061 if($this->getRequest()->getParam('_unsubscribe')) {
00062 $problems = (array) $this->getRequest()->getParam('problem', array());
00063 if (count($problems)>0) {
00064 $collection = Mage::getResourceModel('newsletter/problem_collection');
00065 $collection
00066 ->addSubscriberInfo()
00067 ->addFieldToFilter($collection->getResource()->getIdFieldName(),
00068 array('in'=>$problems))
00069 ->load();
00070
00071 $collection->walk('unsubscribe');
00072 }
00073
00074 Mage::getSingleton('adminhtml/session')
00075 ->addSuccess(Mage::helper('newsletter')->__('Selected problem subscribers successfully unsubscribed'));
00076 }
00077
00078 if($this->getRequest()->getParam('_delete')) {
00079 $problems = (array) $this->getRequest()->getParam('problem', array());
00080 if (count($problems)>0) {
00081 $collection = Mage::getResourceModel('newsletter/problem_collection');
00082 $collection
00083 ->addFieldToFilter($collection->getResource()->getIdFieldName(),
00084 array('in'=>$problems))
00085 ->load();
00086 $collection->walk('delete');
00087 }
00088
00089 Mage::getSingleton('adminhtml/session')
00090 ->addSuccess(Mage::helper('newsletter')->__('Selected problems successfully deleted'));
00091 }
00092 $this->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('adminhtml/session')->getMessages(true));
00093
00094 $grid = $this->getLayout()->createBlock('adminhtml/newsletter_problem_grid');
00095 $this->getResponse()->setBody($grid->toHtml());
00096 }
00097
00098 protected function _isAllowed()
00099 {
00100 return Mage::getSingleton('admin/session')->isAllowed('newsletter/problem');
00101 }
00102 }