Merge pull request #15322 from alifrumin/removePrintIcon
[civicrm-core.git] / CRM / Upgrade / Incremental / php / FiveNineteen.php
CommitLineData
b97c7f3e
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 FiveNineteen */
29class CRM_Upgrade_Incremental_php_FiveNineteen 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
13e9117a
CW
64 /**
65 * Upgrade function.
66 *
67 * @param string $rev
b97c7f3e 68 */
13e9117a
CW
69 public function upgrade_5_19_alpha1($rev) {
70 $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
71 $this->addTask('Add api4 menu', 'api4Menu');
ef91b100 72 $this->addTask('Add is_active field to civicrm_status_pref', 'addColumn', 'civicrm_status_pref', 'is_active',
bb766d8e 73 "tinyint(4) DEFAULT '1' COMMENT 'Is this status check active'", FALSE, '5.19.0');
13e9117a 74 }
b97c7f3e 75
13e9117a
CW
76 /**
77 * Add menu item for api4 explorer; rename v3 explorer menu item.
78 *
79 * @param \CRM_Queue_TaskContext $ctx
80 * @return bool
81 */
82 public static function api4Menu(CRM_Queue_TaskContext $ctx) {
83 try {
84 $v3Item = civicrm_api3('Navigation', 'get', [
85 'name' => 'API Explorer',
86 'return' => ['id', 'parent_id', 'weight'],
87 'sequential' => 1,
88 'domain_id' => CRM_Core_Config::domainID(),
89 'api.Navigation.create' => ['label' => ts("Api Explorer v3")],
90 ]);
91 $existing = civicrm_api3('Navigation', 'getcount', [
92 'name' => "Api Explorer v4",
93 'domain_id' => CRM_Core_Config::domainID(),
94 ]);
95 if (!$existing) {
96 civicrm_api3('Navigation', 'create', [
97 'parent_id' => $v3Item['values'][0]['parent_id'] ?? 'Developer',
98 'label' => ts("Api Explorer v4"),
99 'weight' => $v3Item['values'][0]['weight'] ?? 2,
100 'name' => "Api Explorer v4",
101 'permission' => "administer CiviCRM",
102 'url' => "civicrm/api4#/explorer",
103 'is_active' => 1,
104 ]);
105 }
106 }
107 catch (Exception $e) {
108 // Couldn't create menu item.
109 }
110 return TRUE;
111 }
b97c7f3e
C
112
113}