3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
34 class CRM_Upgrade_Incremental_php_ThreeTwo
{
35 function verifyPreDBstate(&$errors) {
39 function upgrade_3_2_alpha1($rev) {
40 //CRM-5666 -if user already have 'access CiviCase'
41 //give all new permissions and drop access CiviCase.
42 $config = CRM_Core_Config
::singleton();
43 if ($config->userSystem
->is_drupal
) {
45 $config->userSystem
->replacePermission('access CiviCase', array('access my cases and activities', 'access all cases and activities', 'administer CiviCase'));
48 $casePermissions = array(
50 'administer CiviCase',
51 'access my cases and activities',
52 'access all cases and activities',
63 'entity_table' => 'civicrm_acl_role',
65 foreach ($casePermissions as $per) {
66 $aclParams['object_table'] = $per;
67 $acl = new CRM_ACL_DAO_ACL();
68 $acl->object_table
= $per;
69 if (!$acl->find(TRUE)) {
70 $acl->copyValues($aclParams);
74 //drop 'access CiviCase' acl
75 CRM_Core_DAO
::executeQuery("DELETE FROM civicrm_acl WHERE object_table = 'access CiviCase'");
78 $upgrade = new CRM_Upgrade_Form();
79 $upgrade->processSQL($rev);
82 function upgrade_3_2_beta4($rev) {
83 $upgrade = new CRM_Upgrade_Form
;
85 $config = CRM_Core_Config
::singleton();
86 $seedLocale = $config->lcMessages
;
88 //handle missing civicrm_uf_field.help_pre
89 $hasLocalizedPreHelpCols = FALSE;
91 // CRM-6451: for multilingual sites we need to find the optimal
92 // locale to use as the final civicrm_membership_status.name column
93 $domain = new CRM_Core_DAO_Domain
;
96 if ($domain->locales
) {
97 $locales = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $domain->locales
);
98 // optimal: an English locale
100 'en_US', 'en_GB', 'en_AU') as $loc) {
101 if (in_array($loc, $locales)) {
107 // if no English and no $config->lcMessages: use the first available
109 $seedLocale = $locales[0];
112 $upgrade->assign('seedLocale', $seedLocale);
113 $upgrade->assign('locales', $locales);
115 $localizedColNames = array();
116 foreach ($locales as $loc) {
117 $localizedName = "help_pre_{$loc}";
118 $localizedColNames[$localizedName] = $localizedName;
120 $columns = CRM_Core_DAO
::executeQuery('SHOW COLUMNS FROM civicrm_uf_field');
121 while ($columns->fetch()) {
122 if (strpos($columns->Field
, 'help_pre') !== FALSE &&
123 in_array($columns->Field
, $localizedColNames)
125 $hasLocalizedPreHelpCols = TRUE;
130 $upgrade->assign('hasLocalizedPreHelpCols', $hasLocalizedPreHelpCols);
132 $upgrade->processSQL($rev);
134 // now civicrm_membership_status.name has possibly localised strings, so fix them
135 $i18n = new CRM_Core_I18n($seedLocale);
139 'start_event' => 'join_date',
140 'end_event' => 'join_date',
141 'end_event_adjust_unit' => 'month',
142 'end_event_adjust_interval' => '3',
143 'is_current_member' => '1',
146 'is_reserved' => '0',
150 'start_event' => 'start_date',
151 'end_event' => 'end_date',
152 'is_current_member' => '1',
155 'is_reserved' => '0',
159 'start_event' => 'end_date',
160 'end_event' => 'end_date',
161 'end_event_adjust_unit' => 'month',
162 'end_event_adjust_interval' => '1',
163 'is_current_member' => '1',
166 'is_reserved' => '0',
170 'start_event' => 'end_date',
171 'start_event_adjust_unit' => 'month',
172 'start_event_adjust_interval' => '1',
173 'is_current_member' => '0',
176 'is_reserved' => '0',
180 'start_event' => 'join_date',
181 'end_event' => 'join_date',
182 'is_current_member' => '0',
185 'is_reserved' => '1',
188 'name' => 'Cancelled',
189 'start_event' => 'join_date',
190 'end_event' => 'join_date',
191 'is_current_member' => '0',
194 'is_reserved' => '0',
197 'name' => 'Deceased',
198 'is_current_member' => '0',
201 'is_reserved' => '1',
205 $statusIds = array();
206 $insertedNewRecord = FALSE;
207 foreach ($statuses as $status) {
208 $dao = new CRM_Member_DAO_MembershipStatus
;
210 // try to find an existing English status
211 $dao->name
= $status['name'];
213 // // if not found, look for translated status name
214 // if (!$dao->find(true)) {
216 // $dao->name = $i18n->translate($status['name']);
219 // if found, update name and is_reserved
220 if ($dao->find(TRUE)) {
221 $dao->name
= $status['name'];
222 $dao->is_reserved
= $status['is_reserved'];
223 if ($status['is_reserved']) {
226 // if not found, prepare a new row for insertion
229 $insertedNewRecord = TRUE;
230 foreach ($status as $property => $value) {
231 $dao->$property = $value;
233 $dao->weight
= CRM_Utils_Weight
::getDefaultWeight('CRM_Member_DAO_MembershipStatus');
236 // add label (translated name) and save (UPDATE or INSERT)
237 $dao->label
= $i18n->translate($status['name']);
240 $statusIds[$dao->id
] = $dao->id
;
243 //disable all status those are customs.
244 if ($insertedNewRecord) {
246 UPDATE civicrm_membership_status
248 WHERE id NOT IN ( ' . implode(',', $statusIds) . ' )';
249 CRM_Core_DAO
::executeQuery($sql);
253 function upgrade_3_2_1($rev) {
254 //CRM-6565 check if Activity Index is already exists or not.
255 $addActivityTypeIndex = TRUE;
256 $indexes = CRM_Core_DAO
::executeQuery('SHOW INDEXES FROM civicrm_activity');
257 while ($indexes->fetch()) {
258 if ($indexes->Key_name
== 'UI_activity_type_id') {
259 $addActivityTypeIndex = FALSE;
262 // CRM-6563: restrict access to the upload dir, tighten access to the config-and-log dir
263 $config = CRM_Core_Config
::singleton();
264 CRM_Utils_File
::restrictAccess($config->uploadDir
);
265 CRM_Utils_File
::restrictAccess($config->configAndLogDir
);
266 $upgrade = new CRM_Upgrade_Form
;
267 $upgrade->assign('addActivityTypeIndex', $addActivityTypeIndex);
268 $upgrade->processSQL($rev);