/** * Delete Newsletter Task * * @return void */ public function deleteTask() { //get the request vars $id = Request::getInt('id', 0); $sid = Request::getInt('sid', 0); $type = Request::getWord('type', 'primary'); if (strtolower($type) == 'primary') { $story = new PrimaryStory($this->database); } else { $story = new SecondaryStory($this->database); } //load the story $story->load($sid); //mark as deleted $story->deleted = 1; //save so story is marked deleted if (!$story->save($story)) { $this->setError(Lang::txt('COM_NEWSLETTER_STORY_DELETE_FAIL')); $this->editTask(); return; } //redirect back to campaigns list App::redirect(Route::url('index.php?option=com_newsletter&controller=newsletter&task=edit&id=' . $id, false), Lang::txt('COM_NEWSLETTER_STORY_DELETE_SUCCESS')); }
/** * 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(); }