/**
  * Set default values for the form.
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     // CRM-14716 - Pick up mailingID from session since most of the time it's not in the URL
     if (!$mailingID) {
         $mailingID = $this->get('mailing_id');
     }
     $count = $this->get('count');
     $this->assign('count', $count);
     $defaults = array();
     $componentFields = array('reply_id' => 'Reply', 'optout_id' => 'OptOut', 'unsubscribe_id' => 'Unsubscribe', 'resubscribe_id' => 'Resubscribe');
     foreach ($componentFields as $componentVar => $componentType) {
         $defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
     }
     if ($mailingID) {
         $dao = new CRM_Mailing_DAO_Mailing();
         $dao->id = $mailingID;
         $dao->find(TRUE);
         // override_verp must be flipped, as in 3.2 we reverted
         // its meaning to ‘should CiviMail manage replies?’ – i.e.,
         // ‘should it *not* override Reply-To: with VERP-ed address?’
         $dao->override_verp = !$dao->override_verp;
         $dao->storeValues($dao, $defaults);
         $defaults['visibility'] = $dao->visibility;
     }
     return $defaults;
 }
示例#2
0
 /**
  * Set default values for the form.
  * The default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
     $defaults = array();
     if ($mailingID) {
         $mailing = new CRM_Mailing_DAO_Mailing();
         $mailing->id = $mailingID;
         $mailing->addSelect('name');
         $mailing->find(TRUE);
         $defaults['name'] = $mailing->name;
         if (!$continue) {
             $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
         } else {
             // CRM-7590, reuse same mailing ID if we are continuing
             $this->set('mailing_id', $mailingID);
         }
         $dao = new CRM_Mailing_DAO_MailingGroup();
         $mailingGroups = array();
         $dao->mailing_id = $mailingID;
         $dao->find();
         while ($dao->fetch()) {
             $mailingGroups[$dao->entity_table][$dao->group_type][] = $dao->entity_id;
         }
         $defaults['includeGroups'] = $mailingGroups['civicrm_group']['Include'];
         $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
         $defaults['includeMailings'] = CRM_Utils_Array::value('Include', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups));
         $defaults['excludeMailings'] = CRM_Utils_Array::value('Exclude', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups));
     }
     return $defaults;
 }
示例#3
0
 /**
  * This function sets the default values for the form.
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return void
  */
 function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     //need to differentiate new/reuse mailing, CRM-2873
     $reuseMailing = FALSE;
     if ($mailingID) {
         $reuseMailing = TRUE;
     } else {
         $mailingID = $this->_mailingID;
     }
     $count = $this->get('count');
     $this->assign('count', $count);
     $this->set('skipTextFile', FALSE);
     $defaults = array();
     if ($mailingID) {
         $dao = new CRM_Mailing_DAO_Mailing();
         $dao->id = $mailingID;
         $dao->find(TRUE);
         $dao->storeValues($dao, $defaults);
         //we don't want to retrieve template details once it is
         //set in session
         $templateId = $this->get('template');
         $this->assign('templateSelected', $templateId ? $templateId : 0);
         if (isset($defaults['msg_template_id']) && !$templateId) {
             $defaults['template'] = $defaults['msg_template_id'];
             $messageTemplate = new CRM_Core_DAO_MessageTemplate();
             $messageTemplate->id = $defaults['msg_template_id'];
             $messageTemplate->selectAdd();
             $messageTemplate->selectAdd('msg_text');
             $messageTemplate->find(TRUE);
             $defaults['text_message'] = $messageTemplate->msg_text;
         }
         if (isset($defaults['body_text'])) {
             $defaults['text_message'] = $defaults['body_text'];
             $this->set('textFile', $defaults['body_text']);
             $this->set('skipTextFile', TRUE);
         }
     }
     //fix for CRM-2873
     if (!$reuseMailing) {
         $textFilePath = $this->get('textFilePath');
         if ($textFilePath && file_exists($textFilePath)) {
             $defaults['text_message'] = file_get_contents($textFilePath);
             if (strlen($defaults['text_message']) > 0) {
                 $this->set('skipTextFile', TRUE);
             }
         }
     }
     $defaults['upload_type'] = 1;
     return $defaults;
 }
 /**
  * This function sets the default values for the form.
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
     // check that the user has permission to access mailing id
     CRM_Mailing_BAO_Mailing::checkPermission($mailingID);
     $defaults = array();
     if ($mailingID) {
         $mailing = new CRM_Mailing_DAO_Mailing();
         $mailing->id = $mailingID;
         $mailing->addSelect('name', 'campaign_id');
         $mailing->find(TRUE);
         $defaults['name'] = $mailing->name;
         if (!$continue) {
             $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
         } else {
             // CRM-7590, reuse same mailing ID if we are continuing
             $this->set('mailing_id', $mailingID);
         }
         $defaults['campaign_id'] = $mailing->campaign_id;
         $defaults['dedupe_email'] = $mailing->dedupe_email;
         $dao = new CRM_Mailing_DAO_Group();
         $mailingGroups = array();
         $dao->mailing_id = $mailingID;
         $dao->find();
         while ($dao->fetch()) {
             $mailingGroups[$dao->entity_table][$dao->group_type][] = $dao->entity_id;
         }
         $defaults['includeGroups'] = $mailingGroups['civicrm_group']['Include'];
         $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
         $defaults['includeMailings'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_mailing']);
         $defaults['excludeMailings'] = $mailingGroups['civicrm_mailing']['Exclude'];
     }
     //when the context is search hide the mailing recipients.
     $showHide = new CRM_Core_ShowHideBlocks();
     $showGroupSelector = TRUE;
     if ($this->_searchBasedMailing) {
         $showGroupSelector = FALSE;
         $formElements = array('includeGroups', 'excludeGroups', 'includeMailings', 'excludeMailings');
         $formValues = $this->controller->exportValues($this->_name);
         foreach ($formElements as $element) {
             if (!empty($formValues[$element])) {
                 $showGroupSelector = TRUE;
                 break;
             }
         }
     }
     if ($showGroupSelector) {
         $showHide->addShow("id-additional");
         $showHide->addHide("id-additional-show");
     } else {
         $showHide->addShow("id-additional-show");
         $showHide->addHide("id-additional");
     }
     $showHide->addToTemplate();
     return $defaults;
 }
示例#5
0
 /**
  * Set default values for the form.
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     //need to differentiate new/reuse mailing, CRM-2873
     $reuseMailing = FALSE;
     if ($mailingID) {
         $reuseMailing = TRUE;
     } else {
         $mailingID = $this->_mailingID;
     }
     $count = $this->get('count');
     $this->assign('count', $count);
     $this->set('skipTextFile', FALSE);
     $this->set('skipHtmlFile', FALSE);
     $defaults = array();
     $htmlMessage = NULL;
     if ($mailingID) {
         $dao = new CRM_Mailing_DAO_Mailing();
         $dao->id = $mailingID;
         $dao->find(TRUE);
         $dao->storeValues($dao, $defaults);
         //we don't want to retrieve template details once it is
         //set in session
         $templateId = $this->get('template');
         $this->assign('templateSelected', $templateId ? $templateId : 0);
         if (isset($defaults['msg_template_id']) && !$templateId) {
             $defaults['template'] = $defaults['msg_template_id'];
             $messageTemplate = new CRM_Core_DAO_MessageTemplate();
             $messageTemplate->id = $defaults['msg_template_id'];
             $messageTemplate->selectAdd();
             $messageTemplate->selectAdd('msg_text, msg_html');
             $messageTemplate->find(TRUE);
             $defaults['text_message'] = $messageTemplate->msg_text;
             $htmlMessage = $messageTemplate->msg_html;
         }
         if (isset($defaults['body_text'])) {
             $defaults['text_message'] = $defaults['body_text'];
             $this->set('textFile', $defaults['body_text']);
             $this->set('skipTextFile', TRUE);
         }
         if (isset($defaults['body_html'])) {
             $htmlMessage = $defaults['body_html'];
             $this->set('htmlFile', $defaults['body_html']);
             $this->set('skipHtmlFile', TRUE);
         }
         //set default from email address.
         if (!empty($defaults['from_name']) && !empty($defaults['from_email'])) {
             $defaults['from_email_address'] = array_search('"' . $defaults['from_name'] . '" <' . $defaults['from_email'] . '>', CRM_Core_OptionGroup::values('from_email_address'));
         } else {
             //get the default from email address.
             $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
             foreach ($defaultAddress as $id => $value) {
                 $defaults['from_email_address'] = $id;
             }
         }
         if (!empty($defaults['replyto_email'])) {
             $replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
             foreach ($replyToEmail as $value) {
                 if (strstr($value, $defaults['replyto_email'])) {
                     $replyToEmailAddress = $value;
                     break;
                 }
             }
             $replyToEmailAddress = explode('<', $replyToEmailAddress);
             if (count($replyToEmailAddress) > 1) {
                 $replyToEmailAddress = $replyToEmailAddress[0] . '<' . $replyToEmailAddress[1];
             }
             $defaults['reply_to_address'] = array_search($replyToEmailAddress, $replyToEmail);
         }
     }
     //fix for CRM-2873
     if (!$reuseMailing) {
         $textFilePath = $this->get('textFilePath');
         if ($textFilePath && file_exists($textFilePath)) {
             $defaults['text_message'] = file_get_contents($textFilePath);
             if (strlen($defaults['text_message']) > 0) {
                 $this->set('skipTextFile', TRUE);
             }
         }
         $htmlFilePath = $this->get('htmlFilePath');
         if ($htmlFilePath && file_exists($htmlFilePath)) {
             $defaults['html_message'] = file_get_contents($htmlFilePath);
             if (strlen($defaults['html_message']) > 0) {
                 $htmlMessage = $defaults['html_message'];
                 $this->set('skipHtmlFile', TRUE);
             }
         }
     }
     if ($this->get('html_message')) {
         $htmlMessage = $this->get('html_message');
     }
     $htmlMessage = str_replace(array("\n", "\r"), ' ', $htmlMessage);
     $htmlMessage = str_replace("'", "\\'", $htmlMessage);
     $this->assign('message_html', $htmlMessage);
     $defaults['upload_type'] = 1;
     if (isset($defaults['body_html'])) {
         $defaults['html_message'] = $defaults['body_html'];
     }
     //CRM-4678 setdefault to default component when composing new mailing.
     if (!$reuseMailing) {
         $componentFields = array('header_id' => 'Header', 'footer_id' => 'Footer');
         foreach ($componentFields as $componentVar => $componentType) {
             $defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
         }
     }
     return $defaults;
 }
 /**
  * note that $job_id is used only as a variable in the temp table construction
  * and does not play a role in the queries generated
  * @param int $job_id
  *   (misnomer) a nonce value used to name temporary tables.
  * @param int $mailing_id
  * @param bool $storeRecipients
  * @param bool $dedupeEmail
  * @param null $mode
  *
  * @return CRM_Mailing_Event_BAO_Queue|string
  */
 public static function getRecipients($job_id, $mailing_id = NULL, $storeRecipients = FALSE, $dedupeEmail = FALSE, $mode = NULL)
 {
     $mailingGroup = new CRM_Mailing_DAO_MailingGroup();
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $job = CRM_Mailing_BAO_MailingJob::getTableName();
     $mg = CRM_Mailing_DAO_MailingGroup::getTableName();
     $eq = CRM_Mailing_Event_DAO_Queue::getTableName();
     $email = CRM_Core_DAO_Email::getTableName();
     if ($mode == 'sms') {
         $phone = CRM_Core_DAO_Phone::getTableName();
     }
     $contact = CRM_Contact_DAO_Contact::getTableName();
     $group = CRM_Contact_DAO_Group::getTableName();
     $g2contact = CRM_Contact_DAO_GroupContact::getTableName();
     $m = new CRM_Mailing_DAO_Mailing();
     $m->id = $mailing_id;
     $m->find(TRUE);
     $email_selection_method = $m->email_selection_method;
     $location_type_id = $m->location_type_id;
     // Note: When determining the ORDER that results are returned, it's
     // the record that comes last that counts. That's because we are
     // INSERT'ing INTO a table with a primary id so that last record
     // over writes any previous record.
     switch ($email_selection_method) {
         case 'location-exclude':
             $location_filter = "({$email}.location_type_id != {$location_type_id})";
             // If there is more than one email that doesn't match the location,
             // prefer the one marked is_bulkmail, followed by is_primary.
             $order_by = "ORDER BY {$email}.is_bulkmail, {$email}.is_primary";
             break;
         case 'location-only':
             $location_filter = "({$email}.location_type_id = {$location_type_id})";
             // If there is more than one email of the desired location, prefer
             // the one marked is_bulkmail, followed by is_primary.
             $order_by = "ORDER BY {$email}.is_bulkmail, {$email}.is_primary";
             break;
         case 'location-prefer':
             $location_filter = "({$email}.is_bulkmail = 1 OR {$email}.is_primary = 1 OR {$email}.location_type_id = {$location_type_id})";
             // ORDER BY is more complicated because we have to set an arbitrary
             // order that prefers the location that we want. We do that using
             // the FIELD function. For more info, see:
             // https://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_field
             // We assign the location type we want the value "1" by putting it
             // in the first position after we name the field. All other location
             // types are left out, so they will be assigned the value 0. That
             // means, they will all be equally tied for first place, with our
             // location being last.
             $order_by = "ORDER BY FIELD({$email}.location_type_id, {$location_type_id}), {$email}.is_bulkmail, {$email}.is_primary";
             break;
         case 'automatic':
             // fall through to default
         // fall through to default
         default:
             $location_filter = "({$email}.is_bulkmail = 1 OR {$email}.is_primary = 1)";
             $order_by = "ORDER BY {$email}.is_bulkmail";
     }
     /* Create a temp table for contact exclusion */
     $mailingGroup->query("CREATE TEMPORARY TABLE X_{$job_id}\n            (contact_id int primary key)\n            ENGINE=HEAP");
     /* Add all the members of groups excluded from this mailing to the temp
      * table */
     $excludeSubGroup = "INSERT INTO        X_{$job_id} (contact_id)\n                    SELECT  DISTINCT    {$g2contact}.contact_id\n                    FROM                {$g2contact}\n                    INNER JOIN          {$mg}\n                            ON          {$g2contact}.group_id = {$mg}.entity_id AND {$mg}.entity_table = '{$group}'\n                    WHERE\n                                        {$mg}.mailing_id = {$mailing_id}\n                        AND             {$g2contact}.status = 'Added'\n                        AND             {$mg}.group_type = 'Exclude'";
     $mailingGroup->query($excludeSubGroup);
     /* Add all unsubscribe members of base group from this mailing to the temp
      * table */
     $unSubscribeBaseGroup = "INSERT INTO        X_{$job_id} (contact_id)\n                    SELECT  DISTINCT    {$g2contact}.contact_id\n                    FROM                {$g2contact}\n                    INNER JOIN          {$mg}\n                            ON          {$g2contact}.group_id = {$mg}.entity_id AND {$mg}.entity_table = '{$group}'\n                    WHERE\n                                        {$mg}.mailing_id = {$mailing_id}\n                        AND             {$g2contact}.status = 'Removed'\n                        AND             {$mg}.group_type = 'Base'";
     $mailingGroup->query($unSubscribeBaseGroup);
     /* Add all the (intended) recipients of an excluded prior mailing to
      * the temp table */
     $excludeSubMailing = "INSERT IGNORE INTO X_{$job_id} (contact_id)\n                    SELECT  DISTINCT    {$eq}.contact_id\n                    FROM                {$eq}\n                    INNER JOIN          {$job}\n                            ON          {$eq}.job_id = {$job}.id\n                    INNER JOIN          {$mg}\n                            ON          {$job}.mailing_id = {$mg}.entity_id AND {$mg}.entity_table = '{$mailing}'\n                    WHERE\n                                        {$mg}.mailing_id = {$mailing_id}\n                        AND             {$mg}.group_type = 'Exclude'";
     $mailingGroup->query($excludeSubMailing);
     // get all the saved searches AND hierarchical groups
     // and load them in the cache
     $sql = "\nSELECT     {$group}.id, {$group}.cache_date, {$group}.saved_search_id, {$group}.children\nFROM       {$group}\nINNER JOIN {$mg} ON {$mg}.entity_id = {$group}.id\nWHERE      {$mg}.entity_table = '{$group}'\n  AND      {$mg}.group_type = 'Exclude'\n  AND      {$mg}.mailing_id = {$mailing_id}\n  AND      ( saved_search_id != 0\n   OR        saved_search_id IS NOT NULL\n   OR        children IS NOT NULL )\n";
     $groupDAO = CRM_Core_DAO::executeQuery($sql);
     while ($groupDAO->fetch()) {
         if ($groupDAO->cache_date == NULL) {
             CRM_Contact_BAO_GroupContactCache::load($groupDAO);
         }
         $smartGroupExclude = "\nINSERT IGNORE INTO X_{$job_id} (contact_id)\nSELECT c.contact_id\nFROM   civicrm_group_contact_cache c\nWHERE  c.group_id = {$groupDAO->id}\n";
         $mailingGroup->query($smartGroupExclude);
     }
     $tempColumn = 'email_id';
     if ($mode == 'sms') {
         $tempColumn = 'phone_id';
     }
     /* Get all the group contacts we want to include */
     $mailingGroup->query("CREATE TEMPORARY TABLE I_{$job_id}\n            ({$tempColumn} int, contact_id int primary key)\n            ENGINE=HEAP");
     /* Get the group contacts, but only those which are not in the
      * exclusion temp table */
     $query = "REPLACE INTO       I_{$job_id} (email_id, contact_id)\n\n                    SELECT DISTINCT     {$email}.id as email_id,\n                                        {$contact}.id as contact_id\n                    FROM                {$email}\n                    INNER JOIN          {$contact}\n                            ON          {$email}.contact_id = {$contact}.id\n                    INNER JOIN          {$g2contact}\n                            ON          {$contact}.id = {$g2contact}.contact_id\n                    INNER JOIN          {$mg}\n                            ON          {$g2contact}.group_id = {$mg}.entity_id\n                                AND     {$mg}.entity_table = '{$group}'\n                    LEFT JOIN           X_{$job_id}\n                            ON          {$contact}.id = X_{$job_id}.contact_id\n                    WHERE\n                                       ({$mg}.group_type = 'Include')\n                        AND             {$mg}.search_id IS NULL\n                        AND             {$g2contact}.status = 'Added'\n                        AND             {$contact}.do_not_email = 0\n                        AND             {$contact}.is_opt_out = 0\n                        AND             {$contact}.is_deceased <> 1\n                        AND             {$location_filter}\n                        AND             {$email}.email IS NOT NULL\n                        AND             {$email}.email != ''\n                        AND             {$email}.on_hold = 0\n                        AND             {$mg}.mailing_id = {$mailing_id}\n                        AND             X_{$job_id}.contact_id IS null\n                    {$order_by}";
     if ($mode == 'sms') {
         $phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name');
         $query = "REPLACE INTO       I_{$job_id} (phone_id, contact_id)\n\n                    SELECT DISTINCT     {$phone}.id as phone_id,\n                                        {$contact}.id as contact_id\n                    FROM                {$phone}\n                    INNER JOIN          {$contact}\n                            ON          {$phone}.contact_id = {$contact}.id\n                    INNER JOIN          {$g2contact}\n                            ON          {$contact}.id = {$g2contact}.contact_id\n                    INNER JOIN          {$mg}\n                            ON          {$g2contact}.group_id = {$mg}.entity_id\n                                AND     {$mg}.entity_table = '{$group}'\n                    LEFT JOIN           X_{$job_id}\n                            ON          {$contact}.id = X_{$job_id}.contact_id\n                    WHERE\n                                       ({$mg}.group_type = 'Include')\n                        AND             {$mg}.search_id IS NULL\n                        AND             {$g2contact}.status = 'Added'\n                        AND             {$contact}.do_not_sms = 0\n                        AND             {$contact}.is_opt_out = 0\n                        AND             {$contact}.is_deceased <> 1\n                        AND             {$phone}.phone_type_id = {$phoneTypes['Mobile']}\n                        AND             {$phone}.phone IS NOT NULL\n                        AND             {$phone}.phone != ''\n                        AND             {$mg}.mailing_id = {$mailing_id}\n                        AND             X_{$job_id}.contact_id IS null";
     }
     $mailingGroup->query($query);
     /* Query prior mailings */
     $query = "REPLACE INTO       I_{$job_id} (email_id, contact_id)\n                    SELECT DISTINCT     {$email}.id as email_id,\n                                        {$contact}.id as contact_id\n                    FROM                {$email}\n                    INNER JOIN          {$contact}\n                            ON          {$email}.contact_id = {$contact}.id\n                    INNER JOIN          {$eq}\n                            ON          {$eq}.contact_id = {$contact}.id\n                    INNER JOIN          {$job}\n                            ON          {$eq}.job_id = {$job}.id\n                    INNER JOIN          {$mg}\n                            ON          {$job}.mailing_id = {$mg}.entity_id AND {$mg}.entity_table = '{$mailing}'\n                    LEFT JOIN           X_{$job_id}\n                            ON          {$contact}.id = X_{$job_id}.contact_id\n                    WHERE\n                                       ({$mg}.group_type = 'Include')\n                        AND             {$contact}.do_not_email = 0\n                        AND             {$contact}.is_opt_out = 0\n                        AND             {$contact}.is_deceased <> 1\n                        AND             {$location_filter}\n                        AND             {$email}.on_hold = 0\n                        AND             {$mg}.mailing_id = {$mailing_id}\n                        AND             X_{$job_id}.contact_id IS null\n                    {$order_by}";
     if ($mode == 'sms') {
         $query = "REPLACE INTO       I_{$job_id} (phone_id, contact_id)\n                    SELECT DISTINCT     {$phone}.id as phone_id,\n                                        {$contact}.id as contact_id\n                    FROM                {$phone}\n                    INNER JOIN          {$contact}\n                            ON          {$phone}.contact_id = {$contact}.id\n                    INNER JOIN          {$eq}\n                            ON          {$eq}.contact_id = {$contact}.id\n                    INNER JOIN          {$job}\n                            ON          {$eq}.job_id = {$job}.id\n                    INNER JOIN          {$mg}\n                            ON          {$job}.mailing_id = {$mg}.entity_id AND {$mg}.entity_table = '{$mailing}'\n                    LEFT JOIN           X_{$job_id}\n                            ON          {$contact}.id = X_{$job_id}.contact_id\n                    WHERE\n                                       ({$mg}.group_type = 'Include')\n                        AND             {$contact}.do_not_sms = 0\n                        AND             {$contact}.is_opt_out = 0\n                        AND             {$contact}.is_deceased <> 1\n                        AND             {$phone}.phone_type_id = {$phoneTypes['Mobile']}\n                        AND             {$mg}.mailing_id = {$mailing_id}\n                        AND             X_{$job_id}.contact_id IS null";
     }
     $mailingGroup->query($query);
     $sql = "\nSELECT     {$group}.id, {$group}.cache_date, {$group}.saved_search_id, {$group}.children\nFROM       {$group}\nINNER JOIN {$mg} ON {$mg}.entity_id = {$group}.id\nWHERE      {$mg}.entity_table = '{$group}'\n  AND      {$mg}.group_type = 'Include'\n  AND      {$mg}.search_id IS NULL\n  AND      {$mg}.mailing_id = {$mailing_id}\n  AND      ( saved_search_id != 0\n   OR        saved_search_id IS NOT NULL\n   OR        children IS NOT NULL )\n";
     $groupDAO = CRM_Core_DAO::executeQuery($sql);
     while ($groupDAO->fetch()) {
         if ($groupDAO->cache_date == NULL) {
             CRM_Contact_BAO_GroupContactCache::load($groupDAO);
         }
         $smartGroupInclude = "\nREPLACE INTO I_{$job_id} (email_id, contact_id)\nSELECT     civicrm_email.id as email_id, c.id as contact_id\nFROM       civicrm_contact c\nINNER JOIN civicrm_email                ON civicrm_email.contact_id         = c.id\nINNER JOIN civicrm_group_contact_cache gc ON gc.contact_id        = c.id\nLEFT  JOIN X_{$job_id}                      ON X_{$job_id}.contact_id = c.id\nWHERE      gc.group_id = {$groupDAO->id}\n  AND      c.do_not_email = 0\n  AND      c.is_opt_out = 0\n  AND      c.is_deceased <> 1\n  AND      {$location_filter}\n  AND      civicrm_email.on_hold = 0\n  AND      X_{$job_id}.contact_id IS null\n{$order_by}\n";
         if ($mode == 'sms') {
             $smartGroupInclude = "\nREPLACE INTO I_{$job_id} (phone_id, contact_id)\nSELECT     p.id as phone_id, c.id as contact_id\nFROM       civicrm_contact c\nINNER JOIN civicrm_phone p                ON p.contact_id         = c.id\nINNER JOIN civicrm_group_contact_cache gc ON gc.contact_id        = c.id\nLEFT  JOIN X_{$job_id}                      ON X_{$job_id}.contact_id = c.id\nWHERE      gc.group_id = {$groupDAO->id}\n  AND      c.do_not_sms = 0\n  AND      c.is_opt_out = 0\n  AND      c.is_deceased <> 1\n  AND      p.phone_type_id = {$phoneTypes['Mobile']}\n  AND      X_{$job_id}.contact_id IS null";
         }
         $mailingGroup->query($smartGroupInclude);
     }
     /**
      * Construct the filtered search queries
      */
     $query = "\nSELECT search_id, search_args, entity_id\nFROM   {$mg}\nWHERE  {$mg}.search_id IS NOT NULL\nAND    {$mg}.mailing_id = {$mailing_id}\n";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $customSQL = CRM_Contact_BAO_SearchCustom::civiMailSQL($dao->search_id, $dao->search_args, $dao->entity_id);
         $query = "REPLACE INTO       I_{$job_id} ({$tempColumn}, contact_id)\n                         {$customSQL}";
         $mailingGroup->query($query);
     }
     /* Get the emails with only location override */
     $query = "REPLACE INTO       I_{$job_id} (email_id, contact_id)\n                    SELECT DISTINCT     {$email}.id as local_email_id,\n                                        {$contact}.id as contact_id\n                    FROM                {$email}\n                    INNER JOIN          {$contact}\n                            ON          {$email}.contact_id = {$contact}.id\n                    INNER JOIN          {$g2contact}\n                            ON          {$contact}.id = {$g2contact}.contact_id\n                    INNER JOIN          {$mg}\n                            ON          {$g2contact}.group_id = {$mg}.entity_id\n                    LEFT JOIN           X_{$job_id}\n                            ON          {$contact}.id = X_{$job_id}.contact_id\n                    WHERE\n                                        {$mg}.entity_table = '{$group}'\n                        AND             {$mg}.group_type = 'Include'\n                        AND             {$g2contact}.status = 'Added'\n                        AND             {$contact}.do_not_email = 0\n                        AND             {$contact}.is_opt_out = 0\n                        AND             {$contact}.is_deceased <> 1\n                        AND             {$location_filter}\n                        AND             {$email}.on_hold = 0\n                        AND             {$mg}.mailing_id = {$mailing_id}\n                        AND             X_{$job_id}.contact_id IS null\n                    {$order_by}";
     if ($mode == "sms") {
         $query = "REPLACE INTO       I_{$job_id} (phone_id, contact_id)\n                    SELECT DISTINCT     {$phone}.id as phone_id,\n                                        {$contact}.id as contact_id\n                    FROM                {$phone}\n                    INNER JOIN          {$contact}\n                            ON          {$phone}.contact_id = {$contact}.id\n                    INNER JOIN          {$g2contact}\n                            ON          {$contact}.id = {$g2contact}.contact_id\n                    INNER JOIN          {$mg}\n                            ON          {$g2contact}.group_id = {$mg}.entity_id\n                    LEFT JOIN           X_{$job_id}\n                            ON          {$contact}.id = X_{$job_id}.contact_id\n                    WHERE\n                                        {$mg}.entity_table = '{$group}'\n                        AND             {$mg}.group_type = 'Include'\n                        AND             {$g2contact}.status = 'Added'\n                        AND             {$contact}.do_not_sms = 0\n                        AND             {$contact}.is_opt_out = 0\n                        AND             {$contact}.is_deceased <> 1\n                        AND             {$phone}.phone_type_id = {$phoneTypes['Mobile']}\n                        AND             {$mg}.mailing_id = {$mailing_id}\n                        AND             X_{$job_id}.contact_id IS null";
     }
     $mailingGroup->query($query);
     $eq = new CRM_Mailing_Event_BAO_Queue();
     list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause();
     $aclWhere = $aclWhere ? "WHERE {$aclWhere}" : '';
     if ($storeRecipients && $mailing_id) {
         $sql = "\nDELETE\nFROM   civicrm_mailing_recipients\nWHERE  mailing_id = %1\n";
         $params = array(1 => array($mailing_id, 'Integer'));
         CRM_Core_DAO::executeQuery($sql, $params);
         // CRM-3975
         $groupBy = $groupJoin = '';
         if ($dedupeEmail) {
             $groupJoin = " INNER JOIN civicrm_email e ON e.id = i.email_id";
             $groupBy = " GROUP BY e.email ";
         }
         $sql = "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, {$tempColumn} )\nSELECT %1, i.contact_id, i.{$tempColumn}\nFROM       civicrm_contact contact_a\nINNER JOIN I_{$job_id} i ON contact_a.id = i.contact_id\n           {$groupJoin}\n           {$aclFrom}\n           {$aclWhere}\n           {$groupBy}\nORDER BY   i.contact_id, i.{$tempColumn}\n";
         CRM_Core_DAO::executeQuery($sql, $params);
         // if we need to add all emails marked bulk, do it as a post filter
         // on the mailing recipients table
         if (CRM_Core_BAO_Email::isMultipleBulkMail()) {
             self::addMultipleEmails($mailing_id);
         }
     }
     /* Delete the temp table */
     $mailingGroup->reset();
     $mailingGroup->query("DROP TEMPORARY TABLE X_{$job_id}");
     $mailingGroup->query("DROP TEMPORARY TABLE I_{$job_id}");
     return $eq;
 }
 /**
  * This function sets the default values for the form.
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     // to continue the unscheduled or draft mailing
     $continue = $this->_continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     $defaults = array();
     if ($this->_mailingID) {
         // check that the user has permission to access mailing id
         CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingID);
         $mailing = new CRM_Mailing_DAO_Mailing();
         $mailing->id = $this->_mailingID;
         $mailing->addSelect('name', 'campaign_id');
         $mailing->find(TRUE);
         $defaults['name'] = $mailing->name;
         if (!$continue) {
             $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
         } else {
             // CRM-7590, reuse same mailing ID if we are continuing
             $this->set('mailing_id', $this->_mailingID);
         }
         $defaults['campaign_id'] = $mailing->campaign_id;
         $defaults['dedupe_email'] = $mailing->dedupe_email;
         $dao = new CRM_Mailing_DAO_MailingGroup();
         $mailingGroups = array('civicrm_group' => array(), 'civicrm_mailing' => array());
         $dao->mailing_id = $this->_mailingID;
         $dao->find();
         while ($dao->fetch()) {
             // account for multi-lingual
             // CRM-11431
             $entityTable = 'civicrm_group';
             if (substr($dao->entity_table, 0, 15) == 'civicrm_mailing') {
                 $entityTable = 'civicrm_mailing';
             }
             $mailingGroups[$entityTable][$dao->group_type][] = $dao->entity_id;
         }
         $defaults['includeGroups'] = $mailingGroups['civicrm_group']['include'];
         $defaults['excludeGroups'] = CRM_Utils_Array::value('exclude', $mailingGroups['civicrm_group']);
         if (!empty($mailingGroups['civicrm_mailing'])) {
             $defaults['includeMailings'] = CRM_Utils_Array::value('include', $mailingGroups['civicrm_mailing']);
             $defaults['excludeMailings'] = CRM_Utils_Array::value('exclude', $mailingGroups['civicrm_mailing']);
         }
     } else {
         $defaults['url_tracking'] = TRUE;
         $defaults['open_tracking'] = TRUE;
     }
     //set default message body
     $reuseMailing = FALSE;
     if ($mailingID) {
         $reuseMailing = TRUE;
     } else {
         $mailingID = $this->_mailingID;
     }
     $count = $this->get('count');
     $this->assign('count', $count);
     $this->set('skipTextFile', FALSE);
     $this->set('skipHtmlFile', FALSE);
     $htmlMessage = NULL;
     if ($mailingID) {
         $dao = new CRM_Mailing_DAO_Mailing();
         $dao->id = $mailingID;
         $dao->find(TRUE);
         $dao->storeValues($dao, $defaults);
         //we don't want to retrieve template details once it is
         //set in session
         $templateId = $this->get('template');
         $this->assign('templateSelected', $templateId ? $templateId : 0);
         if (isset($defaults['msg_template_id']) && !$templateId) {
             $defaults['template'] = $defaults['msg_template_id'];
             $messageTemplate = new CRM_Core_DAO_MessageTemplate();
             $messageTemplate->id = $defaults['msg_template_id'];
             $messageTemplate->selectAdd();
             $messageTemplate->selectAdd('msg_text, msg_html');
             $messageTemplate->find(TRUE);
             $defaults['text_message'] = $messageTemplate->msg_text;
             $htmlMessage = $messageTemplate->msg_html;
         }
         if (isset($defaults['body_text'])) {
             $defaults['text_message'] = $defaults['body_text'];
             $this->set('textFile', $defaults['body_text']);
             $this->set('skipTextFile', TRUE);
         }
         if (isset($defaults['body_html'])) {
             $htmlMessage = $defaults['body_html'];
             $this->set('htmlFile', $defaults['body_html']);
             $this->set('skipHtmlFile', TRUE);
         }
         //set default from email address.
         if (CRM_Utils_Array::value('from_name', $defaults) && CRM_Utils_Array::value('from_email', $defaults)) {
             $defaults['from_email_address'] = array_search('"' . $defaults['from_name'] . '" <' . $defaults['from_email'] . '>', CRM_Core_OptionGroup::values('from_email_address'));
         } else {
             //get the default from email address.
             $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
             foreach ($defaultAddress as $id => $value) {
                 $defaults['from_email_address'] = $id;
             }
         }
         if (CRM_Utils_Array::value('replyto_email', $defaults)) {
             $replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
             foreach ($replyToEmail as $value) {
                 if (strstr($value, $defaults['replyto_email'])) {
                     $replyToEmailAddress = $value;
                     break;
                 }
             }
             $replyToEmailAddress = explode('<', $replyToEmailAddress);
             $replyToEmailAddress = $replyToEmailAddress[0] . '<' . $replyToEmailAddress[1];
             $this->replytoAddress = $defaults['reply_to_address'] = array_search($replyToEmailAddress, $replyToEmail);
         }
     }
     /*
     //set default from email address.
     if (CRM_Utils_Array::value('from_name', $defaults) && CRM_Utils_Array::value('from_email', $defaults)) {
       $defaults['from_email_address'] = array_search('"' . $defaults['from_name'] . '" <' . $defaults['from_email'] . '>',
         CRM_Core_OptionGroup::values('from_email_address')
       );
     }
     else {
       //get the default from email address.
       $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
       foreach ($defaultAddress as $id => $value) {
         $defaults['from_email_address'] = $id;
       }
     }
     
     if (CRM_Utils_Array::value('replyto_email', $defaults)) {
       $replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
       foreach ($replyToEmail as $value) {
         if (strstr($value, $defaults['replyto_email'])) {
           $replyToEmailAddress = $value;
           break;
         }
       }
       $replyToEmailAddress = explode('<', $replyToEmailAddress);
       $replyToEmailAddress = $replyToEmailAddress[0] . '<' . $replyToEmailAddress[1];
       $this->replytoAddress = $defaults['reply_to_address'] = array_search($replyToEmailAddress, $replyToEmail);
     }
     */
     //fix for CRM-2873
     if (!$reuseMailing) {
         $textFilePath = $this->get('textFilePath');
         if ($textFilePath && file_exists($textFilePath)) {
             $defaults['text_message'] = file_get_contents($textFilePath);
             if (strlen($defaults['text_message']) > 0) {
                 $this->set('skipTextFile', TRUE);
             }
         }
         $htmlFilePath = $this->get('htmlFilePath');
         if ($htmlFilePath && file_exists($htmlFilePath)) {
             $defaults['html_message'] = file_get_contents($htmlFilePath);
             if (strlen($defaults['html_message']) > 0) {
                 $htmlMessage = $defaults['html_message'];
                 $this->set('skipHtmlFile', TRUE);
             }
         }
     }
     if ($this->get('html_message')) {
         $htmlMessage = $this->get('html_message');
     }
     $htmlMessage = str_replace(array("\n", "\r"), ' ', $htmlMessage);
     $htmlMessage = str_replace("'", "\\'", $htmlMessage);
     $this->assign('message_html', $htmlMessage);
     $defaults['upload_type'] = 1;
     if (isset($defaults['body_html'])) {
         $defaults['html_message'] = $defaults['body_html'];
     }
     if (!empty($defaults['html_message'])) {
         $this->assign('reuse_message_template', $defaults['html_message']);
     }
     //CRM-4678 setdefault to default component when composing new mailing.
     if (!$reuseMailing) {
         $componentFields = array('header_id' => 'Header', 'footer_id' => 'Footer');
         foreach ($componentFields as $componentVar => $componentType) {
             $defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
         }
     }
     //end
     return $defaults;
 }
