3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
28 * Upgrade logic for 4.7
30 class CRM_Upgrade_Incremental_php_FourSeven
extends CRM_Upgrade_Incremental_Base
{
33 * Compute any messages which should be displayed beforeupgrade.
35 * Note: This function is called iteratively for each upcoming
36 * revision to the database.
38 * @param string $preUpgradeMessage
40 * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
41 * @param null $currentVer
43 public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
44 if ($rev == '4.7.alpha1') {
45 // CRM-16478 Remove custom fatal error template path option
46 $config = CRM_Core_Config
::singleton();
47 if (!empty($config->fatalErrorTemplate
) && $config->fatalErrorTemplate
!= 'CRM/common/fatal.tpl') {
48 $preUpgradeMessage .= '<p>' . ts('The custom fatal error template setting will be removed during the upgrade. You are currently using this custom template: %1 . Following the upgrade you will need to use the standard approach to overriding template files, as described in the documentation.', array(1 => $config->fatalErrorTemplate
)) . '</p>';
51 if ($rev == '4.7.alpha4') {
52 // CRM-17004 Warn of Moneris removal
54 // Query only works in 4.3+
55 if (version_compare($currentVer, "4.3.0") > 0) {
56 $count = CRM_Core_DAO
::singleValueQuery("SELECT COUNT(id) FROM civicrm_payment_processor WHERE payment_processor_type_id IN (SELECT id FROM civicrm_payment_processor_type WHERE name = 'Moneris')");
58 if ($count && !function_exists('moneris_civicrm_managed')) {
59 $preUpgradeMessage .= '<p>' . ts('The %1 payment processor is no longer bundled with CiviCRM. After upgrading you will need to install the extension to continue using it.', array(1 => 'Moneris')) . '</p>';
65 * Compute any messages which should be displayed after upgrade.
67 * @param string $postUpgradeMessage
70 * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
72 public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
73 if ($rev == '4.7.alpha1') {
74 $config = CRM_Core_Config
::singleton();
75 // FIXME: Performing an upgrade step during postUpgrade message phase is probably bad
76 $editor_id = self
::updateWysiwyg();
78 $ext_href = 'href="' . CRM_Utils_System
::url('civicrm/admin/extensions', 'reset=1') . '"';
79 $dsp_href = 'href="' . CRM_Utils_System
::url('civicrm/admin/setting/preferences/display', 'reset=1') . '"';
80 $blog_href = 'href="https://civicrm.org/blogs/colemanw/big-changes-wysiwyg-editing-47"';
84 $msg = ts('Your configured editor "TinyMCE" is no longer part of the main CiviCRM download. To continue using it, visit the <a %1>Manage Extensions</a> page to download and install the TinyMCE extension.', array(1 => $ext_href));
87 // Drupal/Joomla editor
90 $msg = ts('CiviCRM no longer integrates with the "%1 Default Editor." Your wysiwyg setting has been reset to the built-in CKEditor. <a %2>Learn more...</a>', array(1 => $config->userFramework
, 2 => $blog_href));
94 $postUpgradeMessage .= '<p>' . $msg . '</p>';
96 $postUpgradeMessage .= '<p>' . ts('CiviCRM now includes the easy-to-use CKEditor Configurator. To customize the features and display of your wysiwyg editor, visit the <a %1>Display Preferences</a> page. <a %2>Learn more...</a>', array(1 => $dsp_href, 2 => $blog_href)) . '</p>';
98 $postUpgradeMessage .= '<br /><br />' . ts('Default version of the following System Workflow Message Templates have been modified: <ul><li>Personal Campaign Pages - Owner Notification</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).');
100 $postUpgradeMessage .= '<p>' . ts('The custom fatal error template setting has been removed.') . '</p>';
109 public function upgrade_4_7_alpha1($rev) {
110 $this->addTask('Migrate \'on behalf of\' information to module_data', 'migrateOnBehalfOfInfo');
111 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
112 $this->addTask(ts('Migrate Settings to %1', array(1 => $rev)), 'migrateSettings', $rev);
113 $this->addTask('Add Getting Started dashlet', 'addGettingStartedDashlet', $rev);
121 public function upgrade_4_7_alpha4($rev) {
122 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
123 $this->addTask(ts('Remove %1', array(1 => 'Moneris')), 'removePaymentProcessorType', 'Moneris');
124 $this->addTask('Update Smart Groups', 'fixContactTypeInSmartGroups');
132 public function upgrade_4_7_beta2($rev) {
133 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
134 $this->addTask('Delete unused file', 'deleteVersionCheckCacheFile');
142 public function upgrade_4_7_beta6($rev) {
143 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
144 $this->addTask('Disable flexible jobs extension', 'disableFlexibleJobsExtension');
145 $this->addTask('Add Index to financial_trxn trxn_id field', 'addIndexFinancialTrxnTrxnID');
153 public function upgrade_4_7_1($rev) {
154 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
155 $this->addTask('Add Index to civicrm_contribution creditnote_id field', 'addIndexContributionCreditNoteID');
163 public function upgrade_4_7_2($rev) {
164 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
165 $this->addTask('Fix Index on civicrm_financial_item combined entity_id + entity_table', 'addCombinedIndexFinancialItemEntityIDEntityType');
166 $this->addTask('enable financial account relationships for chargeback & refund', 'addRefundAndChargeBackAccountsIfNotExist');
167 $this->addTask('Add Index to civicrm_contribution.source', 'addIndexContributionSource');
175 public function upgrade_4_7_3($rev) {
176 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
177 $this->addTask('Add Index to civicrm_contribution.total_amount', 'addIndexContributionAmount');
185 public function upgrade_4_7_4($rev) {
186 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
187 $this->addTask('Add Contact Deleted by Merge Activity Type', 'addDeletedByMergeActivityType');
195 public function upgrade_4_7_7($rev) {
196 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
197 // https://issues.civicrm.org/jira/browse/CRM-18006
198 if (CRM_Core_DAO
::checkTableExists('civicrm_install_canary')) {
199 CRM_Core_DAO
::executeQuery('ALTER TABLE civicrm_install_canary ENGINE=InnoDB');
208 public function upgrade_4_7_8($rev) {
209 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
210 $this->addTask('Upgrade mailing foreign key constraints', 'upgradeMailingFKs');
211 $this->addTask('Add Smartgroup refresh options', 'addSmartGroupRefreshOptions');
215 * Important! All upgrade functions MUST call the 'runSql' task.
216 * Uncomment and use the following template for a new upgrade version
217 * (change the x in the function name):
221 // * Upgrade function.
223 // * @param string $rev
225 // public function upgrade_4_7_x($rev) {
226 // $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
227 // // Additional tasks here...
235 public static function updateWysiwyg() {
236 $editorID = Civi
::settings()->get('editor_id');
237 // Previously a numeric value indicated one of 4 wysiwyg editors shipped in core, and no value indicated 'Textarea'
238 // Now the options are "Textarea", "CKEditor", and the rest have been dropped from core.
239 $newEditor = $editorID ?
"CKEditor" : "Textarea";
240 Civi
::settings()->set('editor_id', $newEditor);
246 * Migrate any last remaining options from `civicrm_domain.config_backend` to `civicrm_setting`.
247 * Cleanup setting schema.
249 * @param CRM_Queue_TaskContext $ctx
252 public function migrateSettings(CRM_Queue_TaskContext
$ctx) {
253 // Tip: If there are problems with adding the new uniqueness index, try inspecting:
254 // SELECT name, domain_id, contact_id, count(*) AS dupes FROM civicrm_setting cs GROUP BY name, domain_id, contact_id HAVING dupes > 1;
256 // Nav records are expendable. https://forum.civicrm.org/index.php?topic=36933.0
257 CRM_Core_DAO
::executeQuery('DELETE FROM civicrm_setting WHERE contact_id IS NOT NULL AND name = "navigation"');
259 CRM_Core_DAO
::executeQuery('ALTER TABLE civicrm_setting DROP INDEX index_group_name');
260 CRM_Core_DAO
::executeQuery('ALTER TABLE civicrm_setting DROP COLUMN group_name');
261 CRM_Core_DAO
::executeQuery('ALTER TABLE civicrm_setting ADD UNIQUE INDEX index_domain_contact_name (domain_id, contact_id, name)');
263 $domainDao = CRM_Core_DAO
::executeQuery('SELECT id, config_backend FROM civicrm_domain');
264 while ($domainDao->fetch()) {
265 $settings = CRM_Upgrade_Incremental_php_FourSeven
::convertBackendToSettings($domainDao->id
, $domainDao->config_backend
);
266 CRM_Core_Error
::debug_var('convertBackendToSettings', array(
267 'domainId' => $domainDao->id
,
268 'backend' => $domainDao->config_backend
,
269 'settings' => $settings,
272 foreach ($settings as $name => $value) {
274 1 => array($domainDao->id
, 'Positive'),
275 2 => array($name, 'String'),
276 3 => array(serialize($value), 'String'),
278 $settingId = CRM_Core_DAO
::singleValueQuery(
279 'SELECT id FROM civicrm_setting WHERE domain_id = %1 AND name = %2',
282 CRM_Core_DAO
::executeQuery(
283 'INSERT INTO civicrm_setting (domain_id, name, value, is_domain) VALUES (%1,%2,%3,1)',
289 CRM_Core_DAO
::executeQuery('ALTER TABLE civicrm_domain DROP COLUMN config_backend');
295 * Take a config_backend blob and produce an equivalent list of settings.
297 * @param int $domainId
299 * @param string $config_backend
303 public static function convertBackendToSettings($domainId, $config_backend) {
304 if (!$config_backend) {
308 $backend = unserialize($config_backend);
313 $mappings = \CRM_Core_Config_MagicMerge
::getPropertyMap();
315 foreach ($backend as $propertyName => $propertyValue) {
316 if (isset($mappings[$propertyName][0]) && preg_match('/^setting/', $mappings[$propertyName][0])) {
317 // $mapping format: $propertyName => Array(0 => $type, 1 => $setting|NULL).
318 $settingName = isset($mappings[$propertyName][1]) ?
$mappings[$propertyName][1] : $propertyName;
319 $settings[$settingName] = $propertyValue;
327 * Add Getting Started dashlet to dashboard
329 * @param \CRM_Queue_TaskContext $ctx
333 public function addGettingStartedDashlet(CRM_Queue_TaskContext
$ctx) {
334 $sql = "SELECT count(*) FROM civicrm_dashboard WHERE name='getting-started'";
335 $res = CRM_Core_DAO
::singleValueQuery($sql);
336 $domainId = CRM_Core_Config
::domainID();
338 $sql = "INSERT INTO `civicrm_dashboard`
339 ( `domain_id`, `name`, `label`, `url`, `permission`, `permission_operator`, `column_no`, `is_minimized`, `is_active`, `weight`, `fullscreen_url`, `is_fullscreen`, `is_reserved`) VALUES ( {$domainId}, 'getting-started', 'Getting Started', 'civicrm/dashlet/getting-started?reset=1&snippet=5', 'access CiviCRM', NULL, 0, 0, 1, 0, 'civicrm/dashlet/getting-started?reset=1&snippet=5&context=dashletFullscreen', 1, 1)";
340 CRM_Core_DAO
::executeQuery($sql);
341 // Add default position for Getting Started Dashlet ( left column)
342 $sql = "INSERT INTO `civicrm_dashboard_contact` (dashboard_id, contact_id, column_no, is_active)
343 SELECT (SELECT MAX(id) FROM `civicrm_dashboard`), contact_id, 0, IF (SUM(is_active) > 0, 1, 0)
344 FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_contact.contact_id = civicrm_contact.id GROUP BY contact_id";
345 CRM_Core_DAO
::executeQuery($sql);
351 * Migrate on-behalf information to uf_join.module_data as on-behalf columns will be dropped
354 * @param CRM_Queue_TaskContext $ctx
359 public static function migrateOnBehalfOfInfo(CRM_Queue_TaskContext
$ctx) {
360 $domain = new CRM_Core_DAO_Domain();
363 // fetch onBehalf entry in UFJoin table
364 $ufGroupDAO = new CRM_Core_DAO_UFJoin();
365 $ufGroupDAO->module
= 'OnBehalf';
366 $ufGroupDAO->find(TRUE);
368 $forOrgColums = array();
369 if ($domain->locales
) {
370 $locales = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $domain->locales
);
371 foreach ($locales as $locale) {
372 $forOrgColums[] = "for_organization_{$locale}";
376 $forOrgColums[] = "for_organization";
380 SELECT " . implode(", ", $forOrgColums) . ", uj.id as join_id, uj.uf_group_id as uf_group_id
381 FROM civicrm_contribution_page cp
382 INNER JOIN civicrm_uf_join uj ON uj.entity_id = cp.id AND uj.module = 'OnBehalf'";
383 $dao = CRM_Core_DAO
::executeQuery($query, array(), TRUE, NULL, FALSE, FALSE);
386 while ($dao->fetch()) {
387 $onBehalfParams['on_behalf'] = array('is_for_organization' => $dao->is_for_organization
);
388 if ($domain->locales
) {
389 foreach ($locales as $locale) {
390 $for_organization = "for_organization_{$locale}";
391 $onBehalfParams['on_behalf'] +
= array(
393 'for_organization' => $dao->$for_organization,
399 $onBehalfParams['on_behalf'] +
= array(
401 'for_organization' => $dao->for_organization
,
405 $ufJoinParam = array(
406 'id' => $dao->join_id
,
407 'module' => 'on_behalf',
408 'uf_group_id' => $dao->uf_group_id
,
409 'module_data' => json_encode($onBehalfParams),
411 CRM_Core_BAO_UFJoin
::create($ufJoinParam);
419 * CRM-11782 - Get rid of VALUE_SEPARATOR character in saved search form values
421 * @param \CRM_Queue_TaskContext $ctx
425 public function fixContactTypeInSmartGroups(CRM_Queue_TaskContext
$ctx) {
426 $sep = CRM_Core_DAO
::VALUE_SEPARATOR
;
427 $dao = CRM_Core_DAO
::executeQuery("SELECT id, form_values FROM civicrm_saved_search WHERE form_values LIKE '%$sep%'");
428 while ($dao->fetch()) {
429 $formValues = unserialize($dao->form_values
);
430 if (isset($formValues['contact_type']) && is_array($formValues['contact_type'])) {
432 foreach ($formValues['contact_type'] as $key => $val) {
433 $newVals[str_replace($sep, '__', $key)] = is_string($val) ?
str_replace($sep, '__', $val) : $val;
435 $formValues['contact_type'] = $newVals;
437 CRM_Core_DAO
::executeQuery("UPDATE civicrm_saved_search SET form_values = %1 WHERE id = {$dao->id}", array(1 => array(serialize($formValues), 'String')));
444 * CRM-17637 - Ths file location has been moved; delete the old one
446 * @param \CRM_Queue_TaskContext $ctx
450 public function deleteVersionCheckCacheFile(CRM_Queue_TaskContext
$ctx) {
451 $config = CRM_Core_Config
::singleton();
452 $cacheFile = $config->uploadDir
. 'version-info-cache.json';
453 if (file_exists($cacheFile)) {
460 * CRM-17669 and CRM-17686, make scheduled jobs more flexible, disable the 4.6 extension if installed
462 * @param \CRM_Queue_TaskContext $ctx
466 public function disableFlexibleJobsExtension(CRM_Queue_TaskContext
$ctx) {
468 civicrm_api3('Extension', 'disable', array('key' => 'com.klangsoft.flexiblejobs'));
470 catch (CiviCRM_API3_Exception
$e) {
471 // just ignore if the extension isn't installed
478 * CRM-17752 add index to civicrm_financial_trxn.trxn_id (deliberately non-unique).
480 * @param \CRM_Queue_TaskContext $ctx
484 public function addIndexFinancialTrxnTrxnID(CRM_Queue_TaskContext
$ctx) {
485 $tables = array('civicrm_financial_trxn' => array('trxn_id'));
486 CRM_Core_BAO_SchemaHandler
::createIndexes($tables);
491 * CRM-17882 Add index to civicrm_contribution.credit_note_id.
493 * @param \CRM_Queue_TaskContext $ctx
497 public function addIndexContributionCreditNoteID(CRM_Queue_TaskContext
$ctx) {
498 $tables = array('civicrm_contribution' => array('creditnote_id'));
499 CRM_Core_BAO_SchemaHandler
::createIndexes($tables);
504 * CRM-17775 Add correct index for table civicrm_financial_item.
506 * Note that the entity ID should always precede the entity_table as
507 * it is more unique. This is better for performance and does not cause fallback
508 * to no index if table it omitted.
512 public function addCombinedIndexFinancialItemEntityIDEntityType() {
513 CRM_Core_BAO_SchemaHandler
::dropIndexIfExists('civicrm_financial_item', 'UI_id');
514 CRM_Core_BAO_SchemaHandler
::dropIndexIfExists('civicrm_financial_item', 'IX_Entity');
515 CRM_Core_BAO_SchemaHandler
::createIndexes(array(
516 'civicrm_financial_item' => array(array('entity_id', 'entity_table')),
522 * CRM-17951 Add accounts option values for refund and chargeback.
524 * Add Chargeback contribution status and Chargeback and Contra account relationships,
525 * checking first if one exists.
527 public function addRefundAndChargeBackAccountsIfNotExist() {
528 // First we enable and edit the record for Credit contra - this exists but is disabled for most sites.
529 // Using the ensure function (below) will not enabled a disabled option (by design).
530 CRM_Core_DAO
::executeQuery("UPDATE civicrm_option_value v
531 INNER JOIN civicrm_option_group g on v.option_group_id=g.id and g.name='account_relationship'
532 SET v.is_active=1, v.label='Credit/Contra Revenue Account is', v.name='Credit/Contra Revenue Account is', v.description='Credit/Contra Revenue Account is'
533 WHERE v.name = 'Credit/Contra Account is';");
535 CRM_Core_BAO_OptionValue
::ensureOptionValueExists(array(
536 'option_group_id' => 'account_relationship',
537 'name' => 'Chargeback Account is',
538 'label' => ts('Chargeback Account is'),
540 'component_id' => 'CiviContribute',
543 CRM_Core_BAO_OptionValue
::ensureOptionValueExists(array(
544 'option_group_id' => 'contribution_status',
545 'name' => 'Chargeback',
546 'label' => ts('Chargeback'),
548 'component_id' => 'CiviContribute',
554 * CRM-17999 Add index to civicrm_contribution.source.
556 * @param \CRM_Queue_TaskContext $ctx
560 public function addIndexContributionSource(CRM_Queue_TaskContext
$ctx) {
561 CRM_Core_BAO_SchemaHandler
::createIndexes(array('civicrm_contribution' => array('source')));
566 * CRM-18124 Add index to civicrm_contribution.total_amount.
568 * Note that I made this a combined index with receive_date because the issue included
569 * both criteria and they seemed likely to be used in conjunction to me in other cases.
571 * @param \CRM_Queue_TaskContext $ctx
575 public function addIndexContributionAmount(CRM_Queue_TaskContext
$ctx) {
576 CRM_Core_BAO_SchemaHandler
::createIndexes(array(
577 'civicrm_contribution' => array(array('total_amount', 'receive_date')),
583 * CRM-18124 Add index to civicrm_contribution.total_amount.
585 * Note that I made this a combined index with receive_date because the issue included
586 * both criteria and they seemed likely to be used in conjunction to me in other cases.
588 * @param \CRM_Queue_TaskContext $ctx
592 public function addDeletedByMergeActivityType(CRM_Queue_TaskContext
$ctx) {
593 CRM_Core_BAO_OptionValue
::ensureOptionValueExists(array(
594 'option_group_id' => 'activity_type',
595 'name' => 'Contact Deleted by Merge',
596 'label' => ts('Contact Deleted by Merge'),
597 'description' => ts('Contact was merged into another contact'),
605 * Remove a foreign key from a table if it exists
608 * @param $constraint_name
610 public function safeRemoveFK($table_name, $constraint_name) {
612 $config = CRM_Core_Config
::singleton();
613 $dbUf = DB
::parseDSN($config->dsn
);
615 SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
616 WHERE TABLE_SCHEMA = %1
618 AND CONSTRAINT_NAME = %3
619 AND CONSTRAINT_TYPE = 'FOREIGN KEY'
622 1 => array($dbUf['database'], 'String'),
623 2 => array($table_name, 'String'),
624 3 => array($constraint_name, 'String'),
626 $dao = CRM_Core_DAO
::executeQuery($query, $params);
629 CRM_Core_DAO
::executeQuery("ALTER TABLE {$table_name} DROP FOREIGN KEY {$constraint_name}", array());
635 * CRM-18345 Don't delete mailing data on email/phone deletion
636 * Implemented here in CRM-18526
638 * @param \CRM_Queue_TaskContext $ctx
642 public function upgradeMailingFKs(CRM_Queue_TaskContext
$ctx) {
644 // Safely drop the foreign keys
645 self
::safeRemoveFK('civicrm_mailing_event_queue', 'FK_civicrm_mailing_event_queue_email_id');
646 self
::safeRemoveFK('civicrm_mailing_event_queue', 'FK_civicrm_mailing_event_queue_phone_id');
647 self
::safeRemoveFK('civicrm_mailing_recipients', 'FK_civicrm_mailing_recipients_email_id');
648 self
::safeRemoveFK('civicrm_mailing_recipients', 'FK_civicrm_mailing_recipients_phone_id');
650 // Set up the new foreign keys
651 CRM_Core_DAO
::executeQuery("SET FOREIGN_KEY_CHECKS = 0;");
653 CRM_Core_DAO
::executeQuery("
654 ALTER TABLE `civicrm_mailing_event_queue`
655 ADD CONSTRAINT `FK_civicrm_mailing_event_queue_email_id`
656 FOREIGN KEY (`email_id`)
657 REFERENCES `civicrm_email`(`id`)
662 CRM_Core_DAO
::executeQuery("
663 ALTER TABLE `civicrm_mailing_event_queue`
664 ADD CONSTRAINT `FK_civicrm_mailing_event_queue_phone_id`
665 FOREIGN KEY (`phone_id`)
666 REFERENCES `civicrm_phone`(`id`)
671 CRM_Core_DAO
::executeQuery("
672 ALTER TABLE `civicrm_mailing_recipients`
673 ADD CONSTRAINT `FK_civicrm_mailing_recipients_email_id`
674 FOREIGN KEY (`email_id`)
675 REFERENCES `civicrm_email`(`id`)
680 CRM_Core_DAO
::executeQuery("
681 ALTER TABLE `civicrm_mailing_recipients`
682 ADD CONSTRAINT `FK_civicrm_mailing_recipients_phone_id`
683 FOREIGN KEY (`phone_id`)
684 REFERENCES `civicrm_phone`(`id`)
689 CRM_Core_DAO
::executeQuery("SET FOREIGN_KEY_CHECKS = 1;");
695 * CRM-16642 Add option for smart group refreshing.
697 * @param \CRM_Queue_TaskContext $ctx
701 public function addSmartGroupRefreshOptions(CRM_Queue_TaskContext
$ctx) {
702 $optionGroupID = CRM_Core_BAO_OptionGroup
::ensureOptionGroupExists(array(
703 'name' => 'smart_group_cache_refresh_mode',
704 'title' => ts('Mode for refreshing smart group cache'),
705 'description' => ts('This provides the option for the smart group cache setting'),
708 CRM_Core_BAO_OptionValue
::ensureOptionValueExists(array(
709 'option_group_id' => $optionGroupID,
710 'name' => 'opportunistic',
711 'label' => ts('Opportunistic'),
712 'description' => ts('Purge the cache in response to user actions'),
717 CRM_Core_BAO_OptionValue
::ensureOptionValueExists(array(
718 'option_group_id' => $optionGroupID,
719 'name' => 'deterministic',
720 'label' => ts('Deterministic'),
721 'description' => ts('Only purge the cache on system jobs'),