CRM-16860 - Remove upgrade code < 4.1
[civicrm-core.git] / CRM / Upgrade / Incremental / Legacy.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
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 */
40class 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
6a488035 54 // check for changed message templates
221997c6 55 self::checkMessageTemplate($template, $preUpgradeMessage, $latestVer, $currentVer);
fde21984 56
7abafcbc
TO
57 // http://issues.civicrm.org/jira/browse/CRM-13572
58 // Depending on how the code was upgraded, some sites may still have copies of old
59 // source files left behind. This is often a forgivable offense, but it's quite
60 // dangerous for CIVI-SA-2013-001.
fde21984
TO
61 global $civicrm_root;
62 $ofcFile = "$civicrm_root/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php";
63 if (file_exists($ofcFile)) {
7abafcbc
TO
64 if (@unlink($ofcFile)) {
65 $preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', array(
353ffa53
TO
66 1 => $ofcFile,
67 ));
0db6c3e1
TO
68 }
69 else {
7abafcbc 70 $preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', array(
353ffa53
TO
71 1 => $ofcFile,
72 ));
7abafcbc 73 }
fde21984 74 }
f3103b87 75
56c2750b 76 if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'enable_innodb_fts', NULL, FALSE)) {
f3103b87
TO
77 // The FTS indexing feature dynamically manipulates the schema which could
78 // cause conflicts with other layers that manipulate the schema. The
79 // simplest thing is to turn it off and back on.
80
81 // It may not always be necessary to do this -- but I doubt we're going to test
82 // systematically in future releases. When it is necessary, one could probably
83 // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences
84 // after the upgrade. But that's speculative. For now, we'll leave this
85 // advanced feature in the hands of the sysadmin.
86 $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".');
87 }
6a488035
TO
88 }
89
624e56fa
EM
90 /**
91 * @param $template
92 * @param $message
93 * @param $latestVer
94 * @param $currentVer
95 */
00be9182 96 public static function checkMessageTemplate(&$template, &$message, $latestVer, $currentVer) {
6a488035
TO
97
98 $sql = "SELECT orig.workflow_id as workflow_id,
99 orig.msg_title as title
100 FROM civicrm_msg_template diverted JOIN civicrm_msg_template orig ON (
101 diverted.workflow_id = orig.workflow_id AND
102 orig.is_reserved = 1 AND (
103 diverted.msg_subject != orig.msg_subject OR
104 diverted.msg_text != orig.msg_text OR
105 diverted.msg_html != orig.msg_html
106 )
107 )";
108
109 $dao = &CRM_Core_DAO::executeQuery($sql);
110 while ($dao->fetch()) {
111 $workflows[$dao->workflow_id] = $dao->title;
112 }
113
114 if (empty($workflows)) {
115 return;
116 }
117
353ffa53 118 $html = NULL;
6a488035 119 $pathName = dirname(dirname(__FILE__));
353ffa53 120 $flag = FALSE;
6a488035
TO
121 foreach ($workflows as $workflow => $title) {
122 $name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue',
123 $workflow,
124 'name',
125 'id'
126 );
127
128 // check if file exists locally
129 $textFileName = implode(DIRECTORY_SEPARATOR,
130 array(
131 $pathName,
132 "{$latestVer}.msg_template",
133 'message_templates',
134 "{$name}_text.tpl",
135 )
136 );
137
138 $htmlFileName = implode(DIRECTORY_SEPARATOR,
139 array(
140 $pathName,
141 "{$latestVer}.msg_template",
142 'message_templates',
143 "{$name}_html.tpl",
144 )
145 );
146
147 if (file_exists($textFileName) ||
148 file_exists($htmlFileName)
149 ) {
150 $flag = TRUE;
151 $html .= "<li>{$title}</li>";
152 }
153 }
154
155 if ($flag == TRUE) {
156 $html = "<ul>" . $html . "<ul>";
157
353ffa53
TO
158 $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(
159 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates',
408b79bf 160 2 => $html,
353ffa53 161 ));
6a488035
TO
162 }
163 }
164
6a488035 165}