/**
  * Get all the mailing components of a particular type
  *
  * @param $type the type of component needed
  * @access public
  *
  * @return array - array reference of all mailing components
  * @static
  */
 public static function &component($type = NULL)
 {
     $name = $type ? $type : 'ALL';
     if (!self::$component || !array_key_exists($name, self::$component)) {
         if (!self::$component) {
             self::$component = array();
         }
         if (!$type) {
             self::$component[$name] = NULL;
             CRM_Core_PseudoConstant::populate(self::$component[$name], 'CRM_Mailing_DAO_Component');
         } else {
             // we need to add an additional filter for $type
             self::$component[$name] = array();
             $object = new CRM_Mailing_DAO_Component();
             $object->component_type = $type;
             $object->selectAdd();
             $object->selectAdd("id, name");
             $object->orderBy('component_type, is_default, name');
             $object->is_active = 1;
             $object->find();
             while ($object->fetch()) {
                 self::$component[$name][$object->id] = $object->name;
             }
         }
     }
     return self::$component[$name];
 }
Esempio n. 2
0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 function buildQuickForm()
 {
     $session =& CRM_Core_Session::singleton();
     $this->add('text', 'from_name', ts('From name'));
     $this->add('text', 'from_email', ts('From Email'));
     $defaults['from_email'] = $session->get('ufEmail');
     $this->add('checkbox', 'forward_reply', ts('Forward replies?'));
     $defaults['forward_reply'] = true;
     $this->add('checkbox', 'track_urls', ts('Track URLs?'));
     $defaults['track_urls'] = true;
     $this->add('checkbox', 'track_opens', ts('Track Opens?'));
     $defaults['track_opens'] = true;
     $this->add('checkbox', 'auto_responder', ts('Auto-respond to replies?'));
     $defaults['auto_responder'] = false;
     $this->addElement('text', 'subject', ts('Mailing subject'), 'size=30 maxlength=60');
     $defaults['subject'] = $this->get('mailing_name');
     $this->addElement('file', 'textFile', ts('Upload Text Message'), 'size=30 maxlength=60');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('textFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024);
     $this->addRule('textFile', ts('File must be in ascii format'), 'asciiFile');
     $this->addElement('file', 'htmlFile', ts('Upload HTML Message'), 'size=30 maxlength=60');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('htmlFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024);
     $this->addRule('htmlFile', ts('File must be in ascii format'), 'asciiFile');
     $this->add('select', 'header_id', ts('Mailing Header'), CRM_Mailing_PseudoConstant::component('Header'));
     $this->add('select', 'footer_id', ts('Mailing Footer'), CRM_Mailing_PseudoConstant::component('Footer'));
     $this->add('select', 'reply_id', ts('Auto-responder'), CRM_Mailing_PseudoConstant::component('Reply'));
     $this->add('select', 'unsubscribe_id', ts('Unsubscribe Message'), CRM_Mailing_PseudoConstant::component('Unsubscribe'));
     $this->add('select', 'optout_id', ts('Opt-out Message'), CRM_Mailing_PseudoConstant::component('OptOut'));
     $this->addFormRule(array('CRM_Mailing_Form_Upload', 'dataRule'));
     $this->addButtons(array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'upload', 'name' => ts('Next >>'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->setDefaults($defaults);
 }
Esempio n. 3
0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Mailing/PseudoConstant.php';
     $this->add('checkbox', 'forward_replies', ts('Forward Replies?'));
     $defaults['forward_replies'] = true;
     $this->add('checkbox', 'url_tracking', ts('Track Click-throughs?'));
     $defaults['url_tracking'] = true;
     $this->add('checkbox', 'open_tracking', ts('Track Opens?'));
     $defaults['open_tracking'] = true;
     $this->add('checkbox', 'auto_responder', ts('Auto-respond to Replies?'));
     $defaults['auto_responder'] = false;
     $this->add('select', 'reply_id', ts('Auto-responder'), CRM_Mailing_PseudoConstant::component('Reply'), true);
     $this->add('select', 'unsubscribe_id', ts('Unsubscribe Message'), CRM_Mailing_PseudoConstant::component('Unsubscribe'), true);
     $this->add('select', 'resubscribe_id', ts('Resubscribe Message'), CRM_Mailing_PseudoConstant::component('Resubscribe'), true);
     $this->add('select', 'optout_id', ts('Opt-out Message'), CRM_Mailing_PseudoConstant::component('OptOut'), true);
     //FIXME : currently we are hiding save an continue later when
     //search base mailing, we should handle it when we fix CRM-3876
     $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     if ($this->get('context') == 'search' && $this->get('ssID')) {
         $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     }
     $this->addButtons($buttons);
     $this->setDefaults($defaults);
 }
Esempio n. 4
0
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     $config = CRM_Core_Config::singleton();
     $options = array();
     $tempVar = FALSE;
     // this seems so hacky, not sure what we are doing here and why. Need to investigate and fix
     $session->getVars($options, "CRM_Mailing_Controller_Send_{$this->controller->_key}");
     $fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address');
     if (empty($fromEmailAddress)) {
         //redirect user to enter from email address.
         $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'action=add&reset=1');
         $status = ts("There is no valid from email address present. You can add here <a href='%1'>Add From Email Address.</a>", array(1 => $url));
         $session->setStatus($status, ts('Notice'));
     } else {
         foreach ($fromEmailAddress as $key => $email) {
             $fromEmailAddress[$key] = htmlspecialchars($fromEmailAddress[$key]);
         }
     }
     $this->add('select', 'from_email_address', ts('From Email Address'), array('' => '- select -') + $fromEmailAddress, TRUE);
     //Added code to add custom field as Reply-To on form when it is enabled from Mailer settings
     if ((int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo') && empty($options['override_verp'])) {
         $this->add('select', 'reply_to_address', ts('Reply-To'), array('' => '- select -') + $fromEmailAddress);
     } elseif (!empty($options['override_verp'])) {
         $trackReplies = TRUE;
         $this->assign('trackReplies', $trackReplies);
     }
     $this->add('text', 'subject', ts('Mailing Subject'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'subject'), TRUE);
     $attributes = array('onclick' => "showHideUpload();");
     $options = array(ts('Upload Content'), ts('Compose On-screen'));
     $this->addRadio('upload_type', ts('I want to'), $options, $attributes, "&nbsp;&nbsp;");
     CRM_Mailing_BAO_Mailing::commonCompose($this);
     $this->addElement('file', 'textFile', ts('Upload TEXT Message'), 'size=30 maxlength=60');
     $this->addUploadElement('textFile');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('textFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024);
     $this->addRule('textFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     $this->addElement('file', 'htmlFile', ts('Upload HTML Message'), 'size=30 maxlength=60');
     $this->addUploadElement('htmlFile');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('htmlFile', ts('File size should be less than %1 MByte(s)', array(1 => 1)), 'maxfilesize', 1024 * 1024);
     $this->addRule('htmlFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     //fix upload files when context is search. CRM-3711
     $ssID = $this->get('ssID');
     if ($this->_searchBasedMailing && $ssID) {
         $this->set('uploadNames', array('textFile', 'htmlFile'));
     }
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_mailing', $this->_mailingID);
     $this->add('select', 'header_id', ts('Mailing Header'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Header'));
     $this->add('select', 'footer_id', ts('Mailing Footer'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Footer'));
     $this->addFormRule(array('CRM_Mailing_Form_Upload', 'formRule'), $this);
     $buttons = array(array('type' => 'back', 'name' => ts('Previous')), array('type' => 'upload', 'name' => ts('Next'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save & Continue Later'), 'subName' => 'save'), array('type' => 'cancel', 'name' => ts('Cancel')));
     $this->addButtons($buttons);
 }
 function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     // add form elements
     $this->add('text', 'name', ts('Name Your Mailing'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
     //get the mailing groups.
     $groups = CRM_Core_PseudoConstant::group('Mailing');
     $this->add('select', 'includeGroups', 'Select Group', array('' => '- select -') + $groups, true);
     // Add campaign
     // Start
     $mailingId = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     $campaignId = NULL;
     if ($mailingId) {
         $campaignId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $mailingId, 'campaign_id');
     }
     CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
     // End
     // Add email subject and and template elements
     // Start
     $this->add('text', 'subject', ts('Subject'), 'size=50 maxlength=254', TRUE);
     CRM_Mailing_BAO_Mailing::commonCompose($this);
     // End
     // Advanced options - Tracking options
     // Start
     $this->addElement('checkbox', 'override_verp', ts('Track Replies?'));
     $defaults['override_verp'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'track_civimail_replies', NULL, FALSE);
     $this->add('checkbox', 'url_tracking', ts('Track Click-throughs?'));
     $defaults['url_tracking'] = TRUE;
     $this->add('checkbox', 'open_tracking', ts('Track Opens?'));
     //$this->add('checkbox', 'open_tracking', ts('Track Opens?'), '', array('value' => '1'), array('checked' => 'checked'));
     $defaults['open_tracking'] = TRUE;
     $this->add('checkbox', 'forward_replies', ts('Forward Replies?'));
     $defaults['forward_replies'] = FALSE;
     $this->add('checkbox', 'auto_responder', ts('Auto-respond to Replies?'));
     $defaults['auto_responder'] = FALSE;
     $this->add('select', 'reply_id', ts('Auto-responder'), CRM_Mailing_PseudoConstant::component('Reply'), TRUE);
     // End
     // From email address and reply to options
     // Start
     $options = array();
     // this seems so hacky, not sure what we are doing here and why. Need to investigate and fix
     $session->getVars($options, "CRM_Mailing_Controller_Send_{$this->controller->_key}");
     $fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address');
     if (empty($fromEmailAddress)) {
         //redirect user to enter from email address.
         $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'group=from_email_address&action=add&reset=1');
         $status = ts("There is no valid from email address present. You can add here <a href='%1'>Add From Email Address.</a>", array(1 => $url));
         $session->setStatus($status);
     } else {
         foreach ($fromEmailAddress as $key => $email) {
             $fromEmailAddress[$key] = htmlspecialchars($fromEmailAddress[$key]);
         }
     }
     $this->add('select', 'from_email_address', ts('From Email Address'), array('' => '- select -') + $fromEmailAddress, TRUE);
     //echo "<pre>";print_r ($config);echo "</pre>";
     //Added code to add custom field as Reply-To on form when it is enabled from Mailer settings
     if (isset($config->replyTo) && !empty($config->replyTo) && !CRM_Utils_Array::value('override_verp', $options)) {
         $this->add('select', 'reply_to_address', ts('Reply-To'), array('' => '- select -') + $fromEmailAddress);
     } elseif (CRM_Utils_Array::value('override_verp', $options)) {
         $trackReplies = TRUE;
         $this->assign('trackReplies', $trackReplies);
     }
     // Mailing Header and footer
     // Start
     $this->add('select', 'header_id', ts('Mailing Header'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Header'));
     $this->add('select', 'footer_id', ts('Mailing Footer'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Footer'));
     // End
     #@madav getting default header na footer id to tpl
     #start
     $this->assign('headerId', key(CRM_Mailing_PseudoConstant::component('Header')));
     $this->assign('footerId', key(CRM_Mailing_PseudoConstant::component('Footer')));
     #end
     // Exclude from groups, Innclude/Exclude mailings
     // Start
     $outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $mailings = CRM_Mailing_PseudoConstant::completed();
     if (!$mailings) {
         $mailings = array();
     }
     $inM =& $this->addElement('advmultiselect', 'includeMailings', ts('INCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outM =& $this->addElement('advmultiselect', 'excludeMailings', ts('EXCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $inM->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outM->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outM->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->assign('mailingCount', count($mailings));
     // End
     $this->addFormRule(array('CRM_Quickbulkemail_Form_QuickBulkEmail', 'formRule'));
     // Schedule or send
     // Start
     //$this->addDateTime('start_date', ts('Schedule Mailing'), FALSE, array('formatType' => 'mailing'));
     //$this->addElement('checkbox', 'now', ts('Send Immediately'));
     // End
     $buttons = array(array('type' => 'next', 'name' => ts('Schedule & Send >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')));
     $this->addButtons($buttons);
     // export form elements
     // $this->assign('elementNames', $this->getRenderableElementNames());
     parent::buildQuickForm();
 }
Esempio n. 6
0
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $this->addElement('checkbox', 'override_verp', ts('Track Replies?'));
     $defaults['override_verp'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'track_civimail_replies', NULL, FALSE);
     $this->add('checkbox', 'forward_replies', ts('Forward Replies?'));
     $defaults['forward_replies'] = FALSE;
     $this->add('checkbox', 'url_tracking', ts('Track Click-throughs?'));
     $defaults['url_tracking'] = TRUE;
     $this->add('checkbox', 'open_tracking', ts('Track Opens?'));
     $defaults['open_tracking'] = TRUE;
     $this->add('checkbox', 'auto_responder', ts('Auto-respond to Replies?'));
     $defaults['auto_responder'] = FALSE;
     $this->add('select', 'visibility', ts('Mailing Visibility'), CRM_Core_SelectValues::groupVisibility(), TRUE);
     $this->add('select', 'reply_id', ts('Auto-responder'), CRM_Mailing_PseudoConstant::component('Reply'), TRUE);
     $this->add('select', 'unsubscribe_id', ts('Unsubscribe Message'), CRM_Mailing_PseudoConstant::component('Unsubscribe'), TRUE);
     $this->add('select', 'resubscribe_id', ts('Resubscribe Message'), CRM_Mailing_PseudoConstant::component('Resubscribe'), TRUE);
     $this->add('select', 'optout_id', ts('Opt-out Message'), CRM_Mailing_PseudoConstant::component('OptOut'), TRUE);
     $buttons = array(array('type' => 'back', 'name' => ts('Previous')), array('type' => 'next', 'name' => ts('Next'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     $this->addButtons($buttons);
     $this->setDefaults($defaults);
 }
Esempio n. 7
0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     require_once 'CRM/Core/PseudoConstant.php';
     $formEmailAddress = CRM_Core_PseudoConstant::fromEmailAddress('from_email_address');
     if (empty($formEmailAddress)) {
         //redirect user to enter from email address.
         $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'group=from_email_address&action=add&reset=1');
         $status = ts("There is no valid from email address present. You can add here <a href='%1'>Add From Email Address.</a>", array(1 => $url));
         $session->setStatus($status);
     } else {
         foreach ($formEmailAddress as $key => $email) {
             $formEmailAddress[$key] = htmlspecialchars($formEmailAddress[$key]);
         }
     }
     $this->add('select', 'from_email_address', ts('From Email Address'), array('' => '- select -') + $formEmailAddress, true);
     $this->add('text', 'subject', ts('Mailing Subject'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'subject'), true);
     $attributes = array('onclick' => "showHideUpload();");
     $options = array(ts('Upload Content'), ts('Compose On-screen'));
     $this->addRadio('upload_type', ts('I want to'), $options, $attributes, "&nbsp;&nbsp;");
     require_once 'CRM/Mailing/BAO/Mailing.php';
     CRM_Mailing_BAO_Mailing::commonCompose($this);
     $this->addElement('file', 'textFile', ts('Upload TEXT Message'), 'size=30 maxlength=60');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('textFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024);
     $this->addRule('textFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     $this->addElement('file', 'htmlFile', ts('Upload HTML Message'), 'size=30 maxlength=60');
     $this->setMaxFileSize(1024 * 1024);
     $this->addRule('htmlFile', ts('File size should be less than %1 MByte(s)', array(1 => 1)), 'maxfilesize', 1024 * 1024);
     $this->addRule('htmlFile', ts('File must be in UTF-8 encoding'), 'utf8File');
     //fix upload files when context is search. CRM-3711
     $ssID = $this->get('ssID');
     if ($this->_searchBasedMailing && $ssID) {
         $this->set('uploadNames', array('textFile', 'htmlFile'));
     }
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($this, 'civicrm_mailing', $this->_mailingID);
     require_once 'CRM/Mailing/PseudoConstant.php';
     $this->add('select', 'header_id', ts('Mailing Header'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Header'));
     $this->add('select', 'footer_id', ts('Mailing Footer'), array('' => ts('- none -')) + CRM_Mailing_PseudoConstant::component('Footer'));
     $this->addFormRule(array('CRM_Mailing_Form_Upload', 'formRule'), $this);
     //FIXME : currently we are hiding save an continue later when
     //search base mailing, we should handle it when we fix CRM-3876
     $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'upload', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save & Continue Later'), 'subName' => 'save'), array('type' => 'cancel', 'name' => ts('Cancel')));
     if ($this->_searchBasedMailing && $ssID) {
         $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'upload', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     }
     $this->addButtons($buttons);
 }