示例#8
0
 /**
  * Set default values for the form.
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
     $defaults = array();
     $defaults['dedupe_email'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'dedupe_email_default', NULL, FALSE);
     if ($this->_mailingID) {
         // check that the user has permission to access mailing id
         CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingID);
         $mailing = new CRM_Mailing_DAO_Mailing();
         $mailing->id = $this->_mailingID;
         $mailing->addSelect('name', 'campaign_id');
         $mailing->find(TRUE);
         $defaults['name'] = $mailing->name;
         if (!$continue) {
             $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
         } else {
             // CRM-7590, reuse same mailing ID if we are continuing
             $this->set('mailing_id', $this->_mailingID);
         }
         $defaults['campaign_id'] = $mailing->campaign_id;
         $defaults['dedupe_email'] = $mailing->dedupe_email;
         $defaults['location_type_id'] = $mailing->location_type_id;
         $defaults['email_selection_method'] = $mailing->email_selection_method;
         $dao = new CRM_Mailing_DAO_MailingGroup();
         $mailingGroups = array('civicrm_group' => array(), 'civicrm_mailing' => array());
         $dao->mailing_id = $this->_mailingID;
         $dao->find();
         while ($dao->fetch()) {
             // account for multi-lingual
             // CRM-11431
             $entityTable = 'civicrm_group';
             if (substr($dao->entity_table, 0, 15) == 'civicrm_mailing') {
                 $entityTable = 'civicrm_mailing';
             }
             $mailingGroups[$entityTable][$dao->group_type][] = $dao->entity_id;
         }
         $defaults['includeGroups'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_group']);
         $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
         if (!empty($mailingGroups['civicrm_mailing'])) {
             $defaults['includeMailings'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_mailing']);
             $defaults['excludeMailings'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_mailing']);
         }
     }
     //when the context is search hide the mailing recipients.
     $showHide = new CRM_Core_ShowHideBlocks();
     $showGroupSelector = TRUE;
     if ($this->_searchBasedMailing) {
         $showGroupSelector = FALSE;
         $formElements = array('includeGroups', 'excludeGroups', 'includeMailings', 'excludeMailings');
         $formValues = $this->controller->exportValues($this->_name);
         foreach ($formElements as $element) {
             if (!empty($formValues[$element])) {
                 $showGroupSelector = TRUE;
                 break;
             }
         }
     }
     if ($showGroupSelector) {
         $showHide->addShow("id-additional");
         $showHide->addHide("id-additional-show");
     } else {
         $showHide->addShow("id-additional-show");
         $showHide->addHide("id-additional");
     }
     $showHide->addToTemplate();
     return $defaults;
 }
示例#9
0
 /**
  * This function sets the default values for the form.
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, false, null);
     //need to differentiate new/reuse mailing, CRM-2873
     $reuseMailing = false;
     if ($mailingID) {
         $reuseMailing = true;
     } else {
         $mailingID = $this->_mailingID;
     }
     $count = $this->get('count');
     $this->assign('count', $count);
     $this->set('skipTextFile', false);
     $this->set('skipHtmlFile', false);
     $defaults = array();
     $htmlMessage = null;
     if ($mailingID) {
         require_once 'CRM/Mailing/DAO/Mailing.php';
         $dao = new CRM_Mailing_DAO_Mailing();
         $dao->id = $mailingID;
         $dao->find(true);
         $dao->storeValues($dao, $defaults);
         //we don't want to retrieve template details once it is
         //set in session
         $templateId = $this->get('template');
         $this->assign('templateSelected', $templateId ? $templateId : 0);
         if (isset($defaults['msg_template_id']) && !$templateId) {
             $defaults['template'] = $defaults['msg_template_id'];
             $messageTemplate = new CRM_Core_DAO_MessageTemplates();
             $messageTemplate->id = $defaults['msg_template_id'];
             $messageTemplate->selectAdd();
             $messageTemplate->selectAdd('msg_text, msg_html');
             $messageTemplate->find(true);
             $defaults['text_message'] = $messageTemplate->msg_text;
             $htmlMessage = $messageTemplate->msg_html;
         }
         if (isset($defaults['body_text'])) {
             $defaults['text_message'] = $defaults['body_text'];
             $this->set('textFile', $defaults['body_text']);
             $this->set('skipTextFile', true);
         }
         if (isset($defaults['body_html'])) {
             $htmlMessage = $defaults['body_html'];
             $this->set('htmlFile', $defaults['body_html']);
             $this->set('skipHtmlFile', true);
         }
         //set default from email address.
         require_once 'CRM/Core/OptionGroup.php';
         if (CRM_Utils_Array::value('from_name', $defaults) && CRM_Utils_Array::value('from_email', $defaults)) {
             $defaults['from_email_address'] = array_search('"' . $defaults['from_name'] . '" <' . $defaults['from_email'] . '>', CRM_Core_OptionGroup::values('from_email_address'));
         } else {
             //get the default from email address.
             $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', null, null, null, ' AND is_default = 1');
             foreach ($defaultAddress as $id => $value) {
                 $defaults['from_email_address'] = $id;
             }
         }
     }
     //fix for CRM-2873
     if (!$reuseMailing) {
         $textFilePath = $this->get('textFilePath');
         if ($textFilePath && file_exists($textFilePath)) {
             $defaults['text_message'] = file_get_contents($textFilePath);
             if (strlen($defaults['text_message']) > 0) {
                 $this->set('skipTextFile', true);
             }
         }
         $htmlFilePath = $this->get('htmlFilePath');
         if ($htmlFilePath && file_exists($htmlFilePath)) {
             $defaults['html_message'] = file_get_contents($htmlFilePath);
             if (strlen($defaults['html_message']) > 0) {
                 $htmlMessage = $defaults['html_message'];
                 $this->set('skipHtmlFile', true);
             }
         }
     }
     if ($this->get('html_message')) {
         $htmlMessage = $this->get('html_message');
     }
     $htmlMessage = str_replace(array("\n", "\r"), ' ', $htmlMessage);
     $htmlMessage = str_replace("'", "\\'", $htmlMessage);
     $this->assign('message_html', $htmlMessage);
     $defaults['upload_type'] = 1;
     if (isset($defaults['body_html'])) {
         $defaults['html_message'] = $defaults['body_html'];
     }
     //CRM-4678 setdefault to default component when composing new mailing.
     if (!$reuseMailing) {
         $componentFields = array('header_id' => 'Header', 'footer_id' => 'Footer');
         foreach ($componentFields as $componentVar => $componentType) {
             $defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
         }
     }
     return $defaults;
 }
示例#10
0
function mte_createQueue(&$mandrillHeader, $toEmail)
{
    $mail = new CRM_Mailing_DAO_Mailing();
    $mail->subject = "***All Transactional Emails***";
    $mail->url_tracking = TRUE;
    $mail->forward_replies = FALSE;
    $mail->auto_responder = FALSE;
    $mail->open_tracking = TRUE;
    if ($mail->find(TRUE)) {
        $emails = CRM_Mte_BAO_Mandrill::retrieveEmailContactId($toEmail);
        $jobCLassName = 'CRM_Mailing_DAO_MailingJob';
        if (version_compare('4.4alpha1', CRM_Core_Config::singleton()->civiVersion) > 0) {
            $jobCLassName = 'CRM_Mailing_DAO_Job';
        }
        $params = array('job_id' => CRM_Core_DAO::getFieldValue($jobCLassName, $mail->id, 'id', 'mailing_id'), 'contact_id' => $emails['email']['contact_id'], 'email_id' => $emails['email']['id']);
        $eventQueue = CRM_Mailing_Event_BAO_Queue::create($params);
        $mandrillHeader = implode(CRM_Core_Config::singleton()->verpSeparator, array($mandrillHeader, 'm', $params['job_id'], $eventQueue->id, $eventQueue->hash));
    }
}
 /**
  * Example: Run an external SQL script
  *
  * @return TRUE on success
  * @throws Exception
  */
 public function upgrade_4620()
 {
     $this->ctx->log->info('Applying update for version 2.0');
     $mail = new CRM_Mailing_DAO_Mailing();
     $mail->domain_id = CRM_Core_Config::domainID();
     $mail->subject = "***All Transactional Emails***";
     $mail->url_tracking = TRUE;
     $mail->forward_replies = FALSE;
     $mail->auto_responder = FALSE;
     $mail->open_tracking = TRUE;
     if ($mail->find(TRUE)) {
         $mail->name = ts('Transaction Emails');
         $mail->save();
     }
     $url = CRM_Utils_System::url('civicrm/mte/smtp', 'reset=1', TRUE, NULL, FALSE, TRUE);
     CRM_Core_Session::setStatus(ts("Update the <a href={$url}>Mandrill settings</a> to configure it to use for Transactional Email and/or Civi Bulk Mail."));
     return TRUE;
 }