Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 and the CiviCRM Licensing Exception. | | |
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 and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class is a container for legacy upgrade logic which predates | |
38 | * the current 'CRM/Incremental/php/*' structure. | |
39 | */ | |
40 | class CRM_Upgrade_Incremental_Legacy { | |
41 | ||
42 | /** | |
fe482240 | 43 | * Compute any messages which should be displayed before upgrade. |
6a488035 | 44 | * |
5a4f6742 CW |
45 | * @param string $preUpgradeMessage |
46 | * alterable. | |
77b97be7 EM |
47 | * @param $currentVer |
48 | * @param $latestVer | |
6a488035 | 49 | */ |
00be9182 | 50 | public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) { |
6a488035 TO |
51 | $upgrade = new CRM_Upgrade_Form(); |
52 | $template = CRM_Core_Smarty::singleton(); | |
53 | ||
54 | if ((version_compare($currentVer, '3.3.alpha1') < 0 && | |
55 | version_compare($latestVer, '3.3.alpha1') >= 0 | |
56 | ) || | |
57 | (version_compare($currentVer, '3.4.alpha1') < 0 && | |
58 | version_compare($latestVer, '3.4.alpha1') >= 0 | |
59 | ) | |
60 | ) { | |
61 | $query = " | |
10824d34 | 62 | SELECT id |
63 | FROM civicrm_mailing_job | |
6a488035 TO |
64 | WHERE status NOT IN ( 'Complete', 'Canceled' ) AND is_test = 0 LIMIT 1"; |
65 | $mjId = CRM_Core_DAO::singleValueQuery($query); | |
66 | if ($mjId) { | |
67 | $preUpgradeMessage = ts("There are one or more Scheduled or In Progress mailings in your install. Scheduled mailings will not be sent and In Progress mailings will not finish if you continue with the upgrade. We strongly recommend that all Scheduled and In Progress mailings be completed or cancelled and then upgrade your CiviCRM install."); | |
68 | } | |
69 | } | |
70 | ||
71 | //turning some tables to monolingual during 3.4.beta3, CRM-7869 | |
72 | $upgradeTo = str_replace('4.0.', '3.4.', $latestVer); | |
73 | $upgradeFrom = str_replace('4.0.', '3.4.', $currentVer); | |
74 | ||
75 | // check for changed message templates | |
76 | self::checkMessageTemplate($template, $preUpgradeMessage, $upgradeTo, $upgradeFrom); | |
77 | ||
78 | $upgrade = new CRM_Upgrade_Form(); | |
79 | if ($upgrade->multilingual && | |
80 | version_compare($upgradeFrom, '3.4.beta3') == -1 && | |
81 | version_compare($upgradeTo, '3.4.beta3') >= 0 | |
82 | ) { | |
83 | $config = CRM_Core_Config::singleton(); | |
353ffa53 TO |
84 | $preUpgradeMessage .= '<br />' . ts("As per <a href='%1'>the related blog post</a>, we are making contact names, addresses and mailings monolingual; the values entered for the default locale (%2) will be preserved and values for other locales removed.", array( |
85 | 1 => 'http://civicrm.org/blogs/shot/multilingual-civicrm-3440-making-some-fields-monolingual', | |
408b79bf | 86 | 2 => $config->lcMessages, |
353ffa53 | 87 | )); |
6a488035 TO |
88 | } |
89 | ||
90 | if (version_compare($currentVer, '3.4.6') == -1 && | |
91 | version_compare($latestVer, '3.4.6') >= 0 | |
92 | ) { | |
93 | $googleProcessorExists = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_payment_processor WHERE payment_processor_type = 'Google_Checkout' AND is_active = 1 LIMIT 1;"); | |
94 | ||
95 | if ($googleProcessorExists) { | |
96 | $preUpgradeMessage .= '<br />' . ts('To continue using Google Checkout Payment Processor with latest version of CiviCRM, requires updating merchant account settings. Please refer "Set API callback URL and other settings" section of <a href="%1" target="_blank"><strong>Google Checkout Configuration</strong></a> doc.', array(1 => 'http://wiki.civicrm.org/confluence/x/zAJTAg')); | |
97 | } | |
98 | } | |
fde21984 | 99 | |
7abafcbc TO |
100 | // http://issues.civicrm.org/jira/browse/CRM-13572 |
101 | // Depending on how the code was upgraded, some sites may still have copies of old | |
102 | // source files left behind. This is often a forgivable offense, but it's quite | |
103 | // dangerous for CIVI-SA-2013-001. | |
fde21984 TO |
104 | global $civicrm_root; |
105 | $ofcFile = "$civicrm_root/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php"; | |
106 | if (file_exists($ofcFile)) { | |
7abafcbc TO |
107 | if (@unlink($ofcFile)) { |
108 | $preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', array( | |
353ffa53 TO |
109 | 1 => $ofcFile, |
110 | )); | |
0db6c3e1 TO |
111 | } |
112 | else { | |
7abafcbc | 113 | $preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', array( |
353ffa53 TO |
114 | 1 => $ofcFile, |
115 | )); | |
7abafcbc | 116 | } |
fde21984 | 117 | } |
f3103b87 | 118 | |
56c2750b | 119 | if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'enable_innodb_fts', NULL, FALSE)) { |
f3103b87 TO |
120 | // The FTS indexing feature dynamically manipulates the schema which could |
121 | // cause conflicts with other layers that manipulate the schema. The | |
122 | // simplest thing is to turn it off and back on. | |
123 | ||
124 | // It may not always be necessary to do this -- but I doubt we're going to test | |
125 | // systematically in future releases. When it is necessary, one could probably | |
126 | // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences | |
127 | // after the upgrade. But that's speculative. For now, we'll leave this | |
128 | // advanced feature in the hands of the sysadmin. | |
129 | $preUpgradeMessage .= '<br />' . ts('This database uses InnoDB Full Text Search for optimized searching. The upgrade procedure has not been tested with this feature. You should disable (and later re-enable) the feature by navigating to "Administer => System Settings => Miscellaneous".'); | |
130 | } | |
6a488035 TO |
131 | } |
132 | ||
624e56fa EM |
133 | /** |
134 | * @param $template | |
135 | * @param $message | |
136 | * @param $latestVer | |
137 | * @param $currentVer | |
138 | */ | |
00be9182 | 139 | public static function checkMessageTemplate(&$template, &$message, $latestVer, $currentVer) { |
6a488035 TO |
140 | if (version_compare($currentVer, '3.1.alpha1') < 0) { |
141 | return; | |
142 | } | |
143 | ||
144 | $sql = "SELECT orig.workflow_id as workflow_id, | |
145 | orig.msg_title as title | |
146 | FROM civicrm_msg_template diverted JOIN civicrm_msg_template orig ON ( | |
147 | diverted.workflow_id = orig.workflow_id AND | |
148 | orig.is_reserved = 1 AND ( | |
149 | diverted.msg_subject != orig.msg_subject OR | |
150 | diverted.msg_text != orig.msg_text OR | |
151 | diverted.msg_html != orig.msg_html | |
152 | ) | |
153 | )"; | |
154 | ||
155 | $dao = &CRM_Core_DAO::executeQuery($sql); | |
156 | while ($dao->fetch()) { | |
157 | $workflows[$dao->workflow_id] = $dao->title; | |
158 | } | |
159 | ||
160 | if (empty($workflows)) { | |
161 | return; | |
162 | } | |
163 | ||
353ffa53 | 164 | $html = NULL; |
6a488035 | 165 | $pathName = dirname(dirname(__FILE__)); |
353ffa53 | 166 | $flag = FALSE; |
6a488035 TO |
167 | foreach ($workflows as $workflow => $title) { |
168 | $name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', | |
169 | $workflow, | |
170 | 'name', | |
171 | 'id' | |
172 | ); | |
173 | ||
174 | // check if file exists locally | |
175 | $textFileName = implode(DIRECTORY_SEPARATOR, | |
176 | array( | |
177 | $pathName, | |
178 | "{$latestVer}.msg_template", | |
179 | 'message_templates', | |
180 | "{$name}_text.tpl", | |
181 | ) | |
182 | ); | |
183 | ||
184 | $htmlFileName = implode(DIRECTORY_SEPARATOR, | |
185 | array( | |
186 | $pathName, | |
187 | "{$latestVer}.msg_template", | |
188 | 'message_templates', | |
189 | "{$name}_html.tpl", | |
190 | ) | |
191 | ); | |
192 | ||
193 | if (file_exists($textFileName) || | |
194 | file_exists($htmlFileName) | |
195 | ) { | |
196 | $flag = TRUE; | |
197 | $html .= "<li>{$title}</li>"; | |
198 | } | |
199 | } | |
200 | ||
201 | if ($flag == TRUE) { | |
202 | $html = "<ul>" . $html . "<ul>"; | |
203 | ||
353ffa53 TO |
204 | $message .= '<br />' . ts("The default copies of the message templates listed below will be updated to handle new features or correct a problem. Your installation has customized versions of these message templates, and you will need to apply the updates manually after running this upgrade. <a href='%1' style='color:white; text-decoration:underline; font-weight:bold;' target='_blank'>Click here</a> for detailed instructions. %2", array( |
205 | 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', | |
408b79bf | 206 | 2 => $html, |
353ffa53 | 207 | )); |
6a488035 TO |
208 | } |
209 | } | |
210 | ||
211 | /** | |
fe482240 | 212 | * Compute any messages which should be displayed after upgrade. |
6a488035 | 213 | * |
5a4f6742 CW |
214 | * @param string $postUpgradeMessage |
215 | * alterable. | |
216 | * @param string $rev | |
217 | * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs. | |
6a488035 TO |
218 | * @return void |
219 | */ | |
00be9182 | 220 | public static function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { |
6a488035 TO |
221 | if ($rev == '3.2.alpha1') { |
222 | $postUpgradeMessage .= '<br />' . ts("We have reset the COUNTED flag to false for the event participant status 'Pending from incomplete transaction'. This change ensures that people who have a problem during registration can try again."); | |
223 | } | |
224 | if ($rev == '3.2.beta3') { | |
225 | $subTypes = CRM_Contact_BAO_ContactType::subTypes(); | |
226 | ||
227 | if (is_array($subTypes) && !empty($subTypes)) { | |
228 | $config = CRM_Core_Config::singleton(); | |
229 | $subTypeTemplates = array(); | |
230 | ||
231 | if (isset($config->customTemplateDir)) { | |
232 | foreach ($subTypes as $key => $subTypeName) { | |
233 | $customContactSubTypeEdit = $config->customTemplateDir . "CRM/Contact/Form/Edit/" . $subTypeName . ".tpl"; | |
234 | $customContactSubTypeView = $config->customTemplateDir . "CRM/Contact/Page/View/" . $subTypeName . ".tpl"; | |
235 | if (file_exists($customContactSubTypeEdit) || file_exists($customContactSubTypeView)) { | |
236 | $subTypeTemplates[$subTypeName] = $subTypeName; | |
237 | } | |
238 | } | |
239 | } | |
240 | ||
241 | foreach ($subTypes as $key => $subTypeName) { | |
242 | $customContactSubTypeEdit = $config->templateDir . "CRM/Contact/Form/Edit/" . $subTypeName . ".tpl"; | |
243 | $customContactSubTypeView = $config->templateDir . "CRM/Contact/Page/View/" . $subTypeName . ".tpl"; | |
244 | if (file_exists($customContactSubTypeEdit) || file_exists($customContactSubTypeView)) { | |
245 | $subTypeTemplates[$subTypeName] = $subTypeName; | |
246 | } | |
247 | } | |
248 | ||
249 | if (!empty($subTypeTemplates)) { | |
250 | $subTypeTemplates = implode(',', $subTypeTemplates); | |
353ffa53 TO |
251 | $postUpgradeMessage .= '<br />' . ts('You are using custom template for contact subtypes: %1.', array(1 => $subTypeTemplates)) . '<br />' . ts('You need to move these subtype templates to the SubType directory in %1 and %2 respectively.', array( |
252 | 1 => 'CRM/Contact/Form/Edit', | |
408b79bf | 253 | 2 => 'CRM/Contact/Page/View', |
353ffa53 | 254 | )); |
6a488035 TO |
255 | } |
256 | } | |
257 | } | |
258 | if ($rev == '3.2.beta4') { | |
259 | $statuses = array('New', 'Current', 'Grace', 'Expired', 'Pending', 'Cancelled', 'Deceased'); | |
260 | $sql = " | |
10824d34 | 261 | SELECT count( id ) as statusCount |
262 | FROM civicrm_membership_status | |
6a488035 TO |
263 | WHERE name IN ( '" . implode("' , '", $statuses) . "' ) "; |
264 | $count = CRM_Core_DAO::singleValueQuery($sql); | |
265 | if ($count < count($statuses)) { | |
266 | $postUpgradeMessage .= '<br />' . ts("One or more Membership Status Rules was disabled during the upgrade because it did not match a recognized status name. if custom membership status rules were added to this site - review the disabled statuses and re-enable any that are still needed (Administer > CiviMember > Membership Status Rules)."); | |
267 | } | |
268 | } | |
269 | if ($rev == '3.4.alpha1') { | |
270 | $renamedBinScripts = array( | |
271 | 'ParticipantProcessor.php', | |
272 | 'RespondentProcessor.php', | |
273 | 'UpdateGreeting.php', | |
274 | 'UpdateMembershipRecord.php', | |
275 | 'UpdatePledgeRecord.php ', | |
276 | ); | |
277 | $postUpgradeMessage .= '<br />' . ts('The following files have been renamed to have a ".php" extension instead of a ".php.txt" extension') . ': ' . implode(', ', $renamedBinScripts); | |
278 | } | |
279 | } | |
280 | ||
281 | /** | |
fe482240 | 282 | * Perform an incremental upgrade. |
6a488035 | 283 | * |
5a4f6742 CW |
284 | * @param string $rev |
285 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 286 | */ |
00be9182 | 287 | public static function upgrade_2_2_alpha1($rev) { |
6a488035 TO |
288 | for ($stepID = 1; $stepID <= 4; $stepID++) { |
289 | $formName = "CRM_Upgrade_TwoTwo_Form_Step{$stepID}"; | |
4d5c2eb5 | 290 | $form = new $formName(); |
6a488035 TO |
291 | |
292 | $error = NULL; | |
293 | if (!$form->verifyPreDBState($error)) { | |
294 | if (!isset($error)) { | |
295 | $error = "pre-condition failed for current upgrade step $stepID, rev $rev"; | |
296 | } | |
297 | CRM_Core_Error::fatal($error); | |
298 | } | |
299 | ||
300 | if ($stepID == 4) { | |
301 | return; | |
302 | } | |
303 | ||
304 | $template = CRM_Core_Smarty::singleton(); | |
305 | ||
306 | $eventFees = array(); | |
353ffa53 TO |
307 | $query = "SELECT og.id ogid FROM civicrm_option_group og WHERE og.name LIKE %1"; |
308 | $params = array(1 => array('civicrm_event_page.amount%', 'String')); | |
309 | $dao = CRM_Core_DAO::executeQuery($query, $params); | |
6a488035 TO |
310 | while ($dao->fetch()) { |
311 | $eventFees[$dao->ogid] = $dao->ogid; | |
312 | } | |
313 | $template->assign('eventFees', $eventFees); | |
314 | ||
315 | $form->upgrade(); | |
316 | ||
317 | if (!$form->verifyPostDBState($error)) { | |
318 | if (!isset($error)) { | |
319 | $error = "post-condition failed for current upgrade step $stepID, rev $rev"; | |
320 | } | |
321 | CRM_Core_Error::fatal($error); | |
322 | } | |
323 | } | |
324 | } | |
325 | ||
326 | /** | |
fe482240 | 327 | * Perform an incremental upgrade. |
6a488035 | 328 | * |
5a4f6742 CW |
329 | * @param string $rev |
330 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 331 | */ |
00be9182 | 332 | public static function upgrade_2_1_2($rev) { |
6a488035 | 333 | $formName = "CRM_Upgrade_TwoOne_Form_TwoOneTwo"; |
4d5c2eb5 | 334 | $form = new $formName($rev); |
6a488035 TO |
335 | |
336 | $error = NULL; | |
337 | if (!$form->verifyPreDBState($error)) { | |
338 | if (!isset($error)) { | |
339 | $error = "pre-condition failed for current upgrade for $rev"; | |
340 | } | |
341 | CRM_Core_Error::fatal($error); | |
342 | } | |
343 | ||
344 | $form->upgrade(); | |
345 | ||
346 | if (!$form->verifyPostDBState($error)) { | |
347 | if (!isset($error)) { | |
348 | $error = "post-condition failed for current upgrade for $rev"; | |
349 | } | |
350 | CRM_Core_Error::fatal($error); | |
351 | } | |
352 | } | |
353 | ||
354 | /** | |
fe482240 | 355 | * This function should check if if need to skip current sql file. |
6a488035 | 356 | * Name of this function will change according to the latest release |
6a488035 | 357 | */ |
00be9182 | 358 | public static function upgrade_2_2_alpha3($rev) { |
6a488035 TO |
359 | // skip processing sql file, if fresh install - |
360 | if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'mail_protocol', 'id', 'name')) { | |
361 | $upgrade = new CRM_Upgrade_Form(); | |
362 | $upgrade->processSQL($rev); | |
363 | } | |
364 | return TRUE; | |
365 | } | |
366 | ||
367 | /** | |
fe482240 | 368 | * Perform an incremental upgrade. |
6a488035 | 369 | * |
5a4f6742 CW |
370 | * @param string $rev |
371 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 372 | */ |
00be9182 | 373 | public static function upgrade_2_2_beta1($rev) { |
6a488035 TO |
374 | if (!CRM_Core_DAO::checkFieldExists('civicrm_pcp_block', 'notify_email')) { |
375 | $template = CRM_Core_Smarty::singleton(); | |
376 | $template->assign('notifyAbsent', TRUE); | |
377 | } | |
378 | $upgrade = new CRM_Upgrade_Form(); | |
379 | $upgrade->processSQL($rev); | |
380 | } | |
381 | ||
382 | /** | |
fe482240 | 383 | * Perform an incremental upgrade. |
6a488035 | 384 | * |
5a4f6742 CW |
385 | * @param string $rev |
386 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 387 | */ |
00be9182 | 388 | public static function upgrade_2_2_beta2($rev) { |
6a488035 TO |
389 | $template = CRM_Core_Smarty::singleton(); |
390 | if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', | |
353ffa53 TO |
391 | 'CRM_Contact_Form_Search_Custom_ZipCodeRange', 'id', 'name' |
392 | ) | |
393 | ) { | |
6a488035 TO |
394 | $template->assign('customSearchAbsentAll', TRUE); |
395 | } | |
396 | elseif (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', | |
353ffa53 TO |
397 | 'CRM_Contact_Form_Search_Custom_MultipleValues', 'id', 'name' |
398 | ) | |
399 | ) { | |
6a488035 TO |
400 | $template->assign('customSearchAbsent', TRUE); |
401 | } | |
402 | $upgrade = new CRM_Upgrade_Form(); | |
403 | $upgrade->processSQL($rev); | |
404 | } | |
405 | ||
406 | /** | |
fe482240 | 407 | * Perform an incremental upgrade. |
6a488035 | 408 | * |
5a4f6742 CW |
409 | * @param string $rev |
410 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 411 | */ |
00be9182 | 412 | public static function upgrade_2_2_beta3($rev) { |
6a488035 TO |
413 | $template = CRM_Core_Smarty::singleton(); |
414 | if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'custom_data_type', 'id', 'name')) { | |
415 | $template->assign('customDataType', TRUE); | |
416 | } | |
417 | ||
418 | $upgrade = new CRM_Upgrade_Form(); | |
419 | $upgrade->processSQL($rev); | |
420 | } | |
421 | ||
422 | /** | |
fe482240 | 423 | * Perform an incremental upgrade. |
6a488035 | 424 | * |
5a4f6742 CW |
425 | * @param string $rev |
426 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 427 | */ |
00be9182 | 428 | public static function upgrade_3_0_alpha1($rev) { |
6a488035 TO |
429 | |
430 | $threeZero = new CRM_Upgrade_ThreeZero_ThreeZero(); | |
431 | ||
432 | $error = NULL; | |
433 | if (!$threeZero->verifyPreDBState($error)) { | |
434 | if (!isset($error)) { | |
435 | $error = 'pre-condition failed for current upgrade for 3.0.alpha2'; | |
436 | } | |
437 | CRM_Core_Error::fatal($error); | |
438 | } | |
439 | ||
440 | $threeZero->upgrade($rev); | |
441 | } | |
442 | ||
443 | /** | |
fe482240 | 444 | * Perform an incremental upgrade. |
6a488035 | 445 | * |
5a4f6742 CW |
446 | * @param string $rev |
447 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 448 | */ |
00be9182 | 449 | public static function upgrade_3_1_alpha1($rev) { |
6a488035 TO |
450 | |
451 | $threeOne = new CRM_Upgrade_ThreeOne_ThreeOne(); | |
452 | ||
453 | $error = NULL; | |
454 | if (!$threeOne->verifyPreDBState($error)) { | |
455 | if (!isset($error)) { | |
456 | $error = 'pre-condition failed for current upgrade for 3.0.alpha2'; | |
457 | } | |
458 | CRM_Core_Error::fatal($error); | |
459 | } | |
460 | ||
461 | $threeOne->upgrade($rev); | |
462 | } | |
463 | ||
464 | /** | |
fe482240 | 465 | * Perform an incremental upgrade. |
6a488035 | 466 | * |
5a4f6742 CW |
467 | * @param string $rev |
468 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 469 | */ |
00be9182 | 470 | public static function upgrade_2_2_7($rev) { |
6a488035 TO |
471 | $upgrade = new CRM_Upgrade_Form(); |
472 | $upgrade->processSQL($rev); | |
10824d34 | 473 | $sql = "UPDATE civicrm_report_instance |
6a488035 TO |
474 | SET form_values = REPLACE(form_values,'#',';') "; |
475 | CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray); | |
476 | ||
477 | // make report component enabled by default | |
478 | $domain = new CRM_Core_DAO_Domain(); | |
479 | $domain->selectAdd(); | |
480 | $domain->selectAdd('config_backend'); | |
481 | $domain->find(TRUE); | |
482 | if ($domain->config_backend) { | |
483 | $defaults = unserialize($domain->config_backend); | |
484 | ||
485 | if (is_array($defaults['enableComponents'])) { | |
486 | $compId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_component WHERE name = 'CiviReport'"); | |
487 | if ($compId) { | |
488 | $defaults['enableComponents'][] = 'CiviReport'; | |
489 | $defaults['enableComponentIDs'][] = $compId; | |
490 | ||
491 | CRM_Core_BAO_ConfigSetting::add($defaults); | |
492 | } | |
493 | } | |
494 | } | |
495 | } | |
496 | ||
497 | /** | |
fe482240 | 498 | * Perform an incremental upgrade. |
6a488035 | 499 | * |
5a4f6742 CW |
500 | * @param string $rev |
501 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 502 | */ |
00be9182 | 503 | public static function upgrade_3_0_2($rev) { |
6a488035 TO |
504 | |
505 | $template = CRM_Core_Smarty::singleton(); | |
506 | //check whether upgraded from 2.1.x or 2.2.x | |
507 | $inboundEmailID = CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'); | |
508 | ||
509 | if (!empty($inboundEmailID)) { | |
510 | $template->assign('addInboundEmail', FALSE); | |
511 | } | |
512 | else { | |
513 | $template->assign('addInboundEmail', TRUE); | |
514 | } | |
515 | ||
516 | $upgrade = new CRM_Upgrade_Form(); | |
517 | $upgrade->processSQL($rev); | |
518 | } | |
519 | ||
520 | /** | |
fe482240 | 521 | * Perform an incremental upgrade. |
6a488035 | 522 | * |
5a4f6742 CW |
523 | * @param string $rev |
524 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 525 | */ |
00be9182 | 526 | public static function upgrade_3_0_4($rev) { |
6a488035 TO |
527 | //make sure 'Deceased' membership status present in db,CRM-5636 |
528 | $template = CRM_Core_Smarty::singleton(); | |
529 | ||
530 | $addDeceasedStatus = FALSE; | |
531 | $sql = "SELECT max(id) FROM civicrm_membership_status where name = 'Deceased'"; | |
532 | if (!CRM_Core_DAO::singleValueQuery($sql)) { | |
533 | $addDeceasedStatus = TRUE; | |
534 | } | |
535 | $template->assign('addDeceasedStatus', $addDeceasedStatus); | |
536 | ||
537 | $upgrade = new CRM_Upgrade_Form(); | |
538 | $upgrade->processSQL($rev); | |
539 | } | |
540 | ||
541 | /** | |
fe482240 | 542 | * Perform an incremental upgrade. |
6a488035 | 543 | * |
5a4f6742 CW |
544 | * @param string $rev |
545 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 546 | */ |
00be9182 | 547 | public static function upgrade_3_1_0($rev) { |
6a488035 TO |
548 | // upgrade all roles who have 'access CiviEvent' permission, to also have |
549 | // newly added permission 'edit_all_events', CRM-5472 | |
550 | $config = CRM_Core_Config::singleton(); | |
551 | if (is_callable(array( | |
353ffa53 | 552 | $config->userSystem, |
408b79bf | 553 | 'replacePermission', |
353ffa53 | 554 | ))) { |
6a488035 TO |
555 | $config->userSystem->replacePermission('access CiviEvent', array('access CiviEvent', 'edit all events')); |
556 | } | |
557 | ||
558 | //make sure 'Deceased' membership status present in db,CRM-5636 | |
559 | $template = CRM_Core_Smarty::singleton(); | |
560 | ||
561 | $addDeceasedStatus = FALSE; | |
562 | $sql = "SELECT max(id) FROM civicrm_membership_status where name = 'Deceased'"; | |
563 | if (!CRM_Core_DAO::singleValueQuery($sql)) { | |
564 | $addDeceasedStatus = TRUE; | |
565 | } | |
566 | $template->assign('addDeceasedStatus', $addDeceasedStatus); | |
567 | ||
568 | $upgrade = new CRM_Upgrade_Form(); | |
569 | $upgrade->processSQL($rev); | |
570 | } | |
571 | ||
572 | /** | |
fe482240 | 573 | * Perform an incremental upgrade. |
6a488035 | 574 | * |
5a4f6742 CW |
575 | * @param string $rev |
576 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 577 | */ |
00be9182 | 578 | public static function upgrade_3_1_3($rev) { |
6a488035 TO |
579 | $threeOne = new CRM_Upgrade_ThreeOne_ThreeOne(); |
580 | $threeOne->upgrade_3_1_3(); | |
581 | ||
582 | $upgrade = new CRM_Upgrade_Form(); | |
583 | $upgrade->processSQL($rev); | |
584 | } | |
585 | ||
586 | /** | |
fe482240 | 587 | * Perform an incremental upgrade. |
6a488035 | 588 | * |
5a4f6742 CW |
589 | * @param string $rev |
590 | * the revision to which we are upgrading (Note: When processing a series of upgrades, this is the immediate upgrade - not the final). | |
6a488035 | 591 | */ |
00be9182 | 592 | public static function upgrade_3_1_4($rev) { |
6a488035 TO |
593 | $threeOne = new CRM_Upgrade_ThreeOne_ThreeOne(); |
594 | $threeOne->upgrade_3_1_4(); | |
595 | ||
596 | $upgrade = new CRM_Upgrade_Form(); | |
597 | $upgrade->processSQL($rev); | |
598 | } | |
96025800 | 599 | |
6a488035 | 600 | } |