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