3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
30 * @copyright CiviCRM LLC (c) 2004-2014
34 class CRM_Upgrade_Incremental_php_ThreeTwo
{
40 function verifyPreDBstate(&$errors) {
47 function upgrade_3_2_alpha1($rev) {
48 //CRM-5666 -if user already have 'access CiviCase'
49 //give all new permissions and drop access CiviCase.
50 $config = CRM_Core_Config
::singleton();
51 if ($config->userSystem
->is_drupal
) {
53 $config->userSystem
->replacePermission('access CiviCase', array('access my cases and activities', 'access all cases and activities', 'administer CiviCase'));
56 $casePermissions = array(
58 'administer CiviCase',
59 'access my cases and activities',
60 'access all cases and activities',
71 'entity_table' => 'civicrm_acl_role',
73 foreach ($casePermissions as $per) {
74 $aclParams['object_table'] = $per;
75 $acl = new CRM_ACL_DAO_ACL();
76 $acl->object_table
= $per;
77 if (!$acl->find(TRUE)) {
78 $acl->copyValues($aclParams);
82 //drop 'access CiviCase' acl
83 CRM_Core_DAO
::executeQuery("DELETE FROM civicrm_acl WHERE object_table = 'access CiviCase'");
86 $upgrade = new CRM_Upgrade_Form();
87 $upgrade->processSQL($rev);
93 function upgrade_3_2_beta4($rev) {
94 $upgrade = new CRM_Upgrade_Form
;
96 $config = CRM_Core_Config
::singleton();
97 $seedLocale = $config->lcMessages
;
99 //handle missing civicrm_uf_field.help_pre
100 $hasLocalizedPreHelpCols = FALSE;
102 // CRM-6451: for multilingual sites we need to find the optimal
103 // locale to use as the final civicrm_membership_status.name column
104 $domain = new CRM_Core_DAO_Domain
;
107 if ($domain->locales
) {
108 $locales = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $domain->locales
);
109 // optimal: an English locale
111 'en_US', 'en_GB', 'en_AU') as $loc) {
112 if (in_array($loc, $locales)) {
118 // if no English and no $config->lcMessages: use the first available
120 $seedLocale = $locales[0];
123 $upgrade->assign('seedLocale', $seedLocale);
124 $upgrade->assign('locales', $locales);
126 $localizedColNames = array();
127 foreach ($locales as $loc) {
128 $localizedName = "help_pre_{$loc}";
129 $localizedColNames[$localizedName] = $localizedName;
131 $columns = CRM_Core_DAO
::executeQuery('SHOW COLUMNS FROM civicrm_uf_field');
132 while ($columns->fetch()) {
133 if (strpos($columns->Field
, 'help_pre') !== FALSE &&
134 in_array($columns->Field
, $localizedColNames)
136 $hasLocalizedPreHelpCols = TRUE;
141 $upgrade->assign('hasLocalizedPreHelpCols', $hasLocalizedPreHelpCols);
143 $upgrade->processSQL($rev);
145 // now civicrm_membership_status.name has possibly localised strings, so fix them
146 $i18n = new CRM_Core_I18n($seedLocale);
150 'start_event' => 'join_date',
151 'end_event' => 'join_date',
152 'end_event_adjust_unit' => 'month',
153 'end_event_adjust_interval' => '3',
154 'is_current_member' => '1',
157 'is_reserved' => '0',
161 'start_event' => 'start_date',
162 'end_event' => 'end_date',
163 'is_current_member' => '1',
166 'is_reserved' => '0',
170 'start_event' => 'end_date',
171 'end_event' => 'end_date',
172 'end_event_adjust_unit' => 'month',
173 'end_event_adjust_interval' => '1',
174 'is_current_member' => '1',
177 'is_reserved' => '0',
181 'start_event' => 'end_date',
182 'start_event_adjust_unit' => 'month',
183 'start_event_adjust_interval' => '1',
184 'is_current_member' => '0',
187 'is_reserved' => '0',
191 'start_event' => 'join_date',
192 'end_event' => 'join_date',
193 'is_current_member' => '0',
196 'is_reserved' => '1',
199 'name' => 'Cancelled',
200 'start_event' => 'join_date',
201 'end_event' => 'join_date',
202 'is_current_member' => '0',
205 'is_reserved' => '0',
208 'name' => 'Deceased',
209 'is_current_member' => '0',
212 'is_reserved' => '1',
216 $statusIds = array();
217 $insertedNewRecord = FALSE;
218 foreach ($statuses as $status) {
219 $dao = new CRM_Member_DAO_MembershipStatus
;
221 // try to find an existing English status
222 $dao->name
= $status['name'];
224 // // if not found, look for translated status name
225 // if (!$dao->find(true)) {
227 // $dao->name = $i18n->translate($status['name']);
230 // if found, update name and is_reserved
231 if ($dao->find(TRUE)) {
232 $dao->name
= $status['name'];
233 $dao->is_reserved
= $status['is_reserved'];
234 if ($status['is_reserved']) {
237 // if not found, prepare a new row for insertion
240 $insertedNewRecord = TRUE;
241 foreach ($status as $property => $value) {
242 $dao->$property = $value;
244 $dao->weight
= CRM_Utils_Weight
::getDefaultWeight('CRM_Member_DAO_MembershipStatus');
247 // add label (translated name) and save (UPDATE or INSERT)
248 $dao->label
= $i18n->translate($status['name']);
251 $statusIds[$dao->id
] = $dao->id
;
254 //disable all status those are customs.
255 if ($insertedNewRecord) {
257 UPDATE civicrm_membership_status
259 WHERE id NOT IN ( ' . implode(',', $statusIds) . ' )';
260 CRM_Core_DAO
::executeQuery($sql);
267 function upgrade_3_2_1($rev) {
268 //CRM-6565 check if Activity Index is already exists or not.
269 $addActivityTypeIndex = TRUE;
270 $indexes = CRM_Core_DAO
::executeQuery('SHOW INDEXES FROM civicrm_activity');
271 while ($indexes->fetch()) {
272 if ($indexes->Key_name
== 'UI_activity_type_id') {
273 $addActivityTypeIndex = FALSE;
276 // CRM-6563: restrict access to the upload dir, tighten access to the config-and-log dir
277 $config = CRM_Core_Config
::singleton();
278 CRM_Utils_File
::restrictAccess($config->uploadDir
);
279 CRM_Utils_File
::restrictAccess($config->configAndLogDir
);
280 $upgrade = new CRM_Upgrade_Form
;
281 $upgrade->assign('addActivityTypeIndex', $addActivityTypeIndex);
282 $upgrade->processSQL($rev);