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