Merge pull request #18836 from civicrm/5.31
[civicrm-core.git] / CRM / Upgrade / Incremental / php / FiveThirtyTwo.php
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 FiveThirtyTwo
14 */
15 class CRM_Upgrade_Incremental_php_FiveThirtyTwo extends CRM_Upgrade_Incremental_Base {
16
17 /**
18 * Compute any messages which should be displayed beforeupgrade.
19 *
20 * Note: This function is called iteratively for each upcoming
21 * revision to the database.
22 *
23 * @param string $preUpgradeMessage
24 * @param string $rev
25 * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
26 * @param null $currentVer
27 */
28 public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
29 // Example: Generate a pre-upgrade message.
30 // if ($rev == '5.12.34') {
31 // $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>';
32 // }
33 }
34
35 /**
36 * Compute any messages which should be displayed after upgrade.
37 *
38 * @param string $postUpgradeMessage
39 * alterable.
40 * @param string $rev
41 * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
42 */
43 public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
44 // Example: Generate a post-upgrade message.
45 // if ($rev == '5.12.34') {
46 // $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'.");
47 // }
48 }
49
50 /**
51 * Install contributioncancelactions extension.
52 *
53 * This feature is restructured as a core extension - which is primarily a code cleanup step but
54 * also permits sites / extensions to disable the core actions to do their own workflows.
55 *
56 * @param \CRM_Queue_TaskContext $ctx
57 *
58 * @return bool
59 *
60 * @throws \CRM_Core_Exception
61 */
62 public static function installContributionCancelActions(CRM_Queue_TaskContext $ctx) {
63 // Install via direct SQL manipulation. Note that:
64 // (1) This extension has no activation logic.
65 // (2) On new installs, the extension is activated purely via default SQL INSERT.
66 // (3) Caches are flushed at the end of the upgrade.
67 // ($) Over long term, upgrade steps are more reliable in SQL. API/BAO sometimes don't work mid-upgrade.
68 $insert = CRM_Utils_SQL_Insert::into('civicrm_extension')->row([
69 'type' => 'module',
70 'full_name' => 'contributioncancelactions',
71 'name' => 'contributioncancelactions',
72 'label' => 'Contribution cancel actions',
73 'file' => 'contributioncancelactions',
74 'schema_version' => NULL,
75 'is_active' => 1,
76 ]);
77 CRM_Core_DAO::executeQuery($insert->usingReplace()->toSQL());
78
79 return TRUE;
80 }
81
82 /**
83 * Upgrade function.
84 *
85 * @param string $rev
86 */
87 public function upgrade_5_32_alpha1($rev) {
88 $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
89 $this->addTask('Add column civicrm_saved_search.name', 'addColumn', 'civicrm_saved_search', 'name', "varchar(255) DEFAULT NULL COMMENT 'Unique name of saved search'");
90 $this->addTask('Add column civicrm_saved_search.label', 'addColumn', 'civicrm_saved_search', 'label', "varchar(255) DEFAULT NULL COMMENT 'Administrative label for search'");
91 $this->addTask('Add index civicrm_saved_search.UI_name', 'addIndex', 'civicrm_saved_search', 'name', 'UI');
92 $this->addTask('Install contribution cancel actions extension', 'installContributionCancelActions');
93 }
94
95 }