コード例 #1
0
ファイル: Group.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
    /**
     * Function to actually build the form
     *
     * @return None
     * @access public
     */
    function buildQuickForm()
    {
        $template = '
<table{class}>
<tr><td>{unselected}</td><td>{selected}</tr></tr>
<tr><td>{add}</td><td>{remove}</tr></tr>
</table>';
        $groups =& CRM_Core_PseudoConstant::group();
        $inG =& $this->addElement('advmultiselect', 'includeGroups', ts('Include group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px'));
        $this->addRule('includeGroups', ts('Please select a group to be mailed.'), 'required');
        $outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px'));
        $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
        $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
        $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
        $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
        //         $inG->setElementTemplate($template);
        //         $outG->setElementTemplate($template);
        $mailings =& CRM_Mailing_PseudoConstant::completed();
        if (!$mailings) {
            $mailings = array();
        }
        $inM =& $this->addElement('advmultiselect', 'includeMailings', ts('Include mailing(s)') . ' ', $mailings, array('size' => 5, 'style' => 'width:240px'));
        $outM =& $this->addElement('advmultiselect', 'excludeMailings', ts('Exclude mailing(s)') . ' ', $mailings, array('size' => 5, 'style' => 'width:240px'));
        $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')));
        //         $inM->setElementTemplate($template);
        //         $outM->setElementTemplate($template);
        $this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule'));
        $this->addButtons(array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => ts('Next >>'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
        $this->assign('groupCount', count($groups));
        $this->assign('mailingCount', count($mailings));
    }
コード例 #2
0
ファイル: Group.php プロジェクト: sarehag/civicrm-core
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     // Get the context.
     $context = $this->get('context');
     $this->assign('context', $context);
     $this->add('text', 'name', ts('Name Your SMS'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
     // Get the mailing groups.
     $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
     // Get the sms mailing list.
     $mailings = CRM_Mailing_PseudoConstant::completed('sms');
     if (!$mailings) {
         $mailings = array();
     }
     // run the groups through a hook so users can trim it if needed
     CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
     $select2style = array('multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'));
     $this->add('select', 'includeGroups', ts('Include Group(s)'), $groups, TRUE, $select2style);
     $this->add('select', 'excludeGroups', ts('Exclude Group(s)'), $groups, FALSE, $select2style);
     $this->add('select', 'includeMailings', ts('INCLUDE Recipients of These Message(s)'), $mailings, FALSE, $select2style);
     $this->add('select', 'excludeMailings', ts('EXCLUDE Recipients of These Message(s)'), $mailings, FALSE, $select2style);
     $this->addFormRule(array('CRM_SMS_Form_Group', 'formRule'));
     $buttons = array(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->assign('groupCount', count($groups));
     $this->assign('mailingCount', count($mailings));
 }
コード例 #3
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     //get the context
     $context = $this->get('context');
     $this->assign('context', $context);
     $this->add('text', 'name', ts('Name Your SMS'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
     //get the mailing groups.
     $groups = CRM_Core_PseudoConstant::group('Mailing');
     //get the sms mailing list
     $mailings = CRM_Mailing_PseudoConstant::completed('sms');
     if (!$mailings) {
         $mailings = array();
     }
     // run the groups through a hook so users can trim it if needed
     CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
     $inG =& $this->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $this->addRule('includeGroups', ts('Please select a group to be SMSed.'), 'required');
     $outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $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->addFormRule(array('CRM_SMS_Form_Group', 'formRule'));
     $buttons = array(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->assign('groupCount', count($groups));
     $this->assign('mailingCount', count($mailings));
 }
コード例 #4
0
ファイル: Group.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Mailing/PseudoConstant.php';
     //get the context
     $context = $this->get('context');
     if ($this->_searchBasedMailing) {
         $context = 'search';
     }
     $this->assign('context', $context);
     $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');
     $mailings =& CRM_Mailing_PseudoConstant::completed();
     if (!$mailings) {
         $mailings = array();
     }
     // run the groups through a hook so users can trim it if needed
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
     //when the context is search add base group's.
     if ($this->_searchBasedMailing) {
         //get the static groups
         $staticGroups = CRM_Core_PseudoConstant::staticGroup(false, 'Mailing');
         $this->add('select', 'baseGroup', ts('Base Group'), array('' => ts('- select -')) + $staticGroups, true);
     }
     $inG =& $this->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     //as we are having hidden smart group so no need.
     if (!$this->_searchBasedMailing) {
         $this->addRule('includeGroups', ts('Please select a group to be mailed.'), 'required');
     }
     $outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $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')));
     require_once 'CRM/Contact/Page/CustomSearch.php';
     $urls = array('' => ts('- select -'), -1 => ts('CiviCRM Search')) + CRM_Contact_Page_CustomSearch::info();
     $this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule'));
     //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' => '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->_searchBasedMailing) {
         $buttons = array(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->assign('groupCount', count($groups));
     $this->assign('mailingCount', count($mailings));
 }
コード例 #5
0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     //get the context
     $context = $this->get('context');
     if ($this->_searchBasedMailing) {
         $context = 'search';
     }
     $this->assign('context', $context);
     $this->add('text', 'name', ts('Name Your Mailing'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
     //CRM-7362 --add campaigns.
     $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);
     //dedupe on email option
     $this->addElement('checkbox', 'dedupe_email', ts('Remove duplicate emails?'));
     //get the mailing groups.
     $groups = CRM_Core_PseudoConstant::group('Mailing');
     $mailings = CRM_Mailing_PseudoConstant::completed();
     if (!$mailings) {
         $mailings = array();
     }
     // run the groups through a hook so users can trim it if needed
     CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
     //when the context is search add base group's.
     if ($this->_searchBasedMailing) {
         //get the static groups
         $staticGroups = CRM_Core_PseudoConstant::staticGroup(FALSE, 'Mailing');
         $this->add('select', 'baseGroup', ts('Unsubscription Group'), array('' => ts('- select -')) + $staticGroups, TRUE);
     }
     $inG =& $this->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     //as we are having hidden smart group so no need.
     if (!$this->_searchBasedMailing) {
         $this->addRule('includeGroups', ts('Please select a group to be mailed.'), 'required');
     }
     $outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $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')));
     $urls = array('' => ts('- select -'), -1 => ts('CiviCRM Search')) + CRM_Contact_Page_CustomSearch::info();
     $this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule'));
     //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' => '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->_searchBasedMailing) {
         $buttons = array(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->assign('groupCount', count($groups));
     $this->assign('mailingCount', count($mailings));
 }
コード例 #6
0
 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();
 }
コード例 #7
0
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     //get the context
     $context = $this->get('context');
     if ($this->_searchBasedMailing) {
         $context = 'search';
     }
     $this->assign('context', $context);
     $this->add('text', 'name', ts('Name Your Mailing'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
     $hiddenMailingGroup = NULL;
     $campaignId = NULL;
     //CRM-7362 --add campaigns.
     if ($this->_mailingID) {
         $campaignId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, 'campaign_id');
         $hiddenMailingGroup = CRM_Mailing_BAO_Mailing::hiddenMailingGroup($this->_mailingID);
     }
     CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
     //dedupe on email option
     $this->addElement('checkbox', 'dedupe_email', ts('Remove duplicate emails?'));
     // location types
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('id' => 'display_name'));
     $this->addElement('select', 'location_type_id', ts("Location Type"), array('' => ts('Automatic')) + $locationTypes);
     $methods = CRM_Core_SelectValues::emailSelectMethods();
     $this->addElement('select', 'email_selection_method', ts("Email Selection Method"), $methods);
     //get the mailing groups.
     $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
     if ($hiddenMailingGroup) {
         $groups[$hiddenMailingGroup] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $hiddenMailingGroup, 'title');
     }
     $mailings = CRM_Mailing_PseudoConstant::completed();
     if (!$mailings) {
         $mailings = array();
     }
     // run the groups through a hook so users can trim it if needed
     CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
     //when the context is search add base group's.
     if ($this->_searchBasedMailing) {
         //get the static groups
         $staticGroups = CRM_Core_PseudoConstant::staticGroup(FALSE, 'Mailing');
         $this->add('select', 'baseGroup', ts('Unsubscription Group'), array('' => ts('- select -')) + CRM_Contact_BAO_Group::getGroupsHierarchy($staticGroups, NULL, '&nbsp;&nbsp;', TRUE), TRUE, array('class' => 'crm-select2 huge'));
     }
     $select2style = array('multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'));
     $this->add('select', 'includeGroups', ts('Include Group(s)'), $groups, !$this->_searchBasedMailing, $select2style);
     $this->add('select', 'excludeGroups', ts('Exclude Group(s)'), $groups, FALSE, $select2style);
     $this->add('select', 'includeMailings', ts('INCLUDE Recipients of These Mailing(s)') . ' ', $mailings, FALSE, $select2style);
     $this->add('select', 'excludeMailings', ts('EXCLUDE Recipients of These Mailing(s)') . ' ', $mailings, FALSE, $select2style);
     $this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule'));
     $buttons = array(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->assign('groupCount', count($groups));
     $this->assign('mailingCount', count($mailings));
     if (count($groups) == 0 && count($mailings) == 0 && !$this->_searchBasedMailing) {
         CRM_Core_Error::statusBounce("To send a mailing, you must have a valid group of recipients - either at least one group that's a Mailing List or at least one previous mailing or start from a search");
     }
 }
コード例 #8
0
 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     //get the context
     $context = $this->get('context');
     if ($this->_searchBasedMailing) {
         $context = 'search';
     }
     $this->assign('context', $context);
     $this->add('text', 'name', ts('Name Your Mailing'), CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'name'), TRUE);
     $hiddenMailingGroup = NULL;
     $campaignId = NULL;
     //CRM-7362 --add campaigns.
     if ($this->_mailingID) {
         $campaignId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, 'campaign_id');
         $hiddenMailingGroup = CRM_Mailing_BAO_Mailing::hiddenMailingGroup($this->_mailingID);
     }
     CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId);
     //dedupe on email option
     $this->addElement('checkbox', 'dedupe_email', ts('Remove duplicate emails?'));
     //get the mailing groups.
     $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
     //   asort($groups);
     if ($hiddenMailingGroup) {
         $groups[$hiddenMailingGroup] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $hiddenMailingGroup, 'title');
     }
     $mailings = CRM_Mailing_PseudoConstant::completed();
     if (!$mailings) {
         $mailings = array();
     }
     // run the groups through a hook so users can trim it if needed
     CRM_Utils_Hook::mailingGroups($this, $groups, $mailings);
     //when the context is search add base group's.
     if ($this->_searchBasedMailing) {
         //CRM-16600 Include Smart Groups in Unsubscribe list as that matches
         //all other practices in CiviMail
         $this->add('select', 'baseGroup', ts('Unsubscription Group'), array('' => ts('- select -')) + $groups, TRUE);
     }
     if (count($groups) <= 10) {
         // setting minimum height to 2 since widget looks strange when size (height) is 1
         $groupSize = max(count($groups), 2);
     } else {
         $groupSize = 10;
     }
     $inG =& $this->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => $groupSize, 'style' => 'width:auto; min-width:240px;', 'class' => 'advmultiselect'));
     //as we are having hidden smart group so no need.
     if (!$this->_searchBasedMailing) {
         $this->addRule('includeGroups', ts('Please select a group to be mailed.'), 'required');
     }
     $outG =& $this->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => $groupSize, 'style' => 'width:auto; min-width:240px;', 'class' => 'advmultiselect'));
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     if (count($mailings) <= 10) {
         // setting minimum height to 2 since widget looks strange when size (height) is 1
         $mailingSize = max(count($mailings), 2);
     } else {
         $mailingSize = 10;
     }
     $inM =& $this->addElement('advmultiselect', 'includeMailings', ts('INCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => $mailingSize, 'style' => 'width:auto; min-width:240px;', 'class' => 'advmultiselect'));
     $outM =& $this->addElement('advmultiselect', 'excludeMailings', ts('EXCLUDE Recipients of These Mailing(s)') . ' ', $mailings, array('size' => $mailingSize, 'style' => 'width:auto; min-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')));
     $urls = array('' => ts('- select -'), -1 => ts('CiviCRM Search')) + CRM_Contact_Page_CustomSearch::info();
     $this->addFormRule(array('CRM_Mailing_Form_Group', 'formRule'));
     $buttons = array(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->assign('groupCount', count($groups));
     $this->assign('mailingCount', count($mailings));
     if (count($groups) == 0 && count($mailings) == 0 && !$this->_searchBasedMailing) {
         CRM_Core_Error::statusBounce("To send a mailing, you must have a valid group of recipients - either at least one group that's a Mailing List or at least one previous mailing or start from a search");
     }
 }