Commit | Line | Data |
---|---|---|
a57aaa08 C |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 5 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2017 | | |
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 FiveFour */ | |
29 | class CRM_Upgrade_Incremental_php_FiveFour 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') { | |
e1a49d48 | 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>'; |
a57aaa08 C |
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) { | |
8e8d4058 | 58 | if ($rev == '5.4.alpha1') { |
499a4fb3 | 59 | $postUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. It is not granted by default. If your users create reports, you may wish to review their permissions.', array(1 => ts('save Report Criteria'))) . '</p>'; |
8e8d4058 | 60 | } |
a57aaa08 C |
61 | // Example: Generate a post-upgrade message. |
62 | // if ($rev == '5.12.34') { | |
63 | // $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'."); | |
64 | // } | |
65 | } | |
66 | ||
6bb585d0 JP |
67 | /** |
68 | * Upgrade function. | |
69 | * | |
70 | * @param string $rev | |
71 | */ | |
72 | public function upgrade_5_4_alpha1($rev) { | |
73 | $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); | |
74 | $this->addTask('Add Cancel Button Setting to the Profile', 'addColumn', | |
75 | 'civicrm_uf_group', 'add_cancel_button', "tinyint DEFAULT '1' COMMENT 'Should a Cancel button be included in this Profile form.'"); | |
b3a1fc3d | 76 | $this->addTask('Add location_id if missing to group_contact table (affects some older installs CRM-20711)', 'addColumn', |
77 | 'civicrm_group_contact', 'location_id', "int(10) unsigned DEFAULT NULL COMMENT 'Optional location to associate with this membership'"); | |
ad8d1ce3 RO |
78 | $this->addTask('dev/core#107 - Add Activity\'s default assignee options', 'addActivityDefaultAssigneeOptions'); |
79 | } | |
80 | ||
81 | /** | |
82 | * This task adds the default assignee option values that can be selected when | |
83 | * creating or editing a new workflow's activity. | |
84 | * | |
85 | * @return bool | |
86 | */ | |
87 | public static function addActivityDefaultAssigneeOptions() { | |
88 | // Add option group for activity default assignees: | |
89 | CRM_Core_BAO_OptionGroup::ensureOptionGroupExists(array( | |
90 | 'name' => 'activity_default_assignee', | |
91 | 'title' => ts('Activity default assignee'), | |
92 | 'is_reserved' => 1, | |
93 | )); | |
94 | ||
95 | // Add option values for activity default assignees: | |
96 | $options = array( | |
97 | array('name' => 'NONE', 'label' => ts('None'), 'is_default' => 1), | |
98 | array('name' => 'BY_RELATIONSHIP', 'label' => ts('By relationship to case client')), | |
99 | array('name' => 'SPECIFIC_CONTACT', 'label' => ts('Specific contact')), | |
100 | array('name' => 'USER_CREATING_THE_CASE', 'label' => ts('User creating the case')), | |
101 | ); | |
102 | ||
103 | foreach ($options as $option) { | |
104 | CRM_Core_BAO_OptionValue::ensureOptionValueExists(array( | |
105 | 'option_group_id' => 'activity_default_assignee', | |
106 | 'name' => $option['name'], | |
107 | 'label' => $option['label'], | |
108 | 'is_default' => CRM_Utils_Array::value('is_default', $option, 0), | |
109 | 'is_active' => TRUE, | |
110 | )); | |
111 | } | |
112 | ||
113 | return TRUE; | |
6bb585d0 JP |
114 | } |
115 | ||
a57aaa08 C |
116 | /* |
117 | * Important! All upgrade functions MUST add a 'runSql' task. | |
118 | * Uncomment and use the following template for a new upgrade version | |
119 | * (change the x in the function name): | |
120 | */ | |
121 | ||
122 | // /** | |
123 | // * Upgrade function. | |
124 | // * | |
125 | // * @param string $rev | |
126 | // */ | |
127 | // public function upgrade_5_0_x($rev) { | |
128 | // $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); | |
129 | // $this->addTask('Do the foo change', 'taskFoo', ...); | |
130 | // // Additional tasks here... | |
131 | // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. | |
132 | // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. | |
133 | // } | |
134 | ||
135 | // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { | |
136 | // return TRUE; | |
137 | // } | |
138 | ||
139 | } |