Ejemplo n.º 1
0
 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     $this->add('text', 'test_email', ts('Send to This Address'));
     $defaults['test_email'] = $session->get('ufUniqID');
     $qfKey = $this->get('qfKey');
     $this->add('select', 'test_group', ts('Send to This Group'), array('' => ts('- none -')) + CRM_Core_PseudoConstant::group('Mailing'));
     $this->setDefaults($defaults);
     $this->add('submit', 'sendtest', ts('Send a Test Mailing'));
     $name = ts('Next');
     if (CRM_Mailing_Info::workflowEnabled()) {
         if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
             $name = ts('Inform Scheduler');
         }
     }
     $buttons = array(array('type' => 'back', 'name' => ts('Previous')), array('type' => 'next', 'name' => $name, 'spacing' => '                 ', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     $this->addButtons($buttons);
     $mailingID = $this->get('mailing_id');
     $textFile = $this->get('textFile');
     $htmlFile = $this->get('htmlFile');
     $this->addFormRule(array('CRM_Mailing_Form_Test', 'testMail'), $this);
     $preview = array();
     if ($textFile) {
         $preview['text_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=text&qfKey={$qfKey}");
     }
     if ($htmlFile) {
         $preview['html_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=html&qfKey={$qfKey}");
     }
     $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
     $this->assign('preview', $preview);
     //Token Replacement of Subject in preview mailing
     $options = array();
     $prefix = "CRM_Mailing_Controller_Send_{$qfKey}";
     if ($this->_searchBasedMailing) {
         $prefix = "CRM_Contact_Controller_Search_{$qfKey}";
     }
     $session->getVars($options, $prefix);
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $options['mailing_id'];
     $mailing->find(TRUE);
     $fromEmail = $mailing->from_email;
     $replyToEmail = $mailing->replyto_email;
     $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     $returnProperties = $mailing->getReturnProperties();
     $userID = $session->get('userID');
     $params = array('contact_id' => $userID);
     $details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens(), get_class($this));
     $allDetails =& $mailing->compose(NULL, NULL, NULL, $userID, $fromEmail, $fromEmail, TRUE, $details[0][$userID], $attachments);
     $this->assign('subject', $allDetails->_headers['Subject']);
 }