示例#1
0
 /**
  * Duplicate Task
  *
  * @return 	void
  */
 public function duplicateTask()
 {
     //get request vars
     $ids = Request::getVar('id', array());
     $id = isset($ids[0]) ? $ids[0] : null;
     //are we editing or adding a new tempalte
     if ($id) {
         //get template we want to duplicate
         $newsletterTemplate = new NewsletterTemplate($this->database);
         $template = $newsletterTemplate->getTemplates($id);
         //set var so edit task can use
         $new_template = new stdClass();
         $new_template->id = null;
         $new_template->name = $template->name . ' (copy)';
         $new_template->editable = 1;
         $new_template->primary_title_color = $template->primary_title_color;
         $new_template->primary_text_color = $template->primary_text_color;
         $new_template->secondary_title_color = $template->secondary_title_color;
         $new_template->secondary_text_color = $template->secondary_text_color;
         $new_template->template = $template->template;
     }
     //save copied template
     $newsletterTemplate = new NewsletterTemplate($this->database);
     if (!$newsletterTemplate->save($new_template)) {
         $this->setError(Lang::txt('COM_NEWSLETTER_TEMPLATE_DUPLICATE_FAILED'));
         $this->displayTask();
         return;
     }
     //set success message & redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_NEWSLETTER_TEMPLATE_DUPLICATE_SUCCESS'));
 }
示例#2
0
 /**
  * Edit newsletter task
  *
  * @return 	void
  */
 public function editTask($task = 'edit')
 {
     // instantiate newsletter object
     $this->view->newsletter = new stdClass();
     $this->view->newsletter->id = null;
     $this->view->newsletter->alias = null;
     $this->view->newsletter->name = null;
     $this->view->newsletter->template = null;
     $this->view->newsletter->issue = null;
     $this->view->newsletter->date = null;
     $this->view->newsletter->sent = null;
     $this->view->newsletter->type = null;
     $this->view->newsletter->tracking = 1;
     $this->view->newsletter->published = null;
     $this->view->newsletter->created = null;
     $this->view->newsletter->created_by = null;
     $this->view->newsletter->modified = null;
     $this->view->newsletter->modified_by = null;
     $this->view->newsletter->params = null;
     /** This is used to determine frequency
      * 0 - regular/disabled
      * 1 - daily
      * 2 - weekly
      * 3 - monthly
      **/
     $this->view->newsletter->autogen = 0;
     // default primary and secondary stories to null
     $this->view->newsletter_primary = null;
     $this->view->newsletter_secondary = null;
     // get any templates that exist
     $newsletterTemplate = new Template($this->database);
     $this->view->templates = $newsletterTemplate->getTemplates();
     // get the request vars
     $id = Request::getVar('id', array(0));
     if (is_array($id)) {
         $id = isset($id[0]) ? $id[0] : null;
     }
     if ($task == 'add') {
         $id = null;
     }
     // are we editing
     if ($id) {
         $newsletterNewsletter = new Letter($this->database);
         if ($letter = $newsletterNewsletter->getNewsletters($id)) {
             $this->view->newsletter = $letter;
         }
         // get primary stories
         $newsletterPrimaryStory = new PrimaryStory($this->database);
         $this->view->newsletter_primary = $newsletterPrimaryStory->getStories($id);
         $this->view->newsletter_primary_highest_order = $newsletterPrimaryStory->_getCurrentHighestOrder($id);
         // get secondary stories
         $newsletterSecondaryStory = new SecondaryStory($this->database);
         $this->view->newsletter_secondary = $newsletterSecondaryStory->getStories($id);
         $this->view->newsletter_secondary_highest_order = $newsletterSecondaryStory->_getCurrentHighestOrder($id);
         // get mailing lists
         $newsletterMailinglist = new Mailinglist($this->database);
         $this->view->mailingLists = $newsletterMailinglist->getLists();
     }
     // are we passing newsletter object from saveTask()?
     if ($this->newsletter) {
         $this->view->newsletter = $this->newsletter;
     }
     // check if we have any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // set vars for view
     $this->view->config = $this->config;
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }