Mage_Adminhtml_Newsletter_QueueController Class Reference

Inheritance diagram for Mage_Adminhtml_Newsletter_QueueController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 gridAction ()
 startAction ()
 pauseAction ()
 resumeAction ()
 cancelAction ()
 sendingAction ()
 editAction ()
 saveAction ()

Protected Member Functions

 _isAllowed ()


Detailed Description

Definition at line 34 of file QueueController.php.


Member Function Documentation

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 229 of file QueueController.php.

00230     {
00231         return Mage::getSingleton('admin/session')->isAllowed('newsletter/queue');
00232     }

cancelAction (  ) 

Definition at line 121 of file QueueController.php.

00122     {
00123         $queue = Mage::getSingleton('newsletter/queue')
00124             ->load($this->getRequest()->getParam('id'));
00125 
00126         if (!in_array($queue->getQueueStatus(),
00127                      array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) {
00128             $this->_redirect('*/*');
00129             return;
00130         }
00131 
00132         $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_CANCEL);
00133         $queue->save();
00134 
00135         $this->_redirect('*/*');
00136     }

editAction (  ) 

Definition at line 154 of file QueueController.php.

00155     {
00156         $queue = Mage::getSingleton('newsletter/queue')
00157             ->load($this->getRequest()->getParam('id'));
00158 
00159         Mage::register('current_queue', $queue);
00160 
00161         $this->loadLayout();
00162 
00163         $this->_setActiveMenu('newsletter/queue');
00164 
00165         $this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Queue'), Mage::helper('newsletter')->__('Newsletter Queue'), $this->getUrl('*/newsletter_queue'));
00166         $this->_addBreadcrumb(Mage::helper('newsletter')->__('Edit Queue'), Mage::helper('newsletter')->__('Edit Queue'));
00167 
00168         $this->_addContent(
00169             $this->getLayout()->createBlock('adminhtml/newsletter_queue_edit', 'queue.edit')
00170         );
00171 
00172         $this->renderLayout();
00173     }

gridAction (  ) 

Queue list Ajax action

Definition at line 62 of file QueueController.php.

00063     {
00064         $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/newsletter_queue_grid')->toHtml());
00065     }

indexAction (  ) 

Queue list action

Definition at line 39 of file QueueController.php.

00040     {
00041         if ($this->getRequest()->getQuery('ajax')) {
00042             $this->_forward('grid');
00043             return;
00044         }
00045 
00046         $this->loadLayout();
00047 
00048         $this->_setActiveMenu('newsletter/queue');
00049 
00050         $this->_addContent(
00051             $this->getLayout()->createBlock('adminhtml/newsletter_queue', 'queue')
00052         );
00053 
00054         $this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Queue'), Mage::helper('newsletter')->__('Newsletter Queue'));
00055 
00056         $this->renderLayout();
00057     }

pauseAction (  ) 

Definition at line 87 of file QueueController.php.

00088     {
00089         $queue = Mage::getSingleton('newsletter/queue')
00090             ->load($this->getRequest()->getParam('id'));
00091 
00092         if (!in_array($queue->getQueueStatus(),
00093                      array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) {
00094             $this->_redirect('*/*');
00095             return;
00096         }
00097 
00098         $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_PAUSE);
00099         $queue->save();
00100 
00101         $this->_redirect('*/*');
00102     }

resumeAction (  ) 

Definition at line 104 of file QueueController.php.

00105     {
00106         $queue = Mage::getSingleton('newsletter/queue')
00107             ->load($this->getRequest()->getParam('id'));
00108 
00109         if (!in_array($queue->getQueueStatus(),
00110                      array(Mage_Newsletter_Model_Queue::STATUS_PAUSE))) {
00111             $this->_redirect('*/*');
00112             return;
00113         }
00114 
00115         $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING);
00116         $queue->save();
00117 
00118         $this->_redirect('*/*');
00119     }

saveAction (  ) 

Definition at line 175 of file QueueController.php.

00176     {
00177         $queue = Mage::getSingleton('newsletter/queue')
00178             ->load($this->getRequest()->getParam('id'));
00179 
00180         if (!in_array($queue->getQueueStatus(),
00181                      array(Mage_Newsletter_Model_Queue::STATUS_NEVER,
00182                            Mage_Newsletter_Model_Queue::STATUS_PAUSE))) {
00183             $this->_redirect('*/*');
00184             return;
00185         }
00186 
00187         $format = Mage::app()->getLocale()->getDateTimeFormat(
00188             Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM
00189         );
00190 
00191         if ($queue->getQueueStatus()==Mage_Newsletter_Model_Queue::STATUS_NEVER) {
00192             if ($this->getRequest()->getParam('start_at')) {
00193                 $date = Mage::app()->getLocale()->date($this->getRequest()->getParam('start_at'), $format);
00194                 $time = $date->getTimestamp();
00195                 $queue->setQueueStartAt(
00196                     Mage::getModel('core/date')->gmtDate(null, $time)
00197                 );
00198             } else {
00199                 $queue->setQueueStartAt(null);
00200             }
00201         }
00202 
00203         $queue->setStores($this->getRequest()->getParam('stores', array()));
00204 
00205         $queue->addTemplateData($queue);
00206         $queue->getTemplate()
00207             ->setTemplateSubject($this->getRequest()->getParam('subject'))
00208             ->setTemplateSenderName($this->getRequest()->getParam('sender_name'))
00209             ->setTemplateSenderEmail($this->getRequest()->getParam('sender_email'))
00210             ->setTemplateTextPreprocessed($this->getRequest()->getParam('text'));
00211 
00212         if ($queue->getQueueStatus() == Mage_Newsletter_Model_Queue::STATUS_PAUSE
00213             && $this->getRequest()->getParam('_resume', false)) {
00214             $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING);
00215         }
00216 
00217         $queue->setSaveTemplateFlag(true);
00218 
00219         try {
00220             $queue->save();
00221         }
00222         catch (Exception $e) {
00223             echo $e->getMessage();
00224             exit;
00225         }
00226         $this->_redirect('*/*');
00227     }

sendingAction (  ) 

Definition at line 138 of file QueueController.php.

00139     {
00140         // Todo: put it somewhere in config!
00141         $countOfQueue  = 3;
00142         $countOfSubscritions = 20;
00143 
00144         $collection = Mage::getResourceModel('newsletter/queue_collection')
00145             ->setPageSize($countOfQueue)
00146             ->setCurPage(1)
00147             ->addOnlyForSendingFilter()
00148             ->load();
00149 
00150         $collection->walk('sendPerSubscriber', array($countOfSubscritions));
00151     }

startAction (  ) 

Definition at line 67 of file QueueController.php.

00068     {
00069         $queue = Mage::getModel('newsletter/queue')
00070             ->load($this->getRequest()->getParam('id'));
00071         if ($queue->getId()) {
00072             if (!in_array($queue->getQueueStatus(),
00073                          array(Mage_Newsletter_Model_Queue::STATUS_NEVER,
00074                                Mage_Newsletter_Model_Queue::STATUS_PAUSE))) {
00075                 $this->_redirect('*/*');
00076                 return;
00077             }
00078 
00079             $queue->setQueueStartAt(Mage::getSingleton('core/date')->gmtDate())
00080                 ->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_SENDING)
00081                 ->save();
00082         }
00083 
00084         $this->_redirect('*/*');
00085     }


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