3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 public function verifyPreDBstate(&$errors) {
47 public 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(
54 'access my cases and activities',
55 'access all cases and activities',
60 $casePermissions = array(
62 'administer CiviCase',
63 'access my cases and activities',
64 'access all cases and activities',
75 'entity_table' => 'civicrm_acl_role',
77 foreach ($casePermissions as $per) {
78 $aclParams['object_table'] = $per;
79 $acl = new CRM_ACL_DAO_ACL();
80 $acl->object_table
= $per;
81 if (!$acl->find(TRUE)) {
82 $acl->copyValues($aclParams);
86 //drop 'access CiviCase' acl
87 CRM_Core_DAO
::executeQuery("DELETE FROM civicrm_acl WHERE object_table = 'access CiviCase'");
90 $upgrade = new CRM_Upgrade_Form();
91 $upgrade->processSQL($rev);
97 public function upgrade_3_2_beta4($rev) {
98 $upgrade = new CRM_Upgrade_Form
;
100 $config = CRM_Core_Config
::singleton();
101 $seedLocale = $config->lcMessages
;
103 //handle missing civicrm_uf_field.help_pre
104 $hasLocalizedPreHelpCols = FALSE;
106 // CRM-6451: for multilingual sites we need to find the optimal
107 // locale to use as the final civicrm_membership_status.name column
108 $domain = new CRM_Core_DAO_Domain
;
111 if ($domain->locales
) {
112 $locales = explode(CRM_Core_DAO
::VALUE_SEPARATOR
, $domain->locales
);
113 // optimal: an English locale
119 if (in_array($loc, $locales)) {
125 // if no English and no $config->lcMessages: use the first available
127 $seedLocale = $locales[0];
130 $upgrade->assign('seedLocale', $seedLocale);
131 $upgrade->assign('locales', $locales);
133 $localizedColNames = array();
134 foreach ($locales as $loc) {
135 $localizedName = "help_pre_{$loc}";
136 $localizedColNames[$localizedName] = $localizedName;
138 $columns = CRM_Core_DAO
::executeQuery('SHOW COLUMNS FROM civicrm_uf_field');
139 while ($columns->fetch()) {
140 if (strpos($columns->Field
, 'help_pre') !== FALSE &&
141 in_array($columns->Field
, $localizedColNames)
143 $hasLocalizedPreHelpCols = TRUE;
148 $upgrade->assign('hasLocalizedPreHelpCols', $hasLocalizedPreHelpCols);
150 $upgrade->processSQL($rev);
152 // now civicrm_membership_status.name has possibly localised strings, so fix them
153 $i18n = new CRM_Core_I18n($seedLocale);
157 'start_event' => 'join_date',
158 'end_event' => 'join_date',
159 'end_event_adjust_unit' => 'month',
160 'end_event_adjust_interval' => '3',
161 'is_current_member' => '1',
164 'is_reserved' => '0',
168 'start_event' => 'start_date',
169 'end_event' => 'end_date',
170 'is_current_member' => '1',
173 'is_reserved' => '0',
177 'start_event' => 'end_date',
178 'end_event' => 'end_date',
179 'end_event_adjust_unit' => 'month',
180 'end_event_adjust_interval' => '1',
181 'is_current_member' => '1',
184 'is_reserved' => '0',
188 'start_event' => 'end_date',
189 'start_event_adjust_unit' => 'month',
190 'start_event_adjust_interval' => '1',
191 'is_current_member' => '0',
194 'is_reserved' => '0',
198 'start_event' => 'join_date',
199 'end_event' => 'join_date',
200 'is_current_member' => '0',
203 'is_reserved' => '1',
206 'name' => 'Cancelled',
207 'start_event' => 'join_date',
208 'end_event' => 'join_date',
209 'is_current_member' => '0',
212 'is_reserved' => '0',
215 'name' => 'Deceased',
216 'is_current_member' => '0',
219 'is_reserved' => '1',
223 $statusIds = array();
224 $insertedNewRecord = FALSE;
225 foreach ($statuses as $status) {
226 $dao = new CRM_Member_DAO_MembershipStatus
;
228 // try to find an existing English status
229 $dao->name
= $status['name'];
231 // // if not found, look for translated status name
232 // if (!$dao->find(true)) {
234 // $dao->name = $i18n->translate($status['name']);
237 // if found, update name and is_reserved
238 if ($dao->find(TRUE)) {
239 $dao->name
= $status['name'];
240 $dao->is_reserved
= $status['is_reserved'];
241 if ($status['is_reserved']) {
244 // if not found, prepare a new row for insertion
247 $insertedNewRecord = TRUE;
248 foreach ($status as $property => $value) {
249 $dao->$property = $value;
251 $dao->weight
= CRM_Utils_Weight
::getDefaultWeight('CRM_Member_DAO_MembershipStatus');
254 // add label (translated name) and save (UPDATE or INSERT)
255 $dao->label
= $i18n->translate($status['name']);
258 $statusIds[$dao->id
] = $dao->id
;
261 //disable all status those are customs.
262 if ($insertedNewRecord) {
264 UPDATE civicrm_membership_status
266 WHERE id NOT IN ( ' . implode(',', $statusIds) . ' )';
267 CRM_Core_DAO
::executeQuery($sql);
274 public function upgrade_3_2_1($rev) {
275 //CRM-6565 check if Activity Index is already exists or not.
276 $addActivityTypeIndex = TRUE;
277 $indexes = CRM_Core_DAO
::executeQuery('SHOW INDEXES FROM civicrm_activity');
278 while ($indexes->fetch()) {
279 if ($indexes->Key_name
== 'UI_activity_type_id') {
280 $addActivityTypeIndex = FALSE;
283 // CRM-6563: restrict access to the upload dir, tighten access to the config-and-log dir
284 $config = CRM_Core_Config
::singleton();
285 CRM_Utils_File
::restrictAccess($config->uploadDir
);
286 CRM_Utils_File
::restrictAccess($config->configAndLogDir
);
287 $upgrade = new CRM_Upgrade_Form
;
288 $upgrade->assign('addActivityTypeIndex', $addActivityTypeIndex);
289 $upgrade->processSQL($rev);