Mage_Adminhtml_Newsletter_TemplateController Class Reference

Inheritance diagram for Mage_Adminhtml_Newsletter_TemplateController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 gridAction ()
 newAction ()
 editAction ()
 saveAction ()
 deleteAction ()
 previewAction ()
 toqueueAction ()

Protected Member Functions

 _isAllowed ()


Detailed Description

Definition at line 33 of file TemplateController.php.


Member Function Documentation

_isAllowed (  )  [protected]

Check is allowed access

Returns:
bool

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 217 of file TemplateController.php.

00218     {
00219         return Mage::getSingleton('admin/session')
00220             ->isAllowed('newsletter/template');
00221     }

deleteAction (  ) 

Delete newsletter Template

Definition at line 162 of file TemplateController.php.

00163     {
00164         $template = Mage::getModel('newsletter/template')
00165             ->load($this->getRequest()->getParam('id'));
00166         if ($template->getId()) {
00167             try {
00168                 $template->delete();
00169             }
00170             catch (Mage_Core_Exception $e) {
00171                 $this->_getSession()->addError($e->getMessage());
00172             }
00173             catch (Exception $e) {
00174                 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while deleting this template. Please try again later.'));
00175             }
00176         }
00177         $this->_redirect('*/*');
00178     }

editAction (  ) 

Edit Newsletter Template

Definition at line 77 of file TemplateController.php.

00078     {
00079         $model = Mage::getModel('newsletter/template');
00080         if ($id = $this->getRequest()->getParam('id')) {
00081             $model->load($id);
00082         }
00083 
00084         Mage::register('_current_template', $model);
00085 
00086         $this->loadLayout();
00087         $this->_setActiveMenu('newsletter/template');
00088 
00089         if ($model->getId()) {
00090             $breadcrumbTitle = Mage::helper('newsletter')->__('Edit Template');
00091             $breadcrumbLabel = $breadcrumbTitle;
00092         }
00093         else {
00094             $breadcrumbTitle = Mage::helper('newsletter')->__('New Template');
00095             $breadcrumbLabel = Mage::helper('newsletter')->__('Create Newsletter Template');
00096         }
00097 
00098         $this->_addBreadcrumb($breadcrumbLabel, $breadcrumbTitle);
00099 
00100         // restore data
00101         if ($values = $this->_getSession()->getData('newsletter_template_form_data', true)) {
00102             $model->addData($values);
00103         }
00104 
00105         $content = $this->getLayout()
00106             ->createBlock('adminhtml/newsletter_template_edit', 'template_edit')
00107             ->setEditMode($model->getId() > 0);
00108         $this->_addContent($content);
00109         $this->renderLayout();
00110     }

gridAction (  ) 

JSON Grid Action

Definition at line 56 of file TemplateController.php.

00057     {
00058         $this->loadLayout();
00059         $grid = $this->getLayout()->createBlock('adminhtml/newsletter_template_grid')
00060             ->toHtml();
00061         $this->getResponse()->setBody($grid);
00062     }

indexAction (  ) 

View Templates list

Definition at line 39 of file TemplateController.php.

00040     {
00041         if ($this->getRequest()->getQuery('ajax')) {
00042             $this->_forward('grid');
00043             return;
00044         }
00045         $this->loadLayout();
00046         $this->_setActiveMenu('newsletter/template');
00047         $this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Templates'), Mage::helper('newsletter')->__('Newsletter Templates'));
00048         $this->_addContent($this->getLayout()->createBlock('adminhtml/newsletter_template', 'template'));
00049         $this->renderLayout();
00050     }

newAction (  ) 

Create new Nesletter Template

Definition at line 68 of file TemplateController.php.

00069     {
00070         $this->_forward('edit');
00071     }

previewAction (  ) 

Preview Newsletter template

Definition at line 184 of file TemplateController.php.

00185     {
00186         $this->loadLayout('preview');
00187         $this->renderLayout();
00188     }

saveAction (  ) 

Save Nesletter Template

Definition at line 116 of file TemplateController.php.

00117     {
00118         $request = $this->getRequest();
00119         $template = Mage::getModel('newsletter/template');
00120 
00121         if ($id = (int)$request->getParam('id')) {
00122             $template->load($id);
00123         }
00124 
00125         try {
00126             $template->addData($request->getParams())
00127                 ->setTemplateSubject($request->getParam('subject'))
00128                 ->setTemplateCode($request->getParam('code'))
00129                 ->setTemplateSenderEmail($request->getParam('sender_email'))
00130                 ->setTemplateSenderName($request->getParam('sender_name'))
00131                 ->setTemplateText($request->getParam('text'))
00132                 ->setModifiedAt(Mage::getSingleton('core/date')->gmtDate());
00133 
00134             if (!$template->getId()) {
00135                 $template->setTemplateType(Mage_Newsletter_Model_Template::TYPE_HTML);
00136             }
00137             if ($this->getRequest()->getParam('_change_type_flag')) {
00138                 $template->setTemplateType(Mage_Newsletter_Model_Template::TYPE_TEXT);
00139             }
00140             if ($this->getRequest()->getParam('_save_as_flag')) {
00141                 $template->setId(null);
00142             }
00143             $template->save();
00144             $this->_redirect('*/*');
00145         }
00146         catch (Mage_Core_Exception $e) {
00147             $this->_getSession()->addError(nl2br($e->getMessage()));
00148             $this->_getSession()->setData('newsletter_template_form_data',
00149                 $this->getRequest()->getParams());
00150         }
00151         catch (Exception $e) {
00152             $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while saving this template. Please try again later.'));
00153             $this->_getSession()->setData('newsletter_template_form_data', $this->getRequest()->getParams());
00154         }
00155         $this->_forward('new');
00156     }

toqueueAction (  ) 

Queue Newsletter

Definition at line 194 of file TemplateController.php.

00195     {
00196         $template = Mage::getModel('newsletter/template')
00197             ->load($this->getRequest()->getParam('id'));
00198         if (!$template->getIsSystem()) {
00199             $template->preprocess();
00200             $queue = Mage::getModel('newsletter/queue')
00201                 ->setTemplateId($template->getId())
00202                 ->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_NEVER)
00203                 ->save();
00204             $template->save();
00205             $this->_redirect('*/newsletter_queue/edit', array('id' => $queue->getId()));
00206         }
00207         else {
00208             $this->_redirect('*/*');
00209         }
00210     }


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