[Date picker][REF] Convert jcalendar date fields to date picker on member search...
[civicrm-core.git] / CRM / Upgrade / Incremental / php / FiveEighteen.php
CommitLineData
f07c1d77
C
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
25 */
26
27/**
28 * Upgrade logic for FiveEighteen */
29class CRM_Upgrade_Incremental_php_FiveEighteen extends CRM_Upgrade_Incremental_Base {
30
31 /**
32 * Compute any messages which should be displayed beforeupgrade.
33 *
34 * Note: This function is called iteratively for each upcoming
35 * revision to the database.
36 *
37 * @param string $preUpgradeMessage
38 * @param string $rev
39 * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
40 * @param null $currentVer
41 */
42 public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
43 // Example: Generate a pre-upgrade message.
44 // if ($rev == '5.12.34') {
45 // $preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '</p>';
46 // }
47 }
48
49 /**
50 * Compute any messages which should be displayed after upgrade.
51 *
52 * @param string $postUpgradeMessage
53 * alterable.
54 * @param string $rev
55 * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
56 */
57 public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
58 // Example: Generate a post-upgrade message.
59 // if ($rev == '5.12.34') {
60 // $postUpgradeMessage .= '<br /><br />' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'.");
61 // }
62 }
63
64 /*
65 * Important! All upgrade functions MUST add a 'runSql' task.
66 * Uncomment and use the following template for a new upgrade version
67 * (change the x in the function name):
68 */
69
8f67d99a 70 /**
71 * Upgrade function.
72 *
73 * @param string $rev
74 */
75 public function upgrade_5_18_alpha1($rev) {
76 $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
77 $this->addTask('Update smart groups to reflect change of unique name for is_override', 'updateSmartGroups', [
78 'renameField' => [
79 ['old' => 'is_override', 'new' => 'member_is_override'],
80 ],
81 ]);
1494e986
SL
82 $this->addTask('Remove Foreign Key from civicrm_dashboard on domain_id if exists', 'removeDomainIDFK');
83 $this->addTask('Remove Index on domain_id that might have been randomly added in the same format as FK', 'dropIndex', 'civicrm_dashboard', 'FK_civicrm_dashboard_domain_id');
84 $this->addTask('Re-Create Foreign key between civicrm_dashboard and civicrm_domain correctly', 'recreateDashboardFK');
1519c828
SL
85 $this->addTask('Update smart groups to rename filters on pledge_payment_date to pledge_payment_scheduled_date', 'updateSmartGroups', [
86 'renameField' => [
5f97e97f
SL
87 ['old' => 'pledge_payment_date_relative', 'new' => 'pledge_payment_scheduled_date_relative'],
88 ['old' => 'pledge_payment_date_high', 'new' => 'pledge_payment_scheduled_date_high'],
89 ['old' => 'pledge_payment_date_low', 'new' => 'pledge_payment_scheduled_date_low'],
90 ['old' => 'member_join_date_relative', 'new' => 'membership_join_date_relative'],
91 ['old' => 'member_join_date_high', 'new' => 'membership_join_date_high'],
92 ['old' => 'member_join_date_low', 'new' => 'membership_join_date_low'],
93 ['old' => 'member_start_date_relative', 'new' => 'membership_start_date_relative'],
94 ['old' => 'member_start_date_high', 'new' => 'membership_start_date_high'],
95 ['old' => 'member_start_date_low', 'new' => 'membership_start_date_low'],
96 ['old' => 'member_end_date_relative', 'new' => 'membership_end_date_relative'],
97 ['old' => 'member_end_date_high', 'new' => 'membership_end_date_high'],
98 ['old' => 'member_end_date_low', 'new' => 'membership_end_date_low'],
1519c828
SL
99 ],
100 ]);
101 $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [
102 'datepickerConversion' => [
103 'pledge_payment_scheduled_date',
104 'pledge_create_date',
105 'pledge_end_date',
106 'pledge_start_date',
5f97e97f
SL
107 'membership_join_date',
108 'membership_end_date',
109 'membership_start_date',
1519c828
SL
110 ],
111 ]);
09ba1975 112 $this->addTask('Update civicrm_mapping_field and civicrm_uf_field for change in join_date name', 'updateJoinDateMappingUF');
1494e986
SL
113 }
114
115 public static function removeDomainIDFK() {
116 CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_dashboard', 'FK_civicrm_dashboard_domain_id');
117 return TRUE;
118 }
119
120 public static function recreateDashboardFK() {
121 $sql = CRM_Core_BAO_SchemaHandler::buildForeignKeySQL([
122 'fk_table_name' => 'civicrm_domain',
123 'fk_field_name' => 'id',
124 'name' => 'domain_id',
125 'fk_attributes' => ' ON DELETE CASCADE',
126 ], "\n", " ADD ", 'civicrm_dashboard');
127 CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_dashboard " . $sql, [], TRUE, NULL, FALSE, FALSE);
128 return TRUE;
8f67d99a 129 }
f07c1d77 130
09ba1975
SL
131 public static function updateJoinDateMappingUF() {
132 CRM_Core_DAO::executeQuery("UPDATE civicrm_mapping_field SET name = 'membership_join_date' WHERE name = 'join_date' AND contact_type = 'Membership'");
133 CRM_Core_DAO::executeQuery("UPDATE civicrm_uf_field SET field_name = 'membership_join_date' WHERE field_name = 'join_date' AND field_type = 'Membership'");
134 return TRUE;
135 }
136
f07c1d77
C
137 // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
138 // return TRUE;
139 // }
140
141}