Commit | Line | Data |
---|---|---|
f9a4aff1 C |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
6 | | This work is published under the GNU AGPLv3 license with some | | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
9 | +--------------------------------------------------------------------+ | |
10 | */ | |
11 | ||
12 | /** | |
13 | * Upgrade logic for FiveTwentyFour */ | |
14 | class CRM_Upgrade_Incremental_php_FiveTwentyFour extends CRM_Upgrade_Incremental_Base { | |
15 | ||
16 | /** | |
17 | * Compute any messages which should be displayed beforeupgrade. | |
18 | * | |
19 | * Note: This function is called iteratively for each upcoming | |
20 | * revision to the database. | |
21 | * | |
22 | * @param string $preUpgradeMessage | |
23 | * @param string $rev | |
24 | * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'. | |
25 | * @param null $currentVer | |
26 | */ | |
27 | public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) { | |
28 | // Example: Generate a pre-upgrade message. | |
29 | // if ($rev == '5.12.34') { | |
30 | // $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>'; | |
31 | // } | |
32 | } | |
33 | ||
34 | /** | |
35 | * Compute any messages which should be displayed after upgrade. | |
36 | * | |
37 | * @param string $postUpgradeMessage | |
38 | * alterable. | |
39 | * @param string $rev | |
40 | * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs. | |
41 | */ | |
42 | public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { | |
43 | // Example: Generate a post-upgrade message. | |
44 | // if ($rev == '5.12.34') { | |
45 | // $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'."); | |
46 | // } | |
47 | } | |
48 | ||
38c87aa2 | 49 | /** |
50 | * Upgrade function. | |
51 | * | |
52 | * @param string $rev | |
53 | */ | |
54 | public function upgrade_5_24_alpha1($rev) { | |
55 | $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); | |
56 | $this->addTask('Install sequential creditnote extension', 'installCreditNotes'); | |
a84e7185 | 57 | $this->addTask('Drop obsolete columns from saved_search table', 'dropSavedSearchColumns'); |
0d7216d3 CW |
58 | $this->addTask('Smart groups: Add api_entity column to civicrm_saved_search', 'addColumn', |
59 | 'civicrm_saved_search', 'api_entity', "varchar(255) DEFAULT NULL COMMENT 'Entity name for API based search'" | |
60 | ); | |
61 | $this->addTask('Smart groups: Add api_params column to civicrm_saved_search', 'addColumn', | |
62 | 'civicrm_saved_search', 'api_params', "text DEFAULT NULL COMMENT 'Parameters for API based search'" | |
63 | ); | |
38c87aa2 | 64 | } |
65 | ||
66 | /** | |
67 | * Install sequentialCreditNotes extension. | |
68 | * | |
69 | * This feature is restructured as a core extension - which is primarily a code cleanup step. | |
70 | * | |
71 | * @param \CRM_Queue_TaskContext $ctx | |
72 | * | |
73 | * @return bool | |
74 | * | |
75 | * @throws \CiviCRM_API3_Exception | |
76 | */ | |
77 | public static function installCreditNotes(CRM_Queue_TaskContext $ctx) { | |
8d61bab3 TO |
78 | // Install via direct SQL manipulation. Note that: |
79 | // (1) This extension has no activation logic. | |
80 | // (2) On new installs, the extension is activated purely via default SQL INSERT. | |
81 | // (3) Caches are flushed at the end of the upgrade. | |
82 | // ($) Over long term, upgrade steps are more reliable in SQL. API/BAO sometimes don't work mid-upgrade. | |
83 | $insert = CRM_Utils_SQL_Insert::into('civicrm_extension')->row([ | |
84 | 'type' => 'module', | |
85 | 'full_name' => 'sequentialcreditnotes', | |
86 | 'name' => 'Sequential credit notes', | |
87 | 'label' => 'Sequential credit notes', | |
88 | 'file' => 'sequentialcreditnotes', | |
89 | 'schema_version' => NULL, | |
90 | 'is_active' => 1, | |
91 | ]); | |
92 | CRM_Core_DAO::executeQuery($insert->usingReplace()->toSQL()); | |
38c87aa2 | 93 | return TRUE; |
94 | } | |
f9a4aff1 | 95 | |
f90f330b | 96 | /** |
97 | * Delete unused columns from civicrm_saved_search. | |
98 | * | |
99 | * Follow up on https://github.com/civicrm/civicrm-core/pull/14891 | |
100 | * | |
101 | * @param \CRM_Queue_TaskContext $ctx | |
102 | * | |
103 | * @return bool | |
104 | */ | |
105 | public static function dropSavedSearchColumns(CRM_Queue_TaskContext $ctx) { | |
106 | self::dropColumn($ctx, 'civicrm_saved_search', 'select_tables'); | |
107 | self::dropColumn($ctx, 'civicrm_saved_search', 'where_tables'); | |
108 | self::dropColumn($ctx, 'civicrm_saved_search', 'where_clause'); | |
109 | return TRUE; | |
110 | } | |
f9a4aff1 C |
111 | |
112 | } |