1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Newsletter_ProblemController extends Mage_Adminhtml_Controller_Action
35: {
36: public function indexAction()
37: {
38: $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter Problems'));
39:
40: if ($this->getRequest()->getQuery('ajax')) {
41: $this->_forward('grid');
42: return;
43: }
44:
45: $this->getLayout()->getMessagesBlock()->setMessages(
46: Mage::getSingleton('adminhtml/session')->getMessages(true)
47: );
48: $this->loadLayout();
49:
50: $this->_setActiveMenu('newsletter/problem');
51:
52: $this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Problem Reports'), Mage::helper('newsletter')->__('Newsletter Problem Reports'));
53:
54: $this->_addContent(
55: $this->getLayout()->createBlock('adminhtml/newsletter_problem', 'problem')
56: );
57:
58: $this->renderLayout();
59: }
60:
61: public function gridAction()
62: {
63: if($this->getRequest()->getParam('_unsubscribe')) {
64: $problems = (array) $this->getRequest()->getParam('problem', array());
65: if (count($problems)>0) {
66: $collection = Mage::getResourceModel('newsletter/problem_collection');
67: $collection
68: ->addSubscriberInfo()
69: ->addFieldToFilter($collection->getResource()->getIdFieldName(),
70: array('in'=>$problems))
71: ->load();
72:
73: $collection->walk('unsubscribe');
74: }
75:
76: Mage::getSingleton('adminhtml/session')
77: ->addSuccess(Mage::helper('newsletter')->__('Selected problem subscribers have been unsubscribed.'));
78: }
79:
80: if($this->getRequest()->getParam('_delete')) {
81: $problems = (array) $this->getRequest()->getParam('problem', array());
82: if (count($problems)>0) {
83: $collection = Mage::getResourceModel('newsletter/problem_collection');
84: $collection
85: ->addFieldToFilter($collection->getResource()->getIdFieldName(),
86: array('in'=>$problems))
87: ->load();
88: $collection->walk('delete');
89: }
90:
91: Mage::getSingleton('adminhtml/session')
92: ->addSuccess(Mage::helper('newsletter')->__('Selected problems have been deleted.'));
93: }
94: $this->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('adminhtml/session')->getMessages(true));
95:
96: $grid = $this->getLayout()->createBlock('adminhtml/newsletter_problem_grid');
97: $this->getResponse()->setBody($grid->toHtml());
98: }
99:
100: protected function _isAllowed()
101: {
102: return Mage::getSingleton('admin/session')->isAllowed('newsletter/problem');
103: }
104: }
105: