コード例 #1
0
ファイル: story.php プロジェクト: kevinwojo/hubzero-cms
 public function saveAutoTask()
 {
     // Story information
     $title = Request::getVar('title');
     $source = Request::getVar('contentSource');
     $itemCount = Request::getInt('itemCount');
     $template = Request::getVar('layout');
     // Newsletter ID
     $nid = Request::getInt('nid');
     // Ensure that we have everything
     if ($source != '' && $itemCount > 0 && $template != '') {
         // Enforce a 20 item maximum
         if ($itemCount > 20) {
             $itemCount = 20;
         }
         // Create the string
         $autogenString = "{{AUTOGEN_" . strtoupper($source) . "_" . $itemCount . "_" . strtoupper($template) . "}}";
     } else {
         // Redirect if the information is lacking
         App::redirect(Route::url('index.php?option=com_newsletter&controller=story&task=add&type=autogen&id=' . $nid, false), Lang::txt('COM_NEWSLETTER_STORY_MISSING_REQUIRED'), 'error');
     }
     $newsletterStory = new PrimaryStory($this->database);
     // Check to make sure we have an order
     if (!isset($story['order']) || $story['order'] == '' || $story['order'] == 0) {
         $currentHighestOrder = $newsletterStory->_getCurrentHighestOrder($nid);
         $newOrder = $currentHighestOrder + 1;
         $order = $newOrder;
     }
     $newsletterStory->title = $title;
     $newsletterStory->story = $autogenString;
     $newsletterStory->order = $order;
     $newsletterStory->nid = $nid;
     //save the story
     if (!$newsletterStory->save($newsletterStory)) {
         $this->setError($newsletterStory->getError());
         $this->editTask($nid);
         return;
     }
     //inform and redirect
     App::redirect(Route::url('index.php?option=com_newsletter&controller=newsletter&task=edit&id=' . $nid, false), Lang::txt('COM_NEWSLETTER_STORY_SAVED_SUCCESS'));
 }
コード例 #2
0
ファイル: newsletter.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * 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();
 